remult 0.27.22-next.0 → 0.27.22
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/server/initAsyncHooks.js +0 -49
- package/esm/src/context.js +5 -0
- package/esm/src/remult-proxy.js +3 -0
- package/esm/src/remult3/remult3.js +1 -0
- package/package.json +1 -1
- package/server/initAsyncHooks.d.ts +0 -7
- package/server/initAsyncHooks.js +1 -73
- package/src/context.d.ts +1 -0
- package/src/context.js +5 -0
- package/src/remult-proxy.js +3 -0
- package/src/remult3/remult3.js +1 -0
|
@@ -37,55 +37,6 @@ export class AsyncLocalStorageBridgeToRemultAsyncLocalStorageCoreImpl {
|
|
|
37
37
|
return this.asyncLocalStorage.getStore();
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
const ignoreInStack = [
|
|
41
|
-
'AsyncLocalStorageBridgeToRemultAsyncLocalStorageCore.run',
|
|
42
|
-
'RemultAsyncLocalStorage.run',
|
|
43
|
-
'Module.withRemult',
|
|
44
|
-
'RemultServerImplementation.runWithRemult',
|
|
45
|
-
];
|
|
46
|
-
export class SequentialRemultAsyncLocalStorageCore {
|
|
47
|
-
wasImplemented = 'yes';
|
|
48
|
-
async run(store, callback) {
|
|
49
|
-
let log = (msg) => { };
|
|
50
|
-
if (false) {
|
|
51
|
-
let stack = new Error().stack;
|
|
52
|
-
let y = stack.split('\n');
|
|
53
|
-
while (y.length > 0 &&
|
|
54
|
-
(y[0].trim().startsWith('Error') ||
|
|
55
|
-
ignoreInStack.includes(y[0].trim().split(' ')[1]))) {
|
|
56
|
-
y.splice(0, 1);
|
|
57
|
-
}
|
|
58
|
-
stack = y.join('\n');
|
|
59
|
-
log = (msg) => {
|
|
60
|
-
console.log(msg, stack);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
log('waiting on ');
|
|
64
|
-
const nextPromise = this.lastPromise.then(async () => {
|
|
65
|
-
log('executing ');
|
|
66
|
-
const previousValue = this.currentValue;
|
|
67
|
-
this.currentValue = store;
|
|
68
|
-
const result = await callback();
|
|
69
|
-
this.currentValue = previousValue;
|
|
70
|
-
return result;
|
|
71
|
-
});
|
|
72
|
-
this.lastPromise = nextPromise.catch(() => {
|
|
73
|
-
log('Error on ');
|
|
74
|
-
return undefined;
|
|
75
|
-
});
|
|
76
|
-
try {
|
|
77
|
-
return await nextPromise;
|
|
78
|
-
}
|
|
79
|
-
finally {
|
|
80
|
-
log('completed ');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
getStore() {
|
|
84
|
-
return this.currentValue;
|
|
85
|
-
}
|
|
86
|
-
lastPromise = Promise.resolve(undefined);
|
|
87
|
-
currentValue;
|
|
88
|
-
}
|
|
89
40
|
export class StubRemultAsyncLocalStorageCore {
|
|
90
41
|
isStub = true;
|
|
91
42
|
wasImplemented = 'yes';
|
package/esm/src/context.js
CHANGED
|
@@ -140,6 +140,11 @@ export class Remult {
|
|
|
140
140
|
return this.isAllowed(allowed);
|
|
141
141
|
return undefined;
|
|
142
142
|
}
|
|
143
|
+
useFetch(fetch) {
|
|
144
|
+
this.dataProvider = new RestDataProvider(() => ({
|
|
145
|
+
httpClient: fetch,
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
143
148
|
/** The current data provider */
|
|
144
149
|
dataProvider = new RestDataProvider(() => this.apiClient);
|
|
145
150
|
/* @internal */
|
package/esm/src/remult-proxy.js
CHANGED
|
@@ -17,6 +17,7 @@ const wnn = [
|
|
|
17
17
|
export const flags = {
|
|
18
18
|
error500RetryCount: 4,
|
|
19
19
|
};
|
|
20
|
+
//p1 - allow experimental route registration on remult server, with at least get route, and support redirect, read header and set header - (and the existing get html etc...)
|
|
20
21
|
//p2 - add parameter all to deleteMany, and updateMany
|
|
21
22
|
//p2 filter.apply ApiPreFilter
|
|
22
23
|
//p2 - signIn: (arg) =>withRemult(async () => { - consider if there's a generic way of doing signIn:withRemult(arg=>{})
|
package/package.json
CHANGED
|
@@ -6,13 +6,6 @@ export declare class AsyncLocalStorageBridgeToRemultAsyncLocalStorageCoreImpl<T>
|
|
|
6
6
|
run<R>(store: T, callback: () => Promise<R>): Promise<R>;
|
|
7
7
|
getStore(): T | undefined;
|
|
8
8
|
}
|
|
9
|
-
export declare class SequentialRemultAsyncLocalStorageCore<T> implements RemultAsyncLocalStorageCore<T> {
|
|
10
|
-
wasImplemented: "yes";
|
|
11
|
-
run<R>(store: T, callback: () => Promise<R>): Promise<R>;
|
|
12
|
-
getStore(): T | undefined;
|
|
13
|
-
lastPromise: Promise<T | undefined>;
|
|
14
|
-
currentValue?: T;
|
|
15
|
-
}
|
|
16
9
|
export declare class StubRemultAsyncLocalStorageCore<T> implements RemultAsyncLocalStorageCore<T> {
|
|
17
10
|
isStub: boolean;
|
|
18
11
|
wasImplemented: "yes";
|
package/server/initAsyncHooks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsyncLocalStorageBridgeToRemultAsyncLocalStorageCore = exports.StubRemultAsyncLocalStorageCore = exports.
|
|
3
|
+
exports.AsyncLocalStorageBridgeToRemultAsyncLocalStorageCore = exports.StubRemultAsyncLocalStorageCore = exports.AsyncLocalStorageBridgeToRemultAsyncLocalStorageCoreImpl = void 0;
|
|
4
4
|
exports.initAsyncHooks = initAsyncHooks;
|
|
5
5
|
var tslib_1 = require("tslib");
|
|
6
6
|
var async_hooks_1 = require("async_hooks");
|
|
@@ -66,78 +66,6 @@ var AsyncLocalStorageBridgeToRemultAsyncLocalStorageCoreImpl = /** @class */ (fu
|
|
|
66
66
|
return AsyncLocalStorageBridgeToRemultAsyncLocalStorageCoreImpl;
|
|
67
67
|
}());
|
|
68
68
|
exports.AsyncLocalStorageBridgeToRemultAsyncLocalStorageCoreImpl = AsyncLocalStorageBridgeToRemultAsyncLocalStorageCoreImpl;
|
|
69
|
-
var ignoreInStack = [
|
|
70
|
-
'AsyncLocalStorageBridgeToRemultAsyncLocalStorageCore.run',
|
|
71
|
-
'RemultAsyncLocalStorage.run',
|
|
72
|
-
'Module.withRemult',
|
|
73
|
-
'RemultServerImplementation.runWithRemult',
|
|
74
|
-
];
|
|
75
|
-
var SequentialRemultAsyncLocalStorageCore = /** @class */ (function () {
|
|
76
|
-
function SequentialRemultAsyncLocalStorageCore() {
|
|
77
|
-
this.wasImplemented = 'yes';
|
|
78
|
-
this.lastPromise = Promise.resolve(undefined);
|
|
79
|
-
}
|
|
80
|
-
SequentialRemultAsyncLocalStorageCore.prototype.run = function (store, callback) {
|
|
81
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
82
|
-
var log, stack_1, y, nextPromise;
|
|
83
|
-
var _this = this;
|
|
84
|
-
return tslib_1.__generator(this, function (_a) {
|
|
85
|
-
switch (_a.label) {
|
|
86
|
-
case 0:
|
|
87
|
-
log = function (msg) { };
|
|
88
|
-
if (false) {
|
|
89
|
-
stack_1 = new Error().stack;
|
|
90
|
-
y = stack_1.split('\n');
|
|
91
|
-
while (y.length > 0 &&
|
|
92
|
-
(y[0].trim().startsWith('Error') ||
|
|
93
|
-
ignoreInStack.includes(y[0].trim().split(' ')[1]))) {
|
|
94
|
-
y.splice(0, 1);
|
|
95
|
-
}
|
|
96
|
-
stack_1 = y.join('\n');
|
|
97
|
-
log = function (msg) {
|
|
98
|
-
console.log(msg, stack_1);
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
log('waiting on ');
|
|
102
|
-
nextPromise = this.lastPromise.then(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
103
|
-
var previousValue, result;
|
|
104
|
-
return tslib_1.__generator(this, function (_a) {
|
|
105
|
-
switch (_a.label) {
|
|
106
|
-
case 0:
|
|
107
|
-
log('executing ');
|
|
108
|
-
previousValue = this.currentValue;
|
|
109
|
-
this.currentValue = store;
|
|
110
|
-
return [4 /*yield*/, callback()];
|
|
111
|
-
case 1:
|
|
112
|
-
result = _a.sent();
|
|
113
|
-
this.currentValue = previousValue;
|
|
114
|
-
return [2 /*return*/, result];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}); });
|
|
118
|
-
this.lastPromise = nextPromise.catch(function () {
|
|
119
|
-
log('Error on ');
|
|
120
|
-
return undefined;
|
|
121
|
-
});
|
|
122
|
-
_a.label = 1;
|
|
123
|
-
case 1:
|
|
124
|
-
_a.trys.push([1, , 3, 4]);
|
|
125
|
-
return [4 /*yield*/, nextPromise];
|
|
126
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
127
|
-
case 3:
|
|
128
|
-
log('completed ');
|
|
129
|
-
return [7 /*endfinally*/];
|
|
130
|
-
case 4: return [2 /*return*/];
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
SequentialRemultAsyncLocalStorageCore.prototype.getStore = function () {
|
|
136
|
-
return this.currentValue;
|
|
137
|
-
};
|
|
138
|
-
return SequentialRemultAsyncLocalStorageCore;
|
|
139
|
-
}());
|
|
140
|
-
exports.SequentialRemultAsyncLocalStorageCore = SequentialRemultAsyncLocalStorageCore;
|
|
141
69
|
var StubRemultAsyncLocalStorageCore = /** @class */ (function () {
|
|
142
70
|
function StubRemultAsyncLocalStorageCore() {
|
|
143
71
|
this.isStub = true;
|
package/src/context.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ export declare class Remult {
|
|
|
59
59
|
* [Allowed](https://remult.dev/docs/allowed.html)
|
|
60
60
|
*/
|
|
61
61
|
isAllowedForInstance(instance: any, allowed?: AllowedForInstance<any>): boolean;
|
|
62
|
+
useFetch(fetch: ApiClient['httpClient']): void;
|
|
62
63
|
/** The current data provider */
|
|
63
64
|
dataProvider: DataProvider;
|
|
64
65
|
/** Creates a new instance of the `remult` object.
|
package/src/context.js
CHANGED
|
@@ -230,6 +230,11 @@ var Remult = /** @class */ (function () {
|
|
|
230
230
|
return this.isAllowed(allowed);
|
|
231
231
|
return undefined;
|
|
232
232
|
};
|
|
233
|
+
Remult.prototype.useFetch = function (fetch) {
|
|
234
|
+
this.dataProvider = new rest_data_provider_js_1.RestDataProvider(function () { return ({
|
|
235
|
+
httpClient: fetch,
|
|
236
|
+
}); });
|
|
237
|
+
};
|
|
233
238
|
//@ts-ignore // type error of typescript regarding args that doesn't appear in my normal development
|
|
234
239
|
/** Used to call a `backendMethod` using a specific `remult` object
|
|
235
240
|
* @example
|
package/src/remult-proxy.js
CHANGED
|
@@ -333,6 +333,9 @@ var RemultProxy = /** @class */ (function () {
|
|
|
333
333
|
RemultProxy.prototype.clearAllCache = function () {
|
|
334
334
|
return remult_static_js_1.remultStatic.remultFactory().clearAllCache();
|
|
335
335
|
};
|
|
336
|
+
RemultProxy.prototype.useFetch = function (args) {
|
|
337
|
+
return remult_static_js_1.remultStatic.remultFactory().useFetch(args);
|
|
338
|
+
};
|
|
336
339
|
Object.defineProperty(RemultProxy.prototype, "user", {
|
|
337
340
|
get: function () {
|
|
338
341
|
return remult_static_js_1.remultStatic.remultFactory().user;
|
package/src/remult3/remult3.js
CHANGED
|
@@ -20,6 +20,7 @@ var wnn = [
|
|
|
20
20
|
exports.flags = {
|
|
21
21
|
error500RetryCount: 4,
|
|
22
22
|
};
|
|
23
|
+
//p1 - allow experimental route registration on remult server, with at least get route, and support redirect, read header and set header - (and the existing get html etc...)
|
|
23
24
|
//p2 - add parameter all to deleteMany, and updateMany
|
|
24
25
|
//p2 filter.apply ApiPreFilter
|
|
25
26
|
//p2 - signIn: (arg) =>withRemult(async () => { - consider if there's a generic way of doing signIn:withRemult(arg=>{})
|