@carlonicora/nextjs-jsonapi 1.5.0 → 1.7.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.
- package/dist/{ApiResponseInterface-DDI7QQPR.d.ts → ApiResponseInterface-DMwITHYP.d.mts} +11 -2
- package/dist/{ApiResponseInterface-BHN5D9r5.d.mts → ApiResponseInterface-DWgIAXI-.d.ts} +11 -2
- package/dist/AuthComponent-hxOPs9o8.d.mts +11 -0
- package/dist/AuthComponent-hxOPs9o8.d.ts +11 -0
- package/dist/{BlockNoteEditor-G6AK2NWA.js → BlockNoteEditor-IJASTIUZ.js} +16 -23
- package/dist/BlockNoteEditor-IJASTIUZ.js.map +1 -0
- package/dist/{BlockNoteEditor-AIEEQM6A.mjs → BlockNoteEditor-M6TUP3NT.mjs} +8 -15
- package/dist/BlockNoteEditor-M6TUP3NT.mjs.map +1 -0
- package/dist/JsonApiRequest-2OM5NDAW.js +24 -0
- package/dist/JsonApiRequest-2OM5NDAW.js.map +1 -0
- package/dist/{JsonApiRequest-6UR7DIAR.mjs → JsonApiRequest-SYZ6FGCA.mjs} +2 -3
- package/dist/{chunk-2K3Q24UF.js → chunk-3ZPK4QOB.js} +24 -14
- package/dist/chunk-3ZPK4QOB.js.map +1 -0
- package/dist/{chunk-VET55IZO.js → chunk-4L7OWJ2P.js} +10290 -7537
- package/dist/chunk-4L7OWJ2P.js.map +1 -0
- package/dist/chunk-4U5CJA44.mjs +3435 -0
- package/dist/chunk-4U5CJA44.mjs.map +1 -0
- package/dist/chunk-AGWQ75PQ.js +142 -0
- package/dist/chunk-AGWQ75PQ.js.map +1 -0
- package/dist/{chunk-PMXG5WBC.js → chunk-CKS6SVUK.js} +160 -24
- package/dist/chunk-CKS6SVUK.js.map +1 -0
- package/dist/{chunk-YF5XQZDR.mjs → chunk-F5UNXZ3J.mjs} +1 -1
- package/dist/chunk-F5UNXZ3J.mjs.map +1 -0
- package/dist/chunk-IGOWVLJH.mjs +142 -0
- package/dist/chunk-IGOWVLJH.mjs.map +1 -0
- package/dist/{chunk-HR4H2FP7.mjs → chunk-KJ4ETLJB.mjs} +24 -14
- package/dist/chunk-KJ4ETLJB.mjs.map +1 -0
- package/dist/{chunk-IKBA4AHN.mjs → chunk-SAL7XW2G.mjs} +143 -7
- package/dist/chunk-SAL7XW2G.mjs.map +1 -0
- package/dist/chunk-TW4QRJ7D.mjs +12085 -0
- package/dist/chunk-TW4QRJ7D.mjs.map +1 -0
- package/dist/chunk-U4NADAHN.js +3435 -0
- package/dist/chunk-U4NADAHN.js.map +1 -0
- package/dist/{chunk-EFJEWLRL.js → chunk-YUO55Q5A.js} +1 -1
- package/dist/chunk-YUO55Q5A.js.map +1 -0
- package/dist/client/index.d.mts +161 -11
- package/dist/client/index.d.ts +161 -11
- package/dist/client/index.js +71 -11
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +70 -10
- package/dist/components/index.d.mts +763 -11
- package/dist/components/index.d.ts +763 -11
- package/dist/components/index.js +462 -11
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +463 -12
- package/dist/config-BdCV25CE.d.mts +69 -0
- package/dist/config-C9dt1QiR.d.ts +69 -0
- package/dist/content.fields-Ck5lkQ5d.d.mts +47 -0
- package/dist/content.fields-Ck5lkQ5d.d.ts +47 -0
- package/dist/{content.interface-CR2aBeAW.d.ts → content.interface-B6qP_ABq.d.mts} +2 -3
- package/dist/{content.interface-FpLfsaRm.d.mts → content.interface-DHAFLasV.d.ts} +2 -3
- package/dist/contexts/index.d.mts +13 -6
- package/dist/contexts/index.d.ts +13 -6
- package/dist/contexts/index.js +7 -11
- package/dist/contexts/index.js.map +1 -1
- package/dist/contexts/index.mjs +6 -10
- package/dist/core/index.d.mts +575 -8
- package/dist/core/index.d.ts +575 -8
- package/dist/core/index.js +131 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +132 -4
- package/dist/index.d.mts +95 -71
- package/dist/index.d.ts +95 -71
- package/dist/index.js +113 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -29
- package/dist/notification.interface-agcMYCkg.d.mts +228 -0
- package/dist/notification.interface-agcMYCkg.d.ts +228 -0
- package/dist/request-GBLBPYFM.js +8 -0
- package/dist/request-GBLBPYFM.js.map +1 -0
- package/dist/request-XABCMU25.mjs +8 -0
- package/dist/s3.service-DYnmymEd.d.mts +350 -0
- package/dist/s3.service-DyXjKTqr.d.ts +350 -0
- package/dist/server/index.d.mts +69 -4
- package/dist/server/index.d.ts +69 -4
- package/dist/server/index.js +211 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +211 -5
- package/dist/server/index.mjs.map +1 -1
- package/dist/token-2UWQJY5T.js +8 -0
- package/dist/token-2UWQJY5T.js.map +1 -0
- package/dist/token-EOK3N45S.mjs +8 -0
- package/dist/{useSocket-L-An7_Mr.d.mts → useSocket-91s8M4Xd.d.mts} +1 -1
- package/dist/{useSocket-BV6yMdWS.d.ts → useSocket-DSR7vaXj.d.ts} +1 -1
- package/package.json +12 -52
- package/src/client/JsonApiClient.ts +248 -0
- package/src/client/config.ts +78 -0
- package/src/client/index.ts +6 -1
- package/src/components/containers/TabsContainer.tsx +1 -1
- package/src/components/editors/BlockNoteEditor.tsx +3 -1
- package/src/components/index.ts +4 -0
- package/src/components/navigations/Breadcrumb.tsx +1 -1
- package/src/components/navigations/Header.tsx +2 -2
- package/src/contexts/CommonContext.tsx +1 -1
- package/src/contexts/SocketContext.tsx +1 -1
- package/src/contexts/index.ts +3 -0
- package/src/core/abstracts/ClientAbstractService.ts +255 -0
- package/src/core/abstracts/ServerAbstractService.ts +180 -0
- package/src/core/abstracts/index.ts +2 -0
- package/src/core/index.ts +35 -3
- package/src/discord/config.ts +15 -0
- package/src/discord/index.ts +1 -0
- package/src/features/auth/components/details/LandingComponent.tsx +2 -2
- package/src/features/auth/components/forms/AcceptInvitation.tsx +1 -1
- package/src/features/auth/components/forms/ActivateAccount.tsx +1 -1
- package/src/features/auth/components/forms/Cookies.tsx +2 -1
- package/src/features/auth/components/forms/ForgotPassword.tsx +1 -1
- package/src/features/auth/components/forms/Login.tsx +1 -1
- package/src/features/auth/components/forms/Logout.tsx +1 -1
- package/src/features/auth/components/forms/RefreshUser.tsx +2 -1
- package/src/features/auth/components/forms/Register.tsx +1 -1
- package/src/features/auth/components/forms/ResetPassword.tsx +1 -1
- package/src/features/auth/data/auth.service.ts +1 -1
- package/src/features/auth/utils/AuthCookies.ts +1 -1
- package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +4 -2
- package/src/features/company/components/forms/CompanyDeleter.tsx +2 -1
- package/src/features/company/components/forms/CompanyEditor.tsx +6 -3
- package/src/features/company/components/forms/CompanyLicense.tsx +4 -2
- package/src/features/company/components/lists/CompaniesList.tsx +2 -1
- package/src/features/content/components/lists/ContentsListById.tsx +2 -1
- package/src/features/content/components/lists/RelevantContentsList.tsx +2 -1
- package/src/features/notification/components/lists/NotificationsList.tsx +2 -1
- package/src/features/notification/contexts/NotificationContext.tsx +2 -1
- package/src/features/role/components/forms/RemoveUserFromRole.tsx +4 -2
- package/src/features/role/components/forms/UserRoleAdd.tsx +2 -1
- package/src/features/role/components/lists/RolesList.tsx +2 -1
- package/src/features/role/components/lists/UserRolesList.tsx +2 -1
- package/src/features/user/components/forms/RoleUserAdd.tsx +4 -2
- package/src/features/user/components/forms/UserDeleter.tsx +2 -1
- package/src/features/user/components/forms/UserEditor.tsx +6 -3
- package/src/features/user/components/forms/UserMultiSelect.tsx +2 -1
- package/src/features/user/components/forms/UserReactivator.tsx +2 -1
- package/src/features/user/components/forms/UserResentInvitationEmail.tsx +2 -1
- package/src/features/user/components/forms/UserSelector.tsx +2 -1
- package/src/features/user/components/lists/AdminUsersList.tsx +2 -1
- package/src/features/user/components/lists/CompanyUsersList.tsx +2 -1
- package/src/features/user/components/lists/RelevantUsersList.tsx +2 -1
- package/src/features/user/components/lists/RoleUsersList.tsx +2 -1
- package/src/features/user/components/lists/UsersListByContentIds.tsx +2 -1
- package/src/features/user/hooks/useUserSearch.ts +2 -1
- package/src/hooks/useDataListRetriever.ts +4 -4
- package/src/hooks/usePageTracker.ts +1 -1
- package/src/hooks/usePushNotifications.ts +3 -2
- package/src/hooks/useSocket.ts +1 -1
- package/src/index.ts +7 -2
- package/src/roles/config.ts +0 -15
- package/src/roles/index.ts +1 -9
- package/src/server/JsonApiServer.ts +249 -0
- package/src/server/cache.ts +1 -1
- package/src/server/index.ts +13 -0
- package/src/server/request.ts +32 -18
- package/src/server/token.ts +1 -1
- package/dist/AbstractService-BsY6W3Ej.d.mts +0 -109
- package/dist/AbstractService-wLid8dB0.d.ts +0 -109
- package/dist/ApiData-DPKNfY-9.d.mts +0 -10
- package/dist/ApiData-DPKNfY-9.d.ts +0 -10
- package/dist/ApiDataInterface-DPP8s46n.d.mts +0 -21
- package/dist/ApiDataInterface-DPP8s46n.d.ts +0 -21
- package/dist/AuthComponent-B_Ps2Vb9.d.ts +0 -78
- package/dist/AuthComponent-CxnGgvoh.d.mts +0 -78
- package/dist/BlockNoteEditor-AIEEQM6A.mjs.map +0 -1
- package/dist/BlockNoteEditor-G6AK2NWA.js.map +0 -1
- package/dist/JsonApiRequest-UJ7FGIVI.js +0 -25
- package/dist/JsonApiRequest-UJ7FGIVI.js.map +0 -1
- package/dist/atoms/index.d.mts +0 -12
- package/dist/atoms/index.d.ts +0 -12
- package/dist/atoms/index.js +0 -9
- package/dist/atoms/index.js.map +0 -1
- package/dist/atoms/index.mjs +0 -9
- package/dist/chunk-2K3Q24UF.js.map +0 -1
- package/dist/chunk-32HM6MDD.js +0 -98
- package/dist/chunk-32HM6MDD.js.map +0 -1
- package/dist/chunk-3FBCC4G3.js +0 -8
- package/dist/chunk-3FBCC4G3.js.map +0 -1
- package/dist/chunk-3UELCPIN.js +0 -46
- package/dist/chunk-3UELCPIN.js.map +0 -1
- package/dist/chunk-5IET37O4.js +0 -4210
- package/dist/chunk-5IET37O4.js.map +0 -1
- package/dist/chunk-AGAJMJ4T.js +0 -147
- package/dist/chunk-AGAJMJ4T.js.map +0 -1
- package/dist/chunk-AYHKQWHH.js +0 -68
- package/dist/chunk-AYHKQWHH.js.map +0 -1
- package/dist/chunk-DEYKTLA3.js +0 -1131
- package/dist/chunk-DEYKTLA3.js.map +0 -1
- package/dist/chunk-EFJEWLRL.js.map +0 -1
- package/dist/chunk-FMBQZAIP.mjs +0 -490
- package/dist/chunk-FMBQZAIP.mjs.map +0 -1
- package/dist/chunk-HAG77QBV.mjs +0 -98
- package/dist/chunk-HAG77QBV.mjs.map +0 -1
- package/dist/chunk-HR4H2FP7.mjs.map +0 -1
- package/dist/chunk-IKBA4AHN.mjs.map +0 -1
- package/dist/chunk-J7YDGYSW.mjs +0 -9332
- package/dist/chunk-J7YDGYSW.mjs.map +0 -1
- package/dist/chunk-JGFWIT2E.mjs +0 -1131
- package/dist/chunk-JGFWIT2E.mjs.map +0 -1
- package/dist/chunk-P2F54I7Q.mjs +0 -4210
- package/dist/chunk-P2F54I7Q.mjs.map +0 -1
- package/dist/chunk-PMXG5WBC.js.map +0 -1
- package/dist/chunk-Q2N6SQYW.mjs +0 -8
- package/dist/chunk-Q2N6SQYW.mjs.map +0 -1
- package/dist/chunk-Q4FXESVT.js +0 -490
- package/dist/chunk-Q4FXESVT.js.map +0 -1
- package/dist/chunk-RBIVEH2K.mjs +0 -147
- package/dist/chunk-RBIVEH2K.mjs.map +0 -1
- package/dist/chunk-SM63SZCP.mjs +0 -68
- package/dist/chunk-SM63SZCP.mjs.map +0 -1
- package/dist/chunk-SZZYEG3P.mjs +0 -46
- package/dist/chunk-SZZYEG3P.mjs.map +0 -1
- package/dist/chunk-VET55IZO.js.map +0 -1
- package/dist/chunk-YF5XQZDR.mjs.map +0 -1
- package/dist/config-BmnK65TD.d.mts +0 -35
- package/dist/config-BmnK65TD.d.ts +0 -35
- package/dist/config-DQeAo9Kf.d.mts +0 -49
- package/dist/config-DQeAo9Kf.d.ts +0 -49
- package/dist/content.fields-cHPdM8GJ.d.mts +0 -27
- package/dist/content.fields-cHPdM8GJ.d.ts +0 -27
- package/dist/d3.link.interface-ClC4Irqp.d.mts +0 -21
- package/dist/d3.link.interface-ClC4Irqp.d.ts +0 -21
- package/dist/features/index.d.mts +0 -477
- package/dist/features/index.d.ts +0 -477
- package/dist/features/index.js +0 -108
- package/dist/features/index.js.map +0 -1
- package/dist/features/index.mjs +0 -108
- package/dist/hooks/index.d.mts +0 -69
- package/dist/hooks/index.d.ts +0 -69
- package/dist/hooks/index.js +0 -55
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/index.mjs +0 -55
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/interfaces/index.d.mts +0 -4
- package/dist/interfaces/index.d.ts +0 -4
- package/dist/interfaces/index.js +0 -2
- package/dist/interfaces/index.js.map +0 -1
- package/dist/interfaces/index.mjs +0 -2
- package/dist/interfaces/index.mjs.map +0 -1
- package/dist/notification.interface-B2BrLoDA.d.mts +0 -14
- package/dist/notification.interface-DlZLnAfg.d.ts +0 -14
- package/dist/permissions/index.d.mts +0 -41
- package/dist/permissions/index.d.ts +0 -41
- package/dist/permissions/index.js +0 -14
- package/dist/permissions/index.js.map +0 -1
- package/dist/permissions/index.mjs +0 -14
- package/dist/permissions/index.mjs.map +0 -1
- package/dist/request-7FE3LJLV.mjs +0 -9
- package/dist/request-7FE3LJLV.mjs.map +0 -1
- package/dist/request-QFS7NEIE.js +0 -9
- package/dist/request-QFS7NEIE.js.map +0 -1
- package/dist/roles/index.d.mts +0 -39
- package/dist/roles/index.d.ts +0 -39
- package/dist/roles/index.js +0 -18
- package/dist/roles/index.js.map +0 -1
- package/dist/roles/index.mjs +0 -18
- package/dist/roles/index.mjs.map +0 -1
- package/dist/shadcnui/index.d.mts +0 -698
- package/dist/shadcnui/index.d.ts +0 -698
- package/dist/shadcnui/index.js +0 -468
- package/dist/shadcnui/index.js.map +0 -1
- package/dist/shadcnui/index.mjs +0 -467
- package/dist/shadcnui/index.mjs.map +0 -1
- package/dist/token-IJSPOMW6.mjs +0 -9
- package/dist/token-IJSPOMW6.mjs.map +0 -1
- package/dist/token-UYE7CV6X.js +0 -9
- package/dist/token-UYE7CV6X.js.map +0 -1
- package/dist/types-B2QRyqyK.d.ts +0 -39
- package/dist/types-CgvNmxTd.d.mts +0 -39
- package/dist/types-t2PyXhDu.d.mts +0 -116
- package/dist/types-t2PyXhDu.d.ts +0 -116
- package/dist/user.interface-CooB1R79.d.mts +0 -85
- package/dist/user.interface-KnIT9pVY.d.ts +0 -85
- package/dist/utils/index.d.mts +0 -224
- package/dist/utils/index.d.ts +0 -224
- package/dist/utils/index.js +0 -46
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/index.mjs +0 -46
- package/dist/utils/index.mjs.map +0 -1
- /package/dist/{JsonApiRequest-6UR7DIAR.mjs.map → JsonApiRequest-SYZ6FGCA.mjs.map} +0 -0
- /package/dist/{atoms/index.mjs.map → request-XABCMU25.mjs.map} +0 -0
- /package/dist/{features/index.mjs.map → token-EOK3N45S.mjs.map} +0 -0
package/dist/chunk-RBIVEH2K.mjs
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__name
|
|
3
|
-
} from "./chunk-PAWJFY3S.mjs";
|
|
4
|
-
|
|
5
|
-
// src/core/registry/DataClassRegistry.ts
|
|
6
|
-
var DataClassRegistry = class {
|
|
7
|
-
static {
|
|
8
|
-
__name(this, "DataClassRegistry");
|
|
9
|
-
}
|
|
10
|
-
static _map = /* @__PURE__ */ new Map();
|
|
11
|
-
static registerObjectClass(key, classConstructor) {
|
|
12
|
-
const classKey = key.name;
|
|
13
|
-
if (!this._map.has(classKey)) {
|
|
14
|
-
this._map.set(classKey, classConstructor);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
static get(classKey) {
|
|
18
|
-
const response = this._map.get(classKey.name);
|
|
19
|
-
if (!response) {
|
|
20
|
-
throw new Error(`Class not registered for key: ${typeof classKey === "string" ? classKey : classKey.name}`);
|
|
21
|
-
}
|
|
22
|
-
return response;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Bootstrap the registry with all modules.
|
|
26
|
-
* This is a convenience method for apps to register all their modules at once.
|
|
27
|
-
*
|
|
28
|
-
* @param modules - An object with module definitions (like the app's Modules class)
|
|
29
|
-
*/
|
|
30
|
-
static bootstrap(modules) {
|
|
31
|
-
Object.values(modules).forEach((module) => {
|
|
32
|
-
if (module && module.model) {
|
|
33
|
-
this.registerObjectClass(module, module.model);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Clear all registered classes. Useful for testing.
|
|
39
|
-
*/
|
|
40
|
-
static clear() {
|
|
41
|
-
this._map.clear();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// src/core/factories/JsonApiDataFactory.ts
|
|
46
|
-
var JsonApiDataFactory = class {
|
|
47
|
-
static {
|
|
48
|
-
__name(this, "JsonApiDataFactory");
|
|
49
|
-
}
|
|
50
|
-
static create(classKey, data) {
|
|
51
|
-
const factoryClass = DataClassRegistry.get(classKey);
|
|
52
|
-
const instance = new factoryClass();
|
|
53
|
-
return instance.createJsonApi(data);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// src/core/utils/translateResponse.ts
|
|
58
|
-
function translateData(params) {
|
|
59
|
-
const factoryClass = DataClassRegistry.get(params.classKey);
|
|
60
|
-
if (!factoryClass) {
|
|
61
|
-
throw new Error(
|
|
62
|
-
`Class not registered for key: ${typeof params.classKey === "string" ? params.classKey : params.classKey.name}`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
const included = params.data.included ?? [];
|
|
66
|
-
if (Array.isArray(params.data.data)) {
|
|
67
|
-
const responseData = [];
|
|
68
|
-
for (const data of params.data.data) {
|
|
69
|
-
const object = new factoryClass();
|
|
70
|
-
object.rehydrate({ jsonApi: data, included, allData: params.data.data });
|
|
71
|
-
responseData.push(object);
|
|
72
|
-
}
|
|
73
|
-
return responseData;
|
|
74
|
-
} else {
|
|
75
|
-
const responseData = new factoryClass();
|
|
76
|
-
responseData.rehydrate({
|
|
77
|
-
jsonApi: params.data.data,
|
|
78
|
-
included
|
|
79
|
-
});
|
|
80
|
-
return responseData;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
__name(translateData, "translateData");
|
|
84
|
-
async function translateResponse(params) {
|
|
85
|
-
const response = {
|
|
86
|
-
ok: true,
|
|
87
|
-
response: 0,
|
|
88
|
-
data: [],
|
|
89
|
-
error: ""
|
|
90
|
-
};
|
|
91
|
-
const factoryClass = DataClassRegistry.get(params.classKey);
|
|
92
|
-
if (!factoryClass) {
|
|
93
|
-
throw new Error(
|
|
94
|
-
`Class not registered for key: ${typeof params.classKey === "string" ? params.classKey : params.classKey.name}`
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
response.ok = params.apiResponse.ok;
|
|
98
|
-
response.response = params.apiResponse.status;
|
|
99
|
-
if (!params.apiResponse.ok) {
|
|
100
|
-
response.error = params.apiResponse?.data?.message ?? params.apiResponse.statusText;
|
|
101
|
-
return response;
|
|
102
|
-
}
|
|
103
|
-
if (params.apiResponse.status === 204) return response;
|
|
104
|
-
response.raw = params.apiResponse.data;
|
|
105
|
-
try {
|
|
106
|
-
const included = params.apiResponse.data.included ?? [];
|
|
107
|
-
if (params.apiResponse.data.links) {
|
|
108
|
-
response.self = params.apiResponse.data.links.self;
|
|
109
|
-
if (params.apiResponse.data.links.next && params.paginationHandler) {
|
|
110
|
-
response.next = params.apiResponse.data.links.next;
|
|
111
|
-
response.nextPage = async () => params.paginationHandler(params.apiResponse.data.links.next);
|
|
112
|
-
}
|
|
113
|
-
if (params.apiResponse.data.links.prev && params.paginationHandler) {
|
|
114
|
-
response.prev = params.apiResponse.data.links.prev;
|
|
115
|
-
response.prevPage = async () => params.paginationHandler(params.apiResponse.data.links.prev);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (Array.isArray(params.apiResponse.data.data)) {
|
|
119
|
-
const responseData = [];
|
|
120
|
-
for (const data of params.apiResponse.data.data) {
|
|
121
|
-
const object = new factoryClass();
|
|
122
|
-
object.rehydrate({ jsonApi: data, included, allData: params.apiResponse.data.data });
|
|
123
|
-
responseData.push(object);
|
|
124
|
-
}
|
|
125
|
-
response.data = responseData;
|
|
126
|
-
} else {
|
|
127
|
-
const responseData = new factoryClass();
|
|
128
|
-
responseData.rehydrate({
|
|
129
|
-
jsonApi: params.apiResponse.data.data,
|
|
130
|
-
included
|
|
131
|
-
});
|
|
132
|
-
response.data = responseData;
|
|
133
|
-
}
|
|
134
|
-
} catch (e) {
|
|
135
|
-
console.error(e);
|
|
136
|
-
}
|
|
137
|
-
return response;
|
|
138
|
-
}
|
|
139
|
-
__name(translateResponse, "translateResponse");
|
|
140
|
-
|
|
141
|
-
export {
|
|
142
|
-
DataClassRegistry,
|
|
143
|
-
JsonApiDataFactory,
|
|
144
|
-
translateData,
|
|
145
|
-
translateResponse
|
|
146
|
-
};
|
|
147
|
-
//# sourceMappingURL=chunk-RBIVEH2K.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/registry/DataClassRegistry.ts","../src/core/factories/JsonApiDataFactory.ts","../src/core/utils/translateResponse.ts"],"sourcesContent":["import { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\n\nexport class DataClassRegistry {\n private static _map = new Map<string, { new (): ApiDataInterface }>();\n\n public static registerObjectClass(\n key: ApiRequestDataTypeInterface,\n classConstructor: { new (): ApiDataInterface },\n ): void {\n const classKey = key.name;\n if (!this._map.has(classKey)) {\n this._map.set(classKey, classConstructor);\n }\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(`Class not registered for key: ${typeof classKey === \"string\" ? classKey : classKey.name}`);\n }\n\n return response;\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 return instance.createJsonApi(data);\n }\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 response.error = params.apiResponse?.data?.message ?? params.apiResponse.statusText;\n return response;\n }\n\n if (params.apiResponse.status === 204) return response;\n\n response.raw = params.apiResponse.data;\n\n try {\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"],"mappings":"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","names":[]}
|
package/dist/chunk-SM63SZCP.mjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__name
|
|
3
|
-
} from "./chunk-PAWJFY3S.mjs";
|
|
4
|
-
|
|
5
|
-
// src/i18n/config.ts
|
|
6
|
-
var _config = null;
|
|
7
|
-
function configureI18n(config) {
|
|
8
|
-
_config = config;
|
|
9
|
-
}
|
|
10
|
-
__name(configureI18n, "configureI18n");
|
|
11
|
-
function useI18nRouter() {
|
|
12
|
-
if (!_config?.useRouter) {
|
|
13
|
-
throw new Error("i18n not configured. Call configureI18n() at app startup.");
|
|
14
|
-
}
|
|
15
|
-
return _config.useRouter();
|
|
16
|
-
}
|
|
17
|
-
__name(useI18nRouter, "useI18nRouter");
|
|
18
|
-
function useI18nTranslations(namespace) {
|
|
19
|
-
if (!_config?.useTranslations) {
|
|
20
|
-
return (key) => key;
|
|
21
|
-
}
|
|
22
|
-
return _config.useTranslations(namespace);
|
|
23
|
-
}
|
|
24
|
-
__name(useI18nTranslations, "useI18nTranslations");
|
|
25
|
-
function getI18nLink() {
|
|
26
|
-
if (!_config?.Link) {
|
|
27
|
-
throw new Error("i18n not configured. Call configureI18n() at app startup.");
|
|
28
|
-
}
|
|
29
|
-
return _config.Link;
|
|
30
|
-
}
|
|
31
|
-
__name(getI18nLink, "getI18nLink");
|
|
32
|
-
function useI18nLocale() {
|
|
33
|
-
if (_config?.useLocale) {
|
|
34
|
-
return _config.useLocale();
|
|
35
|
-
}
|
|
36
|
-
return "en";
|
|
37
|
-
}
|
|
38
|
-
__name(useI18nLocale, "useI18nLocale");
|
|
39
|
-
function useI18nDateFnsLocale() {
|
|
40
|
-
if (_config?.useDateFnsLocale) {
|
|
41
|
-
return _config.useDateFnsLocale();
|
|
42
|
-
}
|
|
43
|
-
return void 0;
|
|
44
|
-
}
|
|
45
|
-
__name(useI18nDateFnsLocale, "useI18nDateFnsLocale");
|
|
46
|
-
|
|
47
|
-
// src/features/auth/config.ts
|
|
48
|
-
var _tokenHandler = null;
|
|
49
|
-
function configureAuth(handler) {
|
|
50
|
-
_tokenHandler = handler;
|
|
51
|
-
}
|
|
52
|
-
__name(configureAuth, "configureAuth");
|
|
53
|
-
function getTokenHandler() {
|
|
54
|
-
return _tokenHandler;
|
|
55
|
-
}
|
|
56
|
-
__name(getTokenHandler, "getTokenHandler");
|
|
57
|
-
|
|
58
|
-
export {
|
|
59
|
-
configureI18n,
|
|
60
|
-
useI18nRouter,
|
|
61
|
-
useI18nTranslations,
|
|
62
|
-
getI18nLink,
|
|
63
|
-
useI18nLocale,
|
|
64
|
-
useI18nDateFnsLocale,
|
|
65
|
-
configureAuth,
|
|
66
|
-
getTokenHandler
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=chunk-SM63SZCP.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/i18n/config.ts","../src/features/auth/config.ts"],"sourcesContent":["import { ComponentType } from \"react\";\n\n// Types for injected hooks\nexport interface I18nRouter {\n push: (href: string) => void;\n replace: (href: string) => void;\n back: () => void;\n forward: () => void;\n refresh: () => void;\n prefetch: (href: string) => void;\n}\n\nexport type UseRouterHook = () => I18nRouter;\nexport type UseTranslationsHook = (namespace?: string) => (key: string, values?: Record<string, any>) => string;\nexport type UseLocaleHook = () => string;\n\nexport type UseDateFnsLocaleHook = () => any; // date-fns Locale type\nexport type LinkComponent = ComponentType<{ href: string; children: React.ReactNode; [key: string]: any }>;\n\nexport interface I18nConfig {\n useRouter: UseRouterHook;\n useTranslations: UseTranslationsHook;\n useLocale?: UseLocaleHook;\n useDateFnsLocale?: UseDateFnsLocaleHook;\n Link: LinkComponent;\n usePathname: () => string;\n}\n\n// Private storage\nlet _config: I18nConfig | null = null;\n\n// Configuration function (called by app at startup)\nexport function configureI18n(config: I18nConfig): void {\n _config = config;\n}\n\n// Hooks for library components to use\nexport function useI18nRouter(): I18nRouter {\n if (!_config?.useRouter) {\n throw new Error(\"i18n not configured. Call configureI18n() at app startup.\");\n }\n return _config.useRouter();\n}\n\nexport function useI18nTranslations(namespace?: string): (key: string, values?: Record<string, any>) => string {\n if (!_config?.useTranslations) {\n // Fallback: return key as-is (safe for server/client)\n return (key: string) => key;\n }\n return _config.useTranslations(namespace);\n}\n\nexport function getI18nLink(): LinkComponent {\n if (!_config?.Link) {\n throw new Error(\"i18n not configured. Call configureI18n() at app startup.\");\n }\n return _config.Link;\n}\n\nexport function useI18nLocale(): string {\n if (_config?.useLocale) {\n return _config.useLocale();\n }\n // Fallback to English (safe for server/client)\n return \"en\";\n}\n\nexport function useI18nDateFnsLocale(): any {\n if (_config?.useDateFnsLocale) {\n return _config.useDateFnsLocale();\n }\n // Fallback to undefined (Calendar will use default)\n return undefined;\n}\n","/**\n * Token parameters for authentication cookie management\n */\nexport interface TokenParams {\n token?: string;\n refreshToken?: string;\n userId?: string;\n companyId?: string;\n licenseExpirationDate?: Date;\n roles?: string[];\n features?: string[];\n modules?: {\n id: string;\n permissions: {\n create: boolean | string;\n read: boolean | string;\n update: boolean | string;\n delete: boolean | string;\n };\n }[];\n}\n\n/**\n * Token handler interface for dependency injection\n * Apps must provide implementations of these functions via configureAuth()\n */\nexport interface TokenHandler {\n updateToken: (params: TokenParams) => Promise<void>;\n removeToken: () => Promise<void>;\n}\n\n// Private storage for the injected token handler\nlet _tokenHandler: TokenHandler | null = null;\n\n/**\n * Configure authentication token handling\n * Call this at app startup to provide Server Actions for cookie management\n *\n * @example\n * ```typescript\n * import { configureAuth } from \"@carlonicora/nextjs-jsonapi/features\";\n * import { updateToken, removeToken } from \"@/features/auth/utils/AuthCookies\";\n *\n * configureAuth({ updateToken, removeToken });\n * ```\n */\nexport function configureAuth(handler: TokenHandler): void {\n _tokenHandler = handler;\n}\n\n/**\n * Internal getter for AuthService to access the token handler\n * @internal\n */\nexport function getTokenHandler(): TokenHandler | null {\n return _tokenHandler;\n}\n"],"mappings":";;;;;AA6BA,IAAI,UAA6B;AAG1B,SAAS,cAAc,QAA0B;AACtD,YAAU;AACZ;AAFgB;AAKT,SAAS,gBAA4B;AAC1C,MAAI,CAAC,SAAS,WAAW;AACvB,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACA,SAAO,QAAQ,UAAU;AAC3B;AALgB;AAOT,SAAS,oBAAoB,WAA2E;AAC7G,MAAI,CAAC,SAAS,iBAAiB;AAE7B,WAAO,CAAC,QAAgB;AAAA,EAC1B;AACA,SAAO,QAAQ,gBAAgB,SAAS;AAC1C;AANgB;AAQT,SAAS,cAA6B;AAC3C,MAAI,CAAC,SAAS,MAAM;AAClB,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACA,SAAO,QAAQ;AACjB;AALgB;AAOT,SAAS,gBAAwB;AACtC,MAAI,SAAS,WAAW;AACtB,WAAO,QAAQ,UAAU;AAAA,EAC3B;AAEA,SAAO;AACT;AANgB;AAQT,SAAS,uBAA4B;AAC1C,MAAI,SAAS,kBAAkB;AAC7B,WAAO,QAAQ,iBAAiB;AAAA,EAClC;AAEA,SAAO;AACT;AANgB;;;ACnChB,IAAI,gBAAqC;AAclC,SAAS,cAAc,SAA6B;AACzD,kBAAgB;AAClB;AAFgB;AAQT,SAAS,kBAAuC;AACrD,SAAO;AACT;AAFgB;","names":[]}
|
package/dist/chunk-SZZYEG3P.mjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__name
|
|
3
|
-
} from "./chunk-PAWJFY3S.mjs";
|
|
4
|
-
|
|
5
|
-
// src/roles/config.ts
|
|
6
|
-
var _roleId = null;
|
|
7
|
-
var _useDiscord = false;
|
|
8
|
-
var _useInternalAuth = true;
|
|
9
|
-
function configureRoles(roleId) {
|
|
10
|
-
_roleId = roleId;
|
|
11
|
-
}
|
|
12
|
-
__name(configureRoles, "configureRoles");
|
|
13
|
-
function configureDiscord(params) {
|
|
14
|
-
_useDiscord = params.useDiscord;
|
|
15
|
-
_useInternalAuth = params.useInternalAuth;
|
|
16
|
-
}
|
|
17
|
-
__name(configureDiscord, "configureDiscord");
|
|
18
|
-
function getRoleId() {
|
|
19
|
-
if (!_roleId) {
|
|
20
|
-
throw new Error("Roles not configured. Call configureRoles() at app startup.");
|
|
21
|
-
}
|
|
22
|
-
return _roleId;
|
|
23
|
-
}
|
|
24
|
-
__name(getRoleId, "getRoleId");
|
|
25
|
-
function isRolesConfigured() {
|
|
26
|
-
return _roleId !== null;
|
|
27
|
-
}
|
|
28
|
-
__name(isRolesConfigured, "isRolesConfigured");
|
|
29
|
-
function isDiscordConfigured() {
|
|
30
|
-
return _useDiscord;
|
|
31
|
-
}
|
|
32
|
-
__name(isDiscordConfigured, "isDiscordConfigured");
|
|
33
|
-
function isInternalAuthConfigured() {
|
|
34
|
-
return _useInternalAuth;
|
|
35
|
-
}
|
|
36
|
-
__name(isInternalAuthConfigured, "isInternalAuthConfigured");
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
configureRoles,
|
|
40
|
-
configureDiscord,
|
|
41
|
-
getRoleId,
|
|
42
|
-
isRolesConfigured,
|
|
43
|
-
isDiscordConfigured,
|
|
44
|
-
isInternalAuthConfigured
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=chunk-SZZYEG3P.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/roles/config.ts"],"sourcesContent":["/**\n * Role ID configuration interface\n * Apps provide their role IDs via configureRoles()\n */\nexport interface RoleIdConfig {\n Administrator: string;\n CompanyAdministrator: string;\n [key: string]: string; // Allow additional roles\n}\n\n// Private storage for the injected role IDs\nlet _roleId: RoleIdConfig | null = null;\nlet _useDiscord: boolean = false;\nlet _useInternalAuth: boolean = true;\n\n/**\n * Configure role IDs for the library\n * Call this at app startup to provide role ID constants\n *\n * @example\n * ```typescript\n * import { configureRoles } from \"@carlonicora/nextjs-jsonapi\";\n * import { RoleId } from \"@phlow/shared\";\n *\n * configureRoles(RoleId);\n * ```\n */\nexport function configureRoles(roleId: RoleIdConfig): void {\n _roleId = roleId;\n}\n\nexport function configureDiscord(params: { useDiscord: boolean; useInternalAuth: boolean }): void {\n _useDiscord = params.useDiscord;\n _useInternalAuth = params.useInternalAuth;\n}\n\n/**\n * Get configured role IDs\n * @throws Error if roles not configured\n */\nexport function getRoleId(): RoleIdConfig {\n if (!_roleId) {\n throw new Error(\"Roles not configured. Call configureRoles() at app startup.\");\n }\n return _roleId;\n}\n\n/**\n * Check if roles have been configured\n */\nexport function isRolesConfigured(): boolean {\n return _roleId !== null;\n}\n\nexport function isDiscordConfigured(): boolean {\n return _useDiscord;\n}\n\nexport function isInternalAuthConfigured(): boolean {\n return _useInternalAuth;\n}\n"],"mappings":";;;;;AAWA,IAAI,UAA+B;AACnC,IAAI,cAAuB;AAC3B,IAAI,mBAA4B;AAczB,SAAS,eAAe,QAA4B;AACzD,YAAU;AACZ;AAFgB;AAIT,SAAS,iBAAiB,QAAiE;AAChG,gBAAc,OAAO;AACrB,qBAAmB,OAAO;AAC5B;AAHgB;AAST,SAAS,YAA0B;AACxC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,6DAA6D;AAAA,EAC/E;AACA,SAAO;AACT;AALgB;AAUT,SAAS,oBAA6B;AAC3C,SAAO,YAAY;AACrB;AAFgB;AAIT,SAAS,sBAA+B;AAC7C,SAAO;AACT;AAFgB;AAIT,SAAS,2BAAoC;AAClD,SAAO;AACT;AAFgB;","names":[]}
|