remult 3.0.3 → 3.0.5-next.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/esm/src/context.js +5 -4
- package/esm/src/filter/filter-interfaces.js +1 -1
- package/esm/src/validators.js +1 -1
- package/package.json +1 -1
- package/src/column-interfaces.d.ts +4 -1
- package/src/context.js +5 -5
- package/src/filter/filter-interfaces.js +1 -1
- package/src/validators.d.ts +1 -1
- package/src/validators.js +1 -1
package/esm/src/context.js
CHANGED
|
@@ -10,6 +10,7 @@ import { verifyFieldRelationInfo } from './remult3/relationInfoMember.js';
|
|
|
10
10
|
import { remultStatic, resetFactory } from './remult-static.js';
|
|
11
11
|
import { initDataProvider } from '../server/initDataProvider.js';
|
|
12
12
|
import { SubscribableImp } from './remult3/SubscribableImp.js';
|
|
13
|
+
import { getEntitySettings } from './remult3/getEntityRef.js';
|
|
13
14
|
export class RemultAsyncLocalStorage {
|
|
14
15
|
remultObjectStorage;
|
|
15
16
|
static enable() {
|
|
@@ -65,10 +66,10 @@ export class Remult {
|
|
|
65
66
|
* @param dataProvider - an optional alternative data provider to use. Useful for writing to offline storage or an alternative data provider
|
|
66
67
|
*/
|
|
67
68
|
repo = (entity, dataProvider) => {
|
|
68
|
-
|
|
69
|
+
let info = getEntitySettings(entity)(remult);
|
|
69
70
|
if (dataProvider === undefined) {
|
|
70
|
-
if (info?.
|
|
71
|
-
const d = info.
|
|
71
|
+
if (info?.dataProvider) {
|
|
72
|
+
const d = info.dataProvider(this.dataProvider);
|
|
72
73
|
if (d instanceof Promise) {
|
|
73
74
|
dataProvider = new DataProviderPromiseWrapper(d);
|
|
74
75
|
}
|
|
@@ -85,7 +86,7 @@ export class Remult {
|
|
|
85
86
|
this.repCache.set(dataProvider, (dpCache = new Map()));
|
|
86
87
|
let r = dpCache.get(entity);
|
|
87
88
|
if (!r) {
|
|
88
|
-
dpCache.set(entity, (r = new RepositoryImplementation(entity, this, dataProvider,
|
|
89
|
+
dpCache.set(entity, (r = new RepositoryImplementation(entity, this, dataProvider, createOldEntity(entity, this))));
|
|
89
90
|
verifyFieldRelationInfo(r, this, dataProvider);
|
|
90
91
|
}
|
|
91
92
|
return r;
|
package/esm/src/validators.js
CHANGED
|
@@ -67,7 +67,7 @@ export class Validators {
|
|
|
67
67
|
*/
|
|
68
68
|
static enum = createValueValidatorWithArgs((value, enumObj) => Object.values(enumObj).includes(value), (enumObj) => `Value must be one of ${getEnumValues(enumObj).join(', ')}`);
|
|
69
69
|
/**
|
|
70
|
-
* Validator to check if a related value exists in the database.
|
|
70
|
+
* Validator to check if a related value exists in the database. By side-effect it loads relation data so it is directly available in [lifecycle hooks](https://remult.dev/docs/lifecycle-hooks)
|
|
71
71
|
*/
|
|
72
72
|
static relationExists = createValidator(async (_, e) => {
|
|
73
73
|
if (e.valueIsNull())
|
package/package.json
CHANGED
|
@@ -9,7 +9,10 @@ export interface FieldOptions<entityType = unknown, valueType = unknown> {
|
|
|
9
9
|
caption?: string;
|
|
10
10
|
/** If it can store null in the database */
|
|
11
11
|
allowNull?: boolean;
|
|
12
|
-
/** If a value is required
|
|
12
|
+
/** If a value is required. Short-cut to say `validate: Validators.required`.
|
|
13
|
+
@see option [validate](https://remult.dev/docs/ref_field#validate) below
|
|
14
|
+
@see validator [required](https://remult.dev/docs/ref_validators#required)
|
|
15
|
+
*/
|
|
13
16
|
required?: boolean;
|
|
14
17
|
/**
|
|
15
18
|
* Specifies whether this field should be included in the API. This can be configured
|
package/src/context.js
CHANGED
|
@@ -18,6 +18,7 @@ var relationInfoMember_js_1 = require("./remult3/relationInfoMember.js");
|
|
|
18
18
|
var remult_static_js_1 = require("./remult-static.js");
|
|
19
19
|
var initDataProvider_js_1 = require("../server/initDataProvider.js");
|
|
20
20
|
var SubscribableImp_js_1 = require("./remult3/SubscribableImp.js");
|
|
21
|
+
var getEntityRef_js_1 = require("./remult3/getEntityRef.js");
|
|
21
22
|
var RemultAsyncLocalStorage = /** @class */ (function () {
|
|
22
23
|
function RemultAsyncLocalStorage(remultObjectStorage) {
|
|
23
24
|
this.remultObjectStorage = remultObjectStorage;
|
|
@@ -83,11 +84,10 @@ var Remult = /** @class */ (function () {
|
|
|
83
84
|
* @param dataProvider - an optional alternative data provider to use. Useful for writing to offline storage or an alternative data provider
|
|
84
85
|
*/
|
|
85
86
|
this.repo = function (entity, dataProvider) {
|
|
86
|
-
var
|
|
87
|
-
var info = (0, RepositoryImplementation_js_1.createOldEntity)(entity, _this);
|
|
87
|
+
var info = (0, getEntityRef_js_1.getEntitySettings)(entity)(remult_proxy_js_1.remult);
|
|
88
88
|
if (dataProvider === undefined) {
|
|
89
|
-
if (
|
|
90
|
-
var d = info.
|
|
89
|
+
if (info === null || info === void 0 ? void 0 : info.dataProvider) {
|
|
90
|
+
var d = info.dataProvider(_this.dataProvider);
|
|
91
91
|
if (d instanceof Promise) {
|
|
92
92
|
dataProvider = new data_interfaces_js_1.DataProviderPromiseWrapper(d);
|
|
93
93
|
}
|
|
@@ -104,7 +104,7 @@ var Remult = /** @class */ (function () {
|
|
|
104
104
|
_this.repCache.set(dataProvider, (dpCache = new Map()));
|
|
105
105
|
var r = dpCache.get(entity);
|
|
106
106
|
if (!r) {
|
|
107
|
-
dpCache.set(entity, (r = new RepositoryImplementation_js_1.RepositoryImplementation(entity, _this, dataProvider,
|
|
107
|
+
dpCache.set(entity, (r = new RepositoryImplementation_js_1.RepositoryImplementation(entity, _this, dataProvider, (0, RepositoryImplementation_js_1.createOldEntity)(entity, _this))));
|
|
108
108
|
(0, relationInfoMember_js_1.verifyFieldRelationInfo)(r, _this, dataProvider);
|
|
109
109
|
}
|
|
110
110
|
return r;
|
package/src/validators.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare class Validators {
|
|
|
48
48
|
defaultMessage: ValueValidationMessage<unknown>;
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
51
|
-
* Validator to check if a related value exists in the database.
|
|
51
|
+
* Validator to check if a related value exists in the database. By side-effect it loads relation data so it is directly available in [lifecycle hooks](https://remult.dev/docs/lifecycle-hooks)
|
|
52
52
|
*/
|
|
53
53
|
static relationExists: Validator<unknown>;
|
|
54
54
|
/**
|
package/src/validators.js
CHANGED
|
@@ -103,7 +103,7 @@ var Validators = /** @class */ (function () {
|
|
|
103
103
|
return "Value must be one of ".concat(getEnumValues(enumObj).join(', '));
|
|
104
104
|
});
|
|
105
105
|
/**
|
|
106
|
-
* Validator to check if a related value exists in the database.
|
|
106
|
+
* Validator to check if a related value exists in the database. By side-effect it loads relation data so it is directly available in [lifecycle hooks](https://remult.dev/docs/lifecycle-hooks)
|
|
107
107
|
*/
|
|
108
108
|
Validators.relationExists = createValidator(function (_, e) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
109
109
|
var _b;
|