@redacto.io/consent-sdk-react-native 5.0.0-beta.4 → 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;
@@ -11256,7 +11256,8 @@ var manageConsent = async ({
11256
11256
  nominatorContact,
11257
11257
  dataElementUuids,
11258
11258
  noticeUuid,
11259
- dataElements
11259
+ dataElements,
11260
+ language
11260
11261
  });
11261
11262
  }
11262
11263
  console.error(`Error ${action} consent:`, error);
@@ -14335,6 +14336,7 @@ var useTimePeriodOptions = () => {
14335
14336
  var MAX_DISPLAYED_PURPOSE_NAMES_IN_ERASURE_MODAL = 3;
14336
14337
  var SEARCH_DEBOUNCE_DELAY = 500;
14337
14338
  var FORM_PICKER_GROUP_LIMIT = 100;
14339
+ var LEGACY_PRODUCT_GROUP_UUID = "__legacy_flat_purposes__";
14338
14340
  var POLL_INTERVAL = 3e4;
14339
14341
  var NOTIFICATION_PAGE_SIZE = 10;
14340
14342
  var TAB_TO_CATEGORY = {
@@ -16326,19 +16328,32 @@ var consentGroupToFormProductGroup = (group) => {
16326
16328
  };
16327
16329
  };
16328
16330
  var purposeItemToFormPurpose = (purpose) => {
16329
- var _a3, _b;
16331
+ var _a3, _b, _c, _d, _e, _f;
16330
16332
  return {
16331
- uuid: purpose.purpose_uuid,
16332
- 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 : "",
16333
16338
  name: purpose.name,
16334
- description: (_a3 = purpose.description) != null ? _a3 : "",
16339
+ description: (_e = purpose.description) != null ? _e : "",
16335
16340
  industries: "",
16336
16341
  selected: false,
16337
16342
  given_consent: false,
16338
16343
  status: purpose.status,
16339
16344
  validity: null,
16340
16345
  enabled: true,
16341
- 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))
16342
16357
  };
16343
16358
  };
16344
16359
  var consentDataElementToFormDataElement = (element) => ({
@@ -16384,7 +16399,7 @@ var isProductScopedRequestType = (rt) => PRODUCT_SCOPED_REQUEST_TYPES.has(rt);
16384
16399
  function Form({ onCreateRequest }) {
16385
16400
  const { t } = (0, import_react_i18next16.useTranslation)();
16386
16401
  const { accessToken, refreshToken, email, organizationId, workspaceId, updateTokens, onError } = useAuth();
16387
- const { consentClient, baseUrl, ledgerBaseUrl } = useBaseUrl();
16402
+ const { consentClient, baseUrl } = useBaseUrl();
16388
16403
  const { colors } = useTheme();
16389
16404
  const requestTypeLabels = useRequestTypeLabels();
16390
16405
  const timePeriodOptions = useTimePeriodOptions();
@@ -16421,10 +16436,10 @@ function Form({ onCreateRequest }) {
16421
16436
  });
16422
16437
  const [uploadedDocs, setUploadedDocs] = (0, import_react29.useState)([]);
16423
16438
  const [isUploading, setIsUploading] = (0, import_react29.useState)(false);
16424
- const withLedgerPickerGroups = (0, import_react29.useCallback)(
16439
+ const withUserConsentPickerGroups = (0, import_react29.useCallback)(
16425
16440
  async (form, language) => {
16426
16441
  var _a3, _b;
16427
- if (!ledgerBaseUrl || !organizationId || !workspaceId) {
16442
+ if (!organizationId || !workspaceId) {
16428
16443
  return form;
16429
16444
  }
16430
16445
  const consents = await fetchUserConsents({
@@ -16439,16 +16454,18 @@ function Form({ onCreateRequest }) {
16439
16454
  authContext,
16440
16455
  consentClient
16441
16456
  });
16442
- 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) {
16443
16460
  return form;
16444
16461
  }
16445
16462
  return {
16446
16463
  ...form,
16447
- direct_groups: ((_a3 = consents.direct) != null ? _a3 : []).map(consentGroupToFormProductGroup),
16448
- nominated_groups: ((_b = consents.nominated) != null ? _b : []).map(consentGroupToFormProductGroup)
16464
+ direct_groups: direct.map(consentGroupToFormProductGroup),
16465
+ nominated_groups: nominated.map(consentGroupToFormProductGroup)
16449
16466
  };
16450
16467
  },
16451
- [ledgerBaseUrl, organizationId, workspaceId, authContext, consentClient]
16468
+ [organizationId, workspaceId, authContext, consentClient]
16452
16469
  );
16453
16470
  (0, import_react29.useEffect)(() => {
16454
16471
  if (!organizationId || !workspaceId || !contact) return;
@@ -16456,7 +16473,7 @@ function Form({ onCreateRequest }) {
16456
16473
  setIsLoading(true);
16457
16474
  getFormData(organizationId, workspaceId, contact, false, false, authContext, consentClient, langParam).then(async (data) => {
16458
16475
  if (!data) return;
16459
- const withGroups = await withLedgerPickerGroups(data, langParam);
16476
+ const withGroups = await withUserConsentPickerGroups(data, langParam);
16460
16477
  if (!isCancelled) setFormDataResponse(withGroups);
16461
16478
  }).catch((error) => {
16462
16479
  console.warn("Error fetching form data:", error);
@@ -16473,16 +16490,24 @@ function Form({ onCreateRequest }) {
16473
16490
  authContext,
16474
16491
  consentClient,
16475
16492
  langParam,
16476
- withLedgerPickerGroups
16493
+ withUserConsentPickerGroups
16477
16494
  ]);
16478
16495
  const allGroups = (0, import_react29.useMemo)(() => {
16479
16496
  var _a3, _b;
16480
16497
  if (!formDataResponse) return [];
16481
- return [
16498
+ const groups = [
16482
16499
  ...(_a3 = formDataResponse.direct_groups) != null ? _a3 : [],
16483
16500
  ...(_b = formDataResponse.nominated_groups) != null ? _b : []
16484
16501
  ];
16485
- }, [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]);
16486
16511
  const skipProductStep = allGroups.length === 1;
16487
16512
  const selectedGroup = (0, import_react29.useMemo)(() => {
16488
16513
  var _a3, _b;
@@ -16688,6 +16713,11 @@ function Form({ onCreateRequest }) {
16688
16713
  const isFormValid = (0, import_react29.useMemo)(() => detailsValid && confirmChecked, [detailsValid, confirmChecked]);
16689
16714
  const handleUpload = (0, import_react29.useCallback)(async () => {
16690
16715
  if (!organizationId || !workspaceId) return;
16716
+ const caseUuid = formDataResponse == null ? void 0 : formDataResponse.uuid;
16717
+ if (!caseUuid) {
16718
+ import_react_native44.Alert.alert(t("uploadFile"), t("unableToUpload") || "Unable to upload file. Please try again.");
16719
+ return;
16720
+ }
16691
16721
  try {
16692
16722
  const file = await pickFile();
16693
16723
  if (!file) return;
@@ -16704,11 +16734,11 @@ function Form({ onCreateRequest }) {
16704
16734
  "payload",
16705
16735
  JSON.stringify({
16706
16736
  organization_uuid: organizationId || "",
16707
- space: `privacy/${docUuid}`,
16737
+ space: `privacy/${caseUuid}`,
16708
16738
  uuid: docUuid,
16709
16739
  is_public: true,
16710
16740
  allow_ai_processing: true,
16711
- metadata: { group_by: "privacy", product: "privacy_center" }
16741
+ metadata: { group_by: "privacy", case_uuid: caseUuid, product: "privacy_center" }
16712
16742
  })
16713
16743
  );
16714
16744
  const result = await uploadFileWithS2S({
@@ -16728,7 +16758,7 @@ function Form({ onCreateRequest }) {
16728
16758
  } finally {
16729
16759
  setIsUploading(false);
16730
16760
  }
16731
- }, [organizationId, workspaceId, authContext, consentClient, baseUrl, t]);
16761
+ }, [organizationId, workspaceId, authContext, consentClient, baseUrl, t, formDataResponse]);
16732
16762
  const removeUploadedDoc = (0, import_react29.useCallback)((uuid) => {
16733
16763
  setUploadedDocs((prev) => prev.filter((d) => d.uuid !== uuid));
16734
16764
  }, []);
@@ -16739,7 +16769,8 @@ function Form({ onCreateRequest }) {
16739
16769
  setIsSubmitting(true);
16740
16770
  try {
16741
16771
  const isProductScoped = isProductScopedRequestType(requestType);
16742
- 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;
16743
16774
  const updatePurposes = Array.from(selectedPurposes).map((uuid) => ({
16744
16775
  purpose_uuid: uuid,
16745
16776
  data_element_uuids: Array.from(selectedDataElements.get(uuid) || [])
@@ -11143,7 +11143,8 @@ var manageConsent = async ({
11143
11143
  nominatorContact,
11144
11144
  dataElementUuids,
11145
11145
  noticeUuid,
11146
- dataElements
11146
+ dataElements,
11147
+ language
11147
11148
  });
11148
11149
  }
11149
11150
  console.error(`Error ${action} consent:`, error);
@@ -14309,6 +14310,7 @@ var useTimePeriodOptions = () => {
14309
14310
  var MAX_DISPLAYED_PURPOSE_NAMES_IN_ERASURE_MODAL = 3;
14310
14311
  var SEARCH_DEBOUNCE_DELAY = 500;
14311
14312
  var FORM_PICKER_GROUP_LIMIT = 100;
14313
+ var LEGACY_PRODUCT_GROUP_UUID = "__legacy_flat_purposes__";
14312
14314
  var POLL_INTERVAL = 3e4;
14313
14315
  var NOTIFICATION_PAGE_SIZE = 10;
14314
14316
  var TAB_TO_CATEGORY = {
@@ -16323,19 +16325,32 @@ var consentGroupToFormProductGroup = (group) => {
16323
16325
  };
16324
16326
  };
16325
16327
  var purposeItemToFormPurpose = (purpose) => {
16326
- var _a3, _b;
16328
+ var _a3, _b, _c, _d, _e, _f;
16327
16329
  return {
16328
- uuid: purpose.purpose_uuid,
16329
- 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 : "",
16330
16335
  name: purpose.name,
16331
- description: (_a3 = purpose.description) != null ? _a3 : "",
16336
+ description: (_e = purpose.description) != null ? _e : "",
16332
16337
  industries: "",
16333
16338
  selected: false,
16334
16339
  given_consent: false,
16335
16340
  status: purpose.status,
16336
16341
  validity: null,
16337
16342
  enabled: true,
16338
- 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))
16339
16354
  };
16340
16355
  };
16341
16356
  var consentDataElementToFormDataElement = (element) => ({
@@ -16381,7 +16396,7 @@ var isProductScopedRequestType = (rt) => PRODUCT_SCOPED_REQUEST_TYPES.has(rt);
16381
16396
  function Form({ onCreateRequest }) {
16382
16397
  const { t } = useTranslation15();
16383
16398
  const { accessToken, refreshToken, email, organizationId, workspaceId, updateTokens, onError } = useAuth();
16384
- const { consentClient, baseUrl, ledgerBaseUrl } = useBaseUrl();
16399
+ const { consentClient, baseUrl } = useBaseUrl();
16385
16400
  const { colors } = useTheme();
16386
16401
  const requestTypeLabels = useRequestTypeLabels();
16387
16402
  const timePeriodOptions = useTimePeriodOptions();
@@ -16418,10 +16433,10 @@ function Form({ onCreateRequest }) {
16418
16433
  });
16419
16434
  const [uploadedDocs, setUploadedDocs] = useState16([]);
16420
16435
  const [isUploading, setIsUploading] = useState16(false);
16421
- const withLedgerPickerGroups = useCallback10(
16436
+ const withUserConsentPickerGroups = useCallback10(
16422
16437
  async (form, language) => {
16423
16438
  var _a3, _b;
16424
- if (!ledgerBaseUrl || !organizationId || !workspaceId) {
16439
+ if (!organizationId || !workspaceId) {
16425
16440
  return form;
16426
16441
  }
16427
16442
  const consents = await fetchUserConsents({
@@ -16436,16 +16451,18 @@ function Form({ onCreateRequest }) {
16436
16451
  authContext,
16437
16452
  consentClient
16438
16453
  });
16439
- 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) {
16440
16457
  return form;
16441
16458
  }
16442
16459
  return {
16443
16460
  ...form,
16444
- direct_groups: ((_a3 = consents.direct) != null ? _a3 : []).map(consentGroupToFormProductGroup),
16445
- nominated_groups: ((_b = consents.nominated) != null ? _b : []).map(consentGroupToFormProductGroup)
16461
+ direct_groups: direct.map(consentGroupToFormProductGroup),
16462
+ nominated_groups: nominated.map(consentGroupToFormProductGroup)
16446
16463
  };
16447
16464
  },
16448
- [ledgerBaseUrl, organizationId, workspaceId, authContext, consentClient]
16465
+ [organizationId, workspaceId, authContext, consentClient]
16449
16466
  );
16450
16467
  useEffect14(() => {
16451
16468
  if (!organizationId || !workspaceId || !contact) return;
@@ -16453,7 +16470,7 @@ function Form({ onCreateRequest }) {
16453
16470
  setIsLoading(true);
16454
16471
  getFormData(organizationId, workspaceId, contact, false, false, authContext, consentClient, langParam).then(async (data) => {
16455
16472
  if (!data) return;
16456
- const withGroups = await withLedgerPickerGroups(data, langParam);
16473
+ const withGroups = await withUserConsentPickerGroups(data, langParam);
16457
16474
  if (!isCancelled) setFormDataResponse(withGroups);
16458
16475
  }).catch((error) => {
16459
16476
  console.warn("Error fetching form data:", error);
@@ -16470,16 +16487,24 @@ function Form({ onCreateRequest }) {
16470
16487
  authContext,
16471
16488
  consentClient,
16472
16489
  langParam,
16473
- withLedgerPickerGroups
16490
+ withUserConsentPickerGroups
16474
16491
  ]);
16475
16492
  const allGroups = useMemo14(() => {
16476
16493
  var _a3, _b;
16477
16494
  if (!formDataResponse) return [];
16478
- return [
16495
+ const groups = [
16479
16496
  ...(_a3 = formDataResponse.direct_groups) != null ? _a3 : [],
16480
16497
  ...(_b = formDataResponse.nominated_groups) != null ? _b : []
16481
16498
  ];
16482
- }, [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]);
16483
16508
  const skipProductStep = allGroups.length === 1;
16484
16509
  const selectedGroup = useMemo14(() => {
16485
16510
  var _a3, _b;
@@ -16685,6 +16710,11 @@ function Form({ onCreateRequest }) {
16685
16710
  const isFormValid = useMemo14(() => detailsValid && confirmChecked, [detailsValid, confirmChecked]);
16686
16711
  const handleUpload = useCallback10(async () => {
16687
16712
  if (!organizationId || !workspaceId) return;
16713
+ const caseUuid = formDataResponse == null ? void 0 : formDataResponse.uuid;
16714
+ if (!caseUuid) {
16715
+ Alert5.alert(t("uploadFile"), t("unableToUpload") || "Unable to upload file. Please try again.");
16716
+ return;
16717
+ }
16688
16718
  try {
16689
16719
  const file = await pickFile();
16690
16720
  if (!file) return;
@@ -16701,11 +16731,11 @@ function Form({ onCreateRequest }) {
16701
16731
  "payload",
16702
16732
  JSON.stringify({
16703
16733
  organization_uuid: organizationId || "",
16704
- space: `privacy/${docUuid}`,
16734
+ space: `privacy/${caseUuid}`,
16705
16735
  uuid: docUuid,
16706
16736
  is_public: true,
16707
16737
  allow_ai_processing: true,
16708
- metadata: { group_by: "privacy", product: "privacy_center" }
16738
+ metadata: { group_by: "privacy", case_uuid: caseUuid, product: "privacy_center" }
16709
16739
  })
16710
16740
  );
16711
16741
  const result = await uploadFileWithS2S({
@@ -16725,7 +16755,7 @@ function Form({ onCreateRequest }) {
16725
16755
  } finally {
16726
16756
  setIsUploading(false);
16727
16757
  }
16728
- }, [organizationId, workspaceId, authContext, consentClient, baseUrl, t]);
16758
+ }, [organizationId, workspaceId, authContext, consentClient, baseUrl, t, formDataResponse]);
16729
16759
  const removeUploadedDoc = useCallback10((uuid) => {
16730
16760
  setUploadedDocs((prev) => prev.filter((d) => d.uuid !== uuid));
16731
16761
  }, []);
@@ -16736,7 +16766,8 @@ function Form({ onCreateRequest }) {
16736
16766
  setIsSubmitting(true);
16737
16767
  try {
16738
16768
  const isProductScoped = isProductScopedRequestType(requestType);
16739
- 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;
16740
16771
  const updatePurposes = Array.from(selectedPurposes).map((uuid) => ({
16741
16772
  purpose_uuid: uuid,
16742
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.4",
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",