@neupgroup/mapper 1.2.1 → 1.2.2

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.
@@ -0,0 +1,6 @@
1
+ import { ConfigBasedMapper, createDefaultMapper, createConfigMapper, getConfigMapper } from './config';
2
+ import type { MapperConfig, ConnectionConfig, DatabaseConnectionConfig, ApiConnectionConfig } from './config';
3
+ export { ConfigBasedMapper, createDefaultMapper, createConfigMapper, getConfigMapper };
4
+ export type { MapperConfig, ConnectionConfig, DatabaseConnectionConfig, ApiConnectionConfig };
5
+ export declare const mapper: ConfigBasedMapper;
6
+ export default mapper;
@@ -0,0 +1,7 @@
1
+ import { ConfigBasedMapper, createDefaultMapper, createConfigMapper, getConfigMapper } from './config';
2
+ // Re-export the config-based system as the primary interface
3
+ export { ConfigBasedMapper, createDefaultMapper, createConfigMapper, getConfigMapper };
4
+ // Create and export a default configured mapper instance
5
+ export const mapper = createDefaultMapper();
6
+ // Export the config-based mapper as the default export
7
+ export default mapper;
@@ -0,0 +1,68 @@
1
+ import { Connections, SchemaManager } from './index';
2
+ export interface DatabaseConnectionConfig {
3
+ name: string;
4
+ type: 'mysql' | 'sql' | 'firestore' | 'mongodb';
5
+ host: string;
6
+ port: number;
7
+ database: string;
8
+ user: string;
9
+ password?: string;
10
+ ssl?: boolean;
11
+ [key: string]: any;
12
+ }
13
+ export interface ApiConnectionConfig {
14
+ name: string;
15
+ type: 'api';
16
+ url: string;
17
+ headers?: Record<string, string>;
18
+ timeout?: number;
19
+ [key: string]: any;
20
+ }
21
+ export type ConnectionConfig = DatabaseConnectionConfig | ApiConnectionConfig;
22
+ export interface ConfigSchema {
23
+ name: string;
24
+ connection: string;
25
+ collection: string;
26
+ structure?: Record<string, string> | Array<{
27
+ name: string;
28
+ type: 'string' | 'number' | 'boolean' | 'date' | 'int';
29
+ [key: string]: any;
30
+ }>;
31
+ }
32
+ export interface MapperConfig {
33
+ connections: ConnectionConfig[];
34
+ schemas?: ConfigSchema[];
35
+ }
36
+ export declare class ConfigLoader {
37
+ private static instance;
38
+ private config?;
39
+ static getInstance(): ConfigLoader;
40
+ load(config: MapperConfig): void;
41
+ loadFromFile(path: string): void;
42
+ getConfig(): MapperConfig | undefined;
43
+ }
44
+ export declare class ConfigBasedMapper {
45
+ private mapper;
46
+ private configLoader;
47
+ private initialized;
48
+ constructor();
49
+ configure(config: MapperConfig): this;
50
+ configureFromFile(path: string): this;
51
+ private initializeFromConfig;
52
+ private initializeConnection;
53
+ private initializeSchema;
54
+ getConnections(): Connections;
55
+ getSchemaManager(): SchemaManager;
56
+ use(schemaName: string): any;
57
+ schema(name: string): any;
58
+ connect(name: string, type: 'mysql' | 'sql' | 'firestore' | 'mongodb' | 'api', config: Record<string, any>): import("./mapper").Mapper;
59
+ get(schemaName: string, filters?: Record<string, any>): Promise<Record<string, any>[]>;
60
+ getOne(schemaName: string, filters?: Record<string, any>): Promise<Record<string, any> | null>;
61
+ add(schemaName: string, data: Record<string, any>): Promise<any>;
62
+ update(schemaName: string, filters: Record<string, any>, data: Record<string, any>): Promise<void>;
63
+ delete(schemaName: string, filters: Record<string, any>): Promise<void>;
64
+ }
65
+ export declare function createConfigMapper(config?: MapperConfig): ConfigBasedMapper;
66
+ export declare function getConfigMapper(): ConfigBasedMapper;
67
+ export declare function createDefaultMapper(config?: MapperConfig): ConfigBasedMapper;
68
+ export default ConfigBasedMapper;
package/dist/config.js ADDED
@@ -0,0 +1,234 @@
1
+ import { createMapper } from './mapper';
2
+ export class ConfigLoader {
3
+ static getInstance() {
4
+ if (!ConfigLoader.instance) {
5
+ ConfigLoader.instance = new ConfigLoader();
6
+ }
7
+ return ConfigLoader.instance;
8
+ }
9
+ load(config) {
10
+ this.config = config;
11
+ }
12
+ loadFromFile(path) {
13
+ try {
14
+ // In Node.js environment
15
+ if (typeof require !== 'undefined') {
16
+ const fs = require('fs');
17
+ const configData = fs.readFileSync(path, 'utf8');
18
+ this.config = JSON.parse(configData);
19
+ }
20
+ else {
21
+ // In browser environment, fetch the config file
22
+ fetch(path)
23
+ .then(response => response.json())
24
+ .then(config => {
25
+ this.config = config;
26
+ })
27
+ .catch((error) => {
28
+ throw new Error(`Failed to load config from ${path}: ${error.message}`);
29
+ });
30
+ }
31
+ }
32
+ catch (error) {
33
+ throw new Error(`Failed to load config from ${path}: ${error.message}`);
34
+ }
35
+ }
36
+ getConfig() {
37
+ return this.config;
38
+ }
39
+ }
40
+ export class ConfigBasedMapper {
41
+ constructor() {
42
+ this.initialized = false;
43
+ this.mapper = createMapper();
44
+ this.configLoader = ConfigLoader.getInstance();
45
+ }
46
+ configure(config) {
47
+ this.configLoader.load(config);
48
+ this.initializeFromConfig();
49
+ return this;
50
+ }
51
+ configureFromFile(path) {
52
+ this.configLoader.loadFromFile(path);
53
+ this.initializeFromConfig();
54
+ return this;
55
+ }
56
+ initializeFromConfig() {
57
+ const config = this.configLoader.getConfig();
58
+ if (!config) {
59
+ throw new Error('No configuration loaded');
60
+ }
61
+ // Initialize connections
62
+ for (const connectionConfig of config.connections) {
63
+ this.initializeConnection(connectionConfig);
64
+ }
65
+ // Initialize schemas
66
+ if (config.schemas) {
67
+ for (const schemaConfig of config.schemas) {
68
+ this.initializeSchema(schemaConfig);
69
+ }
70
+ }
71
+ this.initialized = true;
72
+ }
73
+ initializeConnection(config) {
74
+ const { name, type } = config;
75
+ if (type === 'api') {
76
+ const apiConfig = config;
77
+ this.mapper.connect(name, type, apiConfig);
78
+ }
79
+ else {
80
+ const dbConfig = config;
81
+ this.mapper.connect(name, type, dbConfig);
82
+ }
83
+ }
84
+ initializeSchema(config) {
85
+ const schemaBuilder = this.mapper.schema(config.name);
86
+ schemaBuilder.use({ connection: config.connection, collection: config.collection });
87
+ if (config.structure) {
88
+ schemaBuilder.setStructure(config.structure);
89
+ }
90
+ }
91
+ // Delegate methods to the underlying mapper
92
+ getConnections() {
93
+ return this.mapper.getConnections();
94
+ }
95
+ getSchemaManager() {
96
+ return this.mapper.getSchemaManager();
97
+ }
98
+ use(schemaName) {
99
+ if (!this.initialized) {
100
+ throw new Error('Mapper not initialized. Call configure() first.');
101
+ }
102
+ return this.mapper.use(schemaName);
103
+ }
104
+ schema(name) {
105
+ if (!this.initialized) {
106
+ throw new Error('Mapper not initialized. Call configure() first.');
107
+ }
108
+ return this.mapper.schema(name);
109
+ }
110
+ connect(name, type, config) {
111
+ if (!this.initialized) {
112
+ throw new Error('Mapper not initialized. Call configure() first.');
113
+ }
114
+ return this.mapper.connect(name, type, config);
115
+ }
116
+ // Quick query methods
117
+ async get(schemaName, filters) {
118
+ if (!this.initialized) {
119
+ throw new Error('Mapper not initialized. Call configure() first.');
120
+ }
121
+ return this.mapper.get(schemaName, filters);
122
+ }
123
+ async getOne(schemaName, filters) {
124
+ if (!this.initialized) {
125
+ throw new Error('Mapper not initialized. Call configure() first.');
126
+ }
127
+ return this.mapper.getOne(schemaName, filters);
128
+ }
129
+ async add(schemaName, data) {
130
+ if (!this.initialized) {
131
+ throw new Error('Mapper not initialized. Call configure() first.');
132
+ }
133
+ return this.mapper.add(schemaName, data);
134
+ }
135
+ async update(schemaName, filters, data) {
136
+ if (!this.initialized) {
137
+ throw new Error('Mapper not initialized. Call configure() first.');
138
+ }
139
+ return this.mapper.update(schemaName, filters, data);
140
+ }
141
+ async delete(schemaName, filters) {
142
+ if (!this.initialized) {
143
+ throw new Error('Mapper not initialized. Call configure() first.');
144
+ }
145
+ return this.mapper.delete(schemaName, filters);
146
+ }
147
+ }
148
+ // Create a default instance
149
+ let defaultConfigMapper = null;
150
+ export function createConfigMapper(config) {
151
+ const mapper = new ConfigBasedMapper();
152
+ if (config) {
153
+ mapper.configure(config);
154
+ }
155
+ defaultConfigMapper = mapper;
156
+ return mapper;
157
+ }
158
+ // Export a function to get the default instance
159
+ export function getConfigMapper() {
160
+ if (!defaultConfigMapper) {
161
+ defaultConfigMapper = new ConfigBasedMapper();
162
+ }
163
+ return defaultConfigMapper;
164
+ }
165
+ // Create a default configured mapper instance
166
+ export function createDefaultMapper(config) {
167
+ const mapper = new ConfigBasedMapper();
168
+ // If no config provided, try to load from environment or default locations
169
+ if (!config) {
170
+ // Try to load from environment
171
+ const envConfig = loadConfigFromEnvironment();
172
+ if (envConfig) {
173
+ mapper.configure(envConfig);
174
+ }
175
+ else {
176
+ // Try to load from default config file locations
177
+ const defaultPaths = ['./mapper.config.json', './config/mapper.json', '/etc/mapper/config.json'];
178
+ for (const path of defaultPaths) {
179
+ try {
180
+ mapper.configureFromFile(path);
181
+ break;
182
+ }
183
+ catch (error) {
184
+ // Continue trying other paths
185
+ }
186
+ }
187
+ }
188
+ }
189
+ else {
190
+ mapper.configure(config);
191
+ }
192
+ return mapper;
193
+ }
194
+ function loadConfigFromEnvironment() {
195
+ if (typeof process !== 'undefined' && process.env) {
196
+ // Check for MAPPER_CONFIG environment variable
197
+ const envConfig = process.env.MAPPER_CONFIG;
198
+ if (envConfig) {
199
+ try {
200
+ return JSON.parse(envConfig);
201
+ }
202
+ catch (error) {
203
+ console.warn('Failed to parse MAPPER_CONFIG environment variable:', error);
204
+ }
205
+ }
206
+ // Check for individual database connection environment variables
207
+ const databaseUrl = process.env.DATABASE_URL;
208
+ if (databaseUrl) {
209
+ return {
210
+ connections: [{
211
+ name: 'default',
212
+ type: inferConnectionType(databaseUrl),
213
+ host: databaseUrl,
214
+ port: 5432,
215
+ database: 'default',
216
+ user: 'default'
217
+ }]
218
+ };
219
+ }
220
+ }
221
+ return null;
222
+ }
223
+ function inferConnectionType(url) {
224
+ if (url.includes('mysql'))
225
+ return 'mysql';
226
+ if (url.includes('postgres') || url.includes('postgresql'))
227
+ return 'sql';
228
+ if (url.includes('mongodb'))
229
+ return 'mongodb';
230
+ if (url.includes('firestore'))
231
+ return 'firestore';
232
+ return 'sql'; // default to sql
233
+ }
234
+ export default ConfigBasedMapper;
@@ -0,0 +1,80 @@
1
+ export declare class FluentQueryBuilder {
2
+ private mapper;
3
+ private schemaName;
4
+ private query;
5
+ constructor(mapper: any, schemaName: string);
6
+ where(field: string, value: any, operator?: string): this;
7
+ whereComplex(raw: string): this;
8
+ to(update: Record<string, any>): this;
9
+ get(): Promise<Record<string, any>[]>;
10
+ getOne(): Promise<Record<string, any> | null>;
11
+ add(data: Record<string, any>): Promise<any>;
12
+ update(): Promise<void>;
13
+ delete(): Promise<void>;
14
+ deleteOne(): Promise<void>;
15
+ updateOne(): Promise<void>;
16
+ }
17
+ export declare class FluentConnectionBuilder {
18
+ private mapper;
19
+ private connectionName;
20
+ private connectionType;
21
+ private connectionConfig;
22
+ constructor(mapper: any, connectionName: string, connectionType: string, config: Record<string, any>);
23
+ schema(schemaName: string): FluentSchemaBuilder;
24
+ query(schemaName: string): FluentQueryBuilder;
25
+ useConnection(connectionName: string): FluentConnectionSelector;
26
+ }
27
+ export declare class FluentSchemaBuilder {
28
+ private mapper;
29
+ private schemaName;
30
+ private connectionName;
31
+ constructor(mapper: any, schemaName: string, connectionName: string);
32
+ collection(collectionName: string): FluentSchemaCollectionBuilder;
33
+ }
34
+ export declare class FluentSchemaCollectionBuilder {
35
+ private mapper;
36
+ private schemaName;
37
+ private connectionName;
38
+ private collectionName;
39
+ constructor(mapper: any, schemaName: string, connectionName: string, collectionName: string);
40
+ structure(structure: Record<string, string> | Array<{
41
+ name: string;
42
+ type: string;
43
+ [key: string]: any;
44
+ }>): FluentMapper;
45
+ }
46
+ export declare class FluentConnectionSelector {
47
+ private mapper;
48
+ private connectionName;
49
+ constructor(mapper: any, connectionName: string);
50
+ schema(schemaName: string): FluentSchemaBuilder;
51
+ query(schemaName: string): FluentQueryBuilder;
52
+ }
53
+ export declare class FluentMapper {
54
+ private mapper;
55
+ constructor(mapper: any);
56
+ query(schemaName: string): FluentQueryBuilder;
57
+ makeConnection(name: string, type: 'mysql' | 'sql' | 'firestore' | 'mongodb' | 'api', config: Record<string, any>): FluentConnectionBuilder;
58
+ useConnection(connectionName: string): FluentConnectionSelector;
59
+ makeTempConnection(type: 'mysql' | 'sql' | 'firestore' | 'mongodb' | 'api', config: Record<string, any>): FluentConnectionBuilder;
60
+ get(schemaName: string, filters?: Record<string, any>): Promise<Record<string, any>[]>;
61
+ getOne(schemaName: string, filters?: Record<string, any>): Promise<Record<string, any> | null>;
62
+ add(schemaName: string, data: Record<string, any>): Promise<any>;
63
+ update(schemaName: string, filters: Record<string, any>, data: Record<string, any>): Promise<void>;
64
+ delete(schemaName: string, filters: Record<string, any>): Promise<void>;
65
+ }
66
+ export declare class StaticMapper {
67
+ private static instance;
68
+ private static getFluentMapper;
69
+ static makeConnection(name: string, type: 'mysql' | 'sql' | 'firestore' | 'mongodb' | 'api', config: Record<string, any>): FluentConnectionBuilder;
70
+ static useConnection(connectionName: string): FluentConnectionSelector;
71
+ static makeTempConnection(type: 'mysql' | 'sql' | 'firestore' | 'mongodb' | 'api', config: Record<string, any>): FluentConnectionBuilder;
72
+ static query(schemaName: string): FluentQueryBuilder;
73
+ static get(schemaName: string, filters?: Record<string, any>): Promise<Record<string, any>[]>;
74
+ static getOne(schemaName: string, filters?: Record<string, any>): Promise<Record<string, any> | null>;
75
+ static add(schemaName: string, data: Record<string, any>): Promise<any>;
76
+ static update(schemaName: string, filters: Record<string, any>, data: Record<string, any>): Promise<void>;
77
+ static delete(schemaName: string, filters: Record<string, any>): Promise<void>;
78
+ }
79
+ export declare const Mapper: typeof StaticMapper;
80
+ export default Mapper;
@@ -0,0 +1,171 @@
1
+ import { createMapper } from './mapper.js';
2
+ export class FluentQueryBuilder {
3
+ constructor(mapper, schemaName) {
4
+ this.mapper = mapper;
5
+ this.schemaName = schemaName;
6
+ this.query = mapper.use(schemaName);
7
+ }
8
+ where(field, value, operator) {
9
+ this.query.where(field, value, operator);
10
+ return this;
11
+ }
12
+ whereComplex(raw) {
13
+ this.query.whereComplex(raw);
14
+ return this;
15
+ }
16
+ to(update) {
17
+ this.query.to(update);
18
+ return this;
19
+ }
20
+ async get() {
21
+ return this.query.get();
22
+ }
23
+ async getOne() {
24
+ return this.query.getOne();
25
+ }
26
+ async add(data) {
27
+ return this.mapper.add(this.schemaName, data);
28
+ }
29
+ async update() {
30
+ return this.query.update();
31
+ }
32
+ async delete() {
33
+ return this.query.delete();
34
+ }
35
+ async deleteOne() {
36
+ return this.query.deleteOne();
37
+ }
38
+ async updateOne() {
39
+ return this.query.updateOne();
40
+ }
41
+ }
42
+ export class FluentConnectionBuilder {
43
+ constructor(mapper, connectionName, connectionType, config) {
44
+ this.mapper = mapper;
45
+ this.connectionName = connectionName;
46
+ this.connectionType = connectionType;
47
+ this.connectionConfig = config;
48
+ // Create the connection immediately
49
+ this.mapper.connect(connectionName, connectionType, config);
50
+ }
51
+ schema(schemaName) {
52
+ return new FluentSchemaBuilder(this.mapper, schemaName, this.connectionName);
53
+ }
54
+ query(schemaName) {
55
+ return new FluentQueryBuilder(this.mapper, schemaName);
56
+ }
57
+ useConnection(connectionName) {
58
+ return new FluentConnectionSelector(this.mapper, connectionName);
59
+ }
60
+ }
61
+ export class FluentSchemaBuilder {
62
+ constructor(mapper, schemaName, connectionName) {
63
+ this.mapper = mapper;
64
+ this.schemaName = schemaName;
65
+ this.connectionName = connectionName;
66
+ }
67
+ collection(collectionName) {
68
+ return new FluentSchemaCollectionBuilder(this.mapper, this.schemaName, this.connectionName, collectionName);
69
+ }
70
+ }
71
+ export class FluentSchemaCollectionBuilder {
72
+ constructor(mapper, schemaName, connectionName, collectionName) {
73
+ this.mapper = mapper;
74
+ this.schemaName = schemaName;
75
+ this.connectionName = connectionName;
76
+ this.collectionName = collectionName;
77
+ }
78
+ structure(structure) {
79
+ this.mapper.schema(this.schemaName)
80
+ .use({ connection: this.connectionName, collection: this.collectionName })
81
+ .setStructure(structure);
82
+ return new FluentMapper(this.mapper);
83
+ }
84
+ }
85
+ export class FluentConnectionSelector {
86
+ constructor(mapper, connectionName) {
87
+ this.mapper = mapper;
88
+ this.connectionName = connectionName;
89
+ }
90
+ schema(schemaName) {
91
+ return new FluentSchemaBuilder(this.mapper, schemaName, this.connectionName);
92
+ }
93
+ query(schemaName) {
94
+ return new FluentQueryBuilder(this.mapper, schemaName);
95
+ }
96
+ }
97
+ export class FluentMapper {
98
+ constructor(mapper) {
99
+ this.mapper = mapper;
100
+ }
101
+ query(schemaName) {
102
+ return new FluentQueryBuilder(this.mapper, schemaName);
103
+ }
104
+ makeConnection(name, type, config) {
105
+ return new FluentConnectionBuilder(this.mapper, name, type, config);
106
+ }
107
+ useConnection(connectionName) {
108
+ return new FluentConnectionSelector(this.mapper, connectionName);
109
+ }
110
+ makeTempConnection(type, config) {
111
+ const tempName = `temp_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
112
+ return new FluentConnectionBuilder(this.mapper, tempName, type, config);
113
+ }
114
+ // Direct query methods for quick usage
115
+ async get(schemaName, filters) {
116
+ return this.mapper.get(schemaName, filters);
117
+ }
118
+ async getOne(schemaName, filters) {
119
+ return this.mapper.getOne(schemaName, filters);
120
+ }
121
+ async add(schemaName, data) {
122
+ return this.mapper.add(schemaName, data);
123
+ }
124
+ async update(schemaName, filters, data) {
125
+ return this.mapper.update(schemaName, filters, data);
126
+ }
127
+ async delete(schemaName, filters) {
128
+ return this.mapper.delete(schemaName, filters);
129
+ }
130
+ }
131
+ // Static API class that provides the fluent interface
132
+ export class StaticMapper {
133
+ static getFluentMapper() {
134
+ if (!StaticMapper.instance) {
135
+ const baseMapper = createMapper();
136
+ StaticMapper.instance = new FluentMapper(baseMapper);
137
+ }
138
+ return StaticMapper.instance;
139
+ }
140
+ static makeConnection(name, type, config) {
141
+ return StaticMapper.getFluentMapper().makeConnection(name, type, config);
142
+ }
143
+ static useConnection(connectionName) {
144
+ return StaticMapper.getFluentMapper().useConnection(connectionName);
145
+ }
146
+ static makeTempConnection(type, config) {
147
+ return StaticMapper.getFluentMapper().makeTempConnection(type, config);
148
+ }
149
+ static query(schemaName) {
150
+ return StaticMapper.getFluentMapper().query(schemaName);
151
+ }
152
+ // Direct static methods
153
+ static async get(schemaName, filters) {
154
+ return StaticMapper.getFluentMapper().get(schemaName, filters);
155
+ }
156
+ static async getOne(schemaName, filters) {
157
+ return StaticMapper.getFluentMapper().getOne(schemaName, filters);
158
+ }
159
+ static async add(schemaName, data) {
160
+ return StaticMapper.getFluentMapper().add(schemaName, data);
161
+ }
162
+ static async update(schemaName, filters, data) {
163
+ return StaticMapper.getFluentMapper().update(schemaName, filters, data);
164
+ }
165
+ static async delete(schemaName, filters) {
166
+ return StaticMapper.getFluentMapper().delete(schemaName, filters);
167
+ }
168
+ }
169
+ // Export a default instance for convenience
170
+ export const Mapper = StaticMapper;
171
+ export default Mapper;
package/dist/index.d.ts CHANGED
@@ -89,3 +89,9 @@ export type { DbAdapter, QueryOptions };
89
89
  export { parseConnectionsDsl, toNormalizedConnections } from './env';
90
90
  export type { EnvDslConnections, NormalizedConnection } from './env';
91
91
  export { documentationMd, markdownToHtml, getDocumentationHtml } from './docs';
92
+ export { Mapper, createMapper } from './mapper';
93
+ export { default } from './mapper';
94
+ export { StaticMapper } from './fluent-mapper';
95
+ export type { FluentQueryBuilder, FluentConnectionBuilder, FluentSchemaBuilder, FluentSchemaCollectionBuilder, FluentConnectionSelector, FluentMapper } from './fluent-mapper';
96
+ export { ConfigBasedMapper, ConfigLoader, createConfigMapper, getConfigMapper, createDefaultMapper } from './config';
97
+ export type { MapperConfig, ConnectionConfig, DatabaseConnectionConfig, ApiConnectionConfig, ConfigSchema } from './config';
package/dist/index.js CHANGED
@@ -278,3 +278,10 @@ export const schemas = (() => {
278
278
  export { createOrm } from './orm';
279
279
  export { parseConnectionsDsl, toNormalizedConnections } from './env';
280
280
  export { documentationMd, markdownToHtml, getDocumentationHtml } from './docs';
281
+ // Export the simplified Mapper as default
282
+ export { Mapper, createMapper } from './mapper';
283
+ export { default } from './mapper';
284
+ // Export the new fluent/static API
285
+ export { StaticMapper } from './fluent-mapper';
286
+ // Export the new config-based system
287
+ export { ConfigBasedMapper, ConfigLoader, createConfigMapper, getConfigMapper, createDefaultMapper } from './config';
@@ -0,0 +1,27 @@
1
+ import { Connections, SchemaManager } from './index';
2
+ export declare class Mapper {
3
+ private connections;
4
+ private schemaManager;
5
+ private static instance;
6
+ constructor();
7
+ static getInstance(): Mapper;
8
+ autoConfigure(): this;
9
+ private detectEnvironmentConfig;
10
+ private inferConnectionType;
11
+ private applyConfig;
12
+ private applyDefaultConfig;
13
+ private createSchema;
14
+ connect(name: string, type: 'mysql' | 'sql' | 'firestore' | 'mongodb' | 'api', config: Record<string, any>): this;
15
+ schema(name: string): ReturnType<SchemaManager['create']>;
16
+ use(schemaName: string): ReturnType<SchemaManager['use']>;
17
+ get(schemaName: string, filters?: Record<string, any>): Promise<Record<string, any>[]>;
18
+ getOne(schemaName: string, filters?: Record<string, any>): Promise<Record<string, any> | null>;
19
+ add(schemaName: string, data: Record<string, any>): Promise<any>;
20
+ update(schemaName: string, filters: Record<string, any>, data: Record<string, any>): Promise<void>;
21
+ delete(schemaName: string, filters: Record<string, any>): Promise<void>;
22
+ getConnections(): Connections;
23
+ getSchemaManager(): SchemaManager;
24
+ }
25
+ export declare const createMapper: () => Mapper;
26
+ declare const _default: Mapper;
27
+ export default _default;