placementt-core 1.400.985 → 1.400.987

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.
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /**
3
+ * surveys/types.ts — the unified survey engine's data model.
4
+ *
5
+ * One shape for every student/alumni survey CareerThread sends: skills surveys,
6
+ * careers aspiration surveys (Form A), leaver transition forms + their post-leaving
7
+ * checkpoints (Form B), and annual alumni check-ins. Each is a `SurveyKind`; the
8
+ * behavioural differences between them live in the registry (./registry), not in
9
+ * the data model.
10
+ *
11
+ * Firestore:
12
+ * surveyCycles/{cycleId} — one scheduled SEND to one cohort
13
+ * surveyRequests/{requestId} — one PERSON inside one cycle
14
+ *
15
+ * These supersede aspirationCycles/aspirationRequests, leaverGroups/leaverRequests,
16
+ * skillsAssessmentRequests, and the per-Alumni check-in fields. Migration mapping is
17
+ * documented per field below and in SURVEY_UNIFICATION_PLAN.md §3.2.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.SURVEY_KINDS_LIST = void 0;
21
+ /** Every SurveyKind as a runtime array — for iteration, validation and registry tests. */
22
+ exports.SURVEY_KINDS_LIST = [
23
+ "skills", "aspirations", "leaverIntentions", "leaverResults", "leaverChristmas", "alumniCheckIn",
24
+ ];
25
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/surveys/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAiBH,0FAA0F;AAC7E,QAAA,iBAAiB,GAAiB;IAC3C,QAAQ,EAAE,aAAa,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe;CACnG,CAAC"}
@@ -2,6 +2,7 @@ import { DocumentData, DocumentReference, OrderByDirection, Timestamp, WhereFilt
2
2
  import { Descendant } from "slate";
3
3
  import { emailTemplates, skillLabelColours } from "./constants";
4
4
  import type { ChecklistItem, GiftHistory } from "./customerCareConfig";
5
+ import type { SurveySlot } from "./surveys/types";
5
6
  export type FilterObject = {
6
7
  [key: string]: {
7
8
  label: string;
@@ -1918,6 +1919,8 @@ export type EmploymentDetails = {
1918
1919
  sicSection?: string;
1919
1920
  sicLabel?: string;
1920
1921
  employmentStatus: "fullTime" | "partTime" | "selfEmployed" | "contractor" | "zeroHours";
1922
+ /** Optional short free-text description of what the role entails — shown on the journey timeline. */
1923
+ roleDescription?: string;
1921
1924
  employerName?: string;
1922
1925
  employerSize?: "<10" | "10-49" | "50-249" | "250+" | "publicSector";
1923
1926
  isPrimaryJob?: boolean;
@@ -2064,16 +2067,11 @@ export type DestinationsRecipientFilter = {
2064
2067
  e?: WhereFilterOp;
2065
2068
  v: unknown;
2066
2069
  }[];
2067
- /** One scheduled survey in a year's aspiration programme.
2068
- * `rule` (when present) is the source of truth a relative rule like "first Monday
2069
- * of June", resolved to a concrete date for each academic year at provision time.
2070
- * `sendMMDD` ("MM-DD") is the materialised date (and the sole value on legacy slots);
2071
- * provisioning resolves `rule` for the target year, falling back to `sendMMDD`. */
2072
- export type AspirationSurveySlot = {
2073
- sendMMDD: string;
2074
- rule?: SurveyDateRule;
2075
- label?: string;
2076
- };
2070
+ /**
2071
+ * @deprecated Use SurveySlot (surveys/types.ts) this is now an alias of it.
2072
+ * One scheduled survey in a year's aspiration programme.
2073
+ */
2074
+ export type AspirationSurveySlot = SurveySlot;
2077
2075
  /**
2078
2076
  * Per-year-group leaver settings. Used as an override entry in
2079
2077
  * DestinationsConfig.leavers.byYearGroup — each field replaces the shared leaver
@@ -2926,21 +2924,11 @@ export type SurveyDateRule = {
2926
2924
  weekday: SurveyWeekday;
2927
2925
  month: number;
2928
2926
  };
2929
- /** One scheduled skills survey in a group's annual programme.
2930
- * `rule` (when present) is the source of truth a relative rule like "first Monday
2931
- * of June" resolved to a concrete date for each academic year each September.
2932
- * `sendMMDD` ("MM-DD") is the materialised date for the current academic year (and
2933
- * the sole value on legacy slots created before rules existed); the daily cron fires
2934
- * on it, so it is kept in step with `rule`.
2935
- * Auto-provisioned into each new academic year by the daily cron (mirrors the
2936
- * aspirations AspirationSurveySlot model). */
2937
- export type SkillsSurveySlot = {
2938
- sendMMDD: string;
2939
- rule?: SurveyDateRule;
2940
- label?: string;
2941
- students?: boolean;
2942
- parents?: boolean;
2943
- };
2927
+ /**
2928
+ * @deprecated Use SurveySlot (surveys/types.ts) this is now an alias of it.
2929
+ * One scheduled skills survey in a group's annual programme.
2930
+ */
2931
+ export type SkillsSurveySlot = SurveySlot;
2944
2932
  /**
2945
2933
  * A staff-defined student group mapping students to the skills they are served on
2946
2934
  * assessments. `filters` keys are student detail field names (from
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "name": "placementt-core",
4
4
  "author": "Placementt",
5
- "version": "1.400.985",
5
+ "version": "1.400.987",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
8
8
  "scripts": {
package/src/constants.ts CHANGED
@@ -1131,60 +1131,12 @@ export const SURVEY_MONTHS = [
1131
1131
  "July", "August", "September", "October", "November", "December",
1132
1132
  ];
1133
1133
 
1134
- const pad2 = (n: number) => String(n).padStart(2, "0");
1135
-
1136
- /**
1137
- * Academic years run September→August. Given the year a school year STARTS in
1138
- * (e.g. 2026 for "2026/27"), return the calendar year the given month falls in:
1139
- * September–December sit in the start year; January–August roll into the next.
1140
- * Mirrors the aspirations mmddToISO boundary (month >= 9 ⇒ start year).
1141
- */
1142
- export const academicCalendarYear = (month: number, academicStartYear: number): number =>
1143
- month >= 9 ? academicStartYear : academicStartYear + 1;
1144
-
1145
- /**
1146
- * The academic year that a given date falls within, as the START year. From
1147
- * September onwards we are in a new academic year (getMonth() is 0-indexed, so
1148
- * >= 8 is September). Matches DestinationsSetup.currentStartYear.
1149
- */
1150
- export const currentAcademicStartYear = (date = new Date()): number =>
1151
- date.getMonth() >= 8 ? date.getFullYear() : date.getFullYear() - 1;
1152
-
1153
- /**
1154
- * Resolve a rule to a concrete Date in a specific CALENDAR year+month, e.g.
1155
- * ("first", Monday, June 2027). "last" walks back from the month's final day.
1156
- */
1157
- export const resolveNthWeekday = (
1158
- calendarYear: number, month: number, ordinal: SurveyOrdinal, weekday: SurveyWeekday,
1159
- ): Date => {
1160
- if (ordinal === "last") {
1161
- const lastDay = new Date(calendarYear, month, 0).getDate(); // day 0 of next month
1162
- for (let d = lastDay; d >= 1; d--) {
1163
- const date = new Date(calendarYear, month - 1, d);
1164
- if (date.getDay() === weekday) return date;
1165
- }
1166
- return new Date(calendarYear, month - 1, lastDay);
1167
- }
1168
- const nth = {first: 1, second: 2, third: 3, fourth: 4}[ordinal];
1169
- let count = 0;
1170
- const daysInMonth = new Date(calendarYear, month, 0).getDate();
1171
- for (let d = 1; d <= daysInMonth; d++) {
1172
- const date = new Date(calendarYear, month - 1, d);
1173
- if (date.getDay() === weekday && ++count === nth) return date;
1174
- }
1175
- // Fewer than `nth` occurrences (e.g. a 5th Monday) — fall back to the last one.
1176
- return resolveNthWeekday(calendarYear, month, "last", weekday);
1177
- };
1178
-
1179
- /** Resolve a rule to the concrete Date for the academic year starting in academicStartYear. */
1180
- export const surveyRuleToDate = (rule: SurveyDateRule, academicStartYear: number): Date =>
1181
- resolveNthWeekday(academicCalendarYear(rule.month, academicStartYear), rule.month, rule.ordinal, rule.weekday);
1182
-
1183
- /** Resolve a rule to an "MM-DD" string for the academic year starting in academicStartYear. */
1184
- export const surveyRuleToMMDD = (rule: SurveyDateRule, academicStartYear: number): string => {
1185
- const d = surveyRuleToDate(rule, academicStartYear);
1186
- return `${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
1187
- };
1134
+ // The rule→date resolvers (academicCalendarYear, currentAcademicStartYear,
1135
+ // resolveNthWeekday, surveyRuleToDate, surveyRuleToMMDD) now live in
1136
+ // surveys/schedule.ts alongside the rest of the survey engine's scheduling helpers.
1137
+ // They are still exported from the package root, so `import {surveyRuleToMMDD} from
1138
+ // "placementt-core"` is unchanged. The label constants below stay here: they are
1139
+ // editor copy, not scheduling logic.
1188
1140
 
1189
1141
  /** Human label for a rule, e.g. "First Monday of June". */
1190
1142
  export const surveyRuleLabel = (rule: SurveyDateRule): string => {
package/src/index.ts CHANGED
@@ -9,6 +9,9 @@ export * from "./firebase/firebaseConfig";
9
9
  export * from "./firebase/firebaseQuery";
10
10
 
11
11
  export * from "./typeDefinitions";
12
+ export * from "./surveys/types";
13
+ export * from "./surveys/registry";
14
+ export * from "./surveys/schedule";
12
15
  export * from "./skillsResolver";
13
16
  export * from "./emailSections";
14
17
  export * from "./exportTransformers";