@graphql-mesh/transport-mongo 0.0.0-stage → 0.1.0

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,168 @@
1
+ import { ObjectId } from 'mongodb';
2
+ import { parseMongoMapping, resolveMappingValue } from './mapping.js';
3
+ /**
4
+ * Build a MongoDB filter document from `@mongo(filter:)` (or legacy `where:`) mapping.
5
+ */
6
+ export function buildMongoFilter(filterSource, ctx) {
7
+ const parsed = parseMongoMapping(filterSource);
8
+ return filterFromMapping(parsed, ctx);
9
+ }
10
+ export function filterFromMapping(parsed, ctx) {
11
+ const filter = {};
12
+ for (const entry of parsed.entries) {
13
+ if (entry.spread && entry.value) {
14
+ const spreadVal = resolveMappingValue(entry.value, ctx);
15
+ if (spreadVal && typeof spreadVal === 'object' && !Array.isArray(spreadVal)) {
16
+ Object.assign(filter, graphqlFilterToMongo(spreadVal));
17
+ }
18
+ continue;
19
+ }
20
+ // Bare `$args.filter` / `$args.where` binder
21
+ if (entry.value?.kind === 'args' &&
22
+ (entry.key.startsWith('$args') || entry.key === `$args.${entry.value.value}`)) {
23
+ const val = resolveMappingValue(entry.value, ctx);
24
+ if (val && typeof val === 'object' && !Array.isArray(val)) {
25
+ Object.assign(filter, graphqlFilterToMongo(val));
26
+ }
27
+ continue;
28
+ }
29
+ if (entry.children || !entry.value)
30
+ continue;
31
+ const resolved = resolveMappingValue(entry.value, ctx);
32
+ if (resolved === undefined)
33
+ continue;
34
+ // `_id: $args._ids` (array) => `{ _id: { $in: [...] } }`
35
+ if (Array.isArray(resolved)) {
36
+ filter[entry.key] = { $in: resolved.map(coerceFilterValue) };
37
+ }
38
+ else {
39
+ filter[entry.key] = coerceFilterValue(resolved);
40
+ }
41
+ }
42
+ return filter;
43
+ }
44
+ /** @deprecated alias */
45
+ export const graphqlWhereToMongo = graphqlFilterToMongo;
46
+ export function graphqlFilterToMongo(input) {
47
+ const out = {};
48
+ for (const [key, value] of Object.entries(input)) {
49
+ if (value == null)
50
+ continue;
51
+ if (key === 'AND' || key === 'and') {
52
+ out.$and = value.map(graphqlFilterToMongo);
53
+ continue;
54
+ }
55
+ if (key === 'OR' || key === 'or') {
56
+ out.$or = value.map(graphqlFilterToMongo);
57
+ continue;
58
+ }
59
+ if (key === 'NOT' || key === 'not') {
60
+ out.$nor = [graphqlFilterToMongo(value)];
61
+ continue;
62
+ }
63
+ const mongoKey = key === 'id' ? '_id' : key;
64
+ if (typeof value !== 'object' || Array.isArray(value) || value instanceof Date) {
65
+ out[mongoKey] = coerceFilterValue(value);
66
+ continue;
67
+ }
68
+ const ops = value;
69
+ const mongoOps = {};
70
+ let hasOps = false;
71
+ for (const [op, opVal] of Object.entries(ops)) {
72
+ if (opVal === undefined)
73
+ continue;
74
+ hasOps = true;
75
+ switch (op) {
76
+ case 'eq':
77
+ out[mongoKey] = coerceFilterValue(opVal);
78
+ hasOps = false;
79
+ break;
80
+ case 'ne':
81
+ mongoOps.$ne = coerceFilterValue(opVal);
82
+ break;
83
+ case 'in':
84
+ mongoOps.$in = opVal.map(coerceFilterValue);
85
+ break;
86
+ case 'nin':
87
+ mongoOps.$nin = opVal.map(coerceFilterValue);
88
+ break;
89
+ case 'gt':
90
+ mongoOps.$gt = coerceFilterValue(opVal);
91
+ break;
92
+ case 'gte':
93
+ mongoOps.$gte = coerceFilterValue(opVal);
94
+ break;
95
+ case 'lt':
96
+ mongoOps.$lt = coerceFilterValue(opVal);
97
+ break;
98
+ case 'lte':
99
+ mongoOps.$lte = coerceFilterValue(opVal);
100
+ break;
101
+ case 'regex':
102
+ mongoOps.$regex = opVal;
103
+ break;
104
+ case 'exists':
105
+ mongoOps.$exists = opVal;
106
+ break;
107
+ default:
108
+ break;
109
+ }
110
+ if (!hasOps && op === 'eq')
111
+ break;
112
+ }
113
+ if (hasOps && Object.keys(mongoOps).length) {
114
+ out[mongoKey] = mongoOps;
115
+ }
116
+ }
117
+ return out;
118
+ }
119
+ export function buildMongoSort(sortSource, ctx) {
120
+ if (!sortSource)
121
+ return undefined;
122
+ const parsed = parseMongoMapping(sortSource);
123
+ if (parsed.entries.length === 1 && parsed.entries[0].value?.kind === 'args') {
124
+ const val = resolveMappingValue(parsed.entries[0].value, ctx);
125
+ return graphqlSortToMongo(val);
126
+ }
127
+ return undefined;
128
+ }
129
+ export function graphqlSortToMongo(input) {
130
+ if (!input || typeof input !== 'object')
131
+ return undefined;
132
+ const out = {};
133
+ for (const [key, dir] of Object.entries(input)) {
134
+ if (dir == null)
135
+ continue;
136
+ const mongoKey = key === 'id' ? '_id' : key;
137
+ const d = String(dir).toUpperCase();
138
+ out[mongoKey] = d === 'DESC' || d === '-1' ? -1 : 1;
139
+ }
140
+ return Object.keys(out).length ? out : undefined;
141
+ }
142
+ export function buildSetDocument(setSource, ctx) {
143
+ const parsed = parseMongoMapping(setSource);
144
+ const doc = {};
145
+ for (const entry of parsed.entries) {
146
+ if (entry.key === 'records' && entry.value?.kind === 'args') {
147
+ continue;
148
+ }
149
+ if (!entry.value)
150
+ continue;
151
+ const resolved = resolveMappingValue(entry.value, ctx);
152
+ if (resolved === undefined)
153
+ continue;
154
+ doc[entry.key] = resolved;
155
+ }
156
+ return doc;
157
+ }
158
+ export function coerceFilterValue(value) {
159
+ if (typeof value === 'string' && ObjectId.isValid(value) && value.length === 24) {
160
+ try {
161
+ return new ObjectId(value);
162
+ }
163
+ catch {
164
+ return value;
165
+ }
166
+ }
167
+ return value;
168
+ }
@@ -0,0 +1,13 @@
1
+ import { getMongoExecutor } from './execution.js';
2
+ export * from './client.js';
3
+ export * from './execution.js';
4
+ export * from './filter.js';
5
+ export * from './mapping.js';
6
+ export default {
7
+ getSubgraphExecutor({ subgraph, cwd }) {
8
+ return getMongoExecutor({
9
+ subgraph,
10
+ cwd,
11
+ });
12
+ },
13
+ };
@@ -0,0 +1,321 @@
1
+ /**
2
+ * Parse `@mongo` `where` / `set` / `selection` block strings.
3
+ * Skips `# ...` comments to EOL. Supports nested `{ ... }` blocks and `$args` / `$this` / `$pseudo`.
4
+ */
5
+ export function parseMongoMapping(source) {
6
+ if (source == null || !String(source).trim()) {
7
+ return { entries: [] };
8
+ }
9
+ const text = stripComments(String(source));
10
+ const { entries, next } = parseBlock(text, 0, false);
11
+ if (next < text.length && text.slice(next).trim()) {
12
+ throw new Error(`Unexpected trailing content in Mongo mapping: ${text.slice(next, next + 40)}`);
13
+ }
14
+ return { entries };
15
+ }
16
+ export function resolveMappingValue(value, ctx) {
17
+ if (!value)
18
+ return undefined;
19
+ switch (value.kind) {
20
+ case 'literal':
21
+ return value.value;
22
+ case 'column':
23
+ return value.value;
24
+ case 'pseudo':
25
+ return ctx.literals?.[value.value];
26
+ case 'args': {
27
+ return getPath(ctx.args, value.path || [value.value]);
28
+ }
29
+ case 'this': {
30
+ return getPath(ctx.parent, value.path || [value.value]);
31
+ }
32
+ default:
33
+ return undefined;
34
+ }
35
+ }
36
+ export function columnMapFromSelection(parsed) {
37
+ const map = new Map();
38
+ for (const entry of parsed.entries) {
39
+ if (entry.children || entry.spread)
40
+ continue;
41
+ if (entry.value?.kind === 'column') {
42
+ map.set(entry.key, entry.value.value);
43
+ }
44
+ }
45
+ return map;
46
+ }
47
+ /** Build a Mongo projection `{ path: 1 }` from selection column mappings. */
48
+ export function projectionFromSelection(parsed) {
49
+ const projection = {};
50
+ collectProjection(parsed.entries, projection);
51
+ return projection;
52
+ }
53
+ function collectProjection(entries, out) {
54
+ for (const entry of entries) {
55
+ if (entry.spread)
56
+ continue;
57
+ if (entry.children) {
58
+ collectProjection(entry.children, out);
59
+ continue;
60
+ }
61
+ if (entry.value?.kind === 'column') {
62
+ out[entry.value.value] = 1;
63
+ }
64
+ }
65
+ }
66
+ /**
67
+ * Map a Mongo document to GraphQL fields via selection.
68
+ * Nested blocks become nested objects; lists of subdocs pass through for now.
69
+ */
70
+ export function mapDocumentToGraphql(doc, selection) {
71
+ if (doc == null)
72
+ return null;
73
+ const out = {};
74
+ for (const entry of selection.entries) {
75
+ if (entry.spread)
76
+ continue;
77
+ if (entry.key === '$' || entry.value?.kind === 'pseudo')
78
+ continue;
79
+ if (entry.children) {
80
+ out[entry.key] = mapDocumentToGraphql(doc, { entries: entry.children });
81
+ continue;
82
+ }
83
+ if (entry.value?.kind === 'column') {
84
+ out[entry.key] = coerceGraphqlValue(getPath(doc, entry.value.value.split('.')));
85
+ }
86
+ }
87
+ return out;
88
+ }
89
+ /** graphql-scalars ObjectID serialize expects a 24-char hex string, not a driver ObjectId. */
90
+ function coerceGraphqlValue(value) {
91
+ if (value == null)
92
+ return value;
93
+ if (typeof value === 'object' && value !== null && 'toHexString' in value) {
94
+ try {
95
+ return value.toHexString();
96
+ }
97
+ catch {
98
+ return value;
99
+ }
100
+ }
101
+ return value;
102
+ }
103
+ function stripComments(source) {
104
+ return source
105
+ .split('\n')
106
+ .map(line => {
107
+ let inQuote = null;
108
+ for (let i = 0; i < line.length; i++) {
109
+ const c = line[i];
110
+ if (inQuote) {
111
+ if (c === '\\') {
112
+ i++;
113
+ continue;
114
+ }
115
+ if (c === inQuote)
116
+ inQuote = null;
117
+ continue;
118
+ }
119
+ if (c === '"' || c === "'") {
120
+ inQuote = c;
121
+ continue;
122
+ }
123
+ if (c === '#') {
124
+ return line.slice(0, i);
125
+ }
126
+ }
127
+ return line;
128
+ })
129
+ .join('\n');
130
+ }
131
+ function parseBlock(text, start, expectClosing) {
132
+ const entries = [];
133
+ let i = skipWs(text, start);
134
+ while (i < text.length) {
135
+ if (text[i] === '}') {
136
+ if (!expectClosing) {
137
+ throw new Error(`Unexpected "}" in Mongo mapping at ${i}`);
138
+ }
139
+ return { entries, next: i + 1 };
140
+ }
141
+ if (text.startsWith('...', i)) {
142
+ const afterDots = skipWs(text, i + 3);
143
+ if (afterDots >= text.length || text[afterDots] !== '$') {
144
+ throw new Error(`Expected "$" after "..." in Mongo mapping at ${i}`);
145
+ }
146
+ const rhs = readPseudoOrPath(text, afterDots);
147
+ if (rhs.value.kind !== 'args' && rhs.value.kind !== 'this') {
148
+ throw new Error(`Spread target must be $args / $this path, got ${rhs.raw}`);
149
+ }
150
+ entries.push({
151
+ key: `...${rhs.raw}`,
152
+ value: rhs.value,
153
+ spread: true,
154
+ });
155
+ i = skipWs(text, rhs.next);
156
+ continue;
157
+ }
158
+ if (text[i] === '$') {
159
+ const pseudo = readPseudoOrPath(text, i);
160
+ entries.push({
161
+ key: pseudo.raw,
162
+ value: pseudo.value,
163
+ });
164
+ i = skipWs(text, pseudo.next);
165
+ continue;
166
+ }
167
+ const key = readIdent(text, i);
168
+ i = skipWs(text, key.next);
169
+ if (i < text.length && text[i] === '{') {
170
+ const nested = parseBlock(text, i + 1, true);
171
+ entries.push({ key: key.value, children: nested.entries });
172
+ i = skipWs(text, nested.next);
173
+ continue;
174
+ }
175
+ if (i >= text.length || text[i] !== ':') {
176
+ entries.push({
177
+ key: key.value,
178
+ value: { kind: 'column', value: key.value },
179
+ });
180
+ continue;
181
+ }
182
+ i = skipWs(text, i + 1);
183
+ if (i < text.length && text[i] === '{') {
184
+ const nested = parseBlock(text, i + 1, true);
185
+ entries.push({ key: key.value, children: nested.entries });
186
+ i = skipWs(text, nested.next);
187
+ continue;
188
+ }
189
+ if (i < text.length && text[i] === '$') {
190
+ const rhs = readPseudoOrPath(text, i);
191
+ entries.push({ key: key.value, value: rhs.value });
192
+ i = skipWs(text, rhs.next);
193
+ continue;
194
+ }
195
+ if (i < text.length && (text[i] === '"' || text[i] === "'")) {
196
+ const lit = readQuoted(text, i);
197
+ entries.push({
198
+ key: key.value,
199
+ value: { kind: 'literal', value: lit.value },
200
+ });
201
+ i = skipWs(text, lit.next);
202
+ continue;
203
+ }
204
+ const col = readPathIdent(text, i);
205
+ entries.push({
206
+ key: key.value,
207
+ value: { kind: 'column', value: col.value },
208
+ });
209
+ i = skipWs(text, col.next);
210
+ }
211
+ if (expectClosing) {
212
+ throw new Error('Unclosed "{" in Mongo mapping');
213
+ }
214
+ return { entries, next: i };
215
+ }
216
+ function readPseudoOrPath(text, start) {
217
+ if (text[start] !== '$') {
218
+ throw new Error(`Expected "$" at ${start}`);
219
+ }
220
+ // bare `$`
221
+ if (start + 1 >= text.length || !isIdentStart(text[start + 1] ?? '')) {
222
+ return {
223
+ raw: '$',
224
+ value: { kind: 'pseudo', value: '$' },
225
+ next: start + 1,
226
+ };
227
+ }
228
+ const path = readDottedPath(text, start + 1);
229
+ const raw = `$${path.value}`;
230
+ const segments = path.value.split('.');
231
+ const head = segments[0];
232
+ if (head === 'args') {
233
+ return {
234
+ raw,
235
+ value: { kind: 'args', value: segments.slice(1).join('.') || 'args', path: segments.slice(1) },
236
+ next: path.next,
237
+ };
238
+ }
239
+ if (head === 'this') {
240
+ return {
241
+ raw,
242
+ value: { kind: 'this', value: segments.slice(1).join('.') || 'this', path: segments.slice(1) },
243
+ next: path.next,
244
+ };
245
+ }
246
+ return {
247
+ raw,
248
+ value: { kind: 'pseudo', value: path.value },
249
+ next: path.next,
250
+ };
251
+ }
252
+ function readIdent(text, start) {
253
+ if (!isIdentStart(text[start] ?? '')) {
254
+ throw new Error(`Expected identifier at ${start}`);
255
+ }
256
+ let i = start + 1;
257
+ while (i < text.length && isIdentPart(text[i]))
258
+ i++;
259
+ return { value: text.slice(start, i), next: i };
260
+ }
261
+ /** Ident or dotted mongo path (`address.street`). */
262
+ function readPathIdent(text, start) {
263
+ return readDottedPath(text, start);
264
+ }
265
+ function readDottedPath(text, start) {
266
+ const first = readIdent(text, start);
267
+ let value = first.value;
268
+ let i = first.next;
269
+ while (i < text.length && text[i] === '.') {
270
+ i++;
271
+ const next = readIdent(text, i);
272
+ value += `.${next.value}`;
273
+ i = next.next;
274
+ }
275
+ return { value, next: i };
276
+ }
277
+ function readQuoted(text, start) {
278
+ const quote = text[start];
279
+ let i = start + 1;
280
+ let out = '';
281
+ while (i < text.length) {
282
+ const c = text[i];
283
+ if (c === '\\') {
284
+ out += text[i + 1] ?? '';
285
+ i += 2;
286
+ continue;
287
+ }
288
+ if (c === quote) {
289
+ return { value: out, next: i + 1 };
290
+ }
291
+ out += c;
292
+ i++;
293
+ }
294
+ throw new Error('Unclosed string in Mongo mapping');
295
+ }
296
+ function skipWs(text, start) {
297
+ let i = start;
298
+ while (i < text.length && /\s/.test(text[i]))
299
+ i++;
300
+ return i;
301
+ }
302
+ function isIdentStart(c) {
303
+ const code = c.charCodeAt(0);
304
+ return ((code >= 65 && code <= 90) || (code >= 97 && code <= 122) || code === 95 /* _ */);
305
+ }
306
+ function isIdentPart(c) {
307
+ const code = c.charCodeAt(0);
308
+ return ((code >= 65 && code <= 90) ||
309
+ (code >= 97 && code <= 122) ||
310
+ (code >= 48 && code <= 57) ||
311
+ code === 95);
312
+ }
313
+ function getPath(obj, path) {
314
+ let cur = obj;
315
+ for (const seg of path) {
316
+ if (cur == null || typeof cur !== 'object')
317
+ return undefined;
318
+ cur = cur[seg];
319
+ }
320
+ return cur;
321
+ }
File without changes
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@graphql-mesh/transport-mongo",
3
+ "version": "0.1.0",
4
+ "sideEffects": false,
5
+ "peerDependencies": {
6
+ "graphql": "^16.0.0 || ^17.0.0"
7
+ },
8
+ "dependencies": {
9
+ "@graphql-mesh/transport-common": "^1.1.2",
10
+ "@graphql-mesh/utils": "^0.107.3",
11
+ "@graphql-tools/utils": "^13.2.2",
12
+ "@whatwg-node/disposablestack": "^0.1.0",
13
+ "mongodb": "^7.0.0",
14
+ "tslib": "^2.4.0"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "ardatan/graphql-mesh",
19
+ "directory": "packages/transports/mongo"
20
+ },
21
+ "license": "MIT",
22
+ "engines": {
23
+ "node": ">=22.18.0"
24
+ },
25
+ "main": "cjs/index.js",
26
+ "module": "esm/index.js",
27
+ "typings": "typings/index.d.ts",
28
+ "typescript": {
29
+ "definition": "typings/index.d.ts"
30
+ },
31
+ "type": "module",
32
+ "exports": {
33
+ ".": {
34
+ "require": {
35
+ "types": "./typings/index.d.cts",
36
+ "default": "./cjs/index.js"
37
+ },
38
+ "import": {
39
+ "types": "./typings/index.d.ts",
40
+ "default": "./esm/index.js"
41
+ },
42
+ "default": {
43
+ "types": "./typings/index.d.ts",
44
+ "default": "./esm/index.js"
45
+ }
46
+ },
47
+ "./package.json": "./package.json"
48
+ }
49
+ }
@@ -0,0 +1,5 @@
1
+ import type { MongoClientLike, MongoTransportOptions } from './types.cjs';
2
+ export interface CreateMongoClientOptions extends MongoTransportOptions {
3
+ location: string;
4
+ }
5
+ export declare function createMongoClient(opts: CreateMongoClientOptions): MongoClientLike;
@@ -0,0 +1,5 @@
1
+ import type { MongoClientLike, MongoTransportOptions } from './types.js';
2
+ export interface CreateMongoClientOptions extends MongoTransportOptions {
3
+ location: string;
4
+ }
5
+ export declare function createMongoClient(opts: CreateMongoClientOptions): MongoClientLike;
@@ -0,0 +1,9 @@
1
+ import type { GraphQLSchema } from 'graphql';
2
+ import { type DisposableExecutor } from '@graphql-mesh/transport-common';
3
+ import type { MongoClientLike } from './types.cjs';
4
+ export interface GetMongoExecutorOpts {
5
+ subgraph: GraphQLSchema;
6
+ client?: MongoClientLike;
7
+ cwd?: string;
8
+ }
9
+ export declare function getMongoExecutor({ subgraph, client }: GetMongoExecutorOpts): DisposableExecutor;
@@ -0,0 +1,9 @@
1
+ import type { GraphQLSchema } from 'graphql';
2
+ import { type DisposableExecutor } from '@graphql-mesh/transport-common';
3
+ import type { MongoClientLike } from './types.js';
4
+ export interface GetMongoExecutorOpts {
5
+ subgraph: GraphQLSchema;
6
+ client?: MongoClientLike;
7
+ cwd?: string;
8
+ }
9
+ export declare function getMongoExecutor({ subgraph, client }: GetMongoExecutorOpts): DisposableExecutor;
@@ -0,0 +1,24 @@
1
+ import type { ParsedMongoMapping } from './types.cjs';
2
+ /**
3
+ * Build a MongoDB filter document from `@mongo(filter:)` (or legacy `where:`) mapping.
4
+ */
5
+ export declare function buildMongoFilter(filterSource: string | null | undefined, ctx: {
6
+ args?: Record<string, unknown>;
7
+ parent?: unknown;
8
+ }): Record<string, unknown>;
9
+ export declare function filterFromMapping(parsed: ParsedMongoMapping, ctx: {
10
+ args?: Record<string, unknown>;
11
+ parent?: unknown;
12
+ }): Record<string, unknown>;
13
+ /** @deprecated alias */
14
+ export declare const graphqlWhereToMongo: typeof graphqlFilterToMongo;
15
+ export declare function graphqlFilterToMongo(input: Record<string, unknown>): Record<string, unknown>;
16
+ export declare function buildMongoSort(sortSource: string | null | undefined, ctx: {
17
+ args?: Record<string, unknown>;
18
+ }): Record<string, 1 | -1> | undefined;
19
+ export declare function graphqlSortToMongo(input: Record<string, unknown> | null | undefined): Record<string, 1 | -1> | undefined;
20
+ export declare function buildSetDocument(setSource: string | null | undefined, ctx: {
21
+ args?: Record<string, unknown>;
22
+ parent?: unknown;
23
+ }): Record<string, unknown>;
24
+ export declare function coerceFilterValue(value: unknown): unknown;
@@ -0,0 +1,24 @@
1
+ import type { ParsedMongoMapping } from './types.js';
2
+ /**
3
+ * Build a MongoDB filter document from `@mongo(filter:)` (or legacy `where:`) mapping.
4
+ */
5
+ export declare function buildMongoFilter(filterSource: string | null | undefined, ctx: {
6
+ args?: Record<string, unknown>;
7
+ parent?: unknown;
8
+ }): Record<string, unknown>;
9
+ export declare function filterFromMapping(parsed: ParsedMongoMapping, ctx: {
10
+ args?: Record<string, unknown>;
11
+ parent?: unknown;
12
+ }): Record<string, unknown>;
13
+ /** @deprecated alias */
14
+ export declare const graphqlWhereToMongo: typeof graphqlFilterToMongo;
15
+ export declare function graphqlFilterToMongo(input: Record<string, unknown>): Record<string, unknown>;
16
+ export declare function buildMongoSort(sortSource: string | null | undefined, ctx: {
17
+ args?: Record<string, unknown>;
18
+ }): Record<string, 1 | -1> | undefined;
19
+ export declare function graphqlSortToMongo(input: Record<string, unknown> | null | undefined): Record<string, 1 | -1> | undefined;
20
+ export declare function buildSetDocument(setSource: string | null | undefined, ctx: {
21
+ args?: Record<string, unknown>;
22
+ parent?: unknown;
23
+ }): Record<string, unknown>;
24
+ export declare function coerceFilterValue(value: unknown): unknown;
@@ -0,0 +1,10 @@
1
+ import type { MongoTransportOptions } from './types.cjs';
2
+ export * from './client.cjs';
3
+ export * from './execution.cjs';
4
+ export * from './filter.cjs';
5
+ export * from './mapping.cjs';
6
+ export type * from './types.cjs';
7
+ declare const _default: {
8
+ getSubgraphExecutor({ subgraph, cwd }: import("@graphql-mesh/transport-common").TransportGetSubgraphExecutorOptions<MongoTransportOptions>): import("@graphql-mesh/transport-common").DisposableExecutor;
9
+ };
10
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import type { MongoTransportOptions } from './types.js';
2
+ export * from './client.js';
3
+ export * from './execution.js';
4
+ export * from './filter.js';
5
+ export * from './mapping.js';
6
+ export type * from './types.js';
7
+ declare const _default: {
8
+ getSubgraphExecutor({ subgraph, cwd }: import("@graphql-mesh/transport-common").TransportGetSubgraphExecutorOptions<MongoTransportOptions>): import("@graphql-mesh/transport-common").DisposableExecutor;
9
+ };
10
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import type { MongoMappingValue, ParsedMongoMapping } from './types.cjs';
2
+ /**
3
+ * Parse `@mongo` `where` / `set` / `selection` block strings.
4
+ * Skips `# ...` comments to EOL. Supports nested `{ ... }` blocks and `$args` / `$this` / `$pseudo`.
5
+ */
6
+ export declare function parseMongoMapping(source: string | null | undefined): ParsedMongoMapping;
7
+ export declare function resolveMappingValue(value: MongoMappingValue | undefined, ctx: {
8
+ args?: Record<string, unknown>;
9
+ parent?: unknown;
10
+ literals?: Record<string, unknown>;
11
+ }): unknown;
12
+ export declare function columnMapFromSelection(parsed: ParsedMongoMapping): Map<string, string>;
13
+ /** Build a Mongo projection `{ path: 1 }` from selection column mappings. */
14
+ export declare function projectionFromSelection(parsed: ParsedMongoMapping): Record<string, 0 | 1>;
15
+ /**
16
+ * Map a Mongo document to GraphQL fields via selection.
17
+ * Nested blocks become nested objects; lists of subdocs pass through for now.
18
+ */
19
+ export declare function mapDocumentToGraphql(doc: Record<string, unknown> | null | undefined, selection: ParsedMongoMapping): Record<string, unknown> | null;