@proconnect-gouv/proconnect.identite.runtime 0.2.0 → 0.3.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 +11 -0
- package/dist/activity/activity-context-schemas.d.ts +26 -0
- package/dist/activity/activity-context-schemas.d.ts.map +1 -1
- package/dist/activity/activity-context-schemas.js +5 -1
- package/dist/domains/mark-domain-as-verified.d.ts.map +1 -1
- package/dist/domains/mark-domain-as-verified.js +21 -6
- package/dist/journal/insert-activity.d.ts +3 -1
- package/dist/journal/insert-activity.d.ts.map +1 -1
- package/dist/memberships/activities.d.ts +30 -0
- package/dist/memberships/activities.d.ts.map +1 -0
- package/dist/memberships/activities.js +14 -0
- package/dist/memberships/index.d.ts +2 -0
- package/dist/memberships/index.d.ts.map +1 -0
- package/dist/memberships/index.js +2 -0
- package/package.json +2 -2
- package/src/activity/activity-context-schemas.ts +5 -1
- package/src/domains/mark-domain-as-verified.test.ts +79 -2
- package/src/domains/mark-domain-as-verified.ts +26 -6
- package/src/journal/insert-activity.ts +1 -1
- package/src/memberships/activities.ts +17 -0
- package/src/memberships/index.ts +3 -0
- package/src/runtime/create-identite-runtime.test.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @proconnect-gouv/proconnect.identite.runtime
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2370](https://github.com/proconnect-gouv/proconnect-identite/pull/2370) [`d3dd8ca`](https://github.com/proconnect-gouv/proconnect-identite/commit/d3dd8cada634db4d3ed9a08d3b6f0ff4000ea97c) Thanks [@douglasduteil](https://github.com/douglasduteil)! - Journalise les membres promus par une vérification de domaine. `markDomainAsVerified` ajoute, dans sa transaction, une ligne `member.promoted` par membre promu, sous l'acteur `{ type: "app", job: "domain.promote_members" }`, avec `user_id`, `organization_id` et `cause_activity_id` pointant vers la ligne `domain.verified`. `activityContextSchemas` décrit la nouvelle action : `inputs.previous_verification_type`, `outcome.verification_type`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`d3dd8ca`](https://github.com/proconnect-gouv/proconnect-identite/commit/d3dd8cada634db4d3ed9a08d3b6f0ff4000ea97c)]:
|
|
12
|
+
- @proconnect-gouv/proconnect.identite.database@1.12.0
|
|
13
|
+
|
|
3
14
|
## 0.2.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
import type { ContextsOf } from "./types.js";
|
|
2
2
|
export declare const activityContextSchemas: {
|
|
3
|
+
"member.promoted": import("zod").ZodObject<{
|
|
4
|
+
inputs: import("zod").ZodObject<{
|
|
5
|
+
previous_verification_type: import("zod").ZodString;
|
|
6
|
+
}, import("zod/v4/core").$strip>;
|
|
7
|
+
outcome: import("zod").ZodObject<{
|
|
8
|
+
verification_type: import("zod").ZodEnum<{
|
|
9
|
+
domain: "domain";
|
|
10
|
+
organization_dirigeant: "organization_dirigeant";
|
|
11
|
+
code_sent_to_official_contact_email: "code_sent_to_official_contact_email";
|
|
12
|
+
imported_from_coop_mediation_numerique: "imported_from_coop_mediation_numerique";
|
|
13
|
+
imported_from_inclusion_connect: "imported_from_inclusion_connect";
|
|
14
|
+
in_liste_dirigeants_rna: "in_liste_dirigeants_rna";
|
|
15
|
+
in_liste_dirigeants_rne: "in_liste_dirigeants_rne";
|
|
16
|
+
official_contact_email: "official_contact_email";
|
|
17
|
+
ordre_professionnel_domain: "ordre_professionnel_domain";
|
|
18
|
+
proof_received: "proof_received";
|
|
19
|
+
verified_by_coop_mediation_numerique: "verified_by_coop_mediation_numerique";
|
|
20
|
+
bypassed: "bypassed";
|
|
21
|
+
domain_not_verified_yet: "domain_not_verified_yet";
|
|
22
|
+
no_validation_means_available: "no_validation_means_available";
|
|
23
|
+
no_verification_means_for_entreprise_unipersonnelle: "no_verification_means_for_entreprise_unipersonnelle";
|
|
24
|
+
no_verification_means_for_small_association: "no_verification_means_for_small_association";
|
|
25
|
+
no_verification_means_for_small_organization: "no_verification_means_for_small_organization";
|
|
26
|
+
}>;
|
|
27
|
+
}, import("zod/v4/core").$strip>;
|
|
28
|
+
}, import("zod/v4/core").$strip>;
|
|
3
29
|
"domain.verified": import("zod").ZodObject<{
|
|
4
30
|
inputs: import("zod").ZodObject<{
|
|
5
31
|
domain: import("zod").ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity-context-schemas.d.ts","sourceRoot":"","sources":["../../src/activity/activity-context-schemas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"activity-context-schemas.d.ts","sourceRoot":"","sources":["../../src/activity/activity-context-schemas.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGlC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
//
|
|
2
2
|
import { domainActivities } from "#src/domains";
|
|
3
|
+
import { membershipActivities } from "#src/memberships";
|
|
3
4
|
//
|
|
4
|
-
export const activityContextSchemas = {
|
|
5
|
+
export const activityContextSchemas = {
|
|
6
|
+
...domainActivities,
|
|
7
|
+
...membershipActivities,
|
|
8
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mark-domain-as-verified.d.ts","sourceRoot":"","sources":["../../src/domains/mark-domain-as-verified.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,eAAe,CAAC;AAOtE,OAAO,EAKL,KAAK,mCAAmC,EACzC,MAAM,4CAA4C,CAAC;AAKpD,KAAK,2BAA2B,GAC5B;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,iBAAiB,EAAE,mCAAmC,CAAC;KACxD,CAAC;IACF,gBAAgB,EAAE,aAAa,CAAC;QAC9B,0BAA0B,EAAE,MAAM,CAAC;QACnC,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,2BAA2B,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACpD,GACD;IAAE,IAAI,EAAE,wBAAwB,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,wBAAgB,2BAA2B,CAAC,EAC1C,KAAK,EACL,GAAG,EACH,EAAE,GACH,EAAE,cAAc,IACsB,wDAIlC;IACD,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,mCAAmC,CAAC;IAC9D,eAAe,EAAE,MAAM,CAAC;CACzB,KAAG,OAAO,CAAC,2BAA2B,CAAC,
|
|
1
|
+
{"version":3,"file":"mark-domain-as-verified.d.ts","sourceRoot":"","sources":["../../src/domains/mark-domain-as-verified.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,eAAe,CAAC;AAOtE,OAAO,EAKL,KAAK,mCAAmC,EACzC,MAAM,4CAA4C,CAAC;AAKpD,KAAK,2BAA2B,GAC5B;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,iBAAiB,EAAE,mCAAmC,CAAC;KACxD,CAAC;IACF,gBAAgB,EAAE,aAAa,CAAC;QAC9B,0BAA0B,EAAE,MAAM,CAAC;QACnC,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,2BAA2B,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACpD,GACD;IAAE,IAAI,EAAE,wBAAwB,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,wBAAgB,2BAA2B,CAAC,EAC1C,KAAK,EACL,GAAG,EACH,EAAE,GACH,EAAE,cAAc,IACsB,wDAIlC;IACD,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,mCAAmC,CAAC;IAC9D,eAAe,EAAE,MAAM,CAAC;CACzB,KAAG,OAAO,CAAC,2BAA2B,CAAC,CA4HzC"}
|
|
@@ -28,6 +28,12 @@ export function markDomainAsVerifiedFactory({ actor, app, db, }) {
|
|
|
28
28
|
domain,
|
|
29
29
|
members,
|
|
30
30
|
});
|
|
31
|
+
const promoted_members = memberships
|
|
32
|
+
.filter(({ user_id }) => promoted_member_ids.includes(user_id))
|
|
33
|
+
.map(({ user_id, verification_type }) => ({
|
|
34
|
+
previous_verification_type: verification_type,
|
|
35
|
+
user_id,
|
|
36
|
+
}));
|
|
31
37
|
const replaced = await tx
|
|
32
38
|
.delete(email_domains)
|
|
33
39
|
.where(and(eq(email_domains.organization_id, organization_id), eq(email_domains.domain, domain), inArray(email_domains.verification_type, [
|
|
@@ -67,6 +73,20 @@ export function markDomainAsVerifiedFactory({ actor, app, db, }) {
|
|
|
67
73
|
verification_type: LinkEnum.enum.domain,
|
|
68
74
|
})
|
|
69
75
|
.where(and(eq(users_organizations.organization_id, organization_id), inArray(users_organizations.user_id, promoted_member_ids)));
|
|
76
|
+
for (const { previous_verification_type, user_id, } of promoted_members) {
|
|
77
|
+
await insertActivity(tx, {
|
|
78
|
+
action: "member.promoted",
|
|
79
|
+
actor: { type: "app", job: "domain.promote_members" },
|
|
80
|
+
app,
|
|
81
|
+
cause_activity_id: activity_id,
|
|
82
|
+
context: {
|
|
83
|
+
inputs: { previous_verification_type },
|
|
84
|
+
outcome: { verification_type: LinkEnum.enum.domain },
|
|
85
|
+
},
|
|
86
|
+
organization_id,
|
|
87
|
+
user_id,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
70
90
|
}
|
|
71
91
|
return {
|
|
72
92
|
kind: "domain_verified",
|
|
@@ -75,12 +95,7 @@ export function markDomainAsVerifiedFactory({ actor, app, db, }) {
|
|
|
75
95
|
id: email_domain.id,
|
|
76
96
|
verification_type: domain_verification_type,
|
|
77
97
|
},
|
|
78
|
-
promoted_members
|
|
79
|
-
.filter(({ user_id }) => promoted_member_ids.includes(user_id))
|
|
80
|
-
.map(({ user_id, verification_type }) => ({
|
|
81
|
-
previous_verification_type: verification_type,
|
|
82
|
-
user_id,
|
|
83
|
-
})),
|
|
98
|
+
promoted_members,
|
|
84
99
|
replaced_verification_types,
|
|
85
100
|
};
|
|
86
101
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ActivityOf, ActivityTargets, ContextMap, RuntimeContext } from "#src/activity";
|
|
2
2
|
import type { IdentiteTransaction } from "#src/database";
|
|
3
|
-
export declare function insertActivity<Contexts extends ContextMap>(tx: IdentiteTransaction, { actor, app, ...activity }: ActivityOf<Contexts> & ActivityTargets & Pick<RuntimeContext, "actor" | "app">
|
|
3
|
+
export declare function insertActivity<Contexts extends ContextMap>(tx: IdentiteTransaction, { actor, app, ...activity }: ActivityOf<Contexts> & ActivityTargets & Pick<RuntimeContext, "actor" | "app"> & {
|
|
4
|
+
cause_activity_id?: number;
|
|
5
|
+
}): Promise<{
|
|
4
6
|
activity_id: number;
|
|
5
7
|
}>;
|
|
6
8
|
//# sourceMappingURL=insert-activity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert-activity.d.ts","sourceRoot":"","sources":["../../src/journal/insert-activity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACV,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAKzD,wBAAsB,cAAc,CAAC,QAAQ,SAAS,UAAU,EAC9D,EAAE,EAAE,mBAAmB,EACvB,EACE,KAAK,EACL,GAAG,EACH,GAAG,QAAQ,EACZ,EAAE,UAAU,CAAC,QAAQ,CAAC,GACrB,eAAe,GACf,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,KAAK,CAAC;;
|
|
1
|
+
{"version":3,"file":"insert-activity.d.ts","sourceRoot":"","sources":["../../src/journal/insert-activity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACV,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAKzD,wBAAsB,cAAc,CAAC,QAAQ,SAAS,UAAU,EAC9D,EAAE,EAAE,mBAAmB,EACvB,EACE,KAAK,EACL,GAAG,EACH,GAAG,QAAQ,EACZ,EAAE,UAAU,CAAC,QAAQ,CAAC,GACrB,eAAe,GACf,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,KAAK,CAAC,GAAG;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE;;GAQzE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export declare const membershipActivities: {
|
|
3
|
+
"member.promoted": z.ZodObject<{
|
|
4
|
+
inputs: z.ZodObject<{
|
|
5
|
+
previous_verification_type: z.ZodString;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
outcome: z.ZodObject<{
|
|
8
|
+
verification_type: z.ZodEnum<{
|
|
9
|
+
domain: "domain";
|
|
10
|
+
organization_dirigeant: "organization_dirigeant";
|
|
11
|
+
code_sent_to_official_contact_email: "code_sent_to_official_contact_email";
|
|
12
|
+
imported_from_coop_mediation_numerique: "imported_from_coop_mediation_numerique";
|
|
13
|
+
imported_from_inclusion_connect: "imported_from_inclusion_connect";
|
|
14
|
+
in_liste_dirigeants_rna: "in_liste_dirigeants_rna";
|
|
15
|
+
in_liste_dirigeants_rne: "in_liste_dirigeants_rne";
|
|
16
|
+
official_contact_email: "official_contact_email";
|
|
17
|
+
ordre_professionnel_domain: "ordre_professionnel_domain";
|
|
18
|
+
proof_received: "proof_received";
|
|
19
|
+
verified_by_coop_mediation_numerique: "verified_by_coop_mediation_numerique";
|
|
20
|
+
bypassed: "bypassed";
|
|
21
|
+
domain_not_verified_yet: "domain_not_verified_yet";
|
|
22
|
+
no_validation_means_available: "no_validation_means_available";
|
|
23
|
+
no_verification_means_for_entreprise_unipersonnelle: "no_verification_means_for_entreprise_unipersonnelle";
|
|
24
|
+
no_verification_means_for_small_association: "no_verification_means_for_small_association";
|
|
25
|
+
no_verification_means_for_small_organization: "no_verification_means_for_small_organization";
|
|
26
|
+
}>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=activities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/memberships/activities.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;CAShC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
import { LinkEnum } from "@proconnect-gouv/proconnect.identite/types";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
//
|
|
5
|
+
export const membershipActivities = {
|
|
6
|
+
"member.promoted": z.object({
|
|
7
|
+
inputs: z.object({
|
|
8
|
+
previous_verification_type: z.string(),
|
|
9
|
+
}),
|
|
10
|
+
outcome: z.object({
|
|
11
|
+
verification_type: LinkEnum,
|
|
12
|
+
}),
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memberships/index.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proconnect-gouv/proconnect.identite.runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"homepage": "https://github.com/proconnect-gouv/proconnect-identite/tree/main/packages/runtime#readme",
|
|
5
5
|
"bugs": "https://github.com/proconnect-gouv/proconnect-identite/issues",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@proconnect-gouv/proconnect.identite": "^12.0.0",
|
|
35
|
-
"@proconnect-gouv/proconnect.identite.database": "^1.
|
|
35
|
+
"@proconnect-gouv/proconnect.identite.database": "^1.12.0",
|
|
36
36
|
"zod": "^4.6.7"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
3
|
import { domainActivities } from "#src/domains";
|
|
4
|
+
import { membershipActivities } from "#src/memberships";
|
|
4
5
|
import type { ContextsOf } from "./types.js";
|
|
5
6
|
|
|
6
7
|
//
|
|
7
8
|
|
|
8
|
-
export const activityContextSchemas = {
|
|
9
|
+
export const activityContextSchemas = {
|
|
10
|
+
...domainActivities,
|
|
11
|
+
...membershipActivities,
|
|
12
|
+
};
|
|
9
13
|
|
|
10
14
|
export type ActivityContexts = ContextsOf<typeof activityContextSchemas>;
|
|
@@ -87,7 +87,7 @@ describe("markDomainAsVerified", () => {
|
|
|
87
87
|
assert.deepEqual(await readActivityLogs(pg), []);
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
it("✅ replaces the domain states, promotes the domain members and journals the verification", async () => {
|
|
90
|
+
it("✅ replaces the domain states, promotes the domain members and journals the verification and each promotion", async () => {
|
|
91
91
|
const { pg, runtime } = await setup(join_official_contact);
|
|
92
92
|
|
|
93
93
|
const outcome = await runtime.markDomainAsVerified({
|
|
@@ -210,6 +210,7 @@ describe("markDomainAsVerified", () => {
|
|
|
210
210
|
actor_ref: "join.official_contact",
|
|
211
211
|
actor_type: "app",
|
|
212
212
|
app: "proconnect-identite",
|
|
213
|
+
cause_activity_id: null,
|
|
213
214
|
context: {
|
|
214
215
|
inputs: {
|
|
215
216
|
domain: "darkangels.world",
|
|
@@ -227,10 +228,47 @@ describe("markDomainAsVerified", () => {
|
|
|
227
228
|
organization_id: 1,
|
|
228
229
|
user_id: null,
|
|
229
230
|
},
|
|
231
|
+
{
|
|
232
|
+
action: "member.promoted",
|
|
233
|
+
actor_ref: "domain.promote_members",
|
|
234
|
+
actor_type: "app",
|
|
235
|
+
app: "proconnect-identite",
|
|
236
|
+
cause_activity_id: 1,
|
|
237
|
+
context: {
|
|
238
|
+
inputs: {
|
|
239
|
+
previous_verification_type:
|
|
240
|
+
"no_verification_means_for_entreprise_unipersonnelle",
|
|
241
|
+
},
|
|
242
|
+
outcome: { verification_type: "domain" },
|
|
243
|
+
},
|
|
244
|
+
created_at: new Date("5555-05-05"),
|
|
245
|
+
id: 2,
|
|
246
|
+
interaction_cid: null,
|
|
247
|
+
moderation_id: null,
|
|
248
|
+
organization_id: 1,
|
|
249
|
+
user_id: 1,
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
action: "member.promoted",
|
|
253
|
+
actor_ref: "domain.promote_members",
|
|
254
|
+
actor_type: "app",
|
|
255
|
+
app: "proconnect-identite",
|
|
256
|
+
cause_activity_id: 1,
|
|
257
|
+
context: {
|
|
258
|
+
inputs: { previous_verification_type: "domain_not_verified_yet" },
|
|
259
|
+
outcome: { verification_type: "domain" },
|
|
260
|
+
},
|
|
261
|
+
created_at: new Date("5555-05-05"),
|
|
262
|
+
id: 3,
|
|
263
|
+
interaction_cid: null,
|
|
264
|
+
moderation_id: null,
|
|
265
|
+
organization_id: 1,
|
|
266
|
+
user_id: 2,
|
|
267
|
+
},
|
|
230
268
|
]);
|
|
231
269
|
});
|
|
232
270
|
|
|
233
|
-
it("✅ journals the verification under the moderator", async () => {
|
|
271
|
+
it("✅ journals the verification under the moderator and each promotion under the app", async () => {
|
|
234
272
|
const { pg, runtime } = await setup({
|
|
235
273
|
actor: { type: "moderator", sub: "moderator+verifies-darkangels.world" },
|
|
236
274
|
app: "hyyypertool",
|
|
@@ -270,6 +308,7 @@ describe("markDomainAsVerified", () => {
|
|
|
270
308
|
actor_ref: "moderator+verifies-darkangels.world",
|
|
271
309
|
actor_type: "moderator",
|
|
272
310
|
app: "hyyypertool",
|
|
311
|
+
cause_activity_id: null,
|
|
273
312
|
context: {
|
|
274
313
|
inputs: {
|
|
275
314
|
domain: "darkangels.world",
|
|
@@ -287,6 +326,43 @@ describe("markDomainAsVerified", () => {
|
|
|
287
326
|
organization_id: 1,
|
|
288
327
|
user_id: null,
|
|
289
328
|
},
|
|
329
|
+
{
|
|
330
|
+
action: "member.promoted",
|
|
331
|
+
actor_ref: "domain.promote_members",
|
|
332
|
+
actor_type: "app",
|
|
333
|
+
app: "hyyypertool",
|
|
334
|
+
cause_activity_id: 1,
|
|
335
|
+
context: {
|
|
336
|
+
inputs: {
|
|
337
|
+
previous_verification_type:
|
|
338
|
+
"no_verification_means_for_entreprise_unipersonnelle",
|
|
339
|
+
},
|
|
340
|
+
outcome: { verification_type: "domain" },
|
|
341
|
+
},
|
|
342
|
+
created_at: new Date("5555-05-05"),
|
|
343
|
+
id: 2,
|
|
344
|
+
interaction_cid: null,
|
|
345
|
+
moderation_id: null,
|
|
346
|
+
organization_id: 1,
|
|
347
|
+
user_id: 1,
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
action: "member.promoted",
|
|
351
|
+
actor_ref: "domain.promote_members",
|
|
352
|
+
actor_type: "app",
|
|
353
|
+
app: "hyyypertool",
|
|
354
|
+
cause_activity_id: 1,
|
|
355
|
+
context: {
|
|
356
|
+
inputs: { previous_verification_type: "domain_not_verified_yet" },
|
|
357
|
+
outcome: { verification_type: "domain" },
|
|
358
|
+
},
|
|
359
|
+
created_at: new Date("5555-05-05"),
|
|
360
|
+
id: 3,
|
|
361
|
+
interaction_cid: null,
|
|
362
|
+
moderation_id: null,
|
|
363
|
+
organization_id: 1,
|
|
364
|
+
user_id: 2,
|
|
365
|
+
},
|
|
290
366
|
]);
|
|
291
367
|
});
|
|
292
368
|
|
|
@@ -332,6 +408,7 @@ async function readActivityLogs(pg: PGlite) {
|
|
|
332
408
|
actor_ref,
|
|
333
409
|
actor_type,
|
|
334
410
|
app,
|
|
411
|
+
cause_activity_id,
|
|
335
412
|
context,
|
|
336
413
|
created_at,
|
|
337
414
|
id,
|
|
@@ -76,6 +76,13 @@ export function markDomainAsVerifiedFactory({
|
|
|
76
76
|
members,
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
+
const promoted_members = memberships
|
|
80
|
+
.filter(({ user_id }) => promoted_member_ids.includes(user_id))
|
|
81
|
+
.map(({ user_id, verification_type }) => ({
|
|
82
|
+
previous_verification_type: verification_type,
|
|
83
|
+
user_id,
|
|
84
|
+
}));
|
|
85
|
+
|
|
79
86
|
const replaced = await tx
|
|
80
87
|
.delete(email_domains)
|
|
81
88
|
.where(
|
|
@@ -132,6 +139,24 @@ export function markDomainAsVerifiedFactory({
|
|
|
132
139
|
inArray(users_organizations.user_id, promoted_member_ids),
|
|
133
140
|
),
|
|
134
141
|
);
|
|
142
|
+
|
|
143
|
+
for (const {
|
|
144
|
+
previous_verification_type,
|
|
145
|
+
user_id,
|
|
146
|
+
} of promoted_members) {
|
|
147
|
+
await insertActivity<ActivityContexts>(tx, {
|
|
148
|
+
action: "member.promoted",
|
|
149
|
+
actor: { type: "app", job: "domain.promote_members" },
|
|
150
|
+
app,
|
|
151
|
+
cause_activity_id: activity_id,
|
|
152
|
+
context: {
|
|
153
|
+
inputs: { previous_verification_type },
|
|
154
|
+
outcome: { verification_type: LinkEnum.enum.domain },
|
|
155
|
+
},
|
|
156
|
+
organization_id,
|
|
157
|
+
user_id,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
135
160
|
}
|
|
136
161
|
|
|
137
162
|
return {
|
|
@@ -141,12 +166,7 @@ export function markDomainAsVerifiedFactory({
|
|
|
141
166
|
id: email_domain.id,
|
|
142
167
|
verification_type: domain_verification_type,
|
|
143
168
|
},
|
|
144
|
-
promoted_members
|
|
145
|
-
.filter(({ user_id }) => promoted_member_ids.includes(user_id))
|
|
146
|
-
.map(({ user_id, verification_type }) => ({
|
|
147
|
-
previous_verification_type: verification_type,
|
|
148
|
-
user_id,
|
|
149
|
-
})),
|
|
169
|
+
promoted_members,
|
|
150
170
|
replaced_verification_types,
|
|
151
171
|
};
|
|
152
172
|
});
|
|
@@ -19,7 +19,7 @@ export async function insertActivity<Contexts extends ContextMap>(
|
|
|
19
19
|
...activity
|
|
20
20
|
}: ActivityOf<Contexts> &
|
|
21
21
|
ActivityTargets &
|
|
22
|
-
Pick<RuntimeContext, "actor" | "app"
|
|
22
|
+
Pick<RuntimeContext, "actor" | "app"> & { cause_activity_id?: number },
|
|
23
23
|
) {
|
|
24
24
|
const [row] = await tx
|
|
25
25
|
.insert(activity_logs)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import { LinkEnum } from "@proconnect-gouv/proconnect.identite/types";
|
|
4
|
+
import * as z from "zod";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export const membershipActivities = {
|
|
9
|
+
"member.promoted": z.object({
|
|
10
|
+
inputs: z.object({
|
|
11
|
+
previous_verification_type: z.string(),
|
|
12
|
+
}),
|
|
13
|
+
outcome: z.object({
|
|
14
|
+
verification_type: LinkEnum,
|
|
15
|
+
}),
|
|
16
|
+
}),
|
|
17
|
+
};
|