functional-models 3.6.3 → 3.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.
package/README.md CHANGED
@@ -650,25 +650,3 @@ In this situation, the latinName for species is not passed in, but calculated fr
650
650
  A date property that automatically updates whenever the model instance is saved.
651
651
 
652
652
  [Documentation](https://monolithst.github.io/functional-models/functions/index.orm.properties.LastModifiedDateProperty.html)
653
-
654
-
655
- # MCP Development Server
656
-
657
- Functional Models has an MCP server for AI based development. It provides knowledge entries for the AI to have specific examples of how to work with and manipulate models in a system. This GREATLY increases the accuracy and understanding of AI working with these systems, making it really easy to add new features, refactor, and make the best use of features.
658
-
659
- ## Quick Start
660
-
661
- You can setup the server by setting up Cursor (or similar) with this configuration.
662
-
663
- ```json
664
- {
665
- "mcpServers": {
666
- "node-in-layers-core": {
667
- "command": "npx",
668
- "args": ["-y", "@functional-models/knowledge-mcp"]
669
- }
670
- }
671
- }
672
- ```
673
-
674
- You can learn more about this here [Knowledge MCP](./knowledge-mcp/README.md)
@@ -25,23 +25,29 @@ declare const LastModifiedDateProperty: (config?: PropertyConfig<DateValueType>)
25
25
  }>>;
26
26
  }>;
27
27
  /**
28
- * A property that represents a foreign key to another model.
28
+ * A property that represents a key in a database.
29
29
  * By default it is a "uuid" type, but if you want to use an arbitrary string, or an integer type you can set the `dataType` property.
30
30
  * @interface
31
31
  */
32
- type ForeignKeyPropertyConfig<TValue extends string | number> = PropertyConfig<TValue> & Readonly<{
32
+ type DatabaseKeyPropertyConfig<TValue extends string | number> = PropertyConfig<TValue> & Readonly<{
33
33
  /**
34
34
  * Sets the type of the foreign key.
35
35
  * @default 'uuid'
36
36
  */
37
37
  dataType?: 'uuid' | 'string' | 'integer';
38
+ /**
39
+ * If true, the key will be automatically generated if not provided. Only applies to uuids.
40
+ * @default true
41
+ */
42
+ auto?: boolean;
38
43
  }>;
39
44
  /**
40
45
  * A property that represents a foreign key to another model in a database.
41
46
  * By default it is a "uuid" type, but if you want to use an arbitrary string, or an integer type you can set the `dataType` property.
47
+ * NOTE: auto is ignored in config.
42
48
  * @param config - Additional configurations.
43
49
  */
44
- declare const ForeignKeyProperty: <TValue extends string | number, TModel extends DataDescription>(model: MaybeFunction<ModelType<TModel>>, config?: ForeignKeyPropertyConfig<TValue>) => (Readonly<{
50
+ declare const ForeignKeyProperty: <TValue extends string | number, TModel extends DataDescription>(model: MaybeFunction<ModelType<TModel>>, config?: DatabaseKeyPropertyConfig<TValue>) => (Readonly<{
45
51
  getConfig: () => object;
46
52
  getChoices: () => readonly import("../types").ChoiceTypes[];
47
53
  getDefaultValue: () => string | undefined;
@@ -83,9 +89,48 @@ declare const ForeignKeyProperty: <TValue extends string | number, TModel extend
83
89
  getReferencedId: (instanceValues: TValue) => TValue;
84
90
  getReferencedModel: () => ModelType<TModel>;
85
91
  };
92
+ declare const PrimaryKeyProperty: <TValue extends string | number>(config?: DatabaseKeyPropertyConfig<TValue>) => Readonly<{
93
+ getConfig: () => object;
94
+ getChoices: () => readonly import("../types").ChoiceTypes[];
95
+ getDefaultValue: () => string | undefined;
96
+ getConstantValue: () => string | undefined;
97
+ getPropertyType: () => import("../types").PropertyType | string;
98
+ createGetter: (value: string, modelData: Readonly<{
99
+ [s: string]: any;
100
+ }>, modelInstance: import("../types").ModelInstance<Readonly<{
101
+ [s: string]: any;
102
+ }>, object, object>) => import("../types").ValueGetter<string, Readonly<{
103
+ [s: string]: any;
104
+ }>, object, object>;
105
+ getZod: () => import("zod").ZodType<string, unknown, import("zod/v4/core").$ZodTypeInternals<string, unknown>>;
106
+ getValidator: (valueGetter: import("../types").ValueGetter<string, Readonly<{
107
+ [s: string]: any;
108
+ }>, object, object>) => import("../types").PropertyValidator<Readonly<{
109
+ [s: string]: any;
110
+ }>>;
111
+ }> | Readonly<{
112
+ getConfig: () => object;
113
+ getChoices: () => readonly import("../types").ChoiceTypes[];
114
+ getDefaultValue: () => number | undefined;
115
+ getConstantValue: () => number | undefined;
116
+ getPropertyType: () => import("../types").PropertyType | string;
117
+ createGetter: (value: number, modelData: Readonly<{
118
+ [s: string]: any;
119
+ }>, modelInstance: import("../types").ModelInstance<Readonly<{
120
+ [s: string]: any;
121
+ }>, object, object>) => import("../types").ValueGetter<number, Readonly<{
122
+ [s: string]: any;
123
+ }>, object, object>;
124
+ getZod: () => import("zod").ZodType<number, unknown, import("zod/v4/core").$ZodTypeInternals<number, unknown>>;
125
+ getValidator: (valueGetter: import("../types").ValueGetter<number, Readonly<{
126
+ [s: string]: any;
127
+ }>, object, object>) => import("../types").PropertyValidator<Readonly<{
128
+ [s: string]: any;
129
+ }>>;
130
+ }>;
86
131
  /**
87
132
  * Creates an orm based property config.
88
133
  * @param config - Additional configurations.
89
134
  */
90
135
  declare const ormPropertyConfig: <T extends Arrayable<DataValue>>(config?: OrmPropertyConfig<T>) => PropertyConfig<T>;
91
- export { ormPropertyConfig, LastModifiedDateProperty, ForeignKeyProperty };
136
+ export { ormPropertyConfig, LastModifiedDateProperty, ForeignKeyProperty, PrimaryKeyProperty, };
package/orm/properties.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ForeignKeyProperty = exports.LastModifiedDateProperty = exports.ormPropertyConfig = void 0;
6
+ exports.PrimaryKeyProperty = exports.ForeignKeyProperty = exports.LastModifiedDateProperty = exports.ormPropertyConfig = void 0;
7
7
  const merge_1 = __importDefault(require("lodash/merge"));
8
8
  const identity_1 = __importDefault(require("lodash/identity"));
9
9
  const properties_1 = require("../properties");
@@ -23,6 +23,7 @@ exports.LastModifiedDateProperty = LastModifiedDateProperty;
23
23
  /**
24
24
  * A property that represents a foreign key to another model in a database.
25
25
  * By default it is a "uuid" type, but if you want to use an arbitrary string, or an integer type you can set the `dataType` property.
26
+ * NOTE: auto is ignored in config.
26
27
  * @param config - Additional configurations.
27
28
  */
28
29
  const ForeignKeyProperty = (model, config = {}) => {
@@ -52,6 +53,22 @@ const ForeignKeyProperty = (model, config = {}) => {
52
53
  });
53
54
  };
54
55
  exports.ForeignKeyProperty = ForeignKeyProperty;
56
+ const PrimaryKeyProperty = (config = {}) => {
57
+ const _getProperty = () => {
58
+ const auto = config.auto === undefined ? true : config.auto ? true : false;
59
+ if (config.dataType === 'uuid') {
60
+ return (0, properties_1.UuidProperty)((0, merge_1.default)(config, {
61
+ autoNow: auto,
62
+ }));
63
+ }
64
+ if (config.dataType === 'integer') {
65
+ return (0, properties_1.IntegerProperty)(config);
66
+ }
67
+ return (0, properties_1.TextProperty)(config);
68
+ };
69
+ return _getProperty();
70
+ };
71
+ exports.PrimaryKeyProperty = PrimaryKeyProperty;
55
72
  /**
56
73
  * Creates an orm based property config.
57
74
  * @param config - Additional configurations.
@@ -1 +1 @@
1
- {"version":3,"file":"properties.js","sourceRoot":"","sources":["../../src/orm/properties.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAgC;AAChC,+DAAsC;AAUtC,8CAKsB;AACtB,6CAAqC;AAGrC,MAAM,sBAAsB,GAAG;IAC7B,MAAM,EAAE,SAAS;CAClB,CAAA;AAED;;;GAGG;AACH,MAAM,wBAAwB,GAAG,CAC/B,SAAwC,EAAE,EAC1C,EAAE;IACF,MAAM,kBAAkB,GAAG,EAAE,wBAAwB,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,CAAA;IACzE,OAAO,IAAA,6BAAgB,EAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;AACrD,CAAC,CAAA;AAyE2B,4DAAwB;AAxDpD;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,CAIzB,KAAuC,EACvC,SAA2C,EAAE,EAC7C,EAAE;IACF,MAAM,SAAS,GAAG,GAAG,EAAE;QACrB,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,OAAO,KAAK,EAAE,CAAA;QAChB,CAAC;QACD,OAAO,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4
4
  "description": "Functional models is ooey gooey framework for building and using awesome models EVERYWHERE.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
8
- "build": "rm -Rf ./dist && tsc && cp package.json ./dist && cp README.md ./dist",
9
- "build:docs": "npx typedoc --out ./buildDocs ./src/index.ts",
10
- "build:watch": "nodemon -e '*' --watch ./src --exec npm run build",
8
+ "mocha": "mocha -r tsx",
9
+ "test": "mocha -r tsx --extensions ts,tsx 'test/**/*.{ts,tsx}'",
10
+ "test:coverage": "c8 --all --reporter cobertura --reporter text --reporter lcov --reporter html npm run test",
11
+ "test:watch": "nodemon -e '*' --watch test --watch src --exec npm run test:coverage",
11
12
  "commit": "cz",
12
- "coverage": "nyc --all --reporter=lcov npm test",
13
- "dist": "npm run build && npm run build:docs && cd dist && npm publish && cd ../knowledge-mcp && npm run dist",
14
- "eslint": "eslint . --fix",
15
13
  "feature-tests": "./node_modules/.bin/cucumber-js -p default",
16
- "mocha": "mocha -r tsx",
14
+ "coverage": "nyc --all --reporter=lcov npm test",
15
+ "build": "rm -Rf ./dist && tsc && cp package.json ./dist && cp README.md ./dist",
16
+ "build:watch": "nodemon -e '*' --watch ./src --exec npm run build",
17
+ "build:docs": "npx typedoc --out ./buildDocs ./src/index.ts",
17
18
  "prettier": "prettier --write .",
18
19
  "prettier:check": "prettier -c .",
19
- "test": "mocha -r tsx --extensions ts,tsx 'test/**/*.{ts,tsx}'",
20
- "test:coverage": "c8 --all --reporter cobertura --reporter text --reporter lcov --reporter html npm run test",
21
- "test:watch": "nodemon -e '*' --watch test --watch src --exec npm run test:coverage"
20
+ "eslint": "eslint . --fix",
21
+ "dist": "npm run build && cd dist && npm publish"
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",
package/types.d.ts CHANGED
@@ -29,7 +29,7 @@ type JsonObj = Readonly<{
29
29
  /**
30
30
  * A description of valid json values.
31
31
  */
32
- type JsonAble = Arrayable<JsonObj> | readonly (number | string | boolean)[] | readonly JsonAble[] | number | string | boolean | null | undefined;
32
+ type JsonAble = Arrayable<JsonObj> | readonly (number | string | boolean)[] | number | string | boolean | null | undefined;
33
33
  /**
34
34
  * This is a fully Json compliant version of a DataDescription
35
35
  */
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAqmBA;;GAEG;AACH,IAAK,SAMJ;AAND,WAAK,SAAS;IACZ,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;IACrB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;AACnB,CAAC,EANI,SAAS,yBAAT,SAAS,QAMb;AAoTD;;;GAGG;AACH,IAAK,YAaJ;AAbD,WAAK,YAAY;IACf,qCAAqB,CAAA;IACrB,6BAAa,CAAA;IACb,qCAAqB,CAAA;IACrB,+BAAe,CAAA;IACf,iDAAiC,CAAA;IACjC,mCAAmB,CAAA;IACnB,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;IACjB,+BAAe,CAAA;IACf,mCAAmB,CAAA;AACrB,CAAC,EAbI,YAAY,4BAAZ,YAAY,QAahB;AAED;;GAEG;AACH,IAAK,kBAMJ;AAND,WAAK,kBAAkB;IACrB,yCAAmB,CAAA;IACnB,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,yCAAmB,CAAA;AACrB,CAAC,EANI,kBAAkB,kCAAlB,kBAAkB,QAMtB"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAmmBA;;GAEG;AACH,IAAK,SAMJ;AAND,WAAK,SAAS;IACZ,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;IACrB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;AACnB,CAAC,EANI,SAAS,yBAAT,SAAS,QAMb;AAoTD;;;GAGG;AACH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