Updates snaplet transform script (#3199)

* Update .gitignore

* Fixes local dev env checks

* Update transform.ts
This commit is contained in:
Omar López 2022-06-29 13:03:13 -06:00 committed by GitHub
parent fbc4eb5457
commit 92bfb3e5b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 33 deletions

View File

@ -1,7 +1,7 @@
// This transform config was generated by Snaplet.
// Snaplet found fields that may contain personally identifiable information (PII)
// and used that to populate this file.
import { copycat } from "@snaplet/copycat";
import { copycat as c } from "@snaplet/copycat";
import type { Transform } from "./structure";
@ -11,13 +11,13 @@ function hasStringProp<T extends string>(x: unknown, key: T): x is { [key in T]:
function replaceKeyIfExists<T extends string>(x: object, key: T) {
if (hasStringProp(x, key)) {
return { ...x, [key]: copycat.uuid(x[key]) };
return { ...x, [key]: c.uuid(x[key]) };
}
return x;
}
function generateSlug(x: string) {
return copycat.words(x, { max: 3 }).split(" ").join("-");
return c.words(x, { max: 3 }).split(" ").join("-");
}
function replaceSensitiveKeys(record: object) {
@ -39,57 +39,57 @@ function replaceSensitiveKeys(record: object) {
};
}
const generateUsername = (x: string) => `${c.firstName(x)}-${c.lastName(x)}${c.int(x, { min: 2, max: 99 })}`;
const config: Transform = () => ({
public: {
_user_eventtype: ({ row }) => ({
A: copycat.int(row.A),
B: copycat.int(row.B),
}),
ApiKey: ({ row }) => ({
note: copycat.sentence(row.note),
hashedKey: c.uuid(row.hashedKey),
}),
App: ({ row }) => ({
keys: replaceSensitiveKeys(row.keys),
}),
Attendee: ({ row }) => ({
email: copycat.email(row.email),
name: copycat.fullName(row.name),
timeZone: copycat.timezone(row.timeZone),
}),
Availability: ({ row }) => ({
// date: copycat.fullName(row.date),
email: c.email(row.email),
name: c.fullName(row.name),
timeZone: c.timezone(row.timeZone),
}),
Credential: ({ row }) => ({
key: typeof row.key === "string" ? copycat.uuid(row.key) : replaceSensitiveKeys(row.key),
key: typeof row.key === "string" ? c.uuid(row.key) : replaceSensitiveKeys(row.key),
}),
EventType: ({ row }) => ({
slug: generateSlug(row.slug),
timeZone: copycat.timezone(row.timeZone),
}),
Feedback: ({ row }) => ({
// date: copycat.dateString(row.date),
timeZone: c.timezone(row.timeZone),
eventName: c.words(row.eventName, { max: 3 }),
}),
ResetPasswordRequest: ({ row }) => ({
email: copycat.email(row.email),
email: c.email(row.email),
}),
Schedule: ({ row }) => ({
timeZone: copycat.timezone(row.timeZone),
timeZone: c.timezone(row.timeZone),
}),
Team: ({ row }) => ({
bio: copycat.sentence(row.bio),
name: copycat.words(row.name, { max: 2 }),
bio: c.sentence(row.bio),
name: c.words(row.name, { max: 2 }),
slug: generateSlug(row.slug),
}),
users: ({ row }) => ({
bio: copycat.sentence(row.bio),
email: copycat.email(row.email),
name: copycat.fullName(row.name),
password: copycat.password(row.password),
timeZone: copycat.timezone(row.timeZone),
username: generateSlug(row.username),
}),
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,
VerificationToken: ({ row }) => ({
token: copycat.uuid(row.token),
token: c.uuid(row.token),
}),
Account: ({ row }) => ({
access_token: c.uuid(row.access_token),
refresh_token: c.uuid(row.refresh_token),
}),
},
});

View File

@ -21,4 +21,3 @@
"type": "riverside_video"
}
]