@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
@@ -1,11 +1,10 @@
1
- import { DbDefaultSchema, NameIdLogoSchema, OtherValueSchema, SupportedExperienceLevels, } from "../common";
1
+ import { DbDefaultSchema, SupportedExperienceLevels, } from "../common";
2
2
  import { getSchemaByQuestion } from "../job/utils";
3
3
  import { LocationSchema } from "../location";
4
4
  import { MobileNumberSchema } from "../phone";
5
- import { AnswerChoiceType, QuestionType } from "../question";
6
5
  import { ResumeSchema } from "../resume";
7
6
  import { EducationSchema, WorkExperienceSchema, } from "../user";
8
- import { array, boolean, date, lazy, mixed, number, object, string, } from "../yup-extended";
7
+ import { array, boolean, date, lazy, number, object, string, } from "../yup-extended";
9
8
  import { JobApplicationStatus, SupportedJobApplicationScores, SupportedJobApplicationsStatuses, } from "./job-application.constant";
10
9
  export const JobApplicationSchema = object()
11
10
  .shape({
@@ -38,57 +37,60 @@ export const JobApplicationSchema = object()
38
37
  .default(JobApplicationStatus.Open)
39
38
  .label("Status"),
40
39
  questionnaire: array().of(lazy((question) => {
41
- const StringSchema = string().max(500);
42
- return getSchemaByQuestion(question.type).concat(object().shape({
43
- answers: mixed().when("type", {
44
- is: (type) => type === QuestionType.Input,
45
- then: () => lazy(() => {
46
- if (question.isOptional) {
47
- return StringSchema.optional().label("Answer");
48
- }
49
- else {
50
- return StringSchema.required().label("Answer");
51
- }
52
- }),
53
- otherwise: () => lazy(() => {
54
- const commonSchema = mixed().oneOfSchema([
55
- StringSchema,
56
- NameIdLogoSchema,
57
- OtherValueSchema,
58
- ]);
59
- if (question.answerChoiceType === AnswerChoiceType.Multiple) {
60
- return lazy(() => {
61
- const subCommonSchema = array().of(commonSchema);
62
- if (question.isOptional) {
63
- return subCommonSchema
64
- .optional()
65
- .default([])
66
- .label("Answer");
67
- }
68
- else {
69
- return subCommonSchema
70
- .default([])
71
- .min(1, "Select at least 1 option")
72
- .required("Select at least 1 option")
73
- .label("Answer");
74
- }
75
- });
76
- }
77
- else {
78
- return lazy(() => {
79
- if (question.isOptional) {
80
- return commonSchema.optional().label("Answer");
81
- }
82
- else {
83
- return commonSchema
84
- .required("Select an option")
85
- .label("Answer");
86
- }
87
- });
88
- }
89
- }),
90
- }),
91
- }));
40
+ // const StringSchema = string().max(500);
41
+ return getSchemaByQuestion(question.type);
42
+ // .concat(
43
+ // object().shape({
44
+ // answers: mixed<
45
+ // string | TNameIdLogoSchema | TOtherValueSchema
46
+ // >().when("type", {
47
+ // is: (type: QuestionType) => type === QuestionType.Input,
48
+ // then: () =>
49
+ // lazy(() => {
50
+ // if (question.isOptional) {
51
+ // return StringSchema.optional().label("Answer");
52
+ // } else {
53
+ // return StringSchema.required().label("Answer");
54
+ // }
55
+ // }),
56
+ // otherwise: () =>
57
+ // lazy(() => {
58
+ // const commonSchema = mixed().oneOfSchema([
59
+ // StringSchema,
60
+ // NameIdLogoSchema,
61
+ // OtherValueSchema,
62
+ // ]);
63
+ // if (question.answerChoiceType === AnswerChoiceType.Multiple) {
64
+ // return lazy(() => {
65
+ // const subCommonSchema = array().of(commonSchema);
66
+ // if (question.isOptional) {
67
+ // return subCommonSchema
68
+ // .optional()
69
+ // .default([])
70
+ // .label("Answer");
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
+ // } else {
80
+ // return lazy(() => {
81
+ // if (question.isOptional) {
82
+ // return commonSchema.optional().label("Answer");
83
+ // } else {
84
+ // return commonSchema
85
+ // .required("Select an option")
86
+ // .label("Answer");
87
+ // }
88
+ // });
89
+ // }
90
+ // }),
91
+ // }),
92
+ // })
93
+ // );
92
94
  })),
93
95
  history: array()
94
96
  .of(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,4 +1,4 @@
1
- import { object, string, boolean } from "../../yup-extended";
1
+ import { boolean, object, string } from "../../yup-extended";
2
2
  export const PageLocationSchema = object()
3
3
  .shape({
4
4
  isHeadquarters: boolean()
@@ -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"}
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { Common, NameIdLogoSchema, OtherValueSchema } from "../common";
3
- import { array, lazy, mixed, object, string, } from "../yup-extended";
2
+ import { Common, NameIdLogoSchema, OtherValueSchema, } from "../common";
3
+ import { array, lazy, mixed, object, string } from "../yup-extended";
4
4
  import { AnswerChoiceType, QuestionType, SupportedAnswerChoiceTypes, } from "./question.constant";
5
5
  import { QuestionSchema } from "./question.schema";
6
6
  // TODO: Refactor this to use string instead of objcts for values
@@ -76,12 +76,41 @@ const ChoicePreferredAnswerSchema = (label = "Preferred answer") => mixed().when
76
76
  .optional()
77
77
  .label(label),
78
78
  });
79
- export const ChoiceQuestionSchema = (QuestionSchema.concat(object().shape({
79
+ const ChoiceAnswerSchema = lazy((question) => {
80
+ const commonSchema = mixed().oneOfSchema([
81
+ // Note: this can be string, boolean, number, or other complex types
82
+ string().max(500),
83
+ NameIdLogoSchema,
84
+ OtherValueSchema,
85
+ ]);
86
+ if (question.answerChoiceType === AnswerChoiceType.Multiple) {
87
+ const multiAnswerSchema = array().of(commonSchema);
88
+ if (question.isOptional) {
89
+ return multiAnswerSchema.optional().default([]);
90
+ }
91
+ else {
92
+ return multiAnswerSchema
93
+ .min(1, "Select at least one option.")
94
+ .required("Select at least one option.")
95
+ .default([]);
96
+ }
97
+ }
98
+ else {
99
+ // Single choice
100
+ if (question.isOptional) {
101
+ return commonSchema.optional();
102
+ }
103
+ else {
104
+ return commonSchema.required("Select an option.");
105
+ }
106
+ }
107
+ });
108
+ export const ChoiceQuestionSchema = QuestionSchema.concat(object().shape({
80
109
  type: string()
81
110
  .oneOf([QuestionType.Choice])
82
111
  .required()
83
112
  .label("Question type"),
84
- optionsFrom: mixed()
113
+ optionsFrom: string()
85
114
  .oneOf([Common.Skill, Common.EducationLevel, Common.ExperienceLevel])
86
115
  .optional()
87
116
  .label("Option field"),
@@ -91,7 +120,10 @@ export const ChoiceQuestionSchema = (QuestionSchema.concat(object().shape({
91
120
  return string();
92
121
  }
93
122
  else {
94
- return mixed().oneOfSchema([NameIdLogoSchema, OtherValueSchema]);
123
+ return mixed().oneOfSchema([
124
+ NameIdLogoSchema,
125
+ OtherValueSchema,
126
+ ]);
95
127
  }
96
128
  }))
97
129
  .min(1)
@@ -100,6 +132,8 @@ export const ChoiceQuestionSchema = (QuestionSchema.concat(object().shape({
100
132
  answerChoiceType: string()
101
133
  .oneOf(SupportedAnswerChoiceTypes)
102
134
  .required()
135
+ .default(AnswerChoiceType.Single)
103
136
  .label("Type"),
104
137
  preferredAnswer: ChoicePreferredAnswerSchema("Preferred answer"),
105
- })));
138
+ answers: ChoiceAnswerSchema,
139
+ }));
@@ -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,5 +1,18 @@
1
+ // input-question.schema.ts
1
2
  import { object, string } from "../yup-extended";
2
3
  import { QuestionSchema } from "./question.schema";
3
- export const InputQuestionSchema = (QuestionSchema.concat(object().shape({
4
+ import { QuestionType } from "./question.constant";
5
+ export const InputQuestionSchema = QuestionSchema.concat(object().shape({
6
+ type: string()
7
+ .oneOf([QuestionType.Input])
8
+ .required()
9
+ .label("Question type"),
4
10
  preferredAnswer: string().max(100).optional().label("Preferred Answer"),
5
- })));
11
+ answers: string()
12
+ .max(500)
13
+ .when("isOptional", {
14
+ is: false,
15
+ then: (schema) => schema.required("This field is required."),
16
+ otherwise: (schema) => schema.optional(),
17
+ }),
18
+ }));
@@ -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"}
@@ -1,5 +1,5 @@
1
- import { array, boolean, mixed, object, string, } from "../yup-extended";
2
- import { AnswerChoiceType, SupportedAnswerChoiceTypes, SupportedQuestionTypes, } from "./question.constant";
1
+ import { boolean, object, string } from "../yup-extended";
2
+ import { SupportedQuestionTypes } from "./question.constant";
3
3
  export const QuestionSchema = object().shape({
4
4
  label: string().max(50).optional().label("Label"),
5
5
  default: boolean().optional().default(false).label("Default"),
@@ -7,16 +7,13 @@ export const QuestionSchema = object().shape({
7
7
  type: string().oneOf(SupportedQuestionTypes).required().label("Type"),
8
8
  isOptional: boolean().optional().label("Mark if the question is optional"),
9
9
  readonly: boolean().optional().label("Readonly"),
10
- preferredAnswer: mixed().optional().label("Preferred Answer"),
11
- optionsFrom: string().optional().label("Options From"),
12
- options: array().of(mixed()).optional().label("Options"),
13
- description: string().optional().label("Content"),
14
- answers: mixed().optional().label("Answer"),
15
- answerChoiceType: string()
16
- .oneOf(SupportedAnswerChoiceTypes)
17
- .required()
18
- .default(AnswerChoiceType.Single)
19
- .label("Answer Choice Type"),
20
10
  isNew: boolean().optional().label("Is New"),
21
11
  });
22
- //ljlkj
12
+ // export type TQuestionnaire = (
13
+ // | TInputQuestionSchema
14
+ // | TChoiceQuestionSchema
15
+ // | TReadAndAcknowledgeQuestionSchema
16
+ // )[];
17
+ // Note: The TMixedValue and TQuestionSchema types might need adjustments
18
+ // depending on how you use them downstream, but this is the logical
19
+ // 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,10 +1,17 @@
1
+ // read-and-acknowledge-question.schema.ts
1
2
  import { Common } from "../common";
2
3
  import { object, string } from "../yup-extended";
4
+ import { QuestionType } from "./question.constant";
3
5
  import { QuestionSchema } from "./question.schema";
4
- export const ReadAndAcknowledgeQuestionSchema = (QuestionSchema.concat(object().shape({
5
- description: string().max(10000).required().label("Content"),
6
- preferredAnswer: string()
7
- .oneOf([Common.Yes, Common.No])
6
+ const AcknowledgeAnswerSchema = string()
7
+ .oneOf([Common.Yes, Common.No])
8
+ .required("This question must be acknowledged.");
9
+ export const ReadAndAcknowledgeQuestionSchema = QuestionSchema.concat(object().shape({
10
+ type: string()
11
+ .oneOf([QuestionType.ReadAndAcknowledge])
8
12
  .required()
9
- .label("Preferred Answer"),
10
- })));
13
+ .label("Question type"),
14
+ description: string().max(10000).required().label("Content"),
15
+ preferredAnswer: AcknowledgeAnswerSchema.label("Preferred Answer"),
16
+ answers: AcknowledgeAnswerSchema.label("Answer"),
17
+ }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thejob/schema",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",