@carlonicora/nextjs-jsonapi 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/AbstractApiData-DtitRWPz.d.ts +47 -0
  2. package/dist/AbstractApiData-XLhBP5Tl.d.mts +47 -0
  3. package/dist/{BlockNoteEditor-3IZ7PMFM.js → BlockNoteEditor-4KBDD2TM.js} +20 -20
  4. package/dist/{BlockNoteEditor-3IZ7PMFM.js.map → BlockNoteEditor-4KBDD2TM.js.map} +1 -1
  5. package/dist/{BlockNoteEditor-G4XNDV2O.mjs → BlockNoteEditor-LJ2KA44Z.mjs} +5 -5
  6. package/dist/{JsonApiRequest-3UWVIIFL.mjs → JsonApiRequest-2OQCZAK6.mjs} +2 -2
  7. package/dist/JsonApiRequest-6TYNBVUL.js +26 -0
  8. package/dist/{JsonApiRequest-QRU3IPIU.js.map → JsonApiRequest-6TYNBVUL.js.map} +1 -1
  9. package/dist/ai-connection.module-28f-hux0.d.mts +255 -0
  10. package/dist/ai-connection.module-Bqwh_DnR.d.ts +255 -0
  11. package/dist/billing/index.js +399 -399
  12. package/dist/billing/index.mjs +4 -4
  13. package/dist/{chunk-TWXKAY34.mjs → chunk-CGJW7ZZM.mjs} +310 -5
  14. package/dist/chunk-CGJW7ZZM.mjs.map +1 -0
  15. package/dist/{chunk-E5YA5Z5X.mjs → chunk-CMGXH5SA.mjs} +2 -1
  16. package/dist/chunk-CMGXH5SA.mjs.map +1 -0
  17. package/dist/{chunk-JKGEJGSD.js → chunk-H7DOSB7W.js} +9 -9
  18. package/dist/{chunk-JKGEJGSD.js.map → chunk-H7DOSB7W.js.map} +1 -1
  19. package/dist/{chunk-FPO4DLZN.js → chunk-PFAZPP54.js} +2 -1
  20. package/dist/chunk-PFAZPP54.js.map +1 -0
  21. package/dist/{chunk-5GVBUTS4.js → chunk-UYOQG5IW.js} +1453 -793
  22. package/dist/chunk-UYOQG5IW.js.map +1 -0
  23. package/dist/{chunk-WCX4CLRJ.mjs → chunk-WCRZEBX4.mjs} +1739 -1079
  24. package/dist/chunk-WCRZEBX4.mjs.map +1 -0
  25. package/dist/{chunk-53B6NPGA.js → chunk-YUXCJ35V.js} +377 -72
  26. package/dist/chunk-YUXCJ35V.js.map +1 -0
  27. package/dist/{chunk-PHEFWL6L.mjs → chunk-ZMYZFQN3.mjs} +3 -3
  28. package/dist/client/index.js +5 -5
  29. package/dist/client/index.mjs +4 -4
  30. package/dist/components/index.d.mts +122 -4
  31. package/dist/components/index.d.ts +122 -4
  32. package/dist/components/index.js +31 -5
  33. package/dist/components/index.js.map +1 -1
  34. package/dist/components/index.mjs +30 -4
  35. package/dist/{config-BIjrg5wd.d.ts → config-B6UB7j69.d.ts} +1 -46
  36. package/dist/{config-BRUjtCd1.d.mts → config-n-ZpPmOL.d.mts} +1 -46
  37. package/dist/contexts/index.js +5 -5
  38. package/dist/contexts/index.mjs +4 -4
  39. package/dist/core/index.d.mts +5 -4
  40. package/dist/core/index.d.ts +5 -4
  41. package/dist/core/index.js +11 -3
  42. package/dist/core/index.js.map +1 -1
  43. package/dist/core/index.mjs +10 -2
  44. package/dist/features/help/index.js +38 -38
  45. package/dist/features/help/index.mjs +4 -4
  46. package/dist/features/tokenusage/index.d.mts +2 -2
  47. package/dist/features/tokenusage/index.d.ts +2 -2
  48. package/dist/features/tokenusage/index.js +102 -102
  49. package/dist/features/tokenusage/index.mjs +4 -4
  50. package/dist/index.d.mts +3 -3
  51. package/dist/index.d.ts +3 -3
  52. package/dist/index.js +12 -4
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +11 -3
  55. package/dist/server/index.js +12 -12
  56. package/dist/server/index.mjs +2 -2
  57. package/package.json +1 -1
  58. package/src/components/index.ts +1 -0
  59. package/src/core/index.ts +5 -0
  60. package/src/core/registry/ModuleRegistry.ts +2 -0
  61. package/src/core/utils/translateResponse.ts +6 -0
  62. package/src/features/administration/components/AdminIndexContainer.tsx +9 -2
  63. package/src/features/ai-connection/ai-connection.module.ts +14 -0
  64. package/src/features/ai-connection/components/containers/AiConnectionsContainer.tsx +109 -0
  65. package/src/features/ai-connection/components/forms/AiConnectionDeleter.tsx +58 -0
  66. package/src/features/ai-connection/components/forms/AiConnectionEditor.tsx +329 -0
  67. package/src/features/ai-connection/components/lists/AiConnectionTypeCard.tsx +223 -0
  68. package/src/features/ai-connection/contexts/AiConnectionsContext.tsx +111 -0
  69. package/src/features/ai-connection/data/__tests__/ai-connection.test.ts +202 -0
  70. package/src/features/ai-connection/data/ai-connection.fields.ts +6 -0
  71. package/src/features/ai-connection/data/ai-connection.interface.ts +87 -0
  72. package/src/features/ai-connection/data/ai-connection.service.ts +90 -0
  73. package/src/features/ai-connection/data/ai-connection.ts +244 -0
  74. package/src/features/ai-connection/data/index.ts +4 -0
  75. package/src/features/ai-connection/i18n-keys.ts +66 -0
  76. package/src/features/ai-connection/index.ts +11 -0
  77. package/src/features/index.ts +1 -0
  78. package/dist/AuthComponent-Cik96ElA.d.mts +0 -56
  79. package/dist/AuthComponent-DTTKu3VK.d.ts +0 -56
  80. package/dist/JsonApiRequest-QRU3IPIU.js +0 -26
  81. package/dist/chunk-53B6NPGA.js.map +0 -1
  82. package/dist/chunk-5GVBUTS4.js.map +0 -1
  83. package/dist/chunk-E5YA5Z5X.mjs.map +0 -1
  84. package/dist/chunk-FPO4DLZN.js.map +0 -1
  85. package/dist/chunk-TWXKAY34.mjs.map +0 -1
  86. package/dist/chunk-WCX4CLRJ.mjs.map +0 -1
  87. /package/dist/{BlockNoteEditor-G4XNDV2O.mjs.map → BlockNoteEditor-LJ2KA44Z.mjs.map} +0 -0
  88. /package/dist/{JsonApiRequest-3UWVIIFL.mjs.map → JsonApiRequest-2OQCZAK6.mjs.map} +0 -0
  89. /package/dist/{chunk-PHEFWL6L.mjs.map → chunk-ZMYZFQN3.mjs.map} +0 -0
@@ -62,12 +62,12 @@ import {
62
62
  useCurrentUserContext,
63
63
  useDataListRetriever,
64
64
  usePageUrlGenerator
65
- } from "../chunk-WCX4CLRJ.mjs";
65
+ } from "../chunk-WCRZEBX4.mjs";
66
66
  import {
67
67
  getRoleId,
68
68
  getStripePublishableKey,
69
69
  useI18nRouter
70
- } from "../chunk-PHEFWL6L.mjs";
70
+ } from "../chunk-ZMYZFQN3.mjs";
71
71
  import {
72
72
  FeatureService,
73
73
  Modules,
@@ -80,10 +80,10 @@ import {
80
80
  StripeUsageService,
81
81
  cn,
82
82
  rehydrate
83
- } from "../chunk-TWXKAY34.mjs";
83
+ } from "../chunk-CGJW7ZZM.mjs";
84
84
  import "../chunk-AUXK7QSA.mjs";
85
85
  import "../chunk-C7C7VY4F.mjs";
86
- import "../chunk-E5YA5Z5X.mjs";
86
+ import "../chunk-CMGXH5SA.mjs";
87
87
  import "../chunk-VOXD3ZLY.mjs";
88
88
  import {
89
89
  __name
@@ -14,7 +14,7 @@ import {
14
14
  setBootstrapper,
15
15
  translateResponse,
16
16
  tryBootstrap
17
- } from "./chunk-E5YA5Z5X.mjs";
17
+ } from "./chunk-CMGXH5SA.mjs";
18
18
  import {
19
19
  __name
20
20
  } from "./chunk-PAWJFY3S.mjs";
@@ -335,7 +335,7 @@ var AbstractService = class {
335
335
  * Make an API call with automatic environment detection and error handling.
336
336
  */
337
337
  static async callApi(params) {
338
- const { JsonApiGet: JsonApiGet2, JsonApiPost: JsonApiPost2, JsonApiPut, JsonApiPatch, JsonApiDelete: JsonApiDelete2 } = await import("./JsonApiRequest-3UWVIIFL.mjs");
338
+ const { JsonApiGet: JsonApiGet2, JsonApiPost: JsonApiPost2, JsonApiPut, JsonApiPatch, JsonApiDelete: JsonApiDelete2 } = await import("./JsonApiRequest-2OQCZAK6.mjs");
339
339
  let apiResponse;
340
340
  let language = "en";
341
341
  if (typeof window === "undefined") {
@@ -436,7 +436,7 @@ var AbstractService = class {
436
436
  * Make an API call and return both data and meta from the response.
437
437
  */
438
438
  static async callApiWithMeta(params) {
439
- const { JsonApiGet: JsonApiGet2, JsonApiPost: JsonApiPost2, JsonApiPut, JsonApiPatch, JsonApiDelete: JsonApiDelete2 } = await import("./JsonApiRequest-3UWVIIFL.mjs");
439
+ const { JsonApiGet: JsonApiGet2, JsonApiPost: JsonApiPost2, JsonApiPut, JsonApiPatch, JsonApiDelete: JsonApiDelete2 } = await import("./JsonApiRequest-2OQCZAK6.mjs");
440
440
  let apiResponse;
441
441
  let language = "en";
442
442
  if (typeof window === "undefined") {
@@ -522,7 +522,7 @@ var AbstractService = class {
522
522
  * Get raw JSON:API response data without deserialization.
523
523
  */
524
524
  static async getRawData(params) {
525
- const { JsonApiGet: JsonApiGet2 } = await import("./JsonApiRequest-3UWVIIFL.mjs");
525
+ const { JsonApiGet: JsonApiGet2 } = await import("./JsonApiRequest-2OQCZAK6.mjs");
526
526
  let language = "en";
527
527
  if (typeof window === "undefined") {
528
528
  const { getLocale } = await import("next-intl/server");
@@ -4995,6 +4995,307 @@ var StripePromotionCodeModule = /* @__PURE__ */ __name((factory) => factory({
4995
4995
  moduleId: "b8e4f6a2-9d0c-5b3f-c7e8-4g2d9f0a5c6e"
4996
4996
  }), "StripePromotionCodeModule");
4997
4997
 
4998
+ // src/features/ai-connection/data/ai-connection.ts
4999
+ var AiConnection = class extends AbstractApiData {
5000
+ static {
5001
+ __name(this, "AiConnection");
5002
+ }
5003
+ _name;
5004
+ _connectionType;
5005
+ _provider;
5006
+ _position;
5007
+ _enabled;
5008
+ _model;
5009
+ _url;
5010
+ _region;
5011
+ _instance;
5012
+ _apiVersion;
5013
+ _allowFallbacks;
5014
+ _reasoningEffort;
5015
+ _maxOutputTokens;
5016
+ _dimensions;
5017
+ _inputCostPer1MTokens;
5018
+ _outputCostPer1MTokens;
5019
+ _cachedInputCostPer1MTokens;
5020
+ _costPerMinute;
5021
+ _costPerPage;
5022
+ _directUrl;
5023
+ _language;
5024
+ _directFormat;
5025
+ _directProvider;
5026
+ _hasApiKey;
5027
+ _hasGoogleCredentials;
5028
+ _companyId;
5029
+ get name() {
5030
+ return this._name ?? "";
5031
+ }
5032
+ get connectionType() {
5033
+ return this._connectionType ?? "";
5034
+ }
5035
+ get provider() {
5036
+ return this._provider ?? "";
5037
+ }
5038
+ get position() {
5039
+ return this._position ?? 0;
5040
+ }
5041
+ get enabled() {
5042
+ return this._enabled ?? true;
5043
+ }
5044
+ get model() {
5045
+ return this._model;
5046
+ }
5047
+ get url() {
5048
+ return this._url;
5049
+ }
5050
+ get region() {
5051
+ return this._region;
5052
+ }
5053
+ get instance() {
5054
+ return this._instance;
5055
+ }
5056
+ get apiVersion() {
5057
+ return this._apiVersion;
5058
+ }
5059
+ get allowFallbacks() {
5060
+ return this._allowFallbacks;
5061
+ }
5062
+ get reasoningEffort() {
5063
+ return this._reasoningEffort;
5064
+ }
5065
+ get maxOutputTokens() {
5066
+ return this._maxOutputTokens;
5067
+ }
5068
+ get dimensions() {
5069
+ return this._dimensions;
5070
+ }
5071
+ get inputCostPer1MTokens() {
5072
+ return this._inputCostPer1MTokens;
5073
+ }
5074
+ get outputCostPer1MTokens() {
5075
+ return this._outputCostPer1MTokens;
5076
+ }
5077
+ get cachedInputCostPer1MTokens() {
5078
+ return this._cachedInputCostPer1MTokens;
5079
+ }
5080
+ get costPerMinute() {
5081
+ return this._costPerMinute;
5082
+ }
5083
+ get costPerPage() {
5084
+ return this._costPerPage;
5085
+ }
5086
+ get directUrl() {
5087
+ return this._directUrl;
5088
+ }
5089
+ get language() {
5090
+ return this._language;
5091
+ }
5092
+ get directFormat() {
5093
+ return this._directFormat;
5094
+ }
5095
+ get directProvider() {
5096
+ return this._directProvider;
5097
+ }
5098
+ get hasApiKey() {
5099
+ return this._hasApiKey ?? false;
5100
+ }
5101
+ get hasGoogleCredentials() {
5102
+ return this._hasGoogleCredentials ?? false;
5103
+ }
5104
+ get companyId() {
5105
+ return this._companyId;
5106
+ }
5107
+ rehydrate(data) {
5108
+ super.rehydrate(data);
5109
+ const attributes = data.jsonApi.attributes ?? {};
5110
+ this._name = attributes.name;
5111
+ this._connectionType = attributes.connectionType;
5112
+ this._provider = attributes.provider;
5113
+ this._position = attributes.position;
5114
+ this._enabled = attributes.enabled;
5115
+ this._model = attributes.model;
5116
+ this._url = attributes.url;
5117
+ this._region = attributes.region;
5118
+ this._instance = attributes.instance;
5119
+ this._apiVersion = attributes.apiVersion;
5120
+ this._allowFallbacks = attributes.allowFallbacks;
5121
+ this._reasoningEffort = attributes.reasoningEffort;
5122
+ this._maxOutputTokens = attributes.maxOutputTokens;
5123
+ this._dimensions = attributes.dimensions;
5124
+ this._inputCostPer1MTokens = attributes.inputCostPer1MTokens;
5125
+ this._outputCostPer1MTokens = attributes.outputCostPer1MTokens;
5126
+ this._cachedInputCostPer1MTokens = attributes.cachedInputCostPer1MTokens;
5127
+ this._costPerMinute = attributes.costPerMinute;
5128
+ this._costPerPage = attributes.costPerPage;
5129
+ this._directUrl = attributes.directUrl;
5130
+ this._language = attributes.language;
5131
+ this._directFormat = attributes.directFormat;
5132
+ this._directProvider = attributes.directProvider;
5133
+ this._hasApiKey = attributes.hasApiKey;
5134
+ this._hasGoogleCredentials = attributes.hasGoogleCredentials;
5135
+ this._companyId = attributes.companyId;
5136
+ return this;
5137
+ }
5138
+ createJsonApi(data) {
5139
+ const response = {
5140
+ data: {
5141
+ type: Modules.AiConnection.name,
5142
+ id: data.id,
5143
+ attributes: {},
5144
+ relationships: {}
5145
+ },
5146
+ included: []
5147
+ };
5148
+ const setIfDefined = /* @__PURE__ */ __name((key) => {
5149
+ if (data[key] !== void 0) response.data.attributes[key] = data[key];
5150
+ }, "setIfDefined");
5151
+ [
5152
+ "name",
5153
+ "connectionType",
5154
+ "provider",
5155
+ "position",
5156
+ "enabled",
5157
+ "model",
5158
+ "url",
5159
+ "region",
5160
+ "instance",
5161
+ "apiVersion",
5162
+ "allowFallbacks",
5163
+ "reasoningEffort",
5164
+ "maxOutputTokens",
5165
+ "dimensions",
5166
+ "inputCostPer1MTokens",
5167
+ "outputCostPer1MTokens",
5168
+ "cachedInputCostPer1MTokens",
5169
+ "costPerMinute",
5170
+ "costPerPage",
5171
+ "directUrl",
5172
+ "language",
5173
+ "directFormat",
5174
+ "directProvider"
5175
+ ].forEach(setIfDefined);
5176
+ if (data.apiKey) response.data.attributes.apiKey = data.apiKey;
5177
+ if (data.googleCredentialsBase64) {
5178
+ response.data.attributes.googleCredentialsBase64 = data.googleCredentialsBase64;
5179
+ }
5180
+ if (data.companyId) {
5181
+ response.data.relationships.company = {
5182
+ data: { type: Modules.Company.name, id: data.companyId }
5183
+ };
5184
+ }
5185
+ return response;
5186
+ }
5187
+ /**
5188
+ * Body for POST /ai-connections/reorder. A dedicated model method so the
5189
+ * service never constructs a JSON:API payload itself — the sanctioned pairing
5190
+ * for `overridesJsonApiCreation`.
5191
+ */
5192
+ createReorderJsonApi(params) {
5193
+ return {
5194
+ data: {
5195
+ type: Modules.AiConnection.name,
5196
+ ids: params.ids
5197
+ }
5198
+ };
5199
+ }
5200
+ };
5201
+
5202
+ // src/features/ai-connection/data/ai-connection.fields.ts
5203
+ var AiConnectionFields = /* @__PURE__ */ ((AiConnectionFields2) => {
5204
+ AiConnectionFields2["name"] = "name";
5205
+ AiConnectionFields2["provider"] = "provider";
5206
+ AiConnectionFields2["model"] = "model";
5207
+ AiConnectionFields2["enabled"] = "enabled";
5208
+ return AiConnectionFields2;
5209
+ })(AiConnectionFields || {});
5210
+
5211
+ // src/features/ai-connection/data/ai-connection.service.ts
5212
+ var AiConnectionService = class extends AbstractService {
5213
+ static {
5214
+ __name(this, "AiConnectionService");
5215
+ }
5216
+ /**
5217
+ * Full list plus the editor meta in one round-trip: the list endpoint carries
5218
+ * the provider registry and the `.env` defaults as top-level JSON:API `meta`.
5219
+ */
5220
+ static async listConnections() {
5221
+ const endpoint = new EndpointCreator({ endpoint: Modules.AiConnection });
5222
+ endpoint.addAdditionalParam("fetchAll", "true");
5223
+ const { data, meta } = await this.callApiWithMeta({
5224
+ type: Modules.AiConnection,
5225
+ method: "GET" /* GET */,
5226
+ endpoint: endpoint.generate()
5227
+ });
5228
+ return {
5229
+ connections: data ?? [],
5230
+ providerRegistry: meta?.providerRegistry ?? {},
5231
+ envDefaults: meta?.envDefaults ?? {}
5232
+ };
5233
+ }
5234
+ /**
5235
+ * Create a connection. The optional `companyId` fixes its scope forever.
5236
+ */
5237
+ static async create(params) {
5238
+ return this.callApi({
5239
+ type: Modules.AiConnection,
5240
+ method: "POST" /* POST */,
5241
+ endpoint: new EndpointCreator({ endpoint: Modules.AiConnection }).generate(),
5242
+ input: params
5243
+ });
5244
+ }
5245
+ /**
5246
+ * Update a connection. Blank/omitted secrets keep the stored values.
5247
+ */
5248
+ static async update(params) {
5249
+ return this.callApi({
5250
+ type: Modules.AiConnection,
5251
+ method: "PUT" /* PUT */,
5252
+ endpoint: new EndpointCreator({ endpoint: Modules.AiConnection, id: params.id }).generate(),
5253
+ input: params
5254
+ });
5255
+ }
5256
+ /**
5257
+ * Delete a connection.
5258
+ */
5259
+ static async delete(params) {
5260
+ await this.callApi({
5261
+ type: Modules.AiConnection,
5262
+ method: "DELETE" /* DELETE */,
5263
+ endpoint: new EndpointCreator({ endpoint: Modules.AiConnection, id: params.id }).generate()
5264
+ });
5265
+ }
5266
+ /**
5267
+ * Reorder one chain: the ordered id list is renumbered 0..n-1 server-side.
5268
+ * Dedicated model method + `overridesJsonApiCreation` — the sanctioned
5269
+ * pairing, never a hand-built payload here.
5270
+ */
5271
+ static async reorder(params) {
5272
+ const model = new AiConnection();
5273
+ await this.callApi({
5274
+ type: Modules.AiConnection,
5275
+ method: "POST" /* POST */,
5276
+ endpoint: new EndpointCreator({
5277
+ endpoint: Modules.AiConnection,
5278
+ childEndpoint: "reorder"
5279
+ }).generate(),
5280
+ input: model.createReorderJsonApi({ ids: params.ids }),
5281
+ overridesJsonApiCreation: true
5282
+ // OK — the model method provides the structure
5283
+ });
5284
+ }
5285
+ };
5286
+
5287
+ // src/features/ai-connection/ai-connection.module.ts
5288
+ var AiConnectionModule = /* @__PURE__ */ __name((factory) => factory({
5289
+ name: "ai-connections",
5290
+ // The administration route this entity is served at. `name` above stays the
5291
+ // API endpoint; this drives generateUrl / rewriteUrl / EditorSheet
5292
+ // navigation, so it must match the real Next.js route or RoundPageContainer
5293
+ // rewrites the URL to a 404 on the first tab change.
5294
+ pageUrl: "/administration/ai-connections",
5295
+ model: AiConnection,
5296
+ moduleId: "7d3f2b8a-91c4-4e6d-a5f0-2c9b8e4d1a37"
5297
+ }), "AiConnectionModule");
5298
+
4998
5299
  // src/features/company/company.module.ts
4999
5300
  import { Building2Icon } from "lucide-react";
5000
5301
 
@@ -8572,6 +8873,10 @@ export {
8572
8873
  StripePromotionCodeService,
8573
8874
  StripePromotionCode,
8574
8875
  StripePromotionCodeModule,
8876
+ AiConnection,
8877
+ AiConnectionFields,
8878
+ AiConnectionService,
8879
+ AiConnectionModule,
8575
8880
  Company,
8576
8881
  CompanyFields,
8577
8882
  CompanyService,
@@ -8657,4 +8962,4 @@ export {
8657
8962
  AuditLogService,
8658
8963
  AuditLogModule
8659
8964
  };
8660
- //# sourceMappingURL=chunk-TWXKAY34.mjs.map
8965
+ //# sourceMappingURL=chunk-CGJW7ZZM.mjs.map