@purpleschool/student-works 0.0.17 → 0.0.19

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.
@@ -1,6 +1,7 @@
1
1
  export const PAGE_CONTROLLER = 'page' as const;
2
2
 
3
3
  export const PAGE_ROUTES = {
4
+ FIND_BY_CRITERIA: 'search',
4
5
  FIND_BY_UUID: (uuid: string) => `${uuid}`,
5
6
  GET_ALL: '',
6
7
  FIND_BY_ALIAS: (alias: string) => `${alias}`,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PAGE_ROUTES = exports.PAGE_CONTROLLER = void 0;
4
4
  exports.PAGE_CONTROLLER = 'page';
5
5
  exports.PAGE_ROUTES = {
6
+ FIND_BY_CRITERIA: 'search',
6
7
  FIND_BY_UUID: (uuid) => `${uuid}`,
7
8
  GET_ALL: '',
8
9
  FIND_BY_ALIAS: (alias) => `${alias}`,
@@ -9,7 +9,7 @@ var FindPageByAliasCommand;
9
9
  alias: true,
10
10
  });
11
11
  FindPageByAliasCommand.ResponseSchema = zod_1.z.object({
12
- data: zod_1.z.array(models_1.PageSchema),
12
+ data: zod_1.z.array(models_1.PageWithQuestionsSchema),
13
13
  });
14
14
  FindPageByAliasCommand.ResponseByAliasSchema = zod_1.z.object({
15
15
  data: models_1.PageSchema,
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindPageByCriteriaCommand = void 0;
4
+ const models_1 = require("../../models");
5
+ const zod_1 = require("zod");
6
+ const page_1 = require("../../constants/page");
7
+ var FindPageByCriteriaCommand;
8
+ (function (FindPageByCriteriaCommand) {
9
+ FindPageByCriteriaCommand.RequestQuerySchema = zod_1.z.object({
10
+ title: zod_1.z.string().optional(),
11
+ alias: zod_1.z.string().optional(),
12
+ type: zod_1.z.nativeEnum(page_1.PageType).optional(),
13
+ uuid: zod_1.z.string().uuid().optional(),
14
+ limit: zod_1.z.coerce.number().min(1).optional(),
15
+ offset: zod_1.z.coerce.number().min(0).default(0).optional(),
16
+ });
17
+ FindPageByCriteriaCommand.ResponseSchema = zod_1.z.object({
18
+ data: zod_1.z.array(models_1.PageWithQuestionsSchema),
19
+ totalPages: zod_1.z.number(),
20
+ page: zod_1.z.number(),
21
+ });
22
+ })(FindPageByCriteriaCommand || (exports.FindPageByCriteriaCommand = FindPageByCriteriaCommand = {}));
@@ -9,9 +9,9 @@ var FindPageCommand;
9
9
  uuid: true,
10
10
  });
11
11
  FindPageCommand.ResponseSchema = zod_1.z.object({
12
- data: zod_1.z.array(models_1.PageSchema),
12
+ data: zod_1.z.array(models_1.PageWithQuestionsSchema),
13
13
  });
14
14
  FindPageCommand.ResponseByUUIDSchema = zod_1.z.object({
15
- data: models_1.PageSchema,
15
+ data: models_1.PageWithQuestionsSchema,
16
16
  });
17
17
  })(FindPageCommand || (exports.FindPageCommand = FindPageCommand = {}));
@@ -21,4 +21,5 @@ __exportStar(require("./create-page.command"), exports);
21
21
  __exportStar(require("./delete-page.command"), exports);
22
22
  __exportStar(require("./find-page-by-alias.command"), exports);
23
23
  __exportStar(require("./find-page.command"), exports);
24
+ __exportStar(require("./find-page-by-criteria.command"), exports);
24
25
  __exportStar(require("./update-page.command"), exports);
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PageSchema = exports.PageMetadataSchema = exports.WriterDocumentTypePageMetadataSchema = exports.ToolPageMetadataSchema = void 0;
3
+ exports.PageWithQuestionsSchema = exports.PageSchema = exports.PageMetadataSchema = exports.WriterDocumentTypePageMetadataSchema = exports.ToolPageMetadataSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const constants_1 = require("../constants");
6
+ const page_question_schema_1 = require("./page-question.schema");
6
7
  exports.ToolPageMetadataSchema = zod_1.z.object({
7
8
  type: zod_1.z.literal(constants_1.PageType.TOOL),
8
9
  toolType: zod_1.z.string().min(3).max(16384),
@@ -28,3 +29,6 @@ exports.PageSchema = zod_1.z.object({
28
29
  createdAt: zod_1.z.date(),
29
30
  updatedAt: zod_1.z.date(),
30
31
  });
32
+ exports.PageWithQuestionsSchema = exports.PageSchema.extend({
33
+ questions: zod_1.z.array(page_question_schema_1.PageQuestionSchema),
34
+ });
@@ -1,4 +1,4 @@
1
- import { PageSchema } from '../../models';
1
+ import { PageSchema, PageWithQuestionsSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace FindPageByAliasCommand {
@@ -9,7 +9,7 @@ export namespace FindPageByAliasCommand {
9
9
  export type Request = z.infer<typeof RequestSchema>;
10
10
 
11
11
  export const ResponseSchema = z.object({
12
- data: z.array(PageSchema),
12
+ data: z.array(PageWithQuestionsSchema),
13
13
  });
14
14
 
15
15
  export type Response = z.infer<typeof ResponseSchema>;
@@ -0,0 +1,24 @@
1
+ import { PageWithQuestionsSchema } from '../../models';
2
+ import { z } from 'zod';
3
+ import { PageType } from '../../constants/page';
4
+
5
+ export namespace FindPageByCriteriaCommand {
6
+ export const RequestQuerySchema = z.object({
7
+ title: z.string().optional(),
8
+ alias: z.string().optional(),
9
+ type: z.nativeEnum(PageType).optional(),
10
+ uuid: z.string().uuid().optional(),
11
+ limit: z.coerce.number().min(1).optional(),
12
+ offset: z.coerce.number().min(0).default(0).optional(),
13
+ });
14
+
15
+ export type RequestQuery = z.infer<typeof RequestQuerySchema>;
16
+
17
+ export const ResponseSchema = z.object({
18
+ data: z.array(PageWithQuestionsSchema),
19
+ totalPages: z.number(),
20
+ page: z.number(),
21
+ });
22
+
23
+ export type Response = z.infer<typeof ResponseSchema>;
24
+ }
@@ -1,4 +1,4 @@
1
- import { PageSchema } from '../../models';
1
+ import { PageSchema, PageWithQuestionsSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace FindPageCommand {
@@ -9,13 +9,13 @@ export namespace FindPageCommand {
9
9
  export type Request = z.infer<typeof RequestSchema>;
10
10
 
11
11
  export const ResponseSchema = z.object({
12
- data: z.array(PageSchema),
12
+ data: z.array(PageWithQuestionsSchema),
13
13
  });
14
14
 
15
15
  export type Response = z.infer<typeof ResponseSchema>;
16
16
 
17
17
  export const ResponseByUUIDSchema = z.object({
18
- data: PageSchema,
18
+ data: PageWithQuestionsSchema,
19
19
  });
20
20
 
21
21
  export type ResponseByUUID = z.infer<typeof ResponseByUUIDSchema>;
@@ -5,4 +5,5 @@ export * from './create-page.command';
5
5
  export * from './delete-page.command';
6
6
  export * from './find-page-by-alias.command';
7
7
  export * from './find-page.command';
8
+ export * from './find-page-by-criteria.command';
8
9
  export * from './update-page.command';
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { PageType } from '../constants';
3
+ import { PageQuestionSchema } from './page-question.schema';
3
4
 
4
5
  export const ToolPageMetadataSchema = z.object({
5
6
  type: z.literal(PageType.TOOL),
@@ -29,3 +30,7 @@ export const PageSchema = z.object({
29
30
  createdAt: z.date(),
30
31
  updatedAt: z.date(),
31
32
  });
33
+
34
+ export const PageWithQuestionsSchema = PageSchema.extend({
35
+ questions: z.array(PageQuestionSchema),
36
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/student-works",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",