@ng-forge/dynamic-form-mcp 0.6.1 → 0.7.0

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.
@@ -858,54 +858,6 @@ var VALIDATORS = [
858
858
  example: `{
859
859
  type: 'async',
860
860
  functionName: 'checkUsernameAvailability'
861
- }`
862
- },
863
- {
864
- type: "customAsync",
865
- category: "async",
866
- description: "DEPRECATED \u2014 use type: 'async' instead. Async validator using registered async function.",
867
- parameters: {
868
- functionName: {
869
- name: "functionName",
870
- type: "string",
871
- description: "Name of registered async validator function",
872
- required: true
873
- },
874
- params: {
875
- name: "params",
876
- type: "Record<string, unknown>",
877
- description: "Parameters to pass to validator function",
878
- required: false
879
- }
880
- },
881
- example: `// DEPRECATED \u2014 use type: 'async' instead
882
- {
883
- type: 'customAsync',
884
- functionName: 'checkUsernameAvailability'
885
- }`
886
- },
887
- {
888
- type: "customHttp",
889
- category: "http",
890
- description: "DEPRECATED \u2014 use type: 'http' with functionName instead. HTTP-based validator with automatic request cancellation.",
891
- parameters: {
892
- functionName: {
893
- name: "functionName",
894
- type: "string",
895
- description: "Name of registered HTTP validator configuration",
896
- required: true
897
- },
898
- params: {
899
- name: "params",
900
- type: "Record<string, unknown>",
901
- description: "Parameters to pass to HTTP validator",
902
- required: false
903
- }
904
- },
905
- example: `// DEPRECATED \u2014 use type: 'http' with functionName instead
906
- {
907
- type: 'customHttp',
908
- functionName: 'validateEmailExists'
909
861
  }`
910
862
  },
911
863
  {
@@ -3517,16 +3469,12 @@ var FieldValueConditionSchema = BaseComparisonConditionSchema.extend({
3517
3469
  */
3518
3470
  fieldPath: z15.string()
3519
3471
  });
3520
- var FormValueConditionSchema = BaseComparisonConditionSchema.extend({
3521
- type: z15.literal("formValue")
3522
- });
3523
3472
  var CustomConditionSchema = z15.object({
3524
3473
  type: z15.literal("custom"),
3525
3474
  /**
3526
- * JavaScript expression to evaluate.
3527
- * Has access to: fieldValue, formValue, fieldPath
3475
+ * Name of a registered custom function to invoke.
3528
3476
  */
3529
- expression: z15.string()
3477
+ functionName: z15.string()
3530
3478
  });
3531
3479
  var JavaScriptConditionSchema = z15.object({
3532
3480
  type: z15.literal("javascript"),
@@ -3539,7 +3487,6 @@ var JavaScriptConditionSchema = z15.object({
3539
3487
  var ConditionalExpressionSchema = z15.lazy(
3540
3488
  () => z15.discriminatedUnion("type", [
3541
3489
  FieldValueConditionSchema,
3542
- FormValueConditionSchema,
3543
3490
  CustomConditionSchema,
3544
3491
  JavaScriptConditionSchema,
3545
3492
  AndConditionSchema,
@@ -3628,7 +3575,7 @@ var ValidatorConfigSchema = z16.discriminatedUnion("type", [
3628
3575
  }),
3629
3576
  // Async validators
3630
3577
  BaseValidatorSchema.extend({
3631
- type: z16.literal("customAsync"),
3578
+ type: z16.literal("async"),
3632
3579
  /**
3633
3580
  * Name of a registered async validator function. Required.
3634
3581
  */
@@ -3640,7 +3587,7 @@ var ValidatorConfigSchema = z16.discriminatedUnion("type", [
3640
3587
  }),
3641
3588
  // HTTP validators
3642
3589
  BaseValidatorSchema.extend({
3643
- type: z16.literal("customHttp"),
3590
+ type: z16.literal("http"),
3644
3591
  /**
3645
3592
  * Name of a registered HTTP validator config function. Required.
3646
3593
  */
@@ -8002,18 +7949,33 @@ logic: [{ type: 'disabled', condition: 'formSubmitting' }]
8002
7949
  Copy-paste ready expressions for derivations and conditions.
8003
7950
 
8004
7951
  ## Age from Birthdate
7952
+ Complex calculations like age should use a custom function, not an expression:
8005
7953
  \`\`\`typescript
8006
- expression: \`(() => {
8007
- if (!formValue.birthDate) return '';
8008
- const birth = new Date(formValue.birthDate);
8009
- const today = new Date();
8010
- let age = today.getFullYear() - birth.getFullYear();
8011
- const monthDiff = today.getMonth() - birth.getMonth();
8012
- if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birth.getDate())) {
8013
- age--;
8014
- }
8015
- return age;
8016
- })()\`
7954
+ // In your FormConfig:
7955
+ {
7956
+ key: 'age',
7957
+ type: 'input',
7958
+ derivation: {
7959
+ type: 'custom',
7960
+ functionName: 'calculateAge',
7961
+ },
7962
+ }
7963
+
7964
+ // In customFnConfig:
7965
+ customFnConfig: {
7966
+ derivations: {
7967
+ calculateAge: (ctx) => {
7968
+ const birthDate = ctx.formValue().birthDate;
7969
+ if (!birthDate) return '';
7970
+ const birth = new Date(birthDate);
7971
+ const today = new Date();
7972
+ let age = today.getFullYear() - birth.getFullYear();
7973
+ const m = today.getMonth() - birth.getMonth();
7974
+ if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) age--;
7975
+ return age;
7976
+ },
7977
+ },
7978
+ }
8017
7979
  \`\`\`
8018
7980
 
8019
7981
  ## Array Count / Length
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-forge/dynamic-form-mcp",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "MCP server for ng-forge dynamic forms - AI-assisted form schema generation",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -51,11 +51,11 @@
51
51
  "zod": "^3.25.76"
52
52
  },
53
53
  "devDependencies": {
54
- "@ng-forge/dynamic-forms": "^0.6.0",
55
- "@ng-forge/dynamic-forms-bootstrap": "^0.6.0",
56
- "@ng-forge/dynamic-forms-ionic": "^0.6.0",
57
- "@ng-forge/dynamic-forms-material": "^0.6.0",
58
- "@ng-forge/dynamic-forms-primeng": "^0.6.0",
54
+ "@ng-forge/dynamic-forms": "^0.7.0",
55
+ "@ng-forge/dynamic-forms-bootstrap": "^0.7.0",
56
+ "@ng-forge/dynamic-forms-ionic": "^0.7.0",
57
+ "@ng-forge/dynamic-forms-material": "^0.7.0",
58
+ "@ng-forge/dynamic-forms-primeng": "^0.7.0",
59
59
  "tsx": "^4.19.0"
60
60
  }
61
61
  }
package/src/index.js CHANGED
@@ -856,54 +856,6 @@ var VALIDATORS = [
856
856
  example: `{
857
857
  type: 'async',
858
858
  functionName: 'checkUsernameAvailability'
859
- }`
860
- },
861
- {
862
- type: "customAsync",
863
- category: "async",
864
- description: "DEPRECATED \u2014 use type: 'async' instead. Async validator using registered async function.",
865
- parameters: {
866
- functionName: {
867
- name: "functionName",
868
- type: "string",
869
- description: "Name of registered async validator function",
870
- required: true
871
- },
872
- params: {
873
- name: "params",
874
- type: "Record<string, unknown>",
875
- description: "Parameters to pass to validator function",
876
- required: false
877
- }
878
- },
879
- example: `// DEPRECATED \u2014 use type: 'async' instead
880
- {
881
- type: 'customAsync',
882
- functionName: 'checkUsernameAvailability'
883
- }`
884
- },
885
- {
886
- type: "customHttp",
887
- category: "http",
888
- description: "DEPRECATED \u2014 use type: 'http' with functionName instead. HTTP-based validator with automatic request cancellation.",
889
- parameters: {
890
- functionName: {
891
- name: "functionName",
892
- type: "string",
893
- description: "Name of registered HTTP validator configuration",
894
- required: true
895
- },
896
- params: {
897
- name: "params",
898
- type: "Record<string, unknown>",
899
- description: "Parameters to pass to HTTP validator",
900
- required: false
901
- }
902
- },
903
- example: `// DEPRECATED \u2014 use type: 'http' with functionName instead
904
- {
905
- type: 'customHttp',
906
- functionName: 'validateEmailExists'
907
859
  }`
908
860
  },
909
861
  {
@@ -3522,16 +3474,12 @@ var FieldValueConditionSchema = BaseComparisonConditionSchema.extend({
3522
3474
  */
3523
3475
  fieldPath: z15.string()
3524
3476
  });
3525
- var FormValueConditionSchema = BaseComparisonConditionSchema.extend({
3526
- type: z15.literal("formValue")
3527
- });
3528
3477
  var CustomConditionSchema = z15.object({
3529
3478
  type: z15.literal("custom"),
3530
3479
  /**
3531
- * JavaScript expression to evaluate.
3532
- * Has access to: fieldValue, formValue, fieldPath
3480
+ * Name of a registered custom function to invoke.
3533
3481
  */
3534
- expression: z15.string()
3482
+ functionName: z15.string()
3535
3483
  });
3536
3484
  var JavaScriptConditionSchema = z15.object({
3537
3485
  type: z15.literal("javascript"),
@@ -3544,7 +3492,6 @@ var JavaScriptConditionSchema = z15.object({
3544
3492
  var ConditionalExpressionSchema = z15.lazy(
3545
3493
  () => z15.discriminatedUnion("type", [
3546
3494
  FieldValueConditionSchema,
3547
- FormValueConditionSchema,
3548
3495
  CustomConditionSchema,
3549
3496
  JavaScriptConditionSchema,
3550
3497
  AndConditionSchema,
@@ -3633,7 +3580,7 @@ var ValidatorConfigSchema = z16.discriminatedUnion("type", [
3633
3580
  }),
3634
3581
  // Async validators
3635
3582
  BaseValidatorSchema.extend({
3636
- type: z16.literal("customAsync"),
3583
+ type: z16.literal("async"),
3637
3584
  /**
3638
3585
  * Name of a registered async validator function. Required.
3639
3586
  */
@@ -3645,7 +3592,7 @@ var ValidatorConfigSchema = z16.discriminatedUnion("type", [
3645
3592
  }),
3646
3593
  // HTTP validators
3647
3594
  BaseValidatorSchema.extend({
3648
- type: z16.literal("customHttp"),
3595
+ type: z16.literal("http"),
3649
3596
  /**
3650
3597
  * Name of a registered HTTP validator config function. Required.
3651
3598
  */
@@ -8051,18 +7998,33 @@ logic: [{ type: 'disabled', condition: 'formSubmitting' }]
8051
7998
  Copy-paste ready expressions for derivations and conditions.
8052
7999
 
8053
8000
  ## Age from Birthdate
8001
+ Complex calculations like age should use a custom function, not an expression:
8054
8002
  \`\`\`typescript
8055
- expression: \`(() => {
8056
- if (!formValue.birthDate) return '';
8057
- const birth = new Date(formValue.birthDate);
8058
- const today = new Date();
8059
- let age = today.getFullYear() - birth.getFullYear();
8060
- const monthDiff = today.getMonth() - birth.getMonth();
8061
- if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birth.getDate())) {
8062
- age--;
8063
- }
8064
- return age;
8065
- })()\`
8003
+ // In your FormConfig:
8004
+ {
8005
+ key: 'age',
8006
+ type: 'input',
8007
+ derivation: {
8008
+ type: 'custom',
8009
+ functionName: 'calculateAge',
8010
+ },
8011
+ }
8012
+
8013
+ // In customFnConfig:
8014
+ customFnConfig: {
8015
+ derivations: {
8016
+ calculateAge: (ctx) => {
8017
+ const birthDate = ctx.formValue().birthDate;
8018
+ if (!birthDate) return '';
8019
+ const birth = new Date(birthDate);
8020
+ const today = new Date();
8021
+ let age = today.getFullYear() - birth.getFullYear();
8022
+ const m = today.getMonth() - birth.getMonth();
8023
+ if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) age--;
8024
+ return age;
8025
+ },
8026
+ },
8027
+ }
8066
8028
  \`\`\`
8067
8029
 
8068
8030
  ## Array Count / Length
@@ -1 +1 @@
1
- {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../../../packages/dynamic-form-mcp/src/registry/validators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAO,MAAM,UAAU,EAAE,aAAa,EAsSrC,CAAC"}
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../../../packages/dynamic-form-mcp/src/registry/validators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAO,MAAM,UAAU,EAAE,aAAa,EAsPrC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"lookup-topics.d.ts","sourceRoot":"","sources":["../../../../../../packages/dynamic-form-mcp/src/tools/data/lookup-topics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAo4ElE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2CrD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8HhD,CAAC"}
1
+ {"version":3,"file":"lookup-topics.d.ts","sourceRoot":"","sources":["../../../../../../packages/dynamic-form-mcp/src/tools/data/lookup-topics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAm5ElE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2CrD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8HhD,CAAC"}