@carlonicora/nextjs-jsonapi 1.46.1 → 1.47.1

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 (53) hide show
  1. package/dist/{BlockNoteEditor-UOY5GSMU.mjs → BlockNoteEditor-34PX47L4.mjs} +5 -5
  2. package/dist/{BlockNoteEditor-H6KXV3VK.js → BlockNoteEditor-GBD4N4SA.js} +15 -15
  3. package/dist/{BlockNoteEditor-H6KXV3VK.js.map → BlockNoteEditor-GBD4N4SA.js.map} +1 -1
  4. package/dist/JsonApiRequest-CRRH5B5V.js +24 -0
  5. package/dist/{JsonApiRequest-MUPAO7DI.js.map → JsonApiRequest-CRRH5B5V.js.map} +1 -1
  6. package/dist/{JsonApiRequest-XCQHVVYD.mjs → JsonApiRequest-I2S75QTJ.mjs} +2 -2
  7. package/dist/billing/index.js +347 -347
  8. package/dist/billing/index.mjs +4 -4
  9. package/dist/{chunk-WLS4D6VG.js → chunk-4MN547K7.js} +8 -1
  10. package/dist/chunk-4MN547K7.js.map +1 -0
  11. package/dist/{chunk-GCQUTWZ2.mjs → chunk-BTKJFMFL.mjs} +8 -1
  12. package/dist/chunk-BTKJFMFL.mjs.map +1 -0
  13. package/dist/{chunk-4HMQNMP6.mjs → chunk-BUCV5VFT.mjs} +2 -2
  14. package/dist/{chunk-2OJWO6QV.js → chunk-FLQPQEY2.js} +564 -575
  15. package/dist/chunk-FLQPQEY2.js.map +1 -0
  16. package/dist/{chunk-LM4SDN4Y.mjs → chunk-IPVXH3VC.mjs} +43 -5
  17. package/dist/chunk-IPVXH3VC.mjs.map +1 -0
  18. package/dist/{chunk-5AYSTQBI.mjs → chunk-L7RMKAGH.mjs} +6 -17
  19. package/dist/{chunk-5AYSTQBI.mjs.map → chunk-L7RMKAGH.mjs.map} +1 -1
  20. package/dist/{chunk-5PUPWZB4.js → chunk-ULHMVHDS.js} +137 -99
  21. package/dist/chunk-ULHMVHDS.js.map +1 -0
  22. package/dist/{chunk-GP3MDKGE.js → chunk-V63TFESU.js} +3 -3
  23. package/dist/{chunk-GP3MDKGE.js.map → chunk-V63TFESU.js.map} +1 -1
  24. package/dist/client/index.js +5 -5
  25. package/dist/client/index.mjs +4 -4
  26. package/dist/components/index.js +5 -5
  27. package/dist/components/index.mjs +4 -4
  28. package/dist/contexts/index.js +5 -5
  29. package/dist/contexts/index.mjs +4 -4
  30. package/dist/core/index.d.mts +12 -0
  31. package/dist/core/index.d.ts +12 -0
  32. package/dist/core/index.js +3 -3
  33. package/dist/core/index.mjs +2 -2
  34. package/dist/index.js +4 -4
  35. package/dist/index.mjs +3 -3
  36. package/dist/server/index.js +12 -12
  37. package/dist/server/index.mjs +2 -2
  38. package/package.json +1 -1
  39. package/src/core/abstracts/AbstractApiData.ts +56 -0
  40. package/src/core/abstracts/__tests__/readIncludedPolymorphic.spec.ts +195 -0
  41. package/src/core/registry/DataClassRegistry.ts +8 -0
  42. package/src/core/registry/__tests__/DataClassRegistry.getByJsonApiType.spec.ts +138 -0
  43. package/src/features/auth/components/forms/Register.tsx +18 -21
  44. package/src/features/referral/components/ReferralCodeCapture.tsx +0 -9
  45. package/dist/JsonApiRequest-MUPAO7DI.js +0 -24
  46. package/dist/chunk-2OJWO6QV.js.map +0 -1
  47. package/dist/chunk-5PUPWZB4.js.map +0 -1
  48. package/dist/chunk-GCQUTWZ2.mjs.map +0 -1
  49. package/dist/chunk-LM4SDN4Y.mjs.map +0 -1
  50. package/dist/chunk-WLS4D6VG.js.map +0 -1
  51. /package/dist/{BlockNoteEditor-UOY5GSMU.mjs.map → BlockNoteEditor-34PX47L4.mjs.map} +0 -0
  52. /package/dist/{JsonApiRequest-XCQHVVYD.mjs.map → JsonApiRequest-I2S75QTJ.mjs.map} +0 -0
  53. /package/dist/{chunk-4HMQNMP6.mjs.map → chunk-BUCV5VFT.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
 
17
- var _chunkGP3MDKGEjs = require('./chunk-GP3MDKGE.js');
17
+ var _chunkV63TFESUjs = require('./chunk-V63TFESU.js');
18
18
 
19
19
 
20
20
 
@@ -172,7 +172,7 @@ var _chunkGP3MDKGEjs = require('./chunk-GP3MDKGE.js');
172
172
 
173
173
 
174
174
 
175
- var _chunk5PUPWZB4js = require('./chunk-5PUPWZB4.js');
175
+ var _chunkULHMVHDSjs = require('./chunk-ULHMVHDS.js');
176
176
  require('./chunk-LXKSUWAV.js');
177
177
  require('./chunk-IBS6NI7D.js');
178
178
 
@@ -185,7 +185,7 @@ require('./chunk-IBS6NI7D.js');
185
185
 
186
186
 
187
187
 
188
- var _chunkWLS4D6VGjs = require('./chunk-WLS4D6VG.js');
188
+ var _chunk4MN547K7js = require('./chunk-4MN547K7.js');
189
189
  require('./chunk-7QVYU63E.js');
190
190
 
191
191
 
@@ -369,5 +369,5 @@ require('./chunk-7QVYU63E.js');
369
369
 
370
370
 
371
371
 
372
- exports.AVAILABLE_OAUTH_SCOPES = _chunk5PUPWZB4js.AVAILABLE_OAUTH_SCOPES; exports.AbstractApiData = _chunk5PUPWZB4js.AbstractApiData; exports.AbstractService = _chunk5PUPWZB4js.AbstractService; exports.Action = _chunk5PUPWZB4js.Action; exports.Auth = _chunk5PUPWZB4js.Auth; exports.AuthComponent = _chunk5PUPWZB4js.AuthComponent; exports.AuthModule = _chunk5PUPWZB4js.AuthModule; exports.AuthService = _chunk5PUPWZB4js.AuthService; exports.AuthorModule = _chunk5PUPWZB4js.AuthorModule; exports.BackupCodeVerify = _chunk5PUPWZB4js.BackupCodeVerify; exports.BackupCodeVerifyModule = _chunk5PUPWZB4js.BackupCodeVerifyModule; exports.Billing = _chunk5PUPWZB4js.Billing; exports.BillingModule = _chunk5PUPWZB4js.BillingModule; exports.BillingService = _chunk5PUPWZB4js.BillingService; exports.BlockNoteDiffUtil = _chunk5PUPWZB4js.BlockNoteDiffUtil; exports.BlockNoteWordDiffRendererUtil = _chunk5PUPWZB4js.BlockNoteWordDiffRendererUtil; exports.ClientAbstractService = _chunk5PUPWZB4js.ClientAbstractService; exports.ClientHttpMethod = _chunk5PUPWZB4js.ClientHttpMethod; exports.Company = _chunk5PUPWZB4js.Company; exports.CompanyFields = _chunk5PUPWZB4js.CompanyFields; exports.CompanyModule = _chunk5PUPWZB4js.CompanyModule; exports.CompanyService = _chunk5PUPWZB4js.CompanyService; exports.Content = _chunk5PUPWZB4js.Content; exports.ContentFields = _chunk5PUPWZB4js.ContentFields; exports.ContentModule = _chunk5PUPWZB4js.ContentModule; exports.ContentService = _chunk5PUPWZB4js.ContentService; exports.DEFAULT_GRANT_TYPES = _chunk5PUPWZB4js.DEFAULT_GRANT_TYPES; exports.DataClass = _chunkWLS4D6VGjs.DataClassRegistry; exports.DataClassRegistry = _chunkWLS4D6VGjs.DataClassRegistry; exports.EndpointCreator = _chunk5PUPWZB4js.EndpointCreator; exports.Feature = _chunk5PUPWZB4js.Feature; exports.FeatureModule = _chunk5PUPWZB4js.FeatureModule; exports.FeatureService = _chunk5PUPWZB4js.FeatureService; exports.HttpMethod = _chunk5PUPWZB4js.HttpMethod; exports.InvoiceStatus = _chunk5PUPWZB4js.InvoiceStatus; exports.JsonApiDataFactory = _chunkWLS4D6VGjs.JsonApiDataFactory; exports.Module = _chunk5PUPWZB4js.Module; exports.ModuleModule = _chunk5PUPWZB4js.ModuleModule; exports.ModuleRegistrar = _chunk5PUPWZB4js.ModuleRegistrar; exports.ModuleRegistry = _chunk5PUPWZB4js.ModuleRegistry; exports.Modules = _chunk5PUPWZB4js.Modules; exports.Notification = _chunk5PUPWZB4js.Notification; exports.NotificationFields = _chunk5PUPWZB4js.NotificationFields; exports.NotificationModule = _chunk5PUPWZB4js.NotificationModule; exports.NotificationService = _chunk5PUPWZB4js.NotificationService; exports.OAUTH_SCOPE_DISPLAY = _chunk5PUPWZB4js.OAUTH_SCOPE_DISPLAY; exports.OAuthClient = _chunk5PUPWZB4js.OAuthClient; exports.OAuthModule = _chunk5PUPWZB4js.OAuthModule; exports.OAuthService = _chunk5PUPWZB4js.OAuthService; exports.Passkey = _chunk5PUPWZB4js.Passkey; exports.PasskeyAuthenticationOptions = _chunk5PUPWZB4js.PasskeyAuthenticationOptions; exports.PasskeyAuthenticationOptionsModule = _chunk5PUPWZB4js.PasskeyAuthenticationOptionsModule; exports.PasskeyModule = _chunk5PUPWZB4js.PasskeyModule; exports.PasskeyRegistrationOptions = _chunk5PUPWZB4js.PasskeyRegistrationOptions; exports.PasskeyRegistrationOptionsModule = _chunk5PUPWZB4js.PasskeyRegistrationOptionsModule; exports.PasskeyRegistrationVerify = _chunk5PUPWZB4js.PasskeyRegistrationVerify; exports.PasskeyRegistrationVerifyModule = _chunk5PUPWZB4js.PasskeyRegistrationVerifyModule; exports.PasskeyRename = _chunk5PUPWZB4js.PasskeyRename; exports.PasskeyRenameModule = _chunk5PUPWZB4js.PasskeyRenameModule; exports.PasskeyVerifyLogin = _chunk5PUPWZB4js.PasskeyVerifyLogin; exports.PasskeyVerifyLoginModule = _chunk5PUPWZB4js.PasskeyVerifyLoginModule; exports.PaymentMethod = _chunk5PUPWZB4js.PaymentMethod; exports.Push = _chunk5PUPWZB4js.Push; exports.PushModule = _chunk5PUPWZB4js.PushModule; exports.PushService = _chunk5PUPWZB4js.PushService; exports.ReferralModule = _chunk5PUPWZB4js.ReferralModule; exports.ReferralService = _chunk5PUPWZB4js.ReferralService; exports.ReferralStats = _chunk5PUPWZB4js.ReferralStats; exports.ReferralStatsModule = _chunk5PUPWZB4js.ReferralStatsModule; exports.RehydrationFactory = _chunk5PUPWZB4js.RehydrationFactory; exports.Role = _chunk5PUPWZB4js.Role; exports.RoleFields = _chunk5PUPWZB4js.RoleFields; exports.RoleModule = _chunk5PUPWZB4js.RoleModule; exports.RoleService = _chunk5PUPWZB4js.RoleService; exports.S3 = _chunk5PUPWZB4js.S3; exports.S3Module = _chunk5PUPWZB4js.S3Module; exports.S3Service = _chunk5PUPWZB4js.S3Service; exports.StripeCustomer = _chunk5PUPWZB4js.StripeCustomer; exports.StripeCustomerModule = _chunk5PUPWZB4js.StripeCustomerModule; exports.StripeCustomerService = _chunk5PUPWZB4js.StripeCustomerService; exports.StripeInvoice = _chunk5PUPWZB4js.StripeInvoice; exports.StripeInvoiceModule = _chunk5PUPWZB4js.StripeInvoiceModule; exports.StripeInvoiceService = _chunk5PUPWZB4js.StripeInvoiceService; exports.StripePaymentMethodModule = _chunk5PUPWZB4js.StripePaymentMethodModule; exports.StripePrice = _chunk5PUPWZB4js.StripePrice; exports.StripePriceModule = _chunk5PUPWZB4js.StripePriceModule; exports.StripePriceService = _chunk5PUPWZB4js.StripePriceService; exports.StripeProduct = _chunk5PUPWZB4js.StripeProduct; exports.StripeProductModule = _chunk5PUPWZB4js.StripeProductModule; exports.StripeProductService = _chunk5PUPWZB4js.StripeProductService; exports.StripePromotionCode = _chunk5PUPWZB4js.StripePromotionCode; exports.StripePromotionCodeModule = _chunk5PUPWZB4js.StripePromotionCodeModule; exports.StripePromotionCodeService = _chunk5PUPWZB4js.StripePromotionCodeService; exports.StripeSubscription = _chunk5PUPWZB4js.StripeSubscription; exports.StripeSubscriptionModule = _chunk5PUPWZB4js.StripeSubscriptionModule; exports.StripeSubscriptionService = _chunk5PUPWZB4js.StripeSubscriptionService; exports.StripeUsage = _chunk5PUPWZB4js.StripeUsage; exports.StripeUsageModule = _chunk5PUPWZB4js.StripeUsageModule; exports.StripeUsageService = _chunk5PUPWZB4js.StripeUsageService; exports.SubscriptionStatus = _chunk5PUPWZB4js.SubscriptionStatus; exports.TableOptions = _chunk5PUPWZB4js.TableOptions; exports.TotpAuthenticator = _chunk5PUPWZB4js.TotpAuthenticator; exports.TotpAuthenticatorModule = _chunk5PUPWZB4js.TotpAuthenticatorModule; exports.TotpSetup = _chunk5PUPWZB4js.TotpSetup; exports.TotpSetupModule = _chunk5PUPWZB4js.TotpSetupModule; exports.TotpVerify = _chunk5PUPWZB4js.TotpVerify; exports.TotpVerifyLogin = _chunk5PUPWZB4js.TotpVerifyLogin; exports.TotpVerifyLoginModule = _chunk5PUPWZB4js.TotpVerifyLoginModule; exports.TotpVerifyModule = _chunk5PUPWZB4js.TotpVerifyModule; exports.TwoFactorChallenge = _chunk5PUPWZB4js.TwoFactorChallenge; exports.TwoFactorChallengeModule = _chunk5PUPWZB4js.TwoFactorChallengeModule; exports.TwoFactorEnable = _chunk5PUPWZB4js.TwoFactorEnable; exports.TwoFactorEnableModule = _chunk5PUPWZB4js.TwoFactorEnableModule; exports.TwoFactorService = _chunk5PUPWZB4js.TwoFactorService; exports.TwoFactorStatus = _chunk5PUPWZB4js.TwoFactorStatus; exports.TwoFactorStatusModule = _chunk5PUPWZB4js.TwoFactorStatusModule; exports.User = _chunk5PUPWZB4js.User; exports.UserFields = _chunk5PUPWZB4js.UserFields; exports.UserModule = _chunk5PUPWZB4js.UserModule; exports.UserService = _chunk5PUPWZB4js.UserService; exports.Waitlist = _chunk5PUPWZB4js.Waitlist; exports.WaitlistModule = _chunk5PUPWZB4js.WaitlistModule; exports.WaitlistService = _chunk5PUPWZB4js.WaitlistService; exports.WaitlistStats = _chunk5PUPWZB4js.WaitlistStats; exports.WaitlistStatsModule = _chunk5PUPWZB4js.WaitlistStatsModule; exports.checkPermissions = _chunk5PUPWZB4js.checkPermissions; exports.checkPermissionsFromServer = _chunk5PUPWZB4js.checkPermissionsFromServer; exports.clearLastApiTotal = _chunk5PUPWZB4js.clearLastApiTotal; exports.cn = _chunk5PUPWZB4js.cn; exports.composeRefs = _chunk5PUPWZB4js.composeRefs; exports.configureAuth = _chunk5PUPWZB4js.configureAuth; exports.configureI18n = _chunkGP3MDKGEjs.configureI18n; exports.configureJsonApi = _chunkGP3MDKGEjs.configureJsonApi; exports.configureLogin = _chunkGP3MDKGEjs.configureLogin; exports.configureReferral = _chunkGP3MDKGEjs.configureReferral; exports.configureRoles = _chunkGP3MDKGEjs.configureRoles; exports.configureWaitlist = _chunkGP3MDKGEjs.configureWaitlist; exports.createJsonApiInclusion = _chunk5PUPWZB4js.createJsonApiInclusion; exports.dismissToast = _chunk5PUPWZB4js.dismissToast; exports.entityObjectSchema = _chunk5PUPWZB4js.entityObjectSchema; exports.exists = _chunk5PUPWZB4js.exists; exports.formatDate = _chunk5PUPWZB4js.formatDate; exports.getApiUrl = _chunkGP3MDKGEjs.getApiUrl; exports.getAppUrl = _chunkGP3MDKGEjs.getAppUrl; exports.getBootstrapper = _chunkWLS4D6VGjs.getBootstrapper; exports.getClientGlobalErrorHandler = _chunk5PUPWZB4js.getClientGlobalErrorHandler; exports.getGlobalErrorHandler = _chunk5PUPWZB4js.getGlobalErrorHandler; exports.getIcon = _chunk5PUPWZB4js.getIcon; exports.getIconByModule = _chunk5PUPWZB4js.getIconByModule; exports.getIconByModuleName = _chunk5PUPWZB4js.getIconByModuleName; exports.getLastApiTotal = _chunk5PUPWZB4js.getLastApiTotal; exports.getLucideIcon = _chunk5PUPWZB4js.getLucideIcon; exports.getLucideIconByModule = _chunk5PUPWZB4js.getLucideIconByModule; exports.getLucideIconByModuleName = _chunk5PUPWZB4js.getLucideIconByModuleName; exports.getReferralConfig = _chunkGP3MDKGEjs.getReferralConfig; exports.getRoleId = _chunkGP3MDKGEjs.getRoleId; exports.getStripePublishableKey = _chunkGP3MDKGEjs.getStripePublishableKey; exports.getTableComponents = _chunk5PUPWZB4js.getTableComponents; exports.getTableOptions = _chunk5PUPWZB4js.getTableOptions; exports.getTokenHandler = _chunk5PUPWZB4js.getTokenHandler; exports.getTrackablePages = _chunkGP3MDKGEjs.getTrackablePages; exports.getValueFromPath = _chunk5PUPWZB4js.getValueFromPath; exports.getWaitlistConfig = _chunkGP3MDKGEjs.getWaitlistConfig; exports.hasBootstrapper = _chunkWLS4D6VGjs.hasBootstrapper; exports.isReferralEnabled = _chunkGP3MDKGEjs.isReferralEnabled; exports.isRolesConfigured = _chunkGP3MDKGEjs.isRolesConfigured; exports.rehydrate = _chunk5PUPWZB4js.rehydrate; exports.rehydrateList = _chunk5PUPWZB4js.rehydrateList; exports.resetBootstrapStore = _chunkWLS4D6VGjs.resetBootstrapStore; exports.setBootstrapper = _chunkWLS4D6VGjs.setBootstrapper; exports.setClientGlobalErrorHandler = _chunk5PUPWZB4js.setClientGlobalErrorHandler; exports.setGlobalErrorHandler = _chunk5PUPWZB4js.setGlobalErrorHandler; exports.showCustomToast = _chunk5PUPWZB4js.showCustomToast; exports.showError = _chunk5PUPWZB4js.showError; exports.showToast = _chunk5PUPWZB4js.showToast; exports.translateData = _chunkWLS4D6VGjs.translateData; exports.translateResponse = _chunkWLS4D6VGjs.translateResponse; exports.tryBootstrap = _chunkWLS4D6VGjs.tryBootstrap; exports.useComposedRefs = _chunk5PUPWZB4js.useComposedRefs; exports.useIsMobile = _chunk5PUPWZB4js.useIsMobile; exports.userObjectSchema = _chunk5PUPWZB4js.userObjectSchema;
372
+ exports.AVAILABLE_OAUTH_SCOPES = _chunkULHMVHDSjs.AVAILABLE_OAUTH_SCOPES; exports.AbstractApiData = _chunkULHMVHDSjs.AbstractApiData; exports.AbstractService = _chunkULHMVHDSjs.AbstractService; exports.Action = _chunkULHMVHDSjs.Action; exports.Auth = _chunkULHMVHDSjs.Auth; exports.AuthComponent = _chunkULHMVHDSjs.AuthComponent; exports.AuthModule = _chunkULHMVHDSjs.AuthModule; exports.AuthService = _chunkULHMVHDSjs.AuthService; exports.AuthorModule = _chunkULHMVHDSjs.AuthorModule; exports.BackupCodeVerify = _chunkULHMVHDSjs.BackupCodeVerify; exports.BackupCodeVerifyModule = _chunkULHMVHDSjs.BackupCodeVerifyModule; exports.Billing = _chunkULHMVHDSjs.Billing; exports.BillingModule = _chunkULHMVHDSjs.BillingModule; exports.BillingService = _chunkULHMVHDSjs.BillingService; exports.BlockNoteDiffUtil = _chunkULHMVHDSjs.BlockNoteDiffUtil; exports.BlockNoteWordDiffRendererUtil = _chunkULHMVHDSjs.BlockNoteWordDiffRendererUtil; exports.ClientAbstractService = _chunkULHMVHDSjs.ClientAbstractService; exports.ClientHttpMethod = _chunkULHMVHDSjs.ClientHttpMethod; exports.Company = _chunkULHMVHDSjs.Company; exports.CompanyFields = _chunkULHMVHDSjs.CompanyFields; exports.CompanyModule = _chunkULHMVHDSjs.CompanyModule; exports.CompanyService = _chunkULHMVHDSjs.CompanyService; exports.Content = _chunkULHMVHDSjs.Content; exports.ContentFields = _chunkULHMVHDSjs.ContentFields; exports.ContentModule = _chunkULHMVHDSjs.ContentModule; exports.ContentService = _chunkULHMVHDSjs.ContentService; exports.DEFAULT_GRANT_TYPES = _chunkULHMVHDSjs.DEFAULT_GRANT_TYPES; exports.DataClass = _chunk4MN547K7js.DataClassRegistry; exports.DataClassRegistry = _chunk4MN547K7js.DataClassRegistry; exports.EndpointCreator = _chunkULHMVHDSjs.EndpointCreator; exports.Feature = _chunkULHMVHDSjs.Feature; exports.FeatureModule = _chunkULHMVHDSjs.FeatureModule; exports.FeatureService = _chunkULHMVHDSjs.FeatureService; exports.HttpMethod = _chunkULHMVHDSjs.HttpMethod; exports.InvoiceStatus = _chunkULHMVHDSjs.InvoiceStatus; exports.JsonApiDataFactory = _chunk4MN547K7js.JsonApiDataFactory; exports.Module = _chunkULHMVHDSjs.Module; exports.ModuleModule = _chunkULHMVHDSjs.ModuleModule; exports.ModuleRegistrar = _chunkULHMVHDSjs.ModuleRegistrar; exports.ModuleRegistry = _chunkULHMVHDSjs.ModuleRegistry; exports.Modules = _chunkULHMVHDSjs.Modules; exports.Notification = _chunkULHMVHDSjs.Notification; exports.NotificationFields = _chunkULHMVHDSjs.NotificationFields; exports.NotificationModule = _chunkULHMVHDSjs.NotificationModule; exports.NotificationService = _chunkULHMVHDSjs.NotificationService; exports.OAUTH_SCOPE_DISPLAY = _chunkULHMVHDSjs.OAUTH_SCOPE_DISPLAY; exports.OAuthClient = _chunkULHMVHDSjs.OAuthClient; exports.OAuthModule = _chunkULHMVHDSjs.OAuthModule; exports.OAuthService = _chunkULHMVHDSjs.OAuthService; exports.Passkey = _chunkULHMVHDSjs.Passkey; exports.PasskeyAuthenticationOptions = _chunkULHMVHDSjs.PasskeyAuthenticationOptions; exports.PasskeyAuthenticationOptionsModule = _chunkULHMVHDSjs.PasskeyAuthenticationOptionsModule; exports.PasskeyModule = _chunkULHMVHDSjs.PasskeyModule; exports.PasskeyRegistrationOptions = _chunkULHMVHDSjs.PasskeyRegistrationOptions; exports.PasskeyRegistrationOptionsModule = _chunkULHMVHDSjs.PasskeyRegistrationOptionsModule; exports.PasskeyRegistrationVerify = _chunkULHMVHDSjs.PasskeyRegistrationVerify; exports.PasskeyRegistrationVerifyModule = _chunkULHMVHDSjs.PasskeyRegistrationVerifyModule; exports.PasskeyRename = _chunkULHMVHDSjs.PasskeyRename; exports.PasskeyRenameModule = _chunkULHMVHDSjs.PasskeyRenameModule; exports.PasskeyVerifyLogin = _chunkULHMVHDSjs.PasskeyVerifyLogin; exports.PasskeyVerifyLoginModule = _chunkULHMVHDSjs.PasskeyVerifyLoginModule; exports.PaymentMethod = _chunkULHMVHDSjs.PaymentMethod; exports.Push = _chunkULHMVHDSjs.Push; exports.PushModule = _chunkULHMVHDSjs.PushModule; exports.PushService = _chunkULHMVHDSjs.PushService; exports.ReferralModule = _chunkULHMVHDSjs.ReferralModule; exports.ReferralService = _chunkULHMVHDSjs.ReferralService; exports.ReferralStats = _chunkULHMVHDSjs.ReferralStats; exports.ReferralStatsModule = _chunkULHMVHDSjs.ReferralStatsModule; exports.RehydrationFactory = _chunkULHMVHDSjs.RehydrationFactory; exports.Role = _chunkULHMVHDSjs.Role; exports.RoleFields = _chunkULHMVHDSjs.RoleFields; exports.RoleModule = _chunkULHMVHDSjs.RoleModule; exports.RoleService = _chunkULHMVHDSjs.RoleService; exports.S3 = _chunkULHMVHDSjs.S3; exports.S3Module = _chunkULHMVHDSjs.S3Module; exports.S3Service = _chunkULHMVHDSjs.S3Service; exports.StripeCustomer = _chunkULHMVHDSjs.StripeCustomer; exports.StripeCustomerModule = _chunkULHMVHDSjs.StripeCustomerModule; exports.StripeCustomerService = _chunkULHMVHDSjs.StripeCustomerService; exports.StripeInvoice = _chunkULHMVHDSjs.StripeInvoice; exports.StripeInvoiceModule = _chunkULHMVHDSjs.StripeInvoiceModule; exports.StripeInvoiceService = _chunkULHMVHDSjs.StripeInvoiceService; exports.StripePaymentMethodModule = _chunkULHMVHDSjs.StripePaymentMethodModule; exports.StripePrice = _chunkULHMVHDSjs.StripePrice; exports.StripePriceModule = _chunkULHMVHDSjs.StripePriceModule; exports.StripePriceService = _chunkULHMVHDSjs.StripePriceService; exports.StripeProduct = _chunkULHMVHDSjs.StripeProduct; exports.StripeProductModule = _chunkULHMVHDSjs.StripeProductModule; exports.StripeProductService = _chunkULHMVHDSjs.StripeProductService; exports.StripePromotionCode = _chunkULHMVHDSjs.StripePromotionCode; exports.StripePromotionCodeModule = _chunkULHMVHDSjs.StripePromotionCodeModule; exports.StripePromotionCodeService = _chunkULHMVHDSjs.StripePromotionCodeService; exports.StripeSubscription = _chunkULHMVHDSjs.StripeSubscription; exports.StripeSubscriptionModule = _chunkULHMVHDSjs.StripeSubscriptionModule; exports.StripeSubscriptionService = _chunkULHMVHDSjs.StripeSubscriptionService; exports.StripeUsage = _chunkULHMVHDSjs.StripeUsage; exports.StripeUsageModule = _chunkULHMVHDSjs.StripeUsageModule; exports.StripeUsageService = _chunkULHMVHDSjs.StripeUsageService; exports.SubscriptionStatus = _chunkULHMVHDSjs.SubscriptionStatus; exports.TableOptions = _chunkULHMVHDSjs.TableOptions; exports.TotpAuthenticator = _chunkULHMVHDSjs.TotpAuthenticator; exports.TotpAuthenticatorModule = _chunkULHMVHDSjs.TotpAuthenticatorModule; exports.TotpSetup = _chunkULHMVHDSjs.TotpSetup; exports.TotpSetupModule = _chunkULHMVHDSjs.TotpSetupModule; exports.TotpVerify = _chunkULHMVHDSjs.TotpVerify; exports.TotpVerifyLogin = _chunkULHMVHDSjs.TotpVerifyLogin; exports.TotpVerifyLoginModule = _chunkULHMVHDSjs.TotpVerifyLoginModule; exports.TotpVerifyModule = _chunkULHMVHDSjs.TotpVerifyModule; exports.TwoFactorChallenge = _chunkULHMVHDSjs.TwoFactorChallenge; exports.TwoFactorChallengeModule = _chunkULHMVHDSjs.TwoFactorChallengeModule; exports.TwoFactorEnable = _chunkULHMVHDSjs.TwoFactorEnable; exports.TwoFactorEnableModule = _chunkULHMVHDSjs.TwoFactorEnableModule; exports.TwoFactorService = _chunkULHMVHDSjs.TwoFactorService; exports.TwoFactorStatus = _chunkULHMVHDSjs.TwoFactorStatus; exports.TwoFactorStatusModule = _chunkULHMVHDSjs.TwoFactorStatusModule; exports.User = _chunkULHMVHDSjs.User; exports.UserFields = _chunkULHMVHDSjs.UserFields; exports.UserModule = _chunkULHMVHDSjs.UserModule; exports.UserService = _chunkULHMVHDSjs.UserService; exports.Waitlist = _chunkULHMVHDSjs.Waitlist; exports.WaitlistModule = _chunkULHMVHDSjs.WaitlistModule; exports.WaitlistService = _chunkULHMVHDSjs.WaitlistService; exports.WaitlistStats = _chunkULHMVHDSjs.WaitlistStats; exports.WaitlistStatsModule = _chunkULHMVHDSjs.WaitlistStatsModule; exports.checkPermissions = _chunkULHMVHDSjs.checkPermissions; exports.checkPermissionsFromServer = _chunkULHMVHDSjs.checkPermissionsFromServer; exports.clearLastApiTotal = _chunkULHMVHDSjs.clearLastApiTotal; exports.cn = _chunkULHMVHDSjs.cn; exports.composeRefs = _chunkULHMVHDSjs.composeRefs; exports.configureAuth = _chunkULHMVHDSjs.configureAuth; exports.configureI18n = _chunkV63TFESUjs.configureI18n; exports.configureJsonApi = _chunkV63TFESUjs.configureJsonApi; exports.configureLogin = _chunkV63TFESUjs.configureLogin; exports.configureReferral = _chunkV63TFESUjs.configureReferral; exports.configureRoles = _chunkV63TFESUjs.configureRoles; exports.configureWaitlist = _chunkV63TFESUjs.configureWaitlist; exports.createJsonApiInclusion = _chunkULHMVHDSjs.createJsonApiInclusion; exports.dismissToast = _chunkULHMVHDSjs.dismissToast; exports.entityObjectSchema = _chunkULHMVHDSjs.entityObjectSchema; exports.exists = _chunkULHMVHDSjs.exists; exports.formatDate = _chunkULHMVHDSjs.formatDate; exports.getApiUrl = _chunkV63TFESUjs.getApiUrl; exports.getAppUrl = _chunkV63TFESUjs.getAppUrl; exports.getBootstrapper = _chunk4MN547K7js.getBootstrapper; exports.getClientGlobalErrorHandler = _chunkULHMVHDSjs.getClientGlobalErrorHandler; exports.getGlobalErrorHandler = _chunkULHMVHDSjs.getGlobalErrorHandler; exports.getIcon = _chunkULHMVHDSjs.getIcon; exports.getIconByModule = _chunkULHMVHDSjs.getIconByModule; exports.getIconByModuleName = _chunkULHMVHDSjs.getIconByModuleName; exports.getLastApiTotal = _chunkULHMVHDSjs.getLastApiTotal; exports.getLucideIcon = _chunkULHMVHDSjs.getLucideIcon; exports.getLucideIconByModule = _chunkULHMVHDSjs.getLucideIconByModule; exports.getLucideIconByModuleName = _chunkULHMVHDSjs.getLucideIconByModuleName; exports.getReferralConfig = _chunkV63TFESUjs.getReferralConfig; exports.getRoleId = _chunkV63TFESUjs.getRoleId; exports.getStripePublishableKey = _chunkV63TFESUjs.getStripePublishableKey; exports.getTableComponents = _chunkULHMVHDSjs.getTableComponents; exports.getTableOptions = _chunkULHMVHDSjs.getTableOptions; exports.getTokenHandler = _chunkULHMVHDSjs.getTokenHandler; exports.getTrackablePages = _chunkV63TFESUjs.getTrackablePages; exports.getValueFromPath = _chunkULHMVHDSjs.getValueFromPath; exports.getWaitlistConfig = _chunkV63TFESUjs.getWaitlistConfig; exports.hasBootstrapper = _chunk4MN547K7js.hasBootstrapper; exports.isReferralEnabled = _chunkV63TFESUjs.isReferralEnabled; exports.isRolesConfigured = _chunkV63TFESUjs.isRolesConfigured; exports.rehydrate = _chunkULHMVHDSjs.rehydrate; exports.rehydrateList = _chunkULHMVHDSjs.rehydrateList; exports.resetBootstrapStore = _chunk4MN547K7js.resetBootstrapStore; exports.setBootstrapper = _chunk4MN547K7js.setBootstrapper; exports.setClientGlobalErrorHandler = _chunkULHMVHDSjs.setClientGlobalErrorHandler; exports.setGlobalErrorHandler = _chunkULHMVHDSjs.setGlobalErrorHandler; exports.showCustomToast = _chunkULHMVHDSjs.showCustomToast; exports.showError = _chunkULHMVHDSjs.showError; exports.showToast = _chunkULHMVHDSjs.showToast; exports.translateData = _chunk4MN547K7js.translateData; exports.translateResponse = _chunk4MN547K7js.translateResponse; exports.tryBootstrap = _chunk4MN547K7js.tryBootstrap; exports.useComposedRefs = _chunkULHMVHDSjs.useComposedRefs; exports.useIsMobile = _chunkULHMVHDSjs.useIsMobile; exports.userObjectSchema = _chunkULHMVHDSjs.userObjectSchema;
373
373
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  getWaitlistConfig,
15
15
  isReferralEnabled,
16
16
  isRolesConfigured
17
- } from "./chunk-4HMQNMP6.mjs";
17
+ } from "./chunk-BUCV5VFT.mjs";
18
18
  import {
19
19
  AVAILABLE_OAUTH_SCOPES,
20
20
  AbstractApiData,
@@ -172,7 +172,7 @@ import {
172
172
  useComposedRefs,
173
173
  useIsMobile,
174
174
  userObjectSchema
175
- } from "./chunk-LM4SDN4Y.mjs";
175
+ } from "./chunk-IPVXH3VC.mjs";
176
176
  import "./chunk-AUXK7QSA.mjs";
177
177
  import "./chunk-C7C7VY4F.mjs";
178
178
  import {
@@ -185,7 +185,7 @@ import {
185
185
  translateData,
186
186
  translateResponse,
187
187
  tryBootstrap
188
- } from "./chunk-GCQUTWZ2.mjs";
188
+ } from "./chunk-BTKJFMFL.mjs";
189
189
  import "./chunk-PAWJFY3S.mjs";
190
190
  export {
191
191
  AVAILABLE_OAUTH_SCOPES,
@@ -15,13 +15,13 @@ var _chunk3ZPK4QOBjs = require('../chunk-3ZPK4QOB.js');
15
15
 
16
16
 
17
17
 
18
- var _chunk5PUPWZB4js = require('../chunk-5PUPWZB4.js');
18
+ var _chunkULHMVHDSjs = require('../chunk-ULHMVHDS.js');
19
19
  require('../chunk-LXKSUWAV.js');
20
20
  require('../chunk-IBS6NI7D.js');
21
21
 
22
22
 
23
23
 
24
- var _chunkWLS4D6VGjs = require('../chunk-WLS4D6VG.js');
24
+ var _chunk4MN547K7js = require('../chunk-4MN547K7.js');
25
25
 
26
26
 
27
27
  var _chunk7QVYU63Ejs = require('../chunk-7QVYU63E.js');
@@ -86,7 +86,7 @@ var ServerSession = class {
86
86
  if (!rawModules) return false;
87
87
  const modules = JSON.parse(_pako2.default.ungzip(Buffer.from(rawModules, "base64"), { to: "string" }));
88
88
  const selectedModule = modules.find((module) => module.id === params.module.moduleId);
89
- return _chunk5PUPWZB4js.checkPermissionsFromServer.call(void 0, {
89
+ return _chunkULHMVHDSjs.checkPermissionsFromServer.call(void 0, {
90
90
  module: params.module,
91
91
  action: params.action,
92
92
  data: params.data,
@@ -158,7 +158,7 @@ async function ServerJsonApiGet(params) {
158
158
  language: params.language,
159
159
  additionalHeaders: _optionalChain([_serverConfig, 'optionalAccess', _23 => _23.additionalHeaders])
160
160
  });
161
- return _chunkWLS4D6VGjs.translateResponse.call(void 0, {
161
+ return _chunk4MN547K7js.translateResponse.call(void 0, {
162
162
  classKey: params.classKey,
163
163
  apiResponse,
164
164
  companyId: params.companyId,
@@ -179,7 +179,7 @@ async function ServerJsonApiPost(params) {
179
179
  if (!body) {
180
180
  body = {};
181
181
  } else if (params.overridesJsonApiCreation !== true) {
182
- body = _chunkWLS4D6VGjs.JsonApiDataFactory.create(params.classKey, body);
182
+ body = _chunk4MN547K7js.JsonApiDataFactory.create(params.classKey, body);
183
183
  }
184
184
  const apiResponse = await _chunk3ZPK4QOBjs.serverRequest.call(void 0, {
185
185
  method: "POST",
@@ -191,7 +191,7 @@ async function ServerJsonApiPost(params) {
191
191
  language: params.language,
192
192
  additionalHeaders: _optionalChain([_serverConfig, 'optionalAccess', _24 => _24.additionalHeaders])
193
193
  });
194
- return _chunkWLS4D6VGjs.translateResponse.call(void 0, {
194
+ return _chunk4MN547K7js.translateResponse.call(void 0, {
195
195
  classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
196
196
  apiResponse,
197
197
  companyId: params.companyId,
@@ -206,7 +206,7 @@ async function ServerJsonApiPut(params) {
206
206
  if (!body) {
207
207
  body = {};
208
208
  } else {
209
- body = _chunkWLS4D6VGjs.JsonApiDataFactory.create(params.classKey, body);
209
+ body = _chunk4MN547K7js.JsonApiDataFactory.create(params.classKey, body);
210
210
  }
211
211
  const apiResponse = await _chunk3ZPK4QOBjs.serverRequest.call(void 0, {
212
212
  method: "PUT",
@@ -218,7 +218,7 @@ async function ServerJsonApiPut(params) {
218
218
  language: params.language,
219
219
  additionalHeaders: _optionalChain([_serverConfig, 'optionalAccess', _25 => _25.additionalHeaders])
220
220
  });
221
- return _chunkWLS4D6VGjs.translateResponse.call(void 0, {
221
+ return _chunk4MN547K7js.translateResponse.call(void 0, {
222
222
  classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
223
223
  apiResponse,
224
224
  companyId: params.companyId,
@@ -233,7 +233,7 @@ async function ServerJsonApiPatch(params) {
233
233
  if (!body) {
234
234
  body = {};
235
235
  } else if (params.overridesJsonApiCreation !== true) {
236
- body = _chunkWLS4D6VGjs.JsonApiDataFactory.create(params.classKey, body);
236
+ body = _chunk4MN547K7js.JsonApiDataFactory.create(params.classKey, body);
237
237
  }
238
238
  const apiResponse = await _chunk3ZPK4QOBjs.serverRequest.call(void 0, {
239
239
  method: "PATCH",
@@ -245,7 +245,7 @@ async function ServerJsonApiPatch(params) {
245
245
  language: params.language,
246
246
  additionalHeaders: _optionalChain([_serverConfig, 'optionalAccess', _26 => _26.additionalHeaders])
247
247
  });
248
- return _chunkWLS4D6VGjs.translateResponse.call(void 0, {
248
+ return _chunk4MN547K7js.translateResponse.call(void 0, {
249
249
  classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
250
250
  apiResponse,
251
251
  companyId: params.companyId,
@@ -264,7 +264,7 @@ async function ServerJsonApiDelete(params) {
264
264
  language: params.language,
265
265
  additionalHeaders: _optionalChain([_serverConfig, 'optionalAccess', _27 => _27.additionalHeaders])
266
266
  });
267
- return _chunkWLS4D6VGjs.translateResponse.call(void 0, {
267
+ return _chunk4MN547K7js.translateResponse.call(void 0, {
268
268
  classKey: _nullishCoalesce(params.responseType, () => ( params.classKey)),
269
269
  apiResponse,
270
270
  companyId: params.companyId,
@@ -296,5 +296,5 @@ _chunk7QVYU63Ejs.__name.call(void 0, ServerJsonApiDelete, "ServerJsonApiDelete")
296
296
 
297
297
 
298
298
 
299
- exports.ServerAuthService = _chunk5PUPWZB4js.AuthService; exports.ServerCompanyService = _chunk5PUPWZB4js.CompanyService; exports.ServerContentService = _chunk5PUPWZB4js.ContentService; exports.ServerFeatureService = _chunk5PUPWZB4js.FeatureService; exports.ServerJsonApiDelete = ServerJsonApiDelete; exports.ServerJsonApiGet = ServerJsonApiGet; exports.ServerJsonApiPatch = ServerJsonApiPatch; exports.ServerJsonApiPost = ServerJsonApiPost; exports.ServerJsonApiPut = ServerJsonApiPut; exports.ServerNotificationService = _chunk5PUPWZB4js.NotificationService; exports.ServerPushService = _chunk5PUPWZB4js.PushService; exports.ServerRoleService = _chunk5PUPWZB4js.RoleService; exports.ServerS3Service = _chunk5PUPWZB4js.S3Service; exports.ServerSession = ServerSession; exports.ServerUserService = _chunk5PUPWZB4js.UserService; exports.configureServerJsonApi = configureServerJsonApi; exports.getServerApiUrl = getServerApiUrl; exports.getServerAppUrl = getServerAppUrl; exports.getServerToken = _chunkYUO55Q5Ajs.getServerToken; exports.getServerTrackablePages = getServerTrackablePages; exports.invalidateCacheTag = invalidateCacheTag; exports.invalidateCacheTags = invalidateCacheTags; exports.serverRequest = _chunk3ZPK4QOBjs.serverRequest;
299
+ exports.ServerAuthService = _chunkULHMVHDSjs.AuthService; exports.ServerCompanyService = _chunkULHMVHDSjs.CompanyService; exports.ServerContentService = _chunkULHMVHDSjs.ContentService; exports.ServerFeatureService = _chunkULHMVHDSjs.FeatureService; exports.ServerJsonApiDelete = ServerJsonApiDelete; exports.ServerJsonApiGet = ServerJsonApiGet; exports.ServerJsonApiPatch = ServerJsonApiPatch; exports.ServerJsonApiPost = ServerJsonApiPost; exports.ServerJsonApiPut = ServerJsonApiPut; exports.ServerNotificationService = _chunkULHMVHDSjs.NotificationService; exports.ServerPushService = _chunkULHMVHDSjs.PushService; exports.ServerRoleService = _chunkULHMVHDSjs.RoleService; exports.ServerS3Service = _chunkULHMVHDSjs.S3Service; exports.ServerSession = ServerSession; exports.ServerUserService = _chunkULHMVHDSjs.UserService; exports.configureServerJsonApi = configureServerJsonApi; exports.getServerApiUrl = getServerApiUrl; exports.getServerAppUrl = getServerAppUrl; exports.getServerToken = _chunkYUO55Q5Ajs.getServerToken; exports.getServerTrackablePages = getServerTrackablePages; exports.invalidateCacheTag = invalidateCacheTag; exports.invalidateCacheTags = invalidateCacheTags; exports.serverRequest = _chunk3ZPK4QOBjs.serverRequest;
300
300
  //# sourceMappingURL=index.js.map
@@ -15,13 +15,13 @@ import {
15
15
  S3Service,
16
16
  UserService,
17
17
  checkPermissionsFromServer
18
- } from "../chunk-LM4SDN4Y.mjs";
18
+ } from "../chunk-IPVXH3VC.mjs";
19
19
  import "../chunk-AUXK7QSA.mjs";
20
20
  import "../chunk-C7C7VY4F.mjs";
21
21
  import {
22
22
  JsonApiDataFactory,
23
23
  translateResponse
24
- } from "../chunk-GCQUTWZ2.mjs";
24
+ } from "../chunk-BTKJFMFL.mjs";
25
25
  import {
26
26
  __name
27
27
  } from "../chunk-PAWJFY3S.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carlonicora/nextjs-jsonapi",
3
- "version": "1.46.1",
3
+ "version": "1.47.1",
4
4
  "description": "Next.js JSON:API client with server/client support and caching",
5
5
  "author": "Carlo Nicora",
6
6
  "license": "GPL-3.0-or-later",
@@ -115,6 +115,62 @@ export abstract class AbstractApiData implements ApiDataInterface {
115
115
  }) as T;
116
116
  }
117
117
 
118
+ /**
119
+ * Read included relationships with polymorphic type resolution.
120
+ * Determines the correct model class based on the JSON:API type in included data.
121
+ */
122
+ protected _readIncludedPolymorphic<T extends ApiDataInterface>(
123
+ data: JsonApiHydratedDataInterface,
124
+ relationshipKey: string,
125
+ candidateModules: ApiRequestDataTypeInterface[],
126
+ ): T | T[] | undefined {
127
+ // Validate relationship exists
128
+ if (!data.included?.length || !data.jsonApi.relationships?.[relationshipKey]?.data) {
129
+ return undefined;
130
+ }
131
+
132
+ const relData = data.jsonApi.relationships[relationshipKey].data;
133
+
134
+ // Build lookup map: JSON:API type -> module
135
+ const typeToModule = new Map<string, ApiRequestDataTypeInterface>();
136
+ for (const mod of candidateModules) {
137
+ typeToModule.set(mod.name, mod);
138
+ }
139
+
140
+ if (Array.isArray(relData)) {
141
+ // Many relationship
142
+ const result: T[] = [];
143
+ for (const item of relData) {
144
+ const includedItem = data.included.find((inc: any) => inc.id === item.id && inc.type === item.type);
145
+ if (!includedItem) continue;
146
+
147
+ // Resolve module by JSON:API type
148
+ const module = typeToModule.get(includedItem.type);
149
+ if (!module) continue;
150
+
151
+ result.push(
152
+ RehydrationFactory.rehydrate(module, {
153
+ jsonApi: includedItem,
154
+ included: data.included,
155
+ }) as T,
156
+ );
157
+ }
158
+ return result.length > 0 ? result : undefined;
159
+ }
160
+
161
+ // Single relationship
162
+ const includedItem = data.included.find((inc: any) => inc.id === relData.id && inc.type === relData.type);
163
+ if (!includedItem) return undefined;
164
+
165
+ const module = typeToModule.get(includedItem.type);
166
+ if (!module) return undefined;
167
+
168
+ return RehydrationFactory.rehydrate(module, {
169
+ jsonApi: includedItem,
170
+ included: data.included,
171
+ }) as T;
172
+ }
173
+
118
174
  /**
119
175
  * Read included relationship data and augment with relationship meta properties.
120
176
  * Handles both single relationships (one-to-one) and array relationships (one-to-many).
@@ -0,0 +1,195 @@
1
+ import { describe, it, expect, beforeEach, vi } from "vitest";
2
+ import { AbstractApiData } from "../AbstractApiData";
3
+ import { DataClassRegistry } from "../../registry/DataClassRegistry";
4
+ import { ApiDataInterface } from "../../interfaces/ApiDataInterface";
5
+ import { JsonApiHydratedDataInterface } from "../../interfaces/JsonApiHydratedDataInterface";
6
+ import { ApiRequestDataTypeInterface } from "../../interfaces/ApiRequestDataTypeInterface";
7
+
8
+ // Concrete test class to access protected method
9
+ class TestModel extends AbstractApiData {
10
+ public testReadIncludedPolymorphic<T extends ApiDataInterface>(
11
+ data: JsonApiHydratedDataInterface,
12
+ relationshipKey: string,
13
+ candidateModules: ApiRequestDataTypeInterface[],
14
+ ): T | T[] | undefined {
15
+ return this._readIncludedPolymorphic<T>(data, relationshipKey, candidateModules);
16
+ }
17
+ }
18
+
19
+ class MockTaxonomy extends AbstractApiData {
20
+ rehydrate(data: JsonApiHydratedDataInterface): this {
21
+ super.rehydrate(data);
22
+ return this;
23
+ }
24
+ }
25
+
26
+ class MockLeafTaxonomy extends AbstractApiData {
27
+ rehydrate(data: JsonApiHydratedDataInterface): this {
28
+ super.rehydrate(data);
29
+ return this;
30
+ }
31
+ }
32
+
33
+ const taxonomyModule: ApiRequestDataTypeInterface = {
34
+ name: "taxonomies",
35
+ model: MockTaxonomy,
36
+ } as any;
37
+
38
+ const leafTaxonomyModule: ApiRequestDataTypeInterface = {
39
+ name: "leaf-taxonomies",
40
+ model: MockLeafTaxonomy,
41
+ } as any;
42
+
43
+ describe("_readIncludedPolymorphic", () => {
44
+ beforeEach(() => {
45
+ DataClassRegistry.clear();
46
+ DataClassRegistry.registerObjectClass(taxonomyModule, MockTaxonomy);
47
+ DataClassRegistry.registerObjectClass(leafTaxonomyModule, MockLeafTaxonomy);
48
+ });
49
+
50
+ describe("Scenario: Mixed-type array relationship", () => {
51
+ it("should rehydrate items with correct model based on JSON:API type", () => {
52
+ // GIVEN: JSON:API data with mixed taxonomy types in relationship
53
+ const data: JsonApiHydratedDataInterface = {
54
+ jsonApi: {
55
+ id: "skill-1",
56
+ type: "skills",
57
+ attributes: { name: "React Development" },
58
+ relationships: {
59
+ taxonomies: {
60
+ data: [
61
+ { id: "tax-1", type: "taxonomies" },
62
+ { id: "leaf-1", type: "leaf-taxonomies" },
63
+ { id: "tax-2", type: "taxonomies" },
64
+ ],
65
+ },
66
+ },
67
+ },
68
+ included: [
69
+ { id: "tax-1", type: "taxonomies", attributes: { name: "Engineering" } },
70
+ { id: "leaf-1", type: "leaf-taxonomies", attributes: { name: "React" } },
71
+ { id: "tax-2", type: "taxonomies", attributes: { name: "Design" } },
72
+ ],
73
+ };
74
+
75
+ // WHEN: _readIncludedPolymorphic is called with both candidate modules
76
+ const model = new TestModel();
77
+ const result = model.testReadIncludedPolymorphic(data, "taxonomies", [taxonomyModule, leafTaxonomyModule]);
78
+
79
+ // THEN: Returns array with correct model instances
80
+ expect(Array.isArray(result)).toBe(true);
81
+ const items = result as ApiDataInterface[];
82
+ expect(items).toHaveLength(3);
83
+ expect(items[0]).toBeInstanceOf(MockTaxonomy);
84
+ expect(items[1]).toBeInstanceOf(MockLeafTaxonomy);
85
+ expect(items[2]).toBeInstanceOf(MockTaxonomy);
86
+ });
87
+ });
88
+
89
+ describe("Scenario: Missing included data returns undefined", () => {
90
+ it("should return undefined when included array is empty", () => {
91
+ // GIVEN: JSON:API data with no included items
92
+ const data: JsonApiHydratedDataInterface = {
93
+ jsonApi: {
94
+ id: "skill-1",
95
+ type: "skills",
96
+ attributes: {},
97
+ relationships: {
98
+ taxonomies: {
99
+ data: [{ id: "tax-1", type: "taxonomies" }],
100
+ },
101
+ },
102
+ },
103
+ included: [],
104
+ };
105
+
106
+ // WHEN: _readIncludedPolymorphic is called
107
+ const model = new TestModel();
108
+ const result = model.testReadIncludedPolymorphic(data, "taxonomies", [taxonomyModule, leafTaxonomyModule]);
109
+
110
+ // THEN: Returns undefined
111
+ expect(result).toBeUndefined();
112
+ });
113
+
114
+ it("should return undefined when relationship data is missing", () => {
115
+ // GIVEN: JSON:API data without the relationship key
116
+ const data: JsonApiHydratedDataInterface = {
117
+ jsonApi: {
118
+ id: "skill-1",
119
+ type: "skills",
120
+ attributes: {},
121
+ relationships: {},
122
+ },
123
+ included: [{ id: "tax-1", type: "taxonomies", attributes: { name: "Engineering" } }],
124
+ };
125
+
126
+ // WHEN: _readIncludedPolymorphic is called
127
+ const model = new TestModel();
128
+ const result = model.testReadIncludedPolymorphic(data, "taxonomies", [taxonomyModule, leafTaxonomyModule]);
129
+
130
+ // THEN: Returns undefined
131
+ expect(result).toBeUndefined();
132
+ });
133
+ });
134
+
135
+ describe("Scenario: Unknown type in relationship is skipped", () => {
136
+ it("should skip items with types not in candidate modules", () => {
137
+ // GIVEN: JSON:API data with an unknown type in the relationship
138
+ const data: JsonApiHydratedDataInterface = {
139
+ jsonApi: {
140
+ id: "skill-1",
141
+ type: "skills",
142
+ attributes: {},
143
+ relationships: {
144
+ taxonomies: {
145
+ data: [
146
+ { id: "tax-1", type: "taxonomies" },
147
+ { id: "unknown-1", type: "unknown-type" },
148
+ ],
149
+ },
150
+ },
151
+ },
152
+ included: [
153
+ { id: "tax-1", type: "taxonomies", attributes: { name: "Engineering" } },
154
+ { id: "unknown-1", type: "unknown-type", attributes: { name: "Unknown" } },
155
+ ],
156
+ };
157
+
158
+ // WHEN: _readIncludedPolymorphic is called
159
+ const model = new TestModel();
160
+ const result = model.testReadIncludedPolymorphic(data, "taxonomies", [taxonomyModule, leafTaxonomyModule]);
161
+
162
+ // THEN: Only the known type is returned
163
+ expect(Array.isArray(result)).toBe(true);
164
+ const items = result as ApiDataInterface[];
165
+ expect(items).toHaveLength(1);
166
+ expect(items[0]).toBeInstanceOf(MockTaxonomy);
167
+ });
168
+ });
169
+
170
+ describe("Scenario: Single polymorphic relationship", () => {
171
+ it("should rehydrate single relationship with correct type", () => {
172
+ // GIVEN: JSON:API data with a single (non-array) polymorphic relationship
173
+ const data: JsonApiHydratedDataInterface = {
174
+ jsonApi: {
175
+ id: "skill-1",
176
+ type: "skills",
177
+ attributes: {},
178
+ relationships: {
179
+ primaryTaxonomy: {
180
+ data: { id: "leaf-1", type: "leaf-taxonomies" },
181
+ },
182
+ },
183
+ },
184
+ included: [{ id: "leaf-1", type: "leaf-taxonomies", attributes: { name: "React" } }],
185
+ };
186
+
187
+ // WHEN: _readIncludedPolymorphic is called for single relationship
188
+ const model = new TestModel();
189
+ const result = model.testReadIncludedPolymorphic(data, "primaryTaxonomy", [taxonomyModule, leafTaxonomyModule]);
190
+
191
+ // THEN: Returns a single LeafTaxonomy instance
192
+ expect(result).toBeInstanceOf(MockLeafTaxonomy);
193
+ });
194
+ });
195
+ });
@@ -31,6 +31,14 @@ export class DataClassRegistry {
31
31
  return response;
32
32
  }
33
33
 
34
+ /**
35
+ * Get class constructor by JSON:API type name.
36
+ * Used for polymorphic rehydration where the type is determined at runtime.
37
+ */
38
+ public static getByJsonApiType(typeName: string): { new (): ApiDataInterface } | undefined {
39
+ return this._map.get(typeName);
40
+ }
41
+
34
42
  /**
35
43
  * Bootstrap the registry with all modules.
36
44
  * This is a convenience method for apps to register all their modules at once.
@@ -0,0 +1,138 @@
1
+ import { describe, it, expect, beforeEach } from "vitest";
2
+ import { DataClassRegistry } from "../DataClassRegistry";
3
+ import { ApiDataInterface } from "../../interfaces/ApiDataInterface";
4
+ import { ApiRequestDataTypeInterface } from "../../interfaces/ApiRequestDataTypeInterface";
5
+
6
+ class MockTaxonomy implements ApiDataInterface {
7
+ _id?: string;
8
+ _type?: string;
9
+ get id(): string {
10
+ return this._id ?? "";
11
+ }
12
+ get type(): string {
13
+ return this._type ?? "";
14
+ }
15
+ get self(): string | undefined {
16
+ return undefined;
17
+ }
18
+ get createdAt(): Date {
19
+ return new Date();
20
+ }
21
+ get updatedAt(): Date {
22
+ return new Date();
23
+ }
24
+ get included(): any[] {
25
+ return [];
26
+ }
27
+ get jsonApi(): any {
28
+ return undefined;
29
+ }
30
+ ingestJsonApi(): void {}
31
+ generateApiUrl(): string {
32
+ return "";
33
+ }
34
+ createJsonApi(): any {
35
+ return {};
36
+ }
37
+ rehydrate(data: any): this {
38
+ return this;
39
+ }
40
+ dehydrate(): any {
41
+ return {};
42
+ }
43
+ }
44
+
45
+ class MockLeafTaxonomy implements ApiDataInterface {
46
+ _id?: string;
47
+ _type?: string;
48
+ get id(): string {
49
+ return this._id ?? "";
50
+ }
51
+ get type(): string {
52
+ return this._type ?? "";
53
+ }
54
+ get self(): string | undefined {
55
+ return undefined;
56
+ }
57
+ get createdAt(): Date {
58
+ return new Date();
59
+ }
60
+ get updatedAt(): Date {
61
+ return new Date();
62
+ }
63
+ get included(): any[] {
64
+ return [];
65
+ }
66
+ get jsonApi(): any {
67
+ return undefined;
68
+ }
69
+ ingestJsonApi(): void {}
70
+ generateApiUrl(): string {
71
+ return "";
72
+ }
73
+ createJsonApi(): any {
74
+ return {};
75
+ }
76
+ rehydrate(data: any): this {
77
+ return this;
78
+ }
79
+ dehydrate(): any {
80
+ return {};
81
+ }
82
+ }
83
+
84
+ describe("DataClassRegistry.getByJsonApiType", () => {
85
+ beforeEach(() => {
86
+ DataClassRegistry.clear();
87
+ });
88
+
89
+ describe("Scenario: Lookup returns registered class for known type", () => {
90
+ it("should return the class constructor for a registered type name", () => {
91
+ // GIVEN: Two modules registered with different type names
92
+ const taxonomyModule: ApiRequestDataTypeInterface = {
93
+ name: "taxonomies",
94
+ model: MockTaxonomy,
95
+ } as any;
96
+ const leafTaxonomyModule: ApiRequestDataTypeInterface = {
97
+ name: "leaf-taxonomies",
98
+ model: MockLeafTaxonomy,
99
+ } as any;
100
+
101
+ DataClassRegistry.registerObjectClass(taxonomyModule, MockTaxonomy);
102
+ DataClassRegistry.registerObjectClass(leafTaxonomyModule, MockLeafTaxonomy);
103
+
104
+ // WHEN: getByJsonApiType is called with a registered type name
105
+ const result = DataClassRegistry.getByJsonApiType("taxonomies");
106
+
107
+ // THEN: It returns the correct class constructor
108
+ expect(result).toBe(MockTaxonomy);
109
+ });
110
+
111
+ it("should return leaf taxonomy class for leaf-taxonomies type", () => {
112
+ // GIVEN: LeafTaxonomy module registered
113
+ const leafTaxonomyModule: ApiRequestDataTypeInterface = {
114
+ name: "leaf-taxonomies",
115
+ model: MockLeafTaxonomy,
116
+ } as any;
117
+ DataClassRegistry.registerObjectClass(leafTaxonomyModule, MockLeafTaxonomy);
118
+
119
+ // WHEN: getByJsonApiType is called with "leaf-taxonomies"
120
+ const result = DataClassRegistry.getByJsonApiType("leaf-taxonomies");
121
+
122
+ // THEN: It returns MockLeafTaxonomy
123
+ expect(result).toBe(MockLeafTaxonomy);
124
+ });
125
+ });
126
+
127
+ describe("Scenario: Lookup returns undefined for unknown type", () => {
128
+ it("should return undefined for an unregistered type name", () => {
129
+ // GIVEN: No modules registered (registry cleared)
130
+
131
+ // WHEN: getByJsonApiType is called with an unknown type
132
+ const result = DataClassRegistry.getByJsonApiType("unknown-type");
133
+
134
+ // THEN: It returns undefined
135
+ expect(result).toBeUndefined();
136
+ });
137
+ });
138
+ });