remult 0.23.4 → 0.24.0-exp.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/SseSubscriptionServer.d.ts +3 -3
- package/SseSubscriptionServer.js +2 -2
- package/ably.d.ts +3 -3
- package/esm/SseSubscriptionServer.js +1 -1
- package/esm/graphql.js +3 -3
- package/esm/index.js +24 -24
- package/esm/internals.js +5 -5
- package/esm/live-query/data-provider-live-query-storage.js +5 -5
- package/esm/package.json +3 -0
- package/esm/postgres/index.d.ts +2 -2
- package/esm/postgres/index.js +2 -2
- package/esm/postgres/postgres-data-provider.d.ts +17 -6
- package/esm/postgres/postgres-data-provider.js +49 -10
- package/esm/postgres/schema-builder.js +10 -10
- package/esm/remult-express.js +2 -2
- package/esm/remult-fastify.js +2 -2
- package/esm/remult-fresh.js +1 -1
- package/esm/remult-hapi.js +2 -3
- package/esm/remult-knex/index.js +20 -11
- package/esm/remult-mongo.js +6 -6
- package/esm/remult-next.js +2 -2
- package/esm/remult-nuxt.js +49 -0
- package/esm/remult-sveltekit.js +2 -2
- package/esm/server/JsonEntityFileStorage.js +1 -1
- package/esm/server/core.js +4 -4
- package/esm/server/expressBridge.js +23 -23
- package/esm/server/index.js +5 -5
- package/esm/server/initAsyncHooks.js +1 -1
- package/esm/server/initDataProvider.js +1 -1
- package/esm/src/buildRestDataProvider.js +1 -1
- package/esm/src/column-interfaces.d.ts +2 -1
- package/esm/src/column.js +2 -2
- package/esm/src/context.js +26 -20
- package/esm/src/data-api.js +19 -5
- package/esm/src/data-interfaces.js +1 -1
- package/esm/src/data-providers/array-entity-data-provider.js +3 -3
- package/esm/src/data-providers/in-memory-database.js +1 -1
- package/esm/src/data-providers/json-data-provider.js +2 -2
- package/esm/src/data-providers/rest-data-provider.js +6 -6
- package/esm/src/data-providers/sql-database.d.ts +3 -2
- package/esm/src/data-providers/sql-database.js +22 -15
- package/esm/src/data-providers/web-sql-data-provider.js +3 -3
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.d.ts +4 -2
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +44 -6
- package/esm/src/filter/filter-interfaces.js +15 -4
- package/esm/src/live-query/LiveQueryClient.js +5 -5
- package/esm/src/live-query/SseSubscriptionClient.js +10 -7
- package/esm/src/live-query/SubscriptionChannel.js +3 -3
- package/esm/src/live-query/SubscriptionServer.js +1 -1
- package/esm/src/remult-proxy.js +1 -1
- package/esm/src/remult3/Fields.js +8 -4
- package/esm/src/remult3/IdEntity.js +2 -2
- package/esm/src/remult3/RepositoryImplementation.d.ts +2 -4
- package/esm/src/remult3/RepositoryImplementation.js +100 -105
- package/esm/src/remult3/__updateEntityBasedOnWhere.js +1 -1
- package/esm/src/remult3/entity.js +2 -2
- package/esm/src/remult3/relation-loader.js +3 -3
- package/esm/src/remult3/remult3.d.ts +2 -1
- package/esm/src/remult3/remult3.js +24 -20
- package/esm/src/resultCompoundIdFilter.js +1 -1
- package/esm/src/server-action.js +8 -8
- package/esm/src/sort.js +2 -2
- package/esm/src/sql-command.d.ts +1 -0
- package/esm/src/validators.js +1 -1
- package/esm/src/valueConverters.js +1 -1
- package/graphql.d.ts +2 -2
- package/graphql.js +7 -7
- package/index.d.ts +32 -32
- package/index.js +65 -64
- package/internals.d.ts +7 -7
- package/internals.js +12 -12
- package/live-query/data-provider-live-query-storage.d.ts +4 -4
- package/live-query/data-provider-live-query-storage.js +14 -14
- package/package.json +53 -88
- package/postgres/index.d.ts +2 -2
- package/postgres/index.js +9 -3
- package/postgres/postgres-data-provider.d.ts +22 -11
- package/postgres/postgres-data-provider.js +90 -20
- package/postgres/schema-builder.d.ts +4 -4
- package/postgres/schema-builder.js +17 -17
- package/remult-express.d.ts +2 -2
- package/remult-express.js +3 -3
- package/remult-fastify.d.ts +2 -2
- package/remult-fastify.js +3 -3
- package/remult-fresh.d.ts +1 -1
- package/remult-fresh.js +2 -2
- package/remult-hapi.d.ts +2 -2
- package/remult-hapi.js +3 -4
- package/remult-knex/index.d.ts +5 -5
- package/remult-knex/index.js +53 -41
- package/remult-mongo.d.ts +2 -2
- package/remult-mongo.js +16 -16
- package/remult-next.d.ts +1 -1
- package/remult-next.js +4 -4
- package/remult-nuxt.d.ts +6 -0
- package/remult-nuxt.js +74 -0
- package/remult-sveltekit.d.ts +2 -2
- package/remult-sveltekit.js +3 -3
- package/server/JsonEntityFileStorage.d.ts +2 -2
- package/server/JsonEntityFileStorage.js +2 -2
- package/server/core.d.ts +4 -4
- package/server/core.js +9 -9
- package/server/expressBridge.d.ts +9 -9
- package/server/expressBridge.js +70 -77
- package/server/index.d.ts +5 -5
- package/server/index.js +11 -11
- package/server/initAsyncHooks.js +2 -2
- package/server/initDataProvider.d.ts +1 -1
- package/server/initDataProvider.js +1 -1
- package/src/CompoundIdField.d.ts +3 -3
- package/src/buildRestDataProvider.d.ts +1 -1
- package/src/buildRestDataProvider.js +3 -3
- package/src/column-interfaces.d.ts +14 -7
- package/src/column.d.ts +1 -1
- package/src/column.js +6 -6
- package/src/context.d.ts +11 -10
- package/src/context.js +52 -32
- package/src/data-api.d.ts +4 -3
- package/src/data-api.js +47 -22
- package/src/data-interfaces.d.ts +3 -3
- package/src/data-interfaces.js +2 -2
- package/src/data-providers/array-entity-data-provider.js +9 -9
- package/src/data-providers/in-memory-database.d.ts +3 -3
- package/src/data-providers/in-memory-database.js +2 -2
- package/src/data-providers/json-data-provider.d.ts +2 -2
- package/src/data-providers/json-data-provider.js +3 -3
- package/src/data-providers/rest-data-provider.d.ts +5 -5
- package/src/data-providers/rest-data-provider.js +19 -19
- package/src/data-providers/sql-database.d.ts +8 -7
- package/src/data-providers/sql-database.js +56 -41
- package/src/data-providers/web-sql-data-provider.d.ts +4 -4
- package/src/data-providers/web-sql-data-provider.js +10 -10
- package/src/entity.d.ts +3 -3
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +8 -6
- package/src/filter/filter-consumer-bridge-to-sql-request.js +70 -9
- package/src/filter/filter-interfaces.d.ts +3 -3
- package/src/filter/filter-interfaces.js +19 -8
- package/src/live-query/LiveQueryClient.js +9 -9
- package/src/live-query/SseSubscriptionClient.d.ts +2 -1
- package/src/live-query/SseSubscriptionClient.js +15 -12
- package/src/live-query/SubscriptionChannel.d.ts +1 -1
- package/src/live-query/SubscriptionChannel.js +8 -8
- package/src/live-query/SubscriptionServer.js +2 -2
- package/src/remult-proxy.d.ts +1 -1
- package/src/remult-proxy.js +3 -3
- package/src/remult3/Fields.d.ts +6 -6
- package/src/remult3/Fields.js +17 -13
- package/src/remult3/IdEntity.d.ts +1 -1
- package/src/remult3/IdEntity.js +4 -4
- package/src/remult3/RepositoryImplementation.d.ts +48 -18
- package/src/remult3/RepositoryImplementation.js +191 -201
- package/src/remult3/__updateEntityBasedOnWhere.d.ts +1 -1
- package/src/remult3/__updateEntityBasedOnWhere.js +2 -2
- package/src/remult3/columnInfo.d.ts +2 -2
- package/src/remult3/entity.d.ts +3 -3
- package/src/remult3/entity.js +7 -7
- package/src/remult3/getEntityRef.d.ts +3 -3
- package/src/remult3/relation-loader-types.d.ts +2 -2
- package/src/remult3/relation-loader.d.ts +2 -2
- package/src/remult3/relation-loader.js +6 -6
- package/src/remult3/relationInfoMember.d.ts +2 -2
- package/src/remult3/remult3.d.ts +22 -9
- package/src/remult3/remult3.js +24 -20
- package/src/remult3/repository-internals.d.ts +3 -3
- package/src/resultCompoundIdFilter.d.ts +2 -2
- package/src/resultCompoundIdFilter.js +2 -2
- package/src/server-action.d.ts +4 -4
- package/src/server-action.js +40 -40
- package/src/sort.d.ts +2 -2
- package/src/sort.js +5 -5
- package/src/sql-command.d.ts +2 -1
- package/src/validators.d.ts +1 -1
- package/src/validators.js +2 -2
- package/src/valueConverters.d.ts +1 -1
- package/src/valueConverters.js +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { GenericResponse } from './server/index';
|
|
3
|
-
import type { Remult } from './src/context';
|
|
4
|
-
import type { SubscriptionServer } from './src/live-query/SubscriptionServer';
|
|
2
|
+
import type { GenericResponse } from './server/index.js';
|
|
3
|
+
import type { Remult } from './src/context.js';
|
|
4
|
+
import type { SubscriptionServer } from './src/live-query/SubscriptionServer.js';
|
|
5
5
|
export declare class SseSubscriptionServer implements SubscriptionServer {
|
|
6
6
|
private canUserConnectToChannel?;
|
|
7
7
|
constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
|
package/SseSubscriptionServer.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.clientConnection = exports.SseSubscriptionServer = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var uuid_1 = require("uuid");
|
|
6
|
-
var
|
|
6
|
+
var SseSubscriptionClient_js_1 = require("./src/live-query/SseSubscriptionClient.js");
|
|
7
7
|
var SseSubscriptionServer = /** @class */ (function () {
|
|
8
8
|
function SseSubscriptionServer(canUserConnectToChannel) {
|
|
9
9
|
this.canUserConnectToChannel = canUserConnectToChannel;
|
|
@@ -50,7 +50,7 @@ var SseSubscriptionServer = /** @class */ (function () {
|
|
|
50
50
|
}
|
|
51
51
|
finally { if (e_1) throw e_1.error; }
|
|
52
52
|
}
|
|
53
|
-
res.success(
|
|
53
|
+
res.success(SseSubscriptionClient_js_1.ConnectionNotFoundError);
|
|
54
54
|
};
|
|
55
55
|
SseSubscriptionServer.prototype.publishMessage = function (channel, message) {
|
|
56
56
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
package/ably.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type * as Ably from '
|
|
2
|
-
import type { SubscriptionClient, SubscriptionClientConnection } from './src/live-query/SubscriptionChannel';
|
|
3
|
-
import type { SubscriptionServer } from './src/live-query/SubscriptionServer';
|
|
1
|
+
import type * as Ably from 'ably/ably';
|
|
2
|
+
import type { SubscriptionClient, SubscriptionClientConnection } from './src/live-query/SubscriptionChannel.js';
|
|
3
|
+
import type { SubscriptionServer } from './src/live-query/SubscriptionServer.js';
|
|
4
4
|
export declare class AblySubscriptionClient implements SubscriptionClient {
|
|
5
5
|
private ably;
|
|
6
6
|
constructor(ably: Ably.Types.RealtimePromise);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuid } from 'uuid';
|
|
2
|
-
import { ConnectionNotFoundError } from './src/live-query/SseSubscriptionClient';
|
|
2
|
+
import { ConnectionNotFoundError } from './src/live-query/SseSubscriptionClient.js';
|
|
3
3
|
export class SseSubscriptionServer {
|
|
4
4
|
canUserConnectToChannel;
|
|
5
5
|
//@internal
|
package/esm/graphql.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getRelationInfo } from './internals';
|
|
2
|
-
import { Remult, remult } from './index';
|
|
3
|
-
import { DataApi } from './src/data-api';
|
|
1
|
+
import { getRelationInfo } from './internals.js';
|
|
2
|
+
import { Remult, remult } from './index.js';
|
|
3
|
+
import { DataApi } from './src/data-api.js';
|
|
4
4
|
const v2ConnectionAndPagination = false;
|
|
5
5
|
const andImplementation = false;
|
|
6
6
|
let _removeComments = false;
|
package/esm/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export { EntityBase, ControllerBase, FieldType, getFields, ValueListFieldType, getValueList, ValueListInfo, CaptionTransformer, } from './src/remult3/RepositoryImplementation';
|
|
2
|
-
export { Entity } from './src/remult3/entity';
|
|
3
|
-
export { getEntityRef } from './src/remult3/getEntityRef';
|
|
4
|
-
export { Field, Fields, Relations, } from './src/remult3/Fields';
|
|
5
|
-
export { IdEntity } from './src/remult3/IdEntity';
|
|
6
|
-
export { describeClass } from './src/remult3/DecoratorReplacer';
|
|
7
|
-
export { RestDataProvider } from './src/data-providers/rest-data-provider'; //V
|
|
8
|
-
export { InMemoryDataProvider } from './src/data-providers/in-memory-database'; //V
|
|
9
|
-
export { WebSqlDataProvider } from './src/data-providers/web-sql-data-provider'; //V
|
|
10
|
-
export { SqlDatabase } from './src/data-providers/sql-database'; //V
|
|
11
|
-
export { CustomSqlFilterBuilder, dbNamesOf, } from './src/filter/filter-consumer-bridge-to-sql-request';
|
|
12
|
-
export { JsonDataProvider, } from './src/data-providers/json-data-provider'; //V
|
|
1
|
+
export { EntityBase, ControllerBase, FieldType, getFields, ValueListFieldType, getValueList, ValueListInfo, CaptionTransformer, } from './src/remult3/RepositoryImplementation.js';
|
|
2
|
+
export { Entity } from './src/remult3/entity.js';
|
|
3
|
+
export { getEntityRef } from './src/remult3/getEntityRef.js';
|
|
4
|
+
export { Field, Fields, Relations, } from './src/remult3/Fields.js';
|
|
5
|
+
export { IdEntity } from './src/remult3/IdEntity.js';
|
|
6
|
+
export { describeClass } from './src/remult3/DecoratorReplacer.js';
|
|
7
|
+
export { RestDataProvider } from './src/data-providers/rest-data-provider.js'; //V
|
|
8
|
+
export { InMemoryDataProvider } from './src/data-providers/in-memory-database.js'; //V
|
|
9
|
+
export { WebSqlDataProvider } from './src/data-providers/web-sql-data-provider.js'; //V
|
|
10
|
+
export { SqlDatabase } from './src/data-providers/sql-database.js'; //V
|
|
11
|
+
export { CustomSqlFilterBuilder, dbNamesOf, } from './src/filter/filter-consumer-bridge-to-sql-request.js';
|
|
12
|
+
export { JsonDataProvider, } from './src/data-providers/json-data-provider.js'; //V
|
|
13
13
|
//export * from './src/data-api'; //reconsider if to make internal
|
|
14
|
-
export { Controller, BackendMethod, ProgressListener, } from './src/server-action';
|
|
15
|
-
export { Allow, Remult, isBackend, EventSource, } from './src/context';
|
|
16
|
-
export { Sort } from './src/sort';
|
|
17
|
-
export { CompoundIdField } from './src/CompoundIdField';
|
|
18
|
-
export { Filter, } from './src/filter/filter-interfaces';
|
|
19
|
-
export { UrlBuilder } from './urlBuilder';
|
|
20
|
-
export { Validators } from './src/validators';
|
|
21
|
-
export { ValueConverters } from './src/valueConverters';
|
|
22
|
-
export { remult } from './src/remult-proxy';
|
|
23
|
-
import { remult } from './src/remult-proxy';
|
|
14
|
+
export { Controller, BackendMethod, ProgressListener, } from './src/server-action.js';
|
|
15
|
+
export { Allow, Remult, withRemult, isBackend, EventSource, } from './src/context.js';
|
|
16
|
+
export { Sort } from './src/sort.js';
|
|
17
|
+
export { CompoundIdField } from './src/CompoundIdField.js';
|
|
18
|
+
export { Filter, } from './src/filter/filter-interfaces.js';
|
|
19
|
+
export { UrlBuilder } from './urlBuilder.js';
|
|
20
|
+
export { Validators } from './src/validators.js';
|
|
21
|
+
export { ValueConverters } from './src/valueConverters.js';
|
|
22
|
+
export { remult } from './src/remult-proxy.js';
|
|
23
|
+
import { remult } from './src/remult-proxy.js';
|
|
24
24
|
//export { getId } from './src/remult3/getId';
|
|
25
|
-
export { InMemoryLiveQueryStorage, } from './src/live-query/SubscriptionServer';
|
|
26
|
-
export { SubscriptionChannel, } from './src/live-query/SubscriptionChannel';
|
|
25
|
+
export { InMemoryLiveQueryStorage, } from './src/live-query/SubscriptionServer.js';
|
|
26
|
+
export { SubscriptionChannel, } from './src/live-query/SubscriptionChannel.js';
|
|
27
27
|
/**
|
|
28
28
|
* A convenient shortcut function to quickly obtain a repository for a specific entity type in Remult.
|
|
29
29
|
*
|
package/esm/internals.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { getRelationInfo } from './src/remult3/relationInfoMember';
|
|
2
|
-
export { decorateColumnSettings, controllerRefImpl, getControllerRef, } from './src/remult3/RepositoryImplementation';
|
|
3
|
-
export { getEntitySettings } from './src/remult3/getEntityRef';
|
|
4
|
-
export { __updateEntityBasedOnWhere } from './src/filter/filter-interfaces';
|
|
5
|
-
export { actionInfo } from './src/server-action-info';
|
|
1
|
+
export { getRelationInfo } from './src/remult3/relationInfoMember.js';
|
|
2
|
+
export { decorateColumnSettings, controllerRefImpl, getControllerRef, } from './src/remult3/RepositoryImplementation.js';
|
|
3
|
+
export { getEntitySettings } from './src/remult3/getEntityRef.js';
|
|
4
|
+
export { __updateEntityBasedOnWhere } from './src/filter/filter-interfaces.js';
|
|
5
|
+
export { actionInfo } from './src/server-action-info.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { initDataProvider } from '../server/initDataProvider';
|
|
3
|
-
import { allEntities, Remult } from '../src/context';
|
|
4
|
-
import { EntityBase } from '../src/remult3/RepositoryImplementation';
|
|
5
|
-
import { Fields } from '../src/remult3/Fields';
|
|
6
|
-
import { Entity } from '../src/remult3/entity';
|
|
2
|
+
import { initDataProvider } from '../server/initDataProvider.js';
|
|
3
|
+
import { allEntities, Remult } from '../src/context.js';
|
|
4
|
+
import { EntityBase } from '../src/remult3/RepositoryImplementation.js';
|
|
5
|
+
import { Fields } from '../src/remult3/Fields.js';
|
|
6
|
+
import { Entity } from '../src/remult3/entity.js';
|
|
7
7
|
export class DataProviderLiveQueryStorage {
|
|
8
8
|
repo;
|
|
9
9
|
dataProvider;
|
package/esm/package.json
ADDED
package/esm/postgres/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { PostgresDataProvider, PostgresPool, preparePostgresQueueStorage, PostgresClient, createPostgresConnection, createPostgresDataProvider, PostgresCommandSource, } from './postgres-data-provider';
|
|
2
|
+
export { PostgresSchemaBuilder, postgresColumnSyntax } from './schema-builder';
|
package/esm/postgres/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { PostgresDataProvider, preparePostgresQueueStorage, createPostgresConnection, createPostgresDataProvider, } from './postgres-data-provider.js';
|
|
2
|
+
export { PostgresSchemaBuilder, postgresColumnSyntax, } from './schema-builder.js';
|
|
@@ -11,26 +11,37 @@ export interface PostgresClient extends PostgresCommandSource {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class PostgresDataProvider implements SqlImplementation {
|
|
13
13
|
private pool;
|
|
14
|
+
private options?;
|
|
14
15
|
supportsJsonColumnType: boolean;
|
|
15
16
|
static getDb(remult?: Remult): ClientBase;
|
|
16
17
|
entityIsUsedForTheFirstTime(entity: EntityMetadata): Promise<void>;
|
|
17
18
|
getLimitSqlSyntax(limit: number, offset: number): string;
|
|
18
19
|
createCommand(): SqlCommand;
|
|
19
|
-
constructor(pool: PostgresPool
|
|
20
|
+
constructor(pool: PostgresPool, options?: {
|
|
21
|
+
wrapIdentifier?: (name: string) => string;
|
|
22
|
+
schema?: string;
|
|
23
|
+
});
|
|
24
|
+
wrapIdentifier: (name: any) => any;
|
|
20
25
|
ensureSchema(entities: EntityMetadata<any>[]): Promise<void>;
|
|
21
26
|
transaction(action: (dataProvider: SqlImplementation) => Promise<void>): Promise<void>;
|
|
22
27
|
}
|
|
23
28
|
export interface PostgresCommandSource {
|
|
24
29
|
query(queryText: string, values?: any[]): Promise<QueryResult>;
|
|
25
30
|
}
|
|
26
|
-
export declare function createPostgresConnection(options?:
|
|
27
|
-
connectionString?: string;
|
|
28
|
-
sslInDev?: boolean;
|
|
29
|
-
configuration?: 'heroku' | PoolConfig;
|
|
30
|
-
}): Promise<SqlDatabase>;
|
|
31
|
+
export declare function createPostgresConnection(options?: Parameters<typeof createPostgresDataProvider>[0]): Promise<SqlDatabase>;
|
|
31
32
|
export declare function createPostgresDataProvider(options?: {
|
|
32
33
|
connectionString?: string;
|
|
33
34
|
sslInDev?: boolean;
|
|
34
35
|
configuration?: 'heroku' | PoolConfig;
|
|
36
|
+
wrapIdentifier?: (name: string) => string;
|
|
37
|
+
caseInsensitiveIdentifiers?: boolean;
|
|
38
|
+
schema?: string;
|
|
35
39
|
}): Promise<SqlDatabase>;
|
|
36
40
|
export declare function preparePostgresQueueStorage(sql: SqlDatabase): Promise<import("../server/expressBridge").EntityQueueStorage>;
|
|
41
|
+
export declare class PostgresSchemaWrapper implements PostgresPool {
|
|
42
|
+
private pool;
|
|
43
|
+
private schema;
|
|
44
|
+
constructor(pool: PostgresPool, schema: string);
|
|
45
|
+
connect(): Promise<PostgresClient>;
|
|
46
|
+
query(queryText: string, values?: any[]): Promise<QueryResult>;
|
|
47
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
const { Pool } = pg;
|
|
3
|
+
import { Remult } from '../src/context.js';
|
|
4
|
+
import { SqlDatabase } from '../src/data-providers/sql-database.js';
|
|
5
|
+
import { PostgresSchemaBuilder } from './schema-builder.js';
|
|
5
6
|
export class PostgresDataProvider {
|
|
6
7
|
pool;
|
|
8
|
+
options;
|
|
7
9
|
supportsJsonColumnType = true;
|
|
8
10
|
static getDb(remult) {
|
|
9
11
|
const sql = SqlDatabase.getDb(remult);
|
|
@@ -20,12 +22,22 @@ export class PostgresDataProvider {
|
|
|
20
22
|
createCommand() {
|
|
21
23
|
return new PostgresBridgeToSQLCommand(this.pool);
|
|
22
24
|
}
|
|
23
|
-
constructor(pool) {
|
|
25
|
+
constructor(pool, options) {
|
|
24
26
|
this.pool = pool;
|
|
27
|
+
this.options = options;
|
|
28
|
+
if (options.wrapIdentifier)
|
|
29
|
+
this.wrapIdentifier = options.wrapIdentifier;
|
|
30
|
+
if (options.schema) {
|
|
31
|
+
this.pool = new PostgresSchemaWrapper(pool, options.schema);
|
|
32
|
+
}
|
|
25
33
|
}
|
|
34
|
+
wrapIdentifier = (name) => name
|
|
35
|
+
.split('.')
|
|
36
|
+
.map((name) => name.startsWith('"') ? name : '"' + name.replace(/"/g, '""') + '"')
|
|
37
|
+
.join('.');
|
|
26
38
|
async ensureSchema(entities) {
|
|
27
39
|
var db = new SqlDatabase(this);
|
|
28
|
-
var sb = new PostgresSchemaBuilder(db);
|
|
40
|
+
var sb = new PostgresSchemaBuilder(db, this.options?.schema);
|
|
29
41
|
await sb.ensureSchema(entities);
|
|
30
42
|
}
|
|
31
43
|
async transaction(action) {
|
|
@@ -42,6 +54,7 @@ export class PostgresDataProvider {
|
|
|
42
54
|
supportsJsonColumnType: this.supportsJsonColumnType,
|
|
43
55
|
//@ts-ignore
|
|
44
56
|
pool: client,
|
|
57
|
+
wrapIdentifier: this.wrapIdentifier,
|
|
45
58
|
});
|
|
46
59
|
await client.query('COMMIT');
|
|
47
60
|
}
|
|
@@ -66,7 +79,7 @@ class PostgresBridgeToSQLCommand {
|
|
|
66
79
|
this.values.push(val);
|
|
67
80
|
return '$' + this.values.length;
|
|
68
81
|
}
|
|
69
|
-
execute(sql) {
|
|
82
|
+
async execute(sql) {
|
|
70
83
|
return this.source
|
|
71
84
|
.query(sql, this.values)
|
|
72
85
|
.then((r) => new PostgresBridgeToSQLQueryResult(r));
|
|
@@ -110,7 +123,11 @@ export async function createPostgresDataProvider(options) {
|
|
|
110
123
|
if (!config.connectionString && options.connectionString) {
|
|
111
124
|
config.connectionString = options.connectionString;
|
|
112
125
|
}
|
|
113
|
-
const db = new SqlDatabase(new PostgresDataProvider(new Pool(config)
|
|
126
|
+
const db = new SqlDatabase(new PostgresDataProvider(new Pool(config), {
|
|
127
|
+
wrapIdentifier: options?.wrapIdentifier ||
|
|
128
|
+
(options.caseInsensitiveIdentifiers && ((name) => name)),
|
|
129
|
+
schema: options.schema,
|
|
130
|
+
}));
|
|
114
131
|
let remult = new Remult();
|
|
115
132
|
remult.dataProvider = db;
|
|
116
133
|
return db;
|
|
@@ -118,9 +135,31 @@ export async function createPostgresDataProvider(options) {
|
|
|
118
135
|
export async function preparePostgresQueueStorage(sql) {
|
|
119
136
|
let c = new Remult();
|
|
120
137
|
c.dataProvider = sql;
|
|
121
|
-
let JobsInQueueEntity = (await import('../server/expressBridge'))
|
|
138
|
+
let JobsInQueueEntity = (await import('../server/expressBridge.js'))
|
|
122
139
|
.JobsInQueueEntity;
|
|
123
140
|
let e = c.repo(JobsInQueueEntity);
|
|
124
141
|
await sql.ensureSchema([e.metadata]);
|
|
125
|
-
return new (await import('../server/expressBridge')).EntityQueueStorage(c.repo(JobsInQueueEntity));
|
|
142
|
+
return new (await import('../server/expressBridge.js')).EntityQueueStorage(c.repo(JobsInQueueEntity));
|
|
143
|
+
}
|
|
144
|
+
export class PostgresSchemaWrapper {
|
|
145
|
+
pool;
|
|
146
|
+
schema;
|
|
147
|
+
constructor(pool, schema) {
|
|
148
|
+
this.pool = pool;
|
|
149
|
+
this.schema = schema;
|
|
150
|
+
}
|
|
151
|
+
async connect() {
|
|
152
|
+
let r = await this.pool.connect();
|
|
153
|
+
await r.query('set search_path to ' + this.schema);
|
|
154
|
+
return r;
|
|
155
|
+
}
|
|
156
|
+
async query(queryText, values) {
|
|
157
|
+
let c = await this.connect();
|
|
158
|
+
try {
|
|
159
|
+
return await c.query(queryText, values);
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
c.release();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
126
165
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { allEntities } from '../src/context';
|
|
2
|
-
import { dbNamesOf, isDbReadonly, } from '../src/filter/filter-consumer-bridge-to-sql-request';
|
|
3
|
-
import { remult as defaultRemult } from '../src/remult-proxy';
|
|
4
|
-
import { isAutoIncrement } from '../src/remult3/RepositoryImplementation';
|
|
5
|
-
import { ValueConverters } from '../src/valueConverters';
|
|
1
|
+
import { allEntities } from '../src/context.js';
|
|
2
|
+
import { dbNamesOf, isDbReadonly, } from '../src/filter/filter-consumer-bridge-to-sql-request.js';
|
|
3
|
+
import { remult as defaultRemult } from '../src/remult-proxy.js';
|
|
4
|
+
import { isAutoIncrement } from '../src/remult3/RepositoryImplementation.js';
|
|
5
|
+
import { ValueConverters } from '../src/valueConverters.js';
|
|
6
6
|
export function postgresColumnSyntax(x, dbName) {
|
|
7
7
|
let result = dbName;
|
|
8
8
|
if (x.valueType == Number) {
|
|
@@ -97,7 +97,7 @@ export class PostgresSchemaBuilder {
|
|
|
97
97
|
const entities = [];
|
|
98
98
|
for (const entityClass of [...allEntities].reverse()) {
|
|
99
99
|
let entity = remult.repo(entityClass).metadata;
|
|
100
|
-
let e = await dbNamesOf(entity);
|
|
100
|
+
let e = await dbNamesOf(entity, this.pool.wrapIdentifier);
|
|
101
101
|
if (completed.has(e.$entityName))
|
|
102
102
|
continue;
|
|
103
103
|
completed.add(e.$entityName);
|
|
@@ -107,7 +107,7 @@ export class PostgresSchemaBuilder {
|
|
|
107
107
|
}
|
|
108
108
|
async ensureSchema(entities) {
|
|
109
109
|
for (const entity of entities) {
|
|
110
|
-
let e = await dbNamesOf(entity);
|
|
110
|
+
let e = await dbNamesOf(entity, this.pool.wrapIdentifier);
|
|
111
111
|
try {
|
|
112
112
|
if (!entity.options.sqlExpression) {
|
|
113
113
|
if (e.$entityName.toLowerCase().indexOf('from ') < 0) {
|
|
@@ -124,7 +124,7 @@ export class PostgresSchemaBuilder {
|
|
|
124
124
|
}
|
|
125
125
|
async createIfNotExist(entity) {
|
|
126
126
|
var c = this.pool.createCommand();
|
|
127
|
-
let e = await dbNamesOf(entity);
|
|
127
|
+
let e = await dbNamesOf(entity, this.pool.wrapIdentifier);
|
|
128
128
|
await c
|
|
129
129
|
.execute(`SELECT 1 FROM information_Schema.tables WHERE ` +
|
|
130
130
|
`${this.whereTableAndSchema(c, e)}`)
|
|
@@ -154,7 +154,7 @@ CREATE table ${this.schemaAndName(e)} (${result}\r\n)`;
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
async addColumnIfNotExist(entity, c) {
|
|
157
|
-
let e = await dbNamesOf(entity);
|
|
157
|
+
let e = await dbNamesOf(entity, this.pool.wrapIdentifier);
|
|
158
158
|
if (isDbReadonly(c(entity), e))
|
|
159
159
|
return;
|
|
160
160
|
try {
|
|
@@ -177,7 +177,7 @@ CREATE table ${this.schemaAndName(e)} (${result}\r\n)`;
|
|
|
177
177
|
async verifyAllColumns(entity) {
|
|
178
178
|
try {
|
|
179
179
|
let cmd = this.pool.createCommand();
|
|
180
|
-
let e = await dbNamesOf(entity);
|
|
180
|
+
let e = await dbNamesOf(entity, this.pool.wrapIdentifier);
|
|
181
181
|
let cols = (await cmd.execute(`SELECT column_name FROM information_schema.columns WHERE ` +
|
|
182
182
|
`${this.whereTableAndSchema(cmd, e)}`)).rows.map((x) => x.column_name.toLocaleLowerCase());
|
|
183
183
|
for (const col of entity.fields) {
|
package/esm/remult-express.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
|
-
import { createRemultServer } from './server/index';
|
|
2
|
+
import { createRemultServer } from './server/index.js';
|
|
3
3
|
export function remultExpress(options) {
|
|
4
4
|
let app = express.Router();
|
|
5
5
|
if (!options) {
|
|
@@ -21,6 +21,6 @@ export function remultExpress(options) {
|
|
|
21
21
|
getRemult: (req) => server.getRemult(req),
|
|
22
22
|
openApiDoc: (options) => server.openApiDoc(options),
|
|
23
23
|
withRemult: (req, res, next) => server.withRemult(req, res, next),
|
|
24
|
-
|
|
24
|
+
withRemultAsync: (req, what) => server.withRemultAsync(req, what),
|
|
25
25
|
});
|
|
26
26
|
}
|
package/esm/remult-fastify.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRemultServer } from './server/index';
|
|
1
|
+
import { createRemultServer } from './server/index.js';
|
|
2
2
|
export function remultFastify(options) {
|
|
3
3
|
function fastifyHandler(handler) {
|
|
4
4
|
const response = (req, res) => {
|
|
@@ -63,6 +63,6 @@ export function remultFastify(options) {
|
|
|
63
63
|
return Object.assign(pluginFunction, {
|
|
64
64
|
getRemult: (x) => api.getRemult(x),
|
|
65
65
|
openApiDoc: (x) => api.openApiDoc(x),
|
|
66
|
-
withRemult: (req, what) => api.
|
|
66
|
+
withRemult: (req, what) => api.withRemultAsync(req, what),
|
|
67
67
|
});
|
|
68
68
|
}
|
package/esm/remult-fresh.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRemultServerCore } from './server/expressBridge';
|
|
1
|
+
import { createRemultServerCore } from './server/expressBridge.js';
|
|
2
2
|
export function remultFresh(options, response) {
|
|
3
3
|
const server = createRemultServerCore(options, {
|
|
4
4
|
buildGenericRequestInfo: (r) => r,
|
package/esm/remult-hapi.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRemultServer, } from './server';
|
|
1
|
+
import { createRemultServer, } from './server/index.js';
|
|
2
2
|
import { PassThrough } from 'stream';
|
|
3
3
|
export function remultHapi(options) {
|
|
4
4
|
const api = createRemultServer(options, {
|
|
@@ -24,7 +24,6 @@ export function remultHapi(options) {
|
|
|
24
24
|
let r = {
|
|
25
25
|
status(statusCode) {
|
|
26
26
|
status = statusCode;
|
|
27
|
-
console.log(statusCode);
|
|
28
27
|
return r;
|
|
29
28
|
},
|
|
30
29
|
end() {
|
|
@@ -107,6 +106,6 @@ export function remultHapi(options) {
|
|
|
107
106
|
return Object.assign(routesPlugin, {
|
|
108
107
|
getRemult: (x) => api.getRemult(x),
|
|
109
108
|
openApiDoc: (x) => api.openApiDoc(x),
|
|
110
|
-
withRemult: (req, what) => api.
|
|
109
|
+
withRemult: (req, what) => api.withRemultAsync(req, what),
|
|
111
110
|
});
|
|
112
111
|
}
|
package/esm/remult-knex/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { allEntities } from '../src/context';
|
|
2
|
-
import { dbNamesOf, isDbReadonly, } from '../src/filter/filter-consumer-bridge-to-sql-request';
|
|
3
|
-
import { customDatabaseFilterToken, Filter, } from '../src/filter/filter-interfaces';
|
|
4
|
-
import { CompoundIdField } from '../src/CompoundIdField';
|
|
5
|
-
import { remult as remultContext } from '../src/remult-proxy';
|
|
6
|
-
import { getRepository, isAutoIncrement, } from '../src/remult3/RepositoryImplementation';
|
|
7
|
-
import { Sort } from '../src/sort';
|
|
8
|
-
import { ValueConverters } from '../src/valueConverters';
|
|
9
|
-
import { resultCompoundIdFilter as resultCompoundIdFilter } from '../src/resultCompoundIdFilter';
|
|
10
|
-
import { getRepositoryInternals } from '../src/remult3/repository-internals';
|
|
1
|
+
import { allEntities } from '../src/context.js';
|
|
2
|
+
import { dbNamesOf, isDbReadonly, } from '../src/filter/filter-consumer-bridge-to-sql-request.js';
|
|
3
|
+
import { customDatabaseFilterToken, Filter, } from '../src/filter/filter-interfaces.js';
|
|
4
|
+
import { CompoundIdField } from '../src/CompoundIdField.js';
|
|
5
|
+
import { remult as remultContext } from '../src/remult-proxy.js';
|
|
6
|
+
import { getRepository, isAutoIncrement, } from '../src/remult3/RepositoryImplementation.js';
|
|
7
|
+
import { Sort } from '../src/sort.js';
|
|
8
|
+
import { ValueConverters } from '../src/valueConverters.js';
|
|
9
|
+
import { resultCompoundIdFilter as resultCompoundIdFilter } from '../src/resultCompoundIdFilter.js';
|
|
10
|
+
import { getRepositoryInternals } from '../src/remult3/repository-internals.js';
|
|
11
11
|
export class KnexDataProvider {
|
|
12
12
|
knex;
|
|
13
13
|
constructor(knex) {
|
|
@@ -139,7 +139,16 @@ class KnexEntityDataProvider {
|
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
async init() {
|
|
142
|
-
|
|
142
|
+
const r = (await dbNamesOf(this.entity));
|
|
143
|
+
return {
|
|
144
|
+
$dbNameOf: (f) => {
|
|
145
|
+
let fm = f;
|
|
146
|
+
if (fm.options.sqlExpression)
|
|
147
|
+
return this.knex.raw(r.$dbNameOf(f));
|
|
148
|
+
return r.$dbNameOf(f);
|
|
149
|
+
},
|
|
150
|
+
$entityName: r.$entityName,
|
|
151
|
+
};
|
|
143
152
|
}
|
|
144
153
|
async update(id, data) {
|
|
145
154
|
const e = await this.init();
|
package/esm/remult-mongo.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ObjectId, } from 'mongodb';
|
|
2
|
-
import { CompoundIdField, Filter } from '.';
|
|
3
|
-
import { dbNamesOf } from './src/filter/filter-consumer-bridge-to-sql-request';
|
|
4
|
-
import { remult as remultContext } from './src/remult-proxy';
|
|
5
|
-
import { getRepository } from './src/remult3/RepositoryImplementation';
|
|
6
|
-
import { resultCompoundIdFilter } from './src/resultCompoundIdFilter';
|
|
7
|
-
import { getRepositoryInternals } from './src/remult3/repository-internals';
|
|
2
|
+
import { CompoundIdField, Filter } from './index.js';
|
|
3
|
+
import { dbNamesOf } from './src/filter/filter-consumer-bridge-to-sql-request.js';
|
|
4
|
+
import { remult as remultContext } from './src/remult-proxy.js';
|
|
5
|
+
import { getRepository } from './src/remult3/RepositoryImplementation.js';
|
|
6
|
+
import { resultCompoundIdFilter } from './src/resultCompoundIdFilter.js';
|
|
7
|
+
import { getRepositoryInternals } from './src/remult3/repository-internals.js';
|
|
8
8
|
export class MongoDataProvider {
|
|
9
9
|
db;
|
|
10
10
|
client;
|
package/esm/remult-next.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRemultServer } from './server';
|
|
1
|
+
import { createRemultServer } from './server/index.js';
|
|
2
2
|
export function remultNext(options) {
|
|
3
3
|
let result = createRemultServer(options, {
|
|
4
4
|
buildGenericRequestInfo: (req) => req,
|
|
@@ -109,6 +109,6 @@ export function remultNextApp(options) {
|
|
|
109
109
|
POST: handler,
|
|
110
110
|
PUT: handler,
|
|
111
111
|
DELETE: handler,
|
|
112
|
-
withRemult: (what) => result.
|
|
112
|
+
withRemult: (what) => result.withRemultAsync({}, what),
|
|
113
113
|
};
|
|
114
114
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { readBody } from 'h3';
|
|
2
|
+
import { createRemultServer, } from './server/index.js';
|
|
3
|
+
export function remultNuxt(options) {
|
|
4
|
+
const result = createRemultServer(options, {
|
|
5
|
+
buildGenericRequestInfo: (event) => {
|
|
6
|
+
return {
|
|
7
|
+
method: event.node.req.method,
|
|
8
|
+
url: event.node.req.url,
|
|
9
|
+
on: (a, b) => event.node.req.on('close', () => {
|
|
10
|
+
b();
|
|
11
|
+
}),
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
getRequestBody: async (event) => await readBody(event),
|
|
15
|
+
});
|
|
16
|
+
const handler = async (event) => {
|
|
17
|
+
let sse = false;
|
|
18
|
+
const response = {
|
|
19
|
+
end: () => { },
|
|
20
|
+
json: () => { },
|
|
21
|
+
status: () => {
|
|
22
|
+
return response;
|
|
23
|
+
},
|
|
24
|
+
write: (what) => {
|
|
25
|
+
event.node.res.write(what);
|
|
26
|
+
},
|
|
27
|
+
writeHead: (status, headers) => {
|
|
28
|
+
sse = true;
|
|
29
|
+
event.node.res.writeHead(status, headers);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const r = await result.handle(event, response);
|
|
33
|
+
if (sse) {
|
|
34
|
+
await new Promise((resolve) => {
|
|
35
|
+
event.node.req.on('close', () => resolve({}));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (r) {
|
|
39
|
+
return r.data;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return Object.assign(handler, {
|
|
43
|
+
getRemult: (req) => result.getRemult(req),
|
|
44
|
+
openApiDoc: (options) => result.openApiDoc(options),
|
|
45
|
+
withRemult(event, what) {
|
|
46
|
+
return result.withRemultAsync(event, what);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
package/esm/remult-sveltekit.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRemultServer } from './server';
|
|
1
|
+
import { createRemultServer } from './server/index.js';
|
|
2
2
|
export function remultSveltekit(options) {
|
|
3
3
|
let result = createRemultServer(options, {
|
|
4
4
|
buildGenericRequestInfo: (event) => ({
|
|
@@ -68,7 +68,7 @@ export function remultSveltekit(options) {
|
|
|
68
68
|
getRemult: (req) => result.getRemult(req),
|
|
69
69
|
openApiDoc: (options) => result.openApiDoc(options),
|
|
70
70
|
withRemult(request, what) {
|
|
71
|
-
return result.
|
|
71
|
+
return result.withRemultAsync(request, what);
|
|
72
72
|
},
|
|
73
73
|
});
|
|
74
74
|
}
|
package/esm/server/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createRemultServerCore, } from './expressBridge';
|
|
2
|
-
export { JsonEntityFileStorage, JsonFileDataProvider, } from './JsonEntityFileStorage';
|
|
3
|
-
export { SseSubscriptionServer } from '../SseSubscriptionServer';
|
|
4
|
-
export { DataProviderLiveQueryStorage } from '../live-query/data-provider-live-query-storage';
|
|
1
|
+
export { createRemultServerCore, } from './expressBridge.js';
|
|
2
|
+
export { JsonEntityFileStorage, JsonFileDataProvider, } from './JsonEntityFileStorage.js';
|
|
3
|
+
export { SseSubscriptionServer } from '../SseSubscriptionServer.js';
|
|
4
|
+
export { DataProviderLiveQueryStorage } from '../live-query/data-provider-live-query-storage.js';
|