Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

feat: Create the identites module #121

Merged
merged 1 commit into from
Aug 24, 2024

Conversation

Blckbrry-Pi
Copy link
Collaborator

No description provided.

Copy link
Collaborator Author

Blckbrry-Pi commented Jun 29, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @Blckbrry-Pi and the rest of your teammates on Graphite Graphite

@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-27-feat_tokens_add_a_modify_meta_script branch from 06cf55a to d2012c6 Compare July 2, 2024 00:19
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-29-feat_create_the_auth_provider_module branch from ae1fc49 to 7d177f8 Compare July 2, 2024 00:19
@Blckbrry-Pi Blckbrry-Pi marked this pull request as ready for review July 2, 2024 00:22
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-27-feat_tokens_add_a_modify_meta_script branch from d2012c6 to 2832c4c Compare July 2, 2024 01:53
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-29-feat_create_the_auth_provider_module branch from 7d177f8 to 30af057 Compare July 2, 2024 01:53
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-27-feat_tokens_add_a_modify_meta_script branch from 2832c4c to bbb15a8 Compare July 3, 2024 02:16
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-29-feat_create_the_auth_provider_module branch from 30af057 to 553a363 Compare July 3, 2024 02:16
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-27-feat_tokens_add_a_modify_meta_script branch from bbb15a8 to 4411d94 Compare July 3, 2024 02:17
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-29-feat_create_the_auth_provider_module branch 2 times, most recently from aa4b390 to c02a755 Compare July 3, 2024 14:54
@Blckbrry-Pi Blckbrry-Pi changed the title feat: Create the auth_provider module feat: Create the identites module Jul 3, 2024
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-29-feat_create_the_auth_provider_module branch from c02a755 to efc852f Compare July 5, 2024 03:43
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-27-feat_tokens_add_a_modify_meta_script branch from 4411d94 to f3e0b8d Compare July 5, 2024 03:51
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-29-feat_create_the_auth_provider_module branch from efc852f to bfd5d25 Compare July 5, 2024 03:51
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-27-feat_tokens_add_a_modify_meta_script branch from f3e0b8d to ad062ed Compare July 19, 2024 23:48
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-29-feat_create_the_auth_provider_module branch from bfd5d25 to ce34e98 Compare July 19, 2024 23:48
This was referenced Jul 19, 2024
modules/auth_providers/db/schema.prisma Outdated Show resolved Hide resolved
modules/identities/module.json Outdated Show resolved Hide resolved
modules/identities/module.json Show resolved Hide resolved
modules/identities/scripts/get.ts Outdated Show resolved Hide resolved
return { data: null };
}

const { uniqueData, additionalData } = data;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this because of our ajv validation issue or something else? ideally we don't have to write ugly code like this.

this might already be fixed on main with the zod migration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because uniqueData and additionalData are JSON fields in the psql database.

The null reassignment shouldn't be necessary, that was an accident.

However, it doesn't guarantee there's a matching row, and the JSON type doesn't guarantee it's a non-nullable object.

This essentially just says invalid/missing entries have no data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am i missing something: if there's no matching row, identities will be null. it's not going to return an object with undefined properties. our db constraint has not null on jsonb so all of this code is redundant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sadly is not. The DB constraint says that if there is a row, there is a valid JSON value in that column. null is a valid JSON value, along with "hello", 42, etc.

Prisma ensures that the value returned will be JSON, but not whether or not it's an object or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to clarify: there is no case where we intentionally set anything that's not an object to the additional data, right? if that's a case, let's write an assertion using the deno assert lib (which throws an internal error, not runtimeerror) & crash instead of failing silentl.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise, some downstream script will likely break from unintended state afaik.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Will do!

modules/identities/module.json Outdated Show resolved Hide resolved
modules/identities/scripts/sign_in.ts Outdated Show resolved Hide resolved
modules/identities/scripts/sign_in.ts Outdated Show resolved Hide resolved
modules/identities/scripts/sign_in_or_sign_up.ts Outdated Show resolved Hide resolved
modules/identities/scripts/sign_up.ts Outdated Show resolved Hide resolved
modules/identities/scripts/sign_up.ts Outdated Show resolved Hide resolved
await ctx.modules.rateLimit.throttlePublic({});

// Ensure the user token is valid and get the user ID
const { userId } = await ctx.modules.users.authenticateToken({ userToken: req.userToken } );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should let the caller authenticate the token and pass a raw user id. allows for better composability.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a public script— are you sure we want that to be public by user ID?

modules/identities/scripts/link.ts Show resolved Hide resolved
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-29-feat_create_the_auth_provider_module branch 2 times, most recently from 7a38516 to a119950 Compare August 3, 2024 22:57
modules/identities/module.json Show resolved Hide resolved
modules/identities/scripts/get.ts Outdated Show resolved Hide resolved
return { data: null };
}

const { uniqueData, additionalData } = data;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am i missing something: if there's no matching row, identities will be null. it's not going to return an object with undefined properties. our db constraint has not null on jsonb so all of this code is redundant.

modules/identities/scripts/list.ts Show resolved Hide resolved
modules/identities/db/schema.prisma Outdated Show resolved Hide resolved
@Blckbrry-Pi Blckbrry-Pi force-pushed the 06-29-feat_create_the_auth_provider_module branch 2 times, most recently from 7a04e0a to 68f1b5e Compare August 7, 2024 22:09
return { data: null };
}

const { uniqueData, additionalData } = data;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to clarify: there is no case where we intentionally set anything that's not an object to the additional data, right? if that's a case, let's write an assertion using the deno assert lib (which throws an internal error, not runtimeerror) & crash instead of failing silentl.

return { data: null };
}

const { uniqueData, additionalData } = data;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise, some downstream script will likely break from unintended state afaik.

Copy link
Member

NathanFlurry commented Aug 24, 2024

Merge activity

  • Aug 23, 10:59 PM EDT: @NathanFlurry started a stack merge that includes this pull request via Graphite.
  • Aug 23, 11:01 PM EDT: Graphite rebased this pull request as part of a merge.
  • Aug 23, 11:02 PM EDT: @NathanFlurry merged this pull request with Graphite.

@NathanFlurry NathanFlurry changed the base branch from 06-27-feat_tokens_add_a_modify_meta_script to graphite-base/121 August 24, 2024 02:59
@NathanFlurry NathanFlurry changed the base branch from graphite-base/121 to main August 24, 2024 02:59
@NathanFlurry NathanFlurry force-pushed the 06-29-feat_create_the_auth_provider_module branch from faed173 to 171fdbe Compare August 24, 2024 03:00
@NathanFlurry NathanFlurry merged commit ba39943 into main Aug 24, 2024
1 of 2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants