@thejob/schema 1.0.27 → 1.0.29

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.
Files changed (55) hide show
  1. package/dist/cjs/common/common.schema.d.ts.map +1 -1
  2. package/dist/cjs/interfaces.index.d.ts +144 -77
  3. package/dist/cjs/interfaces.index.d.ts.map +1 -1
  4. package/dist/cjs/job/job.schema.d.ts +35 -8
  5. package/dist/cjs/job/job.schema.d.ts.map +1 -1
  6. package/dist/cjs/job/job.schema.js +3 -1
  7. package/dist/cjs/job/utils.d.ts +3 -2
  8. package/dist/cjs/job/utils.d.ts.map +1 -1
  9. package/dist/cjs/job-application/job-application.schema.d.ts +29 -9
  10. package/dist/cjs/job-application/job-application.schema.d.ts.map +1 -1
  11. package/dist/cjs/job-application/job-application.schema.js +54 -52
  12. package/dist/cjs/job-role-template/job-role-template.schema.d.ts +35 -8
  13. package/dist/cjs/job-role-template/job-role-template.schema.d.ts.map +1 -1
  14. package/dist/cjs/page/page-location/page-location.schema.d.ts.map +1 -1
  15. package/dist/cjs/question/choice-question.schema.d.ts +47 -3
  16. package/dist/cjs/question/choice-question.schema.d.ts.map +1 -1
  17. package/dist/cjs/question/choice-question.schema.js +38 -4
  18. package/dist/cjs/question/input-question.schema.d.ts +25 -3
  19. package/dist/cjs/question/input-question.schema.d.ts.map +1 -1
  20. package/dist/cjs/question/input-question.schema.js +15 -2
  21. package/dist/cjs/question/question.schema.d.ts +2 -17
  22. package/dist/cjs/question/question.schema.d.ts.map +1 -1
  23. package/dist/cjs/question/question.schema.js +8 -11
  24. package/dist/cjs/question/read-and-acknowledge.schema.d.ts +28 -3
  25. package/dist/cjs/question/read-and-acknowledge.schema.d.ts.map +1 -1
  26. package/dist/cjs/question/read-and-acknowledge.schema.js +13 -6
  27. package/dist/esm/common/common.schema.d.ts.map +1 -1
  28. package/dist/esm/common/common.schema.js +1 -1
  29. package/dist/esm/interfaces.index.d.ts +144 -77
  30. package/dist/esm/interfaces.index.d.ts.map +1 -1
  31. package/dist/esm/job/job.schema.d.ts +35 -8
  32. package/dist/esm/job/job.schema.d.ts.map +1 -1
  33. package/dist/esm/job/job.schema.js +3 -1
  34. package/dist/esm/job/utils.d.ts +3 -2
  35. package/dist/esm/job/utils.d.ts.map +1 -1
  36. package/dist/esm/job-application/job-application.schema.d.ts +29 -9
  37. package/dist/esm/job-application/job-application.schema.d.ts.map +1 -1
  38. package/dist/esm/job-application/job-application.schema.js +56 -54
  39. package/dist/esm/job-role-template/job-role-template.schema.d.ts +35 -8
  40. package/dist/esm/job-role-template/job-role-template.schema.d.ts.map +1 -1
  41. package/dist/esm/page/page-location/page-location.schema.d.ts.map +1 -1
  42. package/dist/esm/page/page-location/page-location.schema.js +1 -1
  43. package/dist/esm/question/choice-question.schema.d.ts +47 -3
  44. package/dist/esm/question/choice-question.schema.d.ts.map +1 -1
  45. package/dist/esm/question/choice-question.schema.js +40 -6
  46. package/dist/esm/question/input-question.schema.d.ts +25 -3
  47. package/dist/esm/question/input-question.schema.d.ts.map +1 -1
  48. package/dist/esm/question/input-question.schema.js +15 -2
  49. package/dist/esm/question/question.schema.d.ts +2 -17
  50. package/dist/esm/question/question.schema.d.ts.map +1 -1
  51. package/dist/esm/question/question.schema.js +10 -13
  52. package/dist/esm/question/read-and-acknowledge.schema.d.ts +28 -3
  53. package/dist/esm/question/read-and-acknowledge.schema.d.ts.map +1 -1
  54. package/dist/esm/question/read-and-acknowledge.schema.js +13 -6
  55. package/package.json +1 -1
@@ -5,7 +5,6 @@ const common_1 = require("../common");
5
5
  const utils_1 = require("../job/utils");
6
6
  const location_1 = require("../location");
7
7
  const phone_1 = require("../phone");
8
- const question_1 = require("../question");
9
8
  const resume_1 = require("../resume");
10
9
  const user_1 = require("../user");
11
10
  const yup_extended_1 = require("../yup-extended");
@@ -41,57 +40,60 @@ exports.JobApplicationSchema = (0, yup_extended_1.object)()
41
40
  .default(job_application_constant_1.JobApplicationStatus.Open)
42
41
  .label("Status"),
43
42
  questionnaire: (0, yup_extended_1.array)().of((0, yup_extended_1.lazy)((question) => {
44
- const StringSchema = (0, yup_extended_1.string)().max(500);
45
- return (0, utils_1.getSchemaByQuestion)(question.type).concat((0, yup_extended_1.object)().shape({
46
- answers: (0, yup_extended_1.mixed)().when("type", {
47
- is: (type) => type === question_1.QuestionType.Input,
48
- then: () => (0, yup_extended_1.lazy)(() => {
49
- if (question.isOptional) {
50
- return StringSchema.optional().label("Answer");
51
- }
52
- else {
53
- return StringSchema.required().label("Answer");
54
- }
55
- }),
56
- otherwise: () => (0, yup_extended_1.lazy)(() => {
57
- const commonSchema = (0, yup_extended_1.mixed)().oneOfSchema([
58
- StringSchema,
59
- common_1.NameIdLogoSchema,
60
- common_1.OtherValueSchema,
61
- ]);
62
- if (question.answerChoiceType === question_1.AnswerChoiceType.Multiple) {
63
- return (0, yup_extended_1.lazy)(() => {
64
- const subCommonSchema = (0, yup_extended_1.array)().of(commonSchema);
65
- if (question.isOptional) {
66
- return subCommonSchema
67
- .optional()
68
- .default([])
69
- .label("Answer");
70
- }
71
- else {
72
- return subCommonSchema
73
- .default([])
74
- .min(1, "Select at least 1 option")
75
- .required("Select at least 1 option")
76
- .label("Answer");
77
- }
78
- });
79
- }
80
- else {
81
- return (0, yup_extended_1.lazy)(() => {
82
- if (question.isOptional) {
83
- return commonSchema.optional().label("Answer");
84
- }
85
- else {
86
- return commonSchema
87
- .required("Select an option")
88
- .label("Answer");
89
- }
90
- });
91
- }
92
- }),
93
- }),
94
- }));
43
+ // const StringSchema = string().max(500);
44
+ return (0, utils_1.getSchemaByQuestion)(question.type);
45
+ // .concat(
46
+ // object().shape({
47
+ // answers: mixed<
48
+ // string | TNameIdLogoSchema | TOtherValueSchema
49
+ // >().when("type", {
50
+ // is: (type: QuestionType) => type === QuestionType.Input,
51
+ // then: () =>
52
+ // lazy(() => {
53
+ // if (question.isOptional) {
54
+ // return StringSchema.optional().label("Answer");
55
+ // } else {
56
+ // return StringSchema.required().label("Answer");
57
+ // }
58
+ // }),
59
+ // otherwise: () =>
60
+ // lazy(() => {
61
+ // const commonSchema = mixed().oneOfSchema([
62
+ // StringSchema,
63
+ // NameIdLogoSchema,
64
+ // OtherValueSchema,
65
+ // ]);
66
+ // if (question.answerChoiceType === AnswerChoiceType.Multiple) {
67
+ // return lazy(() => {
68
+ // const subCommonSchema = array().of(commonSchema);
69
+ // if (question.isOptional) {
70
+ // return subCommonSchema
71
+ // .optional()
72
+ // .default([])
73
+ // .label("Answer");
74
+ // } else {
75
+ // return subCommonSchema
76
+ // .default([])
77
+ // .min(1, "Select at least 1 option")
78
+ // .required("Select at least 1 option")
79
+ // .label("Answer");
80
+ // }
81
+ // });
82
+ // } else {
83
+ // return lazy(() => {
84
+ // if (question.isOptional) {
85
+ // return commonSchema.optional().label("Answer");
86
+ // } else {
87
+ // return commonSchema
88
+ // .required("Select an option")
89
+ // .label("Answer");
90
+ // }
91
+ // });
92
+ // }
93
+ // }),
94
+ // }),
95
+ // })
96
+ // );
95
97
  })),
96
98
  history: (0, yup_extended_1.array)()
97
99
  .of((0, yup_extended_1.object)().shape({
@@ -20,16 +20,32 @@ export declare const JobRoleTemplateSchema: import("yup").ObjectSchema<{
20
20
  otherValue: string | string[];
21
21
  } | undefined>;
22
22
  tags: any[] | undefined;
23
- questionnaire: {
24
- description?: string | undefined;
23
+ questionnaire: ({
25
24
  label?: string | undefined;
26
25
  isNew?: boolean | undefined;
27
26
  isOptional?: boolean | undefined;
28
27
  readonly?: boolean | undefined;
29
- preferredAnswer?: import("..").TMixedValue | undefined;
30
- optionsFrom?: string | undefined;
31
- answers?: import("..").TMixedValue | undefined;
32
- type: NonNullable<import("..").QuestionType | undefined>;
28
+ preferredAnswer?: string | undefined;
29
+ answers?: string | undefined;
30
+ type: import("..").QuestionType.Input;
31
+ default: boolean;
32
+ title: string;
33
+ } | {
34
+ label?: string | undefined;
35
+ isNew?: boolean | undefined;
36
+ isOptional?: boolean | undefined;
37
+ readonly?: boolean | undefined;
38
+ preferredAnswer?: import("..").TMixedValue | import("..").TMixedValue[] | undefined;
39
+ answers?: import("..").TMixedValue | (string | number | boolean | {
40
+ logo?: string | undefined;
41
+ name: string;
42
+ id: string;
43
+ } | {
44
+ value: "others" | (string | undefined)[];
45
+ otherValue: string | string[];
46
+ } | undefined)[] | undefined;
47
+ optionsFrom?: import("..").Common.EducationLevel | import("..").Common.ExperienceLevel | import("..").Common.Skill | undefined;
48
+ type: import("..").QuestionType.Choice;
33
49
  default: boolean;
34
50
  title: string;
35
51
  options: (string | {
@@ -39,9 +55,20 @@ export declare const JobRoleTemplateSchema: import("yup").ObjectSchema<{
39
55
  } | {
40
56
  value: "others" | (string | undefined)[];
41
57
  otherValue: string | string[];
42
- })[];
58
+ } | undefined)[];
43
59
  answerChoiceType: NonNullable<import("..").AnswerChoiceType | undefined>;
44
- }[] | undefined;
60
+ } | {
61
+ label?: string | undefined;
62
+ isNew?: boolean | undefined;
63
+ isOptional?: boolean | undefined;
64
+ readonly?: boolean | undefined;
65
+ type: import("..").QuestionType.ReadAndAcknowledge;
66
+ default: boolean;
67
+ description: string;
68
+ title: string;
69
+ preferredAnswer: NonNullable<import("..").Common.Yes | import("..").Common.No | undefined>;
70
+ answers: NonNullable<import("..").Common.Yes | import("..").Common.No | undefined>;
71
+ })[] | undefined;
45
72
  }, import("yup").AnyObject, {
46
73
  headline: undefined;
47
74
  slug: undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"job-role-template.schema.d.ts","sourceRoot":"","sources":["../../../src/job-role-template/job-role-template.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAQhC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,SAAS,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
1
+ {"version":3,"file":"job-role-template.schema.d.ts","sourceRoot":"","sources":["../../../src/job-role-template/job-role-template.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAQhC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,SAAS,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"page-location.schema.d.ts","sourceRoot":"","sources":["../../../../src/page/page-location/page-location.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,SAAS,EAAW,MAAM,oBAAoB,CAAC;AAExE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;MAgBD,CAAC;AAE/B,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"file":"page-location.schema.d.ts","sourceRoot":"","sources":["../../../../src/page/page-location/page-location.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA2B,MAAM,oBAAoB,CAAC;AAExE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;MAgBD,CAAC;AAE/B,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -1,5 +1,49 @@
1
- import { InferType, ObjectSchema } from "../yup-extended";
2
- import { TQuestionSchema } from "./question.schema";
3
- export declare const ChoiceQuestionSchema: ObjectSchema<TQuestionSchema>;
1
+ import { Common } from "../common";
2
+ import { InferType } from "../yup-extended";
3
+ import { AnswerChoiceType, QuestionType } from "./question.constant";
4
+ import { TMixedValue } from "./question.schema";
5
+ export declare const ChoiceQuestionSchema: import("yup").ObjectSchema<{
6
+ label: string | undefined;
7
+ default: boolean;
8
+ title: string;
9
+ type: QuestionType.Choice;
10
+ isOptional: boolean | undefined;
11
+ readonly: boolean | undefined;
12
+ isNew: boolean | undefined;
13
+ } & {
14
+ type: QuestionType.Choice;
15
+ optionsFrom: Common.EducationLevel | Common.ExperienceLevel | Common.Skill | undefined;
16
+ options: (string | {
17
+ logo?: string | undefined;
18
+ name: string;
19
+ id: string;
20
+ } | {
21
+ value: "others" | (string | undefined)[];
22
+ otherValue: string | string[];
23
+ } | undefined)[];
24
+ answerChoiceType: NonNullable<AnswerChoiceType | undefined>;
25
+ preferredAnswer: TMixedValue | TMixedValue[] | undefined;
26
+ answers: TMixedValue | (string | number | boolean | {
27
+ logo?: string | undefined;
28
+ name: string;
29
+ id: string;
30
+ } | {
31
+ value: "others" | (string | undefined)[];
32
+ otherValue: string | string[];
33
+ } | undefined)[] | undefined;
34
+ }, import("yup").AnyObject, {
35
+ label: undefined;
36
+ default: false;
37
+ title: undefined;
38
+ type: undefined;
39
+ isOptional: undefined;
40
+ readonly: undefined;
41
+ isNew: undefined;
42
+ optionsFrom: undefined;
43
+ options: "";
44
+ answerChoiceType: AnswerChoiceType.Single;
45
+ preferredAnswer: undefined;
46
+ answers: undefined;
47
+ }, "">;
4
48
  export type TChoiceQuestionSchema = InferType<typeof ChoiceQuestionSchema>;
5
49
  //# sourceMappingURL=choice-question.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"choice-question.schema.d.ts","sourceRoot":"","sources":["../../../src/question/choice-question.schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,SAAS,EAIT,YAAY,EAEb,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EAAkB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAiGpE,eAAO,MAAM,oBAAoB,EAAI,YAAY,CAAC,eAAe,CA+BhE,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,SAAS,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
1
+ {"version":3,"file":"choice-question.schema.d.ts","sourceRoot":"","sources":["../../../src/question/choice-question.schema.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAKP,MAAM,WAAW,CAAC;AACnB,OAAO,EAAS,SAAS,EAA+B,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,gBAAgB,EAChB,YAAY,EAEb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA6HhE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkChC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,SAAS,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -79,12 +79,41 @@ const ChoicePreferredAnswerSchema = (label = "Preferred answer") => (0, yup_exte
79
79
  .optional()
80
80
  .label(label),
81
81
  });
82
- exports.ChoiceQuestionSchema = (question_schema_1.QuestionSchema.concat((0, yup_extended_1.object)().shape({
82
+ const ChoiceAnswerSchema = (0, yup_extended_1.lazy)((question) => {
83
+ const commonSchema = (0, yup_extended_1.mixed)().oneOfSchema([
84
+ // Note: this can be string, boolean, number, or other complex types
85
+ (0, yup_extended_1.string)().max(500),
86
+ common_1.NameIdLogoSchema,
87
+ common_1.OtherValueSchema,
88
+ ]);
89
+ if (question.answerChoiceType === question_constant_1.AnswerChoiceType.Multiple) {
90
+ const multiAnswerSchema = (0, yup_extended_1.array)().of(commonSchema);
91
+ if (question.isOptional) {
92
+ return multiAnswerSchema.optional().default([]);
93
+ }
94
+ else {
95
+ return multiAnswerSchema
96
+ .min(1, "Select at least one option.")
97
+ .required("Select at least one option.")
98
+ .default([]);
99
+ }
100
+ }
101
+ else {
102
+ // Single choice
103
+ if (question.isOptional) {
104
+ return commonSchema.optional();
105
+ }
106
+ else {
107
+ return commonSchema.required("Select an option.");
108
+ }
109
+ }
110
+ });
111
+ exports.ChoiceQuestionSchema = question_schema_1.QuestionSchema.concat((0, yup_extended_1.object)().shape({
83
112
  type: (0, yup_extended_1.string)()
84
113
  .oneOf([question_constant_1.QuestionType.Choice])
85
114
  .required()
86
115
  .label("Question type"),
87
- optionsFrom: (0, yup_extended_1.mixed)()
116
+ optionsFrom: (0, yup_extended_1.string)()
88
117
  .oneOf([common_1.Common.Skill, common_1.Common.EducationLevel, common_1.Common.ExperienceLevel])
89
118
  .optional()
90
119
  .label("Option field"),
@@ -94,7 +123,10 @@ exports.ChoiceQuestionSchema = (question_schema_1.QuestionSchema.concat((0, yup_
94
123
  return (0, yup_extended_1.string)();
95
124
  }
96
125
  else {
97
- return (0, yup_extended_1.mixed)().oneOfSchema([common_1.NameIdLogoSchema, common_1.OtherValueSchema]);
126
+ return (0, yup_extended_1.mixed)().oneOfSchema([
127
+ common_1.NameIdLogoSchema,
128
+ common_1.OtherValueSchema,
129
+ ]);
98
130
  }
99
131
  }))
100
132
  .min(1)
@@ -103,6 +135,8 @@ exports.ChoiceQuestionSchema = (question_schema_1.QuestionSchema.concat((0, yup_
103
135
  answerChoiceType: (0, yup_extended_1.string)()
104
136
  .oneOf(question_constant_1.SupportedAnswerChoiceTypes)
105
137
  .required()
138
+ .default(question_constant_1.AnswerChoiceType.Single)
106
139
  .label("Type"),
107
140
  preferredAnswer: ChoicePreferredAnswerSchema("Preferred answer"),
108
- })));
141
+ answers: ChoiceAnswerSchema,
142
+ }));
@@ -1,5 +1,27 @@
1
1
  import { InferType, ObjectSchema } from "../yup-extended";
2
- import { TQuestionSchema } from "./question.schema";
3
- export declare const InputQuestionSchema: ObjectSchema<TQuestionSchema>;
4
- export type TInputQuestionSchema = Omit<InferType<typeof InputQuestionSchema>, "options">;
2
+ import { QuestionType } from "./question.constant";
3
+ export declare const InputQuestionSchema: ObjectSchema<{
4
+ label: string | undefined;
5
+ default: boolean;
6
+ title: string;
7
+ type: QuestionType.Input;
8
+ isOptional: boolean | undefined;
9
+ readonly: boolean | undefined;
10
+ isNew: boolean | undefined;
11
+ } & {
12
+ type: QuestionType.Input;
13
+ preferredAnswer: string | undefined;
14
+ answers: string | undefined;
15
+ }, import("yup").AnyObject, {
16
+ label: undefined;
17
+ default: false;
18
+ title: undefined;
19
+ type: undefined;
20
+ isOptional: undefined;
21
+ readonly: undefined;
22
+ isNew: undefined;
23
+ preferredAnswer: undefined;
24
+ answers: undefined;
25
+ }, "">;
26
+ export type TInputQuestionSchema = InferType<typeof InputQuestionSchema>;
5
27
  //# sourceMappingURL=input-question.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"input-question.schema.d.ts","sourceRoot":"","sources":["../../../src/question/input-question.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,YAAY,EAAU,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAkB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpE,eAAO,MAAM,mBAAmB,EAAI,YAAY,CAAC,eAAe,CAM/D,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,SAAS,CAAC,OAAO,mBAAmB,CAAC,EACrC,SAAS,CACV,CAAC"}
1
+ {"version":3,"file":"input-question.schema.d.ts","sourceRoot":"","sources":["../../../src/question/input-question.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAU,YAAY,EAAU,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;MAe/B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,SAAS,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -1,8 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InputQuestionSchema = void 0;
4
+ // input-question.schema.ts
4
5
  const yup_extended_1 = require("../yup-extended");
5
6
  const question_schema_1 = require("./question.schema");
6
- exports.InputQuestionSchema = (question_schema_1.QuestionSchema.concat((0, yup_extended_1.object)().shape({
7
+ const question_constant_1 = require("./question.constant");
8
+ exports.InputQuestionSchema = question_schema_1.QuestionSchema.concat((0, yup_extended_1.object)().shape({
9
+ type: (0, yup_extended_1.string)()
10
+ .oneOf([question_constant_1.QuestionType.Input])
11
+ .required()
12
+ .label("Question type"),
7
13
  preferredAnswer: (0, yup_extended_1.string)().max(100).optional().label("Preferred Answer"),
8
- })));
14
+ answers: (0, yup_extended_1.string)()
15
+ .max(500)
16
+ .when("isOptional", {
17
+ is: false,
18
+ then: (schema) => schema.required("This field is required."),
19
+ otherwise: (schema) => schema.optional(),
20
+ }),
21
+ }));
@@ -1,7 +1,6 @@
1
1
  import { TNameIdLogoSchema, TOtherValueSchema } from "../common";
2
2
  import { InferType } from "../yup-extended";
3
- import { AnswerChoiceType } from "./question.constant";
4
- export type TMixedValue = string | boolean | number | TNameIdLogoSchema | TOtherValueSchema | Array<string | boolean | number | TNameIdLogoSchema | TOtherValueSchema>;
3
+ export type TMixedValue = string | boolean | number | TNameIdLogoSchema | TOtherValueSchema;
5
4
  export declare const QuestionSchema: import("yup").ObjectSchema<{
6
5
  label: string | undefined;
7
6
  default: boolean;
@@ -9,12 +8,6 @@ export declare const QuestionSchema: import("yup").ObjectSchema<{
9
8
  type: NonNullable<import("./question.constant").QuestionType | undefined>;
10
9
  isOptional: boolean | undefined;
11
10
  readonly: boolean | undefined;
12
- preferredAnswer: TMixedValue | undefined;
13
- optionsFrom: string | undefined;
14
- options: ({} | undefined)[] | undefined;
15
- description: string | undefined;
16
- answers: TMixedValue | undefined;
17
- answerChoiceType: NonNullable<AnswerChoiceType | undefined>;
18
11
  isNew: boolean | undefined;
19
12
  }, import("yup").AnyObject, {
20
13
  label: undefined;
@@ -23,15 +16,7 @@ export declare const QuestionSchema: import("yup").ObjectSchema<{
23
16
  type: undefined;
24
17
  isOptional: undefined;
25
18
  readonly: undefined;
26
- preferredAnswer: undefined;
27
- optionsFrom: undefined;
28
- options: "";
29
- description: undefined;
30
- answers: undefined;
31
- answerChoiceType: AnswerChoiceType.Single;
32
19
  isNew: undefined;
33
20
  }, "">;
34
- export type TQuestionSchema = Omit<InferType<typeof QuestionSchema>, "options"> & {
35
- options: Array<TNameIdLogoSchema | TOtherValueSchema | string>;
36
- };
21
+ export type TQuestionSchema = Omit<InferType<typeof QuestionSchema>, "options">;
37
22
  //# sourceMappingURL=question.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"question.schema.d.ts","sourceRoot":"","sources":["../../../src/question/question.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAGL,SAAS,EAIV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAGjB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,OAAO,GACP,MAAM,GACN,iBAAiB,GACjB,iBAAiB,GACjB,KAAK,CAAC,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,iBAAiB,GAAG,iBAAiB,CAAC,CAAC;AAE7E,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAoBzB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,SAAS,CAAC,OAAO,cAAc,CAAC,EAChC,SAAS,CACV,GAAG;IACF,OAAO,EAAE,KAAK,CAAC,iBAAiB,GAAG,iBAAiB,GAAG,MAAM,CAAC,CAAC;CAEhE,CAAC"}
1
+ {"version":3,"file":"question.schema.d.ts","sourceRoot":"","sources":["../../../src/question/question.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAW,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AAGrE,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,OAAO,GACP,MAAM,GACN,iBAAiB,GACjB,iBAAiB,CAAC;AAEtB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;MAQzB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,cAAc,CAAC,EAAE,SAAS,CAAC,CAAC"}
@@ -10,16 +10,13 @@ exports.QuestionSchema = (0, yup_extended_1.object)().shape({
10
10
  type: (0, yup_extended_1.string)().oneOf(question_constant_1.SupportedQuestionTypes).required().label("Type"),
11
11
  isOptional: (0, yup_extended_1.boolean)().optional().label("Mark if the question is optional"),
12
12
  readonly: (0, yup_extended_1.boolean)().optional().label("Readonly"),
13
- preferredAnswer: (0, yup_extended_1.mixed)().optional().label("Preferred Answer"),
14
- optionsFrom: (0, yup_extended_1.string)().optional().label("Options From"),
15
- options: (0, yup_extended_1.array)().of((0, yup_extended_1.mixed)()).optional().label("Options"),
16
- description: (0, yup_extended_1.string)().optional().label("Content"),
17
- answers: (0, yup_extended_1.mixed)().optional().label("Answer"),
18
- answerChoiceType: (0, yup_extended_1.string)()
19
- .oneOf(question_constant_1.SupportedAnswerChoiceTypes)
20
- .required()
21
- .default(question_constant_1.AnswerChoiceType.Single)
22
- .label("Answer Choice Type"),
23
13
  isNew: (0, yup_extended_1.boolean)().optional().label("Is New"),
24
14
  });
25
- //ljlkj
15
+ // export type TQuestionnaire = (
16
+ // | TInputQuestionSchema
17
+ // | TChoiceQuestionSchema
18
+ // | TReadAndAcknowledgeQuestionSchema
19
+ // )[];
20
+ // Note: The TMixedValue and TQuestionSchema types might need adjustments
21
+ // depending on how you use them downstream, but this is the logical
22
+ // change for the schema itself.
@@ -1,5 +1,30 @@
1
- import { InferType, ObjectSchema } from "../yup-extended";
2
- import { TQuestionSchema } from "./question.schema";
3
- export declare const ReadAndAcknowledgeQuestionSchema: ObjectSchema<TQuestionSchema>;
1
+ import { Common } from "../common";
2
+ import { InferType } from "../yup-extended";
3
+ import { QuestionType } from "./question.constant";
4
+ export declare const ReadAndAcknowledgeQuestionSchema: import("yup").ObjectSchema<{
5
+ label: string | undefined;
6
+ default: boolean;
7
+ title: string;
8
+ type: QuestionType.ReadAndAcknowledge;
9
+ isOptional: boolean | undefined;
10
+ readonly: boolean | undefined;
11
+ isNew: boolean | undefined;
12
+ } & {
13
+ type: QuestionType.ReadAndAcknowledge;
14
+ description: string;
15
+ preferredAnswer: NonNullable<Common.Yes | Common.No | undefined>;
16
+ answers: NonNullable<Common.Yes | Common.No | undefined>;
17
+ }, import("yup").AnyObject, {
18
+ label: undefined;
19
+ default: false;
20
+ title: undefined;
21
+ type: undefined;
22
+ isOptional: undefined;
23
+ readonly: undefined;
24
+ isNew: undefined;
25
+ description: undefined;
26
+ preferredAnswer: undefined;
27
+ answers: undefined;
28
+ }, "">;
4
29
  export type TReadAndAcknowledgeQuestionSchema = InferType<typeof ReadAndAcknowledgeQuestionSchema>;
5
30
  //# sourceMappingURL=read-and-acknowledge.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-and-acknowledge.schema.d.ts","sourceRoot":"","sources":["../../../src/question/read-and-acknowledge.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAU,YAAY,EAAU,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAkB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpE,eAAO,MAAM,gCAAgC,EAAI,YAAY,CAAC,eAAe,CAU5E,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,OAAO,gCAAgC,CACxC,CAAC"}
1
+ {"version":3,"file":"read-and-acknowledge.schema.d.ts","sourceRoot":"","sources":["../../../src/question/read-and-acknowledge.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAOnD,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;MAU5C,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,OAAO,gCAAgC,CACxC,CAAC"}
@@ -1,13 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ReadAndAcknowledgeQuestionSchema = void 0;
4
+ // read-and-acknowledge-question.schema.ts
4
5
  const common_1 = require("../common");
5
6
  const yup_extended_1 = require("../yup-extended");
7
+ const question_constant_1 = require("./question.constant");
6
8
  const question_schema_1 = require("./question.schema");
7
- exports.ReadAndAcknowledgeQuestionSchema = (question_schema_1.QuestionSchema.concat((0, yup_extended_1.object)().shape({
8
- description: (0, yup_extended_1.string)().max(10000).required().label("Content"),
9
- preferredAnswer: (0, yup_extended_1.string)()
10
- .oneOf([common_1.Common.Yes, common_1.Common.No])
9
+ const AcknowledgeAnswerSchema = (0, yup_extended_1.string)()
10
+ .oneOf([common_1.Common.Yes, common_1.Common.No])
11
+ .required("This question must be acknowledged.");
12
+ exports.ReadAndAcknowledgeQuestionSchema = question_schema_1.QuestionSchema.concat((0, yup_extended_1.object)().shape({
13
+ type: (0, yup_extended_1.string)()
14
+ .oneOf([question_constant_1.QuestionType.ReadAndAcknowledge])
11
15
  .required()
12
- .label("Preferred Answer"),
13
- })));
16
+ .label("Question type"),
17
+ description: (0, yup_extended_1.string)().max(10000).required().label("Content"),
18
+ preferredAnswer: AcknowledgeAnswerSchema.label("Preferred Answer"),
19
+ answers: AcknowledgeAnswerSchema.label("Answer"),
20
+ }));
@@ -1 +1 @@
1
- {"version":3,"file":"common.schema.d.ts","sourceRoot":"","sources":["../../../src/common/common.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAQV,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,gBAAgB;;;;;;;;MAOlB,CAAC;AACZ,MAAM,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEnE,eAAO,MAAM,gBAAgB;;;;;;MAwBlB,CAAC;AACZ,MAAM,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEnE,eAAO,MAAM,uBAAuB;;;;MAIlC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,SAAS,CAC9C,OAAO,uBAAuB,CAC/B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;MAYjB,CAAC;AAEZ,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,eAAe,CAAC,CAAC;AAEjE,eAAO,MAAM,uBAAuB,GAAI,WAAU,MAAW;;;;;;;;MAKzD,CAAC;AAEL,MAAM,MAAM,wBAAwB,GAAG,SAAS,CAC9C,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAC3C,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;MAGnC,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,SAAS,CAC/C,OAAO,wBAAwB,CAChC,CAAC"}
1
+ {"version":3,"file":"common.schema.d.ts","sourceRoot":"","sources":["../../../src/common/common.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAKV,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,gBAAgB;;;;;;;;MAOlB,CAAC;AACZ,MAAM,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEnE,eAAO,MAAM,gBAAgB;;;;;;MAwBlB,CAAC;AACZ,MAAM,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEnE,eAAO,MAAM,uBAAuB;;;;MAIlC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,SAAS,CAC9C,OAAO,uBAAuB,CAC/B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;MAYjB,CAAC;AAEZ,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,eAAe,CAAC,CAAC;AAEjE,eAAO,MAAM,uBAAuB,GAAI,WAAU,MAAW;;;;;;;;MAKzD,CAAC;AAEL,MAAM,MAAM,wBAAwB,GAAG,SAAS,CAC9C,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAC3C,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;MAGnC,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,SAAS,CAC/C,OAAO,wBAAwB,CAChC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { object, string, array, boolean, lazy, number, } from "../yup-extended";
1
+ import { array, boolean, lazy, number, object, string, } from "../yup-extended";
2
2
  export const NameIdLogoSchema = object()
3
3
  .shape({
4
4
  id: string().objectId().required().label("Id"),