@proconnect-gouv/proconnect.identite 12.0.0 → 14.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 +22 -0
- package/dist/connectors/index.d.ts +0 -93
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/index.js +6 -15
- package/dist/managers/organization/index.d.ts +0 -1
- package/dist/managers/organization/index.d.ts.map +1 -1
- package/dist/managers/organization/index.js +0 -1
- package/dist/repositories/email-domain/index.d.ts +0 -3
- package/dist/repositories/email-domain/index.d.ts.map +1 -1
- package/dist/repositories/email-domain/index.js +0 -1
- 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/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/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/package.json +3 -3
- package/src/connectors/index.ts +1 -22
- package/src/managers/organization/index.ts +0 -1
- package/src/repositories/email-domain/index.ts +0 -3
- package/src/repositories/franceconnect_userinfo/index.ts +0 -2
- package/src/repositories/moderation/index.ts +0 -1
- package/src/repositories/organization/index.ts +0 -1
- package/src/repositories/user/index.ts +0 -1
- package/src/repositories/user_organisation/index.ts +0 -3
- package/dist/managers/organization/mark-domain-as-verified.d.ts +0 -18
- package/dist/managers/organization/mark-domain-as-verified.d.ts.map +0 -1
- package/dist/managers/organization/mark-domain-as-verified.js +0 -64
- package/dist/managers/user/assign-user-verification-type-to-domain.d.ts +0 -3
- package/dist/managers/user/assign-user-verification-type-to-domain.d.ts.map +0 -1
- package/dist/managers/user/assign-user-verification-type-to-domain.js +0 -20
- package/dist/managers/user/index.d.ts +0 -2
- package/dist/managers/user/index.d.ts.map +0 -1
- package/dist/managers/user/index.js +0 -1
- package/dist/repositories/email-domain/delete-email-domains-by-verification-types.d.ts +0 -8
- package/dist/repositories/email-domain/delete-email-domains-by-verification-types.d.ts.map +0 -1
- package/dist/repositories/email-domain/delete-email-domains-by-verification-types.js +0 -19
- 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-users-by-organization.d.ts +0 -34
- package/dist/repositories/organization/find-users-by-organization.d.ts.map +0 -1
- package/dist/repositories/organization/find-users-by-organization.js +0 -16
- 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/managers/organization/mark-domain-as-verified.test.ts +0 -250
- package/src/managers/organization/mark-domain-as-verified.ts +0 -123
- package/src/managers/user/assign-user-verification-type-to-domain.test.ts +0 -105
- package/src/managers/user/assign-user-verification-type-to-domain.ts +0 -40
- package/src/managers/user/index.ts +0 -1
- package/src/repositories/email-domain/delete-email-domains-by-verification-types.test.ts +0 -49
- package/src/repositories/email-domain/delete-email-domains-by-verification-types.ts +0 -45
- 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-users-by-organization.test.ts +0 -51
- package/src/repositories/organization/find-users-by-organization.test.ts.snapshot +0 -35
- package/src/repositories/organization/find-users-by-organization.ts +0 -30
- 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
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { NotFoundError } from "#src/errors";
|
|
3
|
-
import { assignUserVerificationTypeToDomainFactory } from "#src/managers/user";
|
|
4
|
-
import { EmailDomainApprovedVerificationValues, EmailDomainPendingVerificationValues, EmailDomainRejectedVerificationValues, } from "#src/types";
|
|
5
|
-
import { isEmpty } from "lodash-es";
|
|
6
|
-
import { match } from "ts-pattern";
|
|
7
|
-
//
|
|
8
|
-
export function markDomainAsVerifiedFactory(context) {
|
|
9
|
-
const assignUserVerificationTypeToDomain = assignUserVerificationTypeToDomainFactory(context);
|
|
10
|
-
const { repository: { email_domains, organizations }, } = context;
|
|
11
|
-
return async function markDomainAsVerified({ organization_id, domain, domain_verification_type, }) {
|
|
12
|
-
const organization = await organizations.findById(organization_id);
|
|
13
|
-
if (isEmpty(organization)) {
|
|
14
|
-
throw new NotFoundError();
|
|
15
|
-
}
|
|
16
|
-
return match(domain_verification_type)
|
|
17
|
-
.with(...EmailDomainApprovedVerificationValues, async (approved_verification_type) => {
|
|
18
|
-
await assignUserVerificationTypeToDomain(organization_id, domain);
|
|
19
|
-
return markDomainAsApproved({
|
|
20
|
-
organization_id,
|
|
21
|
-
domain,
|
|
22
|
-
domain_verification_type: approved_verification_type,
|
|
23
|
-
});
|
|
24
|
-
})
|
|
25
|
-
.with(...EmailDomainRejectedVerificationValues, (rejected_verification_type) => markDomainAsRejected({
|
|
26
|
-
organization_id,
|
|
27
|
-
domain,
|
|
28
|
-
domain_verification_type: rejected_verification_type,
|
|
29
|
-
}))
|
|
30
|
-
.exhaustive();
|
|
31
|
-
};
|
|
32
|
-
async function markDomainAsApproved({ organization_id, domain, domain_verification_type, }) {
|
|
33
|
-
await email_domains.deleteEmailDomainsByVerificationTypes({
|
|
34
|
-
organization_id,
|
|
35
|
-
domain,
|
|
36
|
-
domain_verification_types: [
|
|
37
|
-
...EmailDomainApprovedVerificationValues,
|
|
38
|
-
...EmailDomainPendingVerificationValues,
|
|
39
|
-
...EmailDomainRejectedVerificationValues,
|
|
40
|
-
],
|
|
41
|
-
});
|
|
42
|
-
return email_domains.addDomain({
|
|
43
|
-
organization_id,
|
|
44
|
-
domain,
|
|
45
|
-
verification_type: domain_verification_type,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
async function markDomainAsRejected({ organization_id, domain, domain_verification_type, }) {
|
|
49
|
-
await email_domains.deleteEmailDomainsByVerificationTypes({
|
|
50
|
-
organization_id,
|
|
51
|
-
domain,
|
|
52
|
-
domain_verification_types: [
|
|
53
|
-
...EmailDomainApprovedVerificationValues,
|
|
54
|
-
...EmailDomainPendingVerificationValues,
|
|
55
|
-
...EmailDomainRejectedVerificationValues,
|
|
56
|
-
],
|
|
57
|
-
});
|
|
58
|
-
return email_domains.addDomain({
|
|
59
|
-
organization_id,
|
|
60
|
-
domain,
|
|
61
|
-
verification_type: domain_verification_type,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { Context } from "#src/connectors";
|
|
2
|
-
export declare function assignUserVerificationTypeToDomainFactory({ repository: { organizations, users_organizations }, }: Context): (organization_id: number, domain: string) => Promise<void>;
|
|
3
|
-
//# sourceMappingURL=assign-user-verification-type-to-domain.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assign-user-verification-type-to-domain.d.ts","sourceRoot":"","sources":["../../../src/managers/user/assign-user-verification-type-to-domain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAM/C,wBAAgB,yCAAyC,CAAC,EACxD,UAAU,EAAE,EAAE,aAAa,EAAE,mBAAmB,EAAE,GACnD,EAAE,OAAO,IAEN,iBAAiB,MAAM,EACvB,QAAQ,MAAM,mBA0BjB"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { LinkEnum, SuperWeakLinkEnum, UnverifiedLinkEnum } from "#src/types";
|
|
3
|
-
import { getEmailDomain } from "@proconnect-gouv/proconnect.core/services/email";
|
|
4
|
-
//
|
|
5
|
-
export function assignUserVerificationTypeToDomainFactory({ repository: { organizations, users_organizations }, }) {
|
|
6
|
-
return async function assignUserVerificationTypeToDomain(organization_id, domain) {
|
|
7
|
-
const usersInOrganization = await organizations.findUsers(organization_id);
|
|
8
|
-
await Promise.all(usersInOrganization.map(({ id: user_id, email, verification_type: link_verification_type }) => {
|
|
9
|
-
const userDomain = getEmailDomain(email);
|
|
10
|
-
if (userDomain === domain &&
|
|
11
|
-
(UnverifiedLinkEnum.safeParse(link_verification_type).success ||
|
|
12
|
-
SuperWeakLinkEnum.safeParse(link_verification_type).success)) {
|
|
13
|
-
return users_organizations.update({ organization_id, user_id }, {
|
|
14
|
-
verification_type: LinkEnum.enum.domain,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
}));
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/managers/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,8CAA8C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./assign-user-verification-type-to-domain.js";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext, EmailDomain, EmailDomainVerificationType } from "#src/types";
|
|
2
|
-
export declare function deleteEmailDomainsByVerificationTypesFactory({ pg, }: DatabaseContext): ({ organization_id, domain, domain_verification_types, }: {
|
|
3
|
-
organization_id: EmailDomain["organization_id"];
|
|
4
|
-
domain_verification_types: EmailDomainVerificationType[];
|
|
5
|
-
domain: EmailDomain["domain"];
|
|
6
|
-
}) => Promise<import("pg").QueryResult<any>>;
|
|
7
|
-
export type DeleteEmailDomainsByVerificationTypesHandler = ReturnType<typeof deleteEmailDomainsByVerificationTypesFactory>;
|
|
8
|
-
//# sourceMappingURL=delete-email-domains-by-verification-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete-email-domains-by-verification-types.d.ts","sourceRoot":"","sources":["../../../src/repositories/email-domain/delete-email-domains-by-verification-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AAIpB,wBAAgB,4CAA4C,CAAC,EAC3D,EAAE,GACH,EAAE,eAAe,IAC4C,yDAIzD;IACD,eAAe,EAAE,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAChD,yBAAyB,EAAE,2BAA2B,EAAE,CAAC;IACzD,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;CAC/B,4CAmBF;AAED,MAAM,MAAM,4CAA4C,GAAG,UAAU,CACnE,OAAO,4CAA4C,CACpD,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
export function deleteEmailDomainsByVerificationTypesFactory({ pg, }) {
|
|
4
|
-
return async function deleteEmailDomainsByVerificationTypes({ organization_id, domain, domain_verification_types, }) {
|
|
5
|
-
const SQL_VERIFICATION_TYPES = domain_verification_types
|
|
6
|
-
.map((type) => `verification_type = '${type}'`)
|
|
7
|
-
.join(" OR ");
|
|
8
|
-
return pg.query(`
|
|
9
|
-
DELETE FROM email_domains
|
|
10
|
-
WHERE
|
|
11
|
-
${[
|
|
12
|
-
"organization_id = $1",
|
|
13
|
-
"domain = $2",
|
|
14
|
-
`(${SQL_VERIFICATION_TYPES})`,
|
|
15
|
-
].join(" AND ")}
|
|
16
|
-
;
|
|
17
|
-
`, [organization_id, domain]);
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -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,34 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext } from "#src/types";
|
|
2
|
-
export declare function findUsersByOrganizationFactory({ pg }: DatabaseContext): (organization_id: number) => Promise<({
|
|
3
|
-
created_at: Date;
|
|
4
|
-
current_challenge: string | null;
|
|
5
|
-
email: string;
|
|
6
|
-
email_verified: boolean;
|
|
7
|
-
email_verified_at: Date | null;
|
|
8
|
-
encrypted_password: string | null;
|
|
9
|
-
encrypted_totp_key: string | null;
|
|
10
|
-
family_name: string | null;
|
|
11
|
-
force_2fa: boolean;
|
|
12
|
-
given_name: string | null;
|
|
13
|
-
id: number;
|
|
14
|
-
job: string | null;
|
|
15
|
-
last_sign_in_at: Date | null;
|
|
16
|
-
magic_link_sent_at: Date | null;
|
|
17
|
-
magic_link_token: string | null;
|
|
18
|
-
needs_inclusionconnect_onboarding_help: boolean;
|
|
19
|
-
needs_inclusionconnect_welcome_page: boolean;
|
|
20
|
-
phone_number: string | null;
|
|
21
|
-
reset_password_sent_at: Date | null;
|
|
22
|
-
reset_password_token: string | null;
|
|
23
|
-
sign_in_count: number;
|
|
24
|
-
totp_key_verified_at: Date | null;
|
|
25
|
-
updated_at: Date;
|
|
26
|
-
verify_email_sent_at: Date | null;
|
|
27
|
-
verify_email_token: string | null;
|
|
28
|
-
} & {
|
|
29
|
-
is_external: boolean;
|
|
30
|
-
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";
|
|
31
|
-
verified_at: Date | null;
|
|
32
|
-
has_been_greeted: boolean;
|
|
33
|
-
})[]>;
|
|
34
|
-
//# sourceMappingURL=find-users-by-organization.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-users-by-organization.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/find-users-by-organization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,iBAAiB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAiBtE"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
export function findUsersByOrganizationFactory({ pg }) {
|
|
4
|
-
return async function findUsersByOrganization(organization_id) {
|
|
5
|
-
const { rows } = await pg.query(`
|
|
6
|
-
SELECT u.*,
|
|
7
|
-
uo.is_external,
|
|
8
|
-
uo.verification_type,
|
|
9
|
-
uo.verified_at,
|
|
10
|
-
uo.has_been_greeted
|
|
11
|
-
FROM users u
|
|
12
|
-
INNER JOIN users_organizations AS uo ON uo.user_id = u.id
|
|
13
|
-
WHERE uo.organization_id = $1`, [organization_id]);
|
|
14
|
-
return rows;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -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
|
-
}
|