placementt-core 1.400.979 → 1.400.981
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/callables/__tests__/registry.test.d.ts +1 -0
- package/lib/callables/__tests__/registry.test.js +33 -0
- package/lib/callables/__tests__/registry.test.js.map +1 -0
- package/lib/callables/aspirations.d.ts +32 -0
- package/lib/callables/aspirations.js +23 -0
- package/lib/callables/aspirations.js.map +1 -0
- package/lib/callables/events.d.ts +47 -0
- package/lib/callables/events.js +28 -0
- package/lib/callables/events.js.map +1 -0
- package/lib/callables/index.d.ts +5 -0
- package/lib/callables/index.js +22 -0
- package/lib/callables/index.js.map +1 -0
- package/lib/callables/placement.d.ts +26 -0
- package/lib/callables/placement.js +24 -0
- package/lib/callables/placement.js.map +1 -0
- package/lib/callables/registry.d.ts +204 -0
- package/lib/callables/registry.js +25 -0
- package/lib/callables/registry.js.map +1 -0
- package/lib/callables/types.d.ts +22 -0
- package/lib/callables/types.js +3 -0
- package/lib/callables/types.js.map +1 -0
- package/lib/constants.d.ts +11 -0
- package/lib/constants.js +10 -0
- package/lib/constants.js.map +1 -1
- package/lib/firebase/firebase.d.ts +5 -2
- package/lib/firebase/firebase.js +7 -0
- package/lib/firebase/firebase.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/typeDefinitions.d.ts +5 -0
- package/package.json +3 -2
- package/src/callables/__tests__/registry.test.ts +34 -0
- package/src/callables/aspirations.ts +21 -0
- package/src/callables/events.ts +26 -0
- package/src/callables/index.ts +5 -0
- package/src/callables/placement.ts +22 -0
- package/src/callables/registry.ts +40 -0
- package/src/callables/types.ts +24 -0
- package/src/constants.ts +13 -0
- package/src/firebase/firebase.tsx +14 -2
- package/src/index.ts +1 -0
- package/src/typeDefinitions.ts +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const zod_1 = require("zod");
|
|
4
|
+
const registry_1 = require("../registry");
|
|
5
|
+
/**
|
|
6
|
+
* Self-consistency checks for the callable registry. These run inside
|
|
7
|
+
* placementt-core with no backend dependency. The cross-repo check (every
|
|
8
|
+
* contract maps to a real backend `onCall`) lives in the backend repo, which
|
|
9
|
+
* can import `allCallables` and scan its own source.
|
|
10
|
+
*/
|
|
11
|
+
describe("callable registry", () => {
|
|
12
|
+
const names = Object.keys(registry_1.allCallables);
|
|
13
|
+
it("has no name collisions across feature groups", () => {
|
|
14
|
+
const groupKeyCount = Object.values(registry_1.callableGroups)
|
|
15
|
+
.reduce((sum, group) => sum + Object.keys(group).length, 0);
|
|
16
|
+
// If two groups declared the same name, the spread in registry.ts would
|
|
17
|
+
// silently drop one and the merged count would be lower than the sum.
|
|
18
|
+
expect(names.length).toBe(groupKeyCount);
|
|
19
|
+
});
|
|
20
|
+
it("names every callable as `<module>-<export>`", () => {
|
|
21
|
+
for (const name of names) {
|
|
22
|
+
expect(name).toMatch(/^[a-zA-Z]+-[a-zA-Z]+$/);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
it("gives every callable a request and response zod schema", () => {
|
|
26
|
+
for (const name of names) {
|
|
27
|
+
const contract = registry_1.allCallables[name];
|
|
28
|
+
expect(contract.request).toBeInstanceOf(zod_1.z.ZodType);
|
|
29
|
+
expect(contract.response).toBeInstanceOf(zod_1.z.ZodType);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=registry.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.test.js","sourceRoot":"","sources":["../../../src/callables/__tests__/registry.test.ts"],"names":[],"mappings":";;AAAA,6BAAsB;AACtB,0CAAyD;AAEzD;;;;;GAKG;AACH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,uBAAY,CAAC,CAAC;IAExC,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACpD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,yBAAc,CAAC;aAC9C,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAChE,wEAAwE;QACxE,sEAAsE;QACtE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;QAClD,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAC9D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,MAAM,QAAQ,GAAG,uBAAY,CAAC,IAAiC,CAAC,CAAC;YACjE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,OAAC,CAAC,OAAO,CAAC,CAAC;YACnD,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,OAAC,CAAC,OAAO,CAAC,CAAC;QACxD,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Contracts for the `aspirations` backend module
|
|
4
|
+
* (`Placementt-Backend/functions/src/aspirations.ts`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const aspirationCallables: {
|
|
7
|
+
"aspirations-createAspirationCycle": {
|
|
8
|
+
request: z.ZodObject<{
|
|
9
|
+
oId: z.ZodString;
|
|
10
|
+
yearGroupsIncluded: z.ZodArray<z.ZodNumber, "many">;
|
|
11
|
+
scheduledSendDate: z.ZodString;
|
|
12
|
+
closeAfterDays: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
emailTemplateId: z.ZodOptional<z.ZodString>;
|
|
14
|
+
students: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
oId: string;
|
|
17
|
+
yearGroupsIncluded: number[];
|
|
18
|
+
scheduledSendDate: string;
|
|
19
|
+
students?: string | undefined;
|
|
20
|
+
closeAfterDays?: number | undefined;
|
|
21
|
+
emailTemplateId?: string | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
oId: string;
|
|
24
|
+
yearGroupsIncluded: number[];
|
|
25
|
+
scheduledSendDate: string;
|
|
26
|
+
students?: string | undefined;
|
|
27
|
+
closeAfterDays?: number | undefined;
|
|
28
|
+
emailTemplateId?: string | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
response: z.ZodAny;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.aspirationCallables = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Contracts for the `aspirations` backend module
|
|
7
|
+
* (`Placementt-Backend/functions/src/aspirations.ts`).
|
|
8
|
+
*/
|
|
9
|
+
exports.aspirationCallables = {
|
|
10
|
+
"aspirations-createAspirationCycle": {
|
|
11
|
+
request: zod_1.z.object({
|
|
12
|
+
oId: zod_1.z.string(),
|
|
13
|
+
yearGroupsIncluded: zod_1.z.array(zod_1.z.number()),
|
|
14
|
+
scheduledSendDate: zod_1.z.string(), // ISO string
|
|
15
|
+
closeAfterDays: zod_1.z.number().optional(),
|
|
16
|
+
emailTemplateId: zod_1.z.string().optional(),
|
|
17
|
+
students: zod_1.z.string().optional(), // JSON-serialised DataViewerSelectionBackend
|
|
18
|
+
}),
|
|
19
|
+
// TODO: tighten once the return shape is confirmed.
|
|
20
|
+
response: zod_1.z.any(),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=aspirations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aspirations.js","sourceRoot":"","sources":["../../src/callables/aspirations.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAGtB;;;GAGG;AACU,QAAA,mBAAmB,GAAG;IAC/B,mCAAmC,EAAE;QACjC,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;YACd,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;YACf,kBAAkB,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;YACvC,iBAAiB,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,aAAa;YAC5C,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACrC,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACtC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,6CAA6C;SACjF,CAAC;QACF,oDAAoD;QACpD,QAAQ,EAAE,OAAC,CAAC,GAAG,EAAE;KACpB;CACoB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Contracts for the `events` backend module
|
|
4
|
+
* (`Placementt-Backend/functions/src/events.ts`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const eventsCallables: {
|
|
7
|
+
"events-searchSchool": {
|
|
8
|
+
request: z.ZodObject<{
|
|
9
|
+
oId: z.ZodString;
|
|
10
|
+
query: z.ZodString;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
query: string;
|
|
13
|
+
oId: string;
|
|
14
|
+
}, {
|
|
15
|
+
query: string;
|
|
16
|
+
oId: string;
|
|
17
|
+
}>;
|
|
18
|
+
response: z.ZodArray<z.ZodObject<{
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
name: z.ZodOptional<z.ZodString>;
|
|
21
|
+
geohash: z.ZodOptional<z.ZodString>;
|
|
22
|
+
"address-line1": z.ZodOptional<z.ZodString>;
|
|
23
|
+
"address-line2": z.ZodOptional<z.ZodString>;
|
|
24
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
25
|
+
locality: z.ZodOptional<z.ZodString>;
|
|
26
|
+
country: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
id: string;
|
|
29
|
+
name?: string | undefined;
|
|
30
|
+
"address-line1"?: string | undefined;
|
|
31
|
+
"address-line2"?: string | undefined;
|
|
32
|
+
country?: string | undefined;
|
|
33
|
+
locality?: string | undefined;
|
|
34
|
+
postal_code?: string | undefined;
|
|
35
|
+
geohash?: string | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
id: string;
|
|
38
|
+
name?: string | undefined;
|
|
39
|
+
"address-line1"?: string | undefined;
|
|
40
|
+
"address-line2"?: string | undefined;
|
|
41
|
+
country?: string | undefined;
|
|
42
|
+
locality?: string | undefined;
|
|
43
|
+
postal_code?: string | undefined;
|
|
44
|
+
geohash?: string | undefined;
|
|
45
|
+
}>, "many">;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eventsCallables = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Contracts for the `events` backend module
|
|
7
|
+
* (`Placementt-Backend/functions/src/events.ts`).
|
|
8
|
+
*/
|
|
9
|
+
exports.eventsCallables = {
|
|
10
|
+
"events-searchSchool": {
|
|
11
|
+
request: zod_1.z.object({
|
|
12
|
+
oId: zod_1.z.string(),
|
|
13
|
+
query: zod_1.z.string(),
|
|
14
|
+
}),
|
|
15
|
+
// Example of a fully-modelled response: an array of matched schools.
|
|
16
|
+
response: zod_1.z.array(zod_1.z.object({
|
|
17
|
+
id: zod_1.z.string(),
|
|
18
|
+
name: zod_1.z.string().optional(),
|
|
19
|
+
geohash: zod_1.z.string().optional(),
|
|
20
|
+
"address-line1": zod_1.z.string().optional(),
|
|
21
|
+
"address-line2": zod_1.z.string().optional(),
|
|
22
|
+
postal_code: zod_1.z.string().optional(),
|
|
23
|
+
locality: zod_1.z.string().optional(),
|
|
24
|
+
country: zod_1.z.string().optional(),
|
|
25
|
+
})),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/callables/events.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAGtB;;;GAGG;AACU,QAAA,eAAe,GAAG;IAC3B,qBAAqB,EAAE;QACnB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;YACd,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;YACf,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;SACpB,CAAC;QACF,qEAAqE;QACrE,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,CAAC;YACvB,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC3B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC9B,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACtC,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACtC,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAClC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC/B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SACjC,CAAC,CAAC;KACN;CACoB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./registry"), exports);
|
|
19
|
+
__exportStar(require("./aspirations"), exports);
|
|
20
|
+
__exportStar(require("./placement"), exports);
|
|
21
|
+
__exportStar(require("./events"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/callables/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,6CAA2B;AAC3B,gDAA8B;AAC9B,8CAA4B;AAC5B,2CAAyB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Contracts for the `placement` backend module
|
|
4
|
+
* (`Placementt-Backend/functions/src/placements.ts`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const placementCallables: {
|
|
7
|
+
"placement-propose": {
|
|
8
|
+
request: z.ZodObject<{
|
|
9
|
+
data: z.ZodAny;
|
|
10
|
+
studentId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
isDraft: z.ZodBoolean;
|
|
12
|
+
inSchool: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
isDraft: boolean;
|
|
15
|
+
data?: any;
|
|
16
|
+
inSchool?: boolean | undefined;
|
|
17
|
+
studentId?: string | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
isDraft: boolean;
|
|
20
|
+
data?: any;
|
|
21
|
+
inSchool?: boolean | undefined;
|
|
22
|
+
studentId?: string | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
response: z.ZodAny;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.placementCallables = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Contracts for the `placement` backend module
|
|
7
|
+
* (`Placementt-Backend/functions/src/placements.ts`).
|
|
8
|
+
*/
|
|
9
|
+
exports.placementCallables = {
|
|
10
|
+
"placement-propose": {
|
|
11
|
+
request: zod_1.z.object({
|
|
12
|
+
// Placement payload (StudentPlacementData | ProviderStudentPlacementData
|
|
13
|
+
// & { additionalNeeds? }). Left as z.any() for now - model the nested
|
|
14
|
+
// placement shape here when you want the call site checked in full.
|
|
15
|
+
data: zod_1.z.any(),
|
|
16
|
+
studentId: zod_1.z.string().optional(),
|
|
17
|
+
isDraft: zod_1.z.boolean(),
|
|
18
|
+
inSchool: zod_1.z.boolean().optional(),
|
|
19
|
+
}),
|
|
20
|
+
// TODO: tighten once the return shape is confirmed.
|
|
21
|
+
response: zod_1.z.any(),
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=placement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/callables/placement.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAGtB;;;GAGG;AACU,QAAA,kBAAkB,GAAG;IAC9B,mBAAmB,EAAE;QACjB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;YACd,yEAAyE;YACzE,sEAAsE;YACtE,oEAAoE;YACpE,IAAI,EAAE,OAAC,CAAC,GAAG,EAAE;YACb,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAChC,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE;YACpB,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;SACnC,CAAC;QACF,oDAAoD;QACpD,QAAQ,EAAE,OAAC,CAAC,GAAG,EAAE;KACpB;CACoB,CAAC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The single source of truth for every typed callable. Add a feature group's
|
|
4
|
+
* spread here and its callables are automatically covered by:
|
|
5
|
+
* - client typing (`executeCallable` keys off this),
|
|
6
|
+
* - backend request validation (`allCallables[name].request.parse(...)`),
|
|
7
|
+
* - the cross-repo completeness test.
|
|
8
|
+
*
|
|
9
|
+
* Names must be globally unique. A collision across groups would be silently
|
|
10
|
+
* overwritten by the spread, so the registry test asserts the merged key count
|
|
11
|
+
* equals the sum of the group key counts.
|
|
12
|
+
*/
|
|
13
|
+
export declare const allCallables: {
|
|
14
|
+
"events-searchSchool": {
|
|
15
|
+
request: z.ZodObject<{
|
|
16
|
+
oId: z.ZodString;
|
|
17
|
+
query: z.ZodString;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
query: string;
|
|
20
|
+
oId: string;
|
|
21
|
+
}, {
|
|
22
|
+
query: string;
|
|
23
|
+
oId: string;
|
|
24
|
+
}>;
|
|
25
|
+
response: z.ZodArray<z.ZodObject<{
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
name: z.ZodOptional<z.ZodString>;
|
|
28
|
+
geohash: z.ZodOptional<z.ZodString>;
|
|
29
|
+
"address-line1": z.ZodOptional<z.ZodString>;
|
|
30
|
+
"address-line2": z.ZodOptional<z.ZodString>;
|
|
31
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
32
|
+
locality: z.ZodOptional<z.ZodString>;
|
|
33
|
+
country: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
id: string;
|
|
36
|
+
name?: string | undefined;
|
|
37
|
+
"address-line1"?: string | undefined;
|
|
38
|
+
"address-line2"?: string | undefined;
|
|
39
|
+
country?: string | undefined;
|
|
40
|
+
locality?: string | undefined;
|
|
41
|
+
postal_code?: string | undefined;
|
|
42
|
+
geohash?: string | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
id: string;
|
|
45
|
+
name?: string | undefined;
|
|
46
|
+
"address-line1"?: string | undefined;
|
|
47
|
+
"address-line2"?: string | undefined;
|
|
48
|
+
country?: string | undefined;
|
|
49
|
+
locality?: string | undefined;
|
|
50
|
+
postal_code?: string | undefined;
|
|
51
|
+
geohash?: string | undefined;
|
|
52
|
+
}>, "many">;
|
|
53
|
+
};
|
|
54
|
+
"placement-propose": {
|
|
55
|
+
request: z.ZodObject<{
|
|
56
|
+
data: z.ZodAny;
|
|
57
|
+
studentId: z.ZodOptional<z.ZodString>;
|
|
58
|
+
isDraft: z.ZodBoolean;
|
|
59
|
+
inSchool: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
isDraft: boolean;
|
|
62
|
+
data?: any;
|
|
63
|
+
inSchool?: boolean | undefined;
|
|
64
|
+
studentId?: string | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
isDraft: boolean;
|
|
67
|
+
data?: any;
|
|
68
|
+
inSchool?: boolean | undefined;
|
|
69
|
+
studentId?: string | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
response: z.ZodAny;
|
|
72
|
+
};
|
|
73
|
+
"aspirations-createAspirationCycle": {
|
|
74
|
+
request: z.ZodObject<{
|
|
75
|
+
oId: z.ZodString;
|
|
76
|
+
yearGroupsIncluded: z.ZodArray<z.ZodNumber, "many">;
|
|
77
|
+
scheduledSendDate: z.ZodString;
|
|
78
|
+
closeAfterDays: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
emailTemplateId: z.ZodOptional<z.ZodString>;
|
|
80
|
+
students: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
oId: string;
|
|
83
|
+
yearGroupsIncluded: number[];
|
|
84
|
+
scheduledSendDate: string;
|
|
85
|
+
students?: string | undefined;
|
|
86
|
+
closeAfterDays?: number | undefined;
|
|
87
|
+
emailTemplateId?: string | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
oId: string;
|
|
90
|
+
yearGroupsIncluded: number[];
|
|
91
|
+
scheduledSendDate: string;
|
|
92
|
+
students?: string | undefined;
|
|
93
|
+
closeAfterDays?: number | undefined;
|
|
94
|
+
emailTemplateId?: string | undefined;
|
|
95
|
+
}>;
|
|
96
|
+
response: z.ZodAny;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
/** Every registered callable name. */
|
|
100
|
+
export type CallableName = keyof typeof allCallables;
|
|
101
|
+
/**
|
|
102
|
+
* Request/response static types per callable, inferred from the zod schemas.
|
|
103
|
+
* `executeCallable` and the backend handlers both read from this, so neither
|
|
104
|
+
* side restates a callable's shape.
|
|
105
|
+
*/
|
|
106
|
+
export type CallableContracts = {
|
|
107
|
+
[K in CallableName]: {
|
|
108
|
+
request: z.infer<(typeof allCallables)[K]["request"]>;
|
|
109
|
+
response: z.infer<(typeof allCallables)[K]["response"]>;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
/** The per-group maps, exported so tests can assert no key collisions. */
|
|
113
|
+
export declare const callableGroups: {
|
|
114
|
+
aspirationCallables: {
|
|
115
|
+
"aspirations-createAspirationCycle": {
|
|
116
|
+
request: z.ZodObject<{
|
|
117
|
+
oId: z.ZodString;
|
|
118
|
+
yearGroupsIncluded: z.ZodArray<z.ZodNumber, "many">;
|
|
119
|
+
scheduledSendDate: z.ZodString;
|
|
120
|
+
closeAfterDays: z.ZodOptional<z.ZodNumber>;
|
|
121
|
+
emailTemplateId: z.ZodOptional<z.ZodString>;
|
|
122
|
+
students: z.ZodOptional<z.ZodString>;
|
|
123
|
+
}, "strip", z.ZodTypeAny, {
|
|
124
|
+
oId: string;
|
|
125
|
+
yearGroupsIncluded: number[];
|
|
126
|
+
scheduledSendDate: string;
|
|
127
|
+
students?: string | undefined;
|
|
128
|
+
closeAfterDays?: number | undefined;
|
|
129
|
+
emailTemplateId?: string | undefined;
|
|
130
|
+
}, {
|
|
131
|
+
oId: string;
|
|
132
|
+
yearGroupsIncluded: number[];
|
|
133
|
+
scheduledSendDate: string;
|
|
134
|
+
students?: string | undefined;
|
|
135
|
+
closeAfterDays?: number | undefined;
|
|
136
|
+
emailTemplateId?: string | undefined;
|
|
137
|
+
}>;
|
|
138
|
+
response: z.ZodAny;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
placementCallables: {
|
|
142
|
+
"placement-propose": {
|
|
143
|
+
request: z.ZodObject<{
|
|
144
|
+
data: z.ZodAny;
|
|
145
|
+
studentId: z.ZodOptional<z.ZodString>;
|
|
146
|
+
isDraft: z.ZodBoolean;
|
|
147
|
+
inSchool: z.ZodOptional<z.ZodBoolean>;
|
|
148
|
+
}, "strip", z.ZodTypeAny, {
|
|
149
|
+
isDraft: boolean;
|
|
150
|
+
data?: any;
|
|
151
|
+
inSchool?: boolean | undefined;
|
|
152
|
+
studentId?: string | undefined;
|
|
153
|
+
}, {
|
|
154
|
+
isDraft: boolean;
|
|
155
|
+
data?: any;
|
|
156
|
+
inSchool?: boolean | undefined;
|
|
157
|
+
studentId?: string | undefined;
|
|
158
|
+
}>;
|
|
159
|
+
response: z.ZodAny;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
eventsCallables: {
|
|
163
|
+
"events-searchSchool": {
|
|
164
|
+
request: z.ZodObject<{
|
|
165
|
+
oId: z.ZodString;
|
|
166
|
+
query: z.ZodString;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
query: string;
|
|
169
|
+
oId: string;
|
|
170
|
+
}, {
|
|
171
|
+
query: string;
|
|
172
|
+
oId: string;
|
|
173
|
+
}>;
|
|
174
|
+
response: z.ZodArray<z.ZodObject<{
|
|
175
|
+
id: z.ZodString;
|
|
176
|
+
name: z.ZodOptional<z.ZodString>;
|
|
177
|
+
geohash: z.ZodOptional<z.ZodString>;
|
|
178
|
+
"address-line1": z.ZodOptional<z.ZodString>;
|
|
179
|
+
"address-line2": z.ZodOptional<z.ZodString>;
|
|
180
|
+
postal_code: z.ZodOptional<z.ZodString>;
|
|
181
|
+
locality: z.ZodOptional<z.ZodString>;
|
|
182
|
+
country: z.ZodOptional<z.ZodString>;
|
|
183
|
+
}, "strip", z.ZodTypeAny, {
|
|
184
|
+
id: string;
|
|
185
|
+
name?: string | undefined;
|
|
186
|
+
"address-line1"?: string | undefined;
|
|
187
|
+
"address-line2"?: string | undefined;
|
|
188
|
+
country?: string | undefined;
|
|
189
|
+
locality?: string | undefined;
|
|
190
|
+
postal_code?: string | undefined;
|
|
191
|
+
geohash?: string | undefined;
|
|
192
|
+
}, {
|
|
193
|
+
id: string;
|
|
194
|
+
name?: string | undefined;
|
|
195
|
+
"address-line1"?: string | undefined;
|
|
196
|
+
"address-line2"?: string | undefined;
|
|
197
|
+
country?: string | undefined;
|
|
198
|
+
locality?: string | undefined;
|
|
199
|
+
postal_code?: string | undefined;
|
|
200
|
+
geohash?: string | undefined;
|
|
201
|
+
}>, "many">;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.callableGroups = exports.allCallables = void 0;
|
|
4
|
+
const aspirations_1 = require("./aspirations");
|
|
5
|
+
const placement_1 = require("./placement");
|
|
6
|
+
const events_1 = require("./events");
|
|
7
|
+
/**
|
|
8
|
+
* The single source of truth for every typed callable. Add a feature group's
|
|
9
|
+
* spread here and its callables are automatically covered by:
|
|
10
|
+
* - client typing (`executeCallable` keys off this),
|
|
11
|
+
* - backend request validation (`allCallables[name].request.parse(...)`),
|
|
12
|
+
* - the cross-repo completeness test.
|
|
13
|
+
*
|
|
14
|
+
* Names must be globally unique. A collision across groups would be silently
|
|
15
|
+
* overwritten by the spread, so the registry test asserts the merged key count
|
|
16
|
+
* equals the sum of the group key counts.
|
|
17
|
+
*/
|
|
18
|
+
exports.allCallables = {
|
|
19
|
+
...aspirations_1.aspirationCallables,
|
|
20
|
+
...placement_1.placementCallables,
|
|
21
|
+
...events_1.eventsCallables,
|
|
22
|
+
};
|
|
23
|
+
/** The per-group maps, exported so tests can assert no key collisions. */
|
|
24
|
+
exports.callableGroups = { aspirationCallables: aspirations_1.aspirationCallables, placementCallables: placement_1.placementCallables, eventsCallables: events_1.eventsCallables };
|
|
25
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/callables/registry.ts"],"names":[],"mappings":";;;AAEA,+CAAkD;AAClD,2CAA+C;AAC/C,qCAAyC;AAEzC;;;;;;;;;;GAUG;AACU,QAAA,YAAY,GAAG;IACxB,GAAG,iCAAmB;IACtB,GAAG,8BAAkB;IACrB,GAAG,wBAAe;CACG,CAAC;AAiB1B,0EAA0E;AAC7D,QAAA,cAAc,GAAG,EAAC,mBAAmB,EAAnB,iCAAmB,EAAE,kBAAkB,EAAlB,8BAAkB,EAAE,eAAe,EAAf,wBAAe,EAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* One callable's contract. `request` validates/derives the payload the client
|
|
4
|
+
* sends; `response` validates/derives what the handler returns. Both the client
|
|
5
|
+
* (`executeCallable`) and the backend handler derive their static types from
|
|
6
|
+
* these schemas, so each callable's shape is written exactly once.
|
|
7
|
+
*
|
|
8
|
+
* Tighten `response` from `z.any()` to a concrete schema as you confirm each
|
|
9
|
+
* function's return shape - `any` keeps `res.data` untyped (today's behaviour)
|
|
10
|
+
* so migrating a callable never breaks its existing response consumers.
|
|
11
|
+
*/
|
|
12
|
+
export type CallableContract = {
|
|
13
|
+
request: z.ZodTypeAny;
|
|
14
|
+
response: z.ZodTypeAny;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A group of callables, keyed by their fully-qualified deployed name
|
|
18
|
+
* (`<module>-<export>`, e.g. `aspirations-createAspirationCycle`). Feature
|
|
19
|
+
* files declare a group and `satisfies CallableGroup`; `registry.ts` merges
|
|
20
|
+
* them into the single `allCallables` source of truth.
|
|
21
|
+
*/
|
|
22
|
+
export type CallableGroup = Record<`${string}-${string}`, CallableContract>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/callables/types.ts"],"names":[],"mappings":""}
|
package/lib/constants.d.ts
CHANGED
|
@@ -148,6 +148,17 @@ export declare const skillLabelColours: {
|
|
|
148
148
|
"Work Readiness": string;
|
|
149
149
|
"Career Development": string;
|
|
150
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* Resolves the display colour for a skill label. The colour is stored on the
|
|
153
|
+
* label document (`color`), seeded via the admin "Seed skill labels & colours"
|
|
154
|
+
* action; it falls back to the institute's brand colour, then PRIMARY_COLOUR.
|
|
155
|
+
* No category → colour lookup — the colour lives on the data.
|
|
156
|
+
*/
|
|
157
|
+
export declare function skillColour(label?: {
|
|
158
|
+
color?: string;
|
|
159
|
+
}, institute?: {
|
|
160
|
+
color?: string;
|
|
161
|
+
}): string;
|
|
151
162
|
export declare const skillAssessmentSchedule: {
|
|
152
163
|
[key in "yearStart" | "yearEnd" | "eachTerm" | "preWorkExperience" | "postWorkExperience" | "employerInteraction" | "extracurricularActivity"]: {
|
|
153
164
|
title: string;
|
package/lib/constants.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.leadStageSchema = exports.commSchema = exports.DEFAULT_SURVEY_RULE = exports.surveyRuleLabel = exports.surveyRuleToMMDD = exports.surveyRuleToDate = exports.resolveNthWeekday = exports.currentAcademicStartYear = exports.academicCalendarYear = exports.SURVEY_MONTHS = exports.SURVEY_WEEKDAYS = exports.SURVEY_ORDINALS = exports.skillAssessmentSchedule = exports.skillLabelColours = exports.equalexLearningOutcomes = exports.gatsbyBenchmarks = exports.externalActivityTypes = exports.MISQueryParams = exports.emailTemplates = exports.defaultApplicantWorkflow = exports.mobileCountryCodes = exports.ERROR_COLOR = exports.SUCCESS_COLOR = exports.WARNING_COLOR = exports.INFO_COLOR = exports.INFOBACKGROUNDCOLOR = exports.INFOTEXTCOLOR = exports.WARNINGBACKGROUNDCOLOR = exports.WARNINGTEXTCOLOR = exports.SUCCESSBACKGROUNDCOLOR = exports.SUCCESSTEXTCOLOR = exports.ERRORBACKGROUNDCOLOR = exports.ERRORTEXTCOLOR = exports.STUDENT_COLOUR = exports.PROVIDER_COLOUR = exports.INSTITUTE_COLOUR = exports.SECONDARY_COLOUR = exports.LOGO_TERTIARY_COLOUR = exports.LOGO_SECONDARY_COLOUR = exports.PRIMARY_COLOUR = exports.DEFAULT_ACTIVITY_REFLECTION_FORM = exports.DEFAULT_ACTIVITY_REFLECTION_FORM_ID = exports.sampleTargets = exports.flagCodes = exports.defaultStudentWorkflow = exports.defaultInstituteWorkflow = exports.sectorColours = exports.providerSectors = exports.countryList = exports.providerCodes = void 0;
|
|
4
4
|
exports.JOB_VALUES = exports.CAREER_INTEREST_CATEGORIES = exports.SIC_SECTIONS = exports.SOC_MAJOR_GROUPS = exports.DESTINATION_CODES = exports.careersHubSchoolOnboardingEmailTemplates = exports.emailCampaignFullStatuses = exports.emailCampaignSummaryStatuses = exports.leadStageOrder = void 0;
|
|
5
|
+
exports.skillColour = skillColour;
|
|
5
6
|
/* eslint-disable max-len */
|
|
6
7
|
exports.providerCodes = {
|
|
7
8
|
soleTrader: {
|
|
@@ -1013,6 +1014,15 @@ exports.skillLabelColours = {
|
|
|
1013
1014
|
["Work Readiness"]: "#f5c842",
|
|
1014
1015
|
["Career Development"]: "#c41d7f",
|
|
1015
1016
|
};
|
|
1017
|
+
/**
|
|
1018
|
+
* Resolves the display colour for a skill label. The colour is stored on the
|
|
1019
|
+
* label document (`color`), seeded via the admin "Seed skill labels & colours"
|
|
1020
|
+
* action; it falls back to the institute's brand colour, then PRIMARY_COLOUR.
|
|
1021
|
+
* No category → colour lookup — the colour lives on the data.
|
|
1022
|
+
*/
|
|
1023
|
+
function skillColour(label, institute) {
|
|
1024
|
+
return label?.color || institute?.color || exports.PRIMARY_COLOUR;
|
|
1025
|
+
}
|
|
1016
1026
|
exports.skillAssessmentSchedule = {
|
|
1017
1027
|
yearStart: {
|
|
1018
1028
|
title: "Start of Academic Year",
|