2022-06-25 16:10:35 +00:00
|
|
|
// This transform config was generated by Snaplet.
|
|
|
|
// Snaplet found fields that may contain personally identifiable information (PII)
|
|
|
|
// and used that to populate this file.
|
2022-06-29 19:03:13 +00:00
|
|
|
import { copycat as c } from "@snaplet/copycat";
|
2022-06-25 16:10:35 +00:00
|
|
|
|
|
|
|
import type { Transform } from "./structure";
|
|
|
|
|
|
|
|
function hasStringProp<T extends string>(x: unknown, key: T): x is { [key in T]: string } {
|
|
|
|
return !!x && typeof x === "object" && key in x;
|
|
|
|
}
|
|
|
|
|
|
|
|
function replaceKeyIfExists<T extends string>(x: object, key: T) {
|
|
|
|
if (hasStringProp(x, key)) {
|
2022-06-29 19:03:13 +00:00
|
|
|
return { ...x, [key]: c.uuid(x[key]) };
|
2022-06-25 16:10:35 +00:00
|
|
|
}
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
function generateSlug(x: string) {
|
2022-06-29 19:03:13 +00:00
|
|
|
return c.words(x, { max: 3 }).split(" ").join("-");
|
2022-06-25 16:10:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function replaceSensitiveKeys(record: object) {
|
|
|
|
return {
|
|
|
|
...record,
|
|
|
|
...replaceKeyIfExists(record, "client_id"),
|
|
|
|
...replaceKeyIfExists(record, "client_secret"),
|
|
|
|
...replaceKeyIfExists(record, "public_key"),
|
|
|
|
...replaceKeyIfExists(record, "api_key"),
|
|
|
|
...replaceKeyIfExists(record, "signing_secret"),
|
|
|
|
...replaceKeyIfExists(record, "access_token"),
|
|
|
|
...replaceKeyIfExists(record, "refresh_token"),
|
|
|
|
...replaceKeyIfExists(record, "stripe_user_id"),
|
|
|
|
...replaceKeyIfExists(record, "stripe_publishable_key"),
|
|
|
|
...replaceKeyIfExists(record, "accessToken"),
|
|
|
|
...replaceKeyIfExists(record, "refreshToken"),
|
|
|
|
...replaceKeyIfExists(record, "bot_user_id"),
|
|
|
|
...replaceKeyIfExists(record, "app_id"),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-06-29 19:03:13 +00:00
|
|
|
const generateUsername = (x: string) => `${c.firstName(x)}-${c.lastName(x)}${c.int(x, { min: 2, max: 99 })}`;
|
|
|
|
|
2022-06-25 16:10:35 +00:00
|
|
|
const config: Transform = () => ({
|
|
|
|
public: {
|
|
|
|
ApiKey: ({ row }) => ({
|
2022-06-29 19:03:13 +00:00
|
|
|
hashedKey: c.uuid(row.hashedKey),
|
2022-06-25 16:10:35 +00:00
|
|
|
}),
|
|
|
|
App: ({ row }) => ({
|
|
|
|
keys: replaceSensitiveKeys(row.keys),
|
|
|
|
}),
|
|
|
|
Attendee: ({ row }) => ({
|
2022-06-29 19:03:13 +00:00
|
|
|
email: c.email(row.email),
|
|
|
|
name: c.fullName(row.name),
|
|
|
|
timeZone: c.timezone(row.timeZone),
|
2022-06-25 16:10:35 +00:00
|
|
|
}),
|
|
|
|
Credential: ({ row }) => ({
|
2022-06-29 19:03:13 +00:00
|
|
|
key: typeof row.key === "string" ? c.uuid(row.key) : replaceSensitiveKeys(row.key),
|
2022-06-25 16:10:35 +00:00
|
|
|
}),
|
|
|
|
EventType: ({ row }) => ({
|
|
|
|
slug: generateSlug(row.slug),
|
2022-06-29 19:03:13 +00:00
|
|
|
timeZone: c.timezone(row.timeZone),
|
|
|
|
eventName: c.words(row.eventName, { max: 3 }),
|
2022-06-25 16:10:35 +00:00
|
|
|
}),
|
|
|
|
ResetPasswordRequest: ({ row }) => ({
|
2022-06-29 19:03:13 +00:00
|
|
|
email: c.email(row.email),
|
2022-06-25 16:10:35 +00:00
|
|
|
}),
|
|
|
|
Schedule: ({ row }) => ({
|
2022-06-29 19:03:13 +00:00
|
|
|
timeZone: c.timezone(row.timeZone),
|
2022-06-25 16:10:35 +00:00
|
|
|
}),
|
|
|
|
Team: ({ row }) => ({
|
2022-06-29 19:03:13 +00:00
|
|
|
bio: c.sentence(row.bio),
|
|
|
|
name: c.words(row.name, { max: 2 }),
|
2022-06-25 16:10:35 +00:00
|
|
|
slug: generateSlug(row.slug),
|
|
|
|
}),
|
2022-06-29 19:03:13 +00:00
|
|
|
users: ({ row }) =>
|
|
|
|
row.role !== "ADMIN"
|
|
|
|
? {
|
|
|
|
bio: c.sentence(row.bio),
|
|
|
|
email: c.email(row.email),
|
|
|
|
name: c.fullName(row.name),
|
|
|
|
password: c.password(row.password),
|
|
|
|
timeZone: c.timezone(row.timeZone),
|
|
|
|
username: generateUsername(row.username),
|
|
|
|
}
|
|
|
|
: row,
|
2022-06-25 16:10:35 +00:00
|
|
|
VerificationToken: ({ row }) => ({
|
2022-06-29 19:03:13 +00:00
|
|
|
token: c.uuid(row.token),
|
|
|
|
}),
|
|
|
|
Account: ({ row }) => ({
|
|
|
|
access_token: c.uuid(row.access_token),
|
|
|
|
refresh_token: c.uuid(row.refresh_token),
|
2022-06-25 16:10:35 +00:00
|
|
|
}),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default config;
|