@bwi-mentorspaces/application-utils-npm 0.0.142 → 0.0.143
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/match-guidance/index.d.ts +1 -0
- package/match-guidance/index.js +1 -0
- package/match-guidance/index.js.map +1 -1
- package/match-guidance/reporting-eligibility.d.ts +15 -0
- package/match-guidance/reporting-eligibility.js +69 -0
- package/match-guidance/reporting-eligibility.js.map +1 -0
- package/package.json +1 -1
package/match-guidance/index.js
CHANGED
|
@@ -15,4 +15,5 @@ __exportStar(require("./next-step"), exports);
|
|
|
15
15
|
__exportStar(require("./session-facts"), exports);
|
|
16
16
|
__exportStar(require("./message-facts"), exports);
|
|
17
17
|
__exportStar(require("./invitation-history"), exports);
|
|
18
|
+
__exportStar(require("./reporting-eligibility"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../match-guidance/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,8CAA4B;AAC5B,kDAAgC;AAChC,kDAAgC;AAChC,uDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../match-guidance/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,8CAA4B;AAC5B,kDAAgC;AAChC,kDAAgC;AAChC,uDAAqC;AACrC,0DAAwC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IGuidanceSql } from "./model";
|
|
2
|
+
/** Trusted aliases for already-joined match eligibility records. */
|
|
3
|
+
export interface IProgramMatchEligibilityAliases<TSql> {
|
|
4
|
+
match: TSql;
|
|
5
|
+
mentor: TSql;
|
|
6
|
+
mentee: TSql;
|
|
7
|
+
mentorMember: TSql;
|
|
8
|
+
menteeMember: TSql;
|
|
9
|
+
}
|
|
10
|
+
/** Bind the existing program reporting eligibility rules to the caller's SQL implementation. */
|
|
11
|
+
export declare function createReportingEligibility<TSql>(adapter: IGuidanceSql<TSql>): {
|
|
12
|
+
buildAdminProgramMemberEligibilityCondition: (programMemberAlias: TSql, userAlias: TSql) => TSql;
|
|
13
|
+
programMatchEligibilityConditionSql: (programRef: string, evaluatedAt: Date, aliases: IProgramMatchEligibilityAliases<TSql>) => TSql;
|
|
14
|
+
eligibleProgramMatchesSql: (programRef: string, evaluatedAt: Date) => TSql;
|
|
15
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createReportingEligibility = void 0;
|
|
4
|
+
/** Bind the existing program reporting eligibility rules to the caller's SQL implementation. */
|
|
5
|
+
function createReportingEligibility(adapter) {
|
|
6
|
+
/**
|
|
7
|
+
* Build participant eligibility for admin program data and recommendations.
|
|
8
|
+
* Callers provide static SQL aliases and retain their own program scoping.
|
|
9
|
+
*
|
|
10
|
+
* @param {TSql} programMemberAlias Trusted program-member SQL alias
|
|
11
|
+
* @param {TSql} userAlias Trusted user SQL alias
|
|
12
|
+
* @returns {TSql} Parameterized participant eligibility predicate
|
|
13
|
+
*/
|
|
14
|
+
function buildAdminProgramMemberEligibilityCondition(programMemberAlias, userAlias) {
|
|
15
|
+
return adapter.sql `(
|
|
16
|
+
${programMemberAlias}.Status = ${"active"}
|
|
17
|
+
AND ${programMemberAlias}.IsOnboarded = TRUE
|
|
18
|
+
AND ${userAlias}.Role <> ${"MSA"}
|
|
19
|
+
)`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Evaluate reporting eligibility against existing joins without fetching them again.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} programRef Owning program
|
|
25
|
+
* @param {Date} evaluatedAt Single request timestamp
|
|
26
|
+
* @param {IProgramMatchEligibilityAliases} aliases Trusted SQL aliases
|
|
27
|
+
* @returns {TSql} Shared reporting eligibility predicate
|
|
28
|
+
*/
|
|
29
|
+
function programMatchEligibilityConditionSql(programRef, evaluatedAt, aliases) {
|
|
30
|
+
const { match, mentor, mentee, mentorMember, menteeMember } = aliases;
|
|
31
|
+
return adapter.sql `(${match}.ProgramRef = ${programRef} AND ${match}.Status = ${"active"}
|
|
32
|
+
AND ${match}.PublishedOn IS NOT NULL AND ${match}.PublishedOn <= ${evaluatedAt}
|
|
33
|
+
AND ${mentor}.Status = ${"active"} AND ${mentee}.Status = ${"active"}
|
|
34
|
+
AND ${mentor}.IsOnboarded = TRUE AND ${mentee}.IsOnboarded = TRUE
|
|
35
|
+
AND ${mentorMember}.Role = 'Mentor' AND ${menteeMember}.Role = 'Mentee'
|
|
36
|
+
AND ${buildAdminProgramMemberEligibilityCondition(mentorMember, mentor)}
|
|
37
|
+
AND ${buildAdminProgramMemberEligibilityCondition(menteeMember, mentee)})`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Shared joins and eligibility predicates for match count and page retrieval.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} programRef Owning program
|
|
43
|
+
* @param {Date} evaluatedAt Single request timestamp
|
|
44
|
+
* @returns {TSql} Parameterized FROM and WHERE fragment
|
|
45
|
+
*/
|
|
46
|
+
function eligibleProgramMatchesSql(programRef, evaluatedAt) {
|
|
47
|
+
return adapter.sql `
|
|
48
|
+
FROM \`match\` m
|
|
49
|
+
INNER JOIN user mentor ON mentor.Id = m.MentorUserId
|
|
50
|
+
INNER JOIN user mentee ON mentee.Id = m.MenteeUserId
|
|
51
|
+
INNER JOIN programmember mentorMember ON mentorMember.ProgramRef = m.ProgramRef AND mentorMember.UserRef = mentor.Ref
|
|
52
|
+
INNER JOIN programmember menteeMember ON menteeMember.ProgramRef = m.ProgramRef AND menteeMember.UserRef = mentee.Ref
|
|
53
|
+
WHERE ${programMatchEligibilityConditionSql(programRef, evaluatedAt, {
|
|
54
|
+
match: adapter.sql `m`,
|
|
55
|
+
mentor: adapter.sql `mentor`,
|
|
56
|
+
mentee: adapter.sql `mentee`,
|
|
57
|
+
mentorMember: adapter.sql `mentorMember`,
|
|
58
|
+
menteeMember: adapter.sql `menteeMember`
|
|
59
|
+
})}
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
buildAdminProgramMemberEligibilityCondition,
|
|
64
|
+
programMatchEligibilityConditionSql,
|
|
65
|
+
eligibleProgramMatchesSql
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
exports.createReportingEligibility = createReportingEligibility;
|
|
69
|
+
//# sourceMappingURL=reporting-eligibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporting-eligibility.js","sourceRoot":"","sources":["../../match-guidance/reporting-eligibility.ts"],"names":[],"mappings":";;;AAWA,gGAAgG;AAChG,SAAgB,0BAA0B,CAAO,OAA2B;IACxE;;;;;;;OAOG;IACH,SAAS,2CAA2C,CAAC,kBAAwB,EAAE,SAAe;QAC1F,OAAO,OAAO,CAAC,GAAG,CAAA;UAChB,kBAAkB,aAAa,QAAQ;cACnC,kBAAkB;cAClB,SAAS,YAAY,KAAK;MAClC,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACH,SAAS,mCAAmC,CACxC,UAAkB,EAClB,WAAiB,EACjB,OAA8C;QAE9C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,GAA0C,OAAO,CAAC;QAC7G,OAAO,OAAO,CAAC,GAAG,CAAA,IAAI,KAAK,iBAAiB,UAAU,QAAQ,KAAK,aAAa,QAAQ;cAClF,KAAK,gCAAgC,KAAK,mBAAmB,WAAW;cACxE,MAAM,aAAa,QAAQ,QAAQ,MAAM,aAAa,QAAQ;cAC9D,MAAM,2BAA2B,MAAM;cACvC,YAAY,wBAAwB,YAAY;cAChD,2CAA2C,CAAC,YAAY,EAAE,MAAM,CAAC;cACjE,2CAA2C,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC;IAC/E,CAAC;IAED;;;;;;OAMG;IACH,SAAS,yBAAyB,CAAC,UAAkB,EAAE,WAAiB;QACpE,OAAO,OAAO,CAAC,GAAG,CAAA;;;;;;gBAMV,mCAAmC,CAAC,UAAU,EAAE,WAAW,EAAE;YACjE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAA,GAAG;YACrB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAA,QAAQ;YAC3B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAA,QAAQ;YAC3B,YAAY,EAAE,OAAO,CAAC,GAAG,CAAA,cAAc;YACvC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAA,cAAc;SAC1C,CAAC;KACL,CAAC;IACF,CAAC;IAED,OAAO;QACH,2CAA2C;QAC3C,mCAAmC;QACnC,yBAAyB;KAC5B,CAAC;AACN,CAAC;AArED,gEAqEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bwi-mentorspaces/application-utils-npm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.143",
|
|
4
4
|
"description": "Mentor Spaces npm packages for reusable models, utils, and abstracted, commonly used processes for DB Repo, Logging, etc.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mentor Spaces",
|