@quad-education/sdk 0.5.1 → 0.6.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/README.md +3 -1
- package/dist/contract-tests/harness.d.ts +1 -1
- package/dist/contract-tests/harness.js +3 -0
- package/dist/contract-tests/suite.d.ts +2 -0
- package/dist/contract-tests/suite.js +55 -1
- package/dist/src/client/create-client.js +1 -1
- package/dist/src/contract/types.d.ts +12 -2
- package/dist/src/contract/types.js +1 -1
- package/dist/src/engine/engine.d.ts +12 -1
- package/dist/src/engine/engine.js +38 -10
- package/dist/src/protocol.d.ts +1 -1
- package/dist/src/protocol.js +1 -0
- package/dist/src/testing/index.d.ts +7 -0
- package/dist/src/testing/index.js +7 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -12,7 +12,8 @@ const sdk = await connect()
|
|
|
12
12
|
const { items } = await sdk.school.students.list({ where: { yearLevel: 'Y9' } })
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Modules: `auth
|
|
15
|
+
Modules: `auth` (who is signed in, and whether the school made them an app admin: `me()`,
|
|
16
|
+
`appAdmins()`, D133), `school` (canonical school data, filtered by your scopes and the user's
|
|
16
17
|
visibility), `db` (your app's own data), `notify`, `clock`. Slice B adds `tasks`,
|
|
17
18
|
`schedule`, `cron` and `audit`.
|
|
18
19
|
|
|
@@ -95,6 +96,7 @@ The types allow `orderBy` and ranges only on indexed fields, so most mistakes ar
|
|
|
95
96
|
|
|
96
97
|
## Versions
|
|
97
98
|
|
|
99
|
+
- **0.6.0 (D133, 30 Oct 2026).** App admins: `auth.me()` gains `appAdmin` for a user (staff the school put in charge of the app), and `auth.appAdmins()` lists them for staff and jobs (FORBIDDEN for a student or parent). The engine gains the platform-only `setAppAdmins(appId, personIds)`, the testing kit `createTestPlatform({ appAdmins })` and `setAppAdmins`, and the contract tests the `setAppAdmins` control. A contract change; every `@quad-education/*` package moves to 0.6.0.
|
|
98
100
|
- **0.4.0 (D103, 21 Oct 2026).** A small canonical model, and no field-level coverage anywhere an app can see it (a contract change across all the `@quad-education/*` packages, which move together). The model is 13 entities and 56 fields: the foundation (`schools`, `students`, `staff`, `parents`, `parentStudentLinks`, `cohorts`, `cohortMemberships`) and the extended ones some school systems supply (`periods`, `rooms`, `lessons`, `sessionAttendance`, `medicalAlerts`, `medicalNotes`). **Removed:** `enrolments`, `courses`, `courseEnrolments`, `subjects`, `calendarEvents` and `sdk.school.calendar`, `assignments`, `submissions`, `results`, `studentAbsences`, `attendanceSummaries`, `behaviours`, `achievements`, `learningSupportNeeds`, `medicalEvents`, `employeeAbsences`, `applicants` and `pastoralNotes`; and fields: `students.preferredName` and the seven sensitive demographic fields, `staff.positionTitle` and `phone`, a parent's title, mobile, address and language, `livesWith`, `primaryContact`, `cohorts.parentCohortId` and `subjectId`, the register's `comment` and `minutesLate`, a medical alert's `severity` and `actionPlan`, and a note's `title`, `conditionId` and `eventId`. **Added:** `students.gender`, `parents.phone`, `cohorts.subject` (text, such as "English"), the `form` cohort kind, and the capability map (`CAPABILITIES`, `capabilityOf`, `capabilitiesOf`, `entityKind` in `@quad-education/canonical`). **Changed:** apps no longer declare the fields they read, so the manifest `data` block is accepted and ignored (`manifestWarnings` says to remove it), the engine strips nothing, and `core` is gone; scopes are checked directly. Ids, references and names are required and every other field is typed optional, because a school's system may not supply it. A parent's contact flags (`receivesCorrespondence`, `canConsent`, `contactRestricted`) are optional too, and where a school's system does not supply one the parent is treated as contactable (D17 amended by D103). The `lms` backing goes, and `fieldTier`, `coreFields` and `varyingFields` with it.
|
|
99
101
|
- **0.3.0 (D101, 20 Oct 2026).** Every app runs in a school, so what 0.2.0 added for apps with no school is removed (a removal across all the `@quad-education/*` packages, which move together). Gone from the main entry: the `account` and `guest` principals, `ActingAs`, the account directory and `staticDirectory`, the `account` and `guest` results of `auth.me()`, the `NOT_AVAILABLE` error code (`sdk.school` is always available: the fictional school in dev and the Sandbox, the real school in a school instance), the `{ account }` recipient, and `{ role }` taking any string (it is a school role again). Gone from `@quad-education/sdk/client`: `createHttpTransport`, `connectHttp`, the live connection (`connectLive`, `getLiveStatus`, `signIn`, `continueAsGuest`, `SignInRequired`) and the live branch of `connect()`, which now only talks to the shell. Gone from `@quad-education/sdk/engine` (platform-side only): `school: false`, `accounts`, `accountsFor`, a per-app `timezone`, `attachApp`, `hasApp`, `setAccounts` and `isStandalone`. Gone from `@quad-education/sdk/contract-tests`: the `STANDALONE_APP`, `ACCOUNT_APP` and `TEST_ACCOUNTS` fixtures and the `school` option. `@quad-education/sdk-react` loses `SignInChoices` and `SignInActions`; `@quad-education/schema` loses the manifest's `guests`, the reserved role `guest` and the SDK-version rule for guests. The `subject` rule now applies to every app. **Kept:** the `createdBy, createdAt` implicit index (a list of one's own records can be sorted), and the engine's state behind an `AppStore`, so a school instance's data API can run the same rules over DynamoDB; its `inbox`, `runs`, `auditLog`, `effectsSnapshot` and `runPrincipal` still return promises. Guest access inside a school instance is wanted, and comes back as a contract change when it is designed. Every earlier version, 0.2.0 included, is withdrawn from npm after this one is out.
|
|
100
102
|
- **0.2.0** (20 Oct 2026, withdrawn). Account and guest principals, `NOT_AVAILABLE`, the manifest `guests` flag and the live connection, for apps that were to run live outside a school (V2c, D100). Removed again by D101 in 0.3.0.
|
|
@@ -2,7 +2,7 @@ import type { Principal } from '@quad-education/canonical';
|
|
|
2
2
|
import type { ContractEnv, TestApp } from './suite.ts';
|
|
3
3
|
import type { QuadSdk } from '../src/contract/types.ts';
|
|
4
4
|
import type { Engine } from '../src/engine/index.ts';
|
|
5
|
-
type SliceBControl = Pick<ContractEnv['control'], 'advanceClock' | 'runDueJobs' | 'redeliver' | 'runs' | 'inbox' | 'auditLog'>;
|
|
5
|
+
type SliceBControl = Pick<ContractEnv['control'], 'advanceClock' | 'runDueJobs' | 'redeliver' | 'runs' | 'inbox' | 'auditLog' | 'setAppAdmins'>;
|
|
6
6
|
/**
|
|
7
7
|
* The job-running and inspection controls, shared by both contract runners. Each job runs
|
|
8
8
|
* as its run's principal through whatever transport `connect` uses.
|
|
@@ -6,6 +6,9 @@ import { executeRun } from "../src/jobs/define.js";
|
|
|
6
6
|
export function sliceBControls(engine, app, connect, onClock = async () => { }) {
|
|
7
7
|
const appId = () => app().manifest.id;
|
|
8
8
|
return {
|
|
9
|
+
async setAppAdmins(personIds) {
|
|
10
|
+
engine().setAppAdmins(appId(), personIds);
|
|
11
|
+
},
|
|
9
12
|
async advanceClock(ms) {
|
|
10
13
|
engine().advanceClock(ms);
|
|
11
14
|
await onClock();
|
|
@@ -50,6 +50,8 @@ export type ContractEnv = {
|
|
|
50
50
|
auditLog(): Promise<readonly (Record<string, any> & {
|
|
51
51
|
visibility: 'app' | 'cio';
|
|
52
52
|
})[]>;
|
|
53
|
+
/** The installation's app admins, as the school sets them (D133): person ids, replacing any before. */
|
|
54
|
+
setAppAdmins(personIds: readonly string[]): Promise<void>;
|
|
53
55
|
};
|
|
54
56
|
dispose(): Promise<void>;
|
|
55
57
|
};
|
|
@@ -29,6 +29,7 @@ const STUDENT = persona('student');
|
|
|
29
29
|
const SIBLINGS_PARENT = persona('parent-of-siblings');
|
|
30
30
|
const SEPARATED_PARENT = persona('separated-parent');
|
|
31
31
|
const SYSTEM = { kind: 'system', appId: 'contract-access' };
|
|
32
|
+
const SYSTEM_FOR_TEST_APP = { kind: 'system', appId: TEST_APP.manifest.id };
|
|
32
33
|
const RESTRICTED_PARENT = persona('restricted-parent');
|
|
33
34
|
const childrenOf = (parentId) => ds.parentStudentLinks
|
|
34
35
|
.filter((l) => l.parentId === parentId && !l.contactRestricted)
|
|
@@ -53,6 +54,7 @@ export function defineContractSuite(name, factory) {
|
|
|
53
54
|
expect(me).toEqual({
|
|
54
55
|
kind: 'user',
|
|
55
56
|
role: 'staff',
|
|
57
|
+
appAdmin: false,
|
|
56
58
|
person: {
|
|
57
59
|
id: record.id,
|
|
58
60
|
givenName: record.givenName,
|
|
@@ -61,13 +63,65 @@ export function defineContractSuite(name, factory) {
|
|
|
61
63
|
},
|
|
62
64
|
});
|
|
63
65
|
expect(sdk.appId).toBe(TEST_APP.manifest.id);
|
|
64
|
-
expect(sdk.version).toBe('0.
|
|
66
|
+
expect(sdk.version).toBe('0.6.0');
|
|
65
67
|
});
|
|
66
68
|
it('knows parents and students', async () => {
|
|
67
69
|
expect((await (await env.connect(STUDENT)).auth.me()).role).toBe('student');
|
|
68
70
|
expect((await (await env.connect(SIBLINGS_PARENT)).auth.me()).role).toBe('parent');
|
|
69
71
|
});
|
|
70
72
|
});
|
|
73
|
+
// D133: the school names an installation's app admins (staff only). An app reads the flag to open its settings
|
|
74
|
+
// screen, and lists the admins to show or message them; it never changes them.
|
|
75
|
+
describe('auth: app admins (D133)', () => {
|
|
76
|
+
useApp(TEST_APP);
|
|
77
|
+
const OTHER_STAFF = SUPERVISOR;
|
|
78
|
+
const summary = (id) => {
|
|
79
|
+
const r = ds.staff.find((s) => s.id === id);
|
|
80
|
+
return {
|
|
81
|
+
id: r.id,
|
|
82
|
+
givenName: r.givenName,
|
|
83
|
+
familyName: r.familyName,
|
|
84
|
+
displayName: `${r.givenName} ${r.familyName}`,
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
it('has none until the school names them', async () => {
|
|
88
|
+
const sdk = await env.connect(STAFF);
|
|
89
|
+
expect((await sdk.auth.me()).appAdmin).toBe(false);
|
|
90
|
+
expect(await sdk.auth.appAdmins()).toEqual([]);
|
|
91
|
+
});
|
|
92
|
+
it('marks the staff the school named, and lists them in name order', async () => {
|
|
93
|
+
await env.control.setAppAdmins([OTHER_STAFF.personId, STAFF.personId]);
|
|
94
|
+
expect((await (await env.connect(STAFF)).auth.me()).appAdmin).toBe(true);
|
|
95
|
+
expect((await (await env.connect(OTHER_STAFF)).auth.me()).appAdmin).toBe(true);
|
|
96
|
+
const expected = [summary(STAFF.personId), summary(OTHER_STAFF.personId)].sort((a, b) => a.familyName.localeCompare(b.familyName) ||
|
|
97
|
+
a.givenName.localeCompare(b.givenName) ||
|
|
98
|
+
a.id.localeCompare(b.id));
|
|
99
|
+
expect(await (await env.connect(STAFF)).auth.appAdmins()).toEqual(expected);
|
|
100
|
+
expect(await (await env.connect(SYSTEM_FOR_TEST_APP)).auth.appAdmins()).toEqual(expected);
|
|
101
|
+
});
|
|
102
|
+
it('is only ever staff: a student or parent named by mistake is not an admin', async () => {
|
|
103
|
+
await env.control.setAppAdmins([
|
|
104
|
+
STUDENT.personId,
|
|
105
|
+
SIBLINGS_PARENT.personId,
|
|
106
|
+
'staff-no-such-person',
|
|
107
|
+
]);
|
|
108
|
+
expect((await (await env.connect(STUDENT)).auth.me()).appAdmin).toBe(false);
|
|
109
|
+
expect((await (await env.connect(SIBLINGS_PARENT)).auth.me()).appAdmin).toBe(false);
|
|
110
|
+
expect(await (await env.connect(STAFF)).auth.appAdmins()).toEqual([]);
|
|
111
|
+
});
|
|
112
|
+
it('lists them for staff and jobs only', async () => {
|
|
113
|
+
await env.control.setAppAdmins([STAFF.personId]);
|
|
114
|
+
await expectError((await env.connect(STUDENT)).auth.appAdmins(), 'FORBIDDEN');
|
|
115
|
+
await expectError((await env.connect(SIBLINGS_PARENT)).auth.appAdmins(), 'FORBIDDEN');
|
|
116
|
+
});
|
|
117
|
+
it('says nothing about admins for the system principal', async () => {
|
|
118
|
+
await env.control.setAppAdmins([STAFF.personId]);
|
|
119
|
+
expect(await (await env.connect(SYSTEM_FOR_TEST_APP)).auth.me()).toEqual({
|
|
120
|
+
kind: 'system',
|
|
121
|
+
appId: TEST_APP.manifest.id,
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
});
|
|
71
125
|
describe('school: visibility (D4)', () => {
|
|
72
126
|
useApp(TEST_APP);
|
|
73
127
|
it('staff see every student', async () => {
|
|
@@ -33,7 +33,7 @@ export function createSdkClient(transport, session, context) {
|
|
|
33
33
|
const sdk = {
|
|
34
34
|
version: SDK_VERSION,
|
|
35
35
|
appId: session.appId,
|
|
36
|
-
auth: { me: () => call('auth.me') },
|
|
36
|
+
auth: { me: () => call('auth.me'), appAdmins: () => call('auth.appAdmins') },
|
|
37
37
|
school: Object.freeze(school),
|
|
38
38
|
db: {
|
|
39
39
|
entity: (name) => Object.freeze({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CanonicalRecord, ContactPurpose, Entities, EntityName, RecordWithTiers, Role, TiersFor } from '@quad-education/canonical';
|
|
2
2
|
import type { AppEntityDef, AppInput, AppSchema, FieldValue, SystemFields } from '@quad-education/schema';
|
|
3
3
|
import type { Recipient } from './recipients.ts';
|
|
4
|
-
export declare const SDK_VERSION = "0.
|
|
4
|
+
export declare const SDK_VERSION = "0.6.0";
|
|
5
5
|
/**
|
|
6
6
|
* Describes the current app to the type system. `quad gen` augments it from
|
|
7
7
|
* app.manifest.json and schema/ (D23); without that, nothing is readable.
|
|
@@ -72,10 +72,15 @@ export type PersonSummary = {
|
|
|
72
72
|
readonly familyName: string;
|
|
73
73
|
readonly displayName: string;
|
|
74
74
|
};
|
|
75
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* The current principal. Jobs (Slice B) run as `system` (D8). `appAdmin` says whether the school has put this person in
|
|
77
|
+
* charge of the app (D133): staff only, named by the school for each installation. Use it to open a settings screen;
|
|
78
|
+
* keep any further admins or roles in `sdk.db`.
|
|
79
|
+
*/
|
|
76
80
|
export type Me = {
|
|
77
81
|
readonly kind: 'user';
|
|
78
82
|
readonly role: Role;
|
|
83
|
+
readonly appAdmin: boolean;
|
|
79
84
|
readonly person: PersonSummary;
|
|
80
85
|
} | {
|
|
81
86
|
readonly kind: 'system';
|
|
@@ -83,6 +88,11 @@ export type Me = {
|
|
|
83
88
|
};
|
|
84
89
|
export type AuthApi = {
|
|
85
90
|
me(): Promise<Me>;
|
|
91
|
+
/**
|
|
92
|
+
* The installation's app admins (D133), in name order: the staff the school put in charge of the app. Staff and jobs
|
|
93
|
+
* may ask; a student or parent is refused (FORBIDDEN). Apps can't change the list: the school does.
|
|
94
|
+
*/
|
|
95
|
+
appAdmins(): Promise<readonly PersonSummary[]>;
|
|
86
96
|
};
|
|
87
97
|
/**
|
|
88
98
|
* A school record as this app sees it: the fields of the tiers its scopes grant (D23). Fields beyond ids, references
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = '0.
|
|
1
|
+
export const SDK_VERSION = '0.6.0';
|
|
@@ -18,6 +18,8 @@ export declare class Engine implements Kernel {
|
|
|
18
18
|
private readonly apps;
|
|
19
19
|
private clock;
|
|
20
20
|
private byId;
|
|
21
|
+
/** Each app's admins, as person ids (D133). The platform sets them, as a school does; apps only read them. */
|
|
22
|
+
private readonly admins;
|
|
21
23
|
private school;
|
|
22
24
|
readonly store: AppStore;
|
|
23
25
|
private constructor();
|
|
@@ -38,6 +40,14 @@ export declare class Engine implements Kernel {
|
|
|
38
40
|
schema: AppSchema;
|
|
39
41
|
}): Promise<void>;
|
|
40
42
|
manifest(appId: string): Manifest;
|
|
43
|
+
/**
|
|
44
|
+
* Who the school has put in charge of an app (D133): staff person ids, replacing any before. Platform only (the
|
|
45
|
+
* Sandbox's School data view, a test platform); no SDK method writes it. Ids that aren't staff in the school served at
|
|
46
|
+
* the time of a read are ignored, so someone who leaves drops out.
|
|
47
|
+
*/
|
|
48
|
+
setAppAdmins(appId: string, personIds: readonly string[]): void;
|
|
49
|
+
/** The app's admins who are staff in the school served now, in name order. */
|
|
50
|
+
private appAdminRecords;
|
|
41
51
|
/** Clear an app's data and outbox (the shell's reset button). */
|
|
42
52
|
resetApp(appId: string): Promise<void>;
|
|
43
53
|
/** Open tasks assigned to a person: the shell's inbox (D6). */
|
|
@@ -104,6 +114,7 @@ export declare class Engine implements Kernel {
|
|
|
104
114
|
private appFor;
|
|
105
115
|
private context;
|
|
106
116
|
private me;
|
|
117
|
+
private appAdmins;
|
|
107
118
|
private schoolInfo;
|
|
108
119
|
private entityName;
|
|
109
120
|
/**
|
|
@@ -164,4 +175,4 @@ export declare class Engine implements Kernel {
|
|
|
164
175
|
/** D19: one CIO-visible entry per call that returns pastoral or medical fields. */
|
|
165
176
|
private auditSensitiveRead;
|
|
166
177
|
}
|
|
167
|
-
export declare const ENGINE_SDK_VERSION = "0.
|
|
178
|
+
export declare const ENGINE_SDK_VERSION = "0.6.0";
|
|
@@ -26,6 +26,8 @@ export class Engine {
|
|
|
26
26
|
apps = new Map();
|
|
27
27
|
clock = { kind: 'offset', offsetMs: 0 };
|
|
28
28
|
byId = new Map();
|
|
29
|
+
/** Each app's admins, as person ids (D133). The platform sets them, as a school does; apps only read them. */
|
|
30
|
+
admins = new Map();
|
|
29
31
|
school;
|
|
30
32
|
store;
|
|
31
33
|
constructor(dataset, store) {
|
|
@@ -87,6 +89,25 @@ export class Engine {
|
|
|
87
89
|
manifest(appId) {
|
|
88
90
|
return this.appFor(appId).manifest;
|
|
89
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Who the school has put in charge of an app (D133): staff person ids, replacing any before. Platform only (the
|
|
94
|
+
* Sandbox's School data view, a test platform); no SDK method writes it. Ids that aren't staff in the school served at
|
|
95
|
+
* the time of a read are ignored, so someone who leaves drops out.
|
|
96
|
+
*/
|
|
97
|
+
setAppAdmins(appId, personIds) {
|
|
98
|
+
this.appFor(appId);
|
|
99
|
+
this.admins.set(appId, [...new Set(personIds)]);
|
|
100
|
+
}
|
|
101
|
+
/** The app's admins who are staff in the school served now, in name order. */
|
|
102
|
+
appAdminRecords(appId) {
|
|
103
|
+
return (this.admins.get(appId) ?? [])
|
|
104
|
+
.map((id) => this.byId.get(id))
|
|
105
|
+
.filter((p) => p?.entity === 'staff')
|
|
106
|
+
.map((p) => p.record)
|
|
107
|
+
.sort((a, b) => a.familyName.localeCompare(b.familyName) ||
|
|
108
|
+
a.givenName.localeCompare(b.givenName) ||
|
|
109
|
+
a.id.localeCompare(b.id));
|
|
110
|
+
}
|
|
90
111
|
/** Clear an app's data and outbox (the shell's reset button). */
|
|
91
112
|
async resetApp(appId) {
|
|
92
113
|
const app = this.appFor(appId);
|
|
@@ -216,6 +237,8 @@ export class Engine {
|
|
|
216
237
|
switch (method) {
|
|
217
238
|
case 'auth.me':
|
|
218
239
|
return this.me(ctx);
|
|
240
|
+
case 'auth.appAdmins':
|
|
241
|
+
return this.appAdmins(ctx);
|
|
219
242
|
case 'school.info':
|
|
220
243
|
return this.schoolInfo();
|
|
221
244
|
case 'school.get':
|
|
@@ -297,16 +320,15 @@ export class Engine {
|
|
|
297
320
|
if (principal.kind === 'system')
|
|
298
321
|
return { kind: 'system', appId: principal.appId };
|
|
299
322
|
const r = this.byId.get(principal.personId).record;
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
};
|
|
323
|
+
const appAdmin = principal.role === 'staff' &&
|
|
324
|
+
this.appAdminRecords(ctx.app.manifest.id).some((a) => a.id === r.id);
|
|
325
|
+
return { kind: 'user', role: principal.role, appAdmin, person: personSummary(r) };
|
|
326
|
+
}
|
|
327
|
+
appAdmins(ctx) {
|
|
328
|
+
if (ctx.principal.kind === 'user' && ctx.principal.role !== 'staff') {
|
|
329
|
+
throw new QuadError('FORBIDDEN', 'only staff and jobs can see who the app admins are');
|
|
330
|
+
}
|
|
331
|
+
return this.appAdminRecords(ctx.app.manifest.id).map(personSummary);
|
|
310
332
|
}
|
|
311
333
|
// ---- school ----
|
|
312
334
|
schoolInfo() {
|
|
@@ -908,3 +930,9 @@ export class Engine {
|
|
|
908
930
|
}
|
|
909
931
|
}
|
|
910
932
|
export const ENGINE_SDK_VERSION = SDK_VERSION;
|
|
933
|
+
const personSummary = (r) => ({
|
|
934
|
+
id: r.id,
|
|
935
|
+
givenName: r.givenName,
|
|
936
|
+
familyName: r.familyName,
|
|
937
|
+
displayName: `${r.givenName} ${r.familyName}`,
|
|
938
|
+
});
|
package/dist/src/protocol.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QuadError, type QuadErrorCode } from './contract/errors.ts';
|
|
2
|
-
export declare const METHODS: readonly ["auth.me", "school.info", "school.get", "school.list", "school.cohortByCode", "school.cohortMembers", "school.studentParents", "school.parentChildren", "db.create", "db.update", "db.get", "db.list", "db.delete", "notify.send", "tasks.assign", "tasks.get", "tasks.list", "tasks.complete", "tasks.cancel", "schedule.at", "schedule.cancel", "schedule.list", "cron.list", "audit.record", "audit.list"];
|
|
2
|
+
export declare const METHODS: readonly ["auth.me", "auth.appAdmins", "school.info", "school.get", "school.list", "school.cohortByCode", "school.cohortMembers", "school.studentParents", "school.parentChildren", "db.create", "db.update", "db.get", "db.list", "db.delete", "notify.send", "tasks.assign", "tasks.get", "tasks.list", "tasks.complete", "tasks.cancel", "schedule.at", "schedule.cancel", "schedule.list", "cron.list", "audit.record", "audit.list"];
|
|
3
3
|
export type Method = (typeof METHODS)[number];
|
|
4
4
|
export type SerializedError = {
|
|
5
5
|
code: QuadErrorCode;
|
package/dist/src/protocol.js
CHANGED
|
@@ -16,6 +16,11 @@ export type TestPlatform = {
|
|
|
16
16
|
as(who: PersonWho | Principal): QuadSdk;
|
|
17
17
|
/** An SDK acting as the system principal, as jobs run. */
|
|
18
18
|
system(): QuadSdk;
|
|
19
|
+
/**
|
|
20
|
+
* Name the app's admins, as a school does when it installs the app (D133): suggested people by rule or anyone by id.
|
|
21
|
+
* None by default, so a test says who is an admin.
|
|
22
|
+
*/
|
|
23
|
+
setAppAdmins(who: readonly PersonWho[]): void;
|
|
19
24
|
setClock(iso: string | null): Promise<void>;
|
|
20
25
|
close(): void;
|
|
21
26
|
};
|
|
@@ -24,6 +29,8 @@ export declare function createTestPlatform(app: {
|
|
|
24
29
|
manifest: unknown;
|
|
25
30
|
schema: AppSchema;
|
|
26
31
|
now?: string;
|
|
32
|
+
/** The app's admins from the start (D133); see `TestPlatform.setAppAdmins`. */
|
|
33
|
+
appAdmins?: readonly PersonWho[];
|
|
27
34
|
}): Promise<TestPlatform>;
|
|
28
35
|
/** A suggestion rule, such as `parent-of-siblings` (see `SUGGESTION_RULES`), or a person's id. */
|
|
29
36
|
export type PersonWho = SuggestionRule | (string & {});
|
|
@@ -15,6 +15,12 @@ export async function createTestPlatform(app) {
|
|
|
15
15
|
await engine.setClock(app.now);
|
|
16
16
|
await engine.installApp(app);
|
|
17
17
|
const appId = app.manifest.id;
|
|
18
|
+
const setAppAdmins = (who) => engine.setAppAdmins(appId, who.map((w) => {
|
|
19
|
+
const p = toPrincipal(dataset, w);
|
|
20
|
+
return p.kind === 'user' ? p.personId : '';
|
|
21
|
+
}));
|
|
22
|
+
if (app.appAdmins)
|
|
23
|
+
setAppAdmins(app.appAdmins);
|
|
18
24
|
return {
|
|
19
25
|
engine,
|
|
20
26
|
appId,
|
|
@@ -23,6 +29,7 @@ export async function createTestPlatform(app) {
|
|
|
23
29
|
return connectInProcess(engine, appId, toPrincipal(dataset, who));
|
|
24
30
|
},
|
|
25
31
|
system: () => connectInProcess(engine, appId, { kind: 'system', appId }),
|
|
32
|
+
setAppAdmins,
|
|
26
33
|
setClock: (iso) => engine.setClock(iso),
|
|
27
34
|
close: () => engine.close(),
|
|
28
35
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quad-education/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The @quad-education/sdk contract, its in-browser engine, transports and contract tests",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"fake-indexeddb": "^6.2.5",
|
|
50
|
-
"@quad-education/
|
|
51
|
-
"@quad-education/schema": "^0.
|
|
52
|
-
"@quad-education/
|
|
50
|
+
"@quad-education/fictional-school": "^0.6.0",
|
|
51
|
+
"@quad-education/schema": "^0.6.0",
|
|
52
|
+
"@quad-education/canonical": "^0.6.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"vitest": "^5.0.3"
|