remult 2.7.33 → 3.0.0-next.1
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 +2 -2
- package/esm/remult-express.js +3 -1
- package/esm/remult-fastify.js +3 -1
- package/esm/remult-hapi.js +3 -1
- package/esm/remult-hono.js +3 -1
- package/esm/remult-knex/index.js +10 -5
- package/esm/remult-next.js +2 -1
- package/esm/remult-nuxt.js +2 -1
- package/esm/remult-solid-start.js +2 -1
- package/esm/remult-sveltekit.js +2 -1
- package/esm/server/get-remult-admin-html.js +1 -1
- package/esm/src/context.js +4 -2
- package/package.json +1 -1
- package/remult-express.d.ts +4 -3
- package/remult-express.js +5 -2
- package/remult-fastify.d.ts +2 -1
- package/remult-fastify.js +5 -2
- package/remult-hapi.d.ts +2 -1
- package/remult-hapi.js +5 -2
- package/remult-hono.d.ts +2 -1
- package/remult-hono.js +5 -2
- package/remult-knex/index.js +10 -5
- package/remult-next.d.ts +2 -1
- package/remult-next.js +4 -2
- package/remult-nuxt.d.ts +2 -1
- package/remult-nuxt.js +4 -2
- package/remult-solid-start.d.ts +2 -1
- package/remult-solid-start.js +4 -2
- package/remult-sveltekit.d.ts +2 -1
- package/remult-sveltekit.js +4 -2
- package/server/get-remult-admin-html.js +1 -1
- package/server/remult-api-server.d.ts +1 -1
- package/src/context.js +5 -2
- package/src/entity.d.ts +13 -0
package/README.md
CHANGED
|
@@ -97,14 +97,14 @@ _Example:_
|
|
|
97
97
|
// backend/index.ts
|
|
98
98
|
|
|
99
99
|
import express from 'express'
|
|
100
|
-
import {
|
|
100
|
+
import { remultApi } from 'remult/remult-express' // adapters for: Fastify,Next.js, Nuxt, SvelteKit, SolidStart, Nest, more...
|
|
101
101
|
import { createPostgresDataProvider } from 'remult/postgres' // supported: PostgreSQL, MySQL, SQLite, MongoDB, MSSQL and Oracle
|
|
102
102
|
import { Product } from '../shared/product'
|
|
103
103
|
|
|
104
104
|
const app = express()
|
|
105
105
|
|
|
106
106
|
app.use(
|
|
107
|
-
|
|
107
|
+
remultApi({
|
|
108
108
|
entities: [Product],
|
|
109
109
|
dataProvider: createPostgresDataProvider({
|
|
110
110
|
connectionString: 'postgres://user:password@host:5432/database"',
|
package/esm/remult-express.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
2
|
import { createRemultServer } from './server/index.js';
|
|
3
|
-
export function
|
|
3
|
+
export function remultApi(options) {
|
|
4
4
|
let app = express.Router();
|
|
5
5
|
if (!options) {
|
|
6
6
|
options = {};
|
|
@@ -24,3 +24,5 @@ export function remultExpress(options) {
|
|
|
24
24
|
withRemultAsync: (req, what) => server.withRemultAsync(req, what),
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
+
// @deprecated use remultApi instead
|
|
28
|
+
export const remultExpress = remultApi;
|
package/esm/remult-fastify.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRemultServer } from './server/index.js';
|
|
2
|
-
export function
|
|
2
|
+
export function remultApi(options) {
|
|
3
3
|
function fastifyHandler(handler) {
|
|
4
4
|
const response = (req, res) => {
|
|
5
5
|
const myRes = {
|
|
@@ -69,3 +69,5 @@ export function remultFastify(options) {
|
|
|
69
69
|
withRemult: (req, what) => api.withRemultAsync(req, what),
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
+
// @deprecated use remultApi instead
|
|
73
|
+
export const remultFastify = remultApi;
|
package/esm/remult-hapi.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRemultServer, } from './server/index.js';
|
|
2
2
|
import { PassThrough } from 'stream';
|
|
3
|
-
export function
|
|
3
|
+
export function remultApi(options) {
|
|
4
4
|
const api = createRemultServer(options, {
|
|
5
5
|
buildGenericRequestInfo: (req) => ({
|
|
6
6
|
method: req.method,
|
|
@@ -112,3 +112,5 @@ export function remultHapi(options) {
|
|
|
112
112
|
withRemult: (req, what) => api.withRemultAsync(req, what),
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
+
// @deprecated use remultApi instead
|
|
116
|
+
export const remultHapi = remultApi;
|
package/esm/remult-hono.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
2
|
import { streamSSE } from 'hono/streaming';
|
|
3
3
|
import { createRemultServer, } from './server/index.js';
|
|
4
|
-
export function
|
|
4
|
+
export function remultApi(options) {
|
|
5
5
|
let app = new Hono();
|
|
6
6
|
const api = createRemultServer(options, {
|
|
7
7
|
buildGenericRequestInfo: (c) => {
|
|
@@ -102,3 +102,5 @@ export function remultHono(options) {
|
|
|
102
102
|
withRemult: async (c, what) => api.withRemultAsync(c, what),
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
+
// @deprecated use remultApi instead
|
|
106
|
+
export const remultHono = remultApi;
|
package/esm/remult-knex/index.js
CHANGED
|
@@ -119,12 +119,17 @@ class KnexEntityDataProvider {
|
|
|
119
119
|
async groupBy(options) {
|
|
120
120
|
return groupByImpl(options, await dbNamesOf(this.entity, this.dp.wrapIdentifier), this.dp.createCommand(), false, (limit, offset) => ' limit ' + limit + ' offset ' + offset);
|
|
121
121
|
}
|
|
122
|
+
getEntityFrom(e) {
|
|
123
|
+
if (this.entity.options.sqlExpression)
|
|
124
|
+
return this.knex.fromRaw(e.$entityName);
|
|
125
|
+
return this.knex(e.$entityName);
|
|
126
|
+
}
|
|
122
127
|
async count(where) {
|
|
123
128
|
const e = await this.init();
|
|
124
129
|
const br = new FilterConsumerBridgeToKnexRequest(e, this.rawSqlWrapIdentifier);
|
|
125
130
|
where.__applyToConsumer(br);
|
|
126
131
|
let r = await br.resolveWhere();
|
|
127
|
-
const result = await this.
|
|
132
|
+
const result = await this.getEntityFrom(e)
|
|
128
133
|
.count()
|
|
129
134
|
.where((b) => r.forEach((w) => w(b)));
|
|
130
135
|
var row = result[0];
|
|
@@ -151,7 +156,7 @@ class KnexEntityDataProvider {
|
|
|
151
156
|
colKeys.push(x);
|
|
152
157
|
}
|
|
153
158
|
}
|
|
154
|
-
let query = this.
|
|
159
|
+
let query = this.getEntityFrom(e).select(cols);
|
|
155
160
|
if (options?.where) {
|
|
156
161
|
const br = new FilterConsumerBridgeToKnexRequest(e, this.rawSqlWrapIdentifier);
|
|
157
162
|
options.where.__applyToConsumer(br);
|
|
@@ -218,7 +223,7 @@ class KnexEntityDataProvider {
|
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
225
|
let where = await f.resolveWhere();
|
|
221
|
-
await this.
|
|
226
|
+
await this.getEntityFrom(e)
|
|
222
227
|
.update(updateObject)
|
|
223
228
|
.where((b) => where.forEach((w) => w(b)));
|
|
224
229
|
return getRowAfterUpdate(this.entity, this, data, id, 'update');
|
|
@@ -228,7 +233,7 @@ class KnexEntityDataProvider {
|
|
|
228
233
|
let f = new FilterConsumerBridgeToKnexRequest(e, this.rawSqlWrapIdentifier);
|
|
229
234
|
Filter.fromEntityFilter(this.entity, this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(f);
|
|
230
235
|
let where = await f.resolveWhere();
|
|
231
|
-
await this.
|
|
236
|
+
await this.getEntityFrom(e)
|
|
232
237
|
.delete()
|
|
233
238
|
.where((b) => where.forEach((w) => w(b)));
|
|
234
239
|
}
|
|
@@ -246,7 +251,7 @@ class KnexEntityDataProvider {
|
|
|
246
251
|
}
|
|
247
252
|
}
|
|
248
253
|
}
|
|
249
|
-
let insert = this.
|
|
254
|
+
let insert = this.getEntityFrom(e).insert(insertObject);
|
|
250
255
|
if (isAutoIncrement(this.entity.idMetadata.field)) {
|
|
251
256
|
let newId;
|
|
252
257
|
if (this.knex.client.config.client === 'mysql2' ||
|
package/esm/remult-next.js
CHANGED
|
@@ -37,7 +37,7 @@ export function remultNext(options) {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
const encoder = new TextEncoder();
|
|
40
|
-
export function
|
|
40
|
+
export function remultApi(options) {
|
|
41
41
|
let result = createRemultServer(options, {
|
|
42
42
|
getRequestBody: (req) => req.json(),
|
|
43
43
|
buildGenericRequestInfo: (req) => ({
|
|
@@ -121,3 +121,4 @@ export function remultNextApp(options) {
|
|
|
121
121
|
withRemult: (what) => result.withRemultAsync({}, what),
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
+
export const remultNextApp = remultApi;
|
package/esm/remult-nuxt.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readBody, setResponseStatus } from 'h3';
|
|
2
2
|
import { createRemultServer } from './server/index.js';
|
|
3
|
-
export function
|
|
3
|
+
export function remultApi(options) {
|
|
4
4
|
const result = createRemultServer(options, {
|
|
5
5
|
buildGenericRequestInfo: (event) => {
|
|
6
6
|
return {
|
|
@@ -52,3 +52,4 @@ export function remultNuxt(options) {
|
|
|
52
52
|
},
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
+
export const remultNuxt = remultApi;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getRequestEvent } from 'solid-js/web';
|
|
2
2
|
import { createRemultServer } from './server/index.js';
|
|
3
|
-
export function
|
|
3
|
+
export function remultApi(options) {
|
|
4
4
|
let result = createRemultServer(options, {
|
|
5
5
|
buildGenericRequestInfo: (event) => ({
|
|
6
6
|
url: event.request.url,
|
|
@@ -95,3 +95,4 @@ export function remultSolidStart(options) {
|
|
|
95
95
|
DELETE: serverHandler,
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
+
export const remultSolidStart = remultApi;
|
package/esm/remult-sveltekit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRemultServer } from './server/index.js';
|
|
2
|
-
export function
|
|
2
|
+
export function remultApi(options) {
|
|
3
3
|
let result = createRemultServer(options, {
|
|
4
4
|
buildGenericRequestInfo: (event) => ({
|
|
5
5
|
url: event.request.url,
|
|
@@ -86,3 +86,4 @@ export function remultSveltekit(options) {
|
|
|
86
86
|
DELETE: serverHandler,
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
+
export const remultSveltekit = remultApi;
|