Skip to content

Commit 05a4940

Browse files
refactor: remove anon props (#3276)
1 parent 0beec1b commit 05a4940

3 files changed

Lines changed: 4 additions & 72 deletions

File tree

__tests__/schema/profile.ts

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -196,37 +196,6 @@ describe('query userExperiences', () => {
196196
expect(res.data.userExperiences.edges).toHaveLength(1);
197197
});
198198

199-
it('should restrict fields for anonymous users to only allowed columns', async () => {
200-
loggedUser = null;
201-
202-
const res = await client.query(USER_EXPERIENCES_QUERY, {
203-
variables: { userId: '1' },
204-
});
205-
206-
expect(res.errors).toBeFalsy();
207-
expect(res.data.userExperiences.edges).toHaveLength(1);
208-
209-
const experience = res.data.userExperiences.edges[0].node;
210-
211-
// Allowed columns for anonymous users
212-
expect(experience).toMatchObject({
213-
id: 'f47ac10b-58cc-4372-a567-0e02b2c3d479',
214-
type: 'work',
215-
title: 'Senior Software Engineer',
216-
company: {
217-
id: 'company-1',
218-
name: 'Daily.dev',
219-
},
220-
});
221-
222-
// Restricted columns should be null for anonymous users
223-
expect(experience.subtitle).toBeNull();
224-
expect(experience.description).toBeNull();
225-
expect(experience.startedAt).toBeNull();
226-
expect(experience.endedAt).toBeNull();
227-
expect(experience.createdAt).toBeNull();
228-
});
229-
230199
it('should return all fields for logged-in users', async () => {
231200
loggedUser = '1';
232201

@@ -515,35 +484,6 @@ describe('query userExperienceById', () => {
515484
});
516485
});
517486

518-
it('should restrict fields for anonymous users when fetching by id', async () => {
519-
loggedUser = null;
520-
521-
const res = await client.query(USER_EXPERIENCE_BY_ID_QUERY, {
522-
variables: { id: 'f47ac10b-58cc-4372-a567-0e02b2c3d479' },
523-
});
524-
525-
expect(res.errors).toBeFalsy();
526-
527-
const experience = res.data.userExperienceById;
528-
529-
// Allowed columns for anonymous users
530-
expect(experience).toMatchObject({
531-
id: 'f47ac10b-58cc-4372-a567-0e02b2c3d479',
532-
type: 'work',
533-
title: 'Senior Software Engineer',
534-
company: {
535-
name: 'Daily.dev',
536-
},
537-
});
538-
539-
// Restricted columns should be null for anonymous users
540-
expect(experience.subtitle).toBeNull();
541-
expect(experience.description).toBeNull();
542-
expect(experience.startedAt).toBeNull();
543-
expect(experience.endedAt).toBeNull();
544-
expect(experience.createdAt).toBeNull();
545-
});
546-
547487
it('should return experience from another user', async () => {
548488
loggedUser = '1';
549489

src/common/schema/profile.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export const userExperienceWorkSchema = z
4848
externalReferenceId: z.string().optional(),
4949
employmentType: z.number().nullable().optional().default(null),
5050
locationType: z.number().nullable().optional().default(null),
51-
locationId: z.uuidv4().nullable().optional().default(null),
51+
locationId: z.preprocess(
52+
(val) => (val === '' ? null : val),
53+
z.string().uuid().nullable().optional().default(null),
54+
),
5255
skills: z
5356
.array(z.string().trim().normalize().nonempty().max(100))
5457
.max(50)

src/graphorm/index.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,17 +1726,6 @@ const obj = new GraphORM({
17261726
from: 'DatasetLocation',
17271727
},
17281728
UserExperience: {
1729-
anonymousRestrictedColumns: [
1730-
'user',
1731-
'subtitle',
1732-
'description',
1733-
'startedAt',
1734-
'endedAt',
1735-
'location',
1736-
'locationType',
1737-
'createdAt',
1738-
'updatedAt',
1739-
],
17401729
fields: {
17411730
startedAt: {
17421731
transform: transformDate,

0 commit comments

Comments
 (0)