@carlonicora/nextjs-jsonapi 1.0.3 → 1.0.4

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 (261) hide show
  1. package/package.json +2 -1
  2. package/src/atoms/index.ts +1 -0
  3. package/src/atoms/recentPagesAtom.ts +10 -0
  4. package/src/client/context/JsonApiContext.ts +61 -0
  5. package/src/client/context/JsonApiProvider.tsx +27 -0
  6. package/src/client/context/index.ts +2 -0
  7. package/src/client/hooks/index.ts +3 -0
  8. package/src/client/hooks/useJsonApiGet.ts +188 -0
  9. package/src/client/hooks/useJsonApiMutation.ts +193 -0
  10. package/src/client/hooks/useRehydration.ts +47 -0
  11. package/src/client/index.ts +11 -0
  12. package/src/client/request.ts +97 -0
  13. package/src/client/token.ts +10 -0
  14. package/src/components/containers/PageContainer.tsx +15 -0
  15. package/src/components/containers/ReactMarkdownContainer.tsx +119 -0
  16. package/src/components/containers/TabsContainer.tsx +93 -0
  17. package/src/components/containers/index.ts +3 -0
  18. package/src/components/contents/AttributeElement.tsx +20 -0
  19. package/src/components/contents/index.ts +1 -0
  20. package/src/components/details/AllowedUsersDetails.tsx +23 -0
  21. package/src/components/details/index.ts +1 -0
  22. package/src/components/editors/BlockNoteDiffInlineContent.tsx +152 -0
  23. package/src/components/editors/BlockNoteEditor.tsx +404 -0
  24. package/src/components/editors/BlockNoteEditorContainer.tsx +13 -0
  25. package/src/components/editors/BlockNoteEditorFormattingToolbar.tsx +38 -0
  26. package/src/components/editors/index.ts +1 -0
  27. package/src/components/errors/ErrorDetails.tsx +41 -0
  28. package/src/components/errors/errorToast.ts +9 -0
  29. package/src/components/errors/index.ts +2 -0
  30. package/src/components/forms/CommonAssociationForm.tsx +162 -0
  31. package/src/components/forms/CommonDeleter.tsx +94 -0
  32. package/src/components/forms/CommonEditorButtons.tsx +30 -0
  33. package/src/components/forms/CommonEditorHeader.tsx +35 -0
  34. package/src/components/forms/CommonEditorTrigger.tsx +26 -0
  35. package/src/components/forms/DatePickerPopover.tsx +219 -0
  36. package/src/components/forms/DateRangeSelector.tsx +110 -0
  37. package/src/components/forms/FileUploader.tsx +324 -0
  38. package/src/components/forms/FormCheckbox.tsx +66 -0
  39. package/src/components/forms/FormContainerGeneric.tsx +39 -0
  40. package/src/components/forms/FormDate.tsx +247 -0
  41. package/src/components/forms/FormDateTime.tsx +231 -0
  42. package/src/components/forms/FormInput.tsx +110 -0
  43. package/src/components/forms/FormPassword.tsx +54 -0
  44. package/src/components/forms/FormPlaceAutocomplete.tsx +286 -0
  45. package/src/components/forms/FormSelect.tsx +72 -0
  46. package/src/components/forms/FormSlider.tsx +51 -0
  47. package/src/components/forms/FormSwitch.tsx +25 -0
  48. package/src/components/forms/FormTextarea.tsx +44 -0
  49. package/src/components/forms/MultiFileUploader.tsx +107 -0
  50. package/src/components/forms/PasswordInput.tsx +47 -0
  51. package/src/components/forms/index.ts +21 -0
  52. package/src/components/index.ts +11 -0
  53. package/src/components/navigations/Breadcrumb.tsx +83 -0
  54. package/src/components/navigations/ContentTitle.tsx +39 -0
  55. package/src/components/navigations/Header.tsx +27 -0
  56. package/src/components/navigations/ModeToggleSwitch.tsx +25 -0
  57. package/src/components/navigations/PageSection.tsx +64 -0
  58. package/src/components/navigations/RecentPagesNavigator.tsx +52 -0
  59. package/src/components/navigations/index.ts +6 -0
  60. package/src/components/pages/PageContainerContentDetails.tsx +76 -0
  61. package/src/components/pages/PageContentContainer.tsx +31 -0
  62. package/src/components/pages/index.ts +2 -0
  63. package/src/components/tables/ContentListTable.tsx +165 -0
  64. package/src/components/tables/ContentTableSearch.tsx +105 -0
  65. package/src/components/tables/cells/cell.component.tsx +18 -0
  66. package/src/components/tables/cells/cell.date.tsx +16 -0
  67. package/src/components/tables/cells/cell.id.tsx +27 -0
  68. package/src/components/tables/cells/cell.link.tsx +18 -0
  69. package/src/components/tables/cells/cell.text.tsx +12 -0
  70. package/src/components/tables/cells/cell.url.tsx +13 -0
  71. package/src/components/tables/cells/index.ts +5 -0
  72. package/src/components/tables/index.ts +3 -0
  73. package/src/contexts/SharedContext.tsx +35 -0
  74. package/src/contexts/index.ts +2 -0
  75. package/src/core/abstracts/AbstractApiData.ts +138 -0
  76. package/src/core/abstracts/AbstractService.ts +263 -0
  77. package/src/core/abstracts/index.ts +2 -0
  78. package/src/core/endpoint/EndpointCreator.ts +97 -0
  79. package/src/core/endpoint/index.ts +1 -0
  80. package/src/core/factories/JsonApiDataFactory.ts +12 -0
  81. package/src/core/factories/RehydrationFactory.ts +30 -0
  82. package/src/core/factories/index.ts +2 -0
  83. package/src/core/fields/FieldSelector.ts +15 -0
  84. package/src/core/fields/index.ts +1 -0
  85. package/src/core/index.ts +20 -0
  86. package/src/core/interfaces/ApiData.ts +8 -0
  87. package/src/core/interfaces/ApiDataInterface.ts +15 -0
  88. package/src/core/interfaces/ApiRequestDataTypeInterface.ts +14 -0
  89. package/src/core/interfaces/ApiResponseInterface.ts +17 -0
  90. package/src/core/interfaces/JsonApiHydratedDataInterface.ts +5 -0
  91. package/src/core/interfaces/index.ts +5 -0
  92. package/src/core/registry/DataClassRegistry.ts +51 -0
  93. package/src/core/registry/ModuleRegistrar.ts +43 -0
  94. package/src/core/registry/ModuleRegistry.ts +64 -0
  95. package/src/core/registry/index.ts +3 -0
  96. package/src/core/utils/index.ts +2 -0
  97. package/src/core/utils/rehydrate.ts +24 -0
  98. package/src/core/utils/translateResponse.ts +125 -0
  99. package/src/features/auth/auth.module.ts +9 -0
  100. package/src/features/auth/config.ts +57 -0
  101. package/src/features/auth/data/auth.interface.ts +31 -0
  102. package/src/features/auth/data/auth.service.ts +159 -0
  103. package/src/features/auth/data/auth.ts +54 -0
  104. package/src/features/auth/data/index.ts +3 -0
  105. package/src/features/auth/index.ts +3 -0
  106. package/src/features/company/company.module.ts +10 -0
  107. package/src/features/company/data/company.fields.ts +6 -0
  108. package/src/features/company/data/company.interface.ts +28 -0
  109. package/src/features/company/data/company.service.ts +73 -0
  110. package/src/features/company/data/company.ts +104 -0
  111. package/src/features/company/data/index.ts +4 -0
  112. package/src/features/company/index.ts +2 -0
  113. package/src/features/content/content.module.ts +20 -0
  114. package/src/features/content/data/content.fields.ts +13 -0
  115. package/src/features/content/data/content.interface.ts +23 -0
  116. package/src/features/content/data/content.service.ts +75 -0
  117. package/src/features/content/data/content.ts +85 -0
  118. package/src/features/content/data/index.ts +4 -0
  119. package/src/features/content/index.ts +2 -0
  120. package/src/features/feature/components/forms/FormFeatures.tsx +149 -0
  121. package/src/features/feature/components/index.ts +1 -0
  122. package/src/features/feature/data/feature.interface.ts +9 -0
  123. package/src/features/feature/data/feature.service.ts +19 -0
  124. package/src/features/feature/data/feature.ts +33 -0
  125. package/src/features/feature/data/index.ts +3 -0
  126. package/src/features/feature/feature.module.ts +10 -0
  127. package/src/features/feature/index.ts +3 -0
  128. package/src/features/index.ts +12 -0
  129. package/src/features/module/data/index.ts +2 -0
  130. package/src/features/module/data/module.interface.ts +12 -0
  131. package/src/features/module/data/module.ts +42 -0
  132. package/src/features/module/index.ts +2 -0
  133. package/src/features/module/module.module.ts +10 -0
  134. package/src/features/notification/data/index.ts +4 -0
  135. package/src/features/notification/data/notification.fields.ts +8 -0
  136. package/src/features/notification/data/notification.interface.ts +14 -0
  137. package/src/features/notification/data/notification.service.ts +34 -0
  138. package/src/features/notification/data/notification.ts +51 -0
  139. package/src/features/notification/index.ts +2 -0
  140. package/src/features/notification/notification.module.ts +10 -0
  141. package/src/features/push/data/index.ts +3 -0
  142. package/src/features/push/data/push.interface.ts +8 -0
  143. package/src/features/push/data/push.service.ts +17 -0
  144. package/src/features/push/data/push.ts +18 -0
  145. package/src/features/push/index.ts +2 -0
  146. package/src/features/push/push.module.ts +10 -0
  147. package/src/features/role/data/index.ts +4 -0
  148. package/src/features/role/data/role.fields.ts +8 -0
  149. package/src/features/role/data/role.interface.ts +16 -0
  150. package/src/features/role/data/role.service.ts +117 -0
  151. package/src/features/role/data/role.ts +62 -0
  152. package/src/features/role/index.ts +2 -0
  153. package/src/features/role/role.module.ts +10 -0
  154. package/src/features/s3/data/index.ts +3 -0
  155. package/src/features/s3/data/s3.interface.ts +11 -0
  156. package/src/features/s3/data/s3.service.ts +30 -0
  157. package/src/features/s3/data/s3.ts +60 -0
  158. package/src/features/s3/index.ts +2 -0
  159. package/src/features/s3/s3.module.ts +10 -0
  160. package/src/features/search/index.ts +1 -0
  161. package/src/features/search/interfaces/index.ts +1 -0
  162. package/src/features/search/interfaces/search.result.interface.ts +3 -0
  163. package/src/features/user/author.module.ts +10 -0
  164. package/src/features/user/components/index.ts +2 -0
  165. package/src/features/user/components/lists/ContributorsList.tsx +41 -0
  166. package/src/features/user/components/lists/index.ts +1 -0
  167. package/src/features/user/components/widgets/UserAvatar.tsx +86 -0
  168. package/src/features/user/components/widgets/index.ts +1 -0
  169. package/src/features/user/contexts/CurrentUserContext.tsx +156 -0
  170. package/src/features/user/contexts/index.ts +1 -0
  171. package/src/features/user/data/index.ts +4 -0
  172. package/src/features/user/data/user.fields.ts +8 -0
  173. package/src/features/user/data/user.interface.ts +41 -0
  174. package/src/features/user/data/user.service.ts +246 -0
  175. package/src/features/user/data/user.ts +162 -0
  176. package/src/features/user/index.ts +4 -0
  177. package/src/features/user/user.module.ts +21 -0
  178. package/src/hooks/TableGeneratorRegistry.ts +53 -0
  179. package/src/hooks/index.ts +33 -0
  180. package/src/hooks/types.ts +35 -0
  181. package/src/hooks/url.rewriter.ts +22 -0
  182. package/src/hooks/useCustomD3Graph.tsx +705 -0
  183. package/src/hooks/useDataListRetriever.ts +349 -0
  184. package/src/hooks/useDebounce.ts +33 -0
  185. package/src/hooks/usePageUrlGenerator.ts +50 -0
  186. package/src/hooks/useTableGenerator.ts +16 -0
  187. package/src/i18n/config.ts +73 -0
  188. package/src/i18n/index.ts +18 -0
  189. package/src/index.ts +16 -0
  190. package/src/interfaces/breadcrumb.item.data.interface.ts +4 -0
  191. package/src/interfaces/d3.link.interface.ts +7 -0
  192. package/src/interfaces/d3.node.interface.ts +12 -0
  193. package/src/interfaces/index.ts +3 -0
  194. package/src/permissions/check.ts +127 -0
  195. package/src/permissions/index.ts +2 -0
  196. package/src/permissions/types.ts +109 -0
  197. package/src/roles/config.ts +46 -0
  198. package/src/roles/index.ts +1 -0
  199. package/src/server/cache.ts +28 -0
  200. package/src/server/index.ts +3 -0
  201. package/src/server/request.ts +113 -0
  202. package/src/server/token.ts +10 -0
  203. package/src/shadcnui/custom/kanban.tsx +1001 -0
  204. package/src/shadcnui/custom/link.tsx +18 -0
  205. package/src/shadcnui/custom/multi-select.tsx +382 -0
  206. package/src/shadcnui/index.ts +49 -0
  207. package/src/shadcnui/ui/accordion.tsx +52 -0
  208. package/src/shadcnui/ui/alert-dialog.tsx +141 -0
  209. package/src/shadcnui/ui/alert.tsx +43 -0
  210. package/src/shadcnui/ui/avatar.tsx +50 -0
  211. package/src/shadcnui/ui/badge.tsx +40 -0
  212. package/src/shadcnui/ui/breadcrumb.tsx +115 -0
  213. package/src/shadcnui/ui/button.tsx +51 -0
  214. package/src/shadcnui/ui/calendar.tsx +73 -0
  215. package/src/shadcnui/ui/card.tsx +43 -0
  216. package/src/shadcnui/ui/carousel.tsx +225 -0
  217. package/src/shadcnui/ui/chart.tsx +320 -0
  218. package/src/shadcnui/ui/checkbox.tsx +29 -0
  219. package/src/shadcnui/ui/collapsible.tsx +11 -0
  220. package/src/shadcnui/ui/command.tsx +155 -0
  221. package/src/shadcnui/ui/context-menu.tsx +179 -0
  222. package/src/shadcnui/ui/dialog.tsx +96 -0
  223. package/src/shadcnui/ui/drawer.tsx +89 -0
  224. package/src/shadcnui/ui/dropdown-menu.tsx +205 -0
  225. package/src/shadcnui/ui/form.tsx +138 -0
  226. package/src/shadcnui/ui/hover-card.tsx +29 -0
  227. package/src/shadcnui/ui/input.tsx +21 -0
  228. package/src/shadcnui/ui/label.tsx +26 -0
  229. package/src/shadcnui/ui/navigation-menu.tsx +168 -0
  230. package/src/shadcnui/ui/popover.tsx +33 -0
  231. package/src/shadcnui/ui/progress.tsx +25 -0
  232. package/src/shadcnui/ui/radio-group.tsx +37 -0
  233. package/src/shadcnui/ui/resizable.tsx +47 -0
  234. package/src/shadcnui/ui/scroll-area.tsx +40 -0
  235. package/src/shadcnui/ui/select.tsx +164 -0
  236. package/src/shadcnui/ui/separator.tsx +28 -0
  237. package/src/shadcnui/ui/sheet.tsx +139 -0
  238. package/src/shadcnui/ui/sidebar.tsx +677 -0
  239. package/src/shadcnui/ui/skeleton.tsx +13 -0
  240. package/src/shadcnui/ui/slider.tsx +25 -0
  241. package/src/shadcnui/ui/sonner.tsx +25 -0
  242. package/src/shadcnui/ui/switch.tsx +31 -0
  243. package/src/shadcnui/ui/table.tsx +120 -0
  244. package/src/shadcnui/ui/tabs.tsx +55 -0
  245. package/src/shadcnui/ui/textarea.tsx +24 -0
  246. package/src/shadcnui/ui/toggle.tsx +39 -0
  247. package/src/shadcnui/ui/tooltip.tsx +61 -0
  248. package/src/unified/JsonApiRequest.ts +325 -0
  249. package/src/unified/index.ts +1 -0
  250. package/src/utils/blocknote-diff.util.ts +815 -0
  251. package/src/utils/blocknote-word-diff-renderer.util.ts +413 -0
  252. package/src/utils/cn.ts +6 -0
  253. package/src/utils/compose-refs.ts +61 -0
  254. package/src/utils/date-formatter.ts +53 -0
  255. package/src/utils/exists.ts +7 -0
  256. package/src/utils/index.ts +15 -0
  257. package/src/utils/schemas/entity.object.schema.ts +8 -0
  258. package/src/utils/schemas/index.ts +2 -0
  259. package/src/utils/schemas/user.object.schema.ts +9 -0
  260. package/src/utils/table-options.ts +67 -0
  261. package/src/utils/use-mobile.tsx +21 -0
@@ -0,0 +1,325 @@
1
+ import { ApiData } from "../core/interfaces/ApiData";
2
+ import { ApiRequestDataTypeInterface } from "../core/interfaces/ApiRequestDataTypeInterface";
3
+ import { ApiResponseInterface } from "../core/interfaces/ApiResponseInterface";
4
+ import { JsonApiDataFactory } from "../core/factories/JsonApiDataFactory";
5
+ import { translateResponse } from "../core/utils/translateResponse";
6
+
7
+ // Type definitions for dynamically imported functions (avoiding typeof import to prevent bundling)
8
+ type DirectFetchFn = (params: {
9
+ method: string;
10
+ url: string;
11
+ token?: string;
12
+ body?: any;
13
+ files?: { [key: string]: File | Blob } | File | Blob;
14
+ companyId?: string;
15
+ language: string;
16
+ additionalHeaders?: Record<string, string>;
17
+ }) => Promise<ApiData>;
18
+
19
+ type ServerRequestFn = (params: {
20
+ method: string;
21
+ url: string;
22
+ token?: string;
23
+ cache?: string;
24
+ body?: any;
25
+ files?: { [key: string]: File | Blob } | File | Blob;
26
+ companyId?: string;
27
+ language: string;
28
+ additionalHeaders?: Record<string, string>;
29
+ }) => Promise<ApiData>;
30
+
31
+ type GetTokenFn = () => Promise<string | undefined>;
32
+
33
+ // These will be dynamically imported based on environment
34
+ let _directFetch: DirectFetchFn;
35
+ let _serverRequest: ServerRequestFn;
36
+ let _getClientToken: GetTokenFn;
37
+ let _getServerToken: GetTokenFn;
38
+
39
+ // Config storage for non-React contexts
40
+ let _staticConfig: {
41
+ apiUrl: string;
42
+ bootstrapper?: () => void;
43
+ additionalHeaders?: Record<string, string>;
44
+ } | null = null;
45
+
46
+ /**
47
+ * Configure the JSON:API client for non-React contexts (e.g., server components).
48
+ * For React contexts, use JsonApiProvider instead.
49
+ */
50
+ export function configureJsonApi(config: {
51
+ apiUrl: string;
52
+ bootstrapper?: () => void;
53
+ additionalHeaders?: Record<string, string>;
54
+ }): void {
55
+ _staticConfig = config;
56
+ // Call bootstrapper immediately to register all modules
57
+ if (config.bootstrapper) {
58
+ config.bootstrapper();
59
+ }
60
+ }
61
+
62
+ async function getToken(): Promise<string | undefined> {
63
+ if (typeof window === "undefined") {
64
+ // Server-side
65
+ if (!_getServerToken) {
66
+ const serverModule = await import("../server/token");
67
+ _getServerToken = serverModule.getServerToken;
68
+ }
69
+ return _getServerToken();
70
+ } else {
71
+ // Client-side
72
+ if (!_getClientToken) {
73
+ const clientModule = await import("../client/token");
74
+ _getClientToken = clientModule.getClientToken;
75
+ }
76
+ return _getClientToken();
77
+ }
78
+ }
79
+
80
+ async function makeRequest(params: {
81
+ method: string;
82
+ url: string;
83
+ token?: string;
84
+ cache?: string;
85
+ body?: any;
86
+ files?: { [key: string]: File | Blob } | File | Blob;
87
+ companyId?: string;
88
+ language: string;
89
+ additionalHeaders?: Record<string, string>;
90
+ }): Promise<ApiData> {
91
+ if (typeof window !== "undefined") {
92
+ // Client-side: use direct fetch
93
+ if (!_directFetch) {
94
+ const clientModule = await import("../client/request");
95
+ _directFetch = clientModule.directFetch;
96
+ }
97
+ return _directFetch({
98
+ method: params.method,
99
+ url: params.url,
100
+ token: params.token,
101
+ body: params.body,
102
+ files: params.files,
103
+ companyId: params.companyId,
104
+ language: params.language,
105
+ additionalHeaders: params.additionalHeaders,
106
+ });
107
+ } else {
108
+ // Server-side: use server request with caching
109
+ if (!_serverRequest) {
110
+ const serverModule = await import("../server/request");
111
+ _serverRequest = serverModule.serverRequest;
112
+ }
113
+ return _serverRequest({
114
+ method: params.method,
115
+ url: params.url,
116
+ token: params.token,
117
+ cache: params.cache,
118
+ body: params.body,
119
+ files: params.files,
120
+ companyId: params.companyId,
121
+ language: params.language,
122
+ additionalHeaders: params.additionalHeaders,
123
+ });
124
+ }
125
+ }
126
+
127
+ function getApiUrl(): string {
128
+ if (_staticConfig?.apiUrl) {
129
+ return _staticConfig.apiUrl;
130
+ }
131
+ // Fallback to environment variable
132
+ const envUrl = process.env.NEXT_PUBLIC_API_URL;
133
+ if (!envUrl) {
134
+ throw new Error("API URL not configured. Use configureJsonApi() or set NEXT_PUBLIC_API_URL environment variable.");
135
+ }
136
+ return envUrl;
137
+ }
138
+
139
+ function runBootstrapper(): void {
140
+ if (_staticConfig?.bootstrapper) {
141
+ _staticConfig.bootstrapper();
142
+ }
143
+ }
144
+
145
+ function buildUrl(endpoint: string): string {
146
+ const apiUrl = getApiUrl();
147
+ return endpoint.startsWith("http") ? endpoint : `${apiUrl}${endpoint}`;
148
+ }
149
+
150
+ export async function JsonApiGet(params: {
151
+ classKey: ApiRequestDataTypeInterface;
152
+ endpoint: string;
153
+ companyId?: string;
154
+ language: string;
155
+ }): Promise<ApiResponseInterface> {
156
+ runBootstrapper();
157
+ const token = await getToken();
158
+
159
+ const apiResponse = await makeRequest({
160
+ method: "GET",
161
+ url: buildUrl(params.endpoint),
162
+ token,
163
+ cache: params.classKey.cache,
164
+ companyId: params.companyId,
165
+ language: params.language,
166
+ additionalHeaders: _staticConfig?.additionalHeaders,
167
+ });
168
+
169
+ return translateResponse({
170
+ classKey: params.classKey,
171
+ apiResponse,
172
+ companyId: params.companyId,
173
+ language: params.language,
174
+ paginationHandler: async (endpoint: string) =>
175
+ JsonApiGet({
176
+ classKey: params.classKey,
177
+ endpoint,
178
+ companyId: params.companyId,
179
+ language: params.language,
180
+ }),
181
+ });
182
+ }
183
+
184
+ export async function JsonApiPost(params: {
185
+ classKey: ApiRequestDataTypeInterface;
186
+ endpoint: string;
187
+ companyId?: string;
188
+ body?: any;
189
+ overridesJsonApiCreation?: boolean;
190
+ files?: { [key: string]: File | Blob } | File | Blob;
191
+ language: string;
192
+ responseType?: ApiRequestDataTypeInterface;
193
+ }): Promise<ApiResponseInterface> {
194
+ runBootstrapper();
195
+ const token = await getToken();
196
+
197
+ let body = params.body;
198
+ if (!body) {
199
+ body = {};
200
+ } else if (params.overridesJsonApiCreation !== true) {
201
+ body = JsonApiDataFactory.create(params.classKey, body);
202
+ }
203
+
204
+ const apiResponse = await makeRequest({
205
+ method: "POST",
206
+ url: buildUrl(params.endpoint),
207
+ token,
208
+ body,
209
+ files: params.files,
210
+ companyId: params.companyId,
211
+ language: params.language,
212
+ additionalHeaders: _staticConfig?.additionalHeaders,
213
+ });
214
+
215
+ return translateResponse({
216
+ classKey: params.responseType ?? params.classKey,
217
+ apiResponse,
218
+ companyId: params.companyId,
219
+ language: params.language,
220
+ });
221
+ }
222
+
223
+ export async function JsonApiPut(params: {
224
+ classKey: ApiRequestDataTypeInterface;
225
+ endpoint: string;
226
+ companyId?: string;
227
+ body?: any;
228
+ files?: { [key: string]: File | Blob } | File | Blob;
229
+ language: string;
230
+ responseType?: ApiRequestDataTypeInterface;
231
+ }): Promise<ApiResponseInterface> {
232
+ runBootstrapper();
233
+ const token = await getToken();
234
+
235
+ let body = params.body;
236
+ if (!body) {
237
+ body = {};
238
+ } else {
239
+ body = JsonApiDataFactory.create(params.classKey, body);
240
+ }
241
+
242
+ const apiResponse = await makeRequest({
243
+ method: "PUT",
244
+ url: buildUrl(params.endpoint),
245
+ token,
246
+ body,
247
+ files: params.files,
248
+ companyId: params.companyId,
249
+ language: params.language,
250
+ additionalHeaders: _staticConfig?.additionalHeaders,
251
+ });
252
+
253
+ return translateResponse({
254
+ classKey: params.responseType ?? params.classKey,
255
+ apiResponse,
256
+ companyId: params.companyId,
257
+ language: params.language,
258
+ });
259
+ }
260
+
261
+ export async function JsonApiPatch(params: {
262
+ classKey: ApiRequestDataTypeInterface;
263
+ endpoint: string;
264
+ companyId?: string;
265
+ body?: any;
266
+ files?: { [key: string]: File | Blob } | File | Blob;
267
+ overridesJsonApiCreation?: boolean;
268
+ responseType?: ApiRequestDataTypeInterface;
269
+ language: string;
270
+ }): Promise<ApiResponseInterface> {
271
+ runBootstrapper();
272
+ const token = await getToken();
273
+
274
+ let body = params.body;
275
+ if (!body) {
276
+ body = {};
277
+ } else if (params.overridesJsonApiCreation !== true) {
278
+ body = JsonApiDataFactory.create(params.classKey, body);
279
+ }
280
+
281
+ const apiResponse = await makeRequest({
282
+ method: "PATCH",
283
+ url: buildUrl(params.endpoint),
284
+ token,
285
+ body,
286
+ files: params.files,
287
+ companyId: params.companyId,
288
+ language: params.language,
289
+ additionalHeaders: _staticConfig?.additionalHeaders,
290
+ });
291
+
292
+ return translateResponse({
293
+ classKey: params.responseType ?? params.classKey,
294
+ apiResponse,
295
+ companyId: params.companyId,
296
+ language: params.language,
297
+ });
298
+ }
299
+
300
+ export async function JsonApiDelete(params: {
301
+ classKey: ApiRequestDataTypeInterface;
302
+ endpoint: string;
303
+ companyId?: string;
304
+ language: string;
305
+ responseType?: ApiRequestDataTypeInterface;
306
+ }): Promise<ApiResponseInterface> {
307
+ runBootstrapper();
308
+ const token = await getToken();
309
+
310
+ const apiResponse = await makeRequest({
311
+ method: "DELETE",
312
+ url: buildUrl(params.endpoint),
313
+ token,
314
+ companyId: params.companyId,
315
+ language: params.language,
316
+ additionalHeaders: _staticConfig?.additionalHeaders,
317
+ });
318
+
319
+ return translateResponse({
320
+ classKey: params.responseType ?? params.classKey,
321
+ apiResponse,
322
+ companyId: params.companyId,
323
+ language: params.language,
324
+ });
325
+ }
@@ -0,0 +1 @@
1
+ export * from "./JsonApiRequest";