@quad-education/sdk 0.2.0 → 0.4.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 +4 -2
- package/dist/contract-tests/apps.d.ts +3 -112
- package/dist/contract-tests/apps.js +6 -183
- package/dist/contract-tests/harness.d.ts +2 -2
- package/dist/contract-tests/index.d.ts +2 -3
- package/dist/contract-tests/index.js +1 -2
- package/dist/contract-tests/suite.d.ts +3 -10
- package/dist/contract-tests/suite.js +49 -502
- package/dist/src/client/connect.d.ts +3 -13
- package/dist/src/client/connect.js +3 -21
- package/dist/src/client/create-client.js +0 -3
- package/dist/src/client/handshake-client.d.ts +0 -2
- package/dist/src/client/handshake-client.js +0 -2
- package/dist/src/contract/errors.d.ts +1 -1
- package/dist/src/contract/recipients.d.ts +2 -8
- package/dist/src/contract/types.d.ts +7 -44
- package/dist/src/contract/types.js +1 -1
- package/dist/src/engine/engine.d.ts +10 -46
- package/dist/src/engine/engine.js +42 -222
- package/dist/src/engine/host.d.ts +2 -2
- package/dist/src/engine/in-process.d.ts +2 -2
- package/dist/src/engine/runner.js +2 -4
- package/dist/src/engine/state.d.ts +6 -17
- package/dist/src/engine/state.js +3 -31
- package/dist/src/engine/tasks.js +3 -10
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/jobs/define.d.ts +2 -2
- package/dist/src/platform-types.d.ts +2 -2
- package/dist/src/protocol.d.ts +1 -1
- package/dist/src/protocol.js +0 -1
- package/package.json +4 -4
- package/dist/contract-tests/standalone-apps.d.ts +0 -183
- package/dist/contract-tests/standalone-apps.js +0 -178
- package/dist/contract-tests/standalone.d.ts +0 -2
- package/dist/contract-tests/standalone.js +0 -709
- package/dist/src/client/http-transport.d.ts +0 -18
- package/dist/src/client/http-transport.js +0 -76
- package/dist/src/client/live.d.ts +0 -39
- package/dist/src/client/live.js +0 -122
- package/dist/src/contract/principals.d.ts +0 -30
- package/dist/src/contract/principals.js +0 -12
package/README.md
CHANGED
|
@@ -95,7 +95,9 @@ The types allow `orderBy` and ranges only on indexed fields, so most mistakes ar
|
|
|
95
95
|
|
|
96
96
|
## Versions
|
|
97
97
|
|
|
98
|
-
- **0.
|
|
98
|
+
- **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
|
+
- **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
|
+
- **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.
|
|
99
101
|
- **0.1.4** (19 Oct 2026). The same SDK calls. The canonical model grows to what V2s S4 builds, which is what an app's `sdk.school.<entity>` and its types come from, so **0.1.3 cannot use any of it**: the attendance register (`sessionAttendance`, which must be filtered by student or date; `studentAbsences`, `attendanceSummaries`), behaviour and achievements, learning support, medical events and notes, staff absences and admissions applicants, and the demographic fields on `students`. It also adds two sensitivity tiers, `sensitive` and `hr`, which are staff-only (a student or parent never receives them), audited, and need manifest version 1 and a reason. A version 1 manifest still needs 0.1.3 or newer.
|
|
100
102
|
- **0.1.3** (18 Oct 2026). The same SDK calls, plus what V2s needs to run: manifest version 1 (`data`, `reasons`, `roles` and `schoolRoles`), declared-field types and stripping for school data, the new school entities (`periods`, `rooms`, `subjects`, `lessons`, with `lessons` generated on demand) and the test toolkit that understands all of it. **A version 1 manifest needs 0.1.3 or newer**: the test toolkit in 0.1.2 only reads version 0 manifests and fails every test with `invalid manifest: manifestVersion: expected 0`. The starter templates ask for `^0.1.3`.
|
|
101
103
|
- **0.1.2** (9 Oct 2026). The same contract as 0.1.1, and the first version to stay on npm. All the `@quad-education/*` packages were published on 9 Oct 2026 (0.1.0, and 0.1.1 for this one), then unpublished the same day to move the npm org to a new owner, and npm never allows an unpublished version again; every package is now 0.1.2. `SDK_VERSION` (`sdk.version`) now matches the package version; it had stayed at 0.1.0 through 0.1.1.
|
|
@@ -106,4 +108,4 @@ The types allow `orderBy` and ranges only on indexed fields, so most mistakes ar
|
|
|
106
108
|
- `orca gen` and `orca-env.d.ts` became `quad gen` and `quad-env.d.ts`;
|
|
107
109
|
- the handshake and jobs messages became `quad:*`.
|
|
108
110
|
|
|
109
|
-
The version stays 0.1.0 because nothing was published under the old name.
|
|
111
|
+
The version stays 0.1.0 because nothing was published under the old name.
|
|
@@ -67,127 +67,18 @@ export declare const TEST_APP: {
|
|
|
67
67
|
manifest: Manifest;
|
|
68
68
|
schema: typeof TEST_SCHEMA;
|
|
69
69
|
};
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
* fields of a student and nothing else that varies.
|
|
73
|
-
*/
|
|
74
|
-
export declare const DEMOGRAPHICS_APP: {
|
|
75
|
-
manifest: Manifest;
|
|
76
|
-
schema: typeof TEST_SCHEMA;
|
|
77
|
-
};
|
|
78
|
-
/** An awards app: achievements are academic, so it needs no pastoral scope and is not in the pastoral audit (S4.3). */
|
|
79
|
-
export declare const AWARDS_APP: {
|
|
80
|
-
manifest: Manifest;
|
|
81
|
-
schema: typeof TEST_SCHEMA;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* A staff leave app (S4.6): version 1, because a staff-only tier needs a reason. It asks for the staff reference and the
|
|
85
|
-
* `hr` fields of an absence.
|
|
86
|
-
*/
|
|
87
|
-
export declare const HR_APP: {
|
|
88
|
-
manifest: Manifest;
|
|
89
|
-
schema: typeof TEST_SCHEMA;
|
|
90
|
-
};
|
|
91
|
-
/** A first-aid and learning support app: it holds the medical tier too, so it receives diagnoses (S4.4). */
|
|
92
|
-
export declare const WELLBEING_APP: {
|
|
70
|
+
/** A first-aid app: it holds the medical tier, so it reads alerts and the notes about them (D103). */
|
|
71
|
+
export declare const MEDICAL_APP: {
|
|
93
72
|
manifest: Manifest;
|
|
94
73
|
schema: typeof TEST_SCHEMA;
|
|
95
74
|
};
|
|
96
|
-
/** The account directory the contract suite's engines are given: who exists and which app roles they hold. */
|
|
97
|
-
export declare const TEST_ACCOUNTS: readonly [{
|
|
98
|
-
readonly id: "acc-ada";
|
|
99
|
-
readonly displayName: "Ada Teacher";
|
|
100
|
-
readonly roles: readonly ["Teacher"];
|
|
101
|
-
}, {
|
|
102
|
-
readonly id: "acc-ben";
|
|
103
|
-
readonly displayName: "Ben Both";
|
|
104
|
-
readonly roles: readonly ["Teacher", "Student"];
|
|
105
|
-
}, {
|
|
106
|
-
readonly id: "acc-cai";
|
|
107
|
-
readonly displayName: "Cai Student";
|
|
108
|
-
readonly roles: readonly ["Student"];
|
|
109
|
-
}, {
|
|
110
|
-
readonly id: "acc-dee";
|
|
111
|
-
readonly displayName: "Dee Student";
|
|
112
|
-
readonly roles: readonly ["Student"];
|
|
113
|
-
}, {
|
|
114
|
-
readonly id: "acc-eve";
|
|
115
|
-
readonly displayName: "Eve Staff";
|
|
116
|
-
readonly roles: readonly ["Staff"];
|
|
117
|
-
}, {
|
|
118
|
-
readonly id: "acc-gus";
|
|
119
|
-
readonly displayName: "Gus Staff";
|
|
120
|
-
readonly roles: readonly ["Staff"];
|
|
121
|
-
}];
|
|
122
|
-
declare const ACCOUNT_SCHEMA: {
|
|
123
|
-
readonly note: {
|
|
124
|
-
readonly fields: {
|
|
125
|
-
readonly body: {
|
|
126
|
-
readonly kind: "text";
|
|
127
|
-
readonly tier: import("@quad-education/canonical").Tier;
|
|
128
|
-
};
|
|
129
|
-
readonly score: {
|
|
130
|
-
readonly kind: "number";
|
|
131
|
-
readonly tier: import("@quad-education/canonical").Tier;
|
|
132
|
-
} & {
|
|
133
|
-
readonly optional: true;
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
readonly indexes: readonly [readonly ["score"]];
|
|
137
|
-
readonly subject?: "score" | "body";
|
|
138
|
-
readonly access?: {
|
|
139
|
-
readonly teacher: {
|
|
140
|
-
readonly read: "all";
|
|
141
|
-
readonly create: "all";
|
|
142
|
-
readonly update: "all";
|
|
143
|
-
readonly delete: "all";
|
|
144
|
-
};
|
|
145
|
-
readonly Student: {
|
|
146
|
-
readonly read: "own";
|
|
147
|
-
readonly create: "own";
|
|
148
|
-
readonly update: "own";
|
|
149
|
-
readonly delete: "own";
|
|
150
|
-
};
|
|
151
|
-
readonly guest: {
|
|
152
|
-
readonly read: "own";
|
|
153
|
-
readonly create: "own";
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
};
|
|
158
|
-
type AccountApp = {
|
|
159
|
-
roles: 'teacher' | 'student';
|
|
160
|
-
scopes: never;
|
|
161
|
-
notifications: 'test.message';
|
|
162
|
-
tasks: 'test.review';
|
|
163
|
-
scheduled: 'remind';
|
|
164
|
-
schema: typeof ACCOUNT_SCHEMA;
|
|
165
|
-
};
|
|
166
|
-
/**
|
|
167
|
-
* A standalone app (version 1) with two app roles and guests (V2c). It reads no school data, so everything under
|
|
168
|
-
* `sdk.school` is NOT_AVAILABLE for it, whoever is asking.
|
|
169
|
-
*/
|
|
170
|
-
export declare const ACCOUNT_APP: {
|
|
171
|
-
manifest: Manifest;
|
|
172
|
-
schema: typeof ACCOUNT_SCHEMA;
|
|
173
|
-
jobs: Job<AccountApp>[];
|
|
174
|
-
};
|
|
175
75
|
/** A test app with only `students.basic:read`. */
|
|
176
76
|
export declare const BASIC_APP: {
|
|
177
77
|
manifest: Manifest;
|
|
178
78
|
schema: typeof TEST_SCHEMA;
|
|
179
79
|
};
|
|
180
80
|
/**
|
|
181
|
-
*
|
|
182
|
-
* and nothing else that varies. The core fields (studentNumber, givenName, familyName) come with the
|
|
183
|
-
* entity. Its scopes are exactly the tiers those fields need.
|
|
184
|
-
*/
|
|
185
|
-
export declare const DATA_APP: {
|
|
186
|
-
manifest: Manifest;
|
|
187
|
-
schema: typeof TEST_SCHEMA;
|
|
188
|
-
};
|
|
189
|
-
/**
|
|
190
|
-
* A standalone app (V2s D84): version 1, two app-defined roles named like school roles, so the matching
|
|
81
|
+
* An app (V2s D84) with version 1, two app-defined roles named like school roles, so the matching
|
|
191
82
|
* personas can preview them. The access keys are written in different cases on purpose.
|
|
192
83
|
*/
|
|
193
84
|
export declare const ROLES_SCHEMA: {
|
|
@@ -53,186 +53,27 @@ export const TEST_APP = {
|
|
|
53
53
|
'cohorts.basic:read',
|
|
54
54
|
'cohortMemberships.basic:read',
|
|
55
55
|
'medicalAlerts.medical:read',
|
|
56
|
-
'pastoralNotes.pastoral:read',
|
|
57
|
-
'calendarEvents.basic:read',
|
|
58
|
-
'courses.basic:read',
|
|
59
|
-
'results.academic:read',
|
|
60
56
|
'lessons.basic:read',
|
|
61
57
|
'periods.basic:read',
|
|
62
58
|
'rooms.basic:read',
|
|
63
|
-
'subjects.basic:read',
|
|
64
59
|
'sessionAttendance.basic:read',
|
|
65
60
|
'sessionAttendance.academic:read',
|
|
66
|
-
'sessionAttendance.pastoral:read',
|
|
67
|
-
'studentAbsences.basic:read',
|
|
68
|
-
'studentAbsences.academic:read',
|
|
69
|
-
'attendanceSummaries.basic:read',
|
|
70
|
-
'attendanceSummaries.academic:read',
|
|
71
|
-
'behaviours.basic:read',
|
|
72
|
-
'behaviours.pastoral:read',
|
|
73
|
-
'achievements.basic:read',
|
|
74
|
-
'achievements.academic:read',
|
|
75
|
-
'learningSupportNeeds.basic:read',
|
|
76
|
-
'learningSupportNeeds.pastoral:read',
|
|
77
|
-
'applicants.basic:read',
|
|
78
|
-
'applicants.contact:read',
|
|
79
61
|
],
|
|
80
62
|
notifications: ['test.message', 'test.reminder'],
|
|
81
63
|
},
|
|
82
64
|
schema: TEST_SCHEMA,
|
|
83
65
|
};
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
* fields of a student and nothing else that varies.
|
|
87
|
-
*/
|
|
88
|
-
export const DEMOGRAPHICS_APP = {
|
|
66
|
+
/** A first-aid app: it holds the medical tier, so it reads alerts and the notes about them (D103). */
|
|
67
|
+
export const MEDICAL_APP = {
|
|
89
68
|
manifest: {
|
|
90
69
|
...TEST_APP.manifest,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
scopes: ['parents.basic:read', 'students.basic:read', 'students.sensitive:read'],
|
|
95
|
-
data: {
|
|
96
|
-
parents: { required: [], optional: ['title'] },
|
|
97
|
-
students: {
|
|
98
|
-
required: [],
|
|
99
|
-
optional: [
|
|
100
|
-
'firstLanguage',
|
|
101
|
-
'englishAsAdditionalLanguage',
|
|
102
|
-
'ethnicity',
|
|
103
|
-
'nationality',
|
|
104
|
-
'religion',
|
|
105
|
-
'birthPlace',
|
|
106
|
-
'freeSchoolMeals',
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
reasons: {
|
|
111
|
-
'students.sensitive:read': 'To plan language support and cultural events with families’ agreement.',
|
|
112
|
-
},
|
|
70
|
+
id: 'contract-medical',
|
|
71
|
+
name: 'First-aid app',
|
|
72
|
+
scopes: ['medicalAlerts.medical:read', 'medicalNotes.basic:read', 'medicalNotes.medical:read'],
|
|
113
73
|
notifications: ['test.message'],
|
|
114
74
|
},
|
|
115
75
|
schema: TEST_SCHEMA,
|
|
116
76
|
};
|
|
117
|
-
/** An awards app: achievements are academic, so it needs no pastoral scope and is not in the pastoral audit (S4.3). */
|
|
118
|
-
export const AWARDS_APP = {
|
|
119
|
-
manifest: {
|
|
120
|
-
...TEST_APP.manifest,
|
|
121
|
-
id: 'contract-awards',
|
|
122
|
-
name: 'Awards app',
|
|
123
|
-
scopes: ['achievements.basic:read', 'achievements.academic:read'],
|
|
124
|
-
notifications: ['test.message'],
|
|
125
|
-
},
|
|
126
|
-
schema: TEST_SCHEMA,
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* A staff leave app (S4.6): version 1, because a staff-only tier needs a reason. It asks for the staff reference and the
|
|
130
|
-
* `hr` fields of an absence.
|
|
131
|
-
*/
|
|
132
|
-
export const HR_APP = {
|
|
133
|
-
manifest: {
|
|
134
|
-
...TEST_APP.manifest,
|
|
135
|
-
manifestVersion: 1,
|
|
136
|
-
id: 'contract-hr',
|
|
137
|
-
name: 'Staff leave app',
|
|
138
|
-
scopes: ['employeeAbsences.basic:read', 'employeeAbsences.hr:read'],
|
|
139
|
-
data: {
|
|
140
|
-
employeeAbsences: {
|
|
141
|
-
required: [],
|
|
142
|
-
optional: [
|
|
143
|
-
'staffId',
|
|
144
|
-
'startAt',
|
|
145
|
-
'endAt',
|
|
146
|
-
'absenceType',
|
|
147
|
-
'illnessCategory',
|
|
148
|
-
'workingDays',
|
|
149
|
-
'hours',
|
|
150
|
-
'note',
|
|
151
|
-
],
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
reasons: {
|
|
155
|
-
'employeeAbsences.hr:read': 'To roster relief staff and report on leave taken across the year.',
|
|
156
|
-
},
|
|
157
|
-
notifications: ['test.message'],
|
|
158
|
-
},
|
|
159
|
-
schema: TEST_SCHEMA,
|
|
160
|
-
};
|
|
161
|
-
/** A first-aid and learning support app: it holds the medical tier too, so it receives diagnoses (S4.4). */
|
|
162
|
-
export const WELLBEING_APP = {
|
|
163
|
-
manifest: {
|
|
164
|
-
...TEST_APP.manifest,
|
|
165
|
-
id: 'contract-wellbeing',
|
|
166
|
-
name: 'Wellbeing app',
|
|
167
|
-
scopes: [
|
|
168
|
-
'learningSupportNeeds.basic:read',
|
|
169
|
-
'learningSupportNeeds.pastoral:read',
|
|
170
|
-
'learningSupportNeeds.medical:read',
|
|
171
|
-
'medicalEvents.basic:read',
|
|
172
|
-
'medicalEvents.medical:read',
|
|
173
|
-
'medicalNotes.basic:read',
|
|
174
|
-
'medicalNotes.medical:read',
|
|
175
|
-
],
|
|
176
|
-
notifications: ['test.message'],
|
|
177
|
-
},
|
|
178
|
-
schema: TEST_SCHEMA,
|
|
179
|
-
};
|
|
180
|
-
// ---- Accounts and guests (V2c, D100) ----
|
|
181
|
-
/** The account directory the contract suite's engines are given: who exists and which app roles they hold. */
|
|
182
|
-
export const TEST_ACCOUNTS = [
|
|
183
|
-
{ id: 'acc-ada', displayName: 'Ada Teacher', roles: ['Teacher'] },
|
|
184
|
-
{ id: 'acc-ben', displayName: 'Ben Both', roles: ['Teacher', 'Student'] },
|
|
185
|
-
{ id: 'acc-cai', displayName: 'Cai Student', roles: ['Student'] },
|
|
186
|
-
{ id: 'acc-dee', displayName: 'Dee Student', roles: ['Student'] },
|
|
187
|
-
{ id: 'acc-eve', displayName: 'Eve Staff', roles: ['Staff'] },
|
|
188
|
-
{ id: 'acc-gus', displayName: 'Gus Staff', roles: ['Staff'] },
|
|
189
|
-
];
|
|
190
|
-
const ACCOUNT_SCHEMA = defineSchema({
|
|
191
|
-
note: entity({
|
|
192
|
-
fields: { body: text(), score: number({ optional: true }) },
|
|
193
|
-
indexes: [['score']],
|
|
194
|
-
// The keys are written in different cases on purpose: they match the app's roles ignoring case.
|
|
195
|
-
access: {
|
|
196
|
-
teacher: { read: 'all', create: 'all', update: 'all', delete: 'all' },
|
|
197
|
-
Student: { read: 'own', create: 'own', update: 'own', delete: 'own' },
|
|
198
|
-
guest: { read: 'own', create: 'own' },
|
|
199
|
-
},
|
|
200
|
-
}),
|
|
201
|
-
});
|
|
202
|
-
/** Records who it ran as, so a test can see the run-as principal of a job an account scheduled. */
|
|
203
|
-
const remind = defineJob({
|
|
204
|
-
name: 'remind',
|
|
205
|
-
async run({ sdk, runId }) {
|
|
206
|
-
const me = await sdk.auth.me();
|
|
207
|
-
await sdk.db
|
|
208
|
-
.entity('note')
|
|
209
|
-
.create({ body: JSON.stringify(me) }, { idempotencyKey: `remind:${runId}` });
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
|
-
/**
|
|
213
|
-
* A standalone app (version 1) with two app roles and guests (V2c). It reads no school data, so everything under
|
|
214
|
-
* `sdk.school` is NOT_AVAILABLE for it, whoever is asking.
|
|
215
|
-
*/
|
|
216
|
-
export const ACCOUNT_APP = {
|
|
217
|
-
manifest: {
|
|
218
|
-
manifestVersion: 1,
|
|
219
|
-
id: 'contract-accounts',
|
|
220
|
-
name: 'Accounts app',
|
|
221
|
-
sdk: '^0.2.0',
|
|
222
|
-
kit: 'react-ui',
|
|
223
|
-
roles: ['Teacher', 'Student'],
|
|
224
|
-
schoolRoles: [],
|
|
225
|
-
guests: true,
|
|
226
|
-
scopes: [],
|
|
227
|
-
data: {},
|
|
228
|
-
notifications: ['test.message'],
|
|
229
|
-
tasks: ['test.review'],
|
|
230
|
-
scheduled: ['remind'],
|
|
231
|
-
cron: [],
|
|
232
|
-
},
|
|
233
|
-
schema: ACCOUNT_SCHEMA,
|
|
234
|
-
jobs: [remind],
|
|
235
|
-
};
|
|
236
77
|
/** A test app with only `students.basic:read`. */
|
|
237
78
|
export const BASIC_APP = {
|
|
238
79
|
manifest: {
|
|
@@ -245,25 +86,7 @@ export const BASIC_APP = {
|
|
|
245
86
|
schema: TEST_SCHEMA,
|
|
246
87
|
};
|
|
247
88
|
/**
|
|
248
|
-
*
|
|
249
|
-
* and nothing else that varies. The core fields (studentNumber, givenName, familyName) come with the
|
|
250
|
-
* entity. Its scopes are exactly the tiers those fields need.
|
|
251
|
-
*/
|
|
252
|
-
export const DATA_APP = {
|
|
253
|
-
manifest: {
|
|
254
|
-
...TEST_APP.manifest,
|
|
255
|
-
manifestVersion: 1,
|
|
256
|
-
id: 'contract-data',
|
|
257
|
-
name: 'Declared fields app',
|
|
258
|
-
scopes: ['students.basic:read', 'students.contact:read'],
|
|
259
|
-
data: { students: { required: ['dateOfBirth'], optional: ['email'] } },
|
|
260
|
-
reasons: { 'students.contact:read': 'To show each student’s birthday in the contract tests.' },
|
|
261
|
-
notifications: ['test.message'],
|
|
262
|
-
},
|
|
263
|
-
schema: TEST_SCHEMA,
|
|
264
|
-
};
|
|
265
|
-
/**
|
|
266
|
-
* A standalone app (V2s D84): version 1, two app-defined roles named like school roles, so the matching
|
|
89
|
+
* An app (V2s D84) with version 1, two app-defined roles named like school roles, so the matching
|
|
267
90
|
* personas can preview them. The access keys are written in different cases on purpose.
|
|
268
91
|
*/
|
|
269
92
|
export const ROLES_SCHEMA = defineSchema({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
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';
|
|
@@ -7,5 +7,5 @@ type SliceBControl = Pick<ContractEnv['control'], 'advanceClock' | 'runDueJobs'
|
|
|
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.
|
|
9
9
|
*/
|
|
10
|
-
export declare function sliceBControls(engine: () => Engine, app: () => TestApp, connect: (principal:
|
|
10
|
+
export declare function sliceBControls(engine: () => Engine, app: () => TestApp, connect: (principal: Principal) => Promise<QuadSdk>, onClock?: () => Promise<void>): SliceBControl;
|
|
11
11
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { defineContractSuite } from './suite.ts';
|
|
2
|
-
export type { ContractEnv, ContractFactory,
|
|
2
|
+
export type { ContractEnv, ContractFactory, TestApp } from './suite.ts';
|
|
3
3
|
export { sliceBControls } from './harness.ts';
|
|
4
|
-
export {
|
|
5
|
-
export { ACCESS_APP, ACCOUNT_APP, AWARDS_APP, BASIC_APP, DEMOGRAPHICS_APP, HR_APP, JOBS_APP, TEST_APP, TEST_ACCOUNTS, WELLBEING_APP, slowGate, } from './apps.ts';
|
|
4
|
+
export { ACCESS_APP, BASIC_APP, JOBS_APP, TEST_APP, MEDICAL_APP, slowGate } from './apps.ts';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { defineContractSuite } from "./suite.js";
|
|
2
2
|
export { sliceBControls } from "./harness.js";
|
|
3
|
-
export {
|
|
4
|
-
export { ACCESS_APP, ACCOUNT_APP, AWARDS_APP, BASIC_APP, DEMOGRAPHICS_APP, HR_APP, JOBS_APP, TEST_APP, TEST_ACCOUNTS, WELLBEING_APP, slowGate, } from "./apps.js";
|
|
3
|
+
export { ACCESS_APP, BASIC_APP, JOBS_APP, TEST_APP, MEDICAL_APP, slowGate } from "./apps.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Principal } from '@quad-education/canonical';
|
|
2
2
|
import type { AppSchema, Manifest } from '@quad-education/schema';
|
|
3
3
|
import type { OutboxEntry } from '../src/platform-types.ts';
|
|
4
4
|
import type { Job } from '../src/jobs/index.ts';
|
|
@@ -19,7 +19,7 @@ export type RunSummary = {
|
|
|
19
19
|
/** One running implementation of the SDK contract, loaded with the fictional school. */
|
|
20
20
|
export type ContractEnv = {
|
|
21
21
|
/** An SDK connected as `principal`. Every connection shares the same engine and storage. */
|
|
22
|
-
connect(principal:
|
|
22
|
+
connect(principal: Principal): Promise<any>;
|
|
23
23
|
control: {
|
|
24
24
|
/** Freeze the engine clock at an instant, or `null` for real time. */
|
|
25
25
|
setClock(iso: string | null): Promise<void>;
|
|
@@ -54,11 +54,4 @@ export type ContractEnv = {
|
|
|
54
54
|
dispose(): Promise<void>;
|
|
55
55
|
};
|
|
56
56
|
export type ContractFactory = (app: TestApp) => Promise<ContractEnv>;
|
|
57
|
-
|
|
58
|
-
* What the implementation under test has. The data API holds no school (non-negotiable 13), so it passes
|
|
59
|
-
* `school: false`: the sections that use school personas and school data are skipped, and the standalone ones run.
|
|
60
|
-
*/
|
|
61
|
-
export type ContractOptions = {
|
|
62
|
-
school?: boolean;
|
|
63
|
-
};
|
|
64
|
-
export declare function defineContractSuite(name: string, factory: ContractFactory, options?: ContractOptions): void;
|
|
57
|
+
export declare function defineContractSuite(name: string, factory: ContractFactory): void;
|