remult 0.22.8 → 0.22.9

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 (39) hide show
  1. package/esm/internals.d.ts +7 -0
  2. package/esm/internals.js +5 -0
  3. package/esm/src/remult3/Fields.d.ts +52 -0
  4. package/esm/src/remult3/Fields.js +195 -0
  5. package/esm/src/remult3/IdEntity.d.ts +4 -0
  6. package/esm/src/remult3/IdEntity.js +10 -0
  7. package/esm/src/remult3/RepositoryImplementation.d.ts +1 -1
  8. package/esm/src/remult3/RepositoryImplementation.js +2 -1
  9. package/esm/src/remult3/columnInfo.d.ts +6 -0
  10. package/esm/src/remult3/columnInfo.js +1 -0
  11. package/esm/src/remult3/relation-loader-types.d.ts +7 -0
  12. package/esm/src/remult3/relation-loader-types.js +1 -0
  13. package/esm/src/remult3/relation-loader.d.ts +40 -0
  14. package/esm/src/remult3/relation-loader.js +142 -0
  15. package/esm/src/remult3/relationInfoMember.d.ts +4 -0
  16. package/esm/src/remult3/relationInfoMember.js +4 -0
  17. package/esm/src/remult3/repository-internals.d.ts +14 -0
  18. package/esm/src/remult3/repository-internals.js +7 -0
  19. package/esm/src/server-action.js +1 -1
  20. package/internals.d.ts +7 -0
  21. package/internals.js +15 -0
  22. package/package.json +1 -1
  23. package/src/remult3/Fields.d.ts +52 -0
  24. package/src/remult3/Fields.js +259 -0
  25. package/src/remult3/IdEntity.d.ts +4 -0
  26. package/src/remult3/IdEntity.js +18 -0
  27. package/src/remult3/RepositoryImplementation.d.ts +1 -1
  28. package/src/remult3/RepositoryImplementation.js +3 -1
  29. package/src/remult3/columnInfo.d.ts +6 -0
  30. package/src/remult3/columnInfo.js +2 -0
  31. package/src/remult3/relation-loader-types.d.ts +7 -0
  32. package/src/remult3/relation-loader-types.js +2 -0
  33. package/src/remult3/relation-loader.d.ts +40 -0
  34. package/src/remult3/relation-loader.js +219 -0
  35. package/src/remult3/relationInfoMember.d.ts +4 -0
  36. package/src/remult3/relationInfoMember.js +8 -0
  37. package/src/remult3/repository-internals.d.ts +14 -0
  38. package/src/remult3/repository-internals.js +11 -0
  39. package/src/server-action.js +1 -1
@@ -0,0 +1,259 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkTarget = exports.Field = exports.Relations = exports.Fields = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var cuid2_1 = require("@paralleldrive/cuid2");
6
+ var uuid_1 = require("uuid");
7
+ var valueConverters_1 = require("../valueConverters");
8
+ var RepositoryImplementation_1 = require("./RepositoryImplementation");
9
+ var relationInfoMember_1 = require("./relationInfoMember");
10
+ var Fields = /** @class */ (function () {
11
+ function Fields() {
12
+ }
13
+ /**
14
+ * Stored as a JSON.stringify - to store as json use Fields.json
15
+ */
16
+ Fields.object = function () {
17
+ var options = [];
18
+ for (var _i = 0; _i < arguments.length; _i++) {
19
+ options[_i] = arguments[_i];
20
+ }
21
+ return Field.apply(void 0, tslib_1.__spreadArray([undefined], tslib_1.__read(options), false));
22
+ };
23
+ Fields.json = function () {
24
+ var options = [];
25
+ for (var _i = 0; _i < arguments.length; _i++) {
26
+ options[_i] = arguments[_i];
27
+ }
28
+ return Field.apply(void 0, tslib_1.__spreadArray([undefined,
29
+ {
30
+ valueConverter: {
31
+ fieldTypeInDb: 'json',
32
+ },
33
+ }], tslib_1.__read(options), false));
34
+ };
35
+ Fields.dateOnly = function () {
36
+ var options = [];
37
+ for (var _i = 0; _i < arguments.length; _i++) {
38
+ options[_i] = arguments[_i];
39
+ }
40
+ return Field.apply(void 0, tslib_1.__spreadArray([function () { return Date; },
41
+ {
42
+ valueConverter: valueConverters_1.ValueConverters.DateOnly,
43
+ }], tslib_1.__read(options), false));
44
+ };
45
+ Fields.date = function () {
46
+ var options = [];
47
+ for (var _i = 0; _i < arguments.length; _i++) {
48
+ options[_i] = arguments[_i];
49
+ }
50
+ return Field.apply(void 0, tslib_1.__spreadArray([function () { return Date; }], tslib_1.__read(options), false));
51
+ };
52
+ Fields.integer = function () {
53
+ var options = [];
54
+ for (var _i = 0; _i < arguments.length; _i++) {
55
+ options[_i] = arguments[_i];
56
+ }
57
+ return Field.apply(void 0, tslib_1.__spreadArray([function () { return Number; },
58
+ {
59
+ valueConverter: valueConverters_1.ValueConverters.Integer,
60
+ }], tslib_1.__read(options), false));
61
+ };
62
+ Fields.autoIncrement = function () {
63
+ var options = [];
64
+ for (var _i = 0; _i < arguments.length; _i++) {
65
+ options[_i] = arguments[_i];
66
+ }
67
+ return Field.apply(void 0, tslib_1.__spreadArray([function () { return Number; },
68
+ {
69
+ allowApiUpdate: false,
70
+ dbReadOnly: true,
71
+ valueConverter: tslib_1.__assign(tslib_1.__assign({}, valueConverters_1.ValueConverters.Integer), { fieldTypeInDb: 'autoincrement' }),
72
+ }], tslib_1.__read(options), false));
73
+ };
74
+ Fields.number = function () {
75
+ var options = [];
76
+ for (var _i = 0; _i < arguments.length; _i++) {
77
+ options[_i] = arguments[_i];
78
+ }
79
+ return Field.apply(void 0, tslib_1.__spreadArray([function () { return Number; }], tslib_1.__read(options), false));
80
+ };
81
+ Fields.createdAt = function () {
82
+ var options = [];
83
+ for (var _i = 0; _i < arguments.length; _i++) {
84
+ options[_i] = arguments[_i];
85
+ }
86
+ return Field.apply(void 0, tslib_1.__spreadArray([function () { return Date; },
87
+ {
88
+ allowApiUpdate: false,
89
+ saving: function (_, _a, ref) {
90
+ var isNew = _a.isNew;
91
+ if (isNew)
92
+ ref.value = new Date();
93
+ },
94
+ }], tslib_1.__read(options), false));
95
+ };
96
+ Fields.updatedAt = function () {
97
+ var options = [];
98
+ for (var _i = 0; _i < arguments.length; _i++) {
99
+ options[_i] = arguments[_i];
100
+ }
101
+ return Field.apply(void 0, tslib_1.__spreadArray([function () { return Date; },
102
+ {
103
+ allowApiUpdate: false,
104
+ saving: function (_, _1, ref) {
105
+ ref.value = new Date();
106
+ },
107
+ }], tslib_1.__read(options), false));
108
+ };
109
+ Fields.uuid = function () {
110
+ var options = [];
111
+ for (var _i = 0; _i < arguments.length; _i++) {
112
+ options[_i] = arguments[_i];
113
+ }
114
+ return Field.apply(void 0, tslib_1.__spreadArray([function () { return String; },
115
+ {
116
+ allowApiUpdate: false,
117
+ defaultValue: function () { return (0, uuid_1.v4)(); },
118
+ saving: function (_, _1, r) {
119
+ if (!r.value)
120
+ r.value = (0, uuid_1.v4)();
121
+ },
122
+ }], tslib_1.__read(options), false));
123
+ };
124
+ Fields.cuid = function () {
125
+ var options = [];
126
+ for (var _i = 0; _i < arguments.length; _i++) {
127
+ options[_i] = arguments[_i];
128
+ }
129
+ return Field.apply(void 0, tslib_1.__spreadArray([function () { return String; },
130
+ {
131
+ allowApiUpdate: false,
132
+ defaultValue: function () { return (0, cuid2_1.createId)(); },
133
+ saving: function (_, _1, r) {
134
+ if (!r.value)
135
+ r.value = (0, cuid2_1.createId)();
136
+ },
137
+ }], tslib_1.__read(options), false));
138
+ };
139
+ Fields.string = function () {
140
+ var options = [];
141
+ for (var _i = 0; _i < arguments.length; _i++) {
142
+ options[_i] = arguments[_i];
143
+ }
144
+ return Field.apply(void 0, tslib_1.__spreadArray([function () { return String; }], tslib_1.__read(options), false));
145
+ };
146
+ Fields.boolean = function () {
147
+ var options = [];
148
+ for (var _i = 0; _i < arguments.length; _i++) {
149
+ options[_i] = arguments[_i];
150
+ }
151
+ return Field.apply(void 0, tslib_1.__spreadArray([function () { return Boolean; }], tslib_1.__read(options), false));
152
+ };
153
+ return Fields;
154
+ }());
155
+ exports.Fields = Fields;
156
+ var Relations = /** @class */ (function () {
157
+ function Relations() {
158
+ }
159
+ Relations.toOne = function (toEntityType, options) {
160
+ var _a, _b;
161
+ var op = (typeof options === 'string'
162
+ ? { field: options }
163
+ : !options
164
+ ? {}
165
+ : options);
166
+ if (!op.field && !op.fields && !op.findOptions)
167
+ return Field(toEntityType, tslib_1.__assign(tslib_1.__assign({}, op), (_a = {}, _a[relationInfoMember_1.relationInfoMember] = {
168
+ //field,
169
+ toType: toEntityType,
170
+ type: 'reference',
171
+ }, _a)));
172
+ return Field(function () { return undefined; }, tslib_1.__assign(tslib_1.__assign({}, op), (_b = { serverExpression: function () { return undefined; } }, _b[relationInfoMember_1.relationInfoMember] = {
173
+ //field,
174
+ toType: toEntityType,
175
+ type: 'toOne',
176
+ }, _b)));
177
+ };
178
+ Relations.toMany = function (toEntityType, options) {
179
+ var _a;
180
+ var op = (typeof options === 'string'
181
+ ? { field: options }
182
+ : options);
183
+ return Field(function () { return undefined; }, tslib_1.__assign(tslib_1.__assign({}, op), (_a = { serverExpression: function () { return undefined; } }, _a[relationInfoMember_1.relationInfoMember] = {
184
+ //field,
185
+ toType: toEntityType,
186
+ type: 'toMany',
187
+ }, _a)));
188
+ };
189
+ return Relations;
190
+ }());
191
+ exports.Relations = Relations;
192
+ /**Decorates fields that should be used as fields.
193
+ * for more info see: [Field Types](https://remult.dev/docs/field-types.html)
194
+ *
195
+ * FieldOptions can be set in two ways:
196
+ * @example
197
+ * // as an object
198
+ * @Fields.string({ includeInApi:false })
199
+ * title='';
200
+ * @example
201
+ * // as an arrow function that receives `remult` as a parameter
202
+ * @Fields.string((options,remult) => options.includeInApi = true)
203
+ * title='';
204
+ */
205
+ function Field(valueType) {
206
+ // import ANT!!!! if you call this in another decorator, make sure to set It's return type correctly with the | undefined
207
+ var options = [];
208
+ for (var _i = 1; _i < arguments.length; _i++) {
209
+ options[_i - 1] = arguments[_i];
210
+ }
211
+ return function (target, context, c) {
212
+ var key = typeof context === 'string' ? context : context.name.toString();
213
+ var factory = function (remult) {
214
+ var r = (0, RepositoryImplementation_1.buildOptions)(options, remult);
215
+ if (!r.valueType && valueType) {
216
+ r.valueType = valueType();
217
+ }
218
+ if (!r.key) {
219
+ r.key = key;
220
+ }
221
+ if (!r.dbName)
222
+ r.dbName = r.key;
223
+ var type = r.valueType;
224
+ if (!type) {
225
+ type = Reflect.getMetadata('design:type', target, key);
226
+ r.valueType = type;
227
+ }
228
+ if (!r.target)
229
+ r.target = target;
230
+ return r;
231
+ };
232
+ checkTarget(target);
233
+ var names = RepositoryImplementation_1.columnsOfType.get(target.constructor);
234
+ if (!names) {
235
+ names = [];
236
+ RepositoryImplementation_1.columnsOfType.set(target.constructor, names);
237
+ }
238
+ var set = names.find(function (x) { return x.key == key; });
239
+ if (!set)
240
+ names.push({
241
+ key: key,
242
+ settings: factory,
243
+ });
244
+ else {
245
+ var prev_1 = set.settings;
246
+ set.settings = function (c) {
247
+ var prevO = prev_1(c);
248
+ var curr = factory(c);
249
+ return Object.assign(prevO, curr);
250
+ };
251
+ }
252
+ };
253
+ }
254
+ exports.Field = Field;
255
+ function checkTarget(target) {
256
+ if (!target)
257
+ throw new Error("Set the 'experimentalDecorators:true' option in your 'tsconfig' or 'jsconfig' (target undefined)");
258
+ }
259
+ exports.checkTarget = checkTarget;
@@ -0,0 +1,4 @@
1
+ import { EntityBase } from './RepositoryImplementation';
2
+ export declare class IdEntity extends EntityBase {
3
+ id: string;
4
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdEntity = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var Fields_1 = require("./Fields");
6
+ var RepositoryImplementation_1 = require("./RepositoryImplementation");
7
+ var IdEntity = /** @class */ (function (_super) {
8
+ tslib_1.__extends(IdEntity, _super);
9
+ function IdEntity() {
10
+ return _super !== null && _super.apply(this, arguments) || this;
11
+ }
12
+ tslib_1.__decorate([
13
+ Fields_1.Fields.uuid(),
14
+ tslib_1.__metadata("design:type", String)
15
+ ], IdEntity.prototype, "id", void 0);
16
+ return IdEntity;
17
+ }(RepositoryImplementation_1.EntityBase));
18
+ exports.IdEntity = IdEntity;
@@ -98,7 +98,7 @@ declare abstract class rowHelperBase<T> {
98
98
  __validateEntity(): Promise<void>;
99
99
  __performColumnAndEntityValidations(): Promise<void>;
100
100
  toApiJson(includeRelatedEntities?: boolean): any;
101
- _updateEntityBasedOnApi(body: any): Promise<void>;
101
+ _updateEntityBasedOnApi(body: any, ignoreApiAllowed?: boolean): Promise<void>;
102
102
  }
103
103
  export declare class rowHelperImplementation<T> extends rowHelperBase<T> implements EntityRef<T> {
104
104
  private info;
@@ -1332,7 +1332,8 @@ var rowHelperBase = /** @class */ (function () {
1332
1332
  }
1333
1333
  return result;
1334
1334
  };
1335
- rowHelperBase.prototype._updateEntityBasedOnApi = function (body) {
1335
+ rowHelperBase.prototype._updateEntityBasedOnApi = function (body, ignoreApiAllowed) {
1336
+ if (ignoreApiAllowed === void 0) { ignoreApiAllowed = false; }
1336
1337
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1337
1338
  var keys, _a, _b, col, lu;
1338
1339
  var e_22, _c;
@@ -1347,6 +1348,7 @@ var rowHelperBase = /** @class */ (function () {
1347
1348
  if (col.includeInApi === undefined ||
1348
1349
  this.remult.isAllowed(col.includeInApi)) {
1349
1350
  if (!this.remult ||
1351
+ ignoreApiAllowed ||
1350
1352
  col.allowApiUpdate === undefined ||
1351
1353
  this.remult.isAllowedForInstance(this.instance, col.allowApiUpdate)) {
1352
1354
  lu = this.lookups.get(col.key);
@@ -0,0 +1,6 @@
1
+ import type { FieldOptions } from '../column-interfaces';
2
+ import { Remult } from '../context';
3
+ export interface columnInfo {
4
+ key: string;
5
+ settings: (remult: Remult) => FieldOptions;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import type { ClassType } from '../../classType';
2
+ import type { EntityMetadata, FindOptions } from './remult3';
3
+ export interface RelationLoaderHelper<toEntity> {
4
+ metadata: EntityMetadata<toEntity>;
5
+ entityType: ClassType<toEntity>;
6
+ find(options: FindOptions<toEntity>): Promise<toEntity[]>;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,40 @@
1
+ import type { RelationLoaderHelper } from './relation-loader-types';
2
+ import type { FindOptions } from './remult3';
3
+ export declare class RelationLoader {
4
+ entityLoaders: Map<any, EntityLoader>;
5
+ promises: any[];
6
+ load(rel: RelationLoaderHelper<any>, findOptions: FindOptions<any>): Promise<any[]>;
7
+ constructor();
8
+ resolveAll(): Promise<void>;
9
+ }
10
+ declare class EntityLoader {
11
+ private rel;
12
+ queries: Map<string, QueryVariation>;
13
+ find(findOptions: FindOptions<any>): Promise<any[]>;
14
+ constructor(rel: RelationLoaderHelper<any>);
15
+ }
16
+ declare class QueryVariation {
17
+ private rel;
18
+ find(findOptions: FindOptions<any>, where: any): Promise<any[]>;
19
+ constructor(rel: RelationLoaderHelper<any>);
20
+ resolve(): void;
21
+ pendingInStatements: Map<string, PendingInStatements>;
22
+ whereVariations: Map<string, {
23
+ result: Promise<any[]>;
24
+ }>;
25
+ }
26
+ declare class PendingInStatements {
27
+ private rel;
28
+ private key;
29
+ private options;
30
+ resolve(): void;
31
+ find(where: any): Promise<any[]>;
32
+ values: Map<any, {
33
+ value: any;
34
+ resolve: (value: any[]) => void;
35
+ reject: (error: any) => void;
36
+ result: Promise<any[]>;
37
+ }>;
38
+ constructor(rel: RelationLoaderHelper<any>, key: string, options: FindOptions<any>);
39
+ }
40
+ export {};
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RelationLoader = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var rest_data_provider_1 = require("../data-providers/rest-data-provider");
6
+ var getEntityRef_1 = require("./getEntityRef");
7
+ var relationInfoMember_1 = require("./relationInfoMember");
8
+ var RelationLoader = /** @class */ (function () {
9
+ function RelationLoader() {
10
+ this.entityLoaders = new Map();
11
+ this.promises = [];
12
+ }
13
+ RelationLoader.prototype.load = function (rel, findOptions) {
14
+ var e = this.entityLoaders.get(rel.entityType);
15
+ if (!e) {
16
+ this.entityLoaders.set(rel.entityType, (e = new EntityLoader(rel)));
17
+ }
18
+ var p = e.find(findOptions);
19
+ this.promises.push(p);
20
+ return p;
21
+ };
22
+ RelationLoader.prototype.resolveAll = function () {
23
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
24
+ var _a, _b, entity, _c, _d, variation, x;
25
+ var e_1, _e, e_2, _f;
26
+ return tslib_1.__generator(this, function (_g) {
27
+ switch (_g.label) {
28
+ case 0:
29
+ try {
30
+ for (_a = tslib_1.__values(this.entityLoaders.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
31
+ entity = _b.value;
32
+ try {
33
+ for (_c = (e_2 = void 0, tslib_1.__values(entity.queries.values())), _d = _c.next(); !_d.done; _d = _c.next()) {
34
+ variation = _d.value;
35
+ variation.resolve();
36
+ }
37
+ }
38
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
39
+ finally {
40
+ try {
41
+ if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
42
+ }
43
+ finally { if (e_2) throw e_2.error; }
44
+ }
45
+ }
46
+ }
47
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
48
+ finally {
49
+ try {
50
+ if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
51
+ }
52
+ finally { if (e_1) throw e_1.error; }
53
+ }
54
+ if (this.promises.length === 0)
55
+ return [2 /*return*/];
56
+ x = this.promises;
57
+ this.promises = [];
58
+ return [4 /*yield*/, Promise.all(x)];
59
+ case 1:
60
+ _g.sent();
61
+ return [4 /*yield*/, this.resolveAll()];
62
+ case 2:
63
+ _g.sent();
64
+ return [2 /*return*/];
65
+ }
66
+ });
67
+ });
68
+ };
69
+ return RelationLoader;
70
+ }());
71
+ exports.RelationLoader = RelationLoader;
72
+ var EntityLoader = /** @class */ (function () {
73
+ function EntityLoader(rel) {
74
+ this.rel = rel;
75
+ this.queries = new Map();
76
+ }
77
+ EntityLoader.prototype.find = function (findOptions) {
78
+ var _a = (0, rest_data_provider_1.findOptionsToJson)(findOptions, this.rel.metadata), where = _a.where, options = tslib_1.__rest(_a, ["where"]);
79
+ var optionKeys = JSON.stringify(options);
80
+ var q = this.queries.get(optionKeys);
81
+ if (!q) {
82
+ this.queries.set(optionKeys, (q = new QueryVariation(this.rel)));
83
+ }
84
+ return q.find(findOptions, where);
85
+ };
86
+ return EntityLoader;
87
+ }());
88
+ var QueryVariation = /** @class */ (function () {
89
+ function QueryVariation(rel) {
90
+ this.rel = rel;
91
+ this.pendingInStatements = new Map();
92
+ this.whereVariations = new Map();
93
+ }
94
+ QueryVariation.prototype.find = function (findOptions, where) {
95
+ var whereKey = JSON.stringify(where);
96
+ var w = this.whereVariations.get(whereKey);
97
+ if (!w) {
98
+ var keys = Object.keys(where);
99
+ if (keys.length === 1 &&
100
+ typeof where[keys[0]] !== 'object' &&
101
+ !findOptions.limit // because merging calls in that case may bring non more rows than the limit
102
+ ) {
103
+ var inVariation = this.pendingInStatements.get(keys[0]);
104
+ if (!inVariation) {
105
+ this.pendingInStatements.set(keys[0], (inVariation = new PendingInStatements(this.rel, keys[0], findOptions)));
106
+ }
107
+ this.whereVariations.set(whereKey, (w = {
108
+ result: inVariation.find(where),
109
+ }));
110
+ }
111
+ else {
112
+ this.whereVariations.set(whereKey, (w = {
113
+ result: this.rel.find(findOptions),
114
+ }));
115
+ }
116
+ }
117
+ return w.result;
118
+ };
119
+ QueryVariation.prototype.resolve = function () {
120
+ var e_3, _a;
121
+ var statements = tslib_1.__spreadArray([], tslib_1.__read(this.pendingInStatements.values()), false);
122
+ this.pendingInStatements.clear();
123
+ try {
124
+ for (var statements_1 = tslib_1.__values(statements), statements_1_1 = statements_1.next(); !statements_1_1.done; statements_1_1 = statements_1.next()) {
125
+ var statement = statements_1_1.value;
126
+ statement.resolve();
127
+ }
128
+ }
129
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
130
+ finally {
131
+ try {
132
+ if (statements_1_1 && !statements_1_1.done && (_a = statements_1.return)) _a.call(statements_1);
133
+ }
134
+ finally { if (e_3) throw e_3.error; }
135
+ }
136
+ };
137
+ return QueryVariation;
138
+ }());
139
+ var PendingInStatements = /** @class */ (function () {
140
+ function PendingInStatements(rel, key, options) {
141
+ this.rel = rel;
142
+ this.key = key;
143
+ this.options = options;
144
+ this.values = new Map();
145
+ }
146
+ PendingInStatements.prototype.resolve = function () {
147
+ var _a;
148
+ var _this = this;
149
+ var values = tslib_1.__spreadArray([], tslib_1.__read(this.values.values()), false);
150
+ if (values.length == 1) {
151
+ this.rel.find(this.options).then(values[0].resolve, values[0].reject);
152
+ return;
153
+ }
154
+ var op = tslib_1.__assign({}, this.options);
155
+ op.where = (_a = {}, _a[this.key] = values.map(function (v) { return v.value; }), _a);
156
+ this.rel.find(op).then(function (val) {
157
+ var e_4, _a;
158
+ var _loop_1 = function (value) {
159
+ value.resolve(val.filter(function (x) {
160
+ var ref = (0, getEntityRef_1.getEntityRef)(x);
161
+ var field = ref.fields.find(_this.key);
162
+ var rel = (0, relationInfoMember_1.getRelationInfo)(field.metadata.options);
163
+ var val = (rel === null || rel === void 0 ? void 0 : rel.type) === 'reference'
164
+ ? field.getId()
165
+ : x[_this.key];
166
+ return value.value == val;
167
+ }));
168
+ };
169
+ try {
170
+ for (var _b = tslib_1.__values(_this.values.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
171
+ var value = _c.value;
172
+ _loop_1(value);
173
+ }
174
+ }
175
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
176
+ finally {
177
+ try {
178
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
179
+ }
180
+ finally { if (e_4) throw e_4.error; }
181
+ }
182
+ }, function (err) {
183
+ var e_5, _a;
184
+ try {
185
+ for (var _b = tslib_1.__values(_this.values.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
186
+ var value = _c.value;
187
+ value.reject(err);
188
+ }
189
+ }
190
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
191
+ finally {
192
+ try {
193
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
194
+ }
195
+ finally { if (e_5) throw e_5.error; }
196
+ }
197
+ });
198
+ };
199
+ PendingInStatements.prototype.find = function (where) {
200
+ var val = where[this.key];
201
+ var valHandler = this.values.get(val);
202
+ if (!valHandler) {
203
+ var resolve_1;
204
+ var reject_1;
205
+ var result = new Promise(function (resolve1, reject1) {
206
+ resolve_1 = resolve1;
207
+ reject_1 = reject1;
208
+ });
209
+ this.values.set(val, (valHandler = {
210
+ value: val,
211
+ resolve: resolve_1,
212
+ reject: reject_1,
213
+ result: result,
214
+ }));
215
+ }
216
+ return valHandler.result;
217
+ };
218
+ return PendingInStatements;
219
+ }());
@@ -0,0 +1,4 @@
1
+ import type { FieldOptions } from '../column-interfaces';
2
+ import type { RelationInfo } from './remult3';
3
+ export declare const relationInfoMember: unique symbol;
4
+ export declare function getRelationInfo(options: FieldOptions): RelationInfo;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRelationInfo = exports.relationInfoMember = void 0;
4
+ exports.relationInfoMember = Symbol('relationInfo');
5
+ function getRelationInfo(options) {
6
+ return options === null || options === void 0 ? void 0 : options[exports.relationInfoMember];
7
+ }
8
+ exports.getRelationInfo = getRelationInfo;
@@ -0,0 +1,14 @@
1
+ import type { EntityDataProviderFindOptions } from '../data-interfaces';
2
+ import type { Filter } from '../filter/filter-interfaces';
3
+ import type { EntityFilter, EntityOrderBy, FindOptions, LoadOptions, Repository } from './remult3';
4
+ export interface RepositoryInternal<entityType> {
5
+ createAfterFilter(orderBy: EntityOrderBy<entityType>, lastRow: entityType): Promise<EntityFilter<entityType>>;
6
+ fromJsonArray(jsonItems: any[], loadOptions: LoadOptions<entityType>): Promise<entityType[]>;
7
+ buildEntityDataProviderFindOptions(options: FindOptions<entityType>): Promise<EntityDataProviderFindOptions>;
8
+ translateWhereToFilter(where: EntityFilter<entityType>): Promise<Filter>;
9
+ getCachedById(id: any, doNotLoadIfNotFound: boolean): entityType;
10
+ getCachedByIdAsync(id: any, doNotLoadIfNotFound: boolean): Promise<entityType>;
11
+ addToCache(item: entityType): any;
12
+ }
13
+ export declare function getRepositoryInternals<entityType>(repo: Repository<entityType>): RepositoryInternal<entityType>;
14
+ export declare const getInternalKey = "getInternal";
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInternalKey = exports.getRepositoryInternals = void 0;
4
+ function getRepositoryInternals(repo) {
5
+ var x = repo;
6
+ if (typeof x[exports.getInternalKey] === 'function')
7
+ return x[exports.getInternalKey]();
8
+ throw Error('Error getting repository internal from ' + repo);
9
+ }
10
+ exports.getRepositoryInternals = getRepositoryInternals;
11
+ exports.getInternalKey = 'getInternal';
@@ -439,7 +439,7 @@ function BackendMethod(options) {
439
439
  http])];
440
440
  case 4:
441
441
  r = _h.sent();
442
- return [4 /*yield*/, defs._updateEntityBasedOnApi(r.rowInfo.data)];
442
+ return [4 /*yield*/, defs._updateEntityBasedOnApi(r.rowInfo.data, true)];
443
443
  case 5:
444
444
  _h.sent();
445
445
  return [2 /*return*/, r.result];