@thejob/schema 1.0.28 → 1.0.30
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/dist/cjs/index.d.ts +0 -5
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +0 -5
- package/dist/cjs/interfaces.index.d.ts +55 -49
- package/dist/cjs/interfaces.index.d.ts.map +1 -1
- package/dist/cjs/job/job.schema.d.ts +15 -10
- package/dist/cjs/job/job.schema.d.ts.map +1 -1
- package/dist/cjs/job-application/job-application.schema.d.ts +16 -11
- package/dist/cjs/job-application/job-application.schema.d.ts.map +1 -1
- package/dist/cjs/job-role-template/job-role-template.schema.d.ts +15 -10
- package/dist/cjs/job-role-template/job-role-template.schema.d.ts.map +1 -1
- package/dist/cjs/question/choice-question.schema.d.ts +6 -10
- package/dist/cjs/question/choice-question.schema.d.ts.map +1 -1
- package/dist/cjs/question/choice-question.schema.js +15 -9
- package/dist/cjs/question/input-question.schema.d.ts +2 -2
- package/dist/cjs/question/input-question.schema.d.ts.map +1 -1
- package/dist/cjs/question/input-question.schema.js +3 -3
- package/dist/cjs/question/question.schema.js +5 -0
- package/dist/cjs/question/read-and-acknowledge.schema.d.ts +28 -3
- package/dist/cjs/question/read-and-acknowledge.schema.d.ts.map +1 -1
- package/dist/cjs/question/read-and-acknowledge.schema.js +13 -6
- package/dist/esm/index.d.ts +0 -5
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -5
- package/dist/esm/interfaces.index.d.ts +55 -49
- package/dist/esm/interfaces.index.d.ts.map +1 -1
- package/dist/esm/job/job.schema.d.ts +15 -10
- package/dist/esm/job/job.schema.d.ts.map +1 -1
- package/dist/esm/job-application/job-application.schema.d.ts +16 -11
- package/dist/esm/job-application/job-application.schema.d.ts.map +1 -1
- package/dist/esm/job-role-template/job-role-template.schema.d.ts +15 -10
- package/dist/esm/job-role-template/job-role-template.schema.d.ts.map +1 -1
- package/dist/esm/question/choice-question.schema.d.ts +6 -10
- package/dist/esm/question/choice-question.schema.d.ts.map +1 -1
- package/dist/esm/question/choice-question.schema.js +17 -11
- package/dist/esm/question/input-question.schema.d.ts +2 -2
- package/dist/esm/question/input-question.schema.d.ts.map +1 -1
- package/dist/esm/question/input-question.schema.js +3 -3
- package/dist/esm/question/question.schema.js +5 -0
- package/dist/esm/question/read-and-acknowledge.schema.d.ts +28 -3
- package/dist/esm/question/read-and-acknowledge.schema.d.ts.map +1 -1
- package/dist/esm/question/read-and-acknowledge.schema.js +13 -6
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { NameIdLogoSchema, OtherValueSchema, } from "../common";
|
|
2
|
+
import { Common, NameIdLogoSchema, OtherValueSchema, } from "../common";
|
|
3
3
|
import { array, lazy, mixed, object, string } from "../yup-extended";
|
|
4
|
-
import { AnswerChoiceType, QuestionType } from "./question.constant";
|
|
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
|
|
7
7
|
const displayByName = (option) => {
|
|
@@ -76,15 +76,15 @@ const ChoicePreferredAnswerSchema = (label = "Preferred answer") => mixed().when
|
|
|
76
76
|
.optional()
|
|
77
77
|
.label(label),
|
|
78
78
|
});
|
|
79
|
-
const
|
|
79
|
+
const getChoiceAnswerSchema = (answerChoiceType, isOptional) => {
|
|
80
80
|
const commonSchema = mixed().oneOfSchema([
|
|
81
81
|
string().max(500),
|
|
82
82
|
NameIdLogoSchema,
|
|
83
83
|
OtherValueSchema,
|
|
84
84
|
]);
|
|
85
|
-
if (
|
|
85
|
+
if (answerChoiceType === AnswerChoiceType.Multiple) {
|
|
86
86
|
const multiAnswerSchema = array().of(commonSchema);
|
|
87
|
-
if (
|
|
87
|
+
if (isOptional) {
|
|
88
88
|
return multiAnswerSchema.optional().default([]);
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
@@ -96,20 +96,23 @@ const ChoiceAnswerSchema = lazy((question) => {
|
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
98
98
|
// Single choice
|
|
99
|
-
if (
|
|
99
|
+
if (isOptional) {
|
|
100
100
|
return commonSchema.optional();
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
103
|
return commonSchema.required("Select an option.");
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
}
|
|
106
|
+
};
|
|
107
107
|
export const ChoiceQuestionSchema = QuestionSchema.concat(object().shape({
|
|
108
108
|
type: string()
|
|
109
109
|
.oneOf([QuestionType.Choice])
|
|
110
110
|
.required()
|
|
111
111
|
.label("Question type"),
|
|
112
|
-
optionsFrom: string()
|
|
112
|
+
optionsFrom: string()
|
|
113
|
+
.oneOf([Common.Skill, Common.EducationLevel, Common.ExperienceLevel])
|
|
114
|
+
.optional()
|
|
115
|
+
.label("Option field"),
|
|
113
116
|
options: array()
|
|
114
117
|
.of(lazy((option) => {
|
|
115
118
|
if (typeof option === "string") {
|
|
@@ -125,8 +128,11 @@ export const ChoiceQuestionSchema = QuestionSchema.concat(object().shape({
|
|
|
125
128
|
.min(1)
|
|
126
129
|
.required()
|
|
127
130
|
.label("Options"),
|
|
128
|
-
|
|
131
|
+
answerChoiceType: string()
|
|
132
|
+
.oneOf(SupportedAnswerChoiceTypes)
|
|
133
|
+
.required()
|
|
134
|
+
.default(AnswerChoiceType.Single)
|
|
135
|
+
.label("Type"),
|
|
129
136
|
preferredAnswer: ChoicePreferredAnswerSchema("Preferred answer"),
|
|
130
|
-
|
|
131
|
-
answers: ChoiceAnswerSchema,
|
|
137
|
+
answers: mixed().when(["answerChoiceType", "isOptional"], ([answerChoiceType, isOptional], schema) => getChoiceAnswerSchema(answerChoiceType, isOptional)),
|
|
132
138
|
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InferType } from "../yup-extended";
|
|
1
|
+
import { InferType, ObjectSchema } from "../yup-extended";
|
|
2
2
|
import { QuestionType } from "./question.constant";
|
|
3
|
-
export declare const InputQuestionSchema:
|
|
3
|
+
export declare const InputQuestionSchema: ObjectSchema<{
|
|
4
4
|
label: string | undefined;
|
|
5
5
|
default: boolean;
|
|
6
6
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-question.schema.d.ts","sourceRoot":"","sources":["../../../src/question/input-question.schema.ts"],"names":[],"mappings":"
|
|
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,6 +1,7 @@
|
|
|
1
|
+
// input-question.schema.ts
|
|
1
2
|
import { object, string } from "../yup-extended";
|
|
2
|
-
import { QuestionType } from "./question.constant";
|
|
3
3
|
import { QuestionSchema } from "./question.schema";
|
|
4
|
+
import { QuestionType } from "./question.constant";
|
|
4
5
|
export const InputQuestionSchema = QuestionSchema.concat(object().shape({
|
|
5
6
|
type: string()
|
|
6
7
|
.oneOf([QuestionType.Input])
|
|
@@ -13,6 +14,5 @@ export const InputQuestionSchema = QuestionSchema.concat(object().shape({
|
|
|
13
14
|
is: false,
|
|
14
15
|
then: (schema) => schema.required("This field is required."),
|
|
15
16
|
otherwise: (schema) => schema.optional(),
|
|
16
|
-
})
|
|
17
|
-
.label("Answer"),
|
|
17
|
+
}),
|
|
18
18
|
}));
|
|
@@ -9,6 +9,11 @@ export const QuestionSchema = object().shape({
|
|
|
9
9
|
readonly: boolean().optional().label("Readonly"),
|
|
10
10
|
isNew: boolean().optional().label("Is New"),
|
|
11
11
|
});
|
|
12
|
+
// export type TQuestionnaire = (
|
|
13
|
+
// | TInputQuestionSchema
|
|
14
|
+
// | TChoiceQuestionSchema
|
|
15
|
+
// | TReadAndAcknowledgeQuestionSchema
|
|
16
|
+
// )[];
|
|
12
17
|
// Note: The TMixedValue and TQuestionSchema types might need adjustments
|
|
13
18
|
// depending on how you use them downstream, but this is the logical
|
|
14
19
|
// change for the schema itself.
|
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
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,
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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("
|
|
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
|
+
}));
|