remult 0.16.0-exp.3 → 0.16.0-exp.6
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/index.d.ts +1 -1
- package/esm/server/expressBridge.js +19 -17
- package/esm/src/context.d.ts +2 -2
- package/esm/src/context.js +1 -1
- package/esm/src/remult-proxy.js +2 -2
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/server/expressBridge.js +39 -35
- package/src/context.d.ts +2 -2
- package/src/context.js +1 -1
- package/src/remult-proxy.js +2 -2
package/esm/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { SqlDatabase, } from './src/data-providers/sql-database';
|
|
|
12
12
|
export { CustomSqlFilterObject, CustomSqlFilterBuilder } from './src/filter/filter-consumer-bridge-to-sql-request';
|
|
13
13
|
export { JsonDataProvider, JsonEntityStorage } from './src/data-providers/json-data-provider';
|
|
14
14
|
export { Controller, BackendMethodOptions, BackendMethod, ProgressListener } from './src/server-action';
|
|
15
|
-
export { Allowed, Allow, Remult, isBackend, AllowedForInstance, EventDispatcher, EventSource, HttpProvider, Unobserve, UserInfo } from './src/context';
|
|
15
|
+
export { Allowed, Allow, Remult, RemultContext, isBackend, AllowedForInstance, EventDispatcher, EventSource, HttpProvider, Unobserve, UserInfo } from './src/context';
|
|
16
16
|
export { IdEntity } from './src/id-entity';
|
|
17
17
|
export { SortSegment, Sort } from './src/sort';
|
|
18
18
|
export { OneToMany, CompoundIdField } from './src/column';
|
|
@@ -153,23 +153,26 @@ class RemultServerImplementation {
|
|
|
153
153
|
let myRes = new ExpressResponseBridgeToDataApiResponse(res, req);
|
|
154
154
|
let remult = new Remult();
|
|
155
155
|
remult.setDataProvider(await this.dataProvider);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
user
|
|
156
|
+
await new Promise(res => {
|
|
157
|
+
remultObjectStorage.run(remult, async () => {
|
|
158
|
+
if (req) {
|
|
159
|
+
let user;
|
|
160
|
+
if (this.options.getUser)
|
|
161
|
+
user = await this.options.getUser(req);
|
|
162
|
+
else {
|
|
163
|
+
user = req['user'];
|
|
164
|
+
if (!user)
|
|
165
|
+
user = req['auth'];
|
|
166
|
+
}
|
|
167
|
+
if (user)
|
|
168
|
+
remult.setUser(user);
|
|
165
169
|
}
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
await what(remult, myReq, myRes, req);
|
|
170
|
+
if (this.options.initRequest) {
|
|
171
|
+
await this.options.initRequest(remult, req);
|
|
172
|
+
}
|
|
173
|
+
await what(remult, myReq, myRes, req);
|
|
174
|
+
res({});
|
|
175
|
+
});
|
|
173
176
|
});
|
|
174
177
|
};
|
|
175
178
|
}
|
|
@@ -177,7 +180,6 @@ class RemultServerImplementation {
|
|
|
177
180
|
async getRemult(req) {
|
|
178
181
|
let remult;
|
|
179
182
|
await this.process(async (c) => {
|
|
180
|
-
console.log("DEBUG ", c);
|
|
181
183
|
remult = c;
|
|
182
184
|
})(req, undefined);
|
|
183
185
|
return remult;
|
package/esm/src/context.d.ts
CHANGED
|
@@ -80,9 +80,9 @@ export declare class Remult {
|
|
|
80
80
|
clearAllCache(): any;
|
|
81
81
|
/** A helper callback that is called whenever an entity is created. */
|
|
82
82
|
static entityRefInit?: (ref: EntityRef<any>, row: any) => void;
|
|
83
|
-
readonly
|
|
83
|
+
readonly context: RemultContext;
|
|
84
84
|
}
|
|
85
|
-
export interface
|
|
85
|
+
export interface RemultContext {
|
|
86
86
|
}
|
|
87
87
|
export declare const allEntities: ClassType<any>[];
|
|
88
88
|
export interface ControllerOptions {
|
package/esm/src/context.js
CHANGED
|
@@ -101,7 +101,7 @@ export class Remult {
|
|
|
101
101
|
this._userChangeEvent = new EventSource();
|
|
102
102
|
/* @internal */
|
|
103
103
|
this.repCache = new Map();
|
|
104
|
-
this.
|
|
104
|
+
this.context = {};
|
|
105
105
|
if (provider && provider.getEntityDataProvider) {
|
|
106
106
|
this._dataSource = provider;
|
|
107
107
|
return;
|
package/esm/src/remult-proxy.js
CHANGED
|
@@ -7,8 +7,8 @@ export class RemultProxy {
|
|
|
7
7
|
this.remultFactory = () => defaultRemult;
|
|
8
8
|
this.repo = (...args) => this.remultFactory().repo(...args);
|
|
9
9
|
}
|
|
10
|
-
get
|
|
11
|
-
return this.instance.
|
|
10
|
+
get context() {
|
|
11
|
+
return this.instance.context;
|
|
12
12
|
}
|
|
13
13
|
get _user() {
|
|
14
14
|
return this.instance._user;
|
package/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { SqlDatabase, } from './src/data-providers/sql-database';
|
|
|
12
12
|
export { CustomSqlFilterObject, CustomSqlFilterBuilder } from './src/filter/filter-consumer-bridge-to-sql-request';
|
|
13
13
|
export { JsonDataProvider, JsonEntityStorage } from './src/data-providers/json-data-provider';
|
|
14
14
|
export { Controller, BackendMethodOptions, BackendMethod, ProgressListener } from './src/server-action';
|
|
15
|
-
export { Allowed, Allow, Remult, isBackend, AllowedForInstance, EventDispatcher, EventSource, HttpProvider, Unobserve, UserInfo } from './src/context';
|
|
15
|
+
export { Allowed, Allow, Remult, RemultContext, isBackend, AllowedForInstance, EventDispatcher, EventSource, HttpProvider, Unobserve, UserInfo } from './src/context';
|
|
16
16
|
export { IdEntity } from './src/id-entity';
|
|
17
17
|
export { SortSegment, Sort } from './src/sort';
|
|
18
18
|
export { OneToMany, CompoundIdField } from './src/column';
|
package/package.json
CHANGED
package/server/expressBridge.js
CHANGED
|
@@ -234,40 +234,45 @@ var RemultServerImplementation = /** @class */ (function () {
|
|
|
234
234
|
return [4 /*yield*/, this.dataProvider];
|
|
235
235
|
case 1:
|
|
236
236
|
_b.apply(_a, [_c.sent()]);
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
237
|
+
return [4 /*yield*/, new Promise(function (res) {
|
|
238
|
+
remultObjectStorage.run(remult, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
239
|
+
var user;
|
|
240
|
+
return tslib_1.__generator(this, function (_a) {
|
|
241
|
+
switch (_a.label) {
|
|
242
|
+
case 0:
|
|
243
|
+
if (!req) return [3 /*break*/, 4];
|
|
244
|
+
user = void 0;
|
|
245
|
+
if (!this.options.getUser) return [3 /*break*/, 2];
|
|
246
|
+
return [4 /*yield*/, this.options.getUser(req)];
|
|
247
|
+
case 1:
|
|
248
|
+
user = _a.sent();
|
|
249
|
+
return [3 /*break*/, 3];
|
|
250
|
+
case 2:
|
|
251
|
+
user = req['user'];
|
|
252
|
+
if (!user)
|
|
253
|
+
user = req['auth'];
|
|
254
|
+
_a.label = 3;
|
|
255
|
+
case 3:
|
|
256
|
+
if (user)
|
|
257
|
+
remult.setUser(user);
|
|
258
|
+
_a.label = 4;
|
|
259
|
+
case 4:
|
|
260
|
+
if (!this.options.initRequest) return [3 /*break*/, 6];
|
|
261
|
+
return [4 /*yield*/, this.options.initRequest(remult, req)];
|
|
262
|
+
case 5:
|
|
263
|
+
_a.sent();
|
|
264
|
+
_a.label = 6;
|
|
265
|
+
case 6: return [4 /*yield*/, what(remult, myReq, myRes, req)];
|
|
266
|
+
case 7:
|
|
267
|
+
_a.sent();
|
|
268
|
+
res({});
|
|
269
|
+
return [2 /*return*/];
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}); });
|
|
273
|
+
})];
|
|
274
|
+
case 2:
|
|
275
|
+
_c.sent();
|
|
271
276
|
return [2 /*return*/];
|
|
272
277
|
}
|
|
273
278
|
});
|
|
@@ -282,7 +287,6 @@ var RemultServerImplementation = /** @class */ (function () {
|
|
|
282
287
|
switch (_a.label) {
|
|
283
288
|
case 0: return [4 /*yield*/, this.process(function (c) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
284
289
|
return tslib_1.__generator(this, function (_a) {
|
|
285
|
-
console.log("DEBUG ", c);
|
|
286
290
|
remult = c;
|
|
287
291
|
return [2 /*return*/];
|
|
288
292
|
});
|
package/src/context.d.ts
CHANGED
|
@@ -80,9 +80,9 @@ export declare class Remult {
|
|
|
80
80
|
clearAllCache(): any;
|
|
81
81
|
/** A helper callback that is called whenever an entity is created. */
|
|
82
82
|
static entityRefInit?: (ref: EntityRef<any>, row: any) => void;
|
|
83
|
-
readonly
|
|
83
|
+
readonly context: RemultContext;
|
|
84
84
|
}
|
|
85
|
-
export interface
|
|
85
|
+
export interface RemultContext {
|
|
86
86
|
}
|
|
87
87
|
export declare const allEntities: ClassType<any>[];
|
|
88
88
|
export interface ControllerOptions {
|
package/src/context.js
CHANGED
|
@@ -152,7 +152,7 @@ var Remult = /** @class */ (function () {
|
|
|
152
152
|
this._userChangeEvent = new EventSource();
|
|
153
153
|
/* @internal */
|
|
154
154
|
this.repCache = new Map();
|
|
155
|
-
this.
|
|
155
|
+
this.context = {};
|
|
156
156
|
if (provider && provider.getEntityDataProvider) {
|
|
157
157
|
this._dataSource = provider;
|
|
158
158
|
return;
|
package/src/remult-proxy.js
CHANGED
|
@@ -19,9 +19,9 @@ var RemultProxy = /** @class */ (function () {
|
|
|
19
19
|
return (_a = _this.remultFactory()).repo.apply(_a, tslib_1.__spread(args));
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
Object.defineProperty(RemultProxy.prototype, "
|
|
22
|
+
Object.defineProperty(RemultProxy.prototype, "context", {
|
|
23
23
|
get: function () {
|
|
24
|
-
return this.instance.
|
|
24
|
+
return this.instance.context;
|
|
25
25
|
},
|
|
26
26
|
enumerable: false,
|
|
27
27
|
configurable: true
|