@routevn/creator-model 1.5.1 → 1.5.2

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/model.js +99 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routevn/creator-model",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/model.js CHANGED
@@ -2210,7 +2210,7 @@ const validateAnimationItems = ({ items, path, errorFactory }) => {
2210
2210
  }
2211
2211
 
2212
2212
  {
2213
- const result = validatePreviewObject({
2213
+ const result = validateAnimationPreviewObject({
2214
2214
  value: item.preview,
2215
2215
  path: `${itemPath}.preview`,
2216
2216
  errorFactory,
@@ -4906,6 +4906,102 @@ const validatePreviewObject = ({ value, path, errorFactory }) => {
4906
4906
  return VALID_RESULT;
4907
4907
  };
4908
4908
 
4909
+ const validateAnimationPreviewSlot = ({
4910
+ value,
4911
+ path,
4912
+ allowTransform = false,
4913
+ errorFactory,
4914
+ }) => {
4915
+ if (value === undefined) {
4916
+ return VALID_RESULT;
4917
+ }
4918
+
4919
+ if (!isPlainObject(value)) {
4920
+ return invalidFromErrorFactory(
4921
+ errorFactory,
4922
+ `${path} must be an object when provided`,
4923
+ );
4924
+ }
4925
+
4926
+ {
4927
+ const result = validateAllowedKeys({
4928
+ value,
4929
+ allowedKeys: allowTransform ? ["imageId", "transformId"] : ["imageId"],
4930
+ path,
4931
+ errorFactory,
4932
+ });
4933
+ if (result?.valid === false) {
4934
+ return result;
4935
+ }
4936
+ }
4937
+
4938
+ if (value.imageId !== undefined && !isNonEmptyString(value.imageId)) {
4939
+ return invalidFromErrorFactory(
4940
+ errorFactory,
4941
+ `${path}.imageId must be a non-empty string when provided`,
4942
+ );
4943
+ }
4944
+
4945
+ if (value.transformId !== undefined && !isNonEmptyString(value.transformId)) {
4946
+ return invalidFromErrorFactory(
4947
+ errorFactory,
4948
+ `${path}.transformId must be a non-empty string when provided`,
4949
+ );
4950
+ }
4951
+
4952
+ return VALID_RESULT;
4953
+ };
4954
+
4955
+ const validateAnimationPreviewObject = ({ value, path, errorFactory }) => {
4956
+ if (value === undefined) {
4957
+ return VALID_RESULT;
4958
+ }
4959
+
4960
+ if (!isPlainObject(value)) {
4961
+ return invalidFromErrorFactory(
4962
+ errorFactory,
4963
+ `${path} must be an object when provided`,
4964
+ );
4965
+ }
4966
+
4967
+ {
4968
+ const result = validateAllowedKeys({
4969
+ value,
4970
+ allowedKeys: ["background", "target", "outgoing", "incoming"],
4971
+ path,
4972
+ errorFactory,
4973
+ });
4974
+ if (result?.valid === false) {
4975
+ return result;
4976
+ }
4977
+ }
4978
+
4979
+ {
4980
+ const result = validateAnimationPreviewSlot({
4981
+ value: value.background,
4982
+ path: `${path}.background`,
4983
+ errorFactory,
4984
+ });
4985
+ if (result?.valid === false) {
4986
+ return result;
4987
+ }
4988
+ }
4989
+
4990
+ for (const key of ["target", "outgoing", "incoming"]) {
4991
+ const result = validateAnimationPreviewSlot({
4992
+ value: value[key],
4993
+ path: `${path}.${key}`,
4994
+ allowTransform: true,
4995
+ errorFactory,
4996
+ });
4997
+ if (result?.valid === false) {
4998
+ return result;
4999
+ }
5000
+ }
5001
+
5002
+ return VALID_RESULT;
5003
+ };
5004
+
4909
5005
  const validateTransformPreviewSlot = ({ value, path, errorFactory }) => {
4910
5006
  if (value === undefined) {
4911
5007
  return VALID_RESULT;
@@ -9164,7 +9260,7 @@ const validateAnimationCreateData = ({ data, errorFactory }) => {
9164
9260
  }
9165
9261
 
9166
9262
  {
9167
- const result = validatePreviewObject({
9263
+ const result = validateAnimationPreviewObject({
9168
9264
  value: data.preview,
9169
9265
  path: "payload.data.preview",
9170
9266
  errorFactory,
@@ -9250,7 +9346,7 @@ const validateAnimationUpdateData = ({ data, errorFactory }) => {
9250
9346
  }
9251
9347
 
9252
9348
  {
9253
- const result = validatePreviewObject({
9349
+ const result = validateAnimationPreviewObject({
9254
9350
  value: data.preview,
9255
9351
  path: "payload.data.preview",
9256
9352
  errorFactory,