@proconnect-gouv/proconnect.identite 13.0.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/connectors/index.d.ts +0 -62
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/index.js +5 -13
- package/dist/repositories/franceconnect_userinfo/index.d.ts +0 -2
- package/dist/repositories/franceconnect_userinfo/index.d.ts.map +1 -1
- package/dist/repositories/franceconnect_userinfo/index.js +0 -2
- package/dist/repositories/moderation/index.d.ts +0 -1
- package/dist/repositories/moderation/index.d.ts.map +1 -1
- package/dist/repositories/moderation/index.js +0 -1
- package/dist/repositories/organization/find-by-user-id.d.ts +0 -1
- package/dist/repositories/organization/find-by-user-id.d.ts.map +1 -1
- package/dist/repositories/organization/find-by-user-id.js +1 -2
- package/dist/repositories/organization/index.d.ts +0 -1
- package/dist/repositories/organization/index.d.ts.map +1 -1
- package/dist/repositories/organization/index.js +0 -1
- package/dist/repositories/user/index.d.ts +0 -1
- package/dist/repositories/user/index.d.ts.map +1 -1
- package/dist/repositories/user/index.js +0 -1
- package/dist/repositories/user_organisation/find-user-organization.d.ts +0 -1
- package/dist/repositories/user_organisation/find-user-organization.d.ts.map +1 -1
- package/dist/repositories/user_organisation/find-user-organization.js +1 -2
- package/dist/repositories/user_organisation/get-user-organization.d.ts +0 -1
- package/dist/repositories/user_organisation/get-user-organization.d.ts.map +1 -1
- package/dist/repositories/user_organisation/index.d.ts +0 -3
- package/dist/repositories/user_organisation/index.d.ts.map +1 -1
- package/dist/repositories/user_organisation/index.js +0 -3
- package/dist/types/user-organization-link.d.ts +0 -2
- package/dist/types/user-organization-link.d.ts.map +1 -1
- package/dist/types/user-organization-link.js +0 -1
- package/package.json +3 -3
- package/src/connectors/index.ts +1 -19
- package/src/repositories/franceconnect_userinfo/index.ts +0 -2
- package/src/repositories/moderation/index.ts +0 -1
- package/src/repositories/organization/find-by-user-id.test.ts +5 -5
- package/src/repositories/organization/find-by-user-id.test.ts.snapshot +3 -6
- package/src/repositories/organization/find-by-user-id.ts +1 -2
- package/src/repositories/organization/index.ts +0 -1
- package/src/repositories/user/index.ts +0 -1
- package/src/repositories/user_organisation/find-user-organization.ts +1 -2
- package/src/repositories/user_organisation/get-user-organization.test.ts +0 -1
- package/src/repositories/user_organisation/index.ts +0 -3
- package/src/types/user-organization-link.ts +0 -1
- package/dist/repositories/franceconnect_userinfo/delete-franceconnect-userinfo.d.ts +0 -4
- package/dist/repositories/franceconnect_userinfo/delete-franceconnect-userinfo.d.ts.map +0 -1
- package/dist/repositories/franceconnect_userinfo/delete-franceconnect-userinfo.js +0 -10
- package/dist/repositories/franceconnect_userinfo/upsert-franceconnect-userinfo.d.ts +0 -16
- package/dist/repositories/franceconnect_userinfo/upsert-franceconnect-userinfo.d.ts.map +0 -1
- package/dist/repositories/franceconnect_userinfo/upsert-franceconnect-userinfo.js +0 -23
- package/dist/repositories/moderation/create-moderation.d.ts +0 -22
- package/dist/repositories/moderation/create-moderation.d.ts.map +0 -1
- package/dist/repositories/moderation/create-moderation.js +0 -21
- package/dist/repositories/organization/find-by-verified-email-domain.d.ts +0 -6
- package/dist/repositories/organization/find-by-verified-email-domain.d.ts.map +0 -1
- package/dist/repositories/organization/find-by-verified-email-domain.js +0 -21
- package/dist/repositories/user/delete.d.ts +0 -3
- package/dist/repositories/user/delete.d.ts.map +0 -1
- package/dist/repositories/user/delete.js +0 -11
- package/dist/repositories/user_organisation/create-user-organization.d.ts +0 -12
- package/dist/repositories/user_organisation/create-user-organization.d.ts.map +0 -1
- package/dist/repositories/user_organisation/create-user-organization.js +0 -21
- package/dist/repositories/user_organisation/delete-user-organization.d.ts +0 -3
- package/dist/repositories/user_organisation/delete-user-organization.d.ts.map +0 -1
- package/dist/repositories/user_organisation/delete-user-organization.js +0 -12
- package/dist/repositories/user_organisation/update-user-organization.d.ts +0 -12
- package/dist/repositories/user_organisation/update-user-organization.d.ts.map +0 -1
- package/dist/repositories/user_organisation/update-user-organization.js +0 -20
- package/src/repositories/franceconnect_userinfo/delete-franceconnect-userinfo.test.ts +0 -47
- package/src/repositories/franceconnect_userinfo/delete-franceconnect-userinfo.ts +0 -21
- package/src/repositories/franceconnect_userinfo/upsert-franceconnect-userinfo.test.ts +0 -102
- package/src/repositories/franceconnect_userinfo/upsert-franceconnect-userinfo.ts +0 -41
- package/src/repositories/moderation/create-moderation.test.ts +0 -43
- package/src/repositories/moderation/create-moderation.ts +0 -45
- package/src/repositories/organization/find-by-verified-email-domain.test.ts +0 -46
- package/src/repositories/organization/find-by-verified-email-domain.ts +0 -33
- package/src/repositories/user/delete.test.ts +0 -35
- package/src/repositories/user/delete.ts +0 -19
- package/src/repositories/user_organisation/create-user-organization.test.ts +0 -66
- package/src/repositories/user_organisation/create-user-organization.test.ts.snapshot +0 -25
- package/src/repositories/user_organisation/create-user-organization.ts +0 -39
- package/src/repositories/user_organisation/delete-user-organization.test.ts +0 -55
- package/src/repositories/user_organisation/delete-user-organization.ts +0 -24
- package/src/repositories/user_organisation/update-user-organization.test.ts +0 -48
- package/src/repositories/user_organisation/update-user-organization.ts +0 -42
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
export * from "./find-by-siret.js";
|
|
4
4
|
export * from "./find-by-user-id.js";
|
|
5
|
-
export * from "./find-by-verified-email-domain.js";
|
|
6
5
|
export * from "./find-organization-by-id.js";
|
|
7
6
|
export * from "./find-pending-by-user-id.js";
|
|
8
7
|
export * from "./get-organization-by-id.js";
|
|
@@ -54,7 +54,6 @@ export const BaseUserOrganizationLinkSchema = z.object({
|
|
|
54
54
|
verification_type: LinkEnum,
|
|
55
55
|
// updated when verification_type is changed
|
|
56
56
|
verified_at: z.date().or(z.literal(null)),
|
|
57
|
-
has_been_greeted: z.boolean(),
|
|
58
57
|
});
|
|
59
58
|
|
|
60
59
|
export type BaseUserOrganizationLink = z.output<
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext } from "#src/types";
|
|
2
|
-
export declare function deleteFranceconnectUserinfoFactory({ pg }: DatabaseContext): (user_id: number) => Promise<import("pg").QueryResult<any>>;
|
|
3
|
-
export type DeleteFranceconnectUserinfoHandler = ReturnType<typeof deleteFranceconnectUserinfoFactory>;
|
|
4
|
-
//# sourceMappingURL=delete-franceconnect-userinfo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete-franceconnect-userinfo.d.ts","sourceRoot":"","sources":["../../../src/repositories/franceconnect_userinfo/delete-franceconnect-userinfo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,wBAAgB,kCAAkC,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,SAAS,MAAM,4CASlE;AAED,MAAM,MAAM,kCAAkC,GAAG,UAAU,CACzD,OAAO,kCAAkC,CAC1C,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext, FranceConnectUserInfo } from "#src/types";
|
|
2
|
-
export declare function upsertFranceconnectUserinfoFactory({ pg }: DatabaseContext): (value: Pick<FranceConnectUserInfo, "user_id"> & Partial<FranceConnectUserInfo>) => Promise<{
|
|
3
|
-
birthcountry: string;
|
|
4
|
-
birthdate: Date;
|
|
5
|
-
birthplace: string;
|
|
6
|
-
family_name: string;
|
|
7
|
-
gender: string;
|
|
8
|
-
given_name: string;
|
|
9
|
-
sub: string;
|
|
10
|
-
created_at: Date;
|
|
11
|
-
updated_at: Date;
|
|
12
|
-
user_id: number;
|
|
13
|
-
preferred_username?: string | undefined;
|
|
14
|
-
}>;
|
|
15
|
-
export type UpsetFranceconnectUserinfoHandler = ReturnType<typeof upsertFranceconnectUserinfoFactory>;
|
|
16
|
-
//# sourceMappingURL=upsert-franceconnect-userinfo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upsert-franceconnect-userinfo.d.ts","sourceRoot":"","sources":["../../../src/repositories/franceconnect_userinfo/upsert-franceconnect-userinfo.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAIzE,wBAAgB,kCAAkC,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAEtE,OAAO,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,GAC3C,OAAO,CAAC,qBAAqB,CAAC;;;;;;;;;;;;GA0BnC;AAED,MAAM,MAAM,iCAAiC,GAAG,UAAU,CACxD,OAAO,kCAAkC,CAC1C,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { hashToPostgresParams } from "#src/services/postgres";
|
|
3
|
-
//
|
|
4
|
-
export function upsertFranceconnectUserinfoFactory({ pg }) {
|
|
5
|
-
return async function upsertFranceconnectUserinfo(value) {
|
|
6
|
-
const fieldsWithTimestamps = {
|
|
7
|
-
...value,
|
|
8
|
-
updated_at: new Date(),
|
|
9
|
-
};
|
|
10
|
-
const { paramsString, valuesString, values } = hashToPostgresParams(fieldsWithTimestamps);
|
|
11
|
-
const { rows } = await pg.query(`
|
|
12
|
-
INSERT INTO franceconnect_userinfo
|
|
13
|
-
${paramsString}
|
|
14
|
-
VALUES
|
|
15
|
-
${valuesString}
|
|
16
|
-
ON CONFLICT (user_id)
|
|
17
|
-
DO UPDATE
|
|
18
|
-
SET ${paramsString} = ${valuesString}
|
|
19
|
-
RETURNING *
|
|
20
|
-
`, [...values]);
|
|
21
|
-
return rows.shift();
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type DatabaseContext, type ModerationType } from "#src/types";
|
|
2
|
-
export declare function createModerationFactory({ pg }: DatabaseContext): ({ user_id, organization_id, sp_name, type, ticket_id, }: {
|
|
3
|
-
user_id: number;
|
|
4
|
-
organization_id: number;
|
|
5
|
-
sp_name?: string;
|
|
6
|
-
type: ModerationType;
|
|
7
|
-
ticket_id: string | null;
|
|
8
|
-
}) => Promise<{
|
|
9
|
-
id: number;
|
|
10
|
-
user_id: number;
|
|
11
|
-
organization_id: number;
|
|
12
|
-
ticket_id: string | null;
|
|
13
|
-
type: "non_verified_domain" | "organization_join_block";
|
|
14
|
-
created_at: Date;
|
|
15
|
-
moderated_at: Date | null;
|
|
16
|
-
comment: string | null;
|
|
17
|
-
moderated_by: string | null;
|
|
18
|
-
status: "accepted" | "pending" | "rejected" | "reopened" | "unknown";
|
|
19
|
-
end_user_reason: string;
|
|
20
|
-
allow_editing: boolean;
|
|
21
|
-
}>;
|
|
22
|
-
//# sourceMappingURL=create-moderation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-moderation.d.ts","sourceRoot":"","sources":["../../../src/repositories/moderation/create-moderation.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,yDAMpC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;;;;;;;;;;;;;GAmBF"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { ModerationStatusSchema, } from "#src/types";
|
|
3
|
-
import {} from "pg";
|
|
4
|
-
//
|
|
5
|
-
export function createModerationFactory({ pg }) {
|
|
6
|
-
return async function createModeration({ user_id, organization_id, sp_name, type, ticket_id, }) {
|
|
7
|
-
const { rows } = await pg.query(`
|
|
8
|
-
INSERT INTO moderations (user_id, organization_id, status, type, ticket_id, sp_name, allow_editing)
|
|
9
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
10
|
-
RETURNING *;`, [
|
|
11
|
-
user_id,
|
|
12
|
-
organization_id,
|
|
13
|
-
ModerationStatusSchema.enum.pending,
|
|
14
|
-
type,
|
|
15
|
-
ticket_id,
|
|
16
|
-
sp_name ?? null,
|
|
17
|
-
false,
|
|
18
|
-
]);
|
|
19
|
-
return rows.shift();
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext } from "#src/types";
|
|
2
|
-
import { type Organization } from "#src/types";
|
|
3
|
-
export declare function findByVerifiedEmailDomainFactory({ pg }: DatabaseContext): (email_domain: string) => Promise<(Organization & {
|
|
4
|
-
member_count: number;
|
|
5
|
-
})[]>;
|
|
6
|
-
//# sourceMappingURL=find-by-verified-email-domain.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-by-verified-email-domain.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/find-by-verified-email-domain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,gCAAgC,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,cAAc,MAAM;kBACP,MAAM;MAmBpE"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { EmailDomainApprovedVerificationValues, } from "#src/types";
|
|
3
|
-
import {} from "pg";
|
|
4
|
-
//
|
|
5
|
-
export function findByVerifiedEmailDomainFactory({ pg }) {
|
|
6
|
-
return async function findByVerifiedEmailDomain(email_domain) {
|
|
7
|
-
const { rows } = await pg.query(`
|
|
8
|
-
SELECT o.*, count(u.id)::int as member_count
|
|
9
|
-
FROM organizations o
|
|
10
|
-
INNER JOIN email_domains ed ON ed.organization_id = o.id
|
|
11
|
-
LEFT JOIN users_organizations uo ON uo.organization_id = o.id
|
|
12
|
-
LEFT JOIN users u ON u.id = uo.user_id
|
|
13
|
-
AND substring(u.email FROM '@(.+)$') = $1
|
|
14
|
-
WHERE o.cached_est_active = 'true'
|
|
15
|
-
AND ed.domain = $1
|
|
16
|
-
AND ed.verification_type = ANY ($2)
|
|
17
|
-
GROUP BY o.id
|
|
18
|
-
ORDER BY member_count DESC NULLS LAST;`, [email_domain, EmailDomainApprovedVerificationValues]);
|
|
19
|
-
return rows;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/delete.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKlD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,IAAI,MAAM,sBAU5C"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import {} from "pg";
|
|
3
|
-
//
|
|
4
|
-
export function deleteUserFactory({ pg }) {
|
|
5
|
-
return async function deleteUser(id) {
|
|
6
|
-
const { rowCount, affectedRows } = (await pg.query(`
|
|
7
|
-
DELETE FROM users
|
|
8
|
-
WHERE id = $1`, [id]));
|
|
9
|
-
return (affectedRows ?? rowCount ?? 0) > 0;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext, InsertUserOrganizationLink } from "#src/types";
|
|
2
|
-
export declare function createUserOrganizationFactory({ pg }: DatabaseContext): ({ is_external, organization_id, user_id, verification_type, }: InsertUserOrganizationLink) => Promise<{
|
|
3
|
-
is_external: boolean;
|
|
4
|
-
verification_type: "domain" | "organization_dirigeant" | "code_sent_to_official_contact_email" | "imported_from_coop_mediation_numerique" | "imported_from_inclusion_connect" | "in_liste_dirigeants_rna" | "in_liste_dirigeants_rne" | "official_contact_email" | "ordre_professionnel_domain" | "proof_received" | "verified_by_coop_mediation_numerique" | "bypassed" | "domain_not_verified_yet" | "no_validation_means_available" | "no_verification_means_for_entreprise_unipersonnelle" | "no_verification_means_for_small_association" | "no_verification_means_for_small_organization";
|
|
5
|
-
verified_at: Date | null;
|
|
6
|
-
has_been_greeted: boolean;
|
|
7
|
-
user_id: number;
|
|
8
|
-
organization_id: number;
|
|
9
|
-
created_at: Date;
|
|
10
|
-
updated_at: Date;
|
|
11
|
-
}>;
|
|
12
|
-
//# sourceMappingURL=create-user-organization.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-user-organization.d.ts","sourceRoot":"","sources":["../../../src/repositories/user_organisation/create-user-organization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAE3B,MAAM,YAAY,CAAC;AAGpB,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,+DAK1C,0BAA0B;;;;;;;;;GAwB9B"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { hashToPostgresParams } from "#src/services/postgres";
|
|
2
|
-
export function createUserOrganizationFactory({ pg }) {
|
|
3
|
-
return async function linkUserToOrganization({ is_external = false, organization_id, user_id, verification_type, }) {
|
|
4
|
-
const { paramsString, valuesString, values } = hashToPostgresParams({
|
|
5
|
-
created_at: new Date(),
|
|
6
|
-
is_external,
|
|
7
|
-
organization_id,
|
|
8
|
-
updated_at: new Date(),
|
|
9
|
-
user_id,
|
|
10
|
-
verification_type,
|
|
11
|
-
verified_at: verification_type ? new Date() : undefined,
|
|
12
|
-
});
|
|
13
|
-
const { rows } = await pg.query(`
|
|
14
|
-
INSERT INTO users_organizations
|
|
15
|
-
${paramsString}
|
|
16
|
-
VALUES
|
|
17
|
-
${valuesString}
|
|
18
|
-
RETURNING *;`, values);
|
|
19
|
-
return rows.shift();
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext, FindUserOrganizationLink } from "#src/types";
|
|
2
|
-
export declare function deleteUserOrganizationFactory({ pg }: DatabaseContext): ({ user_id, organization_id, }: FindUserOrganizationLink) => Promise<boolean>;
|
|
3
|
-
//# sourceMappingURL=delete-user-organization.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete-user-organization.d.ts","sourceRoot":"","sources":["../../../src/repositories/user_organisation/delete-user-organization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAK5E,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,+BAG1C,wBAAwB,sBAY5B"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
export function deleteUserOrganizationFactory({ pg }) {
|
|
4
|
-
return async function deleteUserOrganization({ user_id, organization_id, }) {
|
|
5
|
-
const { rowCount, affectedRows } = (await pg.query(`
|
|
6
|
-
DELETE
|
|
7
|
-
FROM users_organizations
|
|
8
|
-
WHERE user_id = $1
|
|
9
|
-
AND organization_id = $2`, [user_id, organization_id]));
|
|
10
|
-
return (affectedRows ?? rowCount ?? 0) > 0;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext, FindUserOrganizationLink, UserOrganizationLink } from "#src/types";
|
|
2
|
-
export declare function updateUserOrganizationFactory({ pg }: DatabaseContext): ({ organization_id, user_id }: FindUserOrganizationLink, fieldsToUpdate: Partial<UserOrganizationLink>) => Promise<{
|
|
3
|
-
is_external: boolean;
|
|
4
|
-
verification_type: "domain" | "organization_dirigeant" | "code_sent_to_official_contact_email" | "imported_from_coop_mediation_numerique" | "imported_from_inclusion_connect" | "in_liste_dirigeants_rna" | "in_liste_dirigeants_rne" | "official_contact_email" | "ordre_professionnel_domain" | "proof_received" | "verified_by_coop_mediation_numerique" | "bypassed" | "domain_not_verified_yet" | "no_validation_means_available" | "no_verification_means_for_entreprise_unipersonnelle" | "no_verification_means_for_small_association" | "no_verification_means_for_small_organization";
|
|
5
|
-
verified_at: Date | null;
|
|
6
|
-
has_been_greeted: boolean;
|
|
7
|
-
user_id: number;
|
|
8
|
-
organization_id: number;
|
|
9
|
-
created_at: Date;
|
|
10
|
-
updated_at: Date;
|
|
11
|
-
}>;
|
|
12
|
-
//# sourceMappingURL=update-user-organization.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-user-organization.d.ts","sourceRoot":"","sources":["../../../src/repositories/user_organisation/update-user-organization.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EACf,wBAAwB,EAExB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAEjE,8BAA8B,wBAAwB,EACtD,gBAAgB,OAAO,CAAC,oBAAoB,CAAC;;;;;;;;;GAyBhD"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { hashToPostgresParams } from "#src/services/postgres";
|
|
3
|
-
//
|
|
4
|
-
export function updateUserOrganizationFactory({ pg }) {
|
|
5
|
-
return async function updateUserOrganization({ organization_id, user_id }, fieldsToUpdate) {
|
|
6
|
-
const connection = pg;
|
|
7
|
-
const fieldsToUpdateWithTimestamps = {
|
|
8
|
-
...fieldsToUpdate,
|
|
9
|
-
updated_at: new Date(),
|
|
10
|
-
};
|
|
11
|
-
const { paramsString, valuesString, values } = hashToPostgresParams(fieldsToUpdateWithTimestamps);
|
|
12
|
-
const { rows } = await connection.query(`
|
|
13
|
-
UPDATE users_organizations SET ${paramsString} = ${valuesString}
|
|
14
|
-
WHERE organization_id = $${values.length + 1}
|
|
15
|
-
AND user_id = $${values.length + 2}
|
|
16
|
-
RETURNING *
|
|
17
|
-
`, [...values, organization_id, user_id]);
|
|
18
|
-
return rows.shift();
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
|
-
import assert from "node:assert/strict";
|
|
5
|
-
import { before, beforeEach, describe, it } from "node:test";
|
|
6
|
-
import { deleteFranceconnectUserinfoFactory } from "./delete-franceconnect-userinfo.js";
|
|
7
|
-
import { findFranceconnectUserinfoFactory } from "./find-franceconnect-userinfo.js";
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
const deleteFranceconnectUserinfo = deleteFranceconnectUserinfoFactory({
|
|
12
|
-
pg: pg as any,
|
|
13
|
-
});
|
|
14
|
-
const findFranceconnectUserinfo = findFranceconnectUserinfoFactory({
|
|
15
|
-
pg: pg as any,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
describe("deleteFranceConnectUserInfo", () => {
|
|
19
|
-
before(migrate);
|
|
20
|
-
beforeEach(emptyDatabase);
|
|
21
|
-
|
|
22
|
-
it("should delete franceconnect user info", async () => {
|
|
23
|
-
await pg.sql`
|
|
24
|
-
INSERT INTO users
|
|
25
|
-
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
26
|
-
VALUES
|
|
27
|
-
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque')
|
|
28
|
-
;
|
|
29
|
-
`;
|
|
30
|
-
await pg.sql`
|
|
31
|
-
INSERT INTO franceconnect_userinfo
|
|
32
|
-
(user_id, birthdate, birthplace, family_name, gender, given_name, preferred_username, sub, created_at, updated_at)
|
|
33
|
-
VALUES
|
|
34
|
-
(1, '8888-08-08', 'Caliban', 'El''Jonson', 'male', 'Li', 'Li', 'abcdefghijklmnopqrstuvwxyz', '4444-04-04', '4444-04-04')
|
|
35
|
-
;
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
await deleteFranceconnectUserinfo(1);
|
|
39
|
-
|
|
40
|
-
const user = await findFranceconnectUserinfo(1);
|
|
41
|
-
assert.equal(user, undefined);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("should not throw when deleting a user_id with no row", async () => {
|
|
45
|
-
await assert.doesNotReject(() => deleteFranceconnectUserinfo(42));
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import type { DatabaseContext } from "#src/types";
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
export function deleteFranceconnectUserinfoFactory({ pg }: DatabaseContext) {
|
|
8
|
-
return async function deleteFranceconnectUserinfo(user_id: number) {
|
|
9
|
-
return pg.query(
|
|
10
|
-
`
|
|
11
|
-
DELETE FROM franceconnect_userinfo
|
|
12
|
-
WHERE user_id = $1
|
|
13
|
-
`,
|
|
14
|
-
[user_id],
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type DeleteFranceconnectUserinfoHandler = ReturnType<
|
|
20
|
-
typeof deleteFranceconnectUserinfoFactory
|
|
21
|
-
>;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
|
-
import assert from "node:assert/strict";
|
|
5
|
-
import { before, beforeEach, describe, it, mock } from "node:test";
|
|
6
|
-
import { upsertFranceconnectUserinfoFactory } from "./upsert-franceconnect-userinfo.js";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
const upsertFranceconnectUserinfo = upsertFranceconnectUserinfoFactory({
|
|
11
|
-
pg: pg as any,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
describe("upsertFranceconnectUserinfo", () => {
|
|
15
|
-
before(migrate);
|
|
16
|
-
beforeEach(emptyDatabase);
|
|
17
|
-
before(() => {
|
|
18
|
-
mock.timers.enable({ apis: ["Date"], now: new Date("4444-04-04") });
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should insert a user franceconnect userinfo", async () => {
|
|
22
|
-
await pg.sql`
|
|
23
|
-
INSERT INTO users
|
|
24
|
-
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
25
|
-
VALUES
|
|
26
|
-
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque')
|
|
27
|
-
;
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
const user = await upsertFranceconnectUserinfo({
|
|
31
|
-
birthdate: new Date("8888-08-08"),
|
|
32
|
-
birthplace: "Caliban",
|
|
33
|
-
created_at: new Date("4444-04-01"),
|
|
34
|
-
family_name: "El’Jonson",
|
|
35
|
-
gender: "male",
|
|
36
|
-
given_name: "Lion",
|
|
37
|
-
preferred_username: "Li",
|
|
38
|
-
sub: "abcdefghijklmnopqrstuvwxyz",
|
|
39
|
-
updated_at: new Date("4444-04-02"),
|
|
40
|
-
user_id: 1,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
assert.deepEqual(user, {
|
|
44
|
-
birthcountry: null,
|
|
45
|
-
birthdate: new Date("8888-08-08"),
|
|
46
|
-
birthplace: "Caliban",
|
|
47
|
-
created_at: new Date("4444-04-01"),
|
|
48
|
-
family_name: "El’Jonson",
|
|
49
|
-
gender: "male",
|
|
50
|
-
given_name: "Lion",
|
|
51
|
-
preferred_username: "Li",
|
|
52
|
-
sub: "abcdefghijklmnopqrstuvwxyz",
|
|
53
|
-
updated_at: new Date("4444-04-04"),
|
|
54
|
-
user_id: 1,
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("should update a user Verification link", async () => {
|
|
59
|
-
await pg.sql`
|
|
60
|
-
INSERT INTO users
|
|
61
|
-
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
62
|
-
VALUES
|
|
63
|
-
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque')
|
|
64
|
-
;
|
|
65
|
-
`;
|
|
66
|
-
await pg.sql`
|
|
67
|
-
INSERT INTO franceconnect_userinfo
|
|
68
|
-
(user_id, created_at, updated_at, given_name)
|
|
69
|
-
VALUES
|
|
70
|
-
(1, '4444-04-01', '4444-04-02', 'Lion')
|
|
71
|
-
;
|
|
72
|
-
`;
|
|
73
|
-
|
|
74
|
-
const user = await upsertFranceconnectUserinfo({
|
|
75
|
-
user_id: 1,
|
|
76
|
-
preferred_username: "Li",
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
assert.deepEqual(user, {
|
|
80
|
-
birthcountry: null,
|
|
81
|
-
birthdate: null,
|
|
82
|
-
birthplace: null,
|
|
83
|
-
created_at: new Date("4444-04-01"),
|
|
84
|
-
family_name: null,
|
|
85
|
-
gender: null,
|
|
86
|
-
given_name: "Lion",
|
|
87
|
-
preferred_username: "Li",
|
|
88
|
-
sub: null,
|
|
89
|
-
updated_at: new Date("4444-04-04"),
|
|
90
|
-
user_id: 1,
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("❎ fail to update an unknown user", async () => {
|
|
95
|
-
await assert.rejects(
|
|
96
|
-
upsertFranceconnectUserinfo({
|
|
97
|
-
user_id: 42,
|
|
98
|
-
}),
|
|
99
|
-
`error: insert or update on table "franceconnect_userinfo" violates foreign key constraint "franceconnect_userinfo_user_id_fkey"`,
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { hashToPostgresParams } from "#src/services/postgres";
|
|
4
|
-
import type { DatabaseContext, FranceConnectUserInfo } from "#src/types";
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
export function upsertFranceconnectUserinfoFactory({ pg }: DatabaseContext) {
|
|
9
|
-
return async function upsertFranceconnectUserinfo(
|
|
10
|
-
value: Pick<FranceConnectUserInfo, "user_id"> &
|
|
11
|
-
Partial<FranceConnectUserInfo>,
|
|
12
|
-
) {
|
|
13
|
-
const fieldsWithTimestamps = {
|
|
14
|
-
...value,
|
|
15
|
-
updated_at: new Date(),
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const { paramsString, valuesString, values } =
|
|
19
|
-
hashToPostgresParams<FranceConnectUserInfo>(fieldsWithTimestamps);
|
|
20
|
-
|
|
21
|
-
const { rows } = await pg.query<FranceConnectUserInfo>(
|
|
22
|
-
`
|
|
23
|
-
INSERT INTO franceconnect_userinfo
|
|
24
|
-
${paramsString}
|
|
25
|
-
VALUES
|
|
26
|
-
${valuesString}
|
|
27
|
-
ON CONFLICT (user_id)
|
|
28
|
-
DO UPDATE
|
|
29
|
-
SET ${paramsString} = ${valuesString}
|
|
30
|
-
RETURNING *
|
|
31
|
-
`,
|
|
32
|
-
[...values],
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
return rows.shift()!;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type UpsetFranceconnectUserinfoHandler = ReturnType<
|
|
40
|
-
typeof upsertFranceconnectUserinfoFactory
|
|
41
|
-
>;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
|
-
import assert from "node:assert/strict";
|
|
5
|
-
import { before, beforeEach, suite, test } from "node:test";
|
|
6
|
-
import { createModerationFactory } from "./create-moderation.js";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
const createModeration = createModerationFactory({ pg: pg as any });
|
|
11
|
-
|
|
12
|
-
suite("createModerationFactory", () => {
|
|
13
|
-
before(migrate);
|
|
14
|
-
beforeEach(emptyDatabase);
|
|
15
|
-
|
|
16
|
-
test("should insert and return the moderation", async () => {
|
|
17
|
-
await pg.sql`
|
|
18
|
-
INSERT INTO organizations
|
|
19
|
-
(cached_libelle, cached_nom_complet, id, siret, created_at, updated_at)
|
|
20
|
-
VALUES
|
|
21
|
-
('Necron', 'Necrontyr', 1, '⚰️', '1967-12-19', '1967-12-19')
|
|
22
|
-
;
|
|
23
|
-
`;
|
|
24
|
-
await pg.sql`
|
|
25
|
-
INSERT INTO users
|
|
26
|
-
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
27
|
-
VALUES
|
|
28
|
-
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque')
|
|
29
|
-
;
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
|
-
const moderation = await createModeration({
|
|
33
|
-
user_id: 1,
|
|
34
|
-
organization_id: 1,
|
|
35
|
-
type: "organization_join_block",
|
|
36
|
-
ticket_id: null,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
assert.equal(moderation.user_id, 1);
|
|
40
|
-
assert.equal(moderation.organization_id, 1);
|
|
41
|
-
assert.equal(moderation.status, "pending");
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ModerationStatusSchema,
|
|
5
|
-
type DatabaseContext,
|
|
6
|
-
type Moderation,
|
|
7
|
-
type ModerationType,
|
|
8
|
-
} from "#src/types";
|
|
9
|
-
import { type QueryResult } from "pg";
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
export function createModerationFactory({ pg }: DatabaseContext) {
|
|
14
|
-
return async function createModeration({
|
|
15
|
-
user_id,
|
|
16
|
-
organization_id,
|
|
17
|
-
sp_name,
|
|
18
|
-
type,
|
|
19
|
-
ticket_id,
|
|
20
|
-
}: {
|
|
21
|
-
user_id: number;
|
|
22
|
-
organization_id: number;
|
|
23
|
-
sp_name?: string;
|
|
24
|
-
type: ModerationType;
|
|
25
|
-
ticket_id: string | null;
|
|
26
|
-
}) {
|
|
27
|
-
const { rows }: QueryResult<Moderation> = await pg.query(
|
|
28
|
-
`
|
|
29
|
-
INSERT INTO moderations (user_id, organization_id, status, type, ticket_id, sp_name, allow_editing)
|
|
30
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
31
|
-
RETURNING *;`,
|
|
32
|
-
[
|
|
33
|
-
user_id,
|
|
34
|
-
organization_id,
|
|
35
|
-
ModerationStatusSchema.enum.pending,
|
|
36
|
-
type,
|
|
37
|
-
ticket_id,
|
|
38
|
-
sp_name ?? null,
|
|
39
|
-
false,
|
|
40
|
-
],
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return rows.shift()!;
|
|
44
|
-
};
|
|
45
|
-
}
|