-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bed09f
commit f5e8462
Showing
21 changed files
with
691 additions
and
269 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file renamed
BIN
+369 KB
...ypes-npm-4.96.0-b86f5e1f6c-0ed38f70c7.zip → ...ypes-npm-4.98.0-49ec094def-bee61228fa.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { GraphQLClient } from 'graphql-request'; | ||
import { PREFERENCE_TOPICS } from './gqls'; | ||
import { makeGraphQLRequest } from './makeGraphQLRequest'; | ||
import { PreferenceTopicType } from '@transcend-io/privacy-types'; | ||
|
||
export interface PreferenceTopic { | ||
/** ID of preference topic */ | ||
id: string; | ||
/** Slug of preference topic */ | ||
slug: string; | ||
/** Type of preference topic */ | ||
type: PreferenceTopicType; | ||
/** Option values */ | ||
preferenceOptionValues: { | ||
/** Slug of value */ | ||
slug: string; | ||
}[]; | ||
/** Related purpose */ | ||
purpose: { | ||
/** Slug */ | ||
trackingType: string; | ||
}; | ||
} | ||
|
||
const PAGE_SIZE = 20; | ||
|
||
/** | ||
* Fetch all preference topics in the organization | ||
* | ||
* @param client - GraphQL client | ||
* @returns All preference topics in the organization | ||
*/ | ||
export async function fetchAllPreferenceTopics( | ||
client: GraphQLClient, | ||
): Promise<PreferenceTopic[]> { | ||
const preferenceTopics: PreferenceTopic[] = []; | ||
let offset = 0; | ||
|
||
// Whether to continue looping | ||
let shouldContinue = false; | ||
do { | ||
const { | ||
preferenceTopics: { nodes }, | ||
// eslint-disable-next-line no-await-in-loop | ||
} = await makeGraphQLRequest<{ | ||
/** Preference topics */ | ||
preferenceTopics: { | ||
/** List */ | ||
nodes: PreferenceTopic[]; | ||
}; | ||
}>(client, PREFERENCE_TOPICS, { | ||
first: PAGE_SIZE, | ||
offset, | ||
}); | ||
preferenceTopics.push(...nodes); | ||
offset += PAGE_SIZE; | ||
shouldContinue = nodes.length === PAGE_SIZE; | ||
} while (shouldContinue); | ||
|
||
return preferenceTopics.sort((a, b) => | ||
`${a.slug}:${a.purpose.trackingType}`.localeCompare( | ||
`${b.slug}:${b.purpose.trackingType}`, | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { GraphQLClient } from 'graphql-request'; | ||
import { PURPOSES } from './gqls'; | ||
import { makeGraphQLRequest } from './makeGraphQLRequest'; | ||
|
||
export interface Purpose { | ||
/** ID of purpose */ | ||
id: string; | ||
/** Name of purpose */ | ||
name: string; | ||
/** Slug of purpose */ | ||
trackingType: string; | ||
/** Whether the purpose is active */ | ||
isActive: boolean; | ||
/** Whether the purpose is deleted */ | ||
deletedAt?: string; | ||
} | ||
|
||
const PAGE_SIZE = 20; | ||
|
||
/** | ||
* Fetch all purposes in the organization | ||
* | ||
* @param client - GraphQL client | ||
* @param input - Input | ||
* @returns All purposes in the organization | ||
*/ | ||
export async function fetchAllPurposes( | ||
client: GraphQLClient, | ||
{ | ||
includeDeleted = false, | ||
}: { | ||
/** Whether to include deleted purposes */ | ||
includeDeleted?: boolean; | ||
} = {}, | ||
): Promise<Purpose[]> { | ||
const purposes: Purpose[] = []; | ||
let offset = 0; | ||
|
||
// Whether to continue looping | ||
let shouldContinue = false; | ||
do { | ||
const { | ||
purposes: { nodes }, | ||
// eslint-disable-next-line no-await-in-loop | ||
} = await makeGraphQLRequest<{ | ||
/** Purposes */ | ||
purposes: { | ||
/** List */ | ||
nodes: Purpose[]; | ||
}; | ||
}>(client, PURPOSES, { | ||
first: PAGE_SIZE, | ||
offset, | ||
input: { | ||
includeDeleted, | ||
}, | ||
}); | ||
purposes.push(...nodes); | ||
offset += PAGE_SIZE; | ||
shouldContinue = nodes.length === PAGE_SIZE; | ||
} while (shouldContinue); | ||
|
||
return purposes.sort((a, b) => a.trackingType.localeCompare(b.trackingType)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { gql } from 'graphql-request'; | ||
|
||
// TODO: https://transcend.height.app/T-27909 - enable optimizations | ||
// isExportCsv: true | ||
// useMaster: false | ||
// orderBy: [ | ||
// { field: createdAt, direction: ASC } | ||
// { field: name, direction: ASC } | ||
// ] | ||
export const PREFERENCE_TOPICS = gql` | ||
query TranscendCliPreferenceTopics( | ||
$first: Int! | ||
$offset: Int! | ||
$filterBy: PreferenceTopicFilterInput | ||
) { | ||
preferenceTopics(first: $first, offset: $offset, filterBy: $filterBy) { | ||
nodes { | ||
id | ||
slug | ||
type | ||
preferenceOptionValues { | ||
slug | ||
} | ||
purpose { | ||
trackingType | ||
} | ||
} | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { gql } from 'graphql-request'; | ||
|
||
// TODO: https://transcend.height.app/T-27909 - enable optimizations | ||
// isExportCsv: true | ||
// useMaster: false | ||
// orderBy: [ | ||
// { field: createdAt, direction: ASC } | ||
// { field: name, direction: ASC } | ||
// ] | ||
export const PURPOSES = gql` | ||
query TranscendCliPurposes( | ||
$first: Int! | ||
$offset: Int! | ||
$filterBy: TrackingPurposeFiltersInput | ||
$input: TrackingPurposeInput! | ||
) { | ||
purposes( | ||
first: $first | ||
offset: $offset | ||
filterBy: $filterBy | ||
input: $input | ||
) { | ||
nodes { | ||
id | ||
name | ||
trackingType | ||
isActive | ||
deletedAt | ||
} | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.