@norbix.ai/react-redux 1.6.0 → 1.8.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/README.md CHANGED
@@ -183,6 +183,44 @@ A _curated_ set of hooks for the most common endpoints. Every hook is end-to-end
183
183
 
184
184
  > **Need a hook we don't ship?** Two options. (1) Drop down to the SDK with `useNorbix()` for a one-off call. (2) Add a new file under `src/hooks/api/` or `src/hooks/hub/`, follow the pattern of the others, and open a PR.
185
185
 
186
+ ### Database — records, trees, bundle, imports — `norbix.hub.database` / `norbix.api.database`
187
+
188
+ Every `hub.database` method (73) and every `api.database` method (22) of `@norbix.ai/ts` has a hook; Hub hooks keep the SDK method name. The rows below are the ones added for `@norbix.ai/ts` >= 4.9.0.
189
+
190
+ | Hook | SDK method | Cache |
191
+ | --------------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------ |
192
+ | `useFindRecordsQuery` | `hub.database.findRecords` | provides `DatabaseRecords/<collectionName>` |
193
+ | `useFindOneRecordQuery` | `hub.database.findOneRecord` | provides `DatabaseRecords/<collectionName>` |
194
+ | `useCountRecordsQuery` | `hub.database.countRecords` | provides `DatabaseRecords/<collectionName>` |
195
+ | `useDistinctRecordValuesQuery` | `hub.database.distinctRecordValues` | provides `DatabaseRecords/<collectionName>` |
196
+ | `useAggregateRecordsMutation` | `hub.database.aggregateRecords` | — (never cached) |
197
+ | `useExecuteRecordsAggregateMutation` | `hub.database.executeRecordsAggregate` | — (never cached) |
198
+ | `useGetCollectionIndexesQuery` | `hub.database.getCollectionIndexes` | provides `DatabaseCollections/<collectionName>` |
199
+ | `useInsertRecordMutation` | `hub.database.insertRecord` | invalidates `DatabaseRecords/<collectionName>` |
200
+ | `useInsertManyRecordsMutation` | `hub.database.insertManyRecords` | invalidates `DatabaseRecords/<collectionName>` |
201
+ | `useUpdateOneRecordMutation` | `hub.database.updateOneRecord` | invalidates `DatabaseRecords/<collectionName>` |
202
+ | `useUpdateManyRecordsMutation` | `hub.database.updateManyRecords` | invalidates `DatabaseRecords/<collectionName>` |
203
+ | `useReplaceRecordMutation` | `hub.database.replaceRecord` | invalidates `DatabaseRecords/<collectionName>` |
204
+ | `useDeleteRecordMutation` | `hub.database.deleteRecord` | invalidates `DatabaseRecords/<collectionName>` |
205
+ | `useDeleteManyRecordsMutation` | `hub.database.deleteManyRecords` | invalidates `DatabaseRecords/<collectionName>` |
206
+ | `useChangeRecordResponsibilityMutation` | `hub.database.changeRecordResponsibility` | invalidates `DatabaseRecords/<collectionName>` |
207
+ | `useSeedCollectionRecordsMutation` | `hub.database.seedCollectionRecords` | invalidates `DatabaseRecords` |
208
+ | `useGetDatabaseTaxonomyTreeQuery` | `hub.database.getDatabaseTaxonomyTree` | provides `DatabaseTaxonomies` + `DatabaseTaxonomyTerms` |
209
+ | `useGetDatabaseTaxonomyTermTreeQuery` | `hub.database.getDatabaseTaxonomyTermTree` | provides `DatabaseTaxonomyTerms/<taxonomyName>` |
210
+ | `useGetDatabaseMergedTermTreeQuery` | `hub.database.getDatabaseMergedTermTree` | provides `DatabaseTaxonomyTerms/<taxonomyName>` |
211
+ | `useApplyDatabaseSchemaBundleMutation` | `hub.database.applyDatabaseSchemaBundle` | invalidates `DatabaseSchemas` + taxonomies + terms |
212
+ | `useUpdateDatabaseSchemaEmbedMutation` | `hub.database.updateDatabaseSchemaEmbed` | invalidates `DatabaseSchemas` |
213
+ | `useGetDatabaseSchemaListSettingsQuery` | `hub.database.getDatabaseSchemaListSettings` | provides `DatabaseSchemas` |
214
+ | `useUpdateDatabaseSchemaListSettingsMutation` | `hub.database.updateDatabaseSchemaListSettings` | invalidates `DatabaseSchemas` |
215
+ | `useGetCollectionImportsQuery` | `hub.database.getCollectionImports` | provides `DatabaseImports` |
216
+ | `useGetCollectionImportQuery` | `hub.database.getCollectionImport` | provides `DatabaseImports` |
217
+ | `useCreateCollectionImportMutation` | `hub.database.createCollectionImport` | invalidates `DatabaseImports` + `DatabaseRecords/<collectionName>` |
218
+ | `useDeleteCollectionImportMutation` | `hub.database.deleteCollectionImport` | invalidates `DatabaseImports` |
219
+ | `useAnalyzeImportFileMutation` | `hub.database.analyzeImportFile` | — |
220
+ | `useRequestImportUploadUrlMutation` | `hub.database.requestImportUploadUrl` | — |
221
+ | `useFindOwnQuery` | `api.database.findOwn` | provides `DatabaseCollections/<collectionName>` |
222
+ | `useFindMergedTermTreeQuery` | `api.database.findMergedTermTree` | provides `DatabaseTaxonomyTerms/<taxonomyName>` |
223
+
186
224
  ### End-user AI chat — `norbix.api.ai`
187
225
 
188
226
  For a signed-in project user. `useStartEndUserChatTurnMutation` answers at once with a `turnId`; the answer streams on the user's SSE channel `ai-chat:{projectId}:{authId}` — open it with `norbix.aiChat({ authId })` from `@norbix.ai/ts` (a foreign channel is refused with 403 `AiChatChannelRefused`, no retry). Needs `@norbix.ai/ts` >= 4.3.0.
@@ -332,17 +370,17 @@ integration.
332
370
 
333
371
  ## SMS
334
372
 
335
- Every SMS Hub endpoint (35) has a hook, 1:1 with `norbix.hub.notifications`.
373
+ Every SMS Hub endpoint (34) has a hook, 1:1 with `norbix.hub.notifications`.
336
374
  Queries provide a tag, mutations invalidate it, so a list re-reads after a
337
375
  write without any manual refetch:
338
376
 
339
- | Area | Hooks | Cache tag |
340
- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
341
- | Module switch | `useEnableSmsMutation`, `useDisableSmsMutation`, `useGetSmsDisableDependenciesQuery` (what a switch-off would affect — read it before disabling), `useGetSmsSettingsQuery` | `Sms`, `SmsSettings` |
342
- | Integrations (providers) | `useGetSmsIntegrationsQuery`, `useGetSmsIntegrationQuery`, `useSaveSmsIntegrationMutation`, `useTestSmsIntegrationMutation`, `useConfirmSmsIntegrationHumanDeliveryMutation`, `useDeleteSmsIntegrationMutation`, `useSetSmsIntegrationAsDefaultMutation`, `useEnableSmsIntegrationMutation`, `useDisableSmsIntegrationMutation` | `SmsIntegrations` |
343
- | Templates | `useGetSmsTemplatesQuery`, `useGetSmsTemplateQuery`, `useCreateSmsTemplateMutation`, `useUpdateSmsTemplateMutation`, `useDeleteSmsTemplateMutation`, `useArchiveSmsTemplateMutation`, `useUnArchiveSmsTemplateMutation`, `useCloneSmsTemplateMutation`, `useGetSmsMessageContentTokensQuery`, `useRenderSmsMutation` | `SmsTemplates`, `Sms` |
344
- | Campaigns | `useGetSmsCampaignsQuery`, `useCreateSmsCampaignMutation`, `useGetSmsCampaignQuery`, `useDeleteSmsCampaignMutation`, `useStopSmsCampaignMutation`, `useGetSmsCampaignStatisticsQuery`, `useGetSmsCampaignBatchesQuery`, `useGetSmsCampaignBatchNotificationsQuery`, `useGetSmsCampaignBatchNotificationQuery`, `useGetSmsCampaignMessagesQuery`, `useGetSmsCampaignMessageQuery` | `SmsCampaigns` |
345
- | Preview | `usePreviewSmsNotificationQuery` (opens with the signed link `hash`, no sign-in — see above) | `Sms` |
377
+ | Area | Hooks | Cache tag |
378
+ | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
379
+ | Module switch | `useEnableSmsMutation`, `useDisableSmsMutation`, `useGetSmsDisableDependenciesQuery` (what a switch-off would affect — read it before disabling), `useGetSmsSettingsQuery` | `Sms`, `SmsSettings` |
380
+ | Integrations (providers) | `useGetSmsIntegrationsQuery`, `useGetSmsIntegrationQuery`, `useSaveSmsIntegrationMutation`, `useTestSmsIntegrationMutation`, `useConfirmSmsIntegrationHumanDeliveryMutation`, `useDeleteSmsIntegrationMutation`, `useSetSmsIntegrationAsDefaultMutation`, `useEnableSmsIntegrationMutation`, `useDisableSmsIntegrationMutation` | `SmsIntegrations` |
381
+ | Templates | `useGetSmsTemplatesQuery`, `useGetSmsTemplateQuery`, `useCreateSmsTemplateMutation`, `useUpdateSmsTemplateMutation`, `useDeleteSmsTemplateMutation`, `useArchiveSmsTemplateMutation`, `useUnArchiveSmsTemplateMutation`, `useCloneSmsTemplateMutation`, `useGetSmsMessageContentTokensQuery`, `useRenderSmsMutation` | `SmsTemplates`, `Sms` |
382
+ | Campaigns | `useGetSmsCampaignsQuery`, `useCreateSmsCampaignMutation`, `useGetSmsCampaignQuery`, `useDeleteSmsCampaignMutation`, `useStopSmsCampaignMutation`, `useGetSmsCampaignStatisticsQuery`, `useGetSmsCampaignBatchesQuery`, `useGetSmsCampaignBatchNotificationsQuery`, `useGetSmsCampaignBatchNotificationQuery`, `useGetSmsCampaignMessagesQuery` | `SmsCampaigns` |
383
+ | Preview | `usePreviewSmsNotificationQuery` (opens with the signed link `hash`, no sign-in — see above) | `Sms` |
346
384
 
347
385
  ```tsx
348
386
  const [stop, { isLoading }] = useStopSmsCampaignMutation();
@@ -366,6 +404,30 @@ it is a mutation only so a render is never served from the cache. The
366
404
  integration hooks can also be produced by `buildIntegrationsEndpoints` (next
367
405
  section) — the shipped ones above are the typed variants.
368
406
 
407
+ ### Your own profile and phone — `norbix.hub.account` (core SDK 4.8.0)
408
+
409
+ An "Account users" SMS campaign (`accountUsers` on `useCreateSmsCampaignMutation`,
410
+ the ids of the account owner / team members) sends to each member's own phone.
411
+ A member reads and sets it with two hooks; members without a phone are skipped.
412
+
413
+ | Hook | SDK method | Wire | Cache |
414
+ | ------------------------------------- | -------------------------------------- | ----------------------- | --------------------- |
415
+ | `useGetMyAccountUserProfileQuery` | `hub.account.getMyAccountUserProfile` | `GET /account/me` | provides `Account` |
416
+ | `useUpdateMyAccountUserPhoneMutation` | `hub.account.updateMyAccountUserPhone` | `PUT /account/me/phone` | invalidates `Account` |
417
+
418
+ ```tsx
419
+ const { data } = useGetMyAccountUserProfileQuery();
420
+ const [setPhone] = useUpdateMyAccountUserPhoneMutation();
421
+
422
+ // E.164: + and the country code, then digits. An empty string clears it.
423
+ await setPhone({ phone: '+37060000000' }).unwrap();
424
+ ```
425
+
426
+ The team list (`useGetAccountCollaboratorsQuery`) also provides `Account`, so it
427
+ re-reads after a phone change. It now pages with flat `startingAfter`,
428
+ `endingBefore` and `pageSize` (default 20), and `projectId` without
429
+ `includeAccountOwner` lists only that project's collaborators.
430
+
369
431
  ## Scheduler
370
432
 
371
433
  Every scheduler Hub endpoint (8) has a hook, 1:1 with `norbix.hub.scheduler`.
package/dist/index.cjs CHANGED
@@ -183,25 +183,47 @@ var apiDatabase = (b) => ({
183
183
  findCollection: b.query({
184
184
  query: (args) => (norbix) => norbix.api.database.find(args),
185
185
  providesTags: (_res, _err, arg) => [
186
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
186
+ {
187
+ type: "DatabaseCollections",
188
+ id: arg?.collectionName ?? "ANY"
189
+ }
187
190
  ]
188
191
  }),
189
192
  findOne: b.query({
190
193
  query: (args) => (norbix) => norbix.api.database.findOne(args),
191
194
  providesTags: (_res, _err, arg) => [
192
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
195
+ {
196
+ type: "DatabaseCollections",
197
+ id: arg?.collectionName ?? "ANY"
198
+ }
199
+ ]
200
+ }),
201
+ // Only the records the caller is responsible for (owner-scoped find).
202
+ findOwn: b.query({
203
+ query: (args) => (norbix) => norbix.api.database.findOwn(args),
204
+ providesTags: (_res, _err, arg) => [
205
+ {
206
+ type: "DatabaseCollections",
207
+ id: arg?.collectionName ?? "ANY"
208
+ }
193
209
  ]
194
210
  }),
195
211
  countCollection: b.query({
196
212
  query: (args) => (norbix) => norbix.api.database.count(args),
197
213
  providesTags: (_res, _err, arg) => [
198
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
214
+ {
215
+ type: "DatabaseCollections",
216
+ id: arg?.collectionName ?? "ANY"
217
+ }
199
218
  ]
200
219
  }),
201
220
  distinct: b.query({
202
221
  query: (args) => (norbix) => norbix.api.database.distinct(args),
203
222
  providesTags: (_res, _err, arg) => [
204
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
223
+ {
224
+ type: "DatabaseCollections",
225
+ id: arg?.collectionName ?? "ANY"
226
+ }
205
227
  ]
206
228
  }),
207
229
  aggregate: b.mutation({
@@ -214,69 +236,102 @@ var apiDatabase = (b) => ({
214
236
  insertOne: b.mutation({
215
237
  query: (args) => (norbix) => norbix.api.database.insertOne(args),
216
238
  invalidatesTags: (_res, _err, arg) => [
217
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
239
+ {
240
+ type: "DatabaseCollections",
241
+ id: arg?.collectionName ?? "ANY"
242
+ }
218
243
  ]
219
244
  }),
220
245
  insertMany: b.mutation({
221
246
  query: (args) => (norbix) => norbix.api.database.insertMany(args),
222
247
  invalidatesTags: (_res, _err, arg) => [
223
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
248
+ {
249
+ type: "DatabaseCollections",
250
+ id: arg?.collectionName ?? "ANY"
251
+ }
224
252
  ]
225
253
  }),
226
254
  updateOne: b.mutation({
227
255
  query: (args) => (norbix) => norbix.api.database.updateOne(args),
228
256
  invalidatesTags: (_res, _err, arg) => [
229
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
257
+ {
258
+ type: "DatabaseCollections",
259
+ id: arg?.collectionName ?? "ANY"
260
+ }
230
261
  ]
231
262
  }),
232
263
  updateMany: b.mutation({
233
264
  query: (args) => (norbix) => norbix.api.database.updateMany(args),
234
265
  invalidatesTags: (_res, _err, arg) => [
235
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
266
+ {
267
+ type: "DatabaseCollections",
268
+ id: arg?.collectionName ?? "ANY"
269
+ }
236
270
  ]
237
271
  }),
238
272
  replaceOne: b.mutation({
239
273
  query: (args) => (norbix) => norbix.api.database.replaceOne(args),
240
274
  invalidatesTags: (_res, _err, arg) => [
241
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
275
+ {
276
+ type: "DatabaseCollections",
277
+ id: arg?.collectionName ?? "ANY"
278
+ }
242
279
  ]
243
280
  }),
244
281
  deleteOne: b.mutation({
245
282
  query: (args) => (norbix) => norbix.api.database.deleteOne(args),
246
283
  invalidatesTags: (_res, _err, arg) => [
247
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
284
+ {
285
+ type: "DatabaseCollections",
286
+ id: arg?.collectionName ?? "ANY"
287
+ }
248
288
  ]
249
289
  }),
250
290
  deleteMany: b.mutation({
251
291
  query: (args) => (norbix) => norbix.api.database.deleteMany(args),
252
292
  invalidatesTags: (_res, _err, arg) => [
253
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
293
+ {
294
+ type: "DatabaseCollections",
295
+ id: arg?.collectionName ?? "ANY"
296
+ }
254
297
  ]
255
298
  }),
256
299
  changeResponsibility: b.mutation({
257
300
  query: (args) => (norbix) => norbix.api.database.changeResponsibility(args),
258
301
  invalidatesTags: (_res, _err, arg) => [
259
- { type: "DatabaseCollections", id: arg?.collectionName ?? "ANY" }
302
+ {
303
+ type: "DatabaseCollections",
304
+ id: arg?.collectionName ?? "ANY"
305
+ }
260
306
  ]
261
307
  }),
262
308
  // ---- Taxonomies (read-only on api; admin lives in hub.database) ----
263
309
  findTerms: b.query({
264
310
  query: (args) => (norbix) => norbix.api.database.findTerms(args),
265
311
  providesTags: (_res, _err, arg) => [
266
- { type: "DatabaseTaxonomyTerms", id: arg?.taxonomyName ?? "ANY" }
312
+ {
313
+ type: "DatabaseTaxonomyTerms",
314
+ id: arg?.taxonomyName ?? "ANY"
315
+ }
267
316
  ]
268
317
  }),
269
318
  findTermsChildren: b.query({
270
319
  query: (args) => (norbix) => norbix.api.database.findTermsChildren(args),
271
320
  providesTags: (_res, _err, arg) => [
272
- { type: "DatabaseTaxonomyTerms", id: arg?.taxonomyName ?? "ANY" }
321
+ {
322
+ type: "DatabaseTaxonomyTerms",
323
+ id: arg?.taxonomyName ?? "ANY"
324
+ }
273
325
  ]
274
326
  }),
275
327
  // Whole term tree of a taxonomy (or a sub-tree from a root term) in one call.
276
328
  findTermTree: b.query({
277
329
  query: (args) => (norbix) => norbix.api.database.findTermTree(args),
278
330
  providesTags: (_res, _err, arg) => [
279
- { type: "DatabaseTaxonomyTerms", id: arg?.taxonomyName ?? "ANY" }
331
+ {
332
+ type: "DatabaseTaxonomyTerms",
333
+ id: arg?.taxonomyName ?? "ANY"
334
+ }
280
335
  ]
281
336
  }),
282
337
  // Single-parent taxonomy structure tree (Countries → Cities), optionally with terms.
@@ -284,6 +339,16 @@ var apiDatabase = (b) => ({
284
339
  query: (args) => (norbix) => norbix.api.database.findTaxonomyTree(args),
285
340
  providesTags: () => [{ type: "DatabaseTaxonomyTerms", id: "ANY" }]
286
341
  }),
342
+ // One tree across related taxonomies (Countries + Cities: each country with its cities).
343
+ findMergedTermTree: b.query({
344
+ query: (args) => (norbix) => norbix.api.database.findMergedTermTree(args),
345
+ providesTags: (_res, _err, arg) => [
346
+ {
347
+ type: "DatabaseTaxonomyTerms",
348
+ id: arg?.taxonomyName ?? "ANY"
349
+ }
350
+ ]
351
+ }),
287
352
  // ---- Schemas (read-only mirror; full CRUD lives in hub.database) ----
288
353
  getApiDatabaseSchema: b.query({
289
354
  query: (args) => (norbix) => norbix.api.database.getDatabaseSchema(args),
@@ -684,6 +749,20 @@ var hubAccount = (b) => ({
684
749
  query: (args) => (norbix) => norbix.hub.account.getAccountCollaborators(args),
685
750
  providesTags: ["Account"]
686
751
  }),
752
+ /** `GET /account/me` — the signed-in owner or team member's own profile, phone included. */
753
+ getMyAccountUserProfile: b.query({
754
+ query: (args) => (norbix) => norbix.hub.account.getMyAccountUserProfile(args),
755
+ providesTags: ["Account"]
756
+ }),
757
+ /**
758
+ * `PUT /account/me/phone` — set (E.164, e.g. `+37060000000`) or clear (empty)
759
+ * your own phone. "Account users" SMS campaigns send to it, so the team list
760
+ * (`getAccountCollaborators`, also tagged `Account`) re-reads after a change.
761
+ */
762
+ updateMyAccountUserPhone: b.mutation({
763
+ query: (args) => (norbix) => norbix.hub.account.updateMyAccountUserPhone(args),
764
+ invalidatesTags: ["Account"]
765
+ }),
687
766
  sendInviteToTeamMember: b.mutation({
688
767
  query: (args) => (norbix) => norbix.hub.account.sendInviteToTeamMember(args),
689
768
  invalidatesTags: ["Account"]
@@ -859,6 +938,18 @@ var hubApikeys = (b) => ({
859
938
  });
860
939
 
861
940
  // src/hooks/hub/database.ts
941
+ var recordsTag = (arg) => [
942
+ {
943
+ type: "DatabaseRecords",
944
+ id: arg?.collectionName ?? "ANY"
945
+ }
946
+ ];
947
+ var termsTag = (arg) => [
948
+ {
949
+ type: "DatabaseTaxonomyTerms",
950
+ id: arg?.taxonomyName ?? "ANY"
951
+ }
952
+ ];
862
953
  var hubDatabase = (b) => ({
863
954
  disableDatabase: b.mutation({
864
955
  query: (args) => (norbix) => norbix.hub.database.disableDatabase(args),
@@ -1035,6 +1126,134 @@ var hubDatabase = (b) => ({
1035
1126
  testDatabaseAggregate: b.mutation({
1036
1127
  query: (args) => (norbix) => norbix.hub.database.testDatabaseAggregate(args),
1037
1128
  invalidatesTags: ["DatabaseAggregates"]
1129
+ }),
1130
+ // ---- Records (Hub data browser: same operations as api.database, admin-scoped) ----
1131
+ findRecords: b.query({
1132
+ query: (args) => (norbix) => norbix.hub.database.findRecords(args),
1133
+ providesTags: (_res, _err, arg) => recordsTag(arg)
1134
+ }),
1135
+ findOneRecord: b.query({
1136
+ query: (args) => (norbix) => norbix.hub.database.findOneRecord(args),
1137
+ providesTags: (_res, _err, arg) => recordsTag(arg)
1138
+ }),
1139
+ countRecords: b.query({
1140
+ query: (args) => (norbix) => norbix.hub.database.countRecords(args),
1141
+ providesTags: (_res, _err, arg) => recordsTag(arg)
1142
+ }),
1143
+ distinctRecordValues: b.query({
1144
+ query: (args) => (norbix) => norbix.hub.database.distinctRecordValues(args),
1145
+ providesTags: (_res, _err, arg) => recordsTag(arg)
1146
+ }),
1147
+ // Aggregations run a pipeline on demand: mutations, so the answer is never served from cache.
1148
+ aggregateRecords: b.mutation({
1149
+ query: (args) => (norbix) => norbix.hub.database.aggregateRecords(args)
1150
+ }),
1151
+ executeRecordsAggregate: b.mutation({
1152
+ query: (args) => (norbix) => norbix.hub.database.executeRecordsAggregate(args)
1153
+ }),
1154
+ getCollectionIndexes: b.query({
1155
+ query: (args) => (norbix) => norbix.hub.database.getCollectionIndexes(args),
1156
+ providesTags: (_res, _err, arg) => [
1157
+ {
1158
+ type: "DatabaseCollections",
1159
+ id: arg?.collectionName ?? "ANY"
1160
+ }
1161
+ ]
1162
+ }),
1163
+ insertRecord: b.mutation({
1164
+ query: (args) => (norbix) => norbix.hub.database.insertRecord(args),
1165
+ invalidatesTags: (_res, _err, arg) => recordsTag(arg)
1166
+ }),
1167
+ insertManyRecords: b.mutation({
1168
+ query: (args) => (norbix) => norbix.hub.database.insertManyRecords(args),
1169
+ invalidatesTags: (_res, _err, arg) => recordsTag(arg)
1170
+ }),
1171
+ updateOneRecord: b.mutation({
1172
+ query: (args) => (norbix) => norbix.hub.database.updateOneRecord(args),
1173
+ invalidatesTags: (_res, _err, arg) => recordsTag(arg)
1174
+ }),
1175
+ updateManyRecords: b.mutation({
1176
+ query: (args) => (norbix) => norbix.hub.database.updateManyRecords(args),
1177
+ invalidatesTags: (_res, _err, arg) => recordsTag(arg)
1178
+ }),
1179
+ replaceRecord: b.mutation({
1180
+ query: (args) => (norbix) => norbix.hub.database.replaceRecord(args),
1181
+ invalidatesTags: (_res, _err, arg) => recordsTag(arg)
1182
+ }),
1183
+ deleteRecord: b.mutation({
1184
+ query: (args) => (norbix) => norbix.hub.database.deleteRecord(args),
1185
+ invalidatesTags: (_res, _err, arg) => recordsTag(arg)
1186
+ }),
1187
+ deleteManyRecords: b.mutation({
1188
+ query: (args) => (norbix) => norbix.hub.database.deleteManyRecords(args),
1189
+ invalidatesTags: (_res, _err, arg) => recordsTag(arg)
1190
+ }),
1191
+ changeRecordResponsibility: b.mutation({
1192
+ query: (args) => (norbix) => norbix.hub.database.changeRecordResponsibility(args),
1193
+ invalidatesTags: (_res, _err, arg) => recordsTag(arg)
1194
+ }),
1195
+ // Seeds several collections at once (`collections` is a JSON map), so every record list is stale.
1196
+ seedCollectionRecords: b.mutation({
1197
+ query: (args) => (norbix) => norbix.hub.database.seedCollectionRecords(args),
1198
+ invalidatesTags: ["DatabaseRecords"]
1199
+ }),
1200
+ // ---- Taxonomy trees ----
1201
+ getDatabaseTaxonomyTree: b.query({
1202
+ query: (args) => (norbix) => norbix.hub.database.getDatabaseTaxonomyTree(args),
1203
+ providesTags: ["DatabaseTaxonomies", "DatabaseTaxonomyTerms"]
1204
+ }),
1205
+ getDatabaseTaxonomyTermTree: b.query({
1206
+ query: (args) => (norbix) => norbix.hub.database.getDatabaseTaxonomyTermTree(args),
1207
+ providesTags: (_res, _err, arg) => termsTag(arg)
1208
+ }),
1209
+ // One tree across related taxonomies (Countries + Cities: each country with its cities).
1210
+ getDatabaseMergedTermTree: b.query({
1211
+ query: (args) => (norbix) => norbix.hub.database.getDatabaseMergedTermTree(args),
1212
+ providesTags: (_res, _err, arg) => termsTag(arg)
1213
+ }),
1214
+ // ---- Schema bundle, embed and list settings ----
1215
+ // A bundle can create schemas, taxonomies and terms in one call.
1216
+ applyDatabaseSchemaBundle: b.mutation({
1217
+ query: (args) => (norbix) => norbix.hub.database.applyDatabaseSchemaBundle(args),
1218
+ invalidatesTags: ["DatabaseSchemas", "DatabaseTaxonomies", "DatabaseTaxonomyTerms"]
1219
+ }),
1220
+ updateDatabaseSchemaEmbed: b.mutation({
1221
+ query: (args) => (norbix) => norbix.hub.database.updateDatabaseSchemaEmbed(args),
1222
+ invalidatesTags: ["DatabaseSchemas"]
1223
+ }),
1224
+ getDatabaseSchemaListSettings: b.query({
1225
+ query: (args) => (norbix) => norbix.hub.database.getDatabaseSchemaListSettings(args),
1226
+ providesTags: ["DatabaseSchemas"]
1227
+ }),
1228
+ updateDatabaseSchemaListSettings: b.mutation({
1229
+ query: (args) => (norbix) => norbix.hub.database.updateDatabaseSchemaListSettings(args),
1230
+ invalidatesTags: ["DatabaseSchemas"]
1231
+ }),
1232
+ // ---- Collection imports (CSV) ----
1233
+ getCollectionImports: b.query({
1234
+ query: (args) => (norbix) => norbix.hub.database.getCollectionImports(args),
1235
+ providesTags: ["DatabaseImports"]
1236
+ }),
1237
+ getCollectionImport: b.query({
1238
+ query: (args) => (norbix) => norbix.hub.database.getCollectionImport(args),
1239
+ providesTags: ["DatabaseImports"]
1240
+ }),
1241
+ // An import writes records into the target collection.
1242
+ createCollectionImport: b.mutation({
1243
+ query: (args) => (norbix) => norbix.hub.database.createCollectionImport(args),
1244
+ invalidatesTags: (_res, _err, arg) => [{ type: "DatabaseImports" }, ...recordsTag(arg)]
1245
+ }),
1246
+ deleteCollectionImport: b.mutation({
1247
+ query: (args) => (norbix) => norbix.hub.database.deleteCollectionImport(args),
1248
+ invalidatesTags: ["DatabaseImports"]
1249
+ }),
1250
+ // Reads the uploaded file and suggests a column mapping; saves nothing.
1251
+ analyzeImportFile: b.mutation({
1252
+ query: (args) => (norbix) => norbix.hub.database.analyzeImportFile(args)
1253
+ }),
1254
+ // Returns a one-time signed upload URL; saves nothing.
1255
+ requestImportUploadUrl: b.mutation({
1256
+ query: (args) => (norbix) => norbix.hub.database.requestImportUploadUrl(args)
1038
1257
  })
1039
1258
  });
1040
1259