@studyportals/sp-connect-backend-contracts 1.0.0-beta.0 → 1.0.0-beta.1
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 +7 -4
- package/{contracts → dist/contracts}/config/routes.d.ts +0 -1
- package/{contracts → dist/contracts}/config/routes.js +0 -1
- package/{contracts → dist/contracts}/errors.d.ts +5 -8
- package/dist/contracts/errors.js +5 -0
- package/{contracts → dist/contracts}/index.d.ts +2 -5
- package/dist/contracts/index.js +4 -0
- package/dist/contracts/roles.d.ts +2 -0
- package/dist/contracts/roles.js +1 -0
- package/dist/modules/auth/contracts/cognito-pool.d.ts +4 -0
- package/dist/modules/auth/contracts/cognito-pool.js +1 -0
- package/{modules → dist/modules}/questions/contracts/question-rules.d.ts +0 -1
- package/{modules → dist/modules}/questions/contracts/question-rules.js +0 -1
- package/dist/modules/questions/contracts/submit-question.d.ts +11 -0
- package/dist/modules/questions/contracts/submit-question.js +1 -0
- package/{modules → dist/modules}/questions/domain/question-constraints.d.ts +0 -1
- package/{modules → dist/modules}/questions/domain/question-constraints.js +0 -1
- package/{modules → dist/modules}/questions/domain/question-error-codes.d.ts +0 -1
- package/{modules → dist/modules}/questions/domain/question-error-codes.js +0 -1
- package/package.json +8 -13
- package/contracts/errors.js +0 -16
- package/contracts/index.js +0 -7
- package/contracts/roles.d.ts +0 -9
- package/contracts/roles.js +0 -4
- package/modules/auth/contracts/cognito-pool.d.ts +0 -7
- package/modules/auth/contracts/cognito-pool.js +0 -6
- package/modules/questions/contracts/submit-question.d.ts +0 -12
- package/modules/questions/contracts/submit-question.js +0 -11
package/README.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# @studyportals/sp-connect-backend-contracts
|
|
2
2
|
|
|
3
|
-
Request and response
|
|
4
|
-
the backend repository so that clients and the service cannot drift apart.
|
|
5
|
-
|
|
3
|
+
Request and response types, error codes and business rules for the SP Connect API, published
|
|
4
|
+
from the backend repository so that clients and the service cannot drift apart. The package has
|
|
5
|
+
no runtime dependencies: it contains TypeScript types and constants only.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
QUESTION_TEXT_MAX_LENGTH,
|
|
10
|
+
QuestionErrorCode,
|
|
11
|
+
} from '@studyportals/sp-connect-backend-contracts';
|
|
9
12
|
import type { SubmitQuestionRequest } from '@studyportals/sp-connect-backend-contracts';
|
|
10
13
|
```
|
|
11
14
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
/** Error codes the API returns that no module owns; module codes live in each module's contracts. */
|
|
3
2
|
export declare const ErrorCode: {
|
|
4
3
|
readonly Internal: "internal_error";
|
|
@@ -9,10 +8,8 @@ export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
|
9
8
|
* `{ code, message, details? }` body of the API's own errors. Nest's built-in HTTP errors, such as
|
|
10
9
|
* a 401 from the auth guard, keep Nest's `{ statusCode, message, error }` body instead.
|
|
11
10
|
*/
|
|
12
|
-
export
|
|
13
|
-
code:
|
|
14
|
-
message:
|
|
15
|
-
details
|
|
16
|
-
}
|
|
17
|
-
export type ErrorResponse = z.infer<typeof ErrorResponseSchema>;
|
|
18
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
11
|
+
export interface ErrorResponse {
|
|
12
|
+
readonly code: string;
|
|
13
|
+
readonly message: string;
|
|
14
|
+
readonly details?: Record<string, string | number | boolean>;
|
|
15
|
+
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export { API_PREFIX, API_VERSION } from './config/routes.js';
|
|
2
|
-
export { ErrorCode
|
|
2
|
+
export { ErrorCode } from './errors.js';
|
|
3
3
|
export type { ErrorResponse } from './errors.js';
|
|
4
|
-
export { ROLES
|
|
4
|
+
export { ROLES } from './roles.js';
|
|
5
5
|
export type { Role } from './roles.js';
|
|
6
|
-
export { CognitoPoolResponseSchema } from '../modules/auth/contracts/cognito-pool.js';
|
|
7
6
|
export type { CognitoPoolResponse } from '../modules/auth/contracts/cognito-pool.js';
|
|
8
7
|
export { EXTERNAL_ID_MAX_LENGTH, EXTERNAL_ID_PATTERN, QUESTION_TEXT_MAX_LENGTH, QUESTION_TEXT_MIN_LENGTH, QuestionErrorCode, } from '../modules/questions/contracts/question-rules.js';
|
|
9
|
-
export { SubmitQuestionRequestSchema, SubmitQuestionResponseSchema, } from '../modules/questions/contracts/submit-question.js';
|
|
10
8
|
export type { SubmitQuestionRequest, SubmitQuestionResponse, } from '../modules/questions/contracts/submit-question.js';
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { API_PREFIX, API_VERSION } from './config/routes.js';
|
|
2
|
+
export { ErrorCode } from './errors.js';
|
|
3
|
+
export { ROLES } from './roles.js';
|
|
4
|
+
export { EXTERNAL_ID_MAX_LENGTH, EXTERNAL_ID_PATTERN, QUESTION_TEXT_MAX_LENGTH, QUESTION_TEXT_MIN_LENGTH, QuestionErrorCode, } from '../modules/questions/contracts/question-rules.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ROLES = ['student', 'expert', 'admin'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Public request and response shapes owned and published by the questions module. */
|
|
2
|
+
export interface SubmitQuestionRequest {
|
|
3
|
+
/** Up to `EXTERNAL_ID_MAX_LENGTH` characters matching `EXTERNAL_ID_PATTERN`. */
|
|
4
|
+
readonly programmeId: string;
|
|
5
|
+
/** `QUESTION_TEXT_MIN_LENGTH` to `QUESTION_TEXT_MAX_LENGTH` characters after trimming. */
|
|
6
|
+
readonly questionText: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SubmitQuestionResponse {
|
|
9
|
+
/** A UUID. */
|
|
10
|
+
readonly questionId: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studyportals/sp-connect-backend-contracts",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"description": "Public API contracts and business rules of the SP Connect backend.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
4
6
|
"type": "module",
|
|
5
7
|
"publishConfig": {
|
|
6
8
|
"access": "public"
|
|
7
9
|
},
|
|
8
10
|
"exports": {
|
|
9
11
|
".": {
|
|
10
|
-
"types": "./contracts/index.d.ts",
|
|
11
|
-
"import": "./contracts/index.js"
|
|
12
|
+
"types": "./dist/contracts/index.d.ts",
|
|
13
|
+
"import": "./dist/contracts/index.js"
|
|
12
14
|
}
|
|
13
15
|
},
|
|
14
16
|
"files": [
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"modules/**/*.js",
|
|
18
|
-
"modules/**/*.d.ts"
|
|
17
|
+
"dist",
|
|
18
|
+
"!dist/*.tgz"
|
|
19
19
|
],
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20"
|
|
23
|
-
}
|
|
24
|
-
"peerDependencies": {
|
|
25
|
-
"zod": "^4.0.0"
|
|
26
|
-
},
|
|
27
|
-
"description": "Public API contracts and business rules of the SP Connect backend.",
|
|
28
|
-
"license": "UNLICENSED"
|
|
23
|
+
}
|
|
29
24
|
}
|
package/contracts/errors.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/** Error codes the API returns that no module owns; module codes live in each module's contracts. */
|
|
3
|
-
export const ErrorCode = {
|
|
4
|
-
Internal: 'internal_error',
|
|
5
|
-
InvalidRequestBody: 'request.invalid_body',
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* `{ code, message, details? }` body of the API's own errors. Nest's built-in HTTP errors, such as
|
|
9
|
-
* a 401 from the auth guard, keep Nest's `{ statusCode, message, error }` body instead.
|
|
10
|
-
*/
|
|
11
|
-
export const ErrorResponseSchema = z.object({
|
|
12
|
-
code: z.string(),
|
|
13
|
-
message: z.string(),
|
|
14
|
-
details: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=errors.js.map
|
package/contracts/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { API_PREFIX, API_VERSION } from './config/routes.js';
|
|
2
|
-
export { ErrorCode, ErrorResponseSchema } from './errors.js';
|
|
3
|
-
export { ROLES, RoleSchema } from './roles.js';
|
|
4
|
-
export { CognitoPoolResponseSchema } from '../modules/auth/contracts/cognito-pool.js';
|
|
5
|
-
export { EXTERNAL_ID_MAX_LENGTH, EXTERNAL_ID_PATTERN, QUESTION_TEXT_MAX_LENGTH, QUESTION_TEXT_MIN_LENGTH, QuestionErrorCode, } from '../modules/questions/contracts/question-rules.js';
|
|
6
|
-
export { SubmitQuestionRequestSchema, SubmitQuestionResponseSchema, } from '../modules/questions/contracts/submit-question.js';
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/contracts/roles.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const ROLES: readonly ["student", "expert", "admin"];
|
|
3
|
-
export declare const RoleSchema: z.ZodEnum<{
|
|
4
|
-
student: "student";
|
|
5
|
-
expert: "expert";
|
|
6
|
-
admin: "admin";
|
|
7
|
-
}>;
|
|
8
|
-
export type Role = z.infer<typeof RoleSchema>;
|
|
9
|
-
//# sourceMappingURL=roles.d.ts.map
|
package/contracts/roles.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const CognitoPoolResponseSchema: z.ZodObject<{
|
|
3
|
-
userPoolId: z.ZodString;
|
|
4
|
-
userPoolClientId: z.ZodString;
|
|
5
|
-
}, z.core.$strip>;
|
|
6
|
-
export type CognitoPoolResponse = z.infer<typeof CognitoPoolResponseSchema>;
|
|
7
|
-
//# sourceMappingURL=cognito-pool.d.ts.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/** Public request and response shapes owned and published by the questions module. */
|
|
3
|
-
export declare const SubmitQuestionRequestSchema: z.ZodObject<{
|
|
4
|
-
programmeId: z.ZodString;
|
|
5
|
-
questionText: z.ZodString;
|
|
6
|
-
}, z.core.$strip>;
|
|
7
|
-
export type SubmitQuestionRequest = z.infer<typeof SubmitQuestionRequestSchema>;
|
|
8
|
-
export declare const SubmitQuestionResponseSchema: z.ZodObject<{
|
|
9
|
-
questionId: z.ZodUUID;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
export type SubmitQuestionResponse = z.infer<typeof SubmitQuestionResponseSchema>;
|
|
12
|
-
//# sourceMappingURL=submit-question.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { EXTERNAL_ID_MAX_LENGTH, EXTERNAL_ID_PATTERN, QUESTION_TEXT_MAX_LENGTH, QUESTION_TEXT_MIN_LENGTH, } from './question-rules.js';
|
|
3
|
-
/** Public request and response shapes owned and published by the questions module. */
|
|
4
|
-
export const SubmitQuestionRequestSchema = z.object({
|
|
5
|
-
programmeId: z.string().trim().min(1).max(EXTERNAL_ID_MAX_LENGTH).regex(EXTERNAL_ID_PATTERN),
|
|
6
|
-
questionText: z.string().trim().min(QUESTION_TEXT_MIN_LENGTH).max(QUESTION_TEXT_MAX_LENGTH),
|
|
7
|
-
});
|
|
8
|
-
export const SubmitQuestionResponseSchema = z.object({
|
|
9
|
-
questionId: z.uuid(),
|
|
10
|
-
});
|
|
11
|
-
//# sourceMappingURL=submit-question.js.map
|