@redacto.io/consent-sdk-react-native 5.0.0-beta.5 → 5.0.0-beta.6

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.
@@ -319,6 +319,12 @@ type ConsentHistoryStatusSummary = {
319
319
  };
320
320
  type PurposeItem = {
321
321
  purpose_uuid: string;
322
+ /**
323
+ * Alias emitted by the legacy Python user-consents payload, which keys some
324
+ * purposes as `uuid` instead of `purpose_uuid`. Optional: the Go ledger
325
+ * always sends `purpose_uuid`.
326
+ */
327
+ uuid?: string;
322
328
  name: string;
323
329
  description: string | null;
324
330
  status: ConsentStatusEnum | string;
@@ -319,6 +319,12 @@ type ConsentHistoryStatusSummary = {
319
319
  };
320
320
  type PurposeItem = {
321
321
  purpose_uuid: string;
322
+ /**
323
+ * Alias emitted by the legacy Python user-consents payload, which keys some
324
+ * purposes as `uuid` instead of `purpose_uuid`. Optional: the Go ledger
325
+ * always sends `purpose_uuid`.
326
+ */
327
+ uuid?: string;
322
328
  name: string;
323
329
  description: string | null;
324
330
  status: ConsentStatusEnum | string;
@@ -14336,6 +14336,7 @@ var useTimePeriodOptions = () => {
14336
14336
  var MAX_DISPLAYED_PURPOSE_NAMES_IN_ERASURE_MODAL = 3;
14337
14337
  var SEARCH_DEBOUNCE_DELAY = 500;
14338
14338
  var FORM_PICKER_GROUP_LIMIT = 100;
14339
+ var LEGACY_PRODUCT_GROUP_UUID = "__legacy_flat_purposes__";
14339
14340
  var POLL_INTERVAL = 3e4;
14340
14341
  var NOTIFICATION_PAGE_SIZE = 10;
14341
14342
  var TAB_TO_CATEGORY = {
@@ -16327,19 +16328,32 @@ var consentGroupToFormProductGroup = (group) => {
16327
16328
  };
16328
16329
  };
16329
16330
  var purposeItemToFormPurpose = (purpose) => {
16330
- var _a3, _b;
16331
+ var _a3, _b, _c, _d, _e, _f;
16331
16332
  return {
16332
- uuid: purpose.purpose_uuid,
16333
- purpose_uuid: purpose.purpose_uuid,
16333
+ // The ledger keys purposes as `purpose_uuid`; the legacy Python
16334
+ // user-consents payload keys some of them as `uuid`. Accept either so the
16335
+ // picker and the submitted `purpose_uuid` resolve on both backends.
16336
+ uuid: (_b = (_a3 = purpose.purpose_uuid) != null ? _a3 : purpose.uuid) != null ? _b : "",
16337
+ purpose_uuid: (_d = (_c = purpose.purpose_uuid) != null ? _c : purpose.uuid) != null ? _d : "",
16334
16338
  name: purpose.name,
16335
- description: (_a3 = purpose.description) != null ? _a3 : "",
16339
+ description: (_e = purpose.description) != null ? _e : "",
16336
16340
  industries: "",
16337
16341
  selected: false,
16338
16342
  given_consent: false,
16339
16343
  status: purpose.status,
16340
16344
  validity: null,
16341
16345
  enabled: true,
16342
- data_elements: ((_b = purpose.data_elements) != null ? _b : []).map(consentDataElementToFormDataElement)
16346
+ data_elements: ((_f = purpose.data_elements) != null ? _f : []).map(consentDataElementToFormDataElement)
16347
+ };
16348
+ };
16349
+ var legacyFlatGroup = (form, label) => {
16350
+ var _a3;
16351
+ return {
16352
+ product_uuid: LEGACY_PRODUCT_GROUP_UUID,
16353
+ product_name: label,
16354
+ product_description: null,
16355
+ nominator: null,
16356
+ purposes: ((_a3 = form.purposes) != null ? _a3 : []).map((wrapper) => wrapper == null ? void 0 : wrapper.purpose).filter((purpose) => Boolean(purpose))
16343
16357
  };
16344
16358
  };
16345
16359
  var consentDataElementToFormDataElement = (element) => ({
@@ -16385,7 +16399,7 @@ var isProductScopedRequestType = (rt) => PRODUCT_SCOPED_REQUEST_TYPES.has(rt);
16385
16399
  function Form({ onCreateRequest }) {
16386
16400
  const { t } = (0, import_react_i18next16.useTranslation)();
16387
16401
  const { accessToken, refreshToken, email, organizationId, workspaceId, updateTokens, onError } = useAuth();
16388
- const { consentClient, baseUrl, ledgerBaseUrl } = useBaseUrl();
16402
+ const { consentClient, baseUrl } = useBaseUrl();
16389
16403
  const { colors } = useTheme();
16390
16404
  const requestTypeLabels = useRequestTypeLabels();
16391
16405
  const timePeriodOptions = useTimePeriodOptions();
@@ -16422,10 +16436,10 @@ function Form({ onCreateRequest }) {
16422
16436
  });
16423
16437
  const [uploadedDocs, setUploadedDocs] = (0, import_react29.useState)([]);
16424
16438
  const [isUploading, setIsUploading] = (0, import_react29.useState)(false);
16425
- const withLedgerPickerGroups = (0, import_react29.useCallback)(
16439
+ const withUserConsentPickerGroups = (0, import_react29.useCallback)(
16426
16440
  async (form, language) => {
16427
16441
  var _a3, _b;
16428
- if (!ledgerBaseUrl || !organizationId || !workspaceId) {
16442
+ if (!organizationId || !workspaceId) {
16429
16443
  return form;
16430
16444
  }
16431
16445
  const consents = await fetchUserConsents({
@@ -16440,16 +16454,18 @@ function Form({ onCreateRequest }) {
16440
16454
  authContext,
16441
16455
  consentClient
16442
16456
  });
16443
- if (!consents) {
16457
+ const direct = (_a3 = consents == null ? void 0 : consents.direct) != null ? _a3 : [];
16458
+ const nominated = (_b = consents == null ? void 0 : consents.nominated) != null ? _b : [];
16459
+ if (direct.length === 0 && nominated.length === 0) {
16444
16460
  return form;
16445
16461
  }
16446
16462
  return {
16447
16463
  ...form,
16448
- direct_groups: ((_a3 = consents.direct) != null ? _a3 : []).map(consentGroupToFormProductGroup),
16449
- nominated_groups: ((_b = consents.nominated) != null ? _b : []).map(consentGroupToFormProductGroup)
16464
+ direct_groups: direct.map(consentGroupToFormProductGroup),
16465
+ nominated_groups: nominated.map(consentGroupToFormProductGroup)
16450
16466
  };
16451
16467
  },
16452
- [ledgerBaseUrl, organizationId, workspaceId, authContext, consentClient]
16468
+ [organizationId, workspaceId, authContext, consentClient]
16453
16469
  );
16454
16470
  (0, import_react29.useEffect)(() => {
16455
16471
  if (!organizationId || !workspaceId || !contact) return;
@@ -16457,7 +16473,7 @@ function Form({ onCreateRequest }) {
16457
16473
  setIsLoading(true);
16458
16474
  getFormData(organizationId, workspaceId, contact, false, false, authContext, consentClient, langParam).then(async (data) => {
16459
16475
  if (!data) return;
16460
- const withGroups = await withLedgerPickerGroups(data, langParam);
16476
+ const withGroups = await withUserConsentPickerGroups(data, langParam);
16461
16477
  if (!isCancelled) setFormDataResponse(withGroups);
16462
16478
  }).catch((error) => {
16463
16479
  console.warn("Error fetching form data:", error);
@@ -16474,16 +16490,24 @@ function Form({ onCreateRequest }) {
16474
16490
  authContext,
16475
16491
  consentClient,
16476
16492
  langParam,
16477
- withLedgerPickerGroups
16493
+ withUserConsentPickerGroups
16478
16494
  ]);
16479
16495
  const allGroups = (0, import_react29.useMemo)(() => {
16480
16496
  var _a3, _b;
16481
16497
  if (!formDataResponse) return [];
16482
- return [
16498
+ const groups = [
16483
16499
  ...(_a3 = formDataResponse.direct_groups) != null ? _a3 : [],
16484
16500
  ...(_b = formDataResponse.nominated_groups) != null ? _b : []
16485
16501
  ];
16486
- }, [formDataResponse]);
16502
+ if (groups.length > 0) {
16503
+ return groups;
16504
+ }
16505
+ const flatGroup = legacyFlatGroup(formDataResponse, t("yourData"));
16506
+ if (buildGroupPurposes(flatGroup).length === 0) {
16507
+ return [];
16508
+ }
16509
+ return [flatGroup];
16510
+ }, [formDataResponse, t]);
16487
16511
  const skipProductStep = allGroups.length === 1;
16488
16512
  const selectedGroup = (0, import_react29.useMemo)(() => {
16489
16513
  var _a3, _b;
@@ -16745,7 +16769,8 @@ function Form({ onCreateRequest }) {
16745
16769
  setIsSubmitting(true);
16746
16770
  try {
16747
16771
  const isProductScoped = isProductScopedRequestType(requestType);
16748
- const anchorGroup = isProductScoped ? selectedGroup : null;
16772
+ const isLegacyFlatSelection = (selectedGroup == null ? void 0 : selectedGroup.product_uuid) === LEGACY_PRODUCT_GROUP_UUID;
16773
+ const anchorGroup = isProductScoped && !isLegacyFlatSelection ? selectedGroup : null;
16749
16774
  const updatePurposes = Array.from(selectedPurposes).map((uuid) => ({
16750
16775
  purpose_uuid: uuid,
16751
16776
  data_element_uuids: Array.from(selectedDataElements.get(uuid) || [])
@@ -14310,6 +14310,7 @@ var useTimePeriodOptions = () => {
14310
14310
  var MAX_DISPLAYED_PURPOSE_NAMES_IN_ERASURE_MODAL = 3;
14311
14311
  var SEARCH_DEBOUNCE_DELAY = 500;
14312
14312
  var FORM_PICKER_GROUP_LIMIT = 100;
14313
+ var LEGACY_PRODUCT_GROUP_UUID = "__legacy_flat_purposes__";
14313
14314
  var POLL_INTERVAL = 3e4;
14314
14315
  var NOTIFICATION_PAGE_SIZE = 10;
14315
14316
  var TAB_TO_CATEGORY = {
@@ -16324,19 +16325,32 @@ var consentGroupToFormProductGroup = (group) => {
16324
16325
  };
16325
16326
  };
16326
16327
  var purposeItemToFormPurpose = (purpose) => {
16327
- var _a3, _b;
16328
+ var _a3, _b, _c, _d, _e, _f;
16328
16329
  return {
16329
- uuid: purpose.purpose_uuid,
16330
- purpose_uuid: purpose.purpose_uuid,
16330
+ // The ledger keys purposes as `purpose_uuid`; the legacy Python
16331
+ // user-consents payload keys some of them as `uuid`. Accept either so the
16332
+ // picker and the submitted `purpose_uuid` resolve on both backends.
16333
+ uuid: (_b = (_a3 = purpose.purpose_uuid) != null ? _a3 : purpose.uuid) != null ? _b : "",
16334
+ purpose_uuid: (_d = (_c = purpose.purpose_uuid) != null ? _c : purpose.uuid) != null ? _d : "",
16331
16335
  name: purpose.name,
16332
- description: (_a3 = purpose.description) != null ? _a3 : "",
16336
+ description: (_e = purpose.description) != null ? _e : "",
16333
16337
  industries: "",
16334
16338
  selected: false,
16335
16339
  given_consent: false,
16336
16340
  status: purpose.status,
16337
16341
  validity: null,
16338
16342
  enabled: true,
16339
- data_elements: ((_b = purpose.data_elements) != null ? _b : []).map(consentDataElementToFormDataElement)
16343
+ data_elements: ((_f = purpose.data_elements) != null ? _f : []).map(consentDataElementToFormDataElement)
16344
+ };
16345
+ };
16346
+ var legacyFlatGroup = (form, label) => {
16347
+ var _a3;
16348
+ return {
16349
+ product_uuid: LEGACY_PRODUCT_GROUP_UUID,
16350
+ product_name: label,
16351
+ product_description: null,
16352
+ nominator: null,
16353
+ purposes: ((_a3 = form.purposes) != null ? _a3 : []).map((wrapper) => wrapper == null ? void 0 : wrapper.purpose).filter((purpose) => Boolean(purpose))
16340
16354
  };
16341
16355
  };
16342
16356
  var consentDataElementToFormDataElement = (element) => ({
@@ -16382,7 +16396,7 @@ var isProductScopedRequestType = (rt) => PRODUCT_SCOPED_REQUEST_TYPES.has(rt);
16382
16396
  function Form({ onCreateRequest }) {
16383
16397
  const { t } = useTranslation15();
16384
16398
  const { accessToken, refreshToken, email, organizationId, workspaceId, updateTokens, onError } = useAuth();
16385
- const { consentClient, baseUrl, ledgerBaseUrl } = useBaseUrl();
16399
+ const { consentClient, baseUrl } = useBaseUrl();
16386
16400
  const { colors } = useTheme();
16387
16401
  const requestTypeLabels = useRequestTypeLabels();
16388
16402
  const timePeriodOptions = useTimePeriodOptions();
@@ -16419,10 +16433,10 @@ function Form({ onCreateRequest }) {
16419
16433
  });
16420
16434
  const [uploadedDocs, setUploadedDocs] = useState16([]);
16421
16435
  const [isUploading, setIsUploading] = useState16(false);
16422
- const withLedgerPickerGroups = useCallback10(
16436
+ const withUserConsentPickerGroups = useCallback10(
16423
16437
  async (form, language) => {
16424
16438
  var _a3, _b;
16425
- if (!ledgerBaseUrl || !organizationId || !workspaceId) {
16439
+ if (!organizationId || !workspaceId) {
16426
16440
  return form;
16427
16441
  }
16428
16442
  const consents = await fetchUserConsents({
@@ -16437,16 +16451,18 @@ function Form({ onCreateRequest }) {
16437
16451
  authContext,
16438
16452
  consentClient
16439
16453
  });
16440
- if (!consents) {
16454
+ const direct = (_a3 = consents == null ? void 0 : consents.direct) != null ? _a3 : [];
16455
+ const nominated = (_b = consents == null ? void 0 : consents.nominated) != null ? _b : [];
16456
+ if (direct.length === 0 && nominated.length === 0) {
16441
16457
  return form;
16442
16458
  }
16443
16459
  return {
16444
16460
  ...form,
16445
- direct_groups: ((_a3 = consents.direct) != null ? _a3 : []).map(consentGroupToFormProductGroup),
16446
- nominated_groups: ((_b = consents.nominated) != null ? _b : []).map(consentGroupToFormProductGroup)
16461
+ direct_groups: direct.map(consentGroupToFormProductGroup),
16462
+ nominated_groups: nominated.map(consentGroupToFormProductGroup)
16447
16463
  };
16448
16464
  },
16449
- [ledgerBaseUrl, organizationId, workspaceId, authContext, consentClient]
16465
+ [organizationId, workspaceId, authContext, consentClient]
16450
16466
  );
16451
16467
  useEffect14(() => {
16452
16468
  if (!organizationId || !workspaceId || !contact) return;
@@ -16454,7 +16470,7 @@ function Form({ onCreateRequest }) {
16454
16470
  setIsLoading(true);
16455
16471
  getFormData(organizationId, workspaceId, contact, false, false, authContext, consentClient, langParam).then(async (data) => {
16456
16472
  if (!data) return;
16457
- const withGroups = await withLedgerPickerGroups(data, langParam);
16473
+ const withGroups = await withUserConsentPickerGroups(data, langParam);
16458
16474
  if (!isCancelled) setFormDataResponse(withGroups);
16459
16475
  }).catch((error) => {
16460
16476
  console.warn("Error fetching form data:", error);
@@ -16471,16 +16487,24 @@ function Form({ onCreateRequest }) {
16471
16487
  authContext,
16472
16488
  consentClient,
16473
16489
  langParam,
16474
- withLedgerPickerGroups
16490
+ withUserConsentPickerGroups
16475
16491
  ]);
16476
16492
  const allGroups = useMemo14(() => {
16477
16493
  var _a3, _b;
16478
16494
  if (!formDataResponse) return [];
16479
- return [
16495
+ const groups = [
16480
16496
  ...(_a3 = formDataResponse.direct_groups) != null ? _a3 : [],
16481
16497
  ...(_b = formDataResponse.nominated_groups) != null ? _b : []
16482
16498
  ];
16483
- }, [formDataResponse]);
16499
+ if (groups.length > 0) {
16500
+ return groups;
16501
+ }
16502
+ const flatGroup = legacyFlatGroup(formDataResponse, t("yourData"));
16503
+ if (buildGroupPurposes(flatGroup).length === 0) {
16504
+ return [];
16505
+ }
16506
+ return [flatGroup];
16507
+ }, [formDataResponse, t]);
16484
16508
  const skipProductStep = allGroups.length === 1;
16485
16509
  const selectedGroup = useMemo14(() => {
16486
16510
  var _a3, _b;
@@ -16742,7 +16766,8 @@ function Form({ onCreateRequest }) {
16742
16766
  setIsSubmitting(true);
16743
16767
  try {
16744
16768
  const isProductScoped = isProductScopedRequestType(requestType);
16745
- const anchorGroup = isProductScoped ? selectedGroup : null;
16769
+ const isLegacyFlatSelection = (selectedGroup == null ? void 0 : selectedGroup.product_uuid) === LEGACY_PRODUCT_GROUP_UUID;
16770
+ const anchorGroup = isProductScoped && !isLegacyFlatSelection ? selectedGroup : null;
16746
16771
  const updatePurposes = Array.from(selectedPurposes).map((uuid) => ({
16747
16772
  purpose_uuid: uuid,
16748
16773
  data_element_uuids: Array.from(selectedDataElements.get(uuid) || [])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redacto.io/consent-sdk-react-native",
3
- "version": "5.0.0-beta.5",
3
+ "version": "5.0.0-beta.6",
4
4
  "description": "React Native SDK for integrating Redacto consent notices and privacy center in mobile apps.",
5
5
  "keywords": [
6
6
  "consent",