placementt-core 1.400.1286 → 1.400.1287
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/lib/typeDefinitions.d.ts +10 -0
- package/lib/typeDefinitions.js.map +1 -1
- package/lib/workflows.d.ts +10 -2
- package/lib/workflows.js +20 -5
- package/lib/workflows.js.map +1 -1
- package/package.json +1 -1
- package/src/typeDefinitions.ts +11 -0
- package/src/workflows.ts +25 -5
package/lib/typeDefinitions.d.ts
CHANGED
|
@@ -1005,6 +1005,11 @@ export type WorkflowStage = {
|
|
|
1005
1005
|
* - "add": the trust's forms/files are a required baseline; schools may add, never remove.
|
|
1006
1006
|
* - "open": schools may add or remove freely. */
|
|
1007
1007
|
export type WorkflowEditPolicy = "locked" | "add" | "open";
|
|
1008
|
+
/** What a school may do with the emails on a trust's workflow.
|
|
1009
|
+
* - "locked": the trust's choices apply as they are.
|
|
1010
|
+
* - "open": schools may switch emails off for their own cohorts. They still can't switch
|
|
1011
|
+
* on one the trust has off, or change any email's wording. */
|
|
1012
|
+
export type WorkflowEmailPolicy = "locked" | "open";
|
|
1008
1013
|
/** The features a trust can impose on its schools. Work experience is absent because
|
|
1009
1014
|
* it predates this and carries its policy on the cohort template a school applies —
|
|
1010
1015
|
* see InstituteData.cohortConfig.mandatory and WorkflowConfig.editPolicy, which this
|
|
@@ -1062,6 +1067,8 @@ export type WorkflowConfig = {
|
|
|
1062
1067
|
trust?: boolean;
|
|
1063
1068
|
/** What a school may change on the stages of this workflow. Defaults to "open". */
|
|
1064
1069
|
editPolicy?: WorkflowEditPolicy;
|
|
1070
|
+
/** Whether schools may switch this workflow's emails off for their cohorts. Defaults to "locked". */
|
|
1071
|
+
emailPolicy?: WorkflowEmailPolicy;
|
|
1065
1072
|
};
|
|
1066
1073
|
export type ProviderPlacementData = {
|
|
1067
1074
|
title: string;
|
|
@@ -1681,6 +1688,9 @@ export type CohortData = {
|
|
|
1681
1688
|
emailParentOnStatusChange?: boolean;
|
|
1682
1689
|
/** emailTemplates keys this cohort doesn't send. Absent means every email is sent. Locked emails ignore it. */
|
|
1683
1690
|
disabledEmails?: string[];
|
|
1691
|
+
/** On a trust workflow with emailPolicy "open": the emails the school has switched off for
|
|
1692
|
+
* this cohort. disabledEmails holds these plus the trust's, and is what sends read. */
|
|
1693
|
+
schoolDisabledEmails?: string[];
|
|
1684
1694
|
targetHours?: number;
|
|
1685
1695
|
manuallySendFeedback?: boolean;
|
|
1686
1696
|
inviteEmployersToDatabase?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeDefinitions.js","sourceRoot":"","sources":["../src/typeDefinitions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"typeDefinitions.js","sourceRoot":"","sources":["../src/typeDefinitions.ts"],"names":[],"mappings":";;;AA+4IA,sDASC;AAeD,oDAKC;AAaD,0CAEC;AAtvED;;;;;kFAKkF;AACrE,QAAA,qBAAqB,GAAG,SAAS,CAAC;AAClC,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAkqEzC;yEACyE;AAC5D,QAAA,0BAA0B,GAA2C;IAC9E,gBAAgB,EAAE,2BAA2B;IAC7C,mBAAmB,EAAE,sBAAsB;IAC3C,cAAc,EAAE,iBAAiB;IACjC,kBAAkB,EAAE,qBAAqB;IACzC,UAAU,EAAE,oCAAoC;IAChD,aAAa,EAAE,yBAAyB;IACxC,aAAa,EAAE,wBAAwB;IACvC,KAAK,EAAE,OAAO;CACjB,CAAC;AAEW,QAAA,0BAA0B,GAA+C;IAClF,QAAQ,EAAE,WAAW;IACrB,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,OAAO;CACjB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,SAAgB,qBAAqB,CAAC,SAAsC;IACxE,QAAQ,SAAS,EAAE,CAAC;QACpB,KAAK,MAAM,CAAC,CAAC,OAAO,OAAO,CAAC;QAC5B,KAAK,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC;QAC7B,KAAK,WAAW,CAAC;QACjB,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,OAAO,CAAC,CAAC,OAAO,UAAU,CAAC;IAC3B,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,oBAAoB,CAChC,IAAwC,EACxC,MAA6C;IAE7C,OAAO,IAAI,EAAE,WAAW,IAAI,MAAM,EAAE,YAAY,IAAI,KAAK,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAAC,KAA6D;IACzF,OAAO,GAAG,KAAK,CAAC,cAAc,IAAI,EAAE,IAAI,KAAK,CAAC,aAAa,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;AAC/E,CAAC"}
|
package/lib/workflows.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FirebaseQuery from "./firebase/firebaseQuery";
|
|
2
|
-
import { CohortData, InstituteData, WorkflowConfig, WorkflowEditPolicy, WorkflowOverrides, WorkflowStage } from "./typeDefinitions";
|
|
2
|
+
import { CohortData, InstituteData, WorkflowConfig, WorkflowEditPolicy, WorkflowEmailPolicy, WorkflowOverrides, WorkflowStage } from "./typeDefinitions";
|
|
3
3
|
/**
|
|
4
4
|
* Workflows live in their own `workflows` collection rather than on the cohort, so a
|
|
5
5
|
* school (or a trust, on behalf of its schools) defines a workflow once and every cohort
|
|
@@ -54,10 +54,18 @@ export declare function flattenWorkflowFormsAndFiles(workflow: WorkflowStage[]):
|
|
|
54
54
|
/**
|
|
55
55
|
* The email settings a workflow hands the cohorts on it, with only the fields it sets.
|
|
56
56
|
* A workflow saved before emails moved onto it sets neither, so its cohorts keep their own.
|
|
57
|
+
*
|
|
58
|
+
* Pass the cohort when it has one: on a trust workflow whose emailPolicy is "open", the
|
|
59
|
+
* emails its school switched off (schoolDisabledEmails) are added to the trust's.
|
|
57
60
|
*/
|
|
58
|
-
export declare const workflowEmailSettings: (config?: Pick<WorkflowConfig, "emailTemplates" | "disabledEmails">) => Pick<CohortData, "emailTemplates" | "disabledEmails">;
|
|
61
|
+
export declare const workflowEmailSettings: (config?: Pick<WorkflowConfig, "emailTemplates" | "disabledEmails" | "trust" | "emailPolicy">, cohort?: Pick<CohortData, "schoolDisabledEmails">) => Pick<CohortData, "emailTemplates" | "disabledEmails">;
|
|
62
|
+
/** What schools may do with a workflow's emails. Only a trust's workflow can be locked. */
|
|
63
|
+
export declare const workflowEmailPolicy: (config?: Pick<WorkflowConfig, "trust" | "emailPolicy">) => WorkflowEmailPolicy;
|
|
59
64
|
/** Whether a workflow's emails are its trust's to set, so the school running it can't change them. */
|
|
60
65
|
export declare const workflowEmailsLockedFor: (config: Pick<WorkflowConfig, "trust" | "oId"> | undefined, oId: string) => boolean;
|
|
66
|
+
/** Whether a school on its trust's workflow may switch that workflow's emails off for its own
|
|
67
|
+
* cohorts (emailPolicy "open"). The wording stays the trust's either way. */
|
|
68
|
+
export declare const workflowEmailSwitchesOpenFor: (config: Pick<WorkflowConfig, "trust" | "oId" | "emailPolicy"> | undefined, oId: string) => boolean;
|
|
61
69
|
/**
|
|
62
70
|
* The workflow a cohort actually runs on: its referenced workflow doc with the cohort's
|
|
63
71
|
* own overrides applied. Pass the workflows already loaded in context/memory.
|
package/lib/workflows.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.cohortWorkflowConfigured = exports.workflowEmailsLockedFor = exports.workflowEmailSettings = exports.workflowEditPolicy = exports.trustWorkflows = exports.approvedTrustId = void 0;
|
|
6
|
+
exports.cohortWorkflowConfigured = exports.workflowEmailSwitchesOpenFor = exports.workflowEmailsLockedFor = exports.workflowEmailPolicy = exports.workflowEmailSettings = exports.workflowEditPolicy = exports.trustWorkflows = exports.approvedTrustId = void 0;
|
|
7
7
|
exports.applyWorkflowOverrides = applyWorkflowOverrides;
|
|
8
8
|
exports.diffWorkflowOverrides = diffWorkflowOverrides;
|
|
9
9
|
exports.enforceEditPolicy = enforceEditPolicy;
|
|
@@ -110,15 +110,30 @@ function flattenWorkflowFormsAndFiles(workflow) {
|
|
|
110
110
|
/**
|
|
111
111
|
* The email settings a workflow hands the cohorts on it, with only the fields it sets.
|
|
112
112
|
* A workflow saved before emails moved onto it sets neither, so its cohorts keep their own.
|
|
113
|
+
*
|
|
114
|
+
* Pass the cohort when it has one: on a trust workflow whose emailPolicy is "open", the
|
|
115
|
+
* emails its school switched off (schoolDisabledEmails) are added to the trust's.
|
|
113
116
|
*/
|
|
114
|
-
const workflowEmailSettings = (config) =>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
const workflowEmailSettings = (config, cohort) => {
|
|
118
|
+
const schoolOff = (0, exports.workflowEmailPolicy)(config) === "open" ? cohort?.schoolDisabledEmails || [] : [];
|
|
119
|
+
const disabledEmails = config?.disabledEmails || schoolOff.length ?
|
|
120
|
+
[...new Set([...(config?.disabledEmails || []), ...schoolOff])] : undefined;
|
|
121
|
+
return {
|
|
122
|
+
...(config?.emailTemplates ? { emailTemplates: config.emailTemplates } : {}),
|
|
123
|
+
...(disabledEmails ? { disabledEmails } : {}),
|
|
124
|
+
};
|
|
125
|
+
};
|
|
118
126
|
exports.workflowEmailSettings = workflowEmailSettings;
|
|
127
|
+
/** What schools may do with a workflow's emails. Only a trust's workflow can be locked. */
|
|
128
|
+
const workflowEmailPolicy = (config) => (config?.trust ? config.emailPolicy || "locked" : "open");
|
|
129
|
+
exports.workflowEmailPolicy = workflowEmailPolicy;
|
|
119
130
|
/** Whether a workflow's emails are its trust's to set, so the school running it can't change them. */
|
|
120
131
|
const workflowEmailsLockedFor = (config, oId) => Boolean(config?.trust && config.oId !== oId);
|
|
121
132
|
exports.workflowEmailsLockedFor = workflowEmailsLockedFor;
|
|
133
|
+
/** Whether a school on its trust's workflow may switch that workflow's emails off for its own
|
|
134
|
+
* cohorts (emailPolicy "open"). The wording stays the trust's either way. */
|
|
135
|
+
const workflowEmailSwitchesOpenFor = (config, oId) => (0, exports.workflowEmailsLockedFor)(config, oId) && (0, exports.workflowEmailPolicy)(config) === "open";
|
|
136
|
+
exports.workflowEmailSwitchesOpenFor = workflowEmailSwitchesOpenFor;
|
|
122
137
|
/**
|
|
123
138
|
* The workflow a cohort actually runs on: its referenced workflow doc with the cohort's
|
|
124
139
|
* own overrides applied. Pass the workflows already loaded in context/memory.
|
package/lib/workflows.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.js","sourceRoot":"","sources":["../src/workflows.ts"],"names":[],"mappings":";;;;;;AA2CA,wDAgBC;AAGD,sDAgBC;AASD,8CAMC;AAGD,oEAQC;
|
|
1
|
+
{"version":3,"file":"workflows.js","sourceRoot":"","sources":["../src/workflows.ts"],"names":[],"mappings":";;;;;;AA2CA,wDAgBC;AAGD,sDAgBC;AASD,8CAMC;AAGD,oEAQC;AAuCD,sDAQC;AAID,kDAQC;AAnKD,6EAAqD;AAGrD;;;;;;;;;;GAUG;AAEH,6CAA6C;AACtC,MAAM,eAAe,GAAG,CAAC,SAA6C,EAAE,EAAE,CAC7E,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AADjF,QAAA,eAAe,mBACkE;AAE9F,2CAA2C;AACpC,MAAM,cAAc,GAAG,CAAC,SAA0C,EAAE,OAAgB,EAAE,EAAE,CAC3F,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,C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itions.ts
CHANGED
|
@@ -1005,6 +1005,12 @@ export type WorkflowStage = {
|
|
|
1005
1005
|
* - "open": schools may add or remove freely. */
|
|
1006
1006
|
export type WorkflowEditPolicy = "locked"|"add"|"open";
|
|
1007
1007
|
|
|
1008
|
+
/** What a school may do with the emails on a trust's workflow.
|
|
1009
|
+
* - "locked": the trust's choices apply as they are.
|
|
1010
|
+
* - "open": schools may switch emails off for their own cohorts. They still can't switch
|
|
1011
|
+
* on one the trust has off, or change any email's wording. */
|
|
1012
|
+
export type WorkflowEmailPolicy = "locked"|"open";
|
|
1013
|
+
|
|
1008
1014
|
/** The features a trust can impose on its schools. Work experience is absent because
|
|
1009
1015
|
* it predates this and carries its policy on the cohort template a school applies —
|
|
1010
1016
|
* see InstituteData.cohortConfig.mandatory and WorkflowConfig.editPolicy, which this
|
|
@@ -1066,6 +1072,8 @@ export type WorkflowConfig = {
|
|
|
1066
1072
|
trust?: boolean,
|
|
1067
1073
|
/** What a school may change on the stages of this workflow. Defaults to "open". */
|
|
1068
1074
|
editPolicy?: WorkflowEditPolicy,
|
|
1075
|
+
/** Whether schools may switch this workflow's emails off for their cohorts. Defaults to "locked". */
|
|
1076
|
+
emailPolicy?: WorkflowEmailPolicy,
|
|
1069
1077
|
};
|
|
1070
1078
|
|
|
1071
1079
|
export type ProviderPlacementData = {
|
|
@@ -1706,6 +1714,9 @@ export type CohortData = {
|
|
|
1706
1714
|
emailParentOnStatusChange?: boolean
|
|
1707
1715
|
/** emailTemplates keys this cohort doesn't send. Absent means every email is sent. Locked emails ignore it. */
|
|
1708
1716
|
disabledEmails?: string[],
|
|
1717
|
+
/** On a trust workflow with emailPolicy "open": the emails the school has switched off for
|
|
1718
|
+
* this cohort. disabledEmails holds these plus the trust's, and is what sends read. */
|
|
1719
|
+
schoolDisabledEmails?: string[],
|
|
1709
1720
|
targetHours?: number,
|
|
1710
1721
|
manuallySendFeedback?: boolean,
|
|
1711
1722
|
// Ask employers reviewing a placement whether they'll take students again and want
|
package/src/workflows.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FirebaseQuery from "./firebase/firebaseQuery";
|
|
2
|
-
import {CohortData, InstituteData, WorkflowConfig, WorkflowEditPolicy, WorkflowOverrides, WorkflowStage} from "./typeDefinitions";
|
|
2
|
+
import {CohortData, InstituteData, WorkflowConfig, WorkflowEditPolicy, WorkflowEmailPolicy, WorkflowOverrides, WorkflowStage} from "./typeDefinitions";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Workflows live in their own `workflows` collection rather than on the cohort, so a
|
|
@@ -107,16 +107,36 @@ export function flattenWorkflowFormsAndFiles(workflow: WorkflowStage[]) {
|
|
|
107
107
|
/**
|
|
108
108
|
* The email settings a workflow hands the cohorts on it, with only the fields it sets.
|
|
109
109
|
* A workflow saved before emails moved onto it sets neither, so its cohorts keep their own.
|
|
110
|
+
*
|
|
111
|
+
* Pass the cohort when it has one: on a trust workflow whose emailPolicy is "open", the
|
|
112
|
+
* emails its school switched off (schoolDisabledEmails) are added to the trust's.
|
|
110
113
|
*/
|
|
111
|
-
export const workflowEmailSettings = (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
export const workflowEmailSettings = (
|
|
115
|
+
config?: Pick<WorkflowConfig, "emailTemplates"|"disabledEmails"|"trust"|"emailPolicy">,
|
|
116
|
+
cohort?: Pick<CohortData, "schoolDisabledEmails">,
|
|
117
|
+
): Pick<CohortData, "emailTemplates"|"disabledEmails"> => {
|
|
118
|
+
const schoolOff = workflowEmailPolicy(config) === "open" ? cohort?.schoolDisabledEmails || [] : [];
|
|
119
|
+
const disabledEmails = config?.disabledEmails || schoolOff.length ?
|
|
120
|
+
[...new Set([...(config?.disabledEmails || []), ...schoolOff])] : undefined;
|
|
121
|
+
return {
|
|
122
|
+
...(config?.emailTemplates ? {emailTemplates: config.emailTemplates} : {}),
|
|
123
|
+
...(disabledEmails ? {disabledEmails} : {}),
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** What schools may do with a workflow's emails. Only a trust's workflow can be locked. */
|
|
128
|
+
export const workflowEmailPolicy = (config?: Pick<WorkflowConfig, "trust"|"emailPolicy">): WorkflowEmailPolicy =>
|
|
129
|
+
(config?.trust ? config.emailPolicy || "locked" : "open");
|
|
115
130
|
|
|
116
131
|
/** Whether a workflow's emails are its trust's to set, so the school running it can't change them. */
|
|
117
132
|
export const workflowEmailsLockedFor = (config: Pick<WorkflowConfig, "trust"|"oId">|undefined, oId: string) =>
|
|
118
133
|
Boolean(config?.trust && config.oId !== oId);
|
|
119
134
|
|
|
135
|
+
/** Whether a school on its trust's workflow may switch that workflow's emails off for its own
|
|
136
|
+
* cohorts (emailPolicy "open"). The wording stays the trust's either way. */
|
|
137
|
+
export const workflowEmailSwitchesOpenFor = (config: Pick<WorkflowConfig, "trust"|"oId"|"emailPolicy">|undefined, oId: string) =>
|
|
138
|
+
workflowEmailsLockedFor(config, oId) && workflowEmailPolicy(config) === "open";
|
|
139
|
+
|
|
120
140
|
/**
|
|
121
141
|
* The workflow a cohort actually runs on: its referenced workflow doc with the cohort's
|
|
122
142
|
* own overrides applied. Pass the workflows already loaded in context/memory.
|