@carlonicora/nextjs-jsonapi 6.22.0 → 6.24.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 (181) hide show
  1. package/dist/{BlockNoteEditor-2XSIQCEB.mjs → BlockNoteEditor-ENDOVTAW.mjs} +8 -8
  2. package/dist/{BlockNoteEditor-HW3TK7SM.js → BlockNoteEditor-MONT74RQ.js} +23 -23
  3. package/dist/{BlockNoteEditor-HW3TK7SM.js.map → BlockNoteEditor-MONT74RQ.js.map} +1 -1
  4. package/dist/{BlockNoteViewer-2UDFTXRS.mjs → BlockNoteViewer-2TJZ6JET.mjs} +6 -6
  5. package/dist/{BlockNoteViewer-4OHBRE4Q.js → BlockNoteViewer-K2HBF3IP.js} +7 -7
  6. package/dist/{BlockNoteViewer-4OHBRE4Q.js.map → BlockNoteViewer-K2HBF3IP.js.map} +1 -1
  7. package/dist/{JsonApiRequest-IKKHWCPB.mjs → JsonApiRequest-ADLBJ5RX.mjs} +2 -2
  8. package/dist/JsonApiRequest-KC6DOHKT.js +26 -0
  9. package/dist/{JsonApiRequest-G4J2WTSU.js.map → JsonApiRequest-KC6DOHKT.js.map} +1 -1
  10. package/dist/billing/index.js +495 -495
  11. package/dist/billing/index.mjs +7 -7
  12. package/dist/{chunk-N5ZE2Z6I.js → chunk-53SD4YRF.js} +5 -5
  13. package/dist/{chunk-N5ZE2Z6I.js.map → chunk-53SD4YRF.js.map} +1 -1
  14. package/dist/{chunk-4RA5PRXX.mjs → chunk-7OIWOPM5.mjs} +2 -2
  15. package/dist/{chunk-WCEYT3GG.js → chunk-A5M3MORY.js} +6 -3
  16. package/dist/chunk-A5M3MORY.js.map +1 -0
  17. package/dist/{chunk-FXRRQ7Q6.js → chunk-BDWV4KYR.js} +1224 -1221
  18. package/dist/chunk-BDWV4KYR.js.map +1 -0
  19. package/dist/{chunk-AUD6ZLBB.mjs → chunk-BE6UMM5X.mjs} +13 -8
  20. package/dist/chunk-BE6UMM5X.mjs.map +1 -0
  21. package/dist/{chunk-KV4N7DEG.js → chunk-BQ2WAG4K.js} +29 -24
  22. package/dist/chunk-BQ2WAG4K.js.map +1 -0
  23. package/dist/{chunk-OQQ7CZWT.js → chunk-GMMDXINC.js} +12 -12
  24. package/dist/{chunk-OQQ7CZWT.js.map → chunk-GMMDXINC.js.map} +1 -1
  25. package/dist/{chunk-ZB6OYIMB.js → chunk-HN7L6RRW.js} +1296 -1093
  26. package/dist/{chunk-DPXOPLQP.mjs.map → chunk-HN7L6RRW.js.map} +1 -1
  27. package/dist/{chunk-JSHLBRFV.mjs → chunk-N2BFT7KI.mjs} +2 -2
  28. package/dist/chunk-N2BFT7KI.mjs.map +1 -0
  29. package/dist/{chunk-EFQIMPCJ.mjs → chunk-OZADFYE7.mjs} +13 -10
  30. package/dist/chunk-OZADFYE7.mjs.map +1 -0
  31. package/dist/{chunk-YWLSIIE6.js → chunk-P7L6OFX5.js} +11 -11
  32. package/dist/{chunk-YWLSIIE6.js.map → chunk-P7L6OFX5.js.map} +1 -1
  33. package/dist/{chunk-GM4VZTWL.js → chunk-RCOKQ3R4.js} +14 -8
  34. package/dist/chunk-RCOKQ3R4.js.map +1 -0
  35. package/dist/{chunk-M3N7LPHX.mjs → chunk-S7SPAC6X.mjs} +6 -3
  36. package/dist/chunk-S7SPAC6X.mjs.map +1 -0
  37. package/dist/{chunk-54K2CZ2F.js → chunk-SO3YUCL6.js} +4 -4
  38. package/dist/{chunk-54K2CZ2F.js.map → chunk-SO3YUCL6.js.map} +1 -1
  39. package/dist/{chunk-DPXOPLQP.mjs → chunk-T6G2F2BK.mjs} +220 -17
  40. package/dist/chunk-T6G2F2BK.mjs.map +1 -0
  41. package/dist/{chunk-G2UIQSNJ.mjs → chunk-TMV7TL7O.mjs} +4 -4
  42. package/dist/{chunk-BD6ARGGI.js → chunk-TNTCLVUR.js} +15 -15
  43. package/dist/{chunk-BD6ARGGI.js.map → chunk-TNTCLVUR.js.map} +1 -1
  44. package/dist/{chunk-QIEF7HIL.mjs → chunk-VNUT2D27.mjs} +2 -2
  45. package/dist/{chunk-KTGKW72G.mjs → chunk-W4ML6D2X.mjs} +2 -2
  46. package/dist/{chunk-MQ7TXALH.mjs → chunk-YMCL3JXZ.mjs} +14 -8
  47. package/dist/chunk-YMCL3JXZ.mjs.map +1 -0
  48. package/dist/{chunk-QGVVF77L.js → chunk-YSE2Z4RB.js} +11 -11
  49. package/dist/{chunk-QGVVF77L.js.map → chunk-YSE2Z4RB.js.map} +1 -1
  50. package/dist/{chunk-A3RB47X4.mjs → chunk-YTDGYI62.mjs} +3 -3
  51. package/dist/client/JsonApiClient.d.ts +5 -0
  52. package/dist/client/JsonApiClient.d.ts.map +1 -1
  53. package/dist/client/index.js +8 -8
  54. package/dist/client/index.mjs +7 -7
  55. package/dist/client/request.d.ts +5 -0
  56. package/dist/client/request.d.ts.map +1 -1
  57. package/dist/components/forms/EditorSheet.d.ts +6 -1
  58. package/dist/components/forms/EditorSheet.d.ts.map +1 -1
  59. package/dist/components/index.js +8 -8
  60. package/dist/components/index.mjs +7 -7
  61. package/dist/contexts/index.js +8 -8
  62. package/dist/contexts/index.mjs +7 -7
  63. package/dist/core/abstracts/AbstractService.d.ts +5 -0
  64. package/dist/core/abstracts/AbstractService.d.ts.map +1 -1
  65. package/dist/core/abstracts/ClientAbstractService.d.ts +5 -0
  66. package/dist/core/abstracts/ClientAbstractService.d.ts.map +1 -1
  67. package/dist/core/index.d.ts +2 -0
  68. package/dist/core/index.d.ts.map +1 -1
  69. package/dist/core/index.js +24 -6
  70. package/dist/core/index.js.map +1 -1
  71. package/dist/core/index.mjs +23 -5
  72. package/dist/core/registry/ModuleRegistry.d.ts +3 -0
  73. package/dist/core/registry/ModuleRegistry.d.ts.map +1 -1
  74. package/dist/email-automations/index.js +121 -121
  75. package/dist/email-automations/index.mjs +7 -7
  76. package/dist/features/analytics/index.js +139 -139
  77. package/dist/features/analytics/index.mjs +7 -7
  78. package/dist/features/analytics/server.js +9 -9
  79. package/dist/features/analytics/server.mjs +7 -7
  80. package/dist/features/blog/index.js +154 -154
  81. package/dist/features/blog/index.mjs +7 -7
  82. package/dist/features/blog/server.js +27 -27
  83. package/dist/features/blog/server.mjs +6 -6
  84. package/dist/features/discord-connection/data/discord-connect-confirmation.d.ts +11 -0
  85. package/dist/features/discord-connection/data/discord-connect-confirmation.d.ts.map +1 -0
  86. package/dist/features/discord-connection/data/discord-connect-confirmation.interface.d.ts +14 -0
  87. package/dist/features/discord-connection/data/discord-connect-confirmation.interface.d.ts.map +1 -0
  88. package/dist/features/discord-connection/data/discord-connect-confirmation.service.d.ts +10 -0
  89. package/dist/features/discord-connection/data/discord-connect-confirmation.service.d.ts.map +1 -0
  90. package/dist/features/discord-connection/data/discord-connect-intent.d.ts +11 -0
  91. package/dist/features/discord-connection/data/discord-connect-intent.d.ts.map +1 -0
  92. package/dist/features/discord-connection/data/discord-connect-intent.interface.d.ts +15 -0
  93. package/dist/features/discord-connection/data/discord-connect-intent.interface.d.ts.map +1 -0
  94. package/dist/features/discord-connection/data/discord-connect-intent.service.d.ts +11 -0
  95. package/dist/features/discord-connection/data/discord-connect-intent.service.d.ts.map +1 -0
  96. package/dist/features/discord-connection/data/discord-connection.d.ts +14 -0
  97. package/dist/features/discord-connection/data/discord-connection.d.ts.map +1 -0
  98. package/dist/features/discord-connection/data/discord-connection.interface.d.ts +10 -0
  99. package/dist/features/discord-connection/data/discord-connection.interface.d.ts.map +1 -0
  100. package/dist/features/discord-connection/data/discord-connection.service.d.ts +12 -0
  101. package/dist/features/discord-connection/data/discord-connection.service.d.ts.map +1 -0
  102. package/dist/features/discord-connection/data/index.d.ts +10 -0
  103. package/dist/features/discord-connection/data/index.d.ts.map +1 -0
  104. package/dist/features/discord-connection/discord-connection.module.d.ts +5 -0
  105. package/dist/features/discord-connection/discord-connection.module.d.ts.map +1 -0
  106. package/dist/features/discord-connection/index.d.ts +3 -0
  107. package/dist/features/discord-connection/index.d.ts.map +1 -0
  108. package/dist/features/help/index.js +41 -41
  109. package/dist/features/help/index.mjs +7 -7
  110. package/dist/features/tokenusage/index.js +130 -130
  111. package/dist/features/tokenusage/index.mjs +7 -7
  112. package/dist/index.d.ts +1 -1
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +27 -7
  115. package/dist/index.js.map +1 -1
  116. package/dist/index.mjs +26 -6
  117. package/dist/local-transport-MJPOKPTU.js +15 -0
  118. package/dist/{local-transport-4YDJ6FQG.js.map → local-transport-MJPOKPTU.js.map} +1 -1
  119. package/dist/{local-transport-C7YTA4I7.mjs → local-transport-RVD4FZGA.mjs} +5 -5
  120. package/dist/offline/index.js +51 -51
  121. package/dist/offline/index.mjs +6 -6
  122. package/dist/{request-66FGJIHB.mjs → request-4AWGPIGH.mjs} +2 -2
  123. package/dist/{request-6W6UGKJV.js → request-H5FZBZA2.js} +3 -3
  124. package/dist/{request-6W6UGKJV.js.map → request-H5FZBZA2.js.map} +1 -1
  125. package/dist/server/index.js +8 -8
  126. package/dist/server/index.mjs +7 -7
  127. package/dist/unified/JsonApiRequest.d.ts +5 -0
  128. package/dist/unified/JsonApiRequest.d.ts.map +1 -1
  129. package/dist/write-through-7I3LA2WN.mjs +15 -0
  130. package/dist/write-through-HE2QSOVI.js +15 -0
  131. package/dist/{write-through-BAPS24GL.js.map → write-through-HE2QSOVI.js.map} +1 -1
  132. package/package.json +1 -1
  133. package/src/client/JsonApiClient.ts +10 -0
  134. package/src/client/__tests__/request.credentials.spec.ts +103 -0
  135. package/src/client/request.ts +9 -0
  136. package/src/components/forms/EditorSheet.tsx +8 -0
  137. package/src/components/forms/__tests__/EditorSheet.spec.tsx +30 -0
  138. package/src/core/abstracts/AbstractService.ts +10 -0
  139. package/src/core/abstracts/ClientAbstractService.ts +10 -0
  140. package/src/core/index.ts +3 -0
  141. package/src/core/registry/ModuleRegistry.ts +4 -0
  142. package/src/features/discord-connection/data/__tests__/DiscordConnection.spec.ts +114 -0
  143. package/src/features/discord-connection/data/discord-connect-confirmation.interface.ts +16 -0
  144. package/src/features/discord-connection/data/discord-connect-confirmation.service.ts +21 -0
  145. package/src/features/discord-connection/data/discord-connect-confirmation.ts +46 -0
  146. package/src/features/discord-connection/data/discord-connect-intent.interface.ts +16 -0
  147. package/src/features/discord-connection/data/discord-connect-intent.service.ts +20 -0
  148. package/src/features/discord-connection/data/discord-connect-intent.ts +42 -0
  149. package/src/features/discord-connection/data/discord-connection.interface.ts +10 -0
  150. package/src/features/discord-connection/data/discord-connection.service.ts +17 -0
  151. package/src/features/discord-connection/data/discord-connection.ts +41 -0
  152. package/src/features/discord-connection/data/index.ts +9 -0
  153. package/src/features/discord-connection/discord-connection.module.ts +28 -0
  154. package/src/features/discord-connection/index.ts +2 -0
  155. package/src/index.ts +1 -1
  156. package/src/unified/JsonApiRequest.ts +14 -0
  157. package/dist/JsonApiRequest-G4J2WTSU.js +0 -26
  158. package/dist/chunk-AUD6ZLBB.mjs.map +0 -1
  159. package/dist/chunk-EFQIMPCJ.mjs.map +0 -1
  160. package/dist/chunk-FXRRQ7Q6.js.map +0 -1
  161. package/dist/chunk-GM4VZTWL.js.map +0 -1
  162. package/dist/chunk-JSHLBRFV.mjs.map +0 -1
  163. package/dist/chunk-KV4N7DEG.js.map +0 -1
  164. package/dist/chunk-M3N7LPHX.mjs.map +0 -1
  165. package/dist/chunk-MQ7TXALH.mjs.map +0 -1
  166. package/dist/chunk-WCEYT3GG.js.map +0 -1
  167. package/dist/chunk-ZB6OYIMB.js.map +0 -1
  168. package/dist/local-transport-4YDJ6FQG.js +0 -15
  169. package/dist/write-through-BAPS24GL.js +0 -15
  170. package/dist/write-through-IWQKXYHE.mjs +0 -15
  171. /package/dist/{BlockNoteEditor-2XSIQCEB.mjs.map → BlockNoteEditor-ENDOVTAW.mjs.map} +0 -0
  172. /package/dist/{BlockNoteViewer-2UDFTXRS.mjs.map → BlockNoteViewer-2TJZ6JET.mjs.map} +0 -0
  173. /package/dist/{JsonApiRequest-IKKHWCPB.mjs.map → JsonApiRequest-ADLBJ5RX.mjs.map} +0 -0
  174. /package/dist/{chunk-4RA5PRXX.mjs.map → chunk-7OIWOPM5.mjs.map} +0 -0
  175. /package/dist/{chunk-G2UIQSNJ.mjs.map → chunk-TMV7TL7O.mjs.map} +0 -0
  176. /package/dist/{chunk-QIEF7HIL.mjs.map → chunk-VNUT2D27.mjs.map} +0 -0
  177. /package/dist/{chunk-KTGKW72G.mjs.map → chunk-W4ML6D2X.mjs.map} +0 -0
  178. /package/dist/{chunk-A3RB47X4.mjs.map → chunk-YTDGYI62.mjs.map} +0 -0
  179. /package/dist/{local-transport-C7YTA4I7.mjs.map → local-transport-RVD4FZGA.mjs.map} +0 -0
  180. /package/dist/{request-66FGJIHB.mjs.map → request-4AWGPIGH.mjs.map} +0 -0
  181. /package/dist/{write-through-IWQKXYHE.mjs.map → write-through-7I3LA2WN.mjs.map} +0 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkGM4VZTWLjs = require('./chunk-GM4VZTWL.js');
5
+ var _chunkRCOKQ3R4js = require('./chunk-RCOKQ3R4.js');
6
6
 
7
7
 
8
8
  var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
@@ -57,11 +57,11 @@ var RehydrationFactory = class {
57
57
  _chunk7QVYU63Ejs.__name.call(void 0, this, "RehydrationFactory");
58
58
  }
59
59
  static rehydrate(classKey, data) {
60
- const factoryClass = _chunkGM4VZTWLjs.DataClassRegistry.get(classKey);
60
+ const factoryClass = _chunkRCOKQ3R4js.DataClassRegistry.get(classKey);
61
61
  return session(() => guarded(factoryClass, data, () => new factoryClass().rehydrate(data)));
62
62
  }
63
63
  static rehydrateList(classKey, data) {
64
- const factoryClass = _chunkGM4VZTWLjs.DataClassRegistry.get(classKey);
64
+ const factoryClass = _chunkRCOKQ3R4js.DataClassRegistry.get(classKey);
65
65
  return session(
66
66
  () => data.map(
67
67
  (item) => guarded(factoryClass, item, () => new factoryClass().rehydrate(item))
@@ -365,13 +365,13 @@ var ModuleRegistryClass = class {
365
365
  get(name) {
366
366
  let module = this._modules.get(name);
367
367
  if (!module) {
368
- const didBootstrap = _chunkGM4VZTWLjs.tryBootstrap.call(void 0, );
368
+ const didBootstrap = _chunkRCOKQ3R4js.tryBootstrap.call(void 0, );
369
369
  if (didBootstrap) {
370
370
  module = this._modules.get(name);
371
371
  }
372
372
  }
373
373
  if (!module) {
374
- const hint = _chunkGM4VZTWLjs.hasBootstrapper.call(void 0, ) ? "Bootstrap was called but module still not found. Check module registration." : "No bootstrapper registered. Ensure configureJsonApi({ bootstrapper }) is called before accessing modules.";
374
+ const hint = _chunkRCOKQ3R4js.hasBootstrapper.call(void 0, ) ? "Bootstrap was called but module still not found. Check module registration." : "No bootstrapper registered. Ensure configureJsonApi({ bootstrapper }) is called before accessing modules.";
375
375
  throw new Error(`Module "${String(name)}" not registered. ${hint}`);
376
376
  }
377
377
  return module;
@@ -381,12 +381,12 @@ var ModuleRegistryClass = class {
381
381
  * can check for an opt-in module the app may not have registered.
382
382
  */
383
383
  has(name) {
384
- if (this._modules.size === 0) _chunkGM4VZTWLjs.tryBootstrap.call(void 0, );
384
+ if (this._modules.size === 0) _chunkRCOKQ3R4js.tryBootstrap.call(void 0, );
385
385
  return this._modules.has(name);
386
386
  }
387
387
  findByName(moduleName) {
388
388
  if (this._modules.size === 0) {
389
- _chunkGM4VZTWLjs.tryBootstrap.call(void 0, );
389
+ _chunkRCOKQ3R4js.tryBootstrap.call(void 0, );
390
390
  }
391
391
  for (const module of this._modules.values()) {
392
392
  if (module.name === moduleName) {
@@ -397,7 +397,7 @@ var ModuleRegistryClass = class {
397
397
  }
398
398
  getAllPageUrls() {
399
399
  if (this._modules.size === 0) {
400
- _chunkGM4VZTWLjs.tryBootstrap.call(void 0, );
400
+ _chunkRCOKQ3R4js.tryBootstrap.call(void 0, );
401
401
  }
402
402
  const seen = /* @__PURE__ */ new Set();
403
403
  const result = [];
@@ -414,7 +414,7 @@ var ModuleRegistryClass = class {
414
414
  findByModelName(modelName) {
415
415
  let module = this._modules.get(modelName);
416
416
  if (!module) {
417
- const didBootstrap = _chunkGM4VZTWLjs.tryBootstrap.call(void 0, );
417
+ const didBootstrap = _chunkRCOKQ3R4js.tryBootstrap.call(void 0, );
418
418
  if (didBootstrap) {
419
419
  module = this._modules.get(modelName);
420
420
  }
@@ -436,7 +436,7 @@ var ModuleRegistryClass = class {
436
436
  }
437
437
  getAll() {
438
438
  if (this._modules.size === 0) {
439
- _chunkGM4VZTWLjs.tryBootstrap.call(void 0, );
439
+ _chunkRCOKQ3R4js.tryBootstrap.call(void 0, );
440
440
  }
441
441
  return Array.from(this._modules.values());
442
442
  }
@@ -596,4 +596,4 @@ var RootSync = (_class2 = class extends AbstractApiData {constructor(...args) {
596
596
 
597
597
 
598
598
  exports.RehydrationFactory = RehydrationFactory; exports.AbstractApiData = AbstractApiData; exports.configureI18n = configureI18n; exports.useI18nRouter = useI18nRouter; exports.useI18nTranslations = useI18nTranslations; exports.getI18nLink = getI18nLink; exports.useI18nLocale = useI18nLocale; exports.getI18nServerLocale = getI18nServerLocale; exports.useI18nDateFnsLocale = useI18nDateFnsLocale; exports.getI18nSupportedLocales = getI18nSupportedLocales; exports.getI18nDefaultLocale = getI18nDefaultLocale; exports.ModuleRegistry = ModuleRegistry; exports.Modules = Modules; exports.EndpointCreator = EndpointCreator; exports.ROOT_SYNC_ENDPOINT = ROOT_SYNC_ENDPOINT; exports.RootSync = RootSync;
599
- //# sourceMappingURL=chunk-YWLSIIE6.js.map
599
+ //# sourceMappingURL=chunk-P7L6OFX5.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-YWLSIIE6.js","../src/core/factories/RehydrationFactory.ts","../src/core/abstracts/AbstractApiData.ts","../src/i18n/config.ts","../src/core/registry/ModuleRegistry.ts","../src/core/endpoint/EndpointCreator.ts","../src/offline/sync/models/RootSync.ts"],"names":["includedData","includedItem","module","entity"],"m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,EAAA;AAEsB,EAAA;AACR,IAAA;AACd,EAAA;AAEmC,EAAA;AACrB,IAAA;AACd,EAAA;AAE+B,EAAA;AACJ,IAAA;AAC3B,EAAA;AAE4B,EAAA;AACH,IAAA;AACzB,EAAA;AAEoD,EAAA;AAC9B,IAAA;AAEY,IAAA;AACF,IAAA;AACI,IAAA;AACJ,IAAA;AACS,IAAA;AACzB,MAAA;AACF,MAAA;AACyB,MAAA;AACnC,IAAA;AACqC,IAAA;AACtB,MAAA;AACF,MAAA;AACA,MAAA;AACF,MAAA;AACA,MAAA;AACW,MAAA;AACtB,IAAA;AAEK,IAAA;AACT,EAAA;AAEgC,EAAA;AACd,IAAA;AAClB,EAAA;AACF;ANggB2C;AACA;AACA;AACA;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-YWLSIIE6.js","sourcesContent":[null,"import { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { JsonApiHydratedDataInterface } from \"../interfaces/JsonApiHydratedDataInterface\";\nimport { DataClassRegistry } from \"../registry/DataClassRegistry\";\n\n/**\n * The resources being rehydrated right now, along the current chain of relationships. A resource\n * met again inside its own chain (A's relationship leads to B, B's back to A) is a circle in the\n * `included` data: following it would recurse until the stack overflows, so it is skipped there.\n */\nconst inProgress = new Set<string>();\n\n/**\n * The included resources already rehydrated during the current top-level `rehydrate` /\n * `rehydrateList` call, by model class and `type:id`, with the `included` array they were read from.\n * A resource reached again through another relationship reuses that model instead of being built\n * again: without it every distinct path through a densely linked `included` (a campaign, its PCs,\n * their locations, the scenes there, back to the campaign...) is rehydrated, which grows\n * exponentially with the number of linked resources. A reused model keeps what it read the first\n * time, so a relationship back to a resource that was mid-rehydration then stays unset.\n * The top-level resources are always rehydrated from scratch, so each one is complete.\n */\nlet built: Map<unknown, Map<string, { included: unknown; model: unknown }>> | undefined;\nlet depth = 0;\n\nconst keyOf = (data: JsonApiHydratedDataInterface): string | undefined => {\n const resource = data?.jsonApi;\n return resource?.type && resource?.id ? `${resource.type}:${resource.id}` : undefined;\n};\n\nfunction session<T>(run: () => T): T {\n const outermost = depth === 0;\n if (outermost) built = new Map();\n depth++;\n try {\n return run();\n } finally {\n depth--;\n if (outermost) built = undefined;\n }\n}\n\nfunction guarded<T>(factoryClass: unknown, data: JsonApiHydratedDataInterface, run: () => T): T {\n const key = keyOf(data);\n if (!key) return run();\n if (inProgress.has(key)) return undefined as T;\n\n if (inProgress.size > 0) {\n const previous = built?.get(factoryClass)?.get(key);\n if (previous && previous.included === data.included) return previous.model as T;\n }\n\n inProgress.add(key);\n try {\n const model = run();\n if (built) {\n let byKey = built.get(factoryClass);\n if (!byKey) {\n byKey = new Map();\n built.set(factoryClass, byKey);\n }\n byKey.set(key, { included: data.included, model });\n }\n return model;\n } finally {\n inProgress.delete(key);\n }\n}\n\nexport class RehydrationFactory {\n public static rehydrate<T extends ApiDataInterface>(\n classKey: ApiRequestDataTypeInterface,\n data: JsonApiHydratedDataInterface,\n ): T {\n const factoryClass = DataClassRegistry.get(classKey);\n\n return session(() => guarded(factoryClass, data, () => new factoryClass().rehydrate(data) as T));\n }\n\n public static rehydrateList<T extends ApiDataInterface>(\n classKey: ApiRequestDataTypeInterface,\n data: JsonApiHydratedDataInterface[],\n ): T[] {\n const factoryClass = DataClassRegistry.get(classKey);\n\n return session(() =>\n data.map((item: JsonApiHydratedDataInterface) =>\n guarded(factoryClass, item, () => new factoryClass().rehydrate(item) as T),\n ),\n );\n }\n}\n","import { RehydrationFactory } from \"../factories/RehydrationFactory\";\nimport { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { JsonApiHydratedDataInterface } from \"../interfaces/JsonApiHydratedDataInterface\";\n\nexport abstract class AbstractApiData implements ApiDataInterface {\n static identifierFields: string[] = [\"name\"];\n\n get identifier(): string {\n const fields = (this.constructor as typeof AbstractApiData).identifierFields;\n return fields\n .map((field) => this._jsonApi?.attributes?.[field])\n .filter((v) => v != null && v !== \"\")\n .join(\" \");\n }\n\n protected _jsonApi?: any;\n protected _included?: any[];\n\n protected _id?: string;\n protected _type?: string;\n protected _createdAt?: Date;\n protected _updatedAt?: Date;\n\n protected _self?: string;\n\n get type(): string {\n if (!this._type) throw new Error(\"Type is not set.\");\n return this._type;\n }\n\n get id(): string {\n if (!this._id) throw new Error(\"Id is not set.\");\n return this._id;\n }\n\n get self(): string | undefined {\n return this._self;\n }\n\n get createdAt(): Date {\n return this._createdAt ?? new Date();\n }\n\n get updatedAt(): Date {\n return this._updatedAt ?? new Date();\n }\n\n get included(): any[] {\n return this._included ?? [];\n }\n\n get jsonApi(): any {\n return this._jsonApi;\n }\n\n ingestJsonApi(_data: JsonApiHydratedDataInterface): void {}\n\n generateApiUrl(_params?: any): string {\n throw new Error(\"Method not implemented.\");\n }\n\n createJsonApi(_data?: any): any {\n throw new Error(\"Method not implemented.\");\n }\n\n protected _readIncluded<T extends ApiDataInterface>(\n data: JsonApiHydratedDataInterface,\n type: string,\n dataType: ApiRequestDataTypeInterface,\n ): T | T[] | undefined {\n if (\n data.included === undefined ||\n data.included.length === 0 ||\n data.jsonApi.relationships === undefined ||\n data.jsonApi.relationships[type] === undefined ||\n data.jsonApi.relationships[type].data === undefined\n ) {\n return undefined;\n }\n\n if (Array.isArray(data.jsonApi.relationships[type].data)) {\n const response: T[] = data.jsonApi.relationships[type].data.map((jsonApiData: any) => {\n const includedData = data.included.find(\n (includedData: any) => includedData.id === jsonApiData.id && includedData.type === jsonApiData.type,\n );\n\n if (includedData === undefined) return undefined;\n\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n });\n\n return response.filter((item: T | undefined) => item !== undefined) as T[];\n }\n\n const includedData = data.included.find(\n (includedData: any) =>\n includedData.id === data.jsonApi.relationships[type].data.id &&\n includedData.type === data.jsonApi.relationships[type].data.type,\n );\n\n if (includedData === undefined && data.allData !== undefined) {\n // Try to find in allData as a fallback\n const fallbackData = data.allData.find(\n (includedData: any) =>\n includedData.id === data.jsonApi.relationships[type].data.id &&\n includedData.type === data.jsonApi.relationships[type].data.type,\n );\n if (fallbackData !== undefined) {\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: fallbackData,\n included: data.included,\n }) as T;\n }\n }\n\n if (includedData === undefined) return undefined;\n\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n }\n\n /**\n * Read included relationships with polymorphic type resolution.\n * Determines the correct model class based on the JSON:API type in included data.\n */\n protected _readIncludedPolymorphic<T extends ApiDataInterface>(\n data: JsonApiHydratedDataInterface,\n relationshipKey: string,\n candidateModules: ApiRequestDataTypeInterface[],\n ): T | T[] | undefined {\n // Validate relationship exists\n if (!data.included?.length || !data.jsonApi.relationships?.[relationshipKey]?.data) {\n return undefined;\n }\n\n const relData = data.jsonApi.relationships[relationshipKey].data;\n\n // Build lookup map: JSON:API type -> module\n const typeToModule = new Map<string, ApiRequestDataTypeInterface>();\n for (const mod of candidateModules) {\n typeToModule.set(mod.name, mod);\n }\n\n if (Array.isArray(relData)) {\n // Many relationship\n const result: T[] = [];\n for (const item of relData) {\n const includedItem = data.included.find((inc: any) => inc.id === item.id && inc.type === item.type);\n if (!includedItem) continue;\n\n // Resolve module by JSON:API type\n const module = typeToModule.get(includedItem.type);\n if (!module) continue;\n\n result.push(\n RehydrationFactory.rehydrate(module, {\n jsonApi: includedItem,\n included: data.included,\n }) as T,\n );\n }\n return result.length > 0 ? result : undefined;\n }\n\n // Single relationship\n const includedItem = data.included.find((inc: any) => inc.id === relData.id && inc.type === relData.type);\n if (!includedItem) return undefined;\n\n const module = typeToModule.get(includedItem.type);\n if (!module) return undefined;\n\n return RehydrationFactory.rehydrate(module, {\n jsonApi: includedItem,\n included: data.included,\n }) as T;\n }\n\n /**\n * Read included relationship data and augment with relationship meta properties.\n * Handles both single relationships (one-to-one) and array relationships (one-to-many).\n *\n * For single relationships: meta is read from `relationships[type].meta`\n * For array relationships: per-item meta is read from `relationships[type].data[].meta`\n *\n * @param data - Hydrated JSON:API data\n * @param type - Relationship type key (e.g., \"guide\", \"persons\")\n * @param dataType - Module reference for rehydration\n * @returns Related object(s) augmented with meta properties, or undefined\n */\n protected _readIncludedWithMeta<T extends ApiDataInterface, M extends Record<string, any>>(\n data: JsonApiHydratedDataInterface,\n type: string,\n dataType: ApiRequestDataTypeInterface,\n ): (T & M) | (T & M)[] | undefined {\n // Check if relationship exists\n if (\n data.included === undefined ||\n data.included.length === 0 ||\n data.jsonApi.relationships === undefined ||\n data.jsonApi.relationships[type] === undefined ||\n data.jsonApi.relationships[type].data === undefined\n ) {\n return undefined;\n }\n\n const relationshipData = data.jsonApi.relationships[type].data;\n\n // Handle array relationships with per-item meta\n if (Array.isArray(relationshipData)) {\n const result: (T & M)[] = [];\n\n for (const item of relationshipData) {\n const includedData = data.included.find((inc: any) => inc.id === item.id && inc.type === item.type);\n\n if (!includedData) continue;\n\n const entity = RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n\n // Merge per-item meta from relationships[type].data[].meta\n if (item.meta) {\n AbstractApiData._mergeMeta(entity, item.meta);\n }\n\n result.push(entity as T & M);\n }\n\n return result;\n }\n\n // Handle single relationship\n const includedData = data.included.find(\n (inc: any) => inc.id === relationshipData.id && inc.type === relationshipData.type,\n );\n\n if (!includedData) {\n // Try to find in allData as a fallback\n if (data.allData !== undefined) {\n const fallbackData = data.allData.find(\n (inc: any) => inc.id === relationshipData.id && inc.type === relationshipData.type,\n );\n if (fallbackData) {\n const entity = RehydrationFactory.rehydrate(dataType, {\n jsonApi: fallbackData,\n included: data.included,\n }) as T;\n\n // Merge relationship-level meta for single relationships\n const relationshipMeta = data.jsonApi.relationships[type].meta;\n if (relationshipMeta) {\n AbstractApiData._mergeMeta(entity, relationshipMeta);\n }\n return entity as T & M;\n }\n }\n return undefined;\n }\n\n const entity = RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n\n // Merge relationship-level meta for single relationships\n const relationshipMeta = data.jsonApi.relationships[type].meta;\n if (relationshipMeta) {\n AbstractApiData._mergeMeta(entity, relationshipMeta);\n }\n\n return entity as T & M;\n }\n\n /**\n * Copies relationship meta onto a rehydrated entity as own data properties. Object.assign throws\n * when the model declares a getter-only accessor of the same name (an app's `Chunk` with\n * `get relevance()`); an own property shadows that getter, so the model reads the meta value.\n */\n private static _mergeMeta(entity: object, meta: Record<string, any>): void {\n for (const [key, value] of Object.entries(meta)) {\n Object.defineProperty(entity, key, { value, writable: true, enumerable: true, configurable: true });\n }\n }\n\n dehydrate(): JsonApiHydratedDataInterface {\n return {\n jsonApi: this._jsonApi,\n included: this._included ?? [],\n };\n }\n\n rehydrate(data: JsonApiHydratedDataInterface): this {\n this._jsonApi = data.jsonApi;\n this._included = data.included;\n\n this._type = this._jsonApi.type;\n this._id = this._jsonApi.id;\n this._createdAt = this._jsonApi.meta?.createdAt !== undefined ? new Date(this._jsonApi.meta.createdAt) : undefined;\n this._updatedAt = this._jsonApi.meta?.updatedAt !== undefined ? new Date(this._jsonApi.meta.updatedAt) : undefined;\n\n this._self = this._jsonApi.links?.self ?? undefined;\n\n return this;\n }\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;\nexport type GetLocaleFunction = () => Promise<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 * Server-side locale for API requests (pass next-intl's `getLocale` from `next-intl/server`).\n *\n * The library never imports next-intl itself: instrumentation loads the library, and\n * next-intl's `getLocale` pulls in the app's `i18n/request.ts`, which reads\n * `next/root-params` — a module only allowed inside the app directory.\n */\n getLocale: GetLocaleFunction;\n /**\n * Locales the app supports. The first entry is the fallback.\n * Defaults to `[\"en\"]` when omitted.\n */\n supportedLocales?: 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\n/** The server-side locale from the app's `getLocale`. Throws when `configureI18n` has not run. */\nexport async function getI18nServerLocale(): Promise<string> {\n if (!_config?.getLocale) {\n throw new Error(\"i18n not configured. Call configureI18n() with getLocale at app startup.\");\n }\n return _config.getLocale();\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\n/** The app's supported locales. Defaults to `[\"en\"]` when not configured. */\nexport function getI18nSupportedLocales(): string[] {\n if (_config?.supportedLocales && _config.supportedLocales.length > 0) {\n return _config.supportedLocales;\n }\n return [\"en\"];\n}\n\n/** The app's default locale: the first supported locale (`\"en\"` when not configured). */\nexport function getI18nDefaultLocale(): string {\n return getI18nSupportedLocales()[0];\n}\n","import { ModuleWithPermissions } from \"../../permissions/types\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { hasBootstrapper, tryBootstrap } from \"./bootstrapStore\";\n\n// Foundation module types - defined by LIBRARY\nexport interface FoundationModuleDefinitions {\n S3: ModuleWithPermissions;\n Auth: ModuleWithPermissions;\n User: ModuleWithPermissions;\n Author: ModuleWithPermissions;\n Company: ModuleWithPermissions;\n Role: ModuleWithPermissions;\n Notification: ModuleWithPermissions;\n Push: ModuleWithPermissions;\n Feature: ModuleWithPermissions;\n Module: ModuleWithPermissions;\n Content: ModuleWithPermissions;\n HowTo: ModuleWithPermissions;\n HandbookPage: ModuleWithPermissions;\n HandbookSection: ModuleWithPermissions;\n HandbookThread: ModuleWithPermissions;\n HandbookThreadMessage: ModuleWithPermissions;\n Assistant: ModuleWithPermissions;\n AssistantMessage: ModuleWithPermissions;\n AssistantAction: ModuleWithPermissions;\n Chunk: ModuleWithPermissions;\n // Billing modules - READ: all users, UPDATE: CompanyAdministrator, ADMIN: Administrator\n Billing: ModuleWithPermissions;\n StripeCustomer: ModuleWithPermissions;\n StripePaymentMethod: ModuleWithPermissions;\n StripeSubscription: ModuleWithPermissions;\n StripeInvoice: ModuleWithPermissions;\n StripeProduct: ModuleWithPermissions;\n StripePrice: ModuleWithPermissions;\n StripeUsage: ModuleWithPermissions;\n StripePromotionCode: ModuleWithPermissions;\n StripeCoupon: ModuleWithPermissions;\n StripeCouponCode: ModuleWithPermissions;\n StripeCouponOffer: ModuleWithPermissions;\n // AI connection administration\n AiConnection: ModuleWithPermissions;\n // OAuth modules\n OAuth: ModuleWithPermissions;\n // Waitlist modules\n Waitlist: ModuleWithPermissions;\n WaitlistStats: ModuleWithPermissions;\n // Email automation modules\n EmailAutomation: ModuleWithPermissions;\n EmailAutomationStep: ModuleWithPermissions;\n EmailAutomationEnrollment: ModuleWithPermissions;\n EmailAutomationTrigger: ModuleWithPermissions;\n EmailAutomationCandidate: ModuleWithPermissions;\n // Email blast modules\n EmailBlast: ModuleWithPermissions;\n EmailBlastDelivery: ModuleWithPermissions;\n EmailBlastAudience: ModuleWithPermissions;\n // Blog modules\n BlogPost: ModuleWithPermissions;\n BlogPostTranslation: ModuleWithPermissions;\n BlogCategory: ModuleWithPermissions;\n BlogCategoryTranslation: ModuleWithPermissions;\n BlogSettings: ModuleWithPermissions;\n // Referral modules\n Referral: ModuleWithPermissions;\n ReferralStats: ModuleWithPermissions;\n // Referral link visits and the administrative referral report (opt-in: registered by apps that spread referralAdminModules)\n ReferralVisit: ModuleWithPermissions;\n ReferralAdminSummary: ModuleWithPermissions;\n ReferralAdminReferrer: ModuleWithPermissions;\n ReferralAdminReferral: ModuleWithPermissions;\n // Two-factor authentication modules\n TotpAuthenticator: ModuleWithPermissions;\n TotpSetup: ModuleWithPermissions;\n TotpVerify: ModuleWithPermissions;\n TotpVerifyLogin: ModuleWithPermissions;\n Passkey: ModuleWithPermissions;\n PasskeyRegistrationOptions: ModuleWithPermissions;\n PasskeyRegistrationVerify: ModuleWithPermissions;\n PasskeyRename: ModuleWithPermissions;\n PasskeyVerifyLogin: ModuleWithPermissions;\n PasskeyAuthenticationOptions: ModuleWithPermissions;\n TwoFactorEnable: ModuleWithPermissions;\n TwoFactorChallenge: ModuleWithPermissions;\n TwoFactorStatus: ModuleWithPermissions;\n BackupCodeVerify: ModuleWithPermissions;\n // OAuth sign-up awaiting consent\n PendingRegistration: ModuleWithPermissions;\n // RBAC modules\n PermissionMapping: ModuleWithPermissions;\n ModulePaths: ModuleWithPermissions;\n RbacMatrix: ModuleWithPermissions;\n // Audit modules\n AuditLog: ModuleWithPermissions;\n // Administrative token-usage reporting modules\n TokenUsageAdminSummary: ModuleWithPermissions;\n TokenUsageAdminTimeline: ModuleWithPermissions;\n TokenUsageAdminBreakdown: ModuleWithPermissions;\n // Self-service token-usage reporting modules\n TokenUsageReportSummary: ModuleWithPermissions;\n TokenUsageReportTimeline: ModuleWithPermissions;\n TokenUsageReportBreakdown: ModuleWithPermissions;\n // First-party web analytics modules (tracker + administrative dashboard)\n AnalyticsEvent: ModuleWithPermissions;\n AnalyticsSummary: ModuleWithPermissions;\n AnalyticsTimeline: ModuleWithPermissions;\n AnalyticsDailyUniqueTimeline: ModuleWithPermissions;\n AnalyticsBreakdown: ModuleWithPermissions;\n AnalyticsSession: ModuleWithPermissions;\n AnalyticsPageView: ModuleWithPermissions;\n // Account deletion (opt-in: registered only by apps that enable it)\n AccountDeletion: ModuleWithPermissions;\n // Offline mode (opt-in: registered by apps that spread offlineModules)\n OfflineChangeSet: ModuleWithPermissions;\n RootSync: ModuleWithPermissions;\n}\n\n// App-specific modules - apps will augment this interface ONLY\n\nexport interface AppModuleDefinitions {}\n\n// Combined type for full autocompletion\nexport type ModuleDefinitions = FoundationModuleDefinitions & AppModuleDefinitions;\n\n// Symbol key to avoid conflicts with other globals\nconst MODULES_KEY = Symbol.for(\"nextjs-jsonapi:modules\");\n\n// Use globalThis to persist module registry across HMR reloads\nconst globalStore = globalThis as unknown as {\n [MODULES_KEY]?: Map<string, ApiRequestDataTypeInterface>;\n};\n\n// Initialize global modules map if not set\nif (!globalStore[MODULES_KEY]) {\n globalStore[MODULES_KEY] = new Map();\n}\n\nclass ModuleRegistryClass {\n private get _modules(): Map<string, ApiRequestDataTypeInterface> {\n return globalStore[MODULES_KEY]!;\n }\n\n register<K extends string>(name: K, module: ApiRequestDataTypeInterface): void {\n this._modules.set(name, module);\n }\n\n get<K extends keyof ModuleDefinitions>(name: K): ModuleDefinitions[K] {\n let module = this._modules.get(name as string);\n\n // Self-healing: if module not found, try bootstrapping first\n if (!module) {\n const didBootstrap = tryBootstrap();\n if (didBootstrap) {\n // Retry after bootstrap\n module = this._modules.get(name as string);\n }\n }\n\n if (!module) {\n // Provide helpful error message based on state\n const hint = hasBootstrapper()\n ? \"Bootstrap was called but module still not found. Check module registration.\"\n : \"No bootstrapper registered. Ensure configureJsonApi({ bootstrapper }) is called before accessing modules.\";\n throw new Error(`Module \"${String(name)}\" not registered. ${hint}`);\n }\n\n return module as ModuleDefinitions[K];\n }\n\n /**\n * True when a module is registered under `name`. Never throws, so a component\n * can check for an opt-in module the app may not have registered.\n */\n has(name: string): boolean {\n // Bootstrap only an empty registry (as findByName does): an app that never\n // registers `name` must not re-run its bootstrapper on every check.\n if (this._modules.size === 0) tryBootstrap();\n return this._modules.has(name);\n }\n\n findByName(moduleName: string): ModuleWithPermissions {\n // Self-healing: try bootstrap if registry is empty\n if (this._modules.size === 0) {\n tryBootstrap();\n }\n\n // Search by module's name property (e.g., \"topics\", \"articles\")\n for (const module of this._modules.values()) {\n if ((module as ModuleWithPermissions).name === moduleName) {\n return module as ModuleWithPermissions;\n }\n }\n throw new Error(`Module not found: ${moduleName}`);\n }\n\n getAllPageUrls(): { id: string; text: string }[] {\n if (this._modules.size === 0) {\n tryBootstrap();\n }\n\n const seen = new Set<string>();\n const result: { id: string; text: string }[] = [];\n for (const [key, module] of this._modules.entries()) {\n const m = module as ModuleWithPermissions;\n if (m.pageUrl && !seen.has(m.pageUrl)) {\n seen.add(m.pageUrl);\n result.push({ id: m.pageUrl, text: key });\n result.push({ id: `${m.pageUrl}/:id`, text: `${key} (detail)` });\n }\n }\n return result.sort((a, b) => a.text.localeCompare(b.text));\n }\n\n findByModelName(modelName: string): ModuleWithPermissions {\n // Direct lookup by registry key (e.g., \"Article\", \"Document\")\n let module = this._modules.get(modelName);\n\n // Self-healing: if not found, try bootstrapping\n if (!module) {\n const didBootstrap = tryBootstrap();\n if (didBootstrap) {\n module = this._modules.get(modelName);\n }\n }\n\n if (!module) {\n throw new Error(`Module not found for model: ${modelName}`);\n }\n return module as ModuleWithPermissions;\n }\n\n findByFeature(feature: string): ModuleWithPermissions[] {\n const response: ModuleWithPermissions[] = [];\n\n for (const module of this._modules.values()) {\n const m = module as ModuleWithPermissions;\n if (m.feature === feature) {\n response.push(m);\n }\n }\n\n return response;\n }\n\n getAll(): ApiRequestDataTypeInterface[] {\n if (this._modules.size === 0) {\n tryBootstrap();\n }\n return Array.from(this._modules.values());\n }\n}\n\nexport const ModuleRegistry = new ModuleRegistryClass();\n\n// Proxy object for Modules.X syntax with autocompletion\nexport const Modules = new Proxy({} as ModuleDefinitions, {\n get(_, prop: string) {\n if (prop === \"findByName\") {\n return (name: string) => ModuleRegistry.findByName(name);\n }\n if (prop === \"findByModelName\") {\n return (name: string) => ModuleRegistry.findByModelName(name);\n }\n if (prop === \"findByFeature\") {\n return (feature: string) => ModuleRegistry.findByFeature(feature);\n }\n return ModuleRegistry.get(prop as keyof ModuleDefinitions);\n },\n}) as ModuleDefinitions & {\n findByName: (name: string) => ModuleWithPermissions;\n findByModelName: (name: string) => ModuleWithPermissions;\n findByFeature: (feature: string) => ModuleWithPermissions[];\n};\n","import { FieldSelector } from \"../fields/FieldSelector\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\n\nexport type EndpointQuery = {\n endpoint: ApiRequestDataTypeInterface | string;\n id?: string;\n childEndpoint?: ApiRequestDataTypeInterface | string;\n childId?: string;\n additionalParams?: { key: string; value: string | string[] }[];\n};\n\nexport class EndpointCreator {\n private _endpoint: EndpointQuery;\n\n constructor(params: {\n endpoint: ApiRequestDataTypeInterface | string;\n id?: string;\n childEndpoint?: ApiRequestDataTypeInterface | string;\n childId?: string;\n additionalParams?: { key: string; value: string }[];\n }) {\n this._endpoint = {\n endpoint: params.endpoint,\n id: params.id,\n childEndpoint: params.childEndpoint,\n childId: params.childId,\n additionalParams: params.additionalParams ?? [],\n };\n }\n\n endpoint(value: ApiRequestDataTypeInterface | string): EndpointCreator {\n this._endpoint.endpoint = value;\n return this;\n }\n\n id(value: string): EndpointCreator {\n this._endpoint.id = value;\n return this;\n }\n\n childEndpoint(value: ApiRequestDataTypeInterface | string): EndpointCreator {\n this._endpoint.childEndpoint = value;\n return this;\n }\n\n childId(value: string): EndpointCreator {\n this._endpoint.childId = value;\n return this;\n }\n\n set additionalParams(value: { key: string; value: string }[]) {\n this._endpoint.additionalParams = value;\n }\n\n addAdditionalParam(key: string, value: string | string[]): EndpointCreator {\n if (!this._endpoint.additionalParams) this._endpoint.additionalParams = [];\n this._endpoint.additionalParams.push({ key, value });\n return this;\n }\n\n limitToType(selectors: string[]): this {\n this.addAdditionalParam(`include`, selectors.join(\",\"));\n return this;\n }\n\n limitToFields(selectors: FieldSelector<any>[]): this {\n if (selectors.length === 0) return this;\n\n selectors.forEach((selector) => {\n const fieldString = selector.fields.join(\",\");\n this.addAdditionalParam(`fields[${selector.type}]`, fieldString);\n });\n\n return this;\n }\n\n generate(): string {\n let additionalParams = \"\";\n if (this._endpoint.additionalParams) {\n additionalParams = this._endpoint.additionalParams.map((param) => `${param.key}=${param.value}`).join(\"&\");\n }\n\n let response = ``;\n response += `${\n typeof this._endpoint.endpoint === \"string\" ? this._endpoint.endpoint : this._endpoint.endpoint.name\n }`;\n if (this._endpoint.id) response += `/${this._endpoint.id}`;\n if (this._endpoint.childEndpoint) {\n response += `/${\n typeof this._endpoint.childEndpoint === \"string\"\n ? this._endpoint.childEndpoint\n : this._endpoint.childEndpoint.name\n }`;\n }\n if (this._endpoint.childId) response += `/${this._endpoint.childId}`;\n if (additionalParams) response += `?${additionalParams}`;\n\n return response;\n }\n}\n","import { AbstractApiData } from \"../../../core/abstracts/AbstractApiData\";\nimport { JsonApiHydratedDataInterface } from \"../../../core/interfaces/JsonApiHydratedDataInterface\";\nimport { RootSyncEntry, RootSyncInterface, RootSyncLink } from \"./RootSyncInterface\";\n\n/**\n * Child path of the sync answer under the root module record\n * (`GET /<root endpoint>/:id/sync`), the same value as the app API's sync meta endpoint\n * (in Wyrdli, `campaignSyncMeta.endpoint`).\n */\nexport const ROOT_SYNC_ENDPOINT = \"sync\";\n\n/** The sync answer for one root record (`root-syncs`, id = root record id). Read-only. */\nexport class RootSync extends AbstractApiData implements RootSyncInterface {\n private _serverTime?: Date;\n private _locked: boolean = false;\n private _lockedFrom?: Date;\n private _entries?: RootSyncEntry[];\n private _links?: RootSyncLink[];\n\n get serverTime(): Date {\n if (!this._serverTime) throw new Error(\"serverTime is not set.\");\n return this._serverTime;\n }\n\n get locked(): boolean {\n return this._locked;\n }\n\n get lockedFrom(): Date | undefined {\n return this._lockedFrom;\n }\n\n get entries(): RootSyncEntry[] {\n return this._entries ?? [];\n }\n\n get links(): RootSyncLink[] {\n return this._links ?? [];\n }\n\n rehydrate(data: JsonApiHydratedDataInterface): this {\n super.rehydrate(data);\n\n const attributes = data.jsonApi.attributes ?? {};\n this._serverTime = attributes.serverTime ? new Date(attributes.serverTime) : undefined;\n this._locked = Boolean(attributes.locked);\n this._lockedFrom = attributes.lockedFrom ? new Date(attributes.lockedFrom) : undefined;\n this._entries = (attributes.entries ?? []).map((entry: { type: string; id: string; updatedAt: string }) => ({\n type: entry.type,\n id: entry.id,\n updatedAt: new Date(entry.updatedAt),\n }));\n this._links = (attributes.links ?? []).map((link: RootSyncLink) => ({\n fromType: link.fromType,\n fromId: link.fromId,\n toType: link.toType,\n toId: link.toId,\n kind: link.kind,\n props: link.props ?? {},\n }));\n\n return this;\n }\n\n createJsonApi(_data?: any): any {\n throw new Error(\"RootSync is read-only and cannot be created\");\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-P7L6OFX5.js","../src/core/factories/RehydrationFactory.ts","../src/core/abstracts/AbstractApiData.ts","../src/i18n/config.ts","../src/core/registry/ModuleRegistry.ts","../src/core/endpoint/EndpointCreator.ts","../src/offline/sync/models/RootSync.ts"],"names":["includedData","includedItem","module","entity"],"mappings":"AAAA;AACE;AACA;AACA;AACF,sD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ACd,EAAA;AAEmC,EAAA;AACrB,IAAA;AACd,EAAA;AAE+B,EAAA;AACJ,IAAA;AAC3B,EAAA;AAE4B,EAAA;AACH,IAAA;AACzB,EAAA;AAEoD,EAAA;AAC9B,IAAA;AAEY,IAAA;AACF,IAAA;AACI,IAAA;AACJ,IAAA;AACS,IAAA;AACzB,MAAA;AACF,MAAA;AACyB,MAAA;AACnC,IAAA;AACqC,IAAA;AACtB,MAAA;AACF,MAAA;AACA,MAAA;AACF,MAAA;AACA,MAAA;AACW,MAAA;AACtB,IAAA;AAEK,IAAA;AACT,EAAA;AAEgC,EAAA;AACd,IAAA;AAClB,EAAA;AACF;ANggB2C;AACA;AACA;AACA;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-P7L6OFX5.js","sourcesContent":[null,"import { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { JsonApiHydratedDataInterface } from \"../interfaces/JsonApiHydratedDataInterface\";\nimport { DataClassRegistry } from \"../registry/DataClassRegistry\";\n\n/**\n * The resources being rehydrated right now, along the current chain of relationships. A resource\n * met again inside its own chain (A's relationship leads to B, B's back to A) is a circle in the\n * `included` data: following it would recurse until the stack overflows, so it is skipped there.\n */\nconst inProgress = new Set<string>();\n\n/**\n * The included resources already rehydrated during the current top-level `rehydrate` /\n * `rehydrateList` call, by model class and `type:id`, with the `included` array they were read from.\n * A resource reached again through another relationship reuses that model instead of being built\n * again: without it every distinct path through a densely linked `included` (a campaign, its PCs,\n * their locations, the scenes there, back to the campaign...) is rehydrated, which grows\n * exponentially with the number of linked resources. A reused model keeps what it read the first\n * time, so a relationship back to a resource that was mid-rehydration then stays unset.\n * The top-level resources are always rehydrated from scratch, so each one is complete.\n */\nlet built: Map<unknown, Map<string, { included: unknown; model: unknown }>> | undefined;\nlet depth = 0;\n\nconst keyOf = (data: JsonApiHydratedDataInterface): string | undefined => {\n const resource = data?.jsonApi;\n return resource?.type && resource?.id ? `${resource.type}:${resource.id}` : undefined;\n};\n\nfunction session<T>(run: () => T): T {\n const outermost = depth === 0;\n if (outermost) built = new Map();\n depth++;\n try {\n return run();\n } finally {\n depth--;\n if (outermost) built = undefined;\n }\n}\n\nfunction guarded<T>(factoryClass: unknown, data: JsonApiHydratedDataInterface, run: () => T): T {\n const key = keyOf(data);\n if (!key) return run();\n if (inProgress.has(key)) return undefined as T;\n\n if (inProgress.size > 0) {\n const previous = built?.get(factoryClass)?.get(key);\n if (previous && previous.included === data.included) return previous.model as T;\n }\n\n inProgress.add(key);\n try {\n const model = run();\n if (built) {\n let byKey = built.get(factoryClass);\n if (!byKey) {\n byKey = new Map();\n built.set(factoryClass, byKey);\n }\n byKey.set(key, { included: data.included, model });\n }\n return model;\n } finally {\n inProgress.delete(key);\n }\n}\n\nexport class RehydrationFactory {\n public static rehydrate<T extends ApiDataInterface>(\n classKey: ApiRequestDataTypeInterface,\n data: JsonApiHydratedDataInterface,\n ): T {\n const factoryClass = DataClassRegistry.get(classKey);\n\n return session(() => guarded(factoryClass, data, () => new factoryClass().rehydrate(data) as T));\n }\n\n public static rehydrateList<T extends ApiDataInterface>(\n classKey: ApiRequestDataTypeInterface,\n data: JsonApiHydratedDataInterface[],\n ): T[] {\n const factoryClass = DataClassRegistry.get(classKey);\n\n return session(() =>\n data.map((item: JsonApiHydratedDataInterface) =>\n guarded(factoryClass, item, () => new factoryClass().rehydrate(item) as T),\n ),\n );\n }\n}\n","import { RehydrationFactory } from \"../factories/RehydrationFactory\";\nimport { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { JsonApiHydratedDataInterface } from \"../interfaces/JsonApiHydratedDataInterface\";\n\nexport abstract class AbstractApiData implements ApiDataInterface {\n static identifierFields: string[] = [\"name\"];\n\n get identifier(): string {\n const fields = (this.constructor as typeof AbstractApiData).identifierFields;\n return fields\n .map((field) => this._jsonApi?.attributes?.[field])\n .filter((v) => v != null && v !== \"\")\n .join(\" \");\n }\n\n protected _jsonApi?: any;\n protected _included?: any[];\n\n protected _id?: string;\n protected _type?: string;\n protected _createdAt?: Date;\n protected _updatedAt?: Date;\n\n protected _self?: string;\n\n get type(): string {\n if (!this._type) throw new Error(\"Type is not set.\");\n return this._type;\n }\n\n get id(): string {\n if (!this._id) throw new Error(\"Id is not set.\");\n return this._id;\n }\n\n get self(): string | undefined {\n return this._self;\n }\n\n get createdAt(): Date {\n return this._createdAt ?? new Date();\n }\n\n get updatedAt(): Date {\n return this._updatedAt ?? new Date();\n }\n\n get included(): any[] {\n return this._included ?? [];\n }\n\n get jsonApi(): any {\n return this._jsonApi;\n }\n\n ingestJsonApi(_data: JsonApiHydratedDataInterface): void {}\n\n generateApiUrl(_params?: any): string {\n throw new Error(\"Method not implemented.\");\n }\n\n createJsonApi(_data?: any): any {\n throw new Error(\"Method not implemented.\");\n }\n\n protected _readIncluded<T extends ApiDataInterface>(\n data: JsonApiHydratedDataInterface,\n type: string,\n dataType: ApiRequestDataTypeInterface,\n ): T | T[] | undefined {\n if (\n data.included === undefined ||\n data.included.length === 0 ||\n data.jsonApi.relationships === undefined ||\n data.jsonApi.relationships[type] === undefined ||\n data.jsonApi.relationships[type].data === undefined\n ) {\n return undefined;\n }\n\n if (Array.isArray(data.jsonApi.relationships[type].data)) {\n const response: T[] = data.jsonApi.relationships[type].data.map((jsonApiData: any) => {\n const includedData = data.included.find(\n (includedData: any) => includedData.id === jsonApiData.id && includedData.type === jsonApiData.type,\n );\n\n if (includedData === undefined) return undefined;\n\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n });\n\n return response.filter((item: T | undefined) => item !== undefined) as T[];\n }\n\n const includedData = data.included.find(\n (includedData: any) =>\n includedData.id === data.jsonApi.relationships[type].data.id &&\n includedData.type === data.jsonApi.relationships[type].data.type,\n );\n\n if (includedData === undefined && data.allData !== undefined) {\n // Try to find in allData as a fallback\n const fallbackData = data.allData.find(\n (includedData: any) =>\n includedData.id === data.jsonApi.relationships[type].data.id &&\n includedData.type === data.jsonApi.relationships[type].data.type,\n );\n if (fallbackData !== undefined) {\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: fallbackData,\n included: data.included,\n }) as T;\n }\n }\n\n if (includedData === undefined) return undefined;\n\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n }\n\n /**\n * Read included relationships with polymorphic type resolution.\n * Determines the correct model class based on the JSON:API type in included data.\n */\n protected _readIncludedPolymorphic<T extends ApiDataInterface>(\n data: JsonApiHydratedDataInterface,\n relationshipKey: string,\n candidateModules: ApiRequestDataTypeInterface[],\n ): T | T[] | undefined {\n // Validate relationship exists\n if (!data.included?.length || !data.jsonApi.relationships?.[relationshipKey]?.data) {\n return undefined;\n }\n\n const relData = data.jsonApi.relationships[relationshipKey].data;\n\n // Build lookup map: JSON:API type -> module\n const typeToModule = new Map<string, ApiRequestDataTypeInterface>();\n for (const mod of candidateModules) {\n typeToModule.set(mod.name, mod);\n }\n\n if (Array.isArray(relData)) {\n // Many relationship\n const result: T[] = [];\n for (const item of relData) {\n const includedItem = data.included.find((inc: any) => inc.id === item.id && inc.type === item.type);\n if (!includedItem) continue;\n\n // Resolve module by JSON:API type\n const module = typeToModule.get(includedItem.type);\n if (!module) continue;\n\n result.push(\n RehydrationFactory.rehydrate(module, {\n jsonApi: includedItem,\n included: data.included,\n }) as T,\n );\n }\n return result.length > 0 ? result : undefined;\n }\n\n // Single relationship\n const includedItem = data.included.find((inc: any) => inc.id === relData.id && inc.type === relData.type);\n if (!includedItem) return undefined;\n\n const module = typeToModule.get(includedItem.type);\n if (!module) return undefined;\n\n return RehydrationFactory.rehydrate(module, {\n jsonApi: includedItem,\n included: data.included,\n }) as T;\n }\n\n /**\n * Read included relationship data and augment with relationship meta properties.\n * Handles both single relationships (one-to-one) and array relationships (one-to-many).\n *\n * For single relationships: meta is read from `relationships[type].meta`\n * For array relationships: per-item meta is read from `relationships[type].data[].meta`\n *\n * @param data - Hydrated JSON:API data\n * @param type - Relationship type key (e.g., \"guide\", \"persons\")\n * @param dataType - Module reference for rehydration\n * @returns Related object(s) augmented with meta properties, or undefined\n */\n protected _readIncludedWithMeta<T extends ApiDataInterface, M extends Record<string, any>>(\n data: JsonApiHydratedDataInterface,\n type: string,\n dataType: ApiRequestDataTypeInterface,\n ): (T & M) | (T & M)[] | undefined {\n // Check if relationship exists\n if (\n data.included === undefined ||\n data.included.length === 0 ||\n data.jsonApi.relationships === undefined ||\n data.jsonApi.relationships[type] === undefined ||\n data.jsonApi.relationships[type].data === undefined\n ) {\n return undefined;\n }\n\n const relationshipData = data.jsonApi.relationships[type].data;\n\n // Handle array relationships with per-item meta\n if (Array.isArray(relationshipData)) {\n const result: (T & M)[] = [];\n\n for (const item of relationshipData) {\n const includedData = data.included.find((inc: any) => inc.id === item.id && inc.type === item.type);\n\n if (!includedData) continue;\n\n const entity = RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n\n // Merge per-item meta from relationships[type].data[].meta\n if (item.meta) {\n AbstractApiData._mergeMeta(entity, item.meta);\n }\n\n result.push(entity as T & M);\n }\n\n return result;\n }\n\n // Handle single relationship\n const includedData = data.included.find(\n (inc: any) => inc.id === relationshipData.id && inc.type === relationshipData.type,\n );\n\n if (!includedData) {\n // Try to find in allData as a fallback\n if (data.allData !== undefined) {\n const fallbackData = data.allData.find(\n (inc: any) => inc.id === relationshipData.id && inc.type === relationshipData.type,\n );\n if (fallbackData) {\n const entity = RehydrationFactory.rehydrate(dataType, {\n jsonApi: fallbackData,\n included: data.included,\n }) as T;\n\n // Merge relationship-level meta for single relationships\n const relationshipMeta = data.jsonApi.relationships[type].meta;\n if (relationshipMeta) {\n AbstractApiData._mergeMeta(entity, relationshipMeta);\n }\n return entity as T & M;\n }\n }\n return undefined;\n }\n\n const entity = RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n\n // Merge relationship-level meta for single relationships\n const relationshipMeta = data.jsonApi.relationships[type].meta;\n if (relationshipMeta) {\n AbstractApiData._mergeMeta(entity, relationshipMeta);\n }\n\n return entity as T & M;\n }\n\n /**\n * Copies relationship meta onto a rehydrated entity as own data properties. Object.assign throws\n * when the model declares a getter-only accessor of the same name (an app's `Chunk` with\n * `get relevance()`); an own property shadows that getter, so the model reads the meta value.\n */\n private static _mergeMeta(entity: object, meta: Record<string, any>): void {\n for (const [key, value] of Object.entries(meta)) {\n Object.defineProperty(entity, key, { value, writable: true, enumerable: true, configurable: true });\n }\n }\n\n dehydrate(): JsonApiHydratedDataInterface {\n return {\n jsonApi: this._jsonApi,\n included: this._included ?? [],\n };\n }\n\n rehydrate(data: JsonApiHydratedDataInterface): this {\n this._jsonApi = data.jsonApi;\n this._included = data.included;\n\n this._type = this._jsonApi.type;\n this._id = this._jsonApi.id;\n this._createdAt = this._jsonApi.meta?.createdAt !== undefined ? new Date(this._jsonApi.meta.createdAt) : undefined;\n this._updatedAt = this._jsonApi.meta?.updatedAt !== undefined ? new Date(this._jsonApi.meta.updatedAt) : undefined;\n\n this._self = this._jsonApi.links?.self ?? undefined;\n\n return this;\n }\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;\nexport type GetLocaleFunction = () => Promise<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 * Server-side locale for API requests (pass next-intl's `getLocale` from `next-intl/server`).\n *\n * The library never imports next-intl itself: instrumentation loads the library, and\n * next-intl's `getLocale` pulls in the app's `i18n/request.ts`, which reads\n * `next/root-params` — a module only allowed inside the app directory.\n */\n getLocale: GetLocaleFunction;\n /**\n * Locales the app supports. The first entry is the fallback.\n * Defaults to `[\"en\"]` when omitted.\n */\n supportedLocales?: 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\n/** The server-side locale from the app's `getLocale`. Throws when `configureI18n` has not run. */\nexport async function getI18nServerLocale(): Promise<string> {\n if (!_config?.getLocale) {\n throw new Error(\"i18n not configured. Call configureI18n() with getLocale at app startup.\");\n }\n return _config.getLocale();\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\n/** The app's supported locales. Defaults to `[\"en\"]` when not configured. */\nexport function getI18nSupportedLocales(): string[] {\n if (_config?.supportedLocales && _config.supportedLocales.length > 0) {\n return _config.supportedLocales;\n }\n return [\"en\"];\n}\n\n/** The app's default locale: the first supported locale (`\"en\"` when not configured). */\nexport function getI18nDefaultLocale(): string {\n return getI18nSupportedLocales()[0];\n}\n","import { ModuleWithPermissions } from \"../../permissions/types\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { hasBootstrapper, tryBootstrap } from \"./bootstrapStore\";\n\n// Foundation module types - defined by LIBRARY\nexport interface FoundationModuleDefinitions {\n S3: ModuleWithPermissions;\n Auth: ModuleWithPermissions;\n User: ModuleWithPermissions;\n Author: ModuleWithPermissions;\n Company: ModuleWithPermissions;\n Role: ModuleWithPermissions;\n Notification: ModuleWithPermissions;\n Push: ModuleWithPermissions;\n Feature: ModuleWithPermissions;\n Module: ModuleWithPermissions;\n Content: ModuleWithPermissions;\n HowTo: ModuleWithPermissions;\n HandbookPage: ModuleWithPermissions;\n HandbookSection: ModuleWithPermissions;\n HandbookThread: ModuleWithPermissions;\n HandbookThreadMessage: ModuleWithPermissions;\n Assistant: ModuleWithPermissions;\n AssistantMessage: ModuleWithPermissions;\n AssistantAction: ModuleWithPermissions;\n Chunk: ModuleWithPermissions;\n // Billing modules - READ: all users, UPDATE: CompanyAdministrator, ADMIN: Administrator\n Billing: ModuleWithPermissions;\n StripeCustomer: ModuleWithPermissions;\n StripePaymentMethod: ModuleWithPermissions;\n StripeSubscription: ModuleWithPermissions;\n StripeInvoice: ModuleWithPermissions;\n StripeProduct: ModuleWithPermissions;\n StripePrice: ModuleWithPermissions;\n StripeUsage: ModuleWithPermissions;\n StripePromotionCode: ModuleWithPermissions;\n StripeCoupon: ModuleWithPermissions;\n StripeCouponCode: ModuleWithPermissions;\n StripeCouponOffer: ModuleWithPermissions;\n // AI connection administration\n AiConnection: ModuleWithPermissions;\n // OAuth modules\n OAuth: ModuleWithPermissions;\n // Waitlist modules\n Waitlist: ModuleWithPermissions;\n WaitlistStats: ModuleWithPermissions;\n // Email automation modules\n EmailAutomation: ModuleWithPermissions;\n EmailAutomationStep: ModuleWithPermissions;\n EmailAutomationEnrollment: ModuleWithPermissions;\n EmailAutomationTrigger: ModuleWithPermissions;\n EmailAutomationCandidate: ModuleWithPermissions;\n // Email blast modules\n EmailBlast: ModuleWithPermissions;\n EmailBlastDelivery: ModuleWithPermissions;\n EmailBlastAudience: ModuleWithPermissions;\n // Blog modules\n BlogPost: ModuleWithPermissions;\n BlogPostTranslation: ModuleWithPermissions;\n BlogCategory: ModuleWithPermissions;\n BlogCategoryTranslation: ModuleWithPermissions;\n BlogSettings: ModuleWithPermissions;\n // Referral modules\n Referral: ModuleWithPermissions;\n ReferralStats: ModuleWithPermissions;\n // Referral link visits and the administrative referral report (opt-in: registered by apps that spread referralAdminModules)\n ReferralVisit: ModuleWithPermissions;\n ReferralAdminSummary: ModuleWithPermissions;\n ReferralAdminReferrer: ModuleWithPermissions;\n ReferralAdminReferral: ModuleWithPermissions;\n // Two-factor authentication modules\n TotpAuthenticator: ModuleWithPermissions;\n TotpSetup: ModuleWithPermissions;\n TotpVerify: ModuleWithPermissions;\n TotpVerifyLogin: ModuleWithPermissions;\n Passkey: ModuleWithPermissions;\n PasskeyRegistrationOptions: ModuleWithPermissions;\n PasskeyRegistrationVerify: ModuleWithPermissions;\n PasskeyRename: ModuleWithPermissions;\n PasskeyVerifyLogin: ModuleWithPermissions;\n PasskeyAuthenticationOptions: ModuleWithPermissions;\n TwoFactorEnable: ModuleWithPermissions;\n TwoFactorChallenge: ModuleWithPermissions;\n TwoFactorStatus: ModuleWithPermissions;\n BackupCodeVerify: ModuleWithPermissions;\n // OAuth sign-up awaiting consent\n PendingRegistration: ModuleWithPermissions;\n // RBAC modules\n PermissionMapping: ModuleWithPermissions;\n ModulePaths: ModuleWithPermissions;\n RbacMatrix: ModuleWithPermissions;\n // Audit modules\n AuditLog: ModuleWithPermissions;\n // Administrative token-usage reporting modules\n TokenUsageAdminSummary: ModuleWithPermissions;\n TokenUsageAdminTimeline: ModuleWithPermissions;\n TokenUsageAdminBreakdown: ModuleWithPermissions;\n // Self-service token-usage reporting modules\n TokenUsageReportSummary: ModuleWithPermissions;\n TokenUsageReportTimeline: ModuleWithPermissions;\n TokenUsageReportBreakdown: ModuleWithPermissions;\n // First-party web analytics modules (tracker + administrative dashboard)\n AnalyticsEvent: ModuleWithPermissions;\n AnalyticsSummary: ModuleWithPermissions;\n AnalyticsTimeline: ModuleWithPermissions;\n AnalyticsDailyUniqueTimeline: ModuleWithPermissions;\n AnalyticsBreakdown: ModuleWithPermissions;\n AnalyticsSession: ModuleWithPermissions;\n AnalyticsPageView: ModuleWithPermissions;\n // Account deletion (opt-in: registered only by apps that enable it)\n AccountDeletion: ModuleWithPermissions;\n // Discord connect (registered by apps that offer it)\n DiscordConnection: ModuleWithPermissions;\n DiscordConnectIntent: ModuleWithPermissions;\n DiscordConnectConfirmation: ModuleWithPermissions;\n // Offline mode (opt-in: registered by apps that spread offlineModules)\n OfflineChangeSet: ModuleWithPermissions;\n RootSync: ModuleWithPermissions;\n}\n\n// App-specific modules - apps will augment this interface ONLY\n\nexport interface AppModuleDefinitions {}\n\n// Combined type for full autocompletion\nexport type ModuleDefinitions = FoundationModuleDefinitions & AppModuleDefinitions;\n\n// Symbol key to avoid conflicts with other globals\nconst MODULES_KEY = Symbol.for(\"nextjs-jsonapi:modules\");\n\n// Use globalThis to persist module registry across HMR reloads\nconst globalStore = globalThis as unknown as {\n [MODULES_KEY]?: Map<string, ApiRequestDataTypeInterface>;\n};\n\n// Initialize global modules map if not set\nif (!globalStore[MODULES_KEY]) {\n globalStore[MODULES_KEY] = new Map();\n}\n\nclass ModuleRegistryClass {\n private get _modules(): Map<string, ApiRequestDataTypeInterface> {\n return globalStore[MODULES_KEY]!;\n }\n\n register<K extends string>(name: K, module: ApiRequestDataTypeInterface): void {\n this._modules.set(name, module);\n }\n\n get<K extends keyof ModuleDefinitions>(name: K): ModuleDefinitions[K] {\n let module = this._modules.get(name as string);\n\n // Self-healing: if module not found, try bootstrapping first\n if (!module) {\n const didBootstrap = tryBootstrap();\n if (didBootstrap) {\n // Retry after bootstrap\n module = this._modules.get(name as string);\n }\n }\n\n if (!module) {\n // Provide helpful error message based on state\n const hint = hasBootstrapper()\n ? \"Bootstrap was called but module still not found. Check module registration.\"\n : \"No bootstrapper registered. Ensure configureJsonApi({ bootstrapper }) is called before accessing modules.\";\n throw new Error(`Module \"${String(name)}\" not registered. ${hint}`);\n }\n\n return module as ModuleDefinitions[K];\n }\n\n /**\n * True when a module is registered under `name`. Never throws, so a component\n * can check for an opt-in module the app may not have registered.\n */\n has(name: string): boolean {\n // Bootstrap only an empty registry (as findByName does): an app that never\n // registers `name` must not re-run its bootstrapper on every check.\n if (this._modules.size === 0) tryBootstrap();\n return this._modules.has(name);\n }\n\n findByName(moduleName: string): ModuleWithPermissions {\n // Self-healing: try bootstrap if registry is empty\n if (this._modules.size === 0) {\n tryBootstrap();\n }\n\n // Search by module's name property (e.g., \"topics\", \"articles\")\n for (const module of this._modules.values()) {\n if ((module as ModuleWithPermissions).name === moduleName) {\n return module as ModuleWithPermissions;\n }\n }\n throw new Error(`Module not found: ${moduleName}`);\n }\n\n getAllPageUrls(): { id: string; text: string }[] {\n if (this._modules.size === 0) {\n tryBootstrap();\n }\n\n const seen = new Set<string>();\n const result: { id: string; text: string }[] = [];\n for (const [key, module] of this._modules.entries()) {\n const m = module as ModuleWithPermissions;\n if (m.pageUrl && !seen.has(m.pageUrl)) {\n seen.add(m.pageUrl);\n result.push({ id: m.pageUrl, text: key });\n result.push({ id: `${m.pageUrl}/:id`, text: `${key} (detail)` });\n }\n }\n return result.sort((a, b) => a.text.localeCompare(b.text));\n }\n\n findByModelName(modelName: string): ModuleWithPermissions {\n // Direct lookup by registry key (e.g., \"Article\", \"Document\")\n let module = this._modules.get(modelName);\n\n // Self-healing: if not found, try bootstrapping\n if (!module) {\n const didBootstrap = tryBootstrap();\n if (didBootstrap) {\n module = this._modules.get(modelName);\n }\n }\n\n if (!module) {\n throw new Error(`Module not found for model: ${modelName}`);\n }\n return module as ModuleWithPermissions;\n }\n\n findByFeature(feature: string): ModuleWithPermissions[] {\n const response: ModuleWithPermissions[] = [];\n\n for (const module of this._modules.values()) {\n const m = module as ModuleWithPermissions;\n if (m.feature === feature) {\n response.push(m);\n }\n }\n\n return response;\n }\n\n getAll(): ApiRequestDataTypeInterface[] {\n if (this._modules.size === 0) {\n tryBootstrap();\n }\n return Array.from(this._modules.values());\n }\n}\n\nexport const ModuleRegistry = new ModuleRegistryClass();\n\n// Proxy object for Modules.X syntax with autocompletion\nexport const Modules = new Proxy({} as ModuleDefinitions, {\n get(_, prop: string) {\n if (prop === \"findByName\") {\n return (name: string) => ModuleRegistry.findByName(name);\n }\n if (prop === \"findByModelName\") {\n return (name: string) => ModuleRegistry.findByModelName(name);\n }\n if (prop === \"findByFeature\") {\n return (feature: string) => ModuleRegistry.findByFeature(feature);\n }\n return ModuleRegistry.get(prop as keyof ModuleDefinitions);\n },\n}) as ModuleDefinitions & {\n findByName: (name: string) => ModuleWithPermissions;\n findByModelName: (name: string) => ModuleWithPermissions;\n findByFeature: (feature: string) => ModuleWithPermissions[];\n};\n","import { FieldSelector } from \"../fields/FieldSelector\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\n\nexport type EndpointQuery = {\n endpoint: ApiRequestDataTypeInterface | string;\n id?: string;\n childEndpoint?: ApiRequestDataTypeInterface | string;\n childId?: string;\n additionalParams?: { key: string; value: string | string[] }[];\n};\n\nexport class EndpointCreator {\n private _endpoint: EndpointQuery;\n\n constructor(params: {\n endpoint: ApiRequestDataTypeInterface | string;\n id?: string;\n childEndpoint?: ApiRequestDataTypeInterface | string;\n childId?: string;\n additionalParams?: { key: string; value: string }[];\n }) {\n this._endpoint = {\n endpoint: params.endpoint,\n id: params.id,\n childEndpoint: params.childEndpoint,\n childId: params.childId,\n additionalParams: params.additionalParams ?? [],\n };\n }\n\n endpoint(value: ApiRequestDataTypeInterface | string): EndpointCreator {\n this._endpoint.endpoint = value;\n return this;\n }\n\n id(value: string): EndpointCreator {\n this._endpoint.id = value;\n return this;\n }\n\n childEndpoint(value: ApiRequestDataTypeInterface | string): EndpointCreator {\n this._endpoint.childEndpoint = value;\n return this;\n }\n\n childId(value: string): EndpointCreator {\n this._endpoint.childId = value;\n return this;\n }\n\n set additionalParams(value: { key: string; value: string }[]) {\n this._endpoint.additionalParams = value;\n }\n\n addAdditionalParam(key: string, value: string | string[]): EndpointCreator {\n if (!this._endpoint.additionalParams) this._endpoint.additionalParams = [];\n this._endpoint.additionalParams.push({ key, value });\n return this;\n }\n\n limitToType(selectors: string[]): this {\n this.addAdditionalParam(`include`, selectors.join(\",\"));\n return this;\n }\n\n limitToFields(selectors: FieldSelector<any>[]): this {\n if (selectors.length === 0) return this;\n\n selectors.forEach((selector) => {\n const fieldString = selector.fields.join(\",\");\n this.addAdditionalParam(`fields[${selector.type}]`, fieldString);\n });\n\n return this;\n }\n\n generate(): string {\n let additionalParams = \"\";\n if (this._endpoint.additionalParams) {\n additionalParams = this._endpoint.additionalParams.map((param) => `${param.key}=${param.value}`).join(\"&\");\n }\n\n let response = ``;\n response += `${\n typeof this._endpoint.endpoint === \"string\" ? this._endpoint.endpoint : this._endpoint.endpoint.name\n }`;\n if (this._endpoint.id) response += `/${this._endpoint.id}`;\n if (this._endpoint.childEndpoint) {\n response += `/${\n typeof this._endpoint.childEndpoint === \"string\"\n ? this._endpoint.childEndpoint\n : this._endpoint.childEndpoint.name\n }`;\n }\n if (this._endpoint.childId) response += `/${this._endpoint.childId}`;\n if (additionalParams) response += `?${additionalParams}`;\n\n return response;\n }\n}\n","import { AbstractApiData } from \"../../../core/abstracts/AbstractApiData\";\nimport { JsonApiHydratedDataInterface } from \"../../../core/interfaces/JsonApiHydratedDataInterface\";\nimport { RootSyncEntry, RootSyncInterface, RootSyncLink } from \"./RootSyncInterface\";\n\n/**\n * Child path of the sync answer under the root module record\n * (`GET /<root endpoint>/:id/sync`), the same value as the app API's sync meta endpoint\n * (in Wyrdli, `campaignSyncMeta.endpoint`).\n */\nexport const ROOT_SYNC_ENDPOINT = \"sync\";\n\n/** The sync answer for one root record (`root-syncs`, id = root record id). Read-only. */\nexport class RootSync extends AbstractApiData implements RootSyncInterface {\n private _serverTime?: Date;\n private _locked: boolean = false;\n private _lockedFrom?: Date;\n private _entries?: RootSyncEntry[];\n private _links?: RootSyncLink[];\n\n get serverTime(): Date {\n if (!this._serverTime) throw new Error(\"serverTime is not set.\");\n return this._serverTime;\n }\n\n get locked(): boolean {\n return this._locked;\n }\n\n get lockedFrom(): Date | undefined {\n return this._lockedFrom;\n }\n\n get entries(): RootSyncEntry[] {\n return this._entries ?? [];\n }\n\n get links(): RootSyncLink[] {\n return this._links ?? [];\n }\n\n rehydrate(data: JsonApiHydratedDataInterface): this {\n super.rehydrate(data);\n\n const attributes = data.jsonApi.attributes ?? {};\n this._serverTime = attributes.serverTime ? new Date(attributes.serverTime) : undefined;\n this._locked = Boolean(attributes.locked);\n this._lockedFrom = attributes.lockedFrom ? new Date(attributes.lockedFrom) : undefined;\n this._entries = (attributes.entries ?? []).map((entry: { type: string; id: string; updatedAt: string }) => ({\n type: entry.type,\n id: entry.id,\n updatedAt: new Date(entry.updatedAt),\n }));\n this._links = (attributes.links ?? []).map((link: RootSyncLink) => ({\n fromType: link.fromType,\n fromId: link.fromId,\n toType: link.toType,\n toId: link.toId,\n kind: link.kind,\n props: link.props ?? {},\n }));\n\n return this;\n }\n\n createJsonApi(_data?: any): any {\n throw new Error(\"RootSync is read-only and cannot be created\");\n }\n}\n"]}
@@ -292,7 +292,7 @@ _chunk7QVYU63Ejs.__name.call(void 0, getToken, "getToken");
292
292
  async function makeRequest(params) {
293
293
  if (typeof window !== "undefined") {
294
294
  if (!_directFetch) {
295
- const clientModule = await Promise.resolve().then(() => _interopRequireWildcard(require("./request-6W6UGKJV.js")));
295
+ const clientModule = await Promise.resolve().then(() => _interopRequireWildcard(require("./request-H5FZBZA2.js")));
296
296
  _directFetch = clientModule.directFetch;
297
297
  }
298
298
  return _directFetch({
@@ -303,7 +303,8 @@ async function makeRequest(params) {
303
303
  files: params.files,
304
304
  companyId: params.companyId,
305
305
  language: params.language,
306
- additionalHeaders: params.additionalHeaders
306
+ additionalHeaders: params.additionalHeaders,
307
+ credentials: params.credentials
307
308
  });
308
309
  } else {
309
310
  if (!_serverRequest) {
@@ -375,7 +376,8 @@ async function JsonApiGet(params) {
375
376
  cache: params.classKey.cache,
376
377
  companyId: params.companyId,
377
378
  language: params.language,
378
- additionalHeaders: _optionalChain([_staticConfig, 'optionalAccess', _23 => _23.additionalHeaders])
379
+ additionalHeaders: _optionalChain([_staticConfig, 'optionalAccess', _23 => _23.additionalHeaders]),
380
+ credentials: params.credentials
379
381
  });
380
382
  return translateResponse({
381
383
  classKey: params.classKey,
@@ -410,7 +412,8 @@ async function JsonApiPost(params) {
410
412
  files: params.files,
411
413
  companyId: params.companyId,
412
414
  language: params.language,
413
- additionalHeaders: _optionalChain([_staticConfig, 'optionalAccess', _24 => _24.additionalHeaders])
415
+ additionalHeaders: _optionalChain([_staticConfig, 'optionalAccess', _24 => _24.additionalHeaders]),
416
+ credentials: params.credentials
414
417
  });
415
418
  return translateResponse({
416
419
  classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
@@ -437,7 +440,8 @@ async function JsonApiPut(params) {
437
440
  files: params.files,
438
441
  companyId: params.companyId,
439
442
  language: params.language,
440
- additionalHeaders: _optionalChain([_staticConfig, 'optionalAccess', _25 => _25.additionalHeaders])
443
+ additionalHeaders: _optionalChain([_staticConfig, 'optionalAccess', _25 => _25.additionalHeaders]),
444
+ credentials: params.credentials
441
445
  });
442
446
  return translateResponse({
443
447
  classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
@@ -464,7 +468,8 @@ async function JsonApiPatch(params) {
464
468
  files: params.files,
465
469
  companyId: params.companyId,
466
470
  language: params.language,
467
- additionalHeaders: _optionalChain([_staticConfig, 'optionalAccess', _26 => _26.additionalHeaders])
471
+ additionalHeaders: _optionalChain([_staticConfig, 'optionalAccess', _26 => _26.additionalHeaders]),
472
+ credentials: params.credentials
468
473
  });
469
474
  return translateResponse({
470
475
  classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
@@ -483,7 +488,8 @@ async function JsonApiDelete(params) {
483
488
  token,
484
489
  companyId: params.companyId,
485
490
  language: params.language,
486
- additionalHeaders: _optionalChain([_staticConfig, 'optionalAccess', _27 => _27.additionalHeaders])
491
+ additionalHeaders: _optionalChain([_staticConfig, 'optionalAccess', _27 => _27.additionalHeaders]),
492
+ credentials: params.credentials
487
493
  });
488
494
  return translateResponse({
489
495
  classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
@@ -516,4 +522,4 @@ _chunk7QVYU63Ejs.__name.call(void 0, JsonApiDelete, "JsonApiDelete");
516
522
 
517
523
 
518
524
  exports.ENV = ENV; exports.DataClassRegistry = DataClassRegistry; exports.JsonApiDataFactory = JsonApiDataFactory; exports.setBootstrapper = setBootstrapper; exports.getBootstrapper = getBootstrapper; exports.tryBootstrap = tryBootstrap; exports.hasBootstrapper = hasBootstrapper; exports.resetBootstrapStore = resetBootstrapStore; exports.translateData = translateData; exports.translateResponse = translateResponse; exports.configureJsonApi = configureJsonApi; exports.getApiUrl = getApiUrl; exports.getAppUrl = getAppUrl; exports.getTrackablePages = getTrackablePages; exports.buildUrl = buildUrl; exports.JsonApiGet = JsonApiGet; exports.JsonApiPost = JsonApiPost; exports.JsonApiPut = JsonApiPut; exports.JsonApiPatch = JsonApiPatch; exports.JsonApiDelete = JsonApiDelete;
519
- //# sourceMappingURL=chunk-GM4VZTWL.js.map
525
+ //# sourceMappingURL=chunk-RCOKQ3R4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-RCOKQ3R4.js","../src/core/env.ts","../src/core/registry/DataClassRegistry.ts","../src/core/factories/JsonApiDataFactory.ts","../src/core/registry/bootstrapStore.ts","../src/core/utils/translateResponse.ts","../src/unified/JsonApiRequest.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;AC4BO,IAAM,IAAA,EAAM;AAAA;AAAA,EAEjB,IAAI,OAAA,CAAA,EAAkB;AACpB,IAAA,wBAAO,OAAA,CAAQ,GAAA,CAAI,mBAAA,UAAuB,IAAA;AAAA,EAC5C,CAAA;AAAA;AAAA,EAEA,IAAI,OAAA,CAAA,EAAkB;AACpB,IAAA,wBAAO,OAAA,CAAQ,GAAA,CAAI,mBAAA,UAAuB,IAAA;AAAA,EAC5C,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,iBAAA,CAAA,EAA4B;AAC9B,IAAA,wBAAO,OAAA,CAAQ,GAAA,CAAI,mBAAA,UAAuB,IAAA;AAAA,EAC5C,CAAA;AAAA;AAAA,EAEA,IAAI,gBAAA,CAAA,EAA2B;AAC7B,IAAA,wBAAO,OAAA,CAAQ,GAAA,CAAI,4BAAA,UAAgC,IAAA;AAAA,EACrD,CAAA;AAAA;AAAA,EAEA,IAAI,mBAAA,CAAA,EAA8B;AAChC,IAAA,wBAAO,OAAA,CAAQ,GAAA,CAAI,+BAAA,UAAmC,IAAA;AAAA,EACxD,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,oBAAA,CAAA,EAAgC;AAClC,IAAA,uBAAO,OAAA,mBAAQ,GAAA,qBAAI,gCAAA,6BAAkC,WAAA,mBAAY,IAAA,IAAM,MAAA;AAAA,EACzE,CAAA;AAAA;AAAA,EAEA,IAAI,aAAA,CAAA,EAAyB;AAC3B,IAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,SAAA,IAAa,YAAA;AAAA,EAClC,CAAA;AAAA;AAAA,EAEA,IAAI,cAAA,CAAA,EAA0B;AAC5B,IAAA,OAAO,OAAA,CAAQ,GAAA,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ACd,EAAA;AAGtB,EAAA;AAAyB,IAAA;AACiB,IAAA;AACxC,IAAA;AACkB,IAAA;AACD,EAAA;AAErB;AAzCsB;AA2CtB;AAUE,EAAA;AACA,EAAA;AAEA,EAAA;AAAsC,IAAA;AAC5B,IAAA;AACqC,IAAA;AAC7C,IAAA;AACkB,IAAA;AACD,IAAA;AACiB,IAAA;AACd,EAAA;AAGtB,EAAA;AAAyB,IAAA;AACiB,IAAA;AACxC,IAAA;AACkB,IAAA;AACD,EAAA;AAErB;AA7BsB;AN+ItB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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-RCOKQ3R4.js","sourcesContent":[null,"/**\n * The single place in this package that reads `process.env`.\n *\n * Everything else imports {@link ENV}. Centralising the reads keeps every\n * default in one place — the same contract `base.config.ts` provides on the\n * NestJS side — instead of scattering `process.env.X || \"…\"` across hooks,\n * clients and components where the fallbacks silently drift apart.\n *\n * WHY THE READS MUST STAY LITERAL: Next.js inlines `NEXT_PUBLIC_*` by textual\n * substitution at build time, replacing the exact expression\n * `process.env.NEXT_PUBLIC_FOO` with a string literal. A computed lookup\n * (`process.env[key]`) is NOT substituted and reads as `undefined` in the\n * browser bundle. Every entry below therefore spells its variable out in full,\n * and new entries must do the same.\n *\n * WHY GETTERS AND NOT PLAIN PROPERTIES: every call site this replaced read\n * `process.env` at CALL time, not at import time. A plain property would freeze\n * the value when the module is first imported, which breaks any consumer that\n * assigns the variable after boot — the package's own tests do exactly that.\n * Getters keep the read lazy while leaving the expression literal, so the build\n * time substitution still applies.\n *\n * Because that substitution happens before the code runs, no reference to\n * `process` survives into the client bundle — so this module is safe to import\n * from client components, server components, route handlers and middleware\n * alike. It deliberately carries no `\"use client\"` directive for that reason.\n *\n * Values are normalised (empty string rather than `undefined`, booleans rather\n * than string comparisons) so callers never repeat the parsing. Callers that\n * must distinguish \"unset\" from \"set to empty\" — the URL getters, which throw a\n * configuration error — check for an empty string.\n */\nexport const ENV = {\n /** Public API base URL (NEXT_PUBLIC_API_URL). Empty when unset. */\n get API_URL(): string {\n return process.env.NEXT_PUBLIC_API_URL ?? \"\";\n },\n /** Public app base URL (NEXT_PUBLIC_ADDRESS). Empty when unset. */\n get APP_URL(): string {\n return process.env.NEXT_PUBLIC_ADDRESS ?? \"\";\n },\n /**\n * Alternative app base URL (NEXT_PUBLIC_APP_URL), used only by\n * `client/config.ts`'s `getAppUrl()` before it falls back to\n * `window.location.origin`. Empty when unset.\n */\n get APP_URL_ALTERNATE(): string {\n return process.env.NEXT_PUBLIC_APP_URL ?? \"\";\n },\n /** Web-push VAPID public key (NEXT_PUBLIC_VAPID_PUBLIC_KEY). Empty when unset. */\n get VAPID_PUBLIC_KEY(): string {\n return process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY ?? \"\";\n },\n /** Google Maps JS key (NEXT_PUBLIC_GOOGLE_MAPS_API_KEY). Empty disables autocomplete. */\n get GOOGLE_MAPS_API_KEY(): string {\n return process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY ?? \"\";\n },\n /**\n * NEXT_PUBLIC_PRIVATE_INSTALLATION === \"true\", case-insensitively\n * (default false). A private installation is a single-tenant deployment.\n */\n get PRIVATE_INSTALLATION(): boolean {\n return process.env.NEXT_PUBLIC_PRIVATE_INSTALLATION?.toLowerCase() === \"true\";\n },\n /** NODE_ENV === \"production\" — set by the Next build, not by `.env`. */\n get IS_PRODUCTION(): boolean {\n return process.env.NODE_ENV === \"production\";\n },\n /** NODE_ENV === \"development\" — gates verbose client-side diagnostics. */\n get IS_DEVELOPMENT(): boolean {\n return process.env.NODE_ENV === \"development\";\n },\n};\n","import { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\n\nexport class DataClassRegistry {\n // Use Map with string key (module.name) for reliable lookup\n // String keys are stable across HMR and module re-evaluations\n // Note: WeakMap with object identity was tried but fails during Next.js navigation\n // because module re-evaluation creates new object instances with different identity\n private static _map = new Map<string, { new (): ApiDataInterface }>();\n\n public static registerObjectClass(\n key: ApiRequestDataTypeInterface,\n classConstructor: { new (): ApiDataInterface },\n ): void {\n // Last registration wins. An earlier version skipped re-registration, which\n // silently pinned the registry to the FIRST constructor seen by the process.\n // In dev that made a long-lived `next dev` server keep rehydrating with the\n // pre-edit class after any model change, so SSR produced a different tree\n // from the freshly bundled client and React threw a hydration mismatch.\n // Production is unaffected either way: bootstrap runs once per process.\n this._map.set(key.name, classConstructor);\n }\n\n public static get(classKey: ApiRequestDataTypeInterface): {\n new (): ApiDataInterface;\n } {\n const response = this._map.get(classKey.name);\n if (!response) {\n throw new Error(\n `Class not registered for key: ${typeof classKey === \"string\" ? classKey : classKey.name}. Ensure bootstrap() was called.`,\n );\n }\n\n return response;\n }\n\n /**\n * Get class constructor by JSON:API type name.\n * Used for polymorphic rehydration where the type is determined at runtime.\n */\n public static getByJsonApiType(typeName: string): { new (): ApiDataInterface } | undefined {\n return this._map.get(typeName);\n }\n\n /**\n * Bootstrap the registry with all modules.\n * This is a convenience method for apps to register all their modules at once.\n *\n * @param modules - An object with module definitions (like the app's Modules class)\n */\n public static bootstrap(modules: Record<string, ApiRequestDataTypeInterface>): void {\n Object.values(modules).forEach((module) => {\n if (module && module.model) {\n this.registerObjectClass(module, module.model);\n }\n });\n }\n\n /**\n * Clear all registered classes. Useful for testing.\n */\n public static clear(): void {\n this._map.clear();\n }\n}\n\n// Export alias for backward compatibility\nexport { DataClassRegistry as DataClass };\n","import { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { DataClassRegistry } from \"../registry/DataClassRegistry\";\n\nexport class JsonApiDataFactory {\n public static create(classKey: ApiRequestDataTypeInterface, data: any): any {\n const factoryClass = DataClassRegistry.get(classKey);\n\n const instance = new factoryClass() as ApiDataInterface;\n const result = instance.createJsonApi(data);\n return result;\n }\n}\n","/**\n * Centralized bootstrap store accessible from ModuleRegistry.\n * This file has NO external dependencies to avoid circular imports.\n *\n * The bootstrap store allows ModuleRegistry to call the app's bootstrapper\n * when modules are accessed before bootstrap() was called, providing\n * self-healing behavior for module evaluation order issues.\n *\n * IMPORTANT: We use globalThis to persist state across HMR/Turbopack\n * module re-evaluations in development mode. Without this, the bootstrapper\n * reference would be lost when modules are hot-reloaded, causing\n * \"Module not registered\" errors during navigation.\n */\n\ntype BootstrapperFn = () => void;\n\n// Symbol key to avoid conflicts with other globals\nconst BOOTSTRAP_KEY = Symbol.for(\"nextjs-jsonapi:bootstrapper\");\nconst BOOTSTRAP_ATTEMPTED_KEY = Symbol.for(\"nextjs-jsonapi:bootstrapAttempted\");\n\n// Use globalThis to persist across HMR reloads\nconst globalStore = globalThis as unknown as {\n [BOOTSTRAP_KEY]?: BootstrapperFn | null;\n [BOOTSTRAP_ATTEMPTED_KEY]?: boolean;\n};\n\n// Initialize from global if not set\nif (globalStore[BOOTSTRAP_KEY] === undefined) {\n globalStore[BOOTSTRAP_KEY] = null;\n}\nif (globalStore[BOOTSTRAP_ATTEMPTED_KEY] === undefined) {\n globalStore[BOOTSTRAP_ATTEMPTED_KEY] = false;\n}\n\n// Getters/setters that use the global store\nfunction getBootstrapperInternal(): BootstrapperFn | null {\n return globalStore[BOOTSTRAP_KEY] ?? null;\n}\n\nfunction setBootstrapperInternal(fn: BootstrapperFn | null): void {\n globalStore[BOOTSTRAP_KEY] = fn;\n}\n\nfunction getBootstrapAttempted(): boolean {\n return globalStore[BOOTSTRAP_ATTEMPTED_KEY] ?? false;\n}\n\nfunction setBootstrapAttempted(value: boolean): void {\n globalStore[BOOTSTRAP_ATTEMPTED_KEY] = value;\n}\n\n/**\n * Register the bootstrapper function.\n * Called by configureJsonApi() from client/config, client/JsonApiClient, or unified/JsonApiRequest.\n */\nexport function setBootstrapper(fn: BootstrapperFn): void {\n setBootstrapperInternal(fn);\n}\n\n/**\n * Get the registered bootstrapper function.\n * Returns null if no bootstrapper has been registered.\n */\nexport function getBootstrapper(): BootstrapperFn | null {\n return getBootstrapperInternal();\n}\n\n/**\n * Attempt to run the bootstrapper if one is registered.\n * Returns true if bootstrapper was executed, false if not available.\n * Safe to call multiple times - bootstrapper is expected to be idempotent.\n */\nexport function tryBootstrap(): boolean {\n const bootstrapper = getBootstrapperInternal();\n const attempted = getBootstrapAttempted();\n\n if (attempted && !bootstrapper) {\n // Already tried and no bootstrapper available\n return false;\n }\n setBootstrapAttempted(true);\n\n if (bootstrapper) {\n bootstrapper();\n return true;\n }\n return false;\n}\n\n/**\n * Check if a bootstrapper has been registered.\n */\nexport function hasBootstrapper(): boolean {\n return getBootstrapperInternal() !== null;\n}\n\n/**\n * Reset the bootstrap store. Useful for testing.\n */\nexport function resetBootstrapStore(): void {\n setBootstrapperInternal(null);\n setBootstrapAttempted(false);\n}\n","import { ApiData } from \"../interfaces/ApiData\";\nimport { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { ApiResponseInterface } from \"../interfaces/ApiResponseInterface\";\nimport { DataClassRegistry } from \"../registry/DataClassRegistry\";\n\n/**\n * Translates raw JSON:API data into typed objects.\n * Does not require API response metadata.\n */\nexport function translateData<T extends ApiDataInterface>(params: {\n classKey: ApiRequestDataTypeInterface;\n data: any;\n}): T | T[] {\n const factoryClass = DataClassRegistry.get(params.classKey);\n\n if (!factoryClass) {\n throw new Error(\n `Class not registered for key: ${typeof params.classKey === \"string\" ? params.classKey : params.classKey.name}`,\n );\n }\n\n const included: any = params.data.included ?? [];\n\n if (Array.isArray(params.data.data)) {\n const responseData: T[] = [];\n\n for (const data of params.data.data) {\n const object = new factoryClass();\n object.rehydrate({ jsonApi: data, included: included, allData: params.data.data });\n responseData.push(object as T);\n }\n\n return responseData as T[];\n } else {\n const responseData = new factoryClass();\n responseData.rehydrate({\n jsonApi: params.data.data,\n included: included,\n });\n\n return responseData as T;\n }\n}\n\n/**\n * Translates a full API response into a typed ApiResponseInterface.\n * Includes pagination support.\n */\nexport async function translateResponse<T extends ApiDataInterface>(params: {\n classKey: ApiRequestDataTypeInterface;\n apiResponse: ApiData;\n companyId?: string;\n language: string;\n paginationHandler?: (endpoint: string) => Promise<ApiResponseInterface>;\n}): Promise<ApiResponseInterface> {\n const response: ApiResponseInterface = {\n ok: true,\n response: 0,\n data: [],\n error: \"\",\n };\n\n const factoryClass = DataClassRegistry.get(params.classKey);\n\n if (!factoryClass) {\n throw new Error(\n `Class not registered for key: ${typeof params.classKey === \"string\" ? params.classKey : params.classKey.name}`,\n );\n }\n\n response.ok = params.apiResponse.ok;\n response.response = params.apiResponse.status;\n\n if (!params.apiResponse.ok) {\n // The nestjs-neo4jsonapi `HttpExceptionFilter` emits a JSON:API error document\n // (`errors: [{ status, title, detail, ... }]`), so `detail` is read first, then the legacy\n // `message`/`error` keys, then `statusText` (empty over HTTP/2).\n response.error =\n params.apiResponse?.data?.errors?.[0]?.detail ??\n params.apiResponse?.data?.message ??\n params.apiResponse?.data?.error ??\n params.apiResponse.statusText;\n response.raw = params.apiResponse.data;\n return response;\n }\n\n if (params.apiResponse.status === 204) return response;\n\n // A success with no body (e.g. a 200 from a handler that sends nothing —\n // @HttpCode is inert when a controller injects @Res, so \"204\" endpoints can\n // arrive as empty 200s) translates to an empty success, not a crash on\n // `.included` below.\n if (params.apiResponse.data === undefined || params.apiResponse.data === null) return response;\n\n response.raw = params.apiResponse.data;\n\n // Extract meta from JSON:API response\n if (params.apiResponse.data?.meta) {\n response.meta = params.apiResponse.data.meta;\n }\n\n try {\n // Check if response is JSON:API formatted (has a 'data' property)\n // If not, return the raw response data directly (e.g., { url: \"...\" } or { clientSecret: \"...\" })\n if (\n params.apiResponse.data &&\n typeof params.apiResponse.data === \"object\" &&\n !Array.isArray(params.apiResponse.data) &&\n params.apiResponse.data.data === undefined\n ) {\n response.data = params.apiResponse.data;\n return response;\n }\n\n const included: any = params.apiResponse.data.included ?? [];\n\n if (params.apiResponse.data.links) {\n response.self = params.apiResponse.data.links.self;\n\n if (params.apiResponse.data.links.next && params.paginationHandler) {\n response.next = params.apiResponse.data.links.next;\n response.nextPage = async () => params.paginationHandler!(params.apiResponse.data.links.next);\n }\n\n if (params.apiResponse.data.links.prev && params.paginationHandler) {\n response.prev = params.apiResponse.data.links.prev;\n response.prevPage = async () => params.paginationHandler!(params.apiResponse.data.links.prev);\n }\n }\n\n if (Array.isArray(params.apiResponse.data.data)) {\n const responseData: T[] = [];\n\n for (const data of params.apiResponse.data.data) {\n const object = new factoryClass();\n object.rehydrate({ jsonApi: data, included: included, allData: params.apiResponse.data.data });\n responseData.push(object as T);\n }\n\n response.data = responseData;\n } else {\n const responseData = new factoryClass();\n responseData.rehydrate({\n jsonApi: params.apiResponse.data.data,\n included: included,\n });\n\n response.data = responseData;\n }\n } catch (e) {\n console.error(e);\n }\n\n return response;\n}\n","import { ENV } from \"../core/env\";\nimport { JsonApiDataFactory } from \"../core/factories/JsonApiDataFactory\";\nimport { ApiData } from \"../core/interfaces/ApiData\";\nimport { ApiRequestDataTypeInterface } from \"../core/interfaces/ApiRequestDataTypeInterface\";\nimport { ApiResponseInterface } from \"../core/interfaces/ApiResponseInterface\";\nimport { setBootstrapper } from \"../core/registry/bootstrapStore\";\nimport { translateResponse } from \"../core/utils/translateResponse\";\nimport { ModuleWithPermissions } from \"../permissions/types\";\n\n// Type definitions for dynamically imported functions (avoiding typeof import to prevent bundling)\ntype DirectFetchFn = (params: {\n method: string;\n url: string;\n token?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n companyId?: string;\n language: string;\n additionalHeaders?: Record<string, string>;\n credentials?: RequestCredentials;\n}) => Promise<ApiData>;\n\ntype ServerRequestFn = (params: {\n method: string;\n url: string;\n token?: string;\n cache?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n companyId?: string;\n language: string;\n additionalHeaders?: Record<string, string>;\n}) => Promise<ApiData>;\n\ntype GetTokenFn = () => Promise<string | undefined>;\n\n// These will be dynamically imported based on environment\nlet _directFetch: DirectFetchFn;\nlet _serverRequest: ServerRequestFn;\nlet _getClientToken: GetTokenFn;\nlet _getServerToken: GetTokenFn;\n\n// Config storage for non-React contexts\nlet _staticConfig: {\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 client for non-React contexts (e.g., server components).\n * For React contexts, use JsonApiProvider instead.\n */\nexport function configureJsonApi(config: {\n apiUrl: string;\n appUrl?: string;\n trackablePages?: ModuleWithPermissions[];\n bootstrapper?: () => void;\n additionalHeaders?: Record<string, string>;\n}): void {\n _staticConfig = config;\n // Register and call bootstrapper to register all modules\n if (config.bootstrapper) {\n setBootstrapper(config.bootstrapper);\n config.bootstrapper();\n }\n}\n\nasync function getToken(): Promise<string | undefined> {\n if (typeof window === \"undefined\") {\n // Server-side\n if (!_getServerToken) {\n const serverModule = await import(\"../server/token\");\n _getServerToken = serverModule.getServerToken;\n }\n return _getServerToken();\n } else {\n // Client-side\n if (!_getClientToken) {\n const clientModule = await import(\"../client/token\");\n _getClientToken = clientModule.getClientToken;\n }\n return _getClientToken();\n }\n}\n\nasync function makeRequest(params: {\n method: string;\n url: string;\n token?: string;\n cache?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n companyId?: string;\n language: string;\n additionalHeaders?: Record<string, string>;\n /** Client-side only: forwarded to the browser `fetch`. Ignored on the server. */\n credentials?: RequestCredentials;\n}): Promise<ApiData> {\n if (typeof window !== \"undefined\") {\n // Client-side: use direct fetch\n if (!_directFetch) {\n const clientModule = await import(\"../client/request\");\n _directFetch = clientModule.directFetch;\n }\n return _directFetch({\n method: params.method,\n url: params.url,\n token: params.token,\n body: params.body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: params.additionalHeaders,\n credentials: params.credentials,\n });\n } else {\n // Server-side: use server request with caching\n if (!_serverRequest) {\n const serverModule = await import(\"../server/request\");\n _serverRequest = serverModule.serverRequest;\n }\n return _serverRequest({\n method: params.method,\n url: params.url,\n token: params.token,\n cache: params.cache,\n body: params.body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: params.additionalHeaders,\n });\n }\n}\n\nexport function getApiUrl(): string {\n if (_staticConfig?.apiUrl) {\n return _staticConfig.apiUrl;\n }\n // Fallback to environment variable\n const envUrl = ENV.API_URL;\n if (!envUrl) {\n throw new Error(\"API URL not configured. Use configureJsonApi() or set NEXT_PUBLIC_API_URL environment variable.\");\n }\n return envUrl;\n}\n\nexport function getAppUrl(): string {\n if (_staticConfig?.appUrl) {\n return _staticConfig.appUrl;\n }\n // Fallback to environment variable\n const envUrl = ENV.APP_URL;\n if (!envUrl) {\n throw new Error(\n \"App URL not configured. Use configureJsonApi({ appUrl }) or set NEXT_PUBLIC_ADDRESS environment variable.\",\n );\n }\n return envUrl.trim().replace(/\\/+$/, \"\");\n}\n\nexport function getTrackablePages(): ModuleWithPermissions[] {\n return _staticConfig?.trackablePages ?? [];\n}\n\nfunction runBootstrapper(): void {\n if (_staticConfig?.bootstrapper) {\n _staticConfig.bootstrapper();\n }\n}\n\n/**\n * Resolve the final request URL for an endpoint.\n *\n * - `endpoint` starting with \"http\" is always passed through unchanged (existing behaviour).\n * - Otherwise, an explicit `baseUrl` (per-call override) takes precedence over the global\n * `getApiUrl()` resolution. Omitting `baseUrl` preserves today's behaviour exactly.\n */\nexport function buildUrl(endpoint: string, baseUrl?: string): string {\n if (endpoint.startsWith(\"http\")) return endpoint;\n const apiUrl = baseUrl ?? getApiUrl();\n return `${apiUrl}${endpoint}`;\n}\n\nexport async function JsonApiGet(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n language: string;\n token?: string;\n baseUrl?: string;\n credentials?: RequestCredentials;\n}): Promise<ApiResponseInterface> {\n runBootstrapper();\n // A cached server GET never sends the token, so it must not read the cookie either:\n // the read would make a public page dynamic.\n const isServerCached = typeof window === \"undefined\" && !!params.classKey.cache;\n const token = isServerCached ? undefined : (params.token ?? (await getToken()));\n\n const apiResponse = await makeRequest({\n method: \"GET\",\n url: buildUrl(params.endpoint, params.baseUrl),\n token,\n cache: params.classKey.cache,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _staticConfig?.additionalHeaders,\n credentials: params.credentials,\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 JsonApiGet({\n classKey: params.classKey,\n endpoint,\n companyId: params.companyId,\n language: params.language,\n token: params.token,\n baseUrl: params.baseUrl,\n }),\n });\n}\n\nexport async function JsonApiPost(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 token?: string;\n baseUrl?: string;\n credentials?: RequestCredentials;\n}): Promise<ApiResponseInterface> {\n runBootstrapper();\n const token = params.token ?? (await getToken());\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 makeRequest({\n method: \"POST\",\n url: buildUrl(params.endpoint, params.baseUrl),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _staticConfig?.additionalHeaders,\n credentials: params.credentials,\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 JsonApiPut(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 token?: string;\n baseUrl?: string;\n credentials?: RequestCredentials;\n}): Promise<ApiResponseInterface> {\n runBootstrapper();\n const token = params.token ?? (await getToken());\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 makeRequest({\n method: \"PUT\",\n url: buildUrl(params.endpoint, params.baseUrl),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _staticConfig?.additionalHeaders,\n credentials: params.credentials,\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 JsonApiPatch(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 token?: string;\n baseUrl?: string;\n credentials?: RequestCredentials;\n}): Promise<ApiResponseInterface> {\n runBootstrapper();\n const token = params.token ?? (await getToken());\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 makeRequest({\n method: \"PATCH\",\n url: buildUrl(params.endpoint, params.baseUrl),\n token,\n body,\n files: params.files,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _staticConfig?.additionalHeaders,\n credentials: params.credentials,\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 JsonApiDelete(params: {\n classKey: ApiRequestDataTypeInterface;\n endpoint: string;\n companyId?: string;\n language: string;\n responseType?: ApiRequestDataTypeInterface;\n token?: string;\n baseUrl?: string;\n credentials?: RequestCredentials;\n}): Promise<ApiResponseInterface> {\n runBootstrapper();\n const token = params.token ?? (await getToken());\n\n const apiResponse = await makeRequest({\n method: \"DELETE\",\n url: buildUrl(params.endpoint, params.baseUrl),\n token,\n companyId: params.companyId,\n language: params.language,\n additionalHeaders: _staticConfig?.additionalHeaders,\n credentials: params.credentials,\n });\n\n return translateResponse({\n classKey: params.responseType ?? params.classKey,\n apiResponse,\n companyId: params.companyId,\n language: params.language,\n });\n}\n"]}
@@ -21,7 +21,7 @@ async function directFetch(params) {
21
21
  return answerLocally(params);
22
22
  }
23
23
  if (offline && response.ok && params.method.toUpperCase() !== "GET") {
24
- const { writeThrough } = await import("./write-through-IWQKXYHE.mjs");
24
+ const { writeThrough } = await import("./write-through-7I3LA2WN.mjs");
25
25
  await writeThrough({ method: params.method, url: params.url }, response);
26
26
  }
27
27
  return response;
@@ -33,7 +33,7 @@ function hasReplayHeader(headers) {
33
33
  }
34
34
  __name(hasReplayHeader, "hasReplayHeader");
35
35
  async function answerLocally(params) {
36
- const { localTransport } = await import("./local-transport-C7YTA4I7.mjs");
36
+ const { localTransport } = await import("./local-transport-RVD4FZGA.mjs");
37
37
  return localTransport({ method: params.method, url: params.url, body: params.body, files: params.files });
38
38
  }
39
39
  __name(answerLocally, "answerLocally");
@@ -83,6 +83,9 @@ async function fetchFromApi(params) {
83
83
  if (requestBody !== void 0) {
84
84
  options.body = requestBody;
85
85
  }
86
+ if (params.credentials) {
87
+ options.credentials = params.credentials;
88
+ }
86
89
  if (params.token) {
87
90
  options.headers = { ...options.headers, Authorization: `Bearer ${params.token}` };
88
91
  }
@@ -110,4 +113,4 @@ __name(fetchFromApi, "fetchFromApi");
110
113
  export {
111
114
  directFetch
112
115
  };
113
- //# sourceMappingURL=chunk-M3N7LPHX.mjs.map
116
+ //# sourceMappingURL=chunk-S7SPAC6X.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client/request.ts"],"sourcesContent":["\"use client\";\n\nimport { ApiData } from \"../core/interfaces/ApiData\";\nimport { isOfflineConfigured } from \"../offline/config\";\nimport { getOfflineState, reachesNetworkWhileOffline, setOfflineState } from \"../offline/state\";\nimport { OFFLINE_REPLAY_HEADER } from \"../offline/types\";\n\nexport interface DirectFetchParams {\n method: string;\n url: string;\n token?: string;\n body?: any;\n files?: { [key: string]: File | Blob } | File | Blob;\n companyId?: string;\n language: string;\n additionalHeaders?: Record<string, string>;\n /**\n * Optional `fetch` credentials mode (e.g. \"include\" so the browser stores a cookie the API sets).\n * Omitted => no `credentials` option is passed, unchanged behaviour.\n */\n credentials?: RequestCredentials;\n}\n\n/**\n * Client-side direct fetch to bypass server action overhead.\n * Use this for client-side API calls.\n */\nexport async function directFetch(params: DirectFetchParams): Promise<ApiData> {\n // Offline mode is opt-in (`configureOffline`). Without it nothing below loads or runs. A request\n // the server runs as an offline replay always goes to the network, and so do the reads and the\n // change-set request of a reconnect attempt (the session stays offline until its sync succeeds).\n const offline = isOfflineConfigured() && !hasReplayHeader(params.additionalHeaders);\n if (offline && !getOfflineState().online && !reachesNetworkWhileOffline(params.method, params.url)) {\n return answerLocally(params);\n }\n\n const response = await fetchFromApi(params);\n\n if (offline && response.networkError) {\n setOfflineState({ online: false });\n return answerLocally(params);\n }\n if (offline && response.ok && params.method.toUpperCase() !== \"GET\") {\n const { writeThrough } = await import(\"../offline/write-through\");\n await writeThrough({ method: params.method, url: params.url }, response);\n }\n\n return response;\n}\n\nfunction hasReplayHeader(headers?: Record<string, string>): boolean {\n if (!headers) return false;\n return Object.keys(headers).some((key) => key.toLowerCase() === OFFLINE_REPLAY_HEADER);\n}\n\nasync function answerLocally(params: DirectFetchParams): Promise<ApiData> {\n const { localTransport } = await import(\"../offline/local-transport\");\n return localTransport({ method: params.method, url: params.url, body: params.body, files: params.files });\n}\n\nasync function fetchFromApi(params: DirectFetchParams): Promise<ApiData> {\n const response: ApiData = {\n data: undefined,\n ok: false,\n status: 0,\n statusText: \"\",\n };\n\n const additionalHeaders: Record<string, string> = { ...params.additionalHeaders };\n\n if (params.companyId) {\n additionalHeaders[\"x-companyid\"] = params.companyId;\n }\n additionalHeaders[\"x-language\"] = params.language;\n\n let requestBody: BodyInit | undefined = undefined;\n\n if (params.files) {\n const formData = new FormData();\n if (params.body && typeof params.body === \"object\") {\n for (const key in params.body) {\n if (Object.prototype.hasOwnProperty.call(params.body, key)) {\n formData.append(\n key,\n typeof params.body[key] === \"object\" ? JSON.stringify(params.body[key]) : params.body[key],\n );\n }\n }\n }\n\n if (params.files instanceof Blob) {\n formData.append(\"file\", params.files);\n } else if (typeof params.files === \"object\" && params.files !== null) {\n for (const key in params.files) {\n if (Object.prototype.hasOwnProperty.call(params.files, key)) {\n formData.append(key, params.files[key]);\n }\n }\n }\n\n requestBody = formData;\n } else if (params.body !== undefined) {\n requestBody = JSON.stringify(params.body);\n additionalHeaders[\"Content-Type\"] = \"application/json\";\n }\n\n const options: RequestInit = {\n method: params.method,\n headers: { Accept: \"application/json\", ...additionalHeaders },\n };\n\n if (requestBody !== undefined) {\n options.body = requestBody;\n }\n\n if (params.credentials) {\n options.credentials = params.credentials;\n }\n\n if (params.token) {\n options.headers = { ...options.headers, Authorization: `Bearer ${params.token}` };\n }\n\n try {\n const apiResponse = await fetch(params.url, options);\n\n response.ok = apiResponse.ok;\n response.status = apiResponse.status;\n response.statusText = apiResponse.statusText;\n try {\n response.data = await apiResponse.json();\n } catch {\n response.data = undefined;\n }\n } catch {\n // fetch() only throws when the API could not be reached at all (server\n // down, DNS, connection refused). Report it as 503 so consumers can tell\n // \"API unreachable\" apart from a 500 the API actually returned.\n response.ok = false;\n response.status = 503;\n response.statusText = \"Service Unavailable\";\n response.data = undefined;\n response.networkError = true;\n }\n\n return response;\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,eAAsB,YAAY,QAA6C;AAI7E,QAAM,UAAU,oBAAoB,KAAK,CAAC,gBAAgB,OAAO,iBAAiB;AAClF,MAAI,WAAW,CAAC,gBAAgB,EAAE,UAAU,CAAC,2BAA2B,OAAO,QAAQ,OAAO,GAAG,GAAG;AAClG,WAAO,cAAc,MAAM;AAAA,EAC7B;AAEA,QA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,OAAO;AAChB,aAAS,eAAe;AAAA,EAC1B;AAEA,SAAO;AACT;AAtFe;","names":[]}
@@ -4,7 +4,7 @@ var _chunkG4JR3SFVjs = require('./chunk-G4JR3SFV.js');
4
4
 
5
5
 
6
6
 
7
- var _chunkZB6OYIMBjs = require('./chunk-ZB6OYIMB.js');
7
+ var _chunkHN7L6RRWjs = require('./chunk-HN7L6RRW.js');
8
8
 
9
9
 
10
10
  var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
@@ -40,7 +40,7 @@ var ServerSession = class {
40
40
  const headerStore = await _headers.headers.call(void 0, );
41
41
  const token = _optionalChain([cookieStore, 'access', _ => _.get, 'call', _2 => _2("token"), 'optionalAccess', _3 => _3.value]) || void 0;
42
42
  const roles = _optionalChain([cookieStore, 'access', _4 => _4.get, 'call', _5 => _5("roles"), 'optionalAccess', _6 => _6.value]);
43
- const viewportCookie = _optionalChain([cookieStore, 'access', _7 => _7.get, 'call', _8 => _8(_chunkZB6OYIMBjs.VIEWPORT_COOKIE_NAME), 'optionalAccess', _9 => _9.value]);
43
+ const viewportCookie = _optionalChain([cookieStore, 'access', _7 => _7.get, 'call', _8 => _8(_chunkHN7L6RRWjs.VIEWPORT_COOKIE_NAME), 'optionalAccess', _9 => _9.value]);
44
44
  return {
45
45
  isLogged: !!token,
46
46
  isAdministrator: !!roles && roles.includes(_chunkG4JR3SFVjs.getRoleId.call(void 0, ).Administrator),
@@ -88,7 +88,7 @@ var ServerSession = class {
88
88
  if (!rawModules) return false;
89
89
  const modules = JSON.parse(_pako.ungzip.call(void 0, Buffer.from(rawModules, "base64"), { toText: true }));
90
90
  const selectedModule = modules.find((module) => module.id === params.module.moduleId);
91
- return _chunkZB6OYIMBjs.checkPermissionsFromServer.call(void 0, {
91
+ return _chunkHN7L6RRWjs.checkPermissionsFromServer.call(void 0, {
92
92
  module: params.module,
93
93
  action: params.action,
94
94
  data: params.data,
@@ -138,4 +138,4 @@ _chunk7QVYU63Ejs.__name.call(void 0, readBuildId, "readBuildId");
138
138
 
139
139
 
140
140
  exports.invalidateCacheTag = invalidateCacheTag; exports.invalidateCacheTags = invalidateCacheTags; exports.updateCacheTag = updateCacheTag; exports.ServerSession = ServerSession; exports.buildOfflineManifest = buildOfflineManifest;
141
- //# sourceMappingURL=chunk-54K2CZ2F.js.map
141
+ //# sourceMappingURL=chunk-SO3YUCL6.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-54K2CZ2F.js","../src/server/cache.ts","../src/server/ServerSession.ts","../src/offline/server/build-offline-manifest.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACTA,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;ADftB;AACA;AE5BA,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,C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B,IAAA,MAAM,KAAA,EAAO,cAAA,CAAK,IAAA,CAAK,GAAA,EAAK,KAAA,CAAM,IAAI,CAAA;AACtC,IAAA,GAAA,CAAI,KAAA,CAAM,WAAA,CAAY,CAAA,EAAG,KAAA,CAAM,IAAA,CAAK,GAAI,MAAM,SAAA,CAAU,IAAI,CAAE,CAAA;AAAA,IAAA,KAAA,GAAA,CACrD,KAAA,CAAM,MAAA,CAAO,CAAA,EAAG,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AAAA,EAC1C;AACA,EAAA,OAAO,KAAA;AACT;AATe,qCAAA,SAAA,EAAA,WAAA,CAAA;AAsBf,MAAA,SAAsB,oBAAA,CAAqB,MAAA,EAGd;AAC3B,EAAA,MAAM,UAAA,EAAY,cAAA,CAAK,IAAA,CAAK,MAAA,CAAO,OAAA,EAAS,QAAQ,CAAA;AACpD,EAAA,MAAM,MAAA,EAAQ,MAAM,SAAA,CAAU,SAAS,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,KAAA,CACZ,GAAA,CAAI,CAAC,IAAA,EAAA,GAAS,CAAA,cAAA,EAAiB,cAAA,CAAK,QAAA,CAAS,SAAA,EAAW,IAAI,CAAA,CAAE,KAAA,CAAM,cAAA,CAAK,GAAG,CAAA,CAAE,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA;AAGlC,EAAA;AAC/B,EAAA;AAC3B;AAZsB;AAcyD;AACzE,EAAA;AACmE,IAAA;AACvD,EAAA;AACgD,IAAA;AACyB,IAAA;AACzF,EAAA;AACF;AAPe;AH0FgG;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-54K2CZ2F.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","import { createHash } from \"node:crypto\";\nimport { readdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport type OfflineManifest = { buildId: string; assets: string[] };\n\nasync function listFiles(dir: string): Promise<string[]> {\n const entries = await readdir(dir, { withFileTypes: true });\n const files: string[] = [];\n for (const entry of entries) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) files.push(...(await listFiles(full)));\n else if (entry.isFile()) files.push(full);\n }\n return files;\n}\n\n/**\n * Describes the running build for the service worker's offline shell precache\n * (`/offline-manifest.json`): the build id from `<distDir>/BUILD_ID` and every\n * file under `<distDir>/static`, as the `/_next/static/...` URL Next serves it at.\n * `next dev` writes no BUILD_ID (its folder is `.next/dev`): the id is then `dev-` plus a hash\n * of the asset list. Dev chunk names do NOT carry content hashes (an edit rewrites a chunk under\n * the same name), so the id changes only when files appear or disappear; the service worker\n * therefore serves `/_next/static/` network first for a `dev-` build (pwa/sw.js).\n * `distDir` must be the value the app's next.config uses. `extraAssets` are further same-origin\n * URLs the shell needs with no network (the SQLite files the device worker loads).\n */\nexport async function buildOfflineManifest(params: {\n distDir: string;\n extraAssets?: string[];\n}): Promise<OfflineManifest> {\n const staticDir = path.join(params.distDir, \"static\");\n const files = await listFiles(staticDir);\n const assets = files\n .map((file) => `/_next/static/${path.relative(staticDir, file).split(path.sep).join(\"/\")}`)\n .concat(params.extraAssets ?? [])\n .sort();\n const buildId = await readBuildId(params.distDir, assets);\n return { buildId, assets };\n}\n\nasync function readBuildId(distDir: string, assets: string[]): Promise<string> {\n try {\n return (await readFile(path.join(distDir, \"BUILD_ID\"), \"utf8\")).trim();\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n return `dev-${createHash(\"sha256\").update(assets.join(\"\\n\")).digest(\"hex\").slice(0, 16)}`;\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-SO3YUCL6.js","../src/server/cache.ts","../src/server/ServerSession.ts","../src/offline/server/build-offline-manifest.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACTA,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;ADftB;AACA;AE5BA,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,EAAc,MAAM,8BAAA,CAAQ;AAClC,IAAA,MAAM,YAAA,EAAc,MAAM,8BAAA,CAAQ;AAElC,IAAA,MAAM,MAAA,kBAAQ,WAAA,mBAAY,GAAA,mBAAI,OAAO,CAAA,6BAAG,QAAA,GAAS,KAAA,CAAA;AACjD,IAAA,MAAM,MAAA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rD,KAAA,CAAM,MAAA,CAAO,CAAA,EAAG,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AAAA,EAC1C;AACA,EAAA,OAAO,KAAA;AACT;AATe,qCAAA,SAAA,EAAA,WAAA,CAAA;AAsBf,MAAA,SAAsB,oBAAA,CAAqB,MAAA,EAGd;AAC3B,EAAA,MAAM,UAAA,EAAY,cAAA,CAAK,IAAA,CAAK,MAAA,CAAO,OAAA,EAAS,QAAQ,CAAA;AACpD,EAAA,MAAM,MAAA,EAAQ,MAAM,SAAA,CAAU,SAAS,CAAA;AACvC,EAAA,MAAM,OAAA,EAAS,KAAA,CACZ,GAAA,CAAI,CAAC,IAAA,EAAA,GAAS,CAAA,cAAA,EAAiB,cAAA,CAAK,QAAA,CAAS,SAAA,EAAW,IAAI,CAAA,CAAE,KAAA,CAAM,cAAA,CAAK,GAAG,CAAA,CAAE,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA;AAGlC,EAAA;AAC/B,EAAA;AAC3B;AAZsB;AAcyD;AACzE,EAAA;AACmE,IAAA;AACvD,EAAA;AACgD,IAAA;AACyB,IAAA;AACzF,EAAA;AACF;AAPe;AH0FgG;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-SO3YUCL6.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","import { createHash } from \"node:crypto\";\nimport { readdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport type OfflineManifest = { buildId: string; assets: string[] };\n\nasync function listFiles(dir: string): Promise<string[]> {\n const entries = await readdir(dir, { withFileTypes: true });\n const files: string[] = [];\n for (const entry of entries) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) files.push(...(await listFiles(full)));\n else if (entry.isFile()) files.push(full);\n }\n return files;\n}\n\n/**\n * Describes the running build for the service worker's offline shell precache\n * (`/offline-manifest.json`): the build id from `<distDir>/BUILD_ID` and every\n * file under `<distDir>/static`, as the `/_next/static/...` URL Next serves it at.\n * `next dev` writes no BUILD_ID (its folder is `.next/dev`): the id is then `dev-` plus a hash\n * of the asset list. Dev chunk names do NOT carry content hashes (an edit rewrites a chunk under\n * the same name), so the id changes only when files appear or disappear; the service worker\n * therefore serves `/_next/static/` network first for a `dev-` build (pwa/sw.js).\n * `distDir` must be the value the app's next.config uses. `extraAssets` are further same-origin\n * URLs the shell needs with no network (the SQLite files the device worker loads).\n */\nexport async function buildOfflineManifest(params: {\n distDir: string;\n extraAssets?: string[];\n}): Promise<OfflineManifest> {\n const staticDir = path.join(params.distDir, \"static\");\n const files = await listFiles(staticDir);\n const assets = files\n .map((file) => `/_next/static/${path.relative(staticDir, file).split(path.sep).join(\"/\")}`)\n .concat(params.extraAssets ?? [])\n .sort();\n const buildId = await readBuildId(params.distDir, assets);\n return { buildId, assets };\n}\n\nasync function readBuildId(distDir: string, assets: string[]): Promise<string> {\n try {\n return (await readFile(path.join(distDir, \"BUILD_ID\"), \"utf8\")).trim();\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n return `dev-${createHash(\"sha256\").update(assets.join(\"\\n\")).digest(\"hex\").slice(0, 16)}`;\n }\n}\n"]}