Skip to content

Commit

Permalink
create runtime types for reserved metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
csmccarthy committed Nov 21, 2023
1 parent 5439677 commit 778f74d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,16 @@ export const TrackingConsentWithNulls = t.record(
/** Type override */
export type TrackingConsentWithNulls = t.TypeOf<typeof TrackingConsent>;

const TCFReservedMetadata = t.partial({
tcString: t.string,
});

const ReservedMetadata = t.partial({
tcmp: t.partial({
tcf: TCFReservedMetadata,
}),
});

const CoreTrackingConsentDetails = t.intersection([
t.type({
/**
Expand All @@ -420,7 +430,7 @@ const CoreTrackingConsentDetails = t.intersection([
/** Whether or not the UI has been shown to the end-user (undefined in older versions of airgap.js) */
prompted: t.boolean,
/** Arbitrary metadata that customers want to be associated with consent state */
metadata: t.UnknownRecord,
metadata: t.intersection([ReservedMetadata, t.UnknownRecord]),
/** When the metadata was last updated */
metadataTimestamp: t.string,
}),
Expand Down

0 comments on commit 778f74d

Please sign in to comment.