@carlonicora/nextjs-jsonapi 4.0.4 → 4.0.5
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/{BlockNoteEditor-BXMTGKDV.js → BlockNoteEditor-H6EXQD46.js} +20 -20
- package/dist/{BlockNoteEditor-BXMTGKDV.js.map → BlockNoteEditor-H6EXQD46.js.map} +1 -1
- package/dist/{BlockNoteEditor-FGVQP35E.mjs → BlockNoteEditor-L3STMBP2.mjs} +5 -5
- package/dist/{BlockNoteViewer-DQYT6IJW.mjs → BlockNoteViewer-4THJHQMK.mjs} +3 -3
- package/dist/{BlockNoteViewer-YH7G66PS.js → BlockNoteViewer-TEC7DN2N.js} +4 -4
- package/dist/{BlockNoteViewer-YH7G66PS.js.map → BlockNoteViewer-TEC7DN2N.js.map} +1 -1
- package/dist/{JsonApiRequest-MEP6AXDT.mjs → JsonApiRequest-A66XK5WT.mjs} +2 -2
- package/dist/JsonApiRequest-FZGPLNUF.js +26 -0
- package/dist/{JsonApiRequest-OB6WL4LA.js.map → JsonApiRequest-FZGPLNUF.js.map} +1 -1
- package/dist/billing/index.js +400 -400
- package/dist/billing/index.mjs +4 -4
- package/dist/{chunk-NFCXUAE6.js → chunk-3JET3LL7.js} +837 -837
- package/dist/{chunk-NFCXUAE6.js.map → chunk-3JET3LL7.js.map} +1 -1
- package/dist/{chunk-6OFANJTE.js → chunk-5PNDDYGL.js} +32 -32
- package/dist/{chunk-6OFANJTE.js.map → chunk-5PNDDYGL.js.map} +1 -1
- package/dist/{chunk-5W5MN7JP.js → chunk-7ZRQOLSV.js} +13 -13
- package/dist/{chunk-5W5MN7JP.js.map → chunk-7ZRQOLSV.js.map} +1 -1
- package/dist/{chunk-TWBZ2GSX.js → chunk-C2WQXUL5.js} +3 -3
- package/dist/{chunk-TWBZ2GSX.js.map → chunk-C2WQXUL5.js.map} +1 -1
- package/dist/{chunk-JEQ34Z5E.js → chunk-DYTKNSHY.js} +15 -15
- package/dist/{chunk-JEQ34Z5E.js.map → chunk-DYTKNSHY.js.map} +1 -1
- package/dist/{chunk-WGVNJXZO.js → chunk-GHE4VT2R.js} +12 -12
- package/dist/{chunk-WGVNJXZO.js.map → chunk-GHE4VT2R.js.map} +1 -1
- package/dist/{chunk-3CZ2GK5R.mjs → chunk-IOG22OAO.mjs} +3 -3
- package/dist/{chunk-WJC4SYRL.mjs → chunk-KX2776OK.mjs} +8 -8
- package/dist/{chunk-R6ZYB4VN.mjs → chunk-RDI62FAT.mjs} +2 -2
- package/dist/{chunk-7SCREMTX.mjs → chunk-V5MI7RNB.mjs} +2 -2
- package/dist/chunk-V5MI7RNB.mjs.map +1 -0
- package/dist/{chunk-ADZSH3MG.mjs → chunk-XTOEN5GN.mjs} +3 -3
- package/dist/{chunk-AQZ3T4BR.mjs → chunk-Z3226FM6.mjs} +5 -5
- package/dist/client/index.js +5 -5
- package/dist/client/index.mjs +4 -4
- package/dist/components/index.js +5 -5
- package/dist/components/index.mjs +4 -4
- package/dist/contexts/index.js +5 -5
- package/dist/contexts/index.mjs +4 -4
- package/dist/core/index.js +3 -3
- package/dist/core/index.mjs +2 -2
- package/dist/features/analytics/index.js +123 -123
- package/dist/features/analytics/index.mjs +5 -5
- package/dist/features/analytics/server.js +5 -5
- package/dist/features/analytics/server.mjs +3 -3
- package/dist/features/help/index.js +38 -38
- package/dist/features/help/index.mjs +4 -4
- package/dist/features/tokenusage/index.js +126 -126
- package/dist/features/tokenusage/index.mjs +5 -5
- package/dist/index.js +4 -4
- package/dist/index.mjs +3 -3
- package/dist/server/index.js +4 -4
- package/dist/server/index.mjs +3 -3
- package/package.json +1 -1
- package/src/core/utils/__tests__/translateResponse.test.ts +17 -0
- package/src/core/utils/translateResponse.ts +7 -3
- package/dist/JsonApiRequest-OB6WL4LA.js +0 -26
- package/dist/chunk-7SCREMTX.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-FGVQP35E.mjs.map → BlockNoteEditor-L3STMBP2.mjs.map} +0 -0
- /package/dist/{BlockNoteViewer-DQYT6IJW.mjs.map → BlockNoteViewer-4THJHQMK.mjs.map} +0 -0
- /package/dist/{JsonApiRequest-MEP6AXDT.mjs.map → JsonApiRequest-A66XK5WT.mjs.map} +0 -0
- /package/dist/{chunk-3CZ2GK5R.mjs.map → chunk-IOG22OAO.mjs.map} +0 -0
- /package/dist/{chunk-WJC4SYRL.mjs.map → chunk-KX2776OK.mjs.map} +0 -0
- /package/dist/{chunk-R6ZYB4VN.mjs.map → chunk-RDI62FAT.mjs.map} +0 -0
- /package/dist/{chunk-ADZSH3MG.mjs.map → chunk-XTOEN5GN.mjs.map} +0 -0
- /package/dist/{chunk-AQZ3T4BR.mjs.map → chunk-Z3226FM6.mjs.map} +0 -0
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunk5PNDDYGLjs = require('./chunk-5PNDDYGL.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkGHE4VT2Rjs = require('./chunk-GHE4VT2R.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
|
|
@@ -35,7 +35,7 @@ function configureJsonApi(config) {
|
|
|
35
35
|
_setStaticHelpContent(helpContent);
|
|
36
36
|
}
|
|
37
37
|
if (config.bootstrapper) {
|
|
38
|
-
|
|
38
|
+
_chunkGHE4VT2Rjs.setBootstrapper.call(void 0, config.bootstrapper);
|
|
39
39
|
config.bootstrapper();
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -48,19 +48,19 @@ function getApiUrl() {
|
|
|
48
48
|
if (_optionalChain([_clientConfig, 'optionalAccess', _ => _.apiUrl])) {
|
|
49
49
|
return _clientConfig.apiUrl;
|
|
50
50
|
}
|
|
51
|
-
return
|
|
51
|
+
return _chunkGHE4VT2Rjs.ENV.API_URL;
|
|
52
52
|
}
|
|
53
53
|
_chunk7QVYU63Ejs.__name.call(void 0, getApiUrl, "getApiUrl");
|
|
54
54
|
function getPublicApiUrl() {
|
|
55
|
-
return
|
|
55
|
+
return _chunkGHE4VT2Rjs.ENV.API_URL;
|
|
56
56
|
}
|
|
57
57
|
_chunk7QVYU63Ejs.__name.call(void 0, getPublicApiUrl, "getPublicApiUrl");
|
|
58
58
|
function getAppUrl() {
|
|
59
59
|
if (_optionalChain([_clientConfig, 'optionalAccess', _2 => _2.appUrl])) {
|
|
60
60
|
return _clientConfig.appUrl;
|
|
61
61
|
}
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
62
|
+
if (_chunkGHE4VT2Rjs.ENV.APP_URL_ALTERNATE) {
|
|
63
|
+
return _chunkGHE4VT2Rjs.ENV.APP_URL_ALTERNATE;
|
|
64
64
|
}
|
|
65
65
|
if (typeof window !== "undefined") {
|
|
66
66
|
return window.location.origin;
|
|
@@ -151,7 +151,7 @@ var COMPANY_ADMINISTRATOR_ROLE_ID = "2e1eee00-6cba-4506-9059-ccd24e4ea5b0";
|
|
|
151
151
|
var ACTION_TYPES = ["read", "create", "update", "delete"];
|
|
152
152
|
|
|
153
153
|
// src/features/rbac/data/RbacService.ts
|
|
154
|
-
var RbacService = class extends
|
|
154
|
+
var RbacService = class extends _chunk5PNDDYGLjs.AbstractService {
|
|
155
155
|
static {
|
|
156
156
|
_chunk7QVYU63Ejs.__name.call(void 0, this, "RbacService");
|
|
157
157
|
}
|
|
@@ -162,9 +162,9 @@ var RbacService = class extends _chunk6OFANJTEjs.AbstractService {
|
|
|
162
162
|
* Dev-only endpoint — see class header.
|
|
163
163
|
*/
|
|
164
164
|
static async fetchMatrix() {
|
|
165
|
-
const endpoint = new (0,
|
|
165
|
+
const endpoint = new (0, _chunk5PNDDYGLjs.EndpointCreator)({ endpoint: _chunk5PNDDYGLjs.Modules.RbacMatrix }).generate();
|
|
166
166
|
const model = await this.callApi({
|
|
167
|
-
type:
|
|
167
|
+
type: _chunk5PNDDYGLjs.Modules.RbacMatrix,
|
|
168
168
|
method: "GET" /* GET */,
|
|
169
169
|
endpoint
|
|
170
170
|
});
|
|
@@ -184,9 +184,9 @@ var RbacService = class extends _chunk6OFANJTEjs.AbstractService {
|
|
|
184
184
|
* Dev-only endpoint — see class header.
|
|
185
185
|
*/
|
|
186
186
|
static async saveMatrix(args) {
|
|
187
|
-
const endpoint = new (0,
|
|
187
|
+
const endpoint = new (0, _chunk5PNDDYGLjs.EndpointCreator)({ endpoint: _chunk5PNDDYGLjs.Modules.RbacMatrix }).generate();
|
|
188
188
|
const model = await this.callApi({
|
|
189
|
-
type:
|
|
189
|
+
type: _chunk5PNDDYGLjs.Modules.RbacMatrix,
|
|
190
190
|
method: "PUT" /* PUT */,
|
|
191
191
|
endpoint,
|
|
192
192
|
input: args
|
|
@@ -222,4 +222,4 @@ var RbacService = class extends _chunk6OFANJTEjs.AbstractService {
|
|
|
222
222
|
|
|
223
223
|
|
|
224
224
|
exports._getStaticHelpContent = _getStaticHelpContent; exports.configureJsonApi = configureJsonApi; exports.configureClientConfig = configureClientConfig; exports.getApiUrl = getApiUrl; exports.getPublicApiUrl = getPublicApiUrl; exports.getAppUrl = getAppUrl; exports.getTrackablePages = getTrackablePages; exports.getStripePublishableKey = getStripePublishableKey; exports.configureLogin = configureLogin; exports.isDiscordAuthEnabled = isDiscordAuthEnabled; exports.isGoogleAuthEnabled = isGoogleAuthEnabled; exports.isInternalAuthEnabled = isInternalAuthEnabled; exports.isRegistrationAllowed = isRegistrationAllowed; exports.getRegistrationMode = getRegistrationMode; exports.configureWaitlist = configureWaitlist; exports.getWaitlistConfig = getWaitlistConfig; exports.configureReferral = configureReferral; exports.getReferralConfig = getReferralConfig; exports.isReferralEnabled = isReferralEnabled; exports.COMPANY_ADMINISTRATOR_ROLE_ID = COMPANY_ADMINISTRATOR_ROLE_ID; exports.ACTION_TYPES = ACTION_TYPES; exports.RbacService = RbacService;
|
|
225
|
-
//# sourceMappingURL=chunk-
|
|
225
|
+
//# sourceMappingURL=chunk-7ZRQOLSV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-5W5MN7JP.js","../src/core/registry/helpStore.ts","../src/client/config.ts","../src/login/config.ts","../src/features/waitlist/config/waitlist.config.ts","../src/features/referral/config.ts","../src/features/rbac/data/RbacTypes.ts","../src/features/rbac/data/RbacService.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACFA,IAAM,iBAAA,kBAAmB,MAAA,CAAO,GAAA,CAAI,4BAA4B,CAAA;AAEhE,IAAM,YAAA,EAAc,UAAA;AAIpB,GAAA,CAAI,WAAA,CAAY,gBAAgB,EAAA,IAAM,KAAA,CAAA,EAAW;AAC/C,EAAA,WAAA,CAAY,gBAAgB,EAAA,EAAI,IAAA;AAClC;AAEO,SAAS,qBAAA,CAAsB,GAAA,EAA2B;AAC/D,EAAA,WAAA,CAAY,gBAAgB,EAAA,EAAI,GAAA;AAClC;AAFgB,qCAAA,qBAAA,EAAA,uBAAA,CAAA;AAIT,SAAS,qBAAA,CAAA,EAA+C;AAC7D,EAAA,wBAAQ,WAAA,CAAY,gBAAgB,CAAA,UAAkB,MAAA;AACxD;AAFgB,qCAAA,qBAAA,EAAA,uBAAA,CAAA;ADEhB;AACA;AEnBA,IAAI,cAAA,EAOO,IAAA;AAOJ,SAAS,gBAAA,CAAiB,MAAA,EAQxB;AACP,EAAA,MAAM,EAAE,WAAA,EAAa,GAAG,KAAK,EAAA,EAAI,MAAA;AACjC,EAAA,cAAA,EAAgB,IAAA;AAChB,EAAA,GAAA,CAAI,WAAA,EAAa;AACf,IAAA,qBAAA,CAAsB,WAAW,CAAA;AAAA,EACnC;AAEA,EAAA,GAAA,CAAI,MAAA,CAAO,YAAA,EAAc;AACvB,IAAA,8CA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W,CAAC,CAAA,CAAE,QAAA,CAAS,CAAA;AAEhF,IAAA,MAAM,MAAA,EAAQ,MAAM,IAAA,CAAK,OAAA,CAAyB;AAAA,MAChD,IAAA,EAAM,wBAAA,CAAQ,UAAA;AAAA,MACd,MAAA,EAAA,eAAA;AAAA,MACA;AAAA,IACF,CAAC,CAAA;AAED,IAAA,OAAO;AAAA,MACL,MAAA,mBAAQ,KAAA,CAAM,MAAA,UAAU,CAAC,GAAA;AAAA,MACzB,WAAA,mBAAa,KAAA,CAAM,WAAA,UAAe,CAAC;AAAA,IACrC,CAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,OAAA,MAAa,UAAA,CAAW,IAAA,EAK4B;AAClD,IAAA,MAAM,SAAA,EAAW,IAAI,qCAAA,CAAgB,EAAE,QAAA,EAAU,wBAAA,CAAQ,WAAW,CAAC,CAAA,CAAE,QAAA,CAAS,CAAA;AAEhF,IAAA,MAAM,MAAA,EAAQ,MAAM,IAAA,CAAK,OAAA,CAAyB;AAAA,MAChD,IAAA,EAAM,wBAAA,CAAQ,UAAA;AAAA,MACd,MAAA,EAAA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,KAAA,EAAO;AAAA,IACT,CAAC,CAAA;AAED,IAAA,OAAO;AAAA,MACL,YAAA,mBAAc,KAAA,CAAM,YAAA,UAAgB,GAAA;AAAA,MACpC,IAAA,mBAAM,KAAA,CAAM,IAAA,UAAQ;AAAA,IACtB,CAAA;AAAA,EACF;AACF,CAAA;AP6HA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yhCAAC","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-5W5MN7JP.js","sourcesContent":[null,"/**\n * Centralized help-content store accessible from client and server contexts.\n * Uses a globalThis Symbol key to persist across HMR/Turbopack reloads and to\n * bridge between the client-side `configureJsonApi` (in `client/config.ts`)\n * and the HelpProvider context. Holds the brand-only HelpContentConfig.\n *\n * NO external dependencies to avoid circular imports.\n *\n * Pattern mirrors `bootstrapStore.ts`.\n */\n\nconst HELP_CONTENT_KEY = Symbol.for(\"nextjs-jsonapi:helpContent\");\n\nconst globalStore = globalThis as unknown as {\n [HELP_CONTENT_KEY]?: unknown | null;\n};\n\nif (globalStore[HELP_CONTENT_KEY] === undefined) {\n globalStore[HELP_CONTENT_KEY] = null;\n}\n\nexport function _setStaticHelpContent(cfg: unknown | null): void {\n globalStore[HELP_CONTENT_KEY] = cfg;\n}\n\nexport function _getStaticHelpContent<T = unknown>(): T | null {\n return (globalStore[HELP_CONTENT_KEY] as T | null) ?? null;\n}\n","\"use client\";\n\nimport { ModuleWithPermissions } from \"../permissions/types\";\nimport { ENV } from \"../core/env\";\nimport { setBootstrapper } from \"../core/registry/bootstrapStore\";\nimport { _setStaticHelpContent } from \"../core/registry/helpStore\";\nimport type { HelpContentConfig } from \"../features/help/interfaces/help-content-config.interface\";\n\n// Config storage for client-side contexts\nlet _clientConfig: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n stripePublishableKey?: string;\n} | null = null;\n\n/**\n * Configure the JSON:API client. This is the main configuration function.\n * This is typically called during app initialization.\n * @param config.helpContent - Optional help-content config (brand only). Forwarded to the help feature's globalThis-backed store; not stored on the client config.\n */\nexport function configureJsonApi(config: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n stripePublishableKey?: string;\n helpContent?: HelpContentConfig;\n}): void {\n const { helpContent, ...rest } = config;\n _clientConfig = rest;\n if (helpContent) {\n _setStaticHelpContent(helpContent);\n }\n // Register and call bootstrapper to register all modules\n if (config.bootstrapper) {\n setBootstrapper(config.bootstrapper);\n config.bootstrapper();\n }\n}\n\n/**\n * Configure the client config. This is typically called during app initialization.\n * @deprecated Use configureJsonApi instead\n */\nexport function configureClientConfig(config: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n}): void {\n _clientConfig = config;\n}\n\n/**\n * Get the configured API URL.\n *\n * This may resolve to an internal/private host (e.g. a docker-network\n * hostname) when configured to do so for SSR fetches. Do NOT use this for\n * URLs that are rendered into HTML and followed by the browser — use\n * `getPublicApiUrl()` instead.\n */\nexport function getApiUrl(): string {\n if (_clientConfig?.apiUrl) {\n return _clientConfig.apiUrl;\n }\n return ENV.API_URL;\n}\n\n/**\n * Get the public-facing API URL.\n *\n * Always sourced from `NEXT_PUBLIC_API_URL` so it is identical on server\n * and client, and reachable from the user's browser. Use for any URL that\n * gets rendered into HTML the browser will navigate to (links, redirects,\n * OAuth hrefs).\n */\nexport function getPublicApiUrl(): string {\n return ENV.API_URL;\n}\n\n/**\n * Get the configured app URL.\n */\nexport function getAppUrl(): string {\n if (_clientConfig?.appUrl) {\n return _clientConfig.appUrl;\n }\n if (ENV.APP_URL_ALTERNATE) {\n return ENV.APP_URL_ALTERNATE;\n }\n if (typeof window !== \"undefined\") {\n return window.location.origin;\n }\n return \"\";\n}\n\n/**\n * Get the configured trackable pages.\n */\nexport function getTrackablePages(): ModuleWithPermissions[] {\n return _clientConfig?.trackablePages ?? [];\n}\n\n/**\n * Get the configured Stripe publishable key.\n */\nexport function getStripePublishableKey(): string | undefined {\n return _clientConfig?.stripePublishableKey;\n}\n","let _useDiscordAuth: boolean = false;\nlet _useGoogleAuth: boolean = false;\nlet _useInternalAuth: boolean = true;\nlet _allowRegistration: boolean = true;\nlet _registrationMode: \"open\" | \"closed\" | \"waitlist\" = \"open\";\n\nexport type RegistrationMode = \"open\" | \"closed\" | \"waitlist\";\n\nexport interface LoginConfig {\n discordClientId?: string;\n googleClientId?: string;\n useInternalAuth?: boolean;\n allowRegistration?: boolean;\n registrationMode?: RegistrationMode;\n}\n\nexport function configureLogin(params: LoginConfig): void {\n _useDiscordAuth = !!params.discordClientId;\n _useGoogleAuth = !!params.googleClientId;\n _useInternalAuth = params.useInternalAuth ?? true;\n _allowRegistration = params.allowRegistration ?? true;\n _registrationMode = params.registrationMode ?? \"open\";\n}\n\nexport function isDiscordAuthEnabled(): boolean {\n return _useDiscordAuth;\n}\n\nexport function isGoogleAuthEnabled(): boolean {\n return _useGoogleAuth;\n}\n\nexport function isInternalAuthEnabled(): boolean {\n return _useInternalAuth;\n}\n\nexport function isRegistrationAllowed(): boolean {\n return _allowRegistration;\n}\n\nexport function getRegistrationMode(): RegistrationMode {\n return _registrationMode;\n}\n","export type QuestionnaireFieldType = \"text\" | \"textarea\" | \"select\" | \"checkbox\";\n\nexport interface QuestionnaireOption {\n value: string;\n label: string;\n description?: string;\n}\n\nexport interface QuestionnaireField {\n id: string;\n type: QuestionnaireFieldType;\n label: string;\n description?: string;\n placeholder?: string;\n required?: boolean;\n options?: QuestionnaireOption[];\n}\n\nexport interface WaitlistConfig {\n questionnaire?: QuestionnaireField[];\n heroTitle?: string;\n heroSubtitle?: string;\n heroDescription?: string;\n benefits?: string[];\n}\n\nlet _waitlistConfig: WaitlistConfig = {};\n\nexport function configureWaitlist(config: WaitlistConfig): void {\n _waitlistConfig = config;\n}\n\nexport function getWaitlistConfig(): WaitlistConfig {\n return _waitlistConfig;\n}\n","/**\n * Configuration interface for frontend referral feature.\n */\nexport interface ReferralConfig {\n /**\n * Whether the referral feature is enabled.\n * When false, components render nothing and hooks return null.\n * @default false\n */\n enabled?: boolean;\n\n /**\n * Name of the cookie used to store referral codes.\n * @default \"referral_code\"\n */\n cookieName?: string;\n\n /**\n * Number of days the referral cookie is valid.\n * @default 30\n */\n cookieDays?: number;\n\n /**\n * Query parameter name for referral code in URL.\n * @default \"ref\"\n */\n urlParamName?: string;\n\n /**\n * Base URL for referral links.\n * @default window.location.origin (client-side only)\n */\n referralUrlBase?: string;\n\n /**\n * Path to append to base URL for referral links.\n * @default \"/\"\n */\n referralPath?: string;\n}\n\n/**\n * Default configuration values\n */\nexport const DEFAULT_REFERRAL_CONFIG: Required<ReferralConfig> = {\n enabled: false,\n cookieName: \"referral_code\",\n cookieDays: 30,\n urlParamName: \"ref\",\n referralUrlBase: \"\",\n referralPath: \"/\",\n};\n\n// Private storage for configuration\nlet _referralConfig: Required<ReferralConfig> = { ...DEFAULT_REFERRAL_CONFIG };\n\n/**\n * Configure referral feature settings.\n * Call this at app startup to enable and configure referral functionality.\n *\n * @example\n * ```typescript\n * import { configureReferral } from \"@carlonicora/nextjs-jsonapi\";\n *\n * configureReferral({\n * enabled: process.env.NEXT_PUBLIC_REFERRAL_ENABLED === 'true',\n * cookieDays: 30,\n * });\n * ```\n */\nexport function configureReferral(config: ReferralConfig): void {\n _referralConfig = { ...DEFAULT_REFERRAL_CONFIG, ...config };\n}\n\n/**\n * Get the current referral configuration.\n * @internal\n */\nexport function getReferralConfig(): Required<ReferralConfig> {\n return _referralConfig;\n}\n\n/**\n * Check if referral feature is enabled.\n */\nexport function isReferralEnabled(): boolean {\n return _referralConfig.enabled;\n}\n","export const COMPANY_ADMINISTRATOR_ROLE_ID = \"2e1eee00-6cba-4506-9059-ccd24e4ea5b0\";\n\nexport type PermissionValue = boolean | string;\n\nexport type ActionType = \"read\" | \"create\" | \"update\" | \"delete\";\n\nexport const ACTION_TYPES: ActionType[] = [\"read\", \"create\", \"update\", \"delete\"];\n\n/** The permissions object shape used by both Module and PermissionMapping entities */\nexport type PermissionsMap = {\n create?: PermissionValue;\n read?: PermissionValue;\n update?: PermissionValue;\n delete?: PermissionValue;\n};\n\n/**\n * Declarative-RBAC matrix types.\n *\n * Mirror of the library types defined in\n * `packages/nestjs-neo4jsonapi/src/foundations/rbac/dsl/types.ts`.\n * Frontend does not import from backend, so the shape is redefined here.\n *\n * A `PermToken` represents a single permission entry:\n * - `scope: true` → unconditional (e.g. full read of the module)\n * - `scope: false` → nothing (rarely used, mostly a placeholder)\n * - `scope: \"path\"` → scoped by relationship path (e.g. \"orders.account\")\n */\nexport type PermToken = { action: string; scope: boolean | string };\n\n/**\n * A per-module block of the matrix. Always has a `default` row (permissions\n * granted to every role). Additional keys are role IDs → role-specific\n * permission tokens that are unioned with `default` to produce the effective\n * permissions for that role in that module.\n */\nexport type RbacModuleBlock = { default: PermToken[] } & Record<string, PermToken[]>;\n\n/**\n * The full RBAC matrix as served by the dev endpoint `GET /_dev/rbac/matrix`.\n * Keys are module IDs; values are module blocks.\n */\nexport type RbacMatrix = Record<string, RbacModuleBlock>;\n","import { AbstractService, EndpointCreator, HttpMethod, Modules } from \"../../../core\";\nimport type { RbacMatrixModel } from \"./RbacMatrixModel\";\nimport type { RbacMatrix } from \"./RbacTypes\";\n\n/**\n * RbacService — fetches RBAC configuration for the admin UI.\n *\n * Declarative-matrix methods (`fetchMatrix`, `saveMatrix`) talk to the\n * dev-only endpoints added in\n * `packages/nestjs-neo4jsonapi/.../rbac-dev.controller.ts`. The controller\n * speaks JSON:API (singleton resource with `type: \"rbac-matrix\"`, `id:\n * \"singleton\"`), so these methods go through the standard `callApi()`\n * pipeline like every other service in the codebase.\n *\n * The backend only registers these routes when `devMode` is enabled on\n * `RbacModule.register` (see `apps/api/src/features/features.modules.ts`).\n * In production the routes return 404; callers should guard with a dev-mode\n * check.\n */\nexport class RbacService extends AbstractService {\n /**\n * Fetch the current RBAC matrix plus each module's known BFS relationship\n * paths (used by the permission picker as scope suggestions).\n *\n * Dev-only endpoint — see class header.\n */\n static async fetchMatrix(): Promise<{\n matrix: RbacMatrix;\n modulePaths: Record<string, readonly string[]>;\n }> {\n const endpoint = new EndpointCreator({ endpoint: Modules.RbacMatrix }).generate();\n\n const model = await this.callApi<RbacMatrixModel>({\n type: Modules.RbacMatrix,\n method: HttpMethod.GET,\n endpoint,\n });\n\n return {\n matrix: model.matrix ?? {},\n modulePaths: model.modulePaths ?? {},\n };\n }\n\n /**\n * Persist a matrix back to the declarative `permissions.ts` file.\n *\n * The backend serializes the matrix to formatted TypeScript using the\n * provided `roleNames` / `moduleNames` lookup tables (so the emitted file\n * references `RoleId.X` / `ModuleId.X` rather than raw UUIDs) and writes\n * it to `outputPath` (absolute, or relative to the repo root).\n *\n * Dev-only endpoint — see class header.\n */\n static async saveMatrix(args: {\n matrix: RbacMatrix;\n roleNames: Record<string, string>;\n moduleNames: Record<string, string>;\n outputPath: string;\n }): Promise<{ bytesWritten: number; path: string }> {\n const endpoint = new EndpointCreator({ endpoint: Modules.RbacMatrix }).generate();\n\n const model = await this.callApi<RbacMatrixModel>({\n type: Modules.RbacMatrix,\n method: HttpMethod.PUT,\n endpoint,\n input: args,\n });\n\n return {\n bytesWritten: model.bytesWritten ?? 0,\n path: model.path ?? \"\",\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-7ZRQOLSV.js","../src/core/registry/helpStore.ts","../src/client/config.ts","../src/login/config.ts","../src/features/waitlist/config/waitlist.config.ts","../src/features/referral/config.ts","../src/features/rbac/data/RbacTypes.ts","../src/features/rbac/data/RbacService.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACFA,IAAM,iBAAA,kBAAmB,MAAA,CAAO,GAAA,CAAI,4BAA4B,CAAA;AAEhE,IAAM,YAAA,EAAc,UAAA;AAIpB,GAAA,CAAI,WAAA,CAAY,gBAAgB,EAAA,IAAM,KAAA,CAAA,EAAW;AAC/C,EAAA,WAAA,CAAY,gBAAgB,EAAA,EAAI,IAAA;AAClC;AAEO,SAAS,qBAAA,CAAsB,GAAA,EAA2B;AAC/D,EAAA,WAAA,CAAY,gBAAgB,EAAA,EAAI,GAAA;AAClC;AAFgB,qCAAA,qBAAA,EAAA,uBAAA,CAAA;AAIT,SAAS,qBAAA,CAAA,EAA+C;AAC7D,EAAA,wBAAQ,WAAA,CAAY,gB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ACL,YAAA,mBAAc,KAAA,CAAM,YAAA,UAAgB,GAAA;AAAA,MACpC,IAAA,mBAAM,KAAA,CAAM,IAAA,UAAQ;AAAA,IACtB,CAAA;AAAA,EACF;AACF,CAAA;AP6HA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yhCAAC","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-7ZRQOLSV.js","sourcesContent":[null,"/**\n * Centralized help-content store accessible from client and server contexts.\n * Uses a globalThis Symbol key to persist across HMR/Turbopack reloads and to\n * bridge between the client-side `configureJsonApi` (in `client/config.ts`)\n * and the HelpProvider context. Holds the brand-only HelpContentConfig.\n *\n * NO external dependencies to avoid circular imports.\n *\n * Pattern mirrors `bootstrapStore.ts`.\n */\n\nconst HELP_CONTENT_KEY = Symbol.for(\"nextjs-jsonapi:helpContent\");\n\nconst globalStore = globalThis as unknown as {\n [HELP_CONTENT_KEY]?: unknown | null;\n};\n\nif (globalStore[HELP_CONTENT_KEY] === undefined) {\n globalStore[HELP_CONTENT_KEY] = null;\n}\n\nexport function _setStaticHelpContent(cfg: unknown | null): void {\n globalStore[HELP_CONTENT_KEY] = cfg;\n}\n\nexport function _getStaticHelpContent<T = unknown>(): T | null {\n return (globalStore[HELP_CONTENT_KEY] as T | null) ?? null;\n}\n","\"use client\";\n\nimport { ModuleWithPermissions } from \"../permissions/types\";\nimport { ENV } from \"../core/env\";\nimport { setBootstrapper } from \"../core/registry/bootstrapStore\";\nimport { _setStaticHelpContent } from \"../core/registry/helpStore\";\nimport type { HelpContentConfig } from \"../features/help/interfaces/help-content-config.interface\";\n\n// Config storage for client-side contexts\nlet _clientConfig: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n stripePublishableKey?: string;\n} | null = null;\n\n/**\n * Configure the JSON:API client. This is the main configuration function.\n * This is typically called during app initialization.\n * @param config.helpContent - Optional help-content config (brand only). Forwarded to the help feature's globalThis-backed store; not stored on the client config.\n */\nexport function configureJsonApi(config: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n stripePublishableKey?: string;\n helpContent?: HelpContentConfig;\n}): void {\n const { helpContent, ...rest } = config;\n _clientConfig = rest;\n if (helpContent) {\n _setStaticHelpContent(helpContent);\n }\n // Register and call bootstrapper to register all modules\n if (config.bootstrapper) {\n setBootstrapper(config.bootstrapper);\n config.bootstrapper();\n }\n}\n\n/**\n * Configure the client config. This is typically called during app initialization.\n * @deprecated Use configureJsonApi instead\n */\nexport function configureClientConfig(config: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n}): void {\n _clientConfig = config;\n}\n\n/**\n * Get the configured API URL.\n *\n * This may resolve to an internal/private host (e.g. a docker-network\n * hostname) when configured to do so for SSR fetches. Do NOT use this for\n * URLs that are rendered into HTML and followed by the browser — use\n * `getPublicApiUrl()` instead.\n */\nexport function getApiUrl(): string {\n if (_clientConfig?.apiUrl) {\n return _clientConfig.apiUrl;\n }\n return ENV.API_URL;\n}\n\n/**\n * Get the public-facing API URL.\n *\n * Always sourced from `NEXT_PUBLIC_API_URL` so it is identical on server\n * and client, and reachable from the user's browser. Use for any URL that\n * gets rendered into HTML the browser will navigate to (links, redirects,\n * OAuth hrefs).\n */\nexport function getPublicApiUrl(): string {\n return ENV.API_URL;\n}\n\n/**\n * Get the configured app URL.\n */\nexport function getAppUrl(): string {\n if (_clientConfig?.appUrl) {\n return _clientConfig.appUrl;\n }\n if (ENV.APP_URL_ALTERNATE) {\n return ENV.APP_URL_ALTERNATE;\n }\n if (typeof window !== \"undefined\") {\n return window.location.origin;\n }\n return \"\";\n}\n\n/**\n * Get the configured trackable pages.\n */\nexport function getTrackablePages(): ModuleWithPermissions[] {\n return _clientConfig?.trackablePages ?? [];\n}\n\n/**\n * Get the configured Stripe publishable key.\n */\nexport function getStripePublishableKey(): string | undefined {\n return _clientConfig?.stripePublishableKey;\n}\n","let _useDiscordAuth: boolean = false;\nlet _useGoogleAuth: boolean = false;\nlet _useInternalAuth: boolean = true;\nlet _allowRegistration: boolean = true;\nlet _registrationMode: \"open\" | \"closed\" | \"waitlist\" = \"open\";\n\nexport type RegistrationMode = \"open\" | \"closed\" | \"waitlist\";\n\nexport interface LoginConfig {\n discordClientId?: string;\n googleClientId?: string;\n useInternalAuth?: boolean;\n allowRegistration?: boolean;\n registrationMode?: RegistrationMode;\n}\n\nexport function configureLogin(params: LoginConfig): void {\n _useDiscordAuth = !!params.discordClientId;\n _useGoogleAuth = !!params.googleClientId;\n _useInternalAuth = params.useInternalAuth ?? true;\n _allowRegistration = params.allowRegistration ?? true;\n _registrationMode = params.registrationMode ?? \"open\";\n}\n\nexport function isDiscordAuthEnabled(): boolean {\n return _useDiscordAuth;\n}\n\nexport function isGoogleAuthEnabled(): boolean {\n return _useGoogleAuth;\n}\n\nexport function isInternalAuthEnabled(): boolean {\n return _useInternalAuth;\n}\n\nexport function isRegistrationAllowed(): boolean {\n return _allowRegistration;\n}\n\nexport function getRegistrationMode(): RegistrationMode {\n return _registrationMode;\n}\n","export type QuestionnaireFieldType = \"text\" | \"textarea\" | \"select\" | \"checkbox\";\n\nexport interface QuestionnaireOption {\n value: string;\n label: string;\n description?: string;\n}\n\nexport interface QuestionnaireField {\n id: string;\n type: QuestionnaireFieldType;\n label: string;\n description?: string;\n placeholder?: string;\n required?: boolean;\n options?: QuestionnaireOption[];\n}\n\nexport interface WaitlistConfig {\n questionnaire?: QuestionnaireField[];\n heroTitle?: string;\n heroSubtitle?: string;\n heroDescription?: string;\n benefits?: string[];\n}\n\nlet _waitlistConfig: WaitlistConfig = {};\n\nexport function configureWaitlist(config: WaitlistConfig): void {\n _waitlistConfig = config;\n}\n\nexport function getWaitlistConfig(): WaitlistConfig {\n return _waitlistConfig;\n}\n","/**\n * Configuration interface for frontend referral feature.\n */\nexport interface ReferralConfig {\n /**\n * Whether the referral feature is enabled.\n * When false, components render nothing and hooks return null.\n * @default false\n */\n enabled?: boolean;\n\n /**\n * Name of the cookie used to store referral codes.\n * @default \"referral_code\"\n */\n cookieName?: string;\n\n /**\n * Number of days the referral cookie is valid.\n * @default 30\n */\n cookieDays?: number;\n\n /**\n * Query parameter name for referral code in URL.\n * @default \"ref\"\n */\n urlParamName?: string;\n\n /**\n * Base URL for referral links.\n * @default window.location.origin (client-side only)\n */\n referralUrlBase?: string;\n\n /**\n * Path to append to base URL for referral links.\n * @default \"/\"\n */\n referralPath?: string;\n}\n\n/**\n * Default configuration values\n */\nexport const DEFAULT_REFERRAL_CONFIG: Required<ReferralConfig> = {\n enabled: false,\n cookieName: \"referral_code\",\n cookieDays: 30,\n urlParamName: \"ref\",\n referralUrlBase: \"\",\n referralPath: \"/\",\n};\n\n// Private storage for configuration\nlet _referralConfig: Required<ReferralConfig> = { ...DEFAULT_REFERRAL_CONFIG };\n\n/**\n * Configure referral feature settings.\n * Call this at app startup to enable and configure referral functionality.\n *\n * @example\n * ```typescript\n * import { configureReferral } from \"@carlonicora/nextjs-jsonapi\";\n *\n * configureReferral({\n * enabled: process.env.NEXT_PUBLIC_REFERRAL_ENABLED === 'true',\n * cookieDays: 30,\n * });\n * ```\n */\nexport function configureReferral(config: ReferralConfig): void {\n _referralConfig = { ...DEFAULT_REFERRAL_CONFIG, ...config };\n}\n\n/**\n * Get the current referral configuration.\n * @internal\n */\nexport function getReferralConfig(): Required<ReferralConfig> {\n return _referralConfig;\n}\n\n/**\n * Check if referral feature is enabled.\n */\nexport function isReferralEnabled(): boolean {\n return _referralConfig.enabled;\n}\n","export const COMPANY_ADMINISTRATOR_ROLE_ID = \"2e1eee00-6cba-4506-9059-ccd24e4ea5b0\";\n\nexport type PermissionValue = boolean | string;\n\nexport type ActionType = \"read\" | \"create\" | \"update\" | \"delete\";\n\nexport const ACTION_TYPES: ActionType[] = [\"read\", \"create\", \"update\", \"delete\"];\n\n/** The permissions object shape used by both Module and PermissionMapping entities */\nexport type PermissionsMap = {\n create?: PermissionValue;\n read?: PermissionValue;\n update?: PermissionValue;\n delete?: PermissionValue;\n};\n\n/**\n * Declarative-RBAC matrix types.\n *\n * Mirror of the library types defined in\n * `packages/nestjs-neo4jsonapi/src/foundations/rbac/dsl/types.ts`.\n * Frontend does not import from backend, so the shape is redefined here.\n *\n * A `PermToken` represents a single permission entry:\n * - `scope: true` → unconditional (e.g. full read of the module)\n * - `scope: false` → nothing (rarely used, mostly a placeholder)\n * - `scope: \"path\"` → scoped by relationship path (e.g. \"orders.account\")\n */\nexport type PermToken = { action: string; scope: boolean | string };\n\n/**\n * A per-module block of the matrix. Always has a `default` row (permissions\n * granted to every role). Additional keys are role IDs → role-specific\n * permission tokens that are unioned with `default` to produce the effective\n * permissions for that role in that module.\n */\nexport type RbacModuleBlock = { default: PermToken[] } & Record<string, PermToken[]>;\n\n/**\n * The full RBAC matrix as served by the dev endpoint `GET /_dev/rbac/matrix`.\n * Keys are module IDs; values are module blocks.\n */\nexport type RbacMatrix = Record<string, RbacModuleBlock>;\n","import { AbstractService, EndpointCreator, HttpMethod, Modules } from \"../../../core\";\nimport type { RbacMatrixModel } from \"./RbacMatrixModel\";\nimport type { RbacMatrix } from \"./RbacTypes\";\n\n/**\n * RbacService — fetches RBAC configuration for the admin UI.\n *\n * Declarative-matrix methods (`fetchMatrix`, `saveMatrix`) talk to the\n * dev-only endpoints added in\n * `packages/nestjs-neo4jsonapi/.../rbac-dev.controller.ts`. The controller\n * speaks JSON:API (singleton resource with `type: \"rbac-matrix\"`, `id:\n * \"singleton\"`), so these methods go through the standard `callApi()`\n * pipeline like every other service in the codebase.\n *\n * The backend only registers these routes when `devMode` is enabled on\n * `RbacModule.register` (see `apps/api/src/features/features.modules.ts`).\n * In production the routes return 404; callers should guard with a dev-mode\n * check.\n */\nexport class RbacService extends AbstractService {\n /**\n * Fetch the current RBAC matrix plus each module's known BFS relationship\n * paths (used by the permission picker as scope suggestions).\n *\n * Dev-only endpoint — see class header.\n */\n static async fetchMatrix(): Promise<{\n matrix: RbacMatrix;\n modulePaths: Record<string, readonly string[]>;\n }> {\n const endpoint = new EndpointCreator({ endpoint: Modules.RbacMatrix }).generate();\n\n const model = await this.callApi<RbacMatrixModel>({\n type: Modules.RbacMatrix,\n method: HttpMethod.GET,\n endpoint,\n });\n\n return {\n matrix: model.matrix ?? {},\n modulePaths: model.modulePaths ?? {},\n };\n }\n\n /**\n * Persist a matrix back to the declarative `permissions.ts` file.\n *\n * The backend serializes the matrix to formatted TypeScript using the\n * provided `roleNames` / `moduleNames` lookup tables (so the emitted file\n * references `RoleId.X` / `ModuleId.X` rather than raw UUIDs) and writes\n * it to `outputPath` (absolute, or relative to the repo root).\n *\n * Dev-only endpoint — see class header.\n */\n static async saveMatrix(args: {\n matrix: RbacMatrix;\n roleNames: Record<string, string>;\n moduleNames: Record<string, string>;\n outputPath: string;\n }): Promise<{ bytesWritten: number; path: string }> {\n const endpoint = new EndpointCreator({ endpoint: Modules.RbacMatrix }).generate();\n\n const model = await this.callApi<RbacMatrixModel>({\n type: Modules.RbacMatrix,\n method: HttpMethod.PUT,\n endpoint,\n input: args,\n });\n\n return {\n bytesWritten: model.bytesWritten ?? 0,\n path: model.path ?? \"\",\n };\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk5PNDDYGLjs = require('./chunk-5PNDDYGL.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
|
|
@@ -43,7 +43,7 @@ function createUsageFormatters(locale, currency) {
|
|
|
43
43
|
_chunk7QVYU63Ejs.__name.call(void 0, createUsageFormatters, "createUsageFormatters");
|
|
44
44
|
function useUsageFormatters() {
|
|
45
45
|
const locale = _nextintl.useLocale.call(void 0, );
|
|
46
|
-
const currency =
|
|
46
|
+
const currency = _chunk5PNDDYGLjs.getTokenUsageCurrency.call(void 0, );
|
|
47
47
|
return _react.useMemo.call(void 0, () => createUsageFormatters(locale, currency), [locale, currency]);
|
|
48
48
|
}
|
|
49
49
|
_chunk7QVYU63Ejs.__name.call(void 0, useUsageFormatters, "useUsageFormatters");
|
|
@@ -107,4 +107,4 @@ _chunk7QVYU63Ejs.__name.call(void 0, seriesColor, "seriesColor");
|
|
|
107
107
|
|
|
108
108
|
|
|
109
109
|
exports.createUsageFormatters = createUsageFormatters; exports.useUsageFormatters = useUsageFormatters; exports.metricValue = metricValue; exports.cacheHitPercentage = cacheHitPercentage; exports.percentageDelta = percentageDelta; exports.CATEGORICAL_CEILING = CATEGORICAL_CEILING; exports.OTHER_COLOR = OTHER_COLOR; exports.SEQUENTIAL_RAMP = SEQUENTIAL_RAMP; exports.seriesColor = seriesColor;
|
|
110
|
-
//# sourceMappingURL=chunk-
|
|
110
|
+
//# sourceMappingURL=chunk-C2WQXUL5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-TWBZ2GSX.js","../src/features/tokenusage/lib/formatters.ts","../src/features/tokenusage/lib/metrics.ts","../src/features/tokenusage/lib/palette.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA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,GAAA,CAAI,OAAA,IAAW,MAAA,EAAQ,OAAO,CAAA,EAAA;AAIJ,MAAA;AACH,MAAA;AACzB,IAAA;AAE0B,IAAA;AACI,MAAA;AAC9B,IAAA;AAE6B,IAAA;AACF,MAAA;AAC3B,IAAA;AAEe,IAAA;AACe,MAAA;AAC9B,IAAA;AAE6B,IAAA;AACd,MAAA;AACU,MAAA;AACzB,IAAA;AAEc,IAAA;AACgB,MAAA;AAC9B,IAAA;AACF,EAAA;AACF;AAnDgB;AA0DsC;AAC3B,EAAA;AACR,EAAA;AACI,EAAA;AACvB;AAJgB;ADlDqB;AACA;AEzBuC;AACxC,EAAA;AACD,EAAA;AACP,EAAA;AAC5B;AAJgB;AAUmC;AAC3B,EAAA;AACO,EAAA;AAC/B;AAHgB;AAYiC;AACzB,EAAA;AACQ,EAAA;AAChC;AAHgB;AFoBqB;AACA;AGwDQ;AAC3C,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACF;AAG4C;AAC1C,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACF;AAcmC;AAOR;AAcuB;AAUA;AAE3B;AAYsC;AACjC,EAAA;AACO,EAAA;AACnC;AAHgB;AHzGqB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-TWBZ2GSX.js","sourcesContent":[null,"\"use client\";\n\nimport { useLocale } from \"next-intl\";\nimport { useMemo } from \"react\";\nimport type { Metric } from \"../data/tokenusage-admin.types\";\nimport { getTokenUsageCurrency } from \"./config\";\n\nexport type UsageFormatters = {\n /** Locale-aware fixed-decimal number, e.g. 9.46 → \"9,46\" in it-IT. */\n decimal(value: number, decimals: number): string;\n /** Currency for cost, 2 decimals for credits, whole numbers for tokens. */\n metricValue(value: number, metric: Metric): string;\n /** Currency with an explicit decimal count — the per-call tile needs 4. */\n currency(value: number, decimals: number): string;\n /** Percentage with one decimal by default, e.g. 60 → \"60,0 %\" in it-IT. */\n percent(value: number, decimals?: number): string;\n /** Compact notation for axis ticks, e.g. 1500000 → \"1,5 Mln\" in it-IT. */\n compact(value: number): string;\n /** A \"YYYY-MM-DD\" bucket key rendered as an axis or tooltip label, in UTC. */\n bucketDate(iso: string, granularity: \"day\" | \"week\" | \"month\"): string;\n /** Locale collation for client-side table sorting. */\n compare(a: string, b: string): number;\n};\n\n/**\n * Builds every formatter the token-usage surfaces need, for one locale and one\n * currency.\n *\n * A pure factory on purpose: it takes no React context, so the arithmetic and\n * the formatting are unit-testable without rendering, and a server component or\n * a test can construct a set for an arbitrary locale.\n *\n * The currency symbol is placed with a space rather than through\n * `style: \"currency\"`, which is what the previous hard-coded implementation\n * rendered (\"€ 9,46\"). Keeping that shape means a consuming app on EUR sees\n * byte-identical output after this refactor.\n *\n * `bucketDate` formats in UTC, always. The wire value is a `type: \"date\"` — a\n * calendar day — parsed to UTC midnight; reading it back with local getters\n * would shift the label a day early west of UTC.\n */\nexport function createUsageFormatters(locale: string, currency: string): UsageFormatters {\n const symbol =\n new Intl.NumberFormat(locale, { style: \"currency\", currency, currencyDisplay: \"narrowSymbol\" })\n .formatToParts(0)\n .find((part) => part.type === \"currency\")?.value ?? currency;\n\n const decimal = (value: number, decimals: number): string =>\n value.toLocaleString(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals });\n\n const dayFormat = new Intl.DateTimeFormat(locale, { day: \"numeric\", month: \"short\", timeZone: \"UTC\" });\n const monthFormat = new Intl.DateTimeFormat(locale, { month: \"short\", year: \"numeric\", timeZone: \"UTC\" });\n // Axis ticks step by 1, 2, 2.5 or 5 times a power of ten, so a tick never needs\n // more than three significant digits. A fixed one-decimal cap rounded a 0.05\n // step into repeated labels (0.1, 0.1, 0.2, 0.2); significant digits keep every\n // tick distinct at any scale (0.05, 0.15, 1.25K).\n const compactFormat = new Intl.NumberFormat(locale, { notation: \"compact\", maximumSignificantDigits: 3 });\n const collator = new Intl.Collator(locale);\n\n return {\n decimal,\n\n metricValue(value, metric) {\n if (metric === \"cost\") return `${symbol} ${decimal(value, 2)}`;\n // Credits are stored to 4 decimals (round4(cost / creditCost)), but that\n // precision is noise to a reader comparing rows: one decimal is enough to\n // separate two values and keeps the columns narrow enough to scan.\n if (metric === \"credits\") return decimal(value, 1);\n return decimal(value, 0);\n },\n\n currency(value, decimals) {\n return `${symbol} ${decimal(value, decimals)}`;\n },\n\n percent(value, decimals = 1) {\n return `${decimal(value, decimals)} %`;\n },\n\n compact(value) {\n return compactFormat.format(value);\n },\n\n bucketDate(iso, granularity) {\n const date = new Date(`${iso}T00:00:00.000Z`);\n return granularity === \"month\" ? monthFormat.format(date) : dayFormat.format(date);\n },\n\n compare(a, b) {\n return collator.compare(a, b);\n },\n };\n}\n\n/**\n * The formatter set for the current request's locale and the app's configured\n * currency. Memoised on both, so the Intl objects are built once per locale\n * rather than on every render.\n */\nexport function useUsageFormatters(): UsageFormatters {\n const locale = useLocale();\n const currency = getTokenUsageCurrency();\n return useMemo(() => createUsageFormatters(locale, currency), [locale, currency]);\n}\n","import type { Metric } from \"../data/tokenusage-admin.types\";\n\n/**\n * Locale-free arithmetic for the token-usage surfaces.\n *\n * Everything that turns a number into a STRING lives in `./formatters` instead,\n * because it depends on the request's locale and the app's configured currency.\n * This file stays pure arithmetic so it needs neither.\n */\n\n/**\n * The metric field set every admin token-usage resource carries. Declared\n * structurally so it accepts the summary, timeline and breakdown interfaces\n * alike — all three expose exactly these getters.\n */\nexport type TokenUsageMetrics = {\n cost: number;\n credits: number;\n tokensIn: number;\n tokensOut: number;\n cached: number;\n calls: number;\n};\n\n/** Reads the single number a row contributes for the currently selected metric. */\nexport function metricValue(row: TokenUsageMetrics, metric: Metric): number {\n if (metric === \"cost\") return row.cost;\n if (metric === \"credits\") return row.credits;\n return row.tokensIn + row.tokensOut;\n}\n\n/**\n * Share of cached input tokens. Returns 0 rather than NaN when the window holds\n * no input tokens at all, so the tile renders \"0,0 %\" instead of \"NaN %\".\n */\nexport function cacheHitPercentage(cached: number, tokensIn: number): number {\n if (!tokensIn) return 0;\n return (cached / tokensIn) * 100;\n}\n\n/**\n * Percentage change of `current` against `previous`, rounded to a whole number.\n *\n * Returns `undefined` when the previous window is zero — there is no meaningful\n * percentage change from nothing, and rendering Infinity would be worse than\n * rendering nothing. Callers show an em dash in that slot.\n */\nexport function percentageDelta(current: number, previous: number): number | undefined {\n if (!previous) return undefined;\n return Math.round(((current - previous) / previous) * 100);\n}\n","/**\n * Chart palette for the administrative token-usage dashboard.\n *\n * Every value here is a documented step of the dataviz skill's reference ramps —\n * nothing was eyeballed, nothing was hand-mixed. The palette was run through the\n * skill's validator against THIS application's real chart surfaces in both modes.\n * The verbatim output is below.\n *\n * The surface is `--card`, NOT `--background`. Every chart that uses this palette\n * is painted inside a `<Card>`, so the card is the surface the marks actually sit\n * on — and in dark mode it is the *lighter* of the two (`oklch(0.205 0 0)` vs the\n * background's `oklch(0.145 0 0)`), which is the harder case for contrast. Taken\n * from `apps/web/src/app/globals.css` (narr8 declares two `:root`/`.dark` pairs;\n * the LATER pair wins, and it is the one read here) — light `oklch(1 0 0)`, dark\n * `oklch(0.205 0 0)`. a360ai declares the same two values.\n *\n * oklch→hex conversion: the algebraic inverse of the Björn Ottosson OKLab\n * matrices — the same matrices the validator applies in the forward direction —\n * giving light `#ffffff` and dark `#171717`. Cross-checked by feeding it the\n * previously recorded background value, which it reproduces exactly:\n * `oklch(0.145 0 0)` → `#0a0a0a`. ✓\n *\n * Light and dark are two SELECTED sets of steps, chosen for their own surface —\n * never one set with its lightness flipped at runtime. Consumers pick a set from\n * the resolved theme (`seriesColor(i, mode)` / `sequentialColor(i, mode)`).\n *\n * ---------------------------------------------------------------------------\n * VALIDATOR OUTPUT — dataviz `scripts/validate_palette.js`, run 2026-08-15\n * ---------------------------------------------------------------------------\n *\n * $ node scripts/validate_palette.js \"#2a78d6,#eb6834,#1baf7a,#eda100,#e87ba4,#008300,#4a3aa7\" --mode light --surface \"#ffffff\"\n *\n * Palette (light, surface #ffffff, categorical): 7 slots\n * [PASS] Lightness band all 7 inside L 0.43–0.77\n * [PASS] Chroma floor all 7 >= 0.1\n * [PASS] CVD separation worst adjacent #eda100↔#1baf7a ΔE 9.1 (protan) · tritan 5.8\n * [PASS] Normal-vision floor worst adjacent #e87ba4↔#eda100 ΔE 19.6 (normal)\n * [WARN] Contrast vs surface below 3:1 — relief required (visible labels or table view): [[\"#1baf7a\",2.82],[\"#eda100\",2.17],[\"#e87ba4\",2.69]]\n *\n * → ALL CHECKS PASS (CVD in the 6–8 floor band is legal ONLY with secondary encoding: direct labels, gaps, or texture)\n * scope: categorical palettes only. For a lone status/text color check WCAG text contrast; for a sequential ramp, lightness monotonicity.\n *\n * $ node scripts/validate_palette.js \"#3987e5,#d95926,#199e70,#c98500,#d55181,#008300,#9085e9\" --mode dark --surface \"#171717\"\n *\n * Palette (dark, surface #171717, categorical): 7 slots\n * [PASS] Lightness band all 7 inside L 0.48–0.67\n * [PASS] Chroma floor all 7 >= 0.1\n * [PASS] CVD separation worst adjacent #c98500↔#199e70 ΔE 8.4 (protan) · tritan 8.7\n * [PASS] Normal-vision floor worst adjacent #d55181↔#c98500 ΔE 19.3 (normal)\n * [PASS] Contrast vs surface all 7 >= 3:1\n *\n * → ALL CHECKS PASS (CVD in the 6–8 floor band is legal ONLY with secondary encoding: direct labels, gaps, or texture)\n * scope: categorical palettes only. For a lone status/text color check WCAG text contrast; for a sequential ramp, lightness monotonicity.\n *\n * $ node scripts/validate_palette.js \"#104281,#1c5cab,#2a78d6,#5598e7,#86b6ef\" --mode light --surface \"#ffffff\" --ordinal\n *\n * Palette (light, surface #ffffff, ordinal ramp): 5 slots\n * [PASS] Lightness monotone steps read light→dark\n * [PASS] Adjacent ΔL all gaps >= 0.06\n * [PASS] Light-end contrast #86b6ef at 2.11:1 vs surface\n * [PASS] Single hue hue spread 3°\n *\n * → ALL CHECKS PASS (ordinal: one hue, monotone L, visible step gaps, light end clears surface)\n *\n * $ node scripts/validate_palette.js \"#9ec5f4,#6da7ec,#3987e5,#256abf,#184f95\" --mode dark --surface \"#171717\" --ordinal\n *\n * Palette (dark, surface #171717, ordinal ramp): 5 slots\n * [PASS] Lightness monotone steps read light→dark\n * [PASS] Adjacent ΔL all gaps >= 0.06\n * [PASS] Light-end contrast #184f95 at 2.21:1 vs surface\n * [PASS] Single hue hue spread 3°\n *\n * → ALL CHECKS PASS (ordinal: one hue, monotone L, visible step gaps, light end clears surface)\n *\n * OTHER_COLOR is achromatic, so the categorical checks (which gate hue identity)\n * do not apply to it; it was gated on contrast alone with the validator's own\n * `contrast()` export: 3.59:1 on `#ffffff`, 4.99:1 on `#171717` — both clear 3:1.\n *\n * ---------------------------------------------------------------------------\n * WHAT THE RESULTS OBLIGE US TO DO\n * ---------------------------------------------------------------------------\n *\n * - NO COLOUR VALUE CHANGED in the move from `--background` to `--card`. Every\n * gate that passed on the background still passes on the card, so re-stepping\n * a hue would have been churn, not a fix. Only the recorded surface, the\n * recorded numbers and this prose changed.\n * - The dark set still clears 3:1 on the LIGHTER card surface: the worst slot is\n * green `#008300` at 3.63:1, and the ordinal ramp's surface-nearest step lands\n * at 2.21:1 (down from 2.44:1 on the background) — still above the 2:1 gate.\n * That headroom is thin, so a future card-surface lightening MUST re-run these\n * four commands rather than assume the set still holds.\n * - The light-mode contrast WARN is NOT dismissable. Three slots (aqua, yellow,\n * magenta) sit below 3:1 on white, so every surface that paints with this\n * palette MUST ship the relief channel: a visible legend, direct labels and a\n * tooltip carrying the value in text. The timeline chart and the breakdown\n * table both do. The light card is `#ffffff`, identical to the light\n * background, so this WARN is unchanged rather than newly incurred.\n * - CVD separation is measured on ADJACENT pairs, which is the correct pairlist\n * for stacked bars, grouped bars and lines — the only forms this palette paints.\n * A scatter / bubble / small-multiples chart would need `--pairs all`, which\n * caps the usable slot count at three; do not reuse this array there without\n * re-running the validator with that flag.\n */\n\n/** Which surface the colours are being painted on. */\nexport type ChartMode = \"light\" | \"dark\";\n\n/**\n * The chart surfaces the palette was validated against (globals.css `--card`).\n *\n * `--card`, never `--background`: the charts are painted inside a `<Card>`.\n */\nexport const CHART_SURFACE: Readonly<Record<ChartMode, string>> = {\n light: \"#ffffff\",\n dark: \"#171717\",\n};\n\n/**\n * Categorical slots, in FIXED order. Slot n is series n — the order is the\n * CVD-safety mechanism, not decoration, so it is never re-ordered and never\n * cycled. The two-series default (customer / platform) takes slots 0 and 1.\n *\n * Hues, in order: blue, orange, aqua, yellow, magenta, green, violet.\n */\nconst CATEGORICAL_LIGHT: readonly string[] = [\n \"#2a78d6\",\n \"#eb6834\",\n \"#1baf7a\",\n \"#eda100\",\n \"#e87ba4\",\n \"#008300\",\n \"#4a3aa7\",\n];\n\n/** The same seven hues, re-stepped for the dark surface. Not a lightness flip. */\nconst CATEGORICAL_DARK: readonly string[] = [\n \"#3987e5\",\n \"#d95926\",\n \"#199e70\",\n \"#c98500\",\n \"#d55181\",\n \"#008300\",\n \"#9085e9\",\n];\n\n/**\n * The default (light-surface) categorical set.\n *\n * Prefer `seriesColor(index, mode)` — this array exists for consumers that only\n * need the documented default order.\n */\nexport const CATEGORICAL: readonly string[] = CATEGORICAL_LIGHT;\n\n/**\n * How many series may carry their own identity hue. An 8th series is NEVER a\n * generated hue: it folds into `other`.\n */\nexport const CATEGORICAL_CEILING = CATEGORICAL_LIGHT.length;\n\n/**\n * The \"other\" rollup colour: deliberately achromatic so it reads as \"not an\n * identity\" beside the seven hues. Same step in both modes — it clears 3:1 on\n * both card surfaces (3.59:1 on `#ffffff`, 4.99:1 on `#171717`).\n */\nexport const OTHER_COLOR = \"#898781\";\n\n/**\n * Sequential (single-hue, blue) ramp for MAGNITUDE, indexed by rank position:\n * index 0 is rank 1 — the largest value — so the strongest step leads.\n *\n * On the light surface \"strongest\" is the darkest step; on the dark surface it\n * is the lightest. The anchor flips with the surface, which is why there are two\n * selected sets rather than one array reversed at runtime.\n *\n * Five steps, not eight: with the adjacent-ΔL ≥ 0.06 gate and the ≥ 2:1\n * surface-contrast gate on the step nearest the surface, the blue ramp fits\n * exactly five distinguishable steps. Consumers clamp past the end.\n */\nconst SEQUENTIAL_RAMP_LIGHT: readonly string[] = [\"#104281\", \"#1c5cab\", \"#2a78d6\", \"#5598e7\", \"#86b6ef\"];\n\nconst SEQUENTIAL_RAMP_DARK: readonly string[] = [\"#9ec5f4\", \"#6da7ec\", \"#3987e5\", \"#256abf\", \"#184f95\"];\n\n/**\n * The default (light-surface) sequential ramp.\n *\n * Prefer `sequentialColor(index, mode)` — this array exists for consumers that\n * only need the documented default.\n */\nexport const SEQUENTIAL_RAMP: readonly string[] = SEQUENTIAL_RAMP_LIGHT;\n\nconst categoricalSet = (mode: ChartMode): readonly string[] => (mode === \"dark\" ? CATEGORICAL_DARK : CATEGORICAL_LIGHT);\n\nconst sequentialSet = (mode: ChartMode): readonly string[] =>\n mode === \"dark\" ? SEQUENTIAL_RAMP_DARK : SEQUENTIAL_RAMP_LIGHT;\n\n/**\n * The identity colour for series `index`.\n *\n * Never generates a hue and never cycles: anything at or past the ceiling gets\n * `OTHER_COLOR`, because a series past the ceiling should already have been\n * folded into the \"other\" bucket by the caller.\n */\nexport function seriesColor(index: number, mode: ChartMode = \"light\"): string {\n if (index < 0 || index >= CATEGORICAL_CEILING) return OTHER_COLOR;\n return categoricalSet(mode)[index];\n}\n\n/**\n * Both mode steps for series `index`, shaped for a shadcn `ChartConfig` entry's\n * `theme` field.\n */\nexport function seriesTheme(index: number): { light: string; dark: string } {\n return { light: seriesColor(index, \"light\"), dark: seriesColor(index, \"dark\") };\n}\n\n/**\n * The magnitude colour for rank position `index`, clamped to the last step so a\n * long list keeps its weakest step rather than falling off the ramp.\n */\nexport function sequentialColor(index: number, mode: ChartMode = \"light\"): string {\n const ramp = sequentialSet(mode);\n const clamped = Math.min(Math.max(index, 0), ramp.length - 1);\n return ramp[clamped];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-C2WQXUL5.js","../src/features/tokenusage/lib/formatters.ts","../src/features/tokenusage/lib/metrics.ts","../src/features/tokenusage/lib/palette.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACLA,qCAA0B;AAC1B,8BAAwB;AAsCjB,SAAS,qBAAA,CAAsB,MAAA,EAAgB,QAAA,EAAmC;AACvF,EAAA,MAAM,OAAA,mCACJ,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ,EAAE,KAAA,EAAO,UAAA,EAAY,QAAA,EAAU,eAAA,EAAiB,eAAe,CAAC,CAAA,mBAC3F,aAAA,mBAAc,CAAC,CAAA,qBACf,IAAA,mBAAK,CAAC,IAAA,EAAA,GAAS,IAAA,CAAK,KAAA,IAAS,UAAU,CAAA,6BAAG,OAAA,UAAS,UAAA;AAExD,EAAA,MAAM,QAAA,kBAAU,qCAAA,CAAC,KAAA,EAAe,QAAA,EAAA,GAC9B,KAAA,CAAM,cAAA,CAAe,MAAA,EAAQ,EAAE,qBAAA,EAAuB,QAAA,EAAU,qBAAA,EAAuB,SAAS,CAAC,CAAA,EADnF,SAAA,CAAA;AAGhB,EAAA,MAAM,UAAA,EAAY,IAAI,IAAA,CAAK,cAAA,CAAe,MAAA,EAAQ,EAAE,GAAA,EAAK,SAAA,EAAW,KAAA,EAAO,OAAA,EAAS,QAAA,EAAU,MAAM,CAAC,CAAA;AACrG,EAAA,MAAM,YAAA,EAAc,IAAI,IAAA,CAAK,cAAA,CAAe,MAAA,EAAQ,EAAE,KAAA,EAAO,OAAA,EAAS,IAAA,EAAM,SAAA,EAAW,QAAA,EAAU,MAAM,CAAC,CAAA;AAKxG,EAAA,MAAM,cAAA,EAAgB,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ,EAAE,QAAA,EAAU,SAAA,EAAW,wBAAA,EAA0B,EAAE,CAAC,CAAA;AACxG,EAAA,MAAM,SAAA,EAAW,IAAI,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA;AAEzC,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IAEA,WAAA,CAAY,KAAA,EAAO,MAAA,EAAQ;AACzB,MAAA,GAAA,CAAI,OAAA,IAAW,MAAA,EAAQ,OAAO,CAAA,EAAA;AAIJ,MAAA;AACH,MAAA;AACzB,IAAA;AAE0B,IAAA;AACI,MAAA;AAC9B,IAAA;AAE6B,IAAA;AACF,MAAA;AAC3B,IAAA;AAEe,IAAA;AACe,MAAA;AAC9B,IAAA;AAE6B,IAAA;AACd,MAAA;AACU,MAAA;AACzB,IAAA;AAEc,IAAA;AACgB,MAAA;AAC9B,IAAA;AACF,EAAA;AACF;AAnDgB;AA0DsC;AAC3B,EAAA;AACR,EAAA;AACI,EAAA;AACvB;AAJgB;ADlDqB;AACA;AEzBuC;AACxC,EAAA;AACD,EAAA;AACP,EAAA;AAC5B;AAJgB;AAUmC;AAC3B,EAAA;AACO,EAAA;AAC/B;AAHgB;AAYiC;AACzB,EAAA;AACQ,EAAA;AAChC;AAHgB;AFoBqB;AACA;AGwDQ;AAC3C,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACF;AAG4C;AAC1C,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACF;AAcmC;AAOR;AAcuB;AAUA;AAE3B;AAYsC;AACjC,EAAA;AACO,EAAA;AACnC;AAHgB;AHzGqB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-C2WQXUL5.js","sourcesContent":[null,"\"use client\";\n\nimport { useLocale } from \"next-intl\";\nimport { useMemo } from \"react\";\nimport type { Metric } from \"../data/tokenusage-admin.types\";\nimport { getTokenUsageCurrency } from \"./config\";\n\nexport type UsageFormatters = {\n /** Locale-aware fixed-decimal number, e.g. 9.46 → \"9,46\" in it-IT. */\n decimal(value: number, decimals: number): string;\n /** Currency for cost, 2 decimals for credits, whole numbers for tokens. */\n metricValue(value: number, metric: Metric): string;\n /** Currency with an explicit decimal count — the per-call tile needs 4. */\n currency(value: number, decimals: number): string;\n /** Percentage with one decimal by default, e.g. 60 → \"60,0 %\" in it-IT. */\n percent(value: number, decimals?: number): string;\n /** Compact notation for axis ticks, e.g. 1500000 → \"1,5 Mln\" in it-IT. */\n compact(value: number): string;\n /** A \"YYYY-MM-DD\" bucket key rendered as an axis or tooltip label, in UTC. */\n bucketDate(iso: string, granularity: \"day\" | \"week\" | \"month\"): string;\n /** Locale collation for client-side table sorting. */\n compare(a: string, b: string): number;\n};\n\n/**\n * Builds every formatter the token-usage surfaces need, for one locale and one\n * currency.\n *\n * A pure factory on purpose: it takes no React context, so the arithmetic and\n * the formatting are unit-testable without rendering, and a server component or\n * a test can construct a set for an arbitrary locale.\n *\n * The currency symbol is placed with a space rather than through\n * `style: \"currency\"`, which is what the previous hard-coded implementation\n * rendered (\"€ 9,46\"). Keeping that shape means a consuming app on EUR sees\n * byte-identical output after this refactor.\n *\n * `bucketDate` formats in UTC, always. The wire value is a `type: \"date\"` — a\n * calendar day — parsed to UTC midnight; reading it back with local getters\n * would shift the label a day early west of UTC.\n */\nexport function createUsageFormatters(locale: string, currency: string): UsageFormatters {\n const symbol =\n new Intl.NumberFormat(locale, { style: \"currency\", currency, currencyDisplay: \"narrowSymbol\" })\n .formatToParts(0)\n .find((part) => part.type === \"currency\")?.value ?? currency;\n\n const decimal = (value: number, decimals: number): string =>\n value.toLocaleString(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals });\n\n const dayFormat = new Intl.DateTimeFormat(locale, { day: \"numeric\", month: \"short\", timeZone: \"UTC\" });\n const monthFormat = new Intl.DateTimeFormat(locale, { month: \"short\", year: \"numeric\", timeZone: \"UTC\" });\n // Axis ticks step by 1, 2, 2.5 or 5 times a power of ten, so a tick never needs\n // more than three significant digits. A fixed one-decimal cap rounded a 0.05\n // step into repeated labels (0.1, 0.1, 0.2, 0.2); significant digits keep every\n // tick distinct at any scale (0.05, 0.15, 1.25K).\n const compactFormat = new Intl.NumberFormat(locale, { notation: \"compact\", maximumSignificantDigits: 3 });\n const collator = new Intl.Collator(locale);\n\n return {\n decimal,\n\n metricValue(value, metric) {\n if (metric === \"cost\") return `${symbol} ${decimal(value, 2)}`;\n // Credits are stored to 4 decimals (round4(cost / creditCost)), but that\n // precision is noise to a reader comparing rows: one decimal is enough to\n // separate two values and keeps the columns narrow enough to scan.\n if (metric === \"credits\") return decimal(value, 1);\n return decimal(value, 0);\n },\n\n currency(value, decimals) {\n return `${symbol} ${decimal(value, decimals)}`;\n },\n\n percent(value, decimals = 1) {\n return `${decimal(value, decimals)} %`;\n },\n\n compact(value) {\n return compactFormat.format(value);\n },\n\n bucketDate(iso, granularity) {\n const date = new Date(`${iso}T00:00:00.000Z`);\n return granularity === \"month\" ? monthFormat.format(date) : dayFormat.format(date);\n },\n\n compare(a, b) {\n return collator.compare(a, b);\n },\n };\n}\n\n/**\n * The formatter set for the current request's locale and the app's configured\n * currency. Memoised on both, so the Intl objects are built once per locale\n * rather than on every render.\n */\nexport function useUsageFormatters(): UsageFormatters {\n const locale = useLocale();\n const currency = getTokenUsageCurrency();\n return useMemo(() => createUsageFormatters(locale, currency), [locale, currency]);\n}\n","import type { Metric } from \"../data/tokenusage-admin.types\";\n\n/**\n * Locale-free arithmetic for the token-usage surfaces.\n *\n * Everything that turns a number into a STRING lives in `./formatters` instead,\n * because it depends on the request's locale and the app's configured currency.\n * This file stays pure arithmetic so it needs neither.\n */\n\n/**\n * The metric field set every admin token-usage resource carries. Declared\n * structurally so it accepts the summary, timeline and breakdown interfaces\n * alike — all three expose exactly these getters.\n */\nexport type TokenUsageMetrics = {\n cost: number;\n credits: number;\n tokensIn: number;\n tokensOut: number;\n cached: number;\n calls: number;\n};\n\n/** Reads the single number a row contributes for the currently selected metric. */\nexport function metricValue(row: TokenUsageMetrics, metric: Metric): number {\n if (metric === \"cost\") return row.cost;\n if (metric === \"credits\") return row.credits;\n return row.tokensIn + row.tokensOut;\n}\n\n/**\n * Share of cached input tokens. Returns 0 rather than NaN when the window holds\n * no input tokens at all, so the tile renders \"0,0 %\" instead of \"NaN %\".\n */\nexport function cacheHitPercentage(cached: number, tokensIn: number): number {\n if (!tokensIn) return 0;\n return (cached / tokensIn) * 100;\n}\n\n/**\n * Percentage change of `current` against `previous`, rounded to a whole number.\n *\n * Returns `undefined` when the previous window is zero — there is no meaningful\n * percentage change from nothing, and rendering Infinity would be worse than\n * rendering nothing. Callers show an em dash in that slot.\n */\nexport function percentageDelta(current: number, previous: number): number | undefined {\n if (!previous) return undefined;\n return Math.round(((current - previous) / previous) * 100);\n}\n","/**\n * Chart palette for the administrative token-usage dashboard.\n *\n * Every value here is a documented step of the dataviz skill's reference ramps —\n * nothing was eyeballed, nothing was hand-mixed. The palette was run through the\n * skill's validator against THIS application's real chart surfaces in both modes.\n * The verbatim output is below.\n *\n * The surface is `--card`, NOT `--background`. Every chart that uses this palette\n * is painted inside a `<Card>`, so the card is the surface the marks actually sit\n * on — and in dark mode it is the *lighter* of the two (`oklch(0.205 0 0)` vs the\n * background's `oklch(0.145 0 0)`), which is the harder case for contrast. Taken\n * from `apps/web/src/app/globals.css` (narr8 declares two `:root`/`.dark` pairs;\n * the LATER pair wins, and it is the one read here) — light `oklch(1 0 0)`, dark\n * `oklch(0.205 0 0)`. a360ai declares the same two values.\n *\n * oklch→hex conversion: the algebraic inverse of the Björn Ottosson OKLab\n * matrices — the same matrices the validator applies in the forward direction —\n * giving light `#ffffff` and dark `#171717`. Cross-checked by feeding it the\n * previously recorded background value, which it reproduces exactly:\n * `oklch(0.145 0 0)` → `#0a0a0a`. ✓\n *\n * Light and dark are two SELECTED sets of steps, chosen for their own surface —\n * never one set with its lightness flipped at runtime. Consumers pick a set from\n * the resolved theme (`seriesColor(i, mode)` / `sequentialColor(i, mode)`).\n *\n * ---------------------------------------------------------------------------\n * VALIDATOR OUTPUT — dataviz `scripts/validate_palette.js`, run 2026-08-15\n * ---------------------------------------------------------------------------\n *\n * $ node scripts/validate_palette.js \"#2a78d6,#eb6834,#1baf7a,#eda100,#e87ba4,#008300,#4a3aa7\" --mode light --surface \"#ffffff\"\n *\n * Palette (light, surface #ffffff, categorical): 7 slots\n * [PASS] Lightness band all 7 inside L 0.43–0.77\n * [PASS] Chroma floor all 7 >= 0.1\n * [PASS] CVD separation worst adjacent #eda100↔#1baf7a ΔE 9.1 (protan) · tritan 5.8\n * [PASS] Normal-vision floor worst adjacent #e87ba4↔#eda100 ΔE 19.6 (normal)\n * [WARN] Contrast vs surface below 3:1 — relief required (visible labels or table view): [[\"#1baf7a\",2.82],[\"#eda100\",2.17],[\"#e87ba4\",2.69]]\n *\n * → ALL CHECKS PASS (CVD in the 6–8 floor band is legal ONLY with secondary encoding: direct labels, gaps, or texture)\n * scope: categorical palettes only. For a lone status/text color check WCAG text contrast; for a sequential ramp, lightness monotonicity.\n *\n * $ node scripts/validate_palette.js \"#3987e5,#d95926,#199e70,#c98500,#d55181,#008300,#9085e9\" --mode dark --surface \"#171717\"\n *\n * Palette (dark, surface #171717, categorical): 7 slots\n * [PASS] Lightness band all 7 inside L 0.48–0.67\n * [PASS] Chroma floor all 7 >= 0.1\n * [PASS] CVD separation worst adjacent #c98500↔#199e70 ΔE 8.4 (protan) · tritan 8.7\n * [PASS] Normal-vision floor worst adjacent #d55181↔#c98500 ΔE 19.3 (normal)\n * [PASS] Contrast vs surface all 7 >= 3:1\n *\n * → ALL CHECKS PASS (CVD in the 6–8 floor band is legal ONLY with secondary encoding: direct labels, gaps, or texture)\n * scope: categorical palettes only. For a lone status/text color check WCAG text contrast; for a sequential ramp, lightness monotonicity.\n *\n * $ node scripts/validate_palette.js \"#104281,#1c5cab,#2a78d6,#5598e7,#86b6ef\" --mode light --surface \"#ffffff\" --ordinal\n *\n * Palette (light, surface #ffffff, ordinal ramp): 5 slots\n * [PASS] Lightness monotone steps read light→dark\n * [PASS] Adjacent ΔL all gaps >= 0.06\n * [PASS] Light-end contrast #86b6ef at 2.11:1 vs surface\n * [PASS] Single hue hue spread 3°\n *\n * → ALL CHECKS PASS (ordinal: one hue, monotone L, visible step gaps, light end clears surface)\n *\n * $ node scripts/validate_palette.js \"#9ec5f4,#6da7ec,#3987e5,#256abf,#184f95\" --mode dark --surface \"#171717\" --ordinal\n *\n * Palette (dark, surface #171717, ordinal ramp): 5 slots\n * [PASS] Lightness monotone steps read light→dark\n * [PASS] Adjacent ΔL all gaps >= 0.06\n * [PASS] Light-end contrast #184f95 at 2.21:1 vs surface\n * [PASS] Single hue hue spread 3°\n *\n * → ALL CHECKS PASS (ordinal: one hue, monotone L, visible step gaps, light end clears surface)\n *\n * OTHER_COLOR is achromatic, so the categorical checks (which gate hue identity)\n * do not apply to it; it was gated on contrast alone with the validator's own\n * `contrast()` export: 3.59:1 on `#ffffff`, 4.99:1 on `#171717` — both clear 3:1.\n *\n * ---------------------------------------------------------------------------\n * WHAT THE RESULTS OBLIGE US TO DO\n * ---------------------------------------------------------------------------\n *\n * - NO COLOUR VALUE CHANGED in the move from `--background` to `--card`. Every\n * gate that passed on the background still passes on the card, so re-stepping\n * a hue would have been churn, not a fix. Only the recorded surface, the\n * recorded numbers and this prose changed.\n * - The dark set still clears 3:1 on the LIGHTER card surface: the worst slot is\n * green `#008300` at 3.63:1, and the ordinal ramp's surface-nearest step lands\n * at 2.21:1 (down from 2.44:1 on the background) — still above the 2:1 gate.\n * That headroom is thin, so a future card-surface lightening MUST re-run these\n * four commands rather than assume the set still holds.\n * - The light-mode contrast WARN is NOT dismissable. Three slots (aqua, yellow,\n * magenta) sit below 3:1 on white, so every surface that paints with this\n * palette MUST ship the relief channel: a visible legend, direct labels and a\n * tooltip carrying the value in text. The timeline chart and the breakdown\n * table both do. The light card is `#ffffff`, identical to the light\n * background, so this WARN is unchanged rather than newly incurred.\n * - CVD separation is measured on ADJACENT pairs, which is the correct pairlist\n * for stacked bars, grouped bars and lines — the only forms this palette paints.\n * A scatter / bubble / small-multiples chart would need `--pairs all`, which\n * caps the usable slot count at three; do not reuse this array there without\n * re-running the validator with that flag.\n */\n\n/** Which surface the colours are being painted on. */\nexport type ChartMode = \"light\" | \"dark\";\n\n/**\n * The chart surfaces the palette was validated against (globals.css `--card`).\n *\n * `--card`, never `--background`: the charts are painted inside a `<Card>`.\n */\nexport const CHART_SURFACE: Readonly<Record<ChartMode, string>> = {\n light: \"#ffffff\",\n dark: \"#171717\",\n};\n\n/**\n * Categorical slots, in FIXED order. Slot n is series n — the order is the\n * CVD-safety mechanism, not decoration, so it is never re-ordered and never\n * cycled. The two-series default (customer / platform) takes slots 0 and 1.\n *\n * Hues, in order: blue, orange, aqua, yellow, magenta, green, violet.\n */\nconst CATEGORICAL_LIGHT: readonly string[] = [\n \"#2a78d6\",\n \"#eb6834\",\n \"#1baf7a\",\n \"#eda100\",\n \"#e87ba4\",\n \"#008300\",\n \"#4a3aa7\",\n];\n\n/** The same seven hues, re-stepped for the dark surface. Not a lightness flip. */\nconst CATEGORICAL_DARK: readonly string[] = [\n \"#3987e5\",\n \"#d95926\",\n \"#199e70\",\n \"#c98500\",\n \"#d55181\",\n \"#008300\",\n \"#9085e9\",\n];\n\n/**\n * The default (light-surface) categorical set.\n *\n * Prefer `seriesColor(index, mode)` — this array exists for consumers that only\n * need the documented default order.\n */\nexport const CATEGORICAL: readonly string[] = CATEGORICAL_LIGHT;\n\n/**\n * How many series may carry their own identity hue. An 8th series is NEVER a\n * generated hue: it folds into `other`.\n */\nexport const CATEGORICAL_CEILING = CATEGORICAL_LIGHT.length;\n\n/**\n * The \"other\" rollup colour: deliberately achromatic so it reads as \"not an\n * identity\" beside the seven hues. Same step in both modes — it clears 3:1 on\n * both card surfaces (3.59:1 on `#ffffff`, 4.99:1 on `#171717`).\n */\nexport const OTHER_COLOR = \"#898781\";\n\n/**\n * Sequential (single-hue, blue) ramp for MAGNITUDE, indexed by rank position:\n * index 0 is rank 1 — the largest value — so the strongest step leads.\n *\n * On the light surface \"strongest\" is the darkest step; on the dark surface it\n * is the lightest. The anchor flips with the surface, which is why there are two\n * selected sets rather than one array reversed at runtime.\n *\n * Five steps, not eight: with the adjacent-ΔL ≥ 0.06 gate and the ≥ 2:1\n * surface-contrast gate on the step nearest the surface, the blue ramp fits\n * exactly five distinguishable steps. Consumers clamp past the end.\n */\nconst SEQUENTIAL_RAMP_LIGHT: readonly string[] = [\"#104281\", \"#1c5cab\", \"#2a78d6\", \"#5598e7\", \"#86b6ef\"];\n\nconst SEQUENTIAL_RAMP_DARK: readonly string[] = [\"#9ec5f4\", \"#6da7ec\", \"#3987e5\", \"#256abf\", \"#184f95\"];\n\n/**\n * The default (light-surface) sequential ramp.\n *\n * Prefer `sequentialColor(index, mode)` — this array exists for consumers that\n * only need the documented default.\n */\nexport const SEQUENTIAL_RAMP: readonly string[] = SEQUENTIAL_RAMP_LIGHT;\n\nconst categoricalSet = (mode: ChartMode): readonly string[] => (mode === \"dark\" ? CATEGORICAL_DARK : CATEGORICAL_LIGHT);\n\nconst sequentialSet = (mode: ChartMode): readonly string[] =>\n mode === \"dark\" ? SEQUENTIAL_RAMP_DARK : SEQUENTIAL_RAMP_LIGHT;\n\n/**\n * The identity colour for series `index`.\n *\n * Never generates a hue and never cycles: anything at or past the ceiling gets\n * `OTHER_COLOR`, because a series past the ceiling should already have been\n * folded into the \"other\" bucket by the caller.\n */\nexport function seriesColor(index: number, mode: ChartMode = \"light\"): string {\n if (index < 0 || index >= CATEGORICAL_CEILING) return OTHER_COLOR;\n return categoricalSet(mode)[index];\n}\n\n/**\n * Both mode steps for series `index`, shaped for a shadcn `ChartConfig` entry's\n * `theme` field.\n */\nexport function seriesTheme(index: number): { light: string; dark: string } {\n return { light: seriesColor(index, \"light\"), dark: seriesColor(index, \"dark\") };\n}\n\n/**\n * The magnitude colour for rank position `index`, clamped to the last step so a\n * long list keeps its weakest step rather than falling off the ramp.\n */\nexport function sequentialColor(index: number, mode: ChartMode = \"light\"): string {\n const ramp = sequentialSet(mode);\n const clamped = Math.min(Math.max(index, 0), ramp.length - 1);\n return ramp[clamped];\n}\n"]}
|
|
@@ -10,12 +10,12 @@ var _chunkG4JR3SFVjs = require('./chunk-G4JR3SFV.js');
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunk5PNDDYGLjs = require('./chunk-5PNDDYGL.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkGHE4VT2Rjs = require('./chunk-GHE4VT2R.js');
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
|
|
@@ -51,7 +51,7 @@ var ServerSession = class {
|
|
|
51
51
|
const headerStore = await _headers.headers.call(void 0, );
|
|
52
52
|
const token = _optionalChain([cookieStore, 'access', _ => _.get, 'call', _2 => _2("token"), 'optionalAccess', _3 => _3.value]) || void 0;
|
|
53
53
|
const roles = _optionalChain([cookieStore, 'access', _4 => _4.get, 'call', _5 => _5("roles"), 'optionalAccess', _6 => _6.value]);
|
|
54
|
-
const viewportCookie = _optionalChain([cookieStore, 'access', _7 => _7.get, 'call', _8 => _8(
|
|
54
|
+
const viewportCookie = _optionalChain([cookieStore, 'access', _7 => _7.get, 'call', _8 => _8(_chunk5PNDDYGLjs.VIEWPORT_COOKIE_NAME), 'optionalAccess', _9 => _9.value]);
|
|
55
55
|
return {
|
|
56
56
|
isLogged: !!token,
|
|
57
57
|
isAdministrator: !!roles && roles.includes(_chunkG4JR3SFVjs.getRoleId.call(void 0, ).Administrator),
|
|
@@ -99,7 +99,7 @@ var ServerSession = class {
|
|
|
99
99
|
if (!rawModules) return false;
|
|
100
100
|
const modules = JSON.parse(_pako.ungzip.call(void 0, Buffer.from(rawModules, "base64"), { toText: true }));
|
|
101
101
|
const selectedModule = modules.find((module) => module.id === params.module.moduleId);
|
|
102
|
-
return
|
|
102
|
+
return _chunk5PNDDYGLjs.checkPermissionsFromServer.call(void 0, {
|
|
103
103
|
module: params.module,
|
|
104
104
|
action: params.action,
|
|
105
105
|
data: params.data,
|
|
@@ -122,7 +122,7 @@ function getServerApiUrl() {
|
|
|
122
122
|
if (_optionalChain([_serverConfig, 'optionalAccess', _31 => _31.apiUrl])) {
|
|
123
123
|
return _serverConfig.apiUrl;
|
|
124
124
|
}
|
|
125
|
-
const envUrl =
|
|
125
|
+
const envUrl = _chunkGHE4VT2Rjs.ENV.API_URL;
|
|
126
126
|
if (!envUrl) {
|
|
127
127
|
throw new Error(
|
|
128
128
|
"API URL not configured. Use configureServerJsonApi() or set NEXT_PUBLIC_API_URL environment variable."
|
|
@@ -135,7 +135,7 @@ function getServerAppUrl() {
|
|
|
135
135
|
if (_optionalChain([_serverConfig, 'optionalAccess', _32 => _32.appUrl])) {
|
|
136
136
|
return _serverConfig.appUrl;
|
|
137
137
|
}
|
|
138
|
-
const envUrl =
|
|
138
|
+
const envUrl = _chunkGHE4VT2Rjs.ENV.APP_URL;
|
|
139
139
|
if (!envUrl) {
|
|
140
140
|
throw new Error(
|
|
141
141
|
"App URL not configured. Use configureServerJsonApi({ appUrl }) or set NEXT_PUBLIC_ADDRESS environment variable."
|
|
@@ -171,7 +171,7 @@ async function ServerJsonApiGet(params) {
|
|
|
171
171
|
language: params.language,
|
|
172
172
|
additionalHeaders: _optionalChain([_serverConfig, 'optionalAccess', _35 => _35.additionalHeaders])
|
|
173
173
|
});
|
|
174
|
-
return
|
|
174
|
+
return _chunkGHE4VT2Rjs.translateResponse.call(void 0, {
|
|
175
175
|
classKey: params.classKey,
|
|
176
176
|
apiResponse,
|
|
177
177
|
companyId: params.companyId,
|
|
@@ -192,7 +192,7 @@ async function ServerJsonApiPost(params) {
|
|
|
192
192
|
if (!body) {
|
|
193
193
|
body = {};
|
|
194
194
|
} else if (params.overridesJsonApiCreation !== true) {
|
|
195
|
-
body =
|
|
195
|
+
body = _chunkGHE4VT2Rjs.JsonApiDataFactory.create(params.classKey, body);
|
|
196
196
|
}
|
|
197
197
|
const apiResponse = await _chunk6TUB7Y6Tjs.serverRequest.call(void 0, {
|
|
198
198
|
method: "POST",
|
|
@@ -204,7 +204,7 @@ async function ServerJsonApiPost(params) {
|
|
|
204
204
|
language: params.language,
|
|
205
205
|
additionalHeaders: _optionalChain([_serverConfig, 'optionalAccess', _36 => _36.additionalHeaders])
|
|
206
206
|
});
|
|
207
|
-
return
|
|
207
|
+
return _chunkGHE4VT2Rjs.translateResponse.call(void 0, {
|
|
208
208
|
classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
|
|
209
209
|
apiResponse,
|
|
210
210
|
companyId: params.companyId,
|
|
@@ -219,7 +219,7 @@ async function ServerJsonApiPut(params) {
|
|
|
219
219
|
if (!body) {
|
|
220
220
|
body = {};
|
|
221
221
|
} else {
|
|
222
|
-
body =
|
|
222
|
+
body = _chunkGHE4VT2Rjs.JsonApiDataFactory.create(params.classKey, body);
|
|
223
223
|
}
|
|
224
224
|
const apiResponse = await _chunk6TUB7Y6Tjs.serverRequest.call(void 0, {
|
|
225
225
|
method: "PUT",
|
|
@@ -231,7 +231,7 @@ async function ServerJsonApiPut(params) {
|
|
|
231
231
|
language: params.language,
|
|
232
232
|
additionalHeaders: _optionalChain([_serverConfig, 'optionalAccess', _37 => _37.additionalHeaders])
|
|
233
233
|
});
|
|
234
|
-
return
|
|
234
|
+
return _chunkGHE4VT2Rjs.translateResponse.call(void 0, {
|
|
235
235
|
classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
|
|
236
236
|
apiResponse,
|
|
237
237
|
companyId: params.companyId,
|
|
@@ -246,7 +246,7 @@ async function ServerJsonApiPatch(params) {
|
|
|
246
246
|
if (!body) {
|
|
247
247
|
body = {};
|
|
248
248
|
} else if (params.overridesJsonApiCreation !== true) {
|
|
249
|
-
body =
|
|
249
|
+
body = _chunkGHE4VT2Rjs.JsonApiDataFactory.create(params.classKey, body);
|
|
250
250
|
}
|
|
251
251
|
const apiResponse = await _chunk6TUB7Y6Tjs.serverRequest.call(void 0, {
|
|
252
252
|
method: "PATCH",
|
|
@@ -258,7 +258,7 @@ async function ServerJsonApiPatch(params) {
|
|
|
258
258
|
language: params.language,
|
|
259
259
|
additionalHeaders: _optionalChain([_serverConfig, 'optionalAccess', _38 => _38.additionalHeaders])
|
|
260
260
|
});
|
|
261
|
-
return
|
|
261
|
+
return _chunkGHE4VT2Rjs.translateResponse.call(void 0, {
|
|
262
262
|
classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
|
|
263
263
|
apiResponse,
|
|
264
264
|
companyId: params.companyId,
|
|
@@ -277,7 +277,7 @@ async function ServerJsonApiDelete(params) {
|
|
|
277
277
|
language: params.language,
|
|
278
278
|
additionalHeaders: _optionalChain([_serverConfig, 'optionalAccess', _39 => _39.additionalHeaders])
|
|
279
279
|
});
|
|
280
|
-
return
|
|
280
|
+
return _chunkGHE4VT2Rjs.translateResponse.call(void 0, {
|
|
281
281
|
classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
|
|
282
282
|
apiResponse,
|
|
283
283
|
companyId: params.companyId,
|
|
@@ -301,4 +301,4 @@ _chunk7QVYU63Ejs.__name.call(void 0, ServerJsonApiDelete, "ServerJsonApiDelete")
|
|
|
301
301
|
|
|
302
302
|
|
|
303
303
|
exports.invalidateCacheTag = invalidateCacheTag; exports.invalidateCacheTags = invalidateCacheTags; exports.updateCacheTag = updateCacheTag; exports.ServerSession = ServerSession; exports.configureServerJsonApi = configureServerJsonApi; exports.getServerApiUrl = getServerApiUrl; exports.getServerAppUrl = getServerAppUrl; exports.getServerTrackablePages = getServerTrackablePages; exports.ServerJsonApiGet = ServerJsonApiGet; exports.ServerJsonApiPost = ServerJsonApiPost; exports.ServerJsonApiPut = ServerJsonApiPut; exports.ServerJsonApiPatch = ServerJsonApiPatch; exports.ServerJsonApiDelete = ServerJsonApiDelete;
|
|
304
|
-
//# sourceMappingURL=chunk-
|
|
304
|
+
//# sourceMappingURL=chunk-DYTKNSHY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-JEQ34Z5E.js","../src/server/cache.ts","../src/server/ServerSession.ts","../src/server/JsonApiServer.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACpBA,mCAAyC;AAkBzC,MAAA,SAAsB,kBAAA,CAAmB,GAAA,EAAa,QAAA,EAAwB,KAAA,EAAsB;AAClG,EAAA,kCAAA,GAAc,EAAK,OAAO,CAAA;AAC5B;AAFsB,qCAAA,kBAAA,EAAA,oBAAA,CAAA;AAUtB,MAAA,SAAsB,mBAAA,CAAoB,IAAA,EAAgB,QAAA,EAAwB,KAAA,EAAsB;AACtG,EAAA,IAAA,CAAA,MAAW,IAAA,GAAO,IAAA,EAAM;AACtB,IAAA,kCAAA,GAAc,EAAK,OAAO,CAAA;AAAA,EAC5B;AACF;AAJsB,qCAAA,mBAAA,EAAA,qBAAA,CAAA;AAYtB,MAAA,SAAsB,cAAA,CAAe,GAAA,EAA4B;AAC/D,EAAA,8BAAA,GAAa,CAAA;AACf;AAFsB,qCAAA,cAAA,EAAA,gBAAA,CAAA;ADJtB;AACA;AEvCA,uCAAiC;AACjC,6CAAyB;AACzB,qCAA0B;AAC1B,4BAAuB;AAahB,IAAM,cAAA,EAAN,MAAoB;AAAA,EAhB3B,OAgB2B;AAAA,IAAA,qCAAA,IAAA,EAAA,eAAA,CAAA;AAAA,EAAA;AAAA,EACzB,OAAA,MAAa,IAAA,CAAA,EAAiC;AAC5C,IAAA,MAAM,YAAA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AAC9B,IAAA;AAC2B,IAAA;AACnC,IAAA;AACkB,IAAA;AACD,IAAA;AACiB,IAAA;AACnC,EAAA;AAEwB,EAAA;AACiB,IAAA;AACxC,IAAA;AACkB,IAAA;AACD,IAAA;AAClB,EAAA;AACH;AAzBsB;AHyD6B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-JEQ34Z5E.js","sourcesContent":[null,"// Server-only utilities (NOT server actions - these cannot be called from client components)\n\nimport { revalidateTag, updateTag } from \"next/cache\";\n\nimport type { CacheProfile } from \"./cacheProfiles\";\n\nexport { CACHE_PROFILES, type CacheProfile } from \"./cacheProfiles\";\n\n/**\n * Revalidate a cache tag to invalidate cached data.\n * Next.js 16+ requires a profile parameter.\n *\n * With `\"max\"` the tagged entries are marked stale and served stale-while-revalidate\n * (a one-year window): the next request still gets the old data while fresh data loads\n * in the background. It is not an immediate invalidation. A Server Action that must\n * read its own write uses `updateCacheTag` instead.\n *\n * @param tag - The cache tag to invalidate\n * @param profile - The cache profile whose `expire` bounds how long stale data may be served (defaults to \"max\")\n */\nexport async function invalidateCacheTag(tag: string, profile: CacheProfile = \"max\"): Promise<void> {\n revalidateTag(tag, profile);\n}\n\n/**\n * Revalidate multiple cache tags.\n *\n * @param tags - Array of cache tags to invalidate\n * @param profile - The cache profile, see `invalidateCacheTag` (defaults to \"max\", stale-while-revalidate)\n */\nexport async function invalidateCacheTags(tags: string[], profile: CacheProfile = \"max\"): Promise<void> {\n for (const tag of tags) {\n revalidateTag(tag, profile);\n }\n}\n\n/**\n * Expire a cache tag immediately, so the same request reads fresh data (read-your-own-writes).\n * Wraps `updateTag`, which works in Server Actions only. Route Handlers use `invalidateCacheTag`.\n *\n * @param tag - The cache tag to expire\n */\nexport async function updateCacheTag(tag: string): Promise<void> {\n updateTag(tag);\n}\n","import { cookies, headers } from \"next/headers\";\nimport { redirect } from \"next/navigation\";\nimport { userAgent } from \"next/server\";\nimport { ungzip } from \"pako\";\nimport { Action, checkPermissionsFromServer, ModuleWithPermissions } from \"../permissions\";\nimport { getRoleId } from \"../roles/config\";\nimport { VIEWPORT_COOKIE_NAME } from \"../utils/use-mobile\";\n\nexport interface SessionSnapshot {\n isLogged: boolean;\n isAdministrator: boolean;\n token?: string;\n sidebarOpen: boolean;\n isMobile: boolean;\n}\n\nexport class ServerSession {\n static async read(): Promise<SessionSnapshot> {\n const cookieStore = await cookies();\n const headerStore = await headers();\n\n const token = cookieStore.get(\"token\")?.value || undefined;\n const roles = cookieStore.get(\"roles\")?.value;\n const viewportCookie = cookieStore.get(VIEWPORT_COOKIE_NAME)?.value;\n\n return {\n isLogged: !!token,\n isAdministrator: !!roles && roles.includes(getRoleId().Administrator),\n token,\n sidebarOpen: cookieStore.get(\"sidebar_state\")?.value !== \"false\",\n isMobile: viewportCookie ? viewportCookie === \"1\" : userAgent({ headers: headerStore }).device.type === \"mobile\",\n };\n }\n\n static async isLogged() {\n const cookieStore = await cookies();\n const token = cookieStore.get(\"token\");\n\n if (!token || !token.value) return false;\n return true;\n }\n\n static async companyId() {\n const cookieStore = await cookies();\n return cookieStore.get(\"companyId\")?.value ?? \"\";\n }\n\n static async userId() {\n const cookieStore = await cookies();\n return cookieStore.get(\"userId\")?.value ?? \"\";\n }\n\n static async checkPermission<M extends ModuleWithPermissions>(params: { module: M; action: Action; data?: any }) {\n if (!(await this.hasPermissionToModule(params))) redirect(`/401`);\n }\n\n static async hasRole(roleId: string): Promise<boolean> {\n const cookieStore = await cookies();\n const roles = cookieStore.get(\"roles\")?.value;\n\n if (!roles || !roles.includes(roleId)) return false;\n\n return true;\n }\n\n static async hasFeature(featureId: string): Promise<boolean> {\n const cookieStore = await cookies();\n const features = cookieStore.get(\"features\")?.value;\n\n if (!features || !features.includes(featureId)) return false;\n\n return true;\n }\n\n static async hasPermissionToModule<M extends ModuleWithPermissions>(params: {\n module: M;\n action: Action;\n data?: any;\n }): Promise<boolean> {\n const cookieStore = await cookies();\n\n if (params.module.feature) {\n const features = cookieStore.get(\"features\")?.value;\n\n if (features && !features.includes(params.module.feature)) return false;\n }\n\n const rawModules = cookieStore.get(\"modules\")?.value;\n if (!rawModules) return false;\n\n const modules: {\n id: string;\n permissions: {\n create: boolean | string;\n read: boolean | string;\n update: boolean | string;\n delete: boolean | string;\n };\n }[] = JSON.parse(ungzip(Buffer.from(rawModules, \"base64\"), { toText: true }));\n\n const selectedModule = modules.find((module) => module.id === params.module.moduleId);\n\n return checkPermissionsFromServer({\n module: params.module,\n action: params.action,\n data: params.data,\n userId: await this.userId(),\n selectedModule: selectedModule,\n });\n\n // if (!selectedModule) return false;\n\n // if (!selectedModule.permissions[params.action]) return false;\n // if (typeof selectedModule.permissions[params.action] === \"boolean\")\n // return selectedModule.permissions[params.action] as boolean;\n\n // if (!params.data) return false;\n\n // return params.data[selectedModule.permissions[params.action] as string] === this.userId;\n }\n}\n","// Server-only utilities (NOT server actions - these cannot be called from client components)\n\nimport { ENV } from \"../core/env\";\nimport { JsonApiDataFactory } from \"../core/factories/JsonApiDataFactory\";\nimport { ApiRequestDataTypeInterface } from \"../core/interfaces/ApiRequestDataTypeInterface\";\nimport { ApiResponseInterface } from \"../core/interfaces/ApiResponseInterface\";\nimport { translateResponse } from \"../core/utils/translateResponse\";\nimport { ModuleWithPermissions } from \"../permissions/types\";\nimport { serverRequest } from \"./request\";\nimport { getServerToken } from \"./token\";\n\n// Config storage for server contexts\nlet _serverConfig: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n} | null = null;\n\n/**\n * Configure the JSON:API server client.\n * Call this in your Bootstrapper or server initialization.\n */\nexport function configureServerJsonApi(config: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n}): void {\n _serverConfig = config;\n if (config.bootstrapper) {\n config.bootstrapper();\n }\n}\n\nexport function getServerApiUrl(): string {\n if (_serverConfig?.apiUrl) {\n return _serverConfig.apiUrl;\n }\n const envUrl = ENV.API_URL;\n if (!envUrl) {\n throw new Error(\n \"API URL not configured. Use configureServerJsonApi() or set NEXT_PUBLIC_API_URL environment variable.\",\n );\n }\n return envUrl;\n}\n\nexport function getServerAppUrl(): string {\n if (_serverConfig?.appUrl) {\n return _serverConfig.appUrl;\n }\n const envUrl = ENV.APP_URL;\n if (!envUrl) {\n throw new Error(\n \"App URL not configured. Use configureServerJsonApi({ appUrl }) or set NEXT_PUBLIC_ADDRESS environment variable.\",\n );\n }\n return envUrl.trim().replace(/\\/+$/, \"\");\n}\n\nexport function getServerTrackablePages(): ModuleWithPermissions[] {\n return _serverConfig?.trackablePages ?? [];\n}\n\nfunction runServerBootstrapper(): void {\n if (_serverConfig?.bootstrapper) {\n _serverConfig.bootstrapper();\n }\n}\n\nfunction buildServerUrl(endpoint: string): string {\n const apiUrl = getServerApiUrl();\n return endpoint.startsWith(\"http\") ? endpoint : `${apiUrl}${endpoint}`;\n}\n\nexport async function ServerJsonApiGet(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n language: string;\n}): Promise<ApiResponseInterface> {\n runServerBootstrapper();\n // A cached GET never sends the token, so it must not read the cookie either:\n // the read would make a public page dynamic.\n const token = params.classKey.cache ? undefined : await getServerToken();\n\n const apiResponse = await serverRequest({\n method: \"GET\",\n url: buildServerUrl(params.endpoint),\n token,\n cache: params.classKey.cache,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _serverConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n paginationHandler: async (endpoint: string) =>\n ServerJsonApiGet({\n classKey: params.classKey,\n endpoint,\n companyId: params.companyId,\n language: params.language,\n }),\n });\n}\n\nexport async function ServerJsonApiPost(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n overridesJsonApiCreation?: boolean;\n files?: { [key: string]: File | Blob } | File | Blob;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n}): Promise<ApiResponseInterface> {\n runServerBootstrapper();\n const token = await getServerToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else if (params.overridesJsonApiCreation !== true) {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await serverRequest({\n method: \"POST\",\n url: buildServerUrl(params.endpoint),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _serverConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ServerJsonApiPut(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n}): Promise<ApiResponseInterface> {\n runServerBootstrapper();\n const token = await getServerToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await serverRequest({\n method: \"PUT\",\n url: buildServerUrl(params.endpoint),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _serverConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ServerJsonApiPatch(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n overridesJsonApiCreation?: boolean;\n responseType?: ApiRequestDataTypeInterface;\n language: string;\n}): Promise<ApiResponseInterface> {\n runServerBootstrapper();\n const token = await getServerToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else if (params.overridesJsonApiCreation !== true) {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await serverRequest({\n method: \"PATCH\",\n url: buildServerUrl(params.endpoint),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _serverConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ServerJsonApiDelete(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n}): Promise<ApiResponseInterface> {\n runServerBootstrapper();\n const token = await getServerToken();\n\n const apiResponse = await serverRequest({\n method: \"DELETE\",\n url: buildServerUrl(params.endpoint),\n token,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _serverConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-DYTKNSHY.js","../src/server/cache.ts","../src/server/ServerSession.ts","../src/server/JsonApiServer.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACpBA,mCAAyC;AAkBzC,MAAA,SAAsB,kBAAA,CAAmB,GAAA,EAAa,QAAA,EAAwB,KAAA,EAAsB;AAClG,EAAA,kCAAA,GAAc,EAAK,OAAO,CAAA;AAC5B;AAFsB,qCAAA,kBAAA,EAAA,oBAAA,CAAA;AAUtB,MAAA,SAAsB,mBAAA,CAAoB,IAAA,EAAgB,QAAA,EAAwB,KAAA,EAAsB;AACtG,EAAA,IAAA,CAAA,MAAW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AA;AACA,IAAA;AACc,IAAA;AACI,IAAA;AACD,IAAA;AACiB,IAAA;AACnC,EAAA;AAEwB,EAAA;AACiB,IAAA;AACxC,IAAA;AACkB,IAAA;AACD,IAAA;AAClB,EAAA;AACH;AApCsB;AA+CY;AACV,EAAA;AACa,EAAA;AAEjB,EAAA;AACP,EAAA;AACD,IAAA;AACqC,EAAA;AACL,IAAA;AAC1C,EAAA;AAEwC,EAAA;AAC9B,IAAA;AAC2B,IAAA;AACnC,IAAA;AACA,IAAA;AACc,IAAA;AACI,IAAA;AACD,IAAA;AACiB,IAAA;AACnC,EAAA;AAEwB,EAAA;AACiB,IAAA;AACxC,IAAA;AACkB,IAAA;AACD,IAAA;AAClB,EAAA;AACH;AArCsB;AA6CY;AACV,EAAA;AACa,EAAA;AAEK,EAAA;AAC9B,IAAA;AAC2B,IAAA;AACnC,IAAA;AACkB,IAAA;AACD,IAAA;AACiB,IAAA;AACnC,EAAA;AAEwB,EAAA;AACiB,IAAA;AACxC,IAAA;AACkB,IAAA;AACD,IAAA;AAClB,EAAA;AACH;AAzBsB;AHyD6B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-DYTKNSHY.js","sourcesContent":[null,"// Server-only utilities (NOT server actions - these cannot be called from client components)\n\nimport { revalidateTag, updateTag } from \"next/cache\";\n\nimport type { CacheProfile } from \"./cacheProfiles\";\n\nexport { CACHE_PROFILES, type CacheProfile } from \"./cacheProfiles\";\n\n/**\n * Revalidate a cache tag to invalidate cached data.\n * Next.js 16+ requires a profile parameter.\n *\n * With `\"max\"` the tagged entries are marked stale and served stale-while-revalidate\n * (a one-year window): the next request still gets the old data while fresh data loads\n * in the background. It is not an immediate invalidation. A Server Action that must\n * read its own write uses `updateCacheTag` instead.\n *\n * @param tag - The cache tag to invalidate\n * @param profile - The cache profile whose `expire` bounds how long stale data may be served (defaults to \"max\")\n */\nexport async function invalidateCacheTag(tag: string, profile: CacheProfile = \"max\"): Promise<void> {\n revalidateTag(tag, profile);\n}\n\n/**\n * Revalidate multiple cache tags.\n *\n * @param tags - Array of cache tags to invalidate\n * @param profile - The cache profile, see `invalidateCacheTag` (defaults to \"max\", stale-while-revalidate)\n */\nexport async function invalidateCacheTags(tags: string[], profile: CacheProfile = \"max\"): Promise<void> {\n for (const tag of tags) {\n revalidateTag(tag, profile);\n }\n}\n\n/**\n * Expire a cache tag immediately, so the same request reads fresh data (read-your-own-writes).\n * Wraps `updateTag`, which works in Server Actions only. Route Handlers use `invalidateCacheTag`.\n *\n * @param tag - The cache tag to expire\n */\nexport async function updateCacheTag(tag: string): Promise<void> {\n updateTag(tag);\n}\n","import { cookies, headers } from \"next/headers\";\nimport { redirect } from \"next/navigation\";\nimport { userAgent } from \"next/server\";\nimport { ungzip } from \"pako\";\nimport { Action, checkPermissionsFromServer, ModuleWithPermissions } from \"../permissions\";\nimport { getRoleId } from \"../roles/config\";\nimport { VIEWPORT_COOKIE_NAME } from \"../utils/use-mobile\";\n\nexport interface SessionSnapshot {\n isLogged: boolean;\n isAdministrator: boolean;\n token?: string;\n sidebarOpen: boolean;\n isMobile: boolean;\n}\n\nexport class ServerSession {\n static async read(): Promise<SessionSnapshot> {\n const cookieStore = await cookies();\n const headerStore = await headers();\n\n const token = cookieStore.get(\"token\")?.value || undefined;\n const roles = cookieStore.get(\"roles\")?.value;\n const viewportCookie = cookieStore.get(VIEWPORT_COOKIE_NAME)?.value;\n\n return {\n isLogged: !!token,\n isAdministrator: !!roles && roles.includes(getRoleId().Administrator),\n token,\n sidebarOpen: cookieStore.get(\"sidebar_state\")?.value !== \"false\",\n isMobile: viewportCookie ? viewportCookie === \"1\" : userAgent({ headers: headerStore }).device.type === \"mobile\",\n };\n }\n\n static async isLogged() {\n const cookieStore = await cookies();\n const token = cookieStore.get(\"token\");\n\n if (!token || !token.value) return false;\n return true;\n }\n\n static async companyId() {\n const cookieStore = await cookies();\n return cookieStore.get(\"companyId\")?.value ?? \"\";\n }\n\n static async userId() {\n const cookieStore = await cookies();\n return cookieStore.get(\"userId\")?.value ?? \"\";\n }\n\n static async checkPermission<M extends ModuleWithPermissions>(params: { module: M; action: Action; data?: any }) {\n if (!(await this.hasPermissionToModule(params))) redirect(`/401`);\n }\n\n static async hasRole(roleId: string): Promise<boolean> {\n const cookieStore = await cookies();\n const roles = cookieStore.get(\"roles\")?.value;\n\n if (!roles || !roles.includes(roleId)) return false;\n\n return true;\n }\n\n static async hasFeature(featureId: string): Promise<boolean> {\n const cookieStore = await cookies();\n const features = cookieStore.get(\"features\")?.value;\n\n if (!features || !features.includes(featureId)) return false;\n\n return true;\n }\n\n static async hasPermissionToModule<M extends ModuleWithPermissions>(params: {\n module: M;\n action: Action;\n data?: any;\n }): Promise<boolean> {\n const cookieStore = await cookies();\n\n if (params.module.feature) {\n const features = cookieStore.get(\"features\")?.value;\n\n if (features && !features.includes(params.module.feature)) return false;\n }\n\n const rawModules = cookieStore.get(\"modules\")?.value;\n if (!rawModules) return false;\n\n const modules: {\n id: string;\n permissions: {\n create: boolean | string;\n read: boolean | string;\n update: boolean | string;\n delete: boolean | string;\n };\n }[] = JSON.parse(ungzip(Buffer.from(rawModules, \"base64\"), { toText: true }));\n\n const selectedModule = modules.find((module) => module.id === params.module.moduleId);\n\n return checkPermissionsFromServer({\n module: params.module,\n action: params.action,\n data: params.data,\n userId: await this.userId(),\n selectedModule: selectedModule,\n });\n\n // if (!selectedModule) return false;\n\n // if (!selectedModule.permissions[params.action]) return false;\n // if (typeof selectedModule.permissions[params.action] === \"boolean\")\n // return selectedModule.permissions[params.action] as boolean;\n\n // if (!params.data) return false;\n\n // return params.data[selectedModule.permissions[params.action] as string] === this.userId;\n }\n}\n","// Server-only utilities (NOT server actions - these cannot be called from client components)\n\nimport { ENV } from \"../core/env\";\nimport { JsonApiDataFactory } from \"../core/factories/JsonApiDataFactory\";\nimport { ApiRequestDataTypeInterface } from \"../core/interfaces/ApiRequestDataTypeInterface\";\nimport { ApiResponseInterface } from \"../core/interfaces/ApiResponseInterface\";\nimport { translateResponse } from \"../core/utils/translateResponse\";\nimport { ModuleWithPermissions } from \"../permissions/types\";\nimport { serverRequest } from \"./request\";\nimport { getServerToken } from \"./token\";\n\n// Config storage for server contexts\nlet _serverConfig: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n} | null = null;\n\n/**\n * Configure the JSON:API server client.\n * Call this in your Bootstrapper or server initialization.\n */\nexport function configureServerJsonApi(config: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n}): void {\n _serverConfig = config;\n if (config.bootstrapper) {\n config.bootstrapper();\n }\n}\n\nexport function getServerApiUrl(): string {\n if (_serverConfig?.apiUrl) {\n return _serverConfig.apiUrl;\n }\n const envUrl = ENV.API_URL;\n if (!envUrl) {\n throw new Error(\n \"API URL not configured. Use configureServerJsonApi() or set NEXT_PUBLIC_API_URL environment variable.\",\n );\n }\n return envUrl;\n}\n\nexport function getServerAppUrl(): string {\n if (_serverConfig?.appUrl) {\n return _serverConfig.appUrl;\n }\n const envUrl = ENV.APP_URL;\n if (!envUrl) {\n throw new Error(\n \"App URL not configured. Use configureServerJsonApi({ appUrl }) or set NEXT_PUBLIC_ADDRESS environment variable.\",\n );\n }\n return envUrl.trim().replace(/\\/+$/, \"\");\n}\n\nexport function getServerTrackablePages(): ModuleWithPermissions[] {\n return _serverConfig?.trackablePages ?? [];\n}\n\nfunction runServerBootstrapper(): void {\n if (_serverConfig?.bootstrapper) {\n _serverConfig.bootstrapper();\n }\n}\n\nfunction buildServerUrl(endpoint: string): string {\n const apiUrl = getServerApiUrl();\n return endpoint.startsWith(\"http\") ? endpoint : `${apiUrl}${endpoint}`;\n}\n\nexport async function ServerJsonApiGet(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n language: string;\n}): Promise<ApiResponseInterface> {\n runServerBootstrapper();\n // A cached GET never sends the token, so it must not read the cookie either:\n // the read would make a public page dynamic.\n const token = params.classKey.cache ? undefined : await getServerToken();\n\n const apiResponse = await serverRequest({\n method: \"GET\",\n url: buildServerUrl(params.endpoint),\n token,\n cache: params.classKey.cache,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _serverConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n paginationHandler: async (endpoint: string) =>\n ServerJsonApiGet({\n classKey: params.classKey,\n endpoint,\n companyId: params.companyId,\n language: params.language,\n }),\n });\n}\n\nexport async function ServerJsonApiPost(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n overridesJsonApiCreation?: boolean;\n files?: { [key: string]: File | Blob } | File | Blob;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n}): Promise<ApiResponseInterface> {\n runServerBootstrapper();\n const token = await getServerToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else if (params.overridesJsonApiCreation !== true) {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await serverRequest({\n method: \"POST\",\n url: buildServerUrl(params.endpoint),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _serverConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ServerJsonApiPut(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n}): Promise<ApiResponseInterface> {\n runServerBootstrapper();\n const token = await getServerToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await serverRequest({\n method: \"PUT\",\n url: buildServerUrl(params.endpoint),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _serverConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ServerJsonApiPatch(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n overridesJsonApiCreation?: boolean;\n responseType?: ApiRequestDataTypeInterface;\n language: string;\n}): Promise<ApiResponseInterface> {\n runServerBootstrapper();\n const token = await getServerToken();\n\n let body = params.body;\n if (!body) {\n body = {};\n } else if (params.overridesJsonApiCreation !== true) {\n body = JsonApiDataFactory.create(params.classKey, body);\n }\n\n const apiResponse = await serverRequest({\n method: \"PATCH\",\n url: buildServerUrl(params.endpoint),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _serverConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n\nexport async function ServerJsonApiDelete(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n}): Promise<ApiResponseInterface> {\n runServerBootstrapper();\n const token = await getServerToken();\n\n const apiResponse = await serverRequest({\n method: \"DELETE\",\n url: buildServerUrl(params.endpoint),\n token,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _serverConfig?.additionalHeaders,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n"]}
|