//native
type Segment = {
token: string;
baseUrl: string;
};
/**
* Create Transformation
* Creates a new Transformation.
• When called, this endpoint may generate the `Transformation Created` event in the audit trail.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
*/
export async function main(
auth: Segment,
body: {
name: string;
sourceId: string;
destinationMetadataId?: string;
enabled: false | true;
if: string;
drop?: false | true;
newEventName?: string;
propertyRenames?: { oldName: string; newName: string }[];
propertyValueTransformations?: {
propertyPaths: string[];
propertyValue: string;
}[];
fqlDefinedProperties?: { fql: string; propertyName: string }[];
allowProperties?: string[];
hashPropertiesConfiguration?: {
algorithm: string;
key?: string;
encoding?: "BASE16" | "BASE64" | "BASE64URL" | "HEX";
paths: string[];
};
},
) {
const url = new URL(`${auth.baseUrl}/transformations`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago