@carlonicora/nextjs-jsonapi 1.78.0 → 1.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/{AssistantMessageInterface-DS_tyJTV.d.ts → AssistantMessageInterface-DWnbd6J7.d.ts} +1 -1
  2. package/dist/{AssistantMessageInterface-D0Kwf8CR.d.mts → AssistantMessageInterface-Mla6kgPe.d.mts} +1 -1
  3. package/dist/{AuthComponent-Blbs06ud.d.ts → AuthComponent-B6DIk8Vf.d.ts} +1 -1
  4. package/dist/{AuthComponent-huIaK5rm.d.mts → AuthComponent-BKI0ZbtD.d.mts} +1 -1
  5. package/dist/{BlockNoteEditor-JXK3JGKJ.mjs → BlockNoteEditor-6CBDTVKV.mjs} +4 -4
  6. package/dist/{BlockNoteEditor-2G5UYALC.js → BlockNoteEditor-EH4HWI7H.js} +14 -14
  7. package/dist/{BlockNoteEditor-2G5UYALC.js.map → BlockNoteEditor-EH4HWI7H.js.map} +1 -1
  8. package/dist/RbacTypes-BTbr27Ew.d.mts +43 -0
  9. package/dist/RbacTypes-BTbr27Ew.d.ts +43 -0
  10. package/dist/{auth.interface-CQJ6A2Cj.d.ts → auth.interface-BBUgMZzs.d.ts} +1 -1
  11. package/dist/{auth.interface-Bdq7-8iV.d.mts → auth.interface-XYEREOD6.d.mts} +1 -1
  12. package/dist/billing/index.js +346 -346
  13. package/dist/billing/index.mjs +3 -3
  14. package/dist/{chunk-FDJQRIMY.js → chunk-5IEWLLLD.js} +61 -2
  15. package/dist/chunk-5IEWLLLD.js.map +1 -0
  16. package/dist/{chunk-I65SSQ5Z.mjs → chunk-BKM5U3DE.mjs} +60 -1
  17. package/dist/chunk-BKM5U3DE.mjs.map +1 -0
  18. package/dist/{chunk-NB6TIKHK.mjs → chunk-ENRSFVOS.mjs} +2064 -2295
  19. package/dist/chunk-ENRSFVOS.mjs.map +1 -0
  20. package/dist/{chunk-NZOUEN67.mjs → chunk-MEWXQEVE.mjs} +38 -29
  21. package/dist/{chunk-NZOUEN67.mjs.map → chunk-MEWXQEVE.mjs.map} +1 -1
  22. package/dist/{chunk-X4YDETTD.js → chunk-TWDSDTHU.js} +39 -30
  23. package/dist/chunk-TWDSDTHU.js.map +1 -0
  24. package/dist/{chunk-ZEDB6JVB.js → chunk-ZDP3MBUI.js} +1142 -1373
  25. package/dist/chunk-ZDP3MBUI.js.map +1 -0
  26. package/dist/client/index.d.mts +6 -24
  27. package/dist/client/index.d.ts +6 -24
  28. package/dist/client/index.js +4 -10
  29. package/dist/client/index.js.map +1 -1
  30. package/dist/client/index.mjs +3 -9
  31. package/dist/components/index.d.mts +32 -34
  32. package/dist/components/index.d.ts +32 -34
  33. package/dist/components/index.js +4 -10
  34. package/dist/components/index.js.map +1 -1
  35. package/dist/components/index.mjs +3 -9
  36. package/dist/{config-B3jKt9P7.d.ts → config-B5oBQVEA.d.ts} +1 -1
  37. package/dist/{config-DkHF61xA.d.mts → config-Bx_uh22h.d.mts} +1 -1
  38. package/dist/contexts/index.d.mts +41 -4
  39. package/dist/contexts/index.d.ts +41 -4
  40. package/dist/contexts/index.js +8 -4
  41. package/dist/contexts/index.js.map +1 -1
  42. package/dist/contexts/index.mjs +7 -3
  43. package/dist/core/index.d.mts +19 -11
  44. package/dist/core/index.d.ts +19 -11
  45. package/dist/core/index.js +4 -2
  46. package/dist/core/index.js.map +1 -1
  47. package/dist/core/index.mjs +3 -1
  48. package/dist/index.d.mts +117 -20
  49. package/dist/index.d.ts +117 -20
  50. package/dist/index.js +7 -3
  51. package/dist/index.js.map +1 -1
  52. package/dist/index.mjs +6 -2
  53. package/dist/{notification.interface-DG6obXUH.d.mts → notification.interface-DLZGtV7Z.d.mts} +1 -1
  54. package/dist/{notification.interface-DcSuc9CL.d.ts → notification.interface-aLEJbA_g.d.ts} +1 -1
  55. package/dist/{s3.service-DGilbikH.d.mts → s3.service-CVgLWaDc.d.mts} +2 -2
  56. package/dist/{s3.service-DjwEQJPe.d.ts → s3.service-SLlX0Zbz.d.ts} +2 -2
  57. package/dist/server/index.d.mts +3 -3
  58. package/dist/server/index.d.ts +3 -3
  59. package/dist/server/index.js +3 -3
  60. package/dist/server/index.mjs +1 -1
  61. package/dist/useDataListRetriever-BqJSFBck.d.mts +33 -0
  62. package/dist/useDataListRetriever-BqJSFBck.d.ts +33 -0
  63. package/dist/{useSocket-CmzVtg32.d.mts → useSocket-BkxHHujj.d.mts} +1 -1
  64. package/dist/{useSocket-8eUtnL7J.d.ts → useSocket-CMDjWFYm.d.ts} +1 -1
  65. package/package.json +1 -1
  66. package/src/client/index.ts +0 -4
  67. package/src/components/index.ts +0 -3
  68. package/src/contexts/index.ts +1 -0
  69. package/src/core/registry/ModuleRegistry.ts +1 -0
  70. package/src/features/rbac/components/RbacContainer.tsx +318 -49
  71. package/src/features/rbac/components/RbacPermissionPicker.tsx +144 -121
  72. package/src/features/rbac/contexts/RbacContext.tsx +209 -0
  73. package/src/features/rbac/contexts/index.ts +1 -0
  74. package/src/features/rbac/data/RbacMatrixModel.ts +84 -0
  75. package/src/features/rbac/data/RbacService.ts +61 -33
  76. package/src/features/rbac/data/RbacTypes.ts +28 -0
  77. package/src/features/rbac/data/index.ts +1 -0
  78. package/src/features/rbac/index.ts +1 -10
  79. package/src/features/rbac/rbac.module.ts +13 -0
  80. package/dist/ModulePathsInterface-BrdqgteS.d.mts +0 -31
  81. package/dist/ModulePathsInterface-DJKs7s_s.d.ts +0 -31
  82. package/dist/chunk-FDJQRIMY.js.map +0 -1
  83. package/dist/chunk-I65SSQ5Z.mjs.map +0 -1
  84. package/dist/chunk-NB6TIKHK.mjs.map +0 -1
  85. package/dist/chunk-X4YDETTD.js.map +0 -1
  86. package/dist/chunk-ZEDB6JVB.js.map +0 -1
  87. package/dist/useRbacState-C88O-5L8.d.ts +0 -77
  88. package/dist/useRbacState-mqYiRp3J.d.mts +0 -77
  89. package/src/features/rbac/components/RbacFeatureSection.tsx +0 -66
  90. package/src/features/rbac/components/RbacModuleTable.tsx +0 -121
  91. package/src/features/rbac/components/RbacToolbar.tsx +0 -40
  92. package/src/features/rbac/hooks/useRbacState.test.ts +0 -180
  93. package/src/features/rbac/hooks/useRbacState.ts +0 -319
  94. package/src/features/rbac/utils/RbacMigrationGenerator.test.ts +0 -124
  95. package/src/features/rbac/utils/RbacMigrationGenerator.ts +0 -184
  96. /package/dist/{BlockNoteEditor-JXK3JGKJ.mjs.map → BlockNoteEditor-6CBDTVKV.mjs.map} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  AbstractService,
3
3
  EndpointCreator,
4
4
  Modules
5
- } from "./chunk-I65SSQ5Z.mjs";
5
+ } from "./chunk-BKM5U3DE.mjs";
6
6
  import {
7
7
  setBootstrapper
8
8
  } from "./chunk-BTKJFMFL.mjs";
@@ -194,37 +194,46 @@ var RbacService = class extends AbstractService {
194
194
  static {
195
195
  __name(this, "RbacService");
196
196
  }
197
- static async getFeatures() {
198
- const endpoint = new EndpointCreator({ endpoint: Modules.Feature }).addAdditionalParam("fetchAll", "true");
199
- return this.callApi({
200
- type: Modules.Feature,
197
+ /**
198
+ * Fetch the current RBAC matrix plus each module's known BFS relationship
199
+ * paths (used by the permission picker as scope suggestions).
200
+ *
201
+ * Dev-only endpoint — see class header.
202
+ */
203
+ static async fetchMatrix() {
204
+ const endpoint = new EndpointCreator({ endpoint: Modules.RbacMatrix }).generate();
205
+ const model = await this.callApi({
206
+ type: Modules.RbacMatrix,
201
207
  method: "GET" /* GET */,
202
- endpoint: endpoint.generate()
208
+ endpoint
203
209
  });
210
+ return {
211
+ matrix: model.matrix ?? {},
212
+ modulePaths: model.modulePaths ?? {}
213
+ };
204
214
  }
205
- static async getRoles() {
206
- const endpoint = new EndpointCreator({ endpoint: Modules.Role }).addAdditionalParam("fetchAll", "true");
207
- return this.callApi({
208
- type: Modules.Role,
209
- method: "GET" /* GET */,
210
- endpoint: endpoint.generate()
211
- });
212
- }
213
- static async getPermissionMappings() {
214
- const endpoint = new EndpointCreator({ endpoint: Modules.PermissionMapping });
215
- return this.callApi({
216
- type: Modules.PermissionMapping,
217
- method: "GET" /* GET */,
218
- endpoint: endpoint.generate()
219
- });
220
- }
221
- static async getModuleRelationshipPaths() {
222
- const endpoint = new EndpointCreator({ endpoint: Modules.ModulePaths });
223
- return this.callApi({
224
- type: Modules.ModulePaths,
225
- method: "GET" /* GET */,
226
- endpoint: endpoint.generate()
215
+ /**
216
+ * Persist a matrix back to the declarative `permissions.ts` file.
217
+ *
218
+ * The backend serializes the matrix to formatted TypeScript using the
219
+ * provided `roleNames` / `moduleNames` lookup tables (so the emitted file
220
+ * references `RoleId.X` / `ModuleId.X` rather than raw UUIDs) and writes
221
+ * it to `outputPath` (absolute, or relative to the repo root).
222
+ *
223
+ * Dev-only endpoint — see class header.
224
+ */
225
+ static async saveMatrix(args) {
226
+ const endpoint = new EndpointCreator({ endpoint: Modules.RbacMatrix }).generate();
227
+ const model = await this.callApi({
228
+ type: Modules.RbacMatrix,
229
+ method: "PUT" /* PUT */,
230
+ endpoint,
231
+ input: args
227
232
  });
233
+ return {
234
+ bytesWritten: model.bytesWritten ?? 0,
235
+ path: model.path ?? ""
236
+ };
228
237
  }
229
238
  };
230
239
 
@@ -259,4 +268,4 @@ export {
259
268
  ACTION_TYPES,
260
269
  RbacService
261
270
  };
262
- //# sourceMappingURL=chunk-NZOUEN67.mjs.map
271
+ //# sourceMappingURL=chunk-MEWXQEVE.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client/config.ts","../src/i18n/config.ts","../src/login/config.ts","../src/roles/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"],"sourcesContent":["\"use client\";\n\nimport { ModuleWithPermissions } from \"../permissions/types\";\nimport { setBootstrapper } from \"../core/registry/bootstrapStore\";\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 */\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}): void {\n _clientConfig = config;\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 */\nexport function getApiUrl(): string {\n if (_clientConfig?.apiUrl) {\n return _clientConfig.apiUrl;\n }\n if (typeof process !== \"undefined\" && process.env?.NEXT_PUBLIC_API_URL) {\n return process.env.NEXT_PUBLIC_API_URL;\n }\n return \"\";\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 (typeof process !== \"undefined\" && process.env?.NEXT_PUBLIC_APP_URL) {\n return process.env.NEXT_PUBLIC_APP_URL;\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","import { ComponentType } from \"react\";\n\n// Types for injected hooks\nexport interface I18nRouter {\n push: (href: string) => void;\n replace: (href: string) => void;\n back: () => void;\n forward: () => void;\n refresh: () => void;\n prefetch: (href: string) => void;\n}\n\nexport type UseRouterHook = () => I18nRouter;\nexport type UseTranslationsHook = (namespace?: string) => (key: string, values?: Record<string, any>) => string;\nexport type UseLocaleHook = () => string;\n\nexport type UseDateFnsLocaleHook = () => any; // date-fns Locale type\nexport type LinkComponent = ComponentType<{ href: string; children: React.ReactNode; [key: string]: any }>;\n\nexport interface I18nConfig {\n useRouter: UseRouterHook;\n useTranslations: UseTranslationsHook;\n useLocale?: UseLocaleHook;\n useDateFnsLocale?: UseDateFnsLocaleHook;\n Link: LinkComponent;\n usePathname: () => string;\n}\n\n// Private storage\nlet _config: I18nConfig | null = null;\n\n// Configuration function (called by app at startup)\nexport function configureI18n(config: I18nConfig): void {\n _config = config;\n}\n\n// Hooks for library components to use\nexport function useI18nRouter(): I18nRouter {\n if (!_config?.useRouter) {\n throw new Error(\"i18n not configured. Call configureI18n() at app startup.\");\n }\n return _config.useRouter();\n}\n\nexport function useI18nTranslations(namespace?: string): (key: string, values?: Record<string, any>) => string {\n if (!_config?.useTranslations) {\n // Fallback: return key as-is (safe for server/client)\n return (key: string) => key;\n }\n return _config.useTranslations(namespace);\n}\n\nexport function getI18nLink(): LinkComponent {\n if (!_config?.Link) {\n throw new Error(\"i18n not configured. Call configureI18n() at app startup.\");\n }\n return _config.Link;\n}\n\nexport function useI18nLocale(): string {\n if (_config?.useLocale) {\n return _config.useLocale();\n }\n // Fallback to English (safe for server/client)\n return \"en\";\n}\n\nexport function useI18nDateFnsLocale(): any {\n if (_config?.useDateFnsLocale) {\n return _config.useDateFnsLocale();\n }\n // Fallback to undefined (Calendar will use default)\n return undefined;\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","/**\n * Role ID configuration interface\n * Apps provide their role IDs via configureRoles()\n */\nexport interface RoleIdConfig {\n Administrator: string;\n CompanyAdministrator: string;\n [key: string]: string; // Allow additional roles\n}\n\n// Private storage for the injected role IDs\nlet _roleId: RoleIdConfig | null = null;\n\n/**\n * Configure role IDs for the library\n * Call this at app startup to provide role ID constants\n *\n * @example\n * ```typescript\n * import { configureRoles } from \"@carlonicora/nextjs-jsonapi\";\n * import { RoleId } from \"@phlow/shared\";\n *\n * configureRoles(RoleId);\n * ```\n */\nexport function configureRoles(roleId: RoleIdConfig): void {\n _roleId = roleId;\n}\n\n/**\n * Get configured role IDs\n * @throws Error if roles not configured\n */\nexport function getRoleId(): RoleIdConfig {\n if (!_roleId) {\n throw new Error(\"Roles not configured. Call configureRoles() at app startup.\");\n }\n return _roleId;\n}\n\n/**\n * Check if roles have been configured\n */\nexport function isRolesConfigured(): boolean {\n return _roleId !== null;\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","import { AbstractService, EndpointCreator, HttpMethod, Modules } from \"../../../core\";\nimport { FeatureInterface } from \"../../feature\";\nimport { RoleInterface } from \"../../role\";\nimport { PermissionMappingInterface } from \"./PermissionMappingInterface\";\nimport { ModulePathsInterface } from \"./ModulePathsInterface\";\n\nexport class RbacService extends AbstractService {\n static async getFeatures(): Promise<FeatureInterface[]> {\n const endpoint = new EndpointCreator({ endpoint: Modules.Feature }).addAdditionalParam(\"fetchAll\", \"true\");\n\n return this.callApi<FeatureInterface[]>({\n type: Modules.Feature,\n method: HttpMethod.GET,\n endpoint: endpoint.generate(),\n });\n }\n\n static async getRoles(): Promise<RoleInterface[]> {\n const endpoint = new EndpointCreator({ endpoint: Modules.Role }).addAdditionalParam(\"fetchAll\", \"true\");\n\n return this.callApi<RoleInterface[]>({\n type: Modules.Role,\n method: HttpMethod.GET,\n endpoint: endpoint.generate(),\n });\n }\n\n static async getPermissionMappings(): Promise<PermissionMappingInterface[]> {\n const endpoint = new EndpointCreator({ endpoint: Modules.PermissionMapping });\n\n return this.callApi<PermissionMappingInterface[]>({\n type: Modules.PermissionMapping,\n method: HttpMethod.GET,\n endpoint: endpoint.generate(),\n });\n }\n\n static async getModuleRelationshipPaths(): Promise<ModulePathsInterface[]> {\n const endpoint = new EndpointCreator({ endpoint: Modules.ModulePaths });\n\n return this.callApi<ModulePathsInterface[]>({\n type: Modules.ModuleP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,WAAW,IAAI,gBAAgB,EAAE,UAAU,QAAQ,YAAY,CAAC;AAEtE,WAAO,KAAK,QAAgC;AAAA,MAC1C,MAAM,QAAQ;AAAA,MACd;AAAA,MACA,UAAU,SAAS,SAAS;AAAA,IAC9B,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/client/config.ts","../src/i18n/config.ts","../src/login/config.ts","../src/roles/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"],"sourcesContent":["\"use client\";\n\nimport { ModuleWithPermissions } from \"../permissions/types\";\nimport { setBootstrapper } from \"../core/registry/bootstrapStore\";\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 */\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}): void {\n _clientConfig = config;\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 */\nexport function getApiUrl(): string {\n if (_clientConfig?.apiUrl) {\n return _clientConfig.apiUrl;\n }\n if (typeof process !== \"undefined\" && process.env?.NEXT_PUBLIC_API_URL) {\n return process.env.NEXT_PUBLIC_API_URL;\n }\n return \"\";\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 (typeof process !== \"undefined\" && process.env?.NEXT_PUBLIC_APP_URL) {\n return process.env.NEXT_PUBLIC_APP_URL;\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","import { ComponentType } from \"react\";\n\n// Types for injected hooks\nexport interface I18nRouter {\n push: (href: string) => void;\n replace: (href: string) => void;\n back: () => void;\n forward: () => void;\n refresh: () => void;\n prefetch: (href: string) => void;\n}\n\nexport type UseRouterHook = () => I18nRouter;\nexport type UseTranslationsHook = (namespace?: string) => (key: string, values?: Record<string, any>) => string;\nexport type UseLocaleHook = () => string;\n\nexport type UseDateFnsLocaleHook = () => any; // date-fns Locale type\nexport type LinkComponent = ComponentType<{ href: string; children: React.ReactNode; [key: string]: any }>;\n\nexport interface I18nConfig {\n useRouter: UseRouterHook;\n useTranslations: UseTranslationsHook;\n useLocale?: UseLocaleHook;\n useDateFnsLocale?: UseDateFnsLocaleHook;\n Link: LinkComponent;\n usePathname: () => string;\n}\n\n// Private storage\nlet _config: I18nConfig | null = null;\n\n// Configuration function (called by app at startup)\nexport function configureI18n(config: I18nConfig): void {\n _config = config;\n}\n\n// Hooks for library components to use\nexport function useI18nRouter(): I18nRouter {\n if (!_config?.useRouter) {\n throw new Error(\"i18n not configured. Call configureI18n() at app startup.\");\n }\n return _config.useRouter();\n}\n\nexport function useI18nTranslations(namespace?: string): (key: string, values?: Record<string, any>) => string {\n if (!_config?.useTranslations) {\n // Fallback: return key as-is (safe for server/client)\n return (key: string) => key;\n }\n return _config.useTranslations(namespace);\n}\n\nexport function getI18nLink(): LinkComponent {\n if (!_config?.Link) {\n throw new Error(\"i18n not configured. Call configureI18n() at app startup.\");\n }\n return _config.Link;\n}\n\nexport function useI18nLocale(): string {\n if (_config?.useLocale) {\n return _config.useLocale();\n }\n // Fallback to English (safe for server/client)\n return \"en\";\n}\n\nexport function useI18nDateFnsLocale(): any {\n if (_config?.useDateFnsLocale) {\n return _config.useDateFnsLocale();\n }\n // Fallback to undefined (Calendar will use default)\n return undefined;\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","/**\n * Role ID configuration interface\n * Apps provide their role IDs via configureRoles()\n */\nexport interface RoleIdConfig {\n Administrator: string;\n CompanyAdministrator: string;\n [key: string]: string; // Allow additional roles\n}\n\n// Private storage for the injected role IDs\nlet _roleId: RoleIdConfig | null = null;\n\n/**\n * Configure role IDs for the library\n * Call this at app startup to provide role ID constants\n *\n * @example\n * ```typescript\n * import { configureRoles } from \"@carlonicora/nextjs-jsonapi\";\n * import { RoleId } from \"@phlow/shared\";\n *\n * configureRoles(RoleId);\n * ```\n */\nexport function configureRoles(roleId: RoleIdConfig): void {\n _roleId = roleId;\n}\n\n/**\n * Get configured role IDs\n * @throws Error if roles not configured\n */\nexport function getRoleId(): RoleIdConfig {\n if (!_roleId) {\n throw new Error(\"Roles not configured. Call configureRoles() at app startup.\");\n }\n return _roleId;\n}\n\n/**\n * Check if roles have been configured\n */\nexport function isRolesConfigured(): boolean {\n return _roleId !== null;\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"],"mappings":";;;;;;;;;;;;;AAMA,IAAI,gBAOO;AAMJ,SAAS,iBAAiB,QAOxB;AACP,kBAAgB;AAEhB,MAAI,OAAO,cAAc;AACvB,oBAAgB,OAAO,YAAY;AACnC,WAAO,aAAa;AAAA,EACtB;AACF;AAdgB;AAoBT,SAAS,sBAAsB,QAI7B;AACP,kBAAgB;AAClB;AANgB;AAWT,SAAS,YAAoB;AAClC,MAAI,eAAe,QAAQ;AACzB,WAAO,cAAc;AAAA,EACvB;AACA,MAAI,OAAO,YAAY,eAAe,QAAQ,KAAK,qBAAqB;AACtE,WAAO,QAAQ,IAAI;AAAA,EACrB;AACA,SAAO;AACT;AARgB;AAaT,SAAS,YAAoB;AAClC,MAAI,eAAe,QAAQ;AACzB,WAAO,cAAc;AAAA,EACvB;AACA,MAAI,OAAO,YAAY,eAAe,QAAQ,KAAK,qBAAqB;AACtE,WAAO,QAAQ,IAAI;AAAA,EACrB;AACA,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO,OAAO,SAAS;AAAA,EACzB;AACA,SAAO;AACT;AAXgB;AAgBT,SAAS,oBAA6C;AAC3D,SAAO,eAAe,kBAAkB,CAAC;AAC3C;AAFgB;AAOT,SAAS,0BAA8C;AAC5D,SAAO,eAAe;AACxB;AAFgB;;;ACzDhB,IAAI,UAA6B;AAG1B,SAAS,cAAc,QAA0B;AACtD,YAAU;AACZ;AAFgB;AAKT,SAAS,gBAA4B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K4B;AAClD,UAAM,WAAW,IAAI,gBAAgB,EAAE,UAAU,QAAQ,WAAW,CAAC,EAAE,SAAS;AAEhF,UAAM,QAAQ,MAAM,KAAK,QAAyB;AAAA,MAChD,MAAM,QAAQ;AAAA,MACd;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACT,CAAC;AAED,WAAO;AAAA,MACL,cAAc,MAAM,gBAAgB;AAAA,MACpC,MAAM,MAAM,QAAQ;AAAA,IACtB;AAAA,EACF;AACF;","names":[]}
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkFDJQRIMYjs = require('./chunk-FDJQRIMY.js');
5
+ var _chunk5IEWLLLDjs = require('./chunk-5IEWLLLD.js');
6
6
 
7
7
 
8
8
  var _chunk4MN547K7js = require('./chunk-4MN547K7.js');
@@ -190,41 +190,50 @@ var COMPANY_ADMINISTRATOR_ROLE_ID = "2e1eee00-6cba-4506-9059-ccd24e4ea5b0";
190
190
  var ACTION_TYPES = ["read", "create", "update", "delete"];
191
191
 
192
192
  // src/features/rbac/data/RbacService.ts
193
- var RbacService = class extends _chunkFDJQRIMYjs.AbstractService {
193
+ var RbacService = class extends _chunk5IEWLLLDjs.AbstractService {
194
194
  static {
195
195
  _chunk7QVYU63Ejs.__name.call(void 0, this, "RbacService");
196
196
  }
197
- static async getFeatures() {
198
- const endpoint = new (0, _chunkFDJQRIMYjs.EndpointCreator)({ endpoint: _chunkFDJQRIMYjs.Modules.Feature }).addAdditionalParam("fetchAll", "true");
199
- return this.callApi({
200
- type: _chunkFDJQRIMYjs.Modules.Feature,
197
+ /**
198
+ * Fetch the current RBAC matrix plus each module's known BFS relationship
199
+ * paths (used by the permission picker as scope suggestions).
200
+ *
201
+ * Dev-only endpoint — see class header.
202
+ */
203
+ static async fetchMatrix() {
204
+ const endpoint = new (0, _chunk5IEWLLLDjs.EndpointCreator)({ endpoint: _chunk5IEWLLLDjs.Modules.RbacMatrix }).generate();
205
+ const model = await this.callApi({
206
+ type: _chunk5IEWLLLDjs.Modules.RbacMatrix,
201
207
  method: "GET" /* GET */,
202
- endpoint: endpoint.generate()
208
+ endpoint
203
209
  });
210
+ return {
211
+ matrix: _nullishCoalesce(model.matrix, () => ( {})),
212
+ modulePaths: _nullishCoalesce(model.modulePaths, () => ( {}))
213
+ };
204
214
  }
205
- static async getRoles() {
206
- const endpoint = new (0, _chunkFDJQRIMYjs.EndpointCreator)({ endpoint: _chunkFDJQRIMYjs.Modules.Role }).addAdditionalParam("fetchAll", "true");
207
- return this.callApi({
208
- type: _chunkFDJQRIMYjs.Modules.Role,
209
- method: "GET" /* GET */,
210
- endpoint: endpoint.generate()
211
- });
212
- }
213
- static async getPermissionMappings() {
214
- const endpoint = new (0, _chunkFDJQRIMYjs.EndpointCreator)({ endpoint: _chunkFDJQRIMYjs.Modules.PermissionMapping });
215
- return this.callApi({
216
- type: _chunkFDJQRIMYjs.Modules.PermissionMapping,
217
- method: "GET" /* GET */,
218
- endpoint: endpoint.generate()
219
- });
220
- }
221
- static async getModuleRelationshipPaths() {
222
- const endpoint = new (0, _chunkFDJQRIMYjs.EndpointCreator)({ endpoint: _chunkFDJQRIMYjs.Modules.ModulePaths });
223
- return this.callApi({
224
- type: _chunkFDJQRIMYjs.Modules.ModulePaths,
225
- method: "GET" /* GET */,
226
- endpoint: endpoint.generate()
215
+ /**
216
+ * Persist a matrix back to the declarative `permissions.ts` file.
217
+ *
218
+ * The backend serializes the matrix to formatted TypeScript using the
219
+ * provided `roleNames` / `moduleNames` lookup tables (so the emitted file
220
+ * references `RoleId.X` / `ModuleId.X` rather than raw UUIDs) and writes
221
+ * it to `outputPath` (absolute, or relative to the repo root).
222
+ *
223
+ * Dev-only endpoint — see class header.
224
+ */
225
+ static async saveMatrix(args) {
226
+ const endpoint = new (0, _chunk5IEWLLLDjs.EndpointCreator)({ endpoint: _chunk5IEWLLLDjs.Modules.RbacMatrix }).generate();
227
+ const model = await this.callApi({
228
+ type: _chunk5IEWLLLDjs.Modules.RbacMatrix,
229
+ method: "PUT" /* PUT */,
230
+ endpoint,
231
+ input: args
227
232
  });
233
+ return {
234
+ bytesWritten: _nullishCoalesce(model.bytesWritten, () => ( 0)),
235
+ path: _nullishCoalesce(model.path, () => ( ""))
236
+ };
228
237
  }
229
238
  };
230
239
 
@@ -259,4 +268,4 @@ var RbacService = class extends _chunkFDJQRIMYjs.AbstractService {
259
268
 
260
269
 
261
270
  exports.configureJsonApi = configureJsonApi; exports.configureClientConfig = configureClientConfig; exports.getApiUrl = getApiUrl; exports.getAppUrl = getAppUrl; exports.getTrackablePages = getTrackablePages; exports.getStripePublishableKey = getStripePublishableKey; exports.configureI18n = configureI18n; exports.useI18nRouter = useI18nRouter; exports.useI18nTranslations = useI18nTranslations; exports.getI18nLink = getI18nLink; exports.useI18nLocale = useI18nLocale; exports.useI18nDateFnsLocale = useI18nDateFnsLocale; exports.configureLogin = configureLogin; exports.isDiscordAuthEnabled = isDiscordAuthEnabled; exports.isGoogleAuthEnabled = isGoogleAuthEnabled; exports.isInternalAuthEnabled = isInternalAuthEnabled; exports.isRegistrationAllowed = isRegistrationAllowed; exports.getRegistrationMode = getRegistrationMode; exports.configureRoles = configureRoles; exports.getRoleId = getRoleId; exports.isRolesConfigured = isRolesConfigured; 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;
262
- //# sourceMappingURL=chunk-X4YDETTD.js.map
271
+ //# sourceMappingURL=chunk-TWDSDTHU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-TWDSDTHU.js","../src/client/config.ts","../src/i18n/config.ts","../src/login/config.ts","../src/roles/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;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNA,IAAI,cAAA,EAOO,IAAA;AAMJ,SAAS,gBAAA,CAAiB,MAAA,EAOxB;AACP,EAAA,cAAA,EAAgB,MAAA;AAEhB,EAAA,GAAA,CAAI,MAAA,CAAO,YAAA,EAAc;AACvB,IAAA,8CAAA,MAAgB,CAAO,YAAY,CAAA;AACnC,IAAA,MAAA,CAAO,YAAA,CAAa,CAAA;AAAA,EACtB;AACF;AAdgB,qCAAA,gBAAA,EAAA,kBAAA,CAAA;AAoBT,SAAS,qBAAA,CAAsB,MAAA,EAI7B;AACP,EAAA,cAAA,EAAgB,MAAA;AAClB;AANgB,qCAAA,qBAAA,EAAA,uBAAA,CAAA;AAWT,SAAS,SAAA,CAAA,EAAoB;AAClC,EAAA,GAAA,iBAAI,aAAA,2BAAe,QAAA,EAAQ;AACzB,IAAA,OAAO,aAAA,CAAc,MAAA;AAAA,EACvB;AACA,EAAA,GAAA,CAAI,OAAO,QAAA,IAAY,YAAA,mBAAe,OAAA,qBAAQ,GAAA,6BAAK,qBAAA,EAAqB;AACtE,IAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,mBAAA;AAAA,EACrB;AACA,EAAA,OAAO,EAAA;AACT;AARgB,qCAAA,SAAA,EAAA,WAAA,CAAA;AAaT,SAAS,SAAA,CAAA,EAAoB;AAClC,EAAA,GAAA,iBAAI,aAAA,6BAAe,QAAA,EAAQ;AACzB,IAAA,OAAO,aAAA,CAAc,MAAA;AAAA,EACvB;AACA,EAAA,GAAA,CAAI,OAAO,QAAA,IAAY,YAAA,mBAAe,OAAA,qBAAQ,GAAA,6BAAK,qBAAA,EAAqB;AACtE,IAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,mBAAA;AAAA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AED,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;ARoKA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,8yCAAC","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-TWDSDTHU.js","sourcesContent":[null,"\"use client\";\n\nimport { ModuleWithPermissions } from \"../permissions/types\";\nimport { setBootstrapper } from \"../core/registry/bootstrapStore\";\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 */\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}): void {\n _clientConfig = config;\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 */\nexport function getApiUrl(): string {\n if (_clientConfig?.apiUrl) {\n return _clientConfig.apiUrl;\n }\n if (typeof process !== \"undefined\" && process.env?.NEXT_PUBLIC_API_URL) {\n return process.env.NEXT_PUBLIC_API_URL;\n }\n return \"\";\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 (typeof process !== \"undefined\" && process.env?.NEXT_PUBLIC_APP_URL) {\n return process.env.NEXT_PUBLIC_APP_URL;\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","import { ComponentType } from \"react\";\n\n// Types for injected hooks\nexport interface I18nRouter {\n push: (href: string) => void;\n replace: (href: string) => void;\n back: () => void;\n forward: () => void;\n refresh: () => void;\n prefetch: (href: string) => void;\n}\n\nexport type UseRouterHook = () => I18nRouter;\nexport type UseTranslationsHook = (namespace?: string) => (key: string, values?: Record<string, any>) => string;\nexport type UseLocaleHook = () => string;\n\nexport type UseDateFnsLocaleHook = () => any; // date-fns Locale type\nexport type LinkComponent = ComponentType<{ href: string; children: React.ReactNode; [key: string]: any }>;\n\nexport interface I18nConfig {\n useRouter: UseRouterHook;\n useTranslations: UseTranslationsHook;\n useLocale?: UseLocaleHook;\n useDateFnsLocale?: UseDateFnsLocaleHook;\n Link: LinkComponent;\n usePathname: () => string;\n}\n\n// Private storage\nlet _config: I18nConfig | null = null;\n\n// Configuration function (called by app at startup)\nexport function configureI18n(config: I18nConfig): void {\n _config = config;\n}\n\n// Hooks for library components to use\nexport function useI18nRouter(): I18nRouter {\n if (!_config?.useRouter) {\n throw new Error(\"i18n not configured. Call configureI18n() at app startup.\");\n }\n return _config.useRouter();\n}\n\nexport function useI18nTranslations(namespace?: string): (key: string, values?: Record<string, any>) => string {\n if (!_config?.useTranslations) {\n // Fallback: return key as-is (safe for server/client)\n return (key: string) => key;\n }\n return _config.useTranslations(namespace);\n}\n\nexport function getI18nLink(): LinkComponent {\n if (!_config?.Link) {\n throw new Error(\"i18n not configured. Call configureI18n() at app startup.\");\n }\n return _config.Link;\n}\n\nexport function useI18nLocale(): string {\n if (_config?.useLocale) {\n return _config.useLocale();\n }\n // Fallback to English (safe for server/client)\n return \"en\";\n}\n\nexport function useI18nDateFnsLocale(): any {\n if (_config?.useDateFnsLocale) {\n return _config.useDateFnsLocale();\n }\n // Fallback to undefined (Calendar will use default)\n return undefined;\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","/**\n * Role ID configuration interface\n * Apps provide their role IDs via configureRoles()\n */\nexport interface RoleIdConfig {\n Administrator: string;\n CompanyAdministrator: string;\n [key: string]: string; // Allow additional roles\n}\n\n// Private storage for the injected role IDs\nlet _roleId: RoleIdConfig | null = null;\n\n/**\n * Configure role IDs for the library\n * Call this at app startup to provide role ID constants\n *\n * @example\n * ```typescript\n * import { configureRoles } from \"@carlonicora/nextjs-jsonapi\";\n * import { RoleId } from \"@phlow/shared\";\n *\n * configureRoles(RoleId);\n * ```\n */\nexport function configureRoles(roleId: RoleIdConfig): void {\n _roleId = roleId;\n}\n\n/**\n * Get configured role IDs\n * @throws Error if roles not configured\n */\nexport function getRoleId(): RoleIdConfig {\n if (!_roleId) {\n throw new Error(\"Roles not configured. Call configureRoles() at app startup.\");\n }\n return _roleId;\n}\n\n/**\n * Check if roles have been configured\n */\nexport function isRolesConfigured(): boolean {\n return _roleId !== null;\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"]}