@memberjunction/server 5.13.0 → 5.15.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.
- package/dist/agents/skip-sdk.d.ts +8 -0
- package/dist/agents/skip-sdk.d.ts.map +1 -1
- package/dist/agents/skip-sdk.js +19 -0
- package/dist/agents/skip-sdk.js.map +1 -1
- package/dist/config.d.ts +37 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/generated/generated.d.ts +169 -0
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +909 -1
- package/dist/generated/generated.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/resolvers/GetDataResolver.d.ts.map +1 -1
- package/dist/resolvers/GetDataResolver.js +2 -1
- package/dist/resolvers/GetDataResolver.js.map +1 -1
- package/dist/resolvers/{CreateQueryResolver.d.ts → QuerySystemUserResolver.d.ts} +26 -82
- package/dist/resolvers/QuerySystemUserResolver.d.ts.map +1 -0
- package/dist/resolvers/{CreateQueryResolver.js → QuerySystemUserResolver.js} +123 -486
- package/dist/resolvers/QuerySystemUserResolver.js.map +1 -0
- package/dist/resolvers/TestQuerySQLResolver.d.ts +54 -0
- package/dist/resolvers/TestQuerySQLResolver.d.ts.map +1 -0
- package/dist/resolvers/TestQuerySQLResolver.js +189 -0
- package/dist/resolvers/TestQuerySQLResolver.js.map +1 -0
- package/package.json +59 -59
- package/src/agents/skip-sdk.ts +22 -0
- package/src/config.ts +8 -0
- package/src/generated/generated.ts +635 -2
- package/src/index.ts +2 -1
- package/src/resolvers/GetDataResolver.ts +2 -1
- package/src/resolvers/{CreateQueryResolver.ts → QuerySystemUserResolver.ts} +143 -413
- package/src/resolvers/TestQuerySQLResolver.ts +149 -0
- package/dist/resolvers/CreateQueryResolver.d.ts.map +0 -1
- package/dist/resolvers/CreateQueryResolver.js.map +0 -1
|
@@ -13,7 +13,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
import { Arg, Ctx, Field, InputType, Mutation, ObjectType, registerEnumType, Resolver, PubSub, PubSubEngine } from 'type-graphql';
|
|
14
14
|
import { LogError, RunView, CompositeKey, LogStatus } from '@memberjunction/core';
|
|
15
15
|
import { RequireSystemUser } from '../directives/RequireSystemUser.js';
|
|
16
|
-
import { MJQueryResolver } from '../generated/generated.js';
|
|
16
|
+
import { MJQueryResolver, MJQuery_ } from '../generated/generated.js';
|
|
17
17
|
import { GetReadWriteProvider } from '../util.js';
|
|
18
18
|
import { DeleteOptionsInput } from '../generic/DeleteOptionsInput.js';
|
|
19
19
|
/**
|
|
@@ -200,310 +200,32 @@ UpdateQuerySystemUserInput = __decorate([
|
|
|
200
200
|
InputType()
|
|
201
201
|
], UpdateQuerySystemUserInput);
|
|
202
202
|
export { UpdateQuerySystemUserInput };
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
], QueryFieldType.prototype, "QueryID", void 0);
|
|
213
|
-
__decorate([
|
|
214
|
-
Field(() => String),
|
|
215
|
-
__metadata("design:type", String)
|
|
216
|
-
], QueryFieldType.prototype, "Name", void 0);
|
|
217
|
-
__decorate([
|
|
218
|
-
Field(() => String, { nullable: true }),
|
|
219
|
-
__metadata("design:type", String)
|
|
220
|
-
], QueryFieldType.prototype, "Description", void 0);
|
|
221
|
-
__decorate([
|
|
222
|
-
Field(() => Number),
|
|
223
|
-
__metadata("design:type", Number)
|
|
224
|
-
], QueryFieldType.prototype, "Sequence", void 0);
|
|
225
|
-
__decorate([
|
|
226
|
-
Field(() => String, { nullable: true }),
|
|
227
|
-
__metadata("design:type", String)
|
|
228
|
-
], QueryFieldType.prototype, "SQLBaseType", void 0);
|
|
229
|
-
__decorate([
|
|
230
|
-
Field(() => String, { nullable: true }),
|
|
231
|
-
__metadata("design:type", String)
|
|
232
|
-
], QueryFieldType.prototype, "SQLFullType", void 0);
|
|
233
|
-
__decorate([
|
|
234
|
-
Field(() => String, { nullable: true }),
|
|
235
|
-
__metadata("design:type", String)
|
|
236
|
-
], QueryFieldType.prototype, "SourceEntityID", void 0);
|
|
237
|
-
__decorate([
|
|
238
|
-
Field(() => String, { nullable: true }),
|
|
239
|
-
__metadata("design:type", String)
|
|
240
|
-
], QueryFieldType.prototype, "SourceEntity", void 0);
|
|
241
|
-
__decorate([
|
|
242
|
-
Field(() => String, { nullable: true }),
|
|
243
|
-
__metadata("design:type", String)
|
|
244
|
-
], QueryFieldType.prototype, "SourceFieldName", void 0);
|
|
245
|
-
__decorate([
|
|
246
|
-
Field(() => Boolean),
|
|
247
|
-
__metadata("design:type", Boolean)
|
|
248
|
-
], QueryFieldType.prototype, "IsComputed", void 0);
|
|
249
|
-
__decorate([
|
|
250
|
-
Field(() => String, { nullable: true }),
|
|
251
|
-
__metadata("design:type", String)
|
|
252
|
-
], QueryFieldType.prototype, "ComputationDescription", void 0);
|
|
253
|
-
__decorate([
|
|
254
|
-
Field(() => Boolean, { nullable: true }),
|
|
255
|
-
__metadata("design:type", Boolean)
|
|
256
|
-
], QueryFieldType.prototype, "IsSummary", void 0);
|
|
257
|
-
__decorate([
|
|
258
|
-
Field(() => String, { nullable: true }),
|
|
259
|
-
__metadata("design:type", String)
|
|
260
|
-
], QueryFieldType.prototype, "SummaryDescription", void 0);
|
|
261
|
-
QueryFieldType = __decorate([
|
|
262
|
-
ObjectType()
|
|
263
|
-
], QueryFieldType);
|
|
264
|
-
export { QueryFieldType };
|
|
265
|
-
let QueryParameterType = class QueryParameterType {
|
|
266
|
-
};
|
|
267
|
-
__decorate([
|
|
268
|
-
Field(() => String),
|
|
269
|
-
__metadata("design:type", String)
|
|
270
|
-
], QueryParameterType.prototype, "ID", void 0);
|
|
271
|
-
__decorate([
|
|
272
|
-
Field(() => String),
|
|
273
|
-
__metadata("design:type", String)
|
|
274
|
-
], QueryParameterType.prototype, "QueryID", void 0);
|
|
275
|
-
__decorate([
|
|
276
|
-
Field(() => String),
|
|
277
|
-
__metadata("design:type", String)
|
|
278
|
-
], QueryParameterType.prototype, "Name", void 0);
|
|
279
|
-
__decorate([
|
|
280
|
-
Field(() => String, { nullable: true }),
|
|
281
|
-
__metadata("design:type", String)
|
|
282
|
-
], QueryParameterType.prototype, "Description", void 0);
|
|
283
|
-
__decorate([
|
|
284
|
-
Field(() => String),
|
|
285
|
-
__metadata("design:type", String)
|
|
286
|
-
], QueryParameterType.prototype, "Type", void 0);
|
|
287
|
-
__decorate([
|
|
288
|
-
Field(() => Boolean),
|
|
289
|
-
__metadata("design:type", Boolean)
|
|
290
|
-
], QueryParameterType.prototype, "IsRequired", void 0);
|
|
291
|
-
__decorate([
|
|
292
|
-
Field(() => String, { nullable: true }),
|
|
293
|
-
__metadata("design:type", String)
|
|
294
|
-
], QueryParameterType.prototype, "DefaultValue", void 0);
|
|
295
|
-
__decorate([
|
|
296
|
-
Field(() => String, { nullable: true }),
|
|
297
|
-
__metadata("design:type", String)
|
|
298
|
-
], QueryParameterType.prototype, "SampleValue", void 0);
|
|
299
|
-
__decorate([
|
|
300
|
-
Field(() => String, { nullable: true }),
|
|
301
|
-
__metadata("design:type", String)
|
|
302
|
-
], QueryParameterType.prototype, "ValidationFilters", void 0);
|
|
303
|
-
QueryParameterType = __decorate([
|
|
304
|
-
ObjectType()
|
|
305
|
-
], QueryParameterType);
|
|
306
|
-
export { QueryParameterType };
|
|
307
|
-
let MJQueryEntityType = class MJQueryEntityType {
|
|
308
|
-
};
|
|
309
|
-
__decorate([
|
|
310
|
-
Field(() => String),
|
|
311
|
-
__metadata("design:type", String)
|
|
312
|
-
], MJQueryEntityType.prototype, "ID", void 0);
|
|
313
|
-
__decorate([
|
|
314
|
-
Field(() => String),
|
|
315
|
-
__metadata("design:type", String)
|
|
316
|
-
], MJQueryEntityType.prototype, "QueryID", void 0);
|
|
317
|
-
__decorate([
|
|
318
|
-
Field(() => String),
|
|
319
|
-
__metadata("design:type", String)
|
|
320
|
-
], MJQueryEntityType.prototype, "EntityID", void 0);
|
|
321
|
-
__decorate([
|
|
322
|
-
Field(() => String, { nullable: true }),
|
|
323
|
-
__metadata("design:type", String)
|
|
324
|
-
], MJQueryEntityType.prototype, "Entity", void 0);
|
|
325
|
-
MJQueryEntityType = __decorate([
|
|
326
|
-
ObjectType()
|
|
327
|
-
], MJQueryEntityType);
|
|
328
|
-
export { MJQueryEntityType };
|
|
329
|
-
let QueryPermissionType = class QueryPermissionType {
|
|
330
|
-
};
|
|
331
|
-
__decorate([
|
|
332
|
-
Field(() => String),
|
|
333
|
-
__metadata("design:type", String)
|
|
334
|
-
], QueryPermissionType.prototype, "ID", void 0);
|
|
335
|
-
__decorate([
|
|
336
|
-
Field(() => String),
|
|
337
|
-
__metadata("design:type", String)
|
|
338
|
-
], QueryPermissionType.prototype, "QueryID", void 0);
|
|
339
|
-
__decorate([
|
|
340
|
-
Field(() => String),
|
|
341
|
-
__metadata("design:type", String)
|
|
342
|
-
], QueryPermissionType.prototype, "RoleID", void 0);
|
|
343
|
-
__decorate([
|
|
344
|
-
Field(() => String, { nullable: true }),
|
|
345
|
-
__metadata("design:type", String)
|
|
346
|
-
], QueryPermissionType.prototype, "Role", void 0);
|
|
347
|
-
QueryPermissionType = __decorate([
|
|
348
|
-
ObjectType()
|
|
349
|
-
], QueryPermissionType);
|
|
350
|
-
export { QueryPermissionType };
|
|
351
|
-
let CreateQueryResultType = class CreateQueryResultType {
|
|
352
|
-
};
|
|
353
|
-
__decorate([
|
|
354
|
-
Field(() => Boolean),
|
|
355
|
-
__metadata("design:type", Boolean)
|
|
356
|
-
], CreateQueryResultType.prototype, "Success", void 0);
|
|
357
|
-
__decorate([
|
|
358
|
-
Field(() => String, { nullable: true }),
|
|
359
|
-
__metadata("design:type", String)
|
|
360
|
-
], CreateQueryResultType.prototype, "ErrorMessage", void 0);
|
|
361
|
-
__decorate([
|
|
362
|
-
Field(() => String, { nullable: true }),
|
|
363
|
-
__metadata("design:type", String)
|
|
364
|
-
], CreateQueryResultType.prototype, "ID", void 0);
|
|
365
|
-
__decorate([
|
|
366
|
-
Field(() => String, { nullable: true }),
|
|
367
|
-
__metadata("design:type", String)
|
|
368
|
-
], CreateQueryResultType.prototype, "Name", void 0);
|
|
369
|
-
__decorate([
|
|
370
|
-
Field(() => String, { nullable: true }),
|
|
371
|
-
__metadata("design:type", String)
|
|
372
|
-
], CreateQueryResultType.prototype, "Description", void 0);
|
|
373
|
-
__decorate([
|
|
374
|
-
Field(() => String, { nullable: true }),
|
|
375
|
-
__metadata("design:type", String)
|
|
376
|
-
], CreateQueryResultType.prototype, "CategoryID", void 0);
|
|
377
|
-
__decorate([
|
|
378
|
-
Field(() => String, { nullable: true }),
|
|
379
|
-
__metadata("design:type", String)
|
|
380
|
-
], CreateQueryResultType.prototype, "Category", void 0);
|
|
381
|
-
__decorate([
|
|
382
|
-
Field(() => String, { nullable: true }),
|
|
383
|
-
__metadata("design:type", String)
|
|
384
|
-
], CreateQueryResultType.prototype, "SQL", void 0);
|
|
385
|
-
__decorate([
|
|
386
|
-
Field(() => String, { nullable: true }),
|
|
387
|
-
__metadata("design:type", String)
|
|
388
|
-
], CreateQueryResultType.prototype, "Status", void 0);
|
|
389
|
-
__decorate([
|
|
390
|
-
Field(() => Number, { nullable: true }),
|
|
391
|
-
__metadata("design:type", Number)
|
|
392
|
-
], CreateQueryResultType.prototype, "QualityRank", void 0);
|
|
393
|
-
__decorate([
|
|
394
|
-
Field(() => String, { nullable: true }),
|
|
395
|
-
__metadata("design:type", String)
|
|
396
|
-
], CreateQueryResultType.prototype, "EmbeddingVector", void 0);
|
|
397
|
-
__decorate([
|
|
398
|
-
Field(() => String, { nullable: true }),
|
|
399
|
-
__metadata("design:type", String)
|
|
400
|
-
], CreateQueryResultType.prototype, "EmbeddingModelID", void 0);
|
|
401
|
-
__decorate([
|
|
402
|
-
Field(() => String, { nullable: true }),
|
|
403
|
-
__metadata("design:type", String)
|
|
404
|
-
], CreateQueryResultType.prototype, "EmbeddingModelName", void 0);
|
|
405
|
-
__decorate([
|
|
406
|
-
Field(() => String, { nullable: true }),
|
|
407
|
-
__metadata("design:type", String)
|
|
408
|
-
], CreateQueryResultType.prototype, "TechnicalDescription", void 0);
|
|
409
|
-
__decorate([
|
|
410
|
-
Field(() => [QueryFieldType], { nullable: true }),
|
|
411
|
-
__metadata("design:type", Array)
|
|
412
|
-
], CreateQueryResultType.prototype, "Fields", void 0);
|
|
413
|
-
__decorate([
|
|
414
|
-
Field(() => [QueryParameterType], { nullable: true }),
|
|
415
|
-
__metadata("design:type", Array)
|
|
416
|
-
], CreateQueryResultType.prototype, "Parameters", void 0);
|
|
417
|
-
__decorate([
|
|
418
|
-
Field(() => [MJQueryEntityType], { nullable: true }),
|
|
419
|
-
__metadata("design:type", Array)
|
|
420
|
-
], CreateQueryResultType.prototype, "Entities", void 0);
|
|
421
|
-
__decorate([
|
|
422
|
-
Field(() => [QueryPermissionType], { nullable: true }),
|
|
423
|
-
__metadata("design:type", Array)
|
|
424
|
-
], CreateQueryResultType.prototype, "Permissions", void 0);
|
|
425
|
-
CreateQueryResultType = __decorate([
|
|
426
|
-
ObjectType()
|
|
427
|
-
], CreateQueryResultType);
|
|
428
|
-
export { CreateQueryResultType };
|
|
429
|
-
let UpdateQueryResultType = class UpdateQueryResultType {
|
|
203
|
+
/**
|
|
204
|
+
* Consolidated result type for Create and Update query mutations.
|
|
205
|
+
* Composes the CodeGen-generated MJQuery_ type so that new entity fields
|
|
206
|
+
* are automatically available in the GraphQL schema without manual sync.
|
|
207
|
+
*
|
|
208
|
+
* On success, Query contains the full query data (scalars + related entities).
|
|
209
|
+
* On failure, Query is null and ErrorMessage describes the problem.
|
|
210
|
+
*/
|
|
211
|
+
let QueryMutationResultType = class QueryMutationResultType {
|
|
430
212
|
};
|
|
431
213
|
__decorate([
|
|
432
214
|
Field(() => Boolean),
|
|
433
215
|
__metadata("design:type", Boolean)
|
|
434
|
-
],
|
|
435
|
-
__decorate([
|
|
436
|
-
Field(() => String, { nullable: true }),
|
|
437
|
-
__metadata("design:type", String)
|
|
438
|
-
], UpdateQueryResultType.prototype, "ErrorMessage", void 0);
|
|
439
|
-
__decorate([
|
|
440
|
-
Field(() => String, { nullable: true }),
|
|
441
|
-
__metadata("design:type", String)
|
|
442
|
-
], UpdateQueryResultType.prototype, "ID", void 0);
|
|
216
|
+
], QueryMutationResultType.prototype, "Success", void 0);
|
|
443
217
|
__decorate([
|
|
444
218
|
Field(() => String, { nullable: true }),
|
|
445
219
|
__metadata("design:type", String)
|
|
446
|
-
],
|
|
220
|
+
], QueryMutationResultType.prototype, "ErrorMessage", void 0);
|
|
447
221
|
__decorate([
|
|
448
|
-
Field(() =>
|
|
449
|
-
__metadata("design:type",
|
|
450
|
-
],
|
|
451
|
-
__decorate([
|
|
452
|
-
Field(() => String, { nullable: true }),
|
|
453
|
-
__metadata("design:type", String)
|
|
454
|
-
], UpdateQueryResultType.prototype, "CategoryID", void 0);
|
|
455
|
-
__decorate([
|
|
456
|
-
Field(() => String, { nullable: true }),
|
|
457
|
-
__metadata("design:type", String)
|
|
458
|
-
], UpdateQueryResultType.prototype, "Category", void 0);
|
|
459
|
-
__decorate([
|
|
460
|
-
Field(() => String, { nullable: true }),
|
|
461
|
-
__metadata("design:type", String)
|
|
462
|
-
], UpdateQueryResultType.prototype, "SQL", void 0);
|
|
463
|
-
__decorate([
|
|
464
|
-
Field(() => String, { nullable: true }),
|
|
465
|
-
__metadata("design:type", String)
|
|
466
|
-
], UpdateQueryResultType.prototype, "Status", void 0);
|
|
467
|
-
__decorate([
|
|
468
|
-
Field(() => Number, { nullable: true }),
|
|
469
|
-
__metadata("design:type", Number)
|
|
470
|
-
], UpdateQueryResultType.prototype, "QualityRank", void 0);
|
|
471
|
-
__decorate([
|
|
472
|
-
Field(() => String, { nullable: true }),
|
|
473
|
-
__metadata("design:type", String)
|
|
474
|
-
], UpdateQueryResultType.prototype, "EmbeddingVector", void 0);
|
|
475
|
-
__decorate([
|
|
476
|
-
Field(() => String, { nullable: true }),
|
|
477
|
-
__metadata("design:type", String)
|
|
478
|
-
], UpdateQueryResultType.prototype, "EmbeddingModelID", void 0);
|
|
479
|
-
__decorate([
|
|
480
|
-
Field(() => String, { nullable: true }),
|
|
481
|
-
__metadata("design:type", String)
|
|
482
|
-
], UpdateQueryResultType.prototype, "EmbeddingModelName", void 0);
|
|
483
|
-
__decorate([
|
|
484
|
-
Field(() => String, { nullable: true }),
|
|
485
|
-
__metadata("design:type", String)
|
|
486
|
-
], UpdateQueryResultType.prototype, "TechnicalDescription", void 0);
|
|
487
|
-
__decorate([
|
|
488
|
-
Field(() => [QueryFieldType], { nullable: true }),
|
|
489
|
-
__metadata("design:type", Array)
|
|
490
|
-
], UpdateQueryResultType.prototype, "Fields", void 0);
|
|
491
|
-
__decorate([
|
|
492
|
-
Field(() => [QueryParameterType], { nullable: true }),
|
|
493
|
-
__metadata("design:type", Array)
|
|
494
|
-
], UpdateQueryResultType.prototype, "Parameters", void 0);
|
|
495
|
-
__decorate([
|
|
496
|
-
Field(() => [MJQueryEntityType], { nullable: true }),
|
|
497
|
-
__metadata("design:type", Array)
|
|
498
|
-
], UpdateQueryResultType.prototype, "Entities", void 0);
|
|
499
|
-
__decorate([
|
|
500
|
-
Field(() => [QueryPermissionType], { nullable: true }),
|
|
501
|
-
__metadata("design:type", Array)
|
|
502
|
-
], UpdateQueryResultType.prototype, "Permissions", void 0);
|
|
503
|
-
UpdateQueryResultType = __decorate([
|
|
222
|
+
Field(() => MJQuery_, { nullable: true }),
|
|
223
|
+
__metadata("design:type", MJQuery_)
|
|
224
|
+
], QueryMutationResultType.prototype, "Query", void 0);
|
|
225
|
+
QueryMutationResultType = __decorate([
|
|
504
226
|
ObjectType()
|
|
505
|
-
],
|
|
506
|
-
export {
|
|
227
|
+
], QueryMutationResultType);
|
|
228
|
+
export { QueryMutationResultType };
|
|
507
229
|
let DeleteQueryResultType = class DeleteQueryResultType {
|
|
508
230
|
};
|
|
509
231
|
__decorate([
|
|
@@ -568,8 +290,8 @@ let MJQueryResolverExtended = class MJQueryResolverExtended extends MJQueryResol
|
|
|
568
290
|
}
|
|
569
291
|
// Use MJQueryEntityServer which handles AI processing
|
|
570
292
|
const record = await provider.GetEntityObject("MJ: Queries", context.userPayload.userRecord);
|
|
571
|
-
//
|
|
572
|
-
const fieldsToSet = {
|
|
293
|
+
// Destructure out non-database fields, keep only fields to persist
|
|
294
|
+
const { Permissions: _permissions, CategoryPath: _categoryPath, ...fieldsToSet } = {
|
|
573
295
|
...input,
|
|
574
296
|
CategoryID: finalCategoryID || input.CategoryID,
|
|
575
297
|
Status: input.Status || 'Approved',
|
|
@@ -580,9 +302,6 @@ let MJQueryResolverExtended = class MJQueryResolverExtended extends MJQueryResol
|
|
|
580
302
|
CacheTTLMinutes: input.CacheTTLMinutes || null,
|
|
581
303
|
CacheMaxSize: input.CacheMaxSize || null
|
|
582
304
|
};
|
|
583
|
-
// Remove non-database fields that we handle separately or are input-only
|
|
584
|
-
delete fieldsToSet.Permissions; // Handled separately via createPermissions
|
|
585
|
-
delete fieldsToSet.CategoryPath; // Input-only field, resolved to CategoryID
|
|
586
305
|
record.SetMany(fieldsToSet, true);
|
|
587
306
|
this.ListenForEntityMessages(record, pubSub, context.userPayload.userRecord);
|
|
588
307
|
// Attempt to save the query
|
|
@@ -598,122 +317,24 @@ let MJQueryResolverExtended = class MJQueryResolverExtended extends MJQueryResol
|
|
|
598
317
|
// Refresh metadata cache to include the newly created query
|
|
599
318
|
// This ensures subsequent operations can find the query without additional DB calls
|
|
600
319
|
await provider.Refresh();
|
|
601
|
-
return
|
|
602
|
-
Success: true,
|
|
603
|
-
ID: record.ID,
|
|
604
|
-
Name: record.Name,
|
|
605
|
-
Description: record.Description,
|
|
606
|
-
CategoryID: record.CategoryID,
|
|
607
|
-
Category: record.Category,
|
|
608
|
-
SQL: record.SQL,
|
|
609
|
-
Status: record.Status,
|
|
610
|
-
QualityRank: record.QualityRank,
|
|
611
|
-
EmbeddingVector: record.EmbeddingVector,
|
|
612
|
-
EmbeddingModelID: record.EmbeddingModelID,
|
|
613
|
-
EmbeddingModelName: record.EmbeddingModel,
|
|
614
|
-
TechnicalDescription: record.TechnicalDescription,
|
|
615
|
-
Fields: record.QueryFields.map(f => ({
|
|
616
|
-
ID: f.ID,
|
|
617
|
-
QueryID: f.QueryID,
|
|
618
|
-
Name: f.Name,
|
|
619
|
-
Description: f.Description,
|
|
620
|
-
Sequence: f.Sequence,
|
|
621
|
-
SQLBaseType: f.SQLBaseType,
|
|
622
|
-
SQLFullType: f.SQLFullType,
|
|
623
|
-
SourceEntityID: f.SourceEntityID,
|
|
624
|
-
SourceEntity: f.SourceEntity,
|
|
625
|
-
SourceFieldName: f.SourceFieldName,
|
|
626
|
-
IsComputed: f.IsComputed,
|
|
627
|
-
ComputationDescription: f.ComputationDescription,
|
|
628
|
-
IsSummary: f.IsSummary,
|
|
629
|
-
SummaryDescription: f.SummaryDescription
|
|
630
|
-
})),
|
|
631
|
-
Parameters: record.QueryParameters.map(p => ({
|
|
632
|
-
ID: p.ID,
|
|
633
|
-
QueryID: p.QueryID,
|
|
634
|
-
Name: p.Name,
|
|
635
|
-
Description: p.Description,
|
|
636
|
-
Type: p.Type,
|
|
637
|
-
IsRequired: p.IsRequired,
|
|
638
|
-
DefaultValue: p.DefaultValue,
|
|
639
|
-
SampleValue: p.SampleValue,
|
|
640
|
-
ValidationFilters: p.ValidationFilters
|
|
641
|
-
})),
|
|
642
|
-
Entities: record.QueryEntities.map(e => ({
|
|
643
|
-
ID: e.ID,
|
|
644
|
-
QueryID: e.QueryID,
|
|
645
|
-
EntityID: e.EntityID,
|
|
646
|
-
Entity: e.Entity
|
|
647
|
-
})),
|
|
648
|
-
Permissions: record.QueryPermissions.map(p => ({
|
|
649
|
-
ID: p.ID,
|
|
650
|
-
QueryID: p.QueryID,
|
|
651
|
-
RoleID: p.RoleID,
|
|
652
|
-
Role: p.Role
|
|
653
|
-
}))
|
|
654
|
-
};
|
|
320
|
+
return this.buildSuccessResult(record);
|
|
655
321
|
}
|
|
656
322
|
else {
|
|
657
323
|
// Save failed - check if another request created the same query (race condition)
|
|
658
324
|
// Always recheck regardless of error type to handle all duplicate scenarios
|
|
659
325
|
const existingQuery = await this.findExistingQuery(provider, input.Name, finalCategoryID, context.userPayload.userRecord);
|
|
660
326
|
if (existingQuery) {
|
|
661
|
-
// Found the query that was created by another request
|
|
662
|
-
//
|
|
327
|
+
// Found the query that was created by another request — load it as a full entity
|
|
328
|
+
// so that related metadata (Fields, Parameters, Entities, Permissions) is populated
|
|
663
329
|
LogStatus(`[CreateQuery] Unique constraint detected for query '${input.Name}'. Using existing query (ID: ${existingQuery.ID}) created by concurrent request.`);
|
|
330
|
+
const existingEntity = await provider.GetEntityObject('MJ: Queries', context.userPayload.userRecord);
|
|
331
|
+
if (await existingEntity.Load(existingQuery.ID)) {
|
|
332
|
+
return this.buildSuccessResult(existingEntity);
|
|
333
|
+
}
|
|
334
|
+
// Entity load failed after confirming the row exists — extremely rare
|
|
664
335
|
return {
|
|
665
|
-
Success:
|
|
666
|
-
ID: existingQuery.ID
|
|
667
|
-
Name: existingQuery.Name,
|
|
668
|
-
Description: existingQuery.Description,
|
|
669
|
-
CategoryID: existingQuery.CategoryID,
|
|
670
|
-
Category: existingQuery.Category,
|
|
671
|
-
SQL: existingQuery.SQL,
|
|
672
|
-
Status: existingQuery.Status,
|
|
673
|
-
QualityRank: existingQuery.QualityRank,
|
|
674
|
-
EmbeddingVector: existingQuery.EmbeddingVector,
|
|
675
|
-
EmbeddingModelID: existingQuery.EmbeddingModelID,
|
|
676
|
-
EmbeddingModelName: existingQuery.EmbeddingModel,
|
|
677
|
-
TechnicalDescription: existingQuery.TechnicalDescription,
|
|
678
|
-
Fields: existingQuery.Fields?.map((f) => ({
|
|
679
|
-
ID: f.ID,
|
|
680
|
-
QueryID: f.QueryID,
|
|
681
|
-
Name: f.Name,
|
|
682
|
-
Description: f.Description,
|
|
683
|
-
Sequence: f.Sequence,
|
|
684
|
-
SQLBaseType: f.SQLBaseType,
|
|
685
|
-
SQLFullType: f.SQLFullType,
|
|
686
|
-
SourceEntityID: f.SourceEntityID,
|
|
687
|
-
SourceEntity: f.SourceEntity,
|
|
688
|
-
SourceFieldName: f.SourceFieldName,
|
|
689
|
-
IsComputed: f.IsComputed,
|
|
690
|
-
ComputationDescription: f.ComputationDescription,
|
|
691
|
-
IsSummary: f.IsSummary,
|
|
692
|
-
SummaryDescription: f.SummaryDescription
|
|
693
|
-
})) || [],
|
|
694
|
-
Parameters: existingQuery.Parameters?.map((p) => ({
|
|
695
|
-
ID: p.ID,
|
|
696
|
-
QueryID: p.QueryID,
|
|
697
|
-
Name: p.Name,
|
|
698
|
-
Description: p.Description,
|
|
699
|
-
Type: p.Type,
|
|
700
|
-
IsRequired: p.IsRequired,
|
|
701
|
-
DefaultValue: p.DefaultValue,
|
|
702
|
-
SampleValue: p.SampleValue,
|
|
703
|
-
ValidationFilters: p.ValidationFilters
|
|
704
|
-
})) || [],
|
|
705
|
-
Entities: existingQuery.Entities?.map((e) => ({
|
|
706
|
-
ID: e.ID,
|
|
707
|
-
QueryID: e.QueryID,
|
|
708
|
-
EntityID: e.EntityID,
|
|
709
|
-
Entity: e.Entity
|
|
710
|
-
})) || [],
|
|
711
|
-
Permissions: existingQuery.Permissions?.map((p) => ({
|
|
712
|
-
ID: p.ID,
|
|
713
|
-
QueryID: p.QueryID,
|
|
714
|
-
RoleID: p.RoleID,
|
|
715
|
-
Role: p.Role
|
|
716
|
-
})) || []
|
|
336
|
+
Success: false,
|
|
337
|
+
ErrorMessage: `Found query '${input.Name}' created by concurrent request (ID: ${existingQuery.ID}) but failed to load it as entity`
|
|
717
338
|
};
|
|
718
339
|
}
|
|
719
340
|
// Genuine failure - couldn't find an existing query with the same name
|
|
@@ -732,28 +353,97 @@ let MJQueryResolverExtended = class MJQueryResolverExtended extends MJQueryResol
|
|
|
732
353
|
};
|
|
733
354
|
}
|
|
734
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Maps an MJQueryEntityServer (with loaded related metadata) to a QueryMutationResultType.
|
|
358
|
+
* Uses entity.GetAll() for scalar fields so that new CodeGen-generated fields are included
|
|
359
|
+
* automatically without manual updates. Related entity arrays are mapped explicitly.
|
|
360
|
+
*/
|
|
361
|
+
buildSuccessResult(entity) {
|
|
362
|
+
return {
|
|
363
|
+
Success: true,
|
|
364
|
+
Query: {
|
|
365
|
+
...entity.GetAll(),
|
|
366
|
+
MJQueryFields_QueryIDArray: this.mapFields(entity.QueryFields),
|
|
367
|
+
MJQueryParameters_QueryIDArray: this.mapParameters(entity.QueryParameters),
|
|
368
|
+
MJQueryEntities_QueryIDArray: this.mapEntities(entity.QueryEntities),
|
|
369
|
+
MJQueryPermissions_QueryIDArray: this.mapPermissions(entity.QueryPermissions),
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
mapFields(fields) {
|
|
374
|
+
return fields.map(f => ({
|
|
375
|
+
ID: f.ID,
|
|
376
|
+
QueryID: f.QueryID,
|
|
377
|
+
Name: f.Name,
|
|
378
|
+
Description: f.Description,
|
|
379
|
+
Sequence: f.Sequence,
|
|
380
|
+
SQLBaseType: f.SQLBaseType,
|
|
381
|
+
SQLFullType: f.SQLFullType,
|
|
382
|
+
SourceEntityID: f.SourceEntityID,
|
|
383
|
+
SourceEntity: f.SourceEntity,
|
|
384
|
+
SourceFieldName: f.SourceFieldName,
|
|
385
|
+
IsComputed: f.IsComputed,
|
|
386
|
+
ComputationDescription: f.ComputationDescription,
|
|
387
|
+
IsSummary: f.IsSummary,
|
|
388
|
+
SummaryDescription: f.SummaryDescription,
|
|
389
|
+
_mj__CreatedAt: f.__mj_CreatedAt,
|
|
390
|
+
_mj__UpdatedAt: f.__mj_UpdatedAt,
|
|
391
|
+
DetectionMethod: f.DetectionMethod,
|
|
392
|
+
AutoDetectConfidenceScore: f.AutoDetectConfidenceScore,
|
|
393
|
+
Query: '',
|
|
394
|
+
}));
|
|
395
|
+
}
|
|
396
|
+
mapParameters(params) {
|
|
397
|
+
return params.map(p => ({
|
|
398
|
+
ID: p.ID,
|
|
399
|
+
QueryID: p.QueryID,
|
|
400
|
+
Name: p.Name,
|
|
401
|
+
Description: p.Description,
|
|
402
|
+
Type: p.Type,
|
|
403
|
+
IsRequired: p.IsRequired,
|
|
404
|
+
DefaultValue: p.DefaultValue,
|
|
405
|
+
SampleValue: p.SampleValue,
|
|
406
|
+
ValidationFilters: p.ValidationFilters,
|
|
407
|
+
_mj__CreatedAt: p.__mj_CreatedAt,
|
|
408
|
+
_mj__UpdatedAt: p.__mj_UpdatedAt,
|
|
409
|
+
DetectionMethod: p.DetectionMethod,
|
|
410
|
+
AutoDetectConfidenceScore: p.AutoDetectConfidenceScore,
|
|
411
|
+
Query: p.Query ?? '',
|
|
412
|
+
}));
|
|
413
|
+
}
|
|
414
|
+
mapEntities(entities) {
|
|
415
|
+
return entities.map(e => ({
|
|
416
|
+
ID: e.ID,
|
|
417
|
+
QueryID: e.QueryID,
|
|
418
|
+
EntityID: e.EntityID,
|
|
419
|
+
Entity: e.Entity,
|
|
420
|
+
_mj__CreatedAt: e.__mj_CreatedAt,
|
|
421
|
+
_mj__UpdatedAt: e.__mj_UpdatedAt,
|
|
422
|
+
DetectionMethod: e.DetectionMethod,
|
|
423
|
+
AutoDetectConfidenceScore: e.AutoDetectConfidenceScore,
|
|
424
|
+
Query: e.Query ?? '',
|
|
425
|
+
}));
|
|
426
|
+
}
|
|
427
|
+
mapPermissions(permissions) {
|
|
428
|
+
return permissions.map(p => ({
|
|
429
|
+
ID: p.ID,
|
|
430
|
+
QueryID: p.QueryID,
|
|
431
|
+
RoleID: p.RoleID,
|
|
432
|
+
Role: p.Role,
|
|
433
|
+
_mj__CreatedAt: new Date(),
|
|
434
|
+
_mj__UpdatedAt: new Date(),
|
|
435
|
+
Query: p.Query ?? '',
|
|
436
|
+
}));
|
|
437
|
+
}
|
|
735
438
|
async createPermissions(p, permissions, queryID, contextUser) {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
permissionEntity.QueryID = queryID;
|
|
743
|
-
permissionEntity.RoleID = perm.RoleID;
|
|
744
|
-
const saveResult = await permissionEntity.Save();
|
|
745
|
-
if (saveResult) {
|
|
746
|
-
createdPermissions.push({
|
|
747
|
-
ID: permissionEntity.ID,
|
|
748
|
-
QueryID: permissionEntity.QueryID,
|
|
749
|
-
RoleID: permissionEntity.RoleID,
|
|
750
|
-
Role: permissionEntity.Role
|
|
751
|
-
});
|
|
752
|
-
}
|
|
753
|
-
}
|
|
439
|
+
for (const perm of permissions) {
|
|
440
|
+
const permissionEntity = await p.GetEntityObject('MJ: Query Permissions', contextUser);
|
|
441
|
+
if (permissionEntity) {
|
|
442
|
+
permissionEntity.QueryID = queryID;
|
|
443
|
+
permissionEntity.RoleID = perm.RoleID;
|
|
444
|
+
await permissionEntity.Save();
|
|
754
445
|
}
|
|
755
446
|
}
|
|
756
|
-
return createdPermissions;
|
|
757
447
|
}
|
|
758
448
|
/**
|
|
759
449
|
* Updates an existing query with the provided attributes. This mutation is restricted to system users only.
|
|
@@ -853,60 +543,7 @@ let MJQueryResolverExtended = class MJQueryResolverExtended extends MJQueryResol
|
|
|
853
543
|
// Refresh the metadata to get updated permissions
|
|
854
544
|
await queryEntity.RefreshRelatedMetadata(true);
|
|
855
545
|
}
|
|
856
|
-
return
|
|
857
|
-
Success: true,
|
|
858
|
-
ID: queryEntity.ID,
|
|
859
|
-
Name: queryEntity.Name,
|
|
860
|
-
Description: queryEntity.Description,
|
|
861
|
-
CategoryID: queryEntity.CategoryID,
|
|
862
|
-
Category: queryEntity.Category,
|
|
863
|
-
SQL: queryEntity.SQL,
|
|
864
|
-
Status: queryEntity.Status,
|
|
865
|
-
QualityRank: queryEntity.QualityRank,
|
|
866
|
-
EmbeddingVector: queryEntity.EmbeddingVector,
|
|
867
|
-
EmbeddingModelID: queryEntity.EmbeddingModelID,
|
|
868
|
-
EmbeddingModelName: queryEntity.EmbeddingModel,
|
|
869
|
-
TechnicalDescription: queryEntity.TechnicalDescription,
|
|
870
|
-
Fields: queryEntity.QueryFields.map(f => ({
|
|
871
|
-
ID: f.ID,
|
|
872
|
-
QueryID: f.QueryID,
|
|
873
|
-
Name: f.Name,
|
|
874
|
-
Description: f.Description,
|
|
875
|
-
Sequence: f.Sequence,
|
|
876
|
-
SQLBaseType: f.SQLBaseType,
|
|
877
|
-
SQLFullType: f.SQLFullType,
|
|
878
|
-
SourceEntityID: f.SourceEntityID,
|
|
879
|
-
SourceEntity: f.SourceEntity,
|
|
880
|
-
SourceFieldName: f.SourceFieldName,
|
|
881
|
-
IsComputed: f.IsComputed,
|
|
882
|
-
ComputationDescription: f.ComputationDescription,
|
|
883
|
-
IsSummary: f.IsSummary,
|
|
884
|
-
SummaryDescription: f.SummaryDescription
|
|
885
|
-
})),
|
|
886
|
-
Parameters: queryEntity.QueryParameters.map(p => ({
|
|
887
|
-
ID: p.ID,
|
|
888
|
-
QueryID: p.QueryID,
|
|
889
|
-
Name: p.Name,
|
|
890
|
-
Description: p.Description,
|
|
891
|
-
Type: p.Type,
|
|
892
|
-
IsRequired: p.IsRequired,
|
|
893
|
-
DefaultValue: p.DefaultValue,
|
|
894
|
-
SampleValue: p.SampleValue,
|
|
895
|
-
ValidationFilters: p.ValidationFilters
|
|
896
|
-
})),
|
|
897
|
-
Entities: queryEntity.QueryEntities.map(e => ({
|
|
898
|
-
ID: e.ID,
|
|
899
|
-
QueryID: e.QueryID,
|
|
900
|
-
EntityID: e.EntityID,
|
|
901
|
-
Entity: e.Entity
|
|
902
|
-
})),
|
|
903
|
-
Permissions: queryEntity.QueryPermissions.map(p => ({
|
|
904
|
-
ID: p.ID,
|
|
905
|
-
QueryID: p.QueryID,
|
|
906
|
-
RoleID: p.RoleID,
|
|
907
|
-
Role: p.Role
|
|
908
|
-
}))
|
|
909
|
-
};
|
|
546
|
+
return this.buildSuccessResult(queryEntity);
|
|
910
547
|
}
|
|
911
548
|
catch (err) {
|
|
912
549
|
LogError(err);
|
|
@@ -1054,7 +691,7 @@ let MJQueryResolverExtended = class MJQueryResolverExtended extends MJQueryResol
|
|
|
1054
691
|
* @param queryName - Name of the query to find
|
|
1055
692
|
* @param categoryID - Category ID (can be null)
|
|
1056
693
|
* @param contextUser - User context for database operations
|
|
1057
|
-
* @returns The matching query
|
|
694
|
+
* @returns The matching query row or null if not found
|
|
1058
695
|
*/
|
|
1059
696
|
async findExistingQuery(provider, queryName, categoryID, contextUser) {
|
|
1060
697
|
try {
|
|
@@ -1106,7 +743,7 @@ let MJQueryResolverExtended = class MJQueryResolverExtended extends MJQueryResol
|
|
|
1106
743
|
};
|
|
1107
744
|
__decorate([
|
|
1108
745
|
RequireSystemUser(),
|
|
1109
|
-
Mutation(() =>
|
|
746
|
+
Mutation(() => QueryMutationResultType),
|
|
1110
747
|
__param(0, Arg('input', () => CreateQuerySystemUserInput)),
|
|
1111
748
|
__param(1, Ctx()),
|
|
1112
749
|
__param(2, PubSub()),
|
|
@@ -1116,7 +753,7 @@ __decorate([
|
|
|
1116
753
|
], MJQueryResolverExtended.prototype, "CreateQuerySystemUser", null);
|
|
1117
754
|
__decorate([
|
|
1118
755
|
RequireSystemUser(),
|
|
1119
|
-
Mutation(() =>
|
|
756
|
+
Mutation(() => QueryMutationResultType),
|
|
1120
757
|
__param(0, Arg('input', () => UpdateQuerySystemUserInput)),
|
|
1121
758
|
__param(1, Ctx()),
|
|
1122
759
|
__param(2, PubSub()),
|
|
@@ -1139,4 +776,4 @@ MJQueryResolverExtended = __decorate([
|
|
|
1139
776
|
Resolver()
|
|
1140
777
|
], MJQueryResolverExtended);
|
|
1141
778
|
export { MJQueryResolverExtended };
|
|
1142
|
-
//# sourceMappingURL=
|
|
779
|
+
//# sourceMappingURL=QuerySystemUserResolver.js.map
|