Skip to content

Commit

Permalink
refactor(insee): extract insee connector to individual pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Dec 17, 2024
1 parent 7e68f48 commit 1af7362
Show file tree
Hide file tree
Showing 26 changed files with 446 additions and 157 deletions.
8 changes: 4 additions & 4 deletions migrations/1545154190802_create-users-table.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exports.shorthands = undefined;

exports.up = async (pgm) => {
await pgm.db.query(`
await pgm.db.query(`
CREATE TABLE users (
id serial NOT NULL,
email character varying DEFAULT ''::character varying NOT NULL,
Expand All @@ -21,16 +21,16 @@ CREATE TABLE users (
type character varying
);`);

await pgm.db.query(`
await pgm.db.query(`
ALTER TABLE ONLY users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
`);

await pgm.db.query(`
CREATE UNIQUE INDEX index_users_on_email ON users USING btree (email);
CREATE UNIQUE INDEX index_users_on_email ON users USING btree (email);
`);

await pgm.db.query(`
await pgm.db.query(`
CREATE UNIQUE INDEX index_users_on_reset_password_token ON users USING btree (reset_password_token);
`);

Expand Down
2 changes: 2 additions & 0 deletions migrations/1623752868625_add-moderation-table.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ exports.shorthands = undefined;
exports.up = async (pgm) => {
await pgm.db.query(`
CREATE TYPE moderation_type AS ENUM('organization_join_block');
`);
await pgm.db.query(`
CREATE TABLE moderations (
id serial,
user_id int NOT NULL,
Expand Down
2 changes: 2 additions & 0 deletions migrations/1633705667117_add-new-moderation-type.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ exports.up = async (pgm) => {
await pgm.db.query(`
ALTER TABLE moderations
ALTER COLUMN type TYPE character varying;
`);
await pgm.db.query(`
DROP TYPE moderation_type;
`);
};
Expand Down
3 changes: 3 additions & 0 deletions migrations/1702600151114_add-webauthn.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ exports.up = async (pgm) => {
REFERENCES users (id)
ON DELETE CASCADE
);
`);

await pgm.db.query(`
CREATE UNIQUE INDEX index_authenticators_on_credential_id ON authenticators USING btree (credential_id);
`);

Expand Down
57 changes: 48 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
"watch:js": "tsc --watch --preserveWatchOutput",
"watch:node": "tsx --watch src/index.ts",
"watch:workspaces:core": "npm run dev --if-present --workspace=@gouvfr-lasuite/proconnect.core",
"watch:workspaces:email": "npm run dev --if-present --workspace=@gouvfr-lasuite/proconnect.email"
"watch:workspaces:email": "npm run dev --if-present --workspace=@gouvfr-lasuite/proconnect.email",
"watch:workspaces:insee": "npm run dev --if-present --workspace=@gouvfr-lasuite/proconnect.insee",
"watch:workspaces:identity-repository": "npm run dev --if-present --workspace=@gouvfr-lasuite/proconnect.identity-repository"
},
"prettier": {
"plugins": [
Expand All @@ -51,6 +53,7 @@
"@gouvfr-lasuite/crisp": "https://github.com/douglasduteil/crisp/releases/download/v1.6.1/douglasduteil-crisp-1.6.1.tgz",
"@gouvfr-lasuite/proconnect.core": "workspace:*",
"@gouvfr-lasuite/proconnect.email": "workspace:*",
"@gouvfr-lasuite/proconnect.insee": "workspace:*",
"@gouvfr/dsfr": "^1.12.1",
"@kitajs/html": "^4.2.4",
"@kitajs/ts-html-plugin": "^4.1.0",
Expand Down
Empty file.
63 changes: 0 additions & 63 deletions packages/core/src/connectors/insee/get-access-token.test.ts

This file was deleted.

43 changes: 0 additions & 43 deletions packages/core/src/connectors/insee/get-access-token.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/core/src/connectors/insee/index.ts

This file was deleted.

3 changes: 3 additions & 0 deletions packages/core/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//

export * from "./user.js";
35 changes: 35 additions & 0 deletions packages/core/src/types/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//

export type UserId = number;
export type UserEmail = string;

export interface User {
id: UserId;
email: UserEmail;
created_at: Date;
updated_at: Date;
given_name: string | null;
family_name: string | null;
phone_number: string | null;
job: string | null;
}

export interface UserAuth {
current_challenge: string | null;
email_verified_at: Date | null;
email_verified: boolean;
encrypted_password: string | null;
encrypted_totp_key: string | null;
force_2fa: boolean;
last_sign_in_at: Date | null;
magic_link_sent_at: Date | null;
magic_link_token: string | null;
needs_inclusionconnect_onboarding_help: boolean;
needs_inclusionconnect_welcome_page: boolean;
reset_password_sent_at: Date | null;
reset_password_token: string | null;
sign_in_count: number;
totp_key_verified_at: Date | null;
verify_email_sent_at: Date | null;
verify_email_token: string | null;
}
64 changes: 64 additions & 0 deletions packages/identity/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "@gouvfr-lasuite/proconnect.identity-repository",
"version": "0.2.0",
"homepage": "https://github.com/numerique-gouv/moncomptepro/tree/master/packages/identity-repository#readme",
"bugs": "https://github.com/numerique-gouv/moncomptepro/issues",
"repository": {
"type": "git",
"url": "git+https://github.com/numerique-gouv/moncomptepro.git",
"directory": "packages/identity-repository"
},
"license": "MIT",
"sideEffects": false,
"type": "module",
"imports": {
"#src/*": {
"types": "./src/*",
"default": "./dist/*"
}
},
"exports": {
"./*": {
"require": {
"types": "./dist/*/index.d.ts",
"default": "./dist/*/index.js"
},
"import": {
"types": "./dist/*/index.d.ts",
"default": "./dist/*/index.js"
},
"types": "./dist/*/index.d.ts",
"default": "./dist/*/index.js"
}
},
"scripts": {
"build": "tsc --project tsconfig.lib.json",
"check": "npm run build -- --noEmit",
"dev": "npm run build -- --watch --preserveWatchOutput",
"test": "mocha"
},
"mocha": {
"reporter": "spec",
"require": [
"tsx"
],
"spec": "src/**/*.test.ts"
},
"dependencies": {},
"devDependencies": {
"@electric-sql/pglite": "^0.2.15",
"@gouvfr-lasuite/proconnect.core": "^0.2.0",
"@tsconfig/node22": "^22.0.0",
"@types/mocha": "^10.0.10",
"@types/node": "^22.10.2",
"chai": "^5.1.2",
"mocha": "^11.0.1",
"node-pg-migrate": "^7.6.1",
"pg": "^8.13.0",
"tsx": "^4.19.2"
},
"publishConfig": {
"access": "public",
"provenance": true
}
}
Loading

0 comments on commit 1af7362

Please sign in to comment.