@memberjunction/server 5.35.0 → 5.37.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,930 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { LogError } from '@memberjunction/core';
14
+ import { ListOperations, ListSharing } from '@memberjunction/lists';
15
+ import { Arg, Ctx, Field, InputType, Int, Mutation, ObjectType, Query, Resolver } from 'type-graphql';
16
+ import { ResolverBase } from '../generic/ResolverBase.js';
17
+ import { GetReadWriteProvider } from '../util.js';
18
+ // ---------------------------------------------------------------------------
19
+ // GraphQL types — mirror the @memberjunction/lists shape one-to-one.
20
+ //
21
+ // Why duplicate: GraphQL types must be decorated with `@ObjectType` /
22
+ // `@InputType` / `@Field`, but @memberjunction/lists is intentionally
23
+ // framework-agnostic and ships zero type-graphql metadata. The duplication
24
+ // stays cheap because there's a single converter at each boundary
25
+ // (`fromCoreDelta`, `toCoreSource`) — drift gets caught at compile time
26
+ // when fields change shape.
27
+ // ---------------------------------------------------------------------------
28
+ /**
29
+ * Discriminated source descriptor as a flat input. GraphQL does not support
30
+ * tagged unions in inputs, so we encode the discriminator in `Kind` and
31
+ * the variant-specific payload in optional fields. Runtime validation
32
+ * enforces the right field-presence per kind.
33
+ */
34
+ let ListSourceInput = class ListSourceInput {
35
+ };
36
+ __decorate([
37
+ Field(() => String, { description: 'Discriminator. One of: list | view | adhoc.' }),
38
+ __metadata("design:type", String)
39
+ ], ListSourceInput.prototype, "Kind", void 0);
40
+ __decorate([
41
+ Field(() => String, { nullable: true, description: 'List ID, required when Kind=list.' }),
42
+ __metadata("design:type", String)
43
+ ], ListSourceInput.prototype, "ListID", void 0);
44
+ __decorate([
45
+ Field(() => String, { nullable: true, description: 'User View ID, required when Kind=view.' }),
46
+ __metadata("design:type", String)
47
+ ], ListSourceInput.prototype, "ViewID", void 0);
48
+ __decorate([
49
+ Field(() => String, { nullable: true, description: 'Entity name, required when Kind=adhoc.' }),
50
+ __metadata("design:type", String)
51
+ ], ListSourceInput.prototype, "EntityName", void 0);
52
+ __decorate([
53
+ Field(() => String, { nullable: true, description: 'WHERE clause expression, required when Kind=adhoc.' }),
54
+ __metadata("design:type", String)
55
+ ], ListSourceInput.prototype, "ExtraFilter", void 0);
56
+ ListSourceInput = __decorate([
57
+ InputType('ListSourceInput')
58
+ ], ListSourceInput);
59
+ export { ListSourceInput };
60
+ let MaterializeOptionsInput = class MaterializeOptionsInput {
61
+ };
62
+ __decorate([
63
+ Field(() => String),
64
+ __metadata("design:type", String)
65
+ ], MaterializeOptionsInput.prototype, "ListName", void 0);
66
+ __decorate([
67
+ Field(() => String, { nullable: true }),
68
+ __metadata("design:type", String)
69
+ ], MaterializeOptionsInput.prototype, "CategoryId", void 0);
70
+ __decorate([
71
+ Field(() => String, { nullable: true }),
72
+ __metadata("design:type", String)
73
+ ], MaterializeOptionsInput.prototype, "Description", void 0);
74
+ __decorate([
75
+ Field(() => Boolean),
76
+ __metadata("design:type", Boolean)
77
+ ], MaterializeOptionsInput.prototype, "RememberLineage", void 0);
78
+ __decorate([
79
+ Field(() => Boolean),
80
+ __metadata("design:type", Boolean)
81
+ ], MaterializeOptionsInput.prototype, "UseSnapshot", void 0);
82
+ __decorate([
83
+ Field(() => String, { description: 'Refresh mode: Additive | Sync.' }),
84
+ __metadata("design:type", String)
85
+ ], MaterializeOptionsInput.prototype, "RefreshMode", void 0);
86
+ MaterializeOptionsInput = __decorate([
87
+ InputType('MaterializeOptionsInput')
88
+ ], MaterializeOptionsInput);
89
+ export { MaterializeOptionsInput };
90
+ let ListDeltaCountsType = class ListDeltaCountsType {
91
+ };
92
+ __decorate([
93
+ Field(() => Int),
94
+ __metadata("design:type", Number)
95
+ ], ListDeltaCountsType.prototype, "Add", void 0);
96
+ __decorate([
97
+ Field(() => Int),
98
+ __metadata("design:type", Number)
99
+ ], ListDeltaCountsType.prototype, "Remove", void 0);
100
+ __decorate([
101
+ Field(() => Int),
102
+ __metadata("design:type", Number)
103
+ ], ListDeltaCountsType.prototype, "Unchanged", void 0);
104
+ __decorate([
105
+ Field(() => Int),
106
+ __metadata("design:type", Number)
107
+ ], ListDeltaCountsType.prototype, "SourceTotal", void 0);
108
+ __decorate([
109
+ Field(() => Int),
110
+ __metadata("design:type", Number)
111
+ ], ListDeltaCountsType.prototype, "TargetTotal", void 0);
112
+ ListDeltaCountsType = __decorate([
113
+ ObjectType('ListDeltaCountsType')
114
+ ], ListDeltaCountsType);
115
+ export { ListDeltaCountsType };
116
+ let ListDeltaWarningType = class ListDeltaWarningType {
117
+ };
118
+ __decorate([
119
+ Field(() => String),
120
+ __metadata("design:type", String)
121
+ ], ListDeltaWarningType.prototype, "Code", void 0);
122
+ __decorate([
123
+ Field(() => String),
124
+ __metadata("design:type", String)
125
+ ], ListDeltaWarningType.prototype, "Message", void 0);
126
+ __decorate([
127
+ Field(() => String, { nullable: true }),
128
+ __metadata("design:type", String)
129
+ ], ListDeltaWarningType.prototype, "DetailsJSON", void 0);
130
+ ListDeltaWarningType = __decorate([
131
+ ObjectType('ListDeltaWarningType')
132
+ ], ListDeltaWarningType);
133
+ export { ListDeltaWarningType };
134
+ let ListDeltaType = class ListDeltaType {
135
+ };
136
+ __decorate([
137
+ Field(() => String, { nullable: true }),
138
+ __metadata("design:type", String)
139
+ ], ListDeltaType.prototype, "TargetListId", void 0);
140
+ __decorate([
141
+ Field(() => String),
142
+ __metadata("design:type", String)
143
+ ], ListDeltaType.prototype, "EntityName", void 0);
144
+ __decorate([
145
+ Field(() => [String]),
146
+ __metadata("design:type", Array)
147
+ ], ListDeltaType.prototype, "ToAdd", void 0);
148
+ __decorate([
149
+ Field(() => [String]),
150
+ __metadata("design:type", Array)
151
+ ], ListDeltaType.prototype, "ToRemove", void 0);
152
+ __decorate([
153
+ Field(() => [String]),
154
+ __metadata("design:type", Array)
155
+ ], ListDeltaType.prototype, "Unchanged", void 0);
156
+ __decorate([
157
+ Field(() => ListDeltaCountsType),
158
+ __metadata("design:type", ListDeltaCountsType)
159
+ ], ListDeltaType.prototype, "Counts", void 0);
160
+ __decorate([
161
+ Field(() => [ListDeltaWarningType]),
162
+ __metadata("design:type", Array)
163
+ ], ListDeltaType.prototype, "Warnings", void 0);
164
+ __decorate([
165
+ Field(() => String),
166
+ __metadata("design:type", String)
167
+ ], ListDeltaType.prototype, "DeltaToken", void 0);
168
+ ListDeltaType = __decorate([
169
+ ObjectType('ListDeltaType')
170
+ ], ListDeltaType);
171
+ export { ListDeltaType };
172
+ let ApplyListResultType = class ApplyListResultType {
173
+ };
174
+ __decorate([
175
+ Field(() => Boolean),
176
+ __metadata("design:type", Boolean)
177
+ ], ApplyListResultType.prototype, "Success", void 0);
178
+ __decorate([
179
+ Field(() => String),
180
+ __metadata("design:type", String)
181
+ ], ApplyListResultType.prototype, "ResultCode", void 0);
182
+ __decorate([
183
+ Field(() => String),
184
+ __metadata("design:type", String)
185
+ ], ApplyListResultType.prototype, "Message", void 0);
186
+ __decorate([
187
+ Field(() => String, { nullable: true }),
188
+ __metadata("design:type", String)
189
+ ], ApplyListResultType.prototype, "CreatedListId", void 0);
190
+ __decorate([
191
+ Field(() => String, { nullable: true }),
192
+ __metadata("design:type", String)
193
+ ], ApplyListResultType.prototype, "TargetListId", void 0);
194
+ __decorate([
195
+ Field(() => Int, { nullable: true }),
196
+ __metadata("design:type", Number)
197
+ ], ApplyListResultType.prototype, "AddedCount", void 0);
198
+ __decorate([
199
+ Field(() => Int, { nullable: true }),
200
+ __metadata("design:type", Number)
201
+ ], ApplyListResultType.prototype, "RemovedCount", void 0);
202
+ __decorate([
203
+ Field(() => Int, { nullable: true }),
204
+ __metadata("design:type", Number)
205
+ ], ApplyListResultType.prototype, "FailedCount", void 0);
206
+ __decorate([
207
+ Field(() => [String], { nullable: true }),
208
+ __metadata("design:type", Array)
209
+ ], ApplyListResultType.prototype, "Errors", void 0);
210
+ ApplyListResultType = __decorate([
211
+ ObjectType('ApplyListResultType')
212
+ ], ApplyListResultType);
213
+ export { ApplyListResultType };
214
+ let ComputeDeltaInput = class ComputeDeltaInput {
215
+ };
216
+ __decorate([
217
+ Field(() => String, { description: 'TargetListId, or the literal string "new" to materialize.' }),
218
+ __metadata("design:type", String)
219
+ ], ComputeDeltaInput.prototype, "Target", void 0);
220
+ __decorate([
221
+ Field(() => ListSourceInput),
222
+ __metadata("design:type", ListSourceInput)
223
+ ], ComputeDeltaInput.prototype, "Source", void 0);
224
+ __decorate([
225
+ Field(() => String, { description: 'Refresh mode: Additive | Sync.' }),
226
+ __metadata("design:type", String)
227
+ ], ComputeDeltaInput.prototype, "Mode", void 0);
228
+ ComputeDeltaInput = __decorate([
229
+ InputType('ComputeDeltaInput')
230
+ ], ComputeDeltaInput);
231
+ export { ComputeDeltaInput };
232
+ let ApplyDeltaInput = class ApplyDeltaInput {
233
+ };
234
+ __decorate([
235
+ Field(() => String),
236
+ __metadata("design:type", String)
237
+ ], ApplyDeltaInput.prototype, "TargetListId", void 0);
238
+ __decorate([
239
+ Field(() => String),
240
+ __metadata("design:type", String)
241
+ ], ApplyDeltaInput.prototype, "EntityName", void 0);
242
+ __decorate([
243
+ Field(() => [String]),
244
+ __metadata("design:type", Array)
245
+ ], ApplyDeltaInput.prototype, "ToAdd", void 0);
246
+ __decorate([
247
+ Field(() => [String]),
248
+ __metadata("design:type", Array)
249
+ ], ApplyDeltaInput.prototype, "ToRemove", void 0);
250
+ __decorate([
251
+ Field(() => [String]),
252
+ __metadata("design:type", Array)
253
+ ], ApplyDeltaInput.prototype, "Unchanged", void 0);
254
+ __decorate([
255
+ Field(() => Int),
256
+ __metadata("design:type", Number)
257
+ ], ApplyDeltaInput.prototype, "AddCount", void 0);
258
+ __decorate([
259
+ Field(() => Int),
260
+ __metadata("design:type", Number)
261
+ ], ApplyDeltaInput.prototype, "RemoveCount", void 0);
262
+ __decorate([
263
+ Field(() => Int),
264
+ __metadata("design:type", Number)
265
+ ], ApplyDeltaInput.prototype, "UnchangedCount", void 0);
266
+ __decorate([
267
+ Field(() => Int),
268
+ __metadata("design:type", Number)
269
+ ], ApplyDeltaInput.prototype, "SourceTotal", void 0);
270
+ __decorate([
271
+ Field(() => Int),
272
+ __metadata("design:type", Number)
273
+ ], ApplyDeltaInput.prototype, "TargetTotal", void 0);
274
+ __decorate([
275
+ Field(() => String),
276
+ __metadata("design:type", String)
277
+ ], ApplyDeltaInput.prototype, "DeltaToken", void 0);
278
+ __decorate([
279
+ Field(() => Boolean),
280
+ __metadata("design:type", Boolean)
281
+ ], ApplyDeltaInput.prototype, "ConfirmDrops", void 0);
282
+ ApplyDeltaInput = __decorate([
283
+ InputType('ApplyDeltaInput')
284
+ ], ApplyDeltaInput);
285
+ export { ApplyDeltaInput };
286
+ // ---------------------------------------------------------------------------
287
+ // Sharing inputs / outputs (Phase 2)
288
+ // ---------------------------------------------------------------------------
289
+ let ShareTargetInput = class ShareTargetInput {
290
+ };
291
+ __decorate([
292
+ Field(() => String, { description: 'Target kind: user | role.' }),
293
+ __metadata("design:type", String)
294
+ ], ShareTargetInput.prototype, "Kind", void 0);
295
+ __decorate([
296
+ Field(() => String, { nullable: true, description: 'User ID, required when Kind=user.' }),
297
+ __metadata("design:type", String)
298
+ ], ShareTargetInput.prototype, "UserID", void 0);
299
+ __decorate([
300
+ Field(() => String, { nullable: true, description: 'Role ID, required when Kind=role.' }),
301
+ __metadata("design:type", String)
302
+ ], ShareTargetInput.prototype, "RoleID", void 0);
303
+ ShareTargetInput = __decorate([
304
+ InputType('ShareTargetInput')
305
+ ], ShareTargetInput);
306
+ export { ShareTargetInput };
307
+ let ShareListInput = class ShareListInput {
308
+ };
309
+ __decorate([
310
+ Field(() => String),
311
+ __metadata("design:type", String)
312
+ ], ShareListInput.prototype, "ListID", void 0);
313
+ __decorate([
314
+ Field(() => ShareTargetInput),
315
+ __metadata("design:type", ShareTargetInput)
316
+ ], ShareListInput.prototype, "Target", void 0);
317
+ __decorate([
318
+ Field(() => String, { description: 'Permission level: View | Edit | Owner.' }),
319
+ __metadata("design:type", String)
320
+ ], ShareListInput.prototype, "PermissionLevel", void 0);
321
+ ShareListInput = __decorate([
322
+ InputType('ShareListInput')
323
+ ], ShareListInput);
324
+ export { ShareListInput };
325
+ let InviteToListInput = class InviteToListInput {
326
+ };
327
+ __decorate([
328
+ Field(() => String),
329
+ __metadata("design:type", String)
330
+ ], InviteToListInput.prototype, "ListID", void 0);
331
+ __decorate([
332
+ Field(() => String),
333
+ __metadata("design:type", String)
334
+ ], InviteToListInput.prototype, "Email", void 0);
335
+ __decorate([
336
+ Field(() => String, { description: 'Role: Editor | Viewer.' }),
337
+ __metadata("design:type", String)
338
+ ], InviteToListInput.prototype, "Role", void 0);
339
+ __decorate([
340
+ Field(() => Int, { nullable: true, description: 'Optional TTL in hours. Defaults to 7 days.' }),
341
+ __metadata("design:type", Number)
342
+ ], InviteToListInput.prototype, "TtlHours", void 0);
343
+ InviteToListInput = __decorate([
344
+ InputType('InviteToListInput')
345
+ ], InviteToListInput);
346
+ export { InviteToListInput };
347
+ let ShareTargetType = class ShareTargetType {
348
+ };
349
+ __decorate([
350
+ Field(() => String),
351
+ __metadata("design:type", String)
352
+ ], ShareTargetType.prototype, "Kind", void 0);
353
+ __decorate([
354
+ Field(() => String, { nullable: true }),
355
+ __metadata("design:type", String)
356
+ ], ShareTargetType.prototype, "UserID", void 0);
357
+ __decorate([
358
+ Field(() => String, { nullable: true }),
359
+ __metadata("design:type", String)
360
+ ], ShareTargetType.prototype, "RoleID", void 0);
361
+ ShareTargetType = __decorate([
362
+ ObjectType('ShareTargetType')
363
+ ], ShareTargetType);
364
+ export { ShareTargetType };
365
+ let ListShareSummaryType = class ListShareSummaryType {
366
+ };
367
+ __decorate([
368
+ Field(() => String),
369
+ __metadata("design:type", String)
370
+ ], ListShareSummaryType.prototype, "PermissionID", void 0);
371
+ __decorate([
372
+ Field(() => String),
373
+ __metadata("design:type", String)
374
+ ], ListShareSummaryType.prototype, "ListID", void 0);
375
+ __decorate([
376
+ Field(() => ShareTargetType),
377
+ __metadata("design:type", ShareTargetType)
378
+ ], ListShareSummaryType.prototype, "Target", void 0);
379
+ __decorate([
380
+ Field(() => String),
381
+ __metadata("design:type", String)
382
+ ], ListShareSummaryType.prototype, "PermissionLevel", void 0);
383
+ __decorate([
384
+ Field(() => String),
385
+ __metadata("design:type", String)
386
+ ], ListShareSummaryType.prototype, "Status", void 0);
387
+ __decorate([
388
+ Field(() => String, { nullable: true }),
389
+ __metadata("design:type", String)
390
+ ], ListShareSummaryType.prototype, "SharedByUserID", void 0);
391
+ __decorate([
392
+ Field(() => Date),
393
+ __metadata("design:type", Date)
394
+ ], ListShareSummaryType.prototype, "CreatedAt", void 0);
395
+ ListShareSummaryType = __decorate([
396
+ ObjectType('ListShareSummaryType')
397
+ ], ListShareSummaryType);
398
+ export { ListShareSummaryType };
399
+ let SharedListSummaryType = class SharedListSummaryType {
400
+ };
401
+ __decorate([
402
+ Field(() => String),
403
+ __metadata("design:type", String)
404
+ ], SharedListSummaryType.prototype, "ListID", void 0);
405
+ __decorate([
406
+ Field(() => String),
407
+ __metadata("design:type", String)
408
+ ], SharedListSummaryType.prototype, "ListName", void 0);
409
+ __decorate([
410
+ Field(() => String),
411
+ __metadata("design:type", String)
412
+ ], SharedListSummaryType.prototype, "PermissionLevel", void 0);
413
+ __decorate([
414
+ Field(() => String, { nullable: true }),
415
+ __metadata("design:type", String)
416
+ ], SharedListSummaryType.prototype, "SharedByUserID", void 0);
417
+ __decorate([
418
+ Field(() => Date),
419
+ __metadata("design:type", Date)
420
+ ], SharedListSummaryType.prototype, "SharedAt", void 0);
421
+ SharedListSummaryType = __decorate([
422
+ ObjectType('SharedListSummaryType')
423
+ ], SharedListSummaryType);
424
+ export { SharedListSummaryType };
425
+ let ShareResultType = class ShareResultType {
426
+ };
427
+ __decorate([
428
+ Field(() => Boolean),
429
+ __metadata("design:type", Boolean)
430
+ ], ShareResultType.prototype, "Success", void 0);
431
+ __decorate([
432
+ Field(() => String),
433
+ __metadata("design:type", String)
434
+ ], ShareResultType.prototype, "ResultCode", void 0);
435
+ __decorate([
436
+ Field(() => String),
437
+ __metadata("design:type", String)
438
+ ], ShareResultType.prototype, "Message", void 0);
439
+ __decorate([
440
+ Field(() => String, { nullable: true }),
441
+ __metadata("design:type", String)
442
+ ], ShareResultType.prototype, "PermissionID", void 0);
443
+ ShareResultType = __decorate([
444
+ ObjectType('ShareResultType')
445
+ ], ShareResultType);
446
+ export { ShareResultType };
447
+ let InviteResultType = class InviteResultType {
448
+ };
449
+ __decorate([
450
+ Field(() => Boolean),
451
+ __metadata("design:type", Boolean)
452
+ ], InviteResultType.prototype, "Success", void 0);
453
+ __decorate([
454
+ Field(() => String),
455
+ __metadata("design:type", String)
456
+ ], InviteResultType.prototype, "ResultCode", void 0);
457
+ __decorate([
458
+ Field(() => String),
459
+ __metadata("design:type", String)
460
+ ], InviteResultType.prototype, "Message", void 0);
461
+ __decorate([
462
+ Field(() => String, { nullable: true }),
463
+ __metadata("design:type", String)
464
+ ], InviteResultType.prototype, "InvitationID", void 0);
465
+ __decorate([
466
+ Field(() => String, { nullable: true }),
467
+ __metadata("design:type", String)
468
+ ], InviteResultType.prototype, "Token", void 0);
469
+ __decorate([
470
+ Field(() => Date, { nullable: true }),
471
+ __metadata("design:type", Date)
472
+ ], InviteResultType.prototype, "ExpiresAt", void 0);
473
+ InviteResultType = __decorate([
474
+ ObjectType('InviteResultType')
475
+ ], InviteResultType);
476
+ export { InviteResultType };
477
+ let AcceptInvitationResultType = class AcceptInvitationResultType {
478
+ };
479
+ __decorate([
480
+ Field(() => Boolean),
481
+ __metadata("design:type", Boolean)
482
+ ], AcceptInvitationResultType.prototype, "Success", void 0);
483
+ __decorate([
484
+ Field(() => String),
485
+ __metadata("design:type", String)
486
+ ], AcceptInvitationResultType.prototype, "ResultCode", void 0);
487
+ __decorate([
488
+ Field(() => String),
489
+ __metadata("design:type", String)
490
+ ], AcceptInvitationResultType.prototype, "Message", void 0);
491
+ __decorate([
492
+ Field(() => String, { nullable: true }),
493
+ __metadata("design:type", String)
494
+ ], AcceptInvitationResultType.prototype, "PermissionID", void 0);
495
+ __decorate([
496
+ Field(() => String, { nullable: true }),
497
+ __metadata("design:type", String)
498
+ ], AcceptInvitationResultType.prototype, "ListID", void 0);
499
+ AcceptInvitationResultType = __decorate([
500
+ ObjectType('AcceptInvitationResultType')
501
+ ], AcceptInvitationResultType);
502
+ export { AcceptInvitationResultType };
503
+ let ComposeListsInput = class ComposeListsInput {
504
+ };
505
+ __decorate([
506
+ Field(() => String, { description: 'Set-op kind: union | intersection | difference.' }),
507
+ __metadata("design:type", String)
508
+ ], ComposeListsInput.prototype, "Op", void 0);
509
+ __decorate([
510
+ Field(() => [ListSourceInput]),
511
+ __metadata("design:type", Array)
512
+ ], ComposeListsInput.prototype, "Inputs", void 0);
513
+ __decorate([
514
+ Field(() => ListSourceInput, { nullable: true, description: 'Optional target list (for in-place set-op). Omit to preview against a new list.' }),
515
+ __metadata("design:type", ListSourceInput)
516
+ ], ComposeListsInput.prototype, "Target", void 0);
517
+ ComposeListsInput = __decorate([
518
+ InputType('ComposeListsInput')
519
+ ], ComposeListsInput);
520
+ export { ComposeListsInput };
521
+ // ---------------------------------------------------------------------------
522
+ // Boundary converters — exported for unit testing. Kept as standalone
523
+ // functions (not methods) so tests don't have to construct a full
524
+ // AppContext / type-graphql runtime.
525
+ // ---------------------------------------------------------------------------
526
+ export function toCoreSource(input) {
527
+ switch (input.Kind) {
528
+ case 'list':
529
+ if (!input.ListID)
530
+ throw new Error("ListSourceInput.ListID is required when Kind='list'");
531
+ return { kind: 'list', listId: input.ListID };
532
+ case 'view':
533
+ if (!input.ViewID)
534
+ throw new Error("ListSourceInput.ViewID is required when Kind='view'");
535
+ return { kind: 'view', viewId: input.ViewID };
536
+ case 'adhoc':
537
+ if (!input.EntityName || input.ExtraFilter == null) {
538
+ throw new Error("ListSourceInput.EntityName and ExtraFilter are required when Kind='adhoc'");
539
+ }
540
+ return { kind: 'adhoc', entityName: input.EntityName, extraFilter: input.ExtraFilter };
541
+ default:
542
+ throw new Error(`Unknown ListSourceInput.Kind: ${String(input.Kind)}`);
543
+ }
544
+ }
545
+ export function fromCoreDelta(delta) {
546
+ return {
547
+ TargetListId: delta.TargetListId,
548
+ EntityName: delta.EntityName,
549
+ ToAdd: delta.ToAdd,
550
+ ToRemove: delta.ToRemove,
551
+ Unchanged: delta.Unchanged,
552
+ Counts: { ...delta.Counts },
553
+ Warnings: delta.Warnings.map(fromCoreWarning),
554
+ DeltaToken: delta.DeltaToken,
555
+ };
556
+ }
557
+ export function fromCoreWarning(w) {
558
+ return {
559
+ Code: w.Code,
560
+ Message: w.Message,
561
+ DetailsJSON: w.Details ? JSON.stringify(w.Details) : undefined,
562
+ };
563
+ }
564
+ export function fromCoreApplyResult(r) {
565
+ return {
566
+ Success: r.Success,
567
+ ResultCode: r.ResultCode,
568
+ Message: r.Message,
569
+ CreatedListId: r.CreatedListId,
570
+ TargetListId: r.TargetListId,
571
+ AddedCount: r.Counts?.Added,
572
+ RemovedCount: r.Counts?.Removed,
573
+ FailedCount: r.Counts?.Failed,
574
+ Errors: r.Errors,
575
+ };
576
+ }
577
+ /** Convert a `ListShareSummary` from the core into the GraphQL DTO. */
578
+ export function fromCoreShareSummary(s) {
579
+ return {
580
+ PermissionID: s.PermissionID,
581
+ ListID: s.ListID,
582
+ Target: s.Target.kind === 'user'
583
+ ? { Kind: 'user', UserID: s.Target.userId }
584
+ : { Kind: 'role', RoleID: s.Target.roleId },
585
+ PermissionLevel: s.PermissionLevel,
586
+ Status: s.Status,
587
+ SharedByUserID: s.SharedByUserID ?? undefined,
588
+ CreatedAt: s.CreatedAt,
589
+ };
590
+ }
591
+ /** Guard for required-when-Kind-X fields on discriminated inputs. */
592
+ export function requireField(value, name) {
593
+ if (value == null)
594
+ throw new Error(`'${name}' is required`);
595
+ return value;
596
+ }
597
+ /** Three failure helpers — one per output type — keep the try/catch
598
+ * sites in the resolver methods tiny. */
599
+ export function shareUnexpected(e, op) {
600
+ const message = e instanceof Error ? e.message : String(e);
601
+ return { Success: false, ResultCode: 'UNEXPECTED_ERROR', Message: `${op}: ${message}` };
602
+ }
603
+ export function inviteUnexpected(e, op) {
604
+ const message = e instanceof Error ? e.message : String(e);
605
+ return { Success: false, ResultCode: 'UNEXPECTED_ERROR', Message: `${op}: ${message}` };
606
+ }
607
+ export function acceptInvitationUnexpected(e, op) {
608
+ const message = e instanceof Error ? e.message : String(e);
609
+ return { Success: false, ResultCode: 'UNEXPECTED_ERROR', Message: `${op}: ${message}` };
610
+ }
611
+ export function rebuildDeltaFromInput(input) {
612
+ return {
613
+ TargetListId: input.TargetListId,
614
+ EntityName: input.EntityName,
615
+ ToAdd: input.ToAdd,
616
+ ToRemove: input.ToRemove,
617
+ Unchanged: input.Unchanged,
618
+ Counts: {
619
+ Add: input.AddCount,
620
+ Remove: input.RemoveCount,
621
+ Unchanged: input.UnchangedCount,
622
+ SourceTotal: input.SourceTotal,
623
+ TargetTotal: input.TargetTotal,
624
+ },
625
+ Warnings: [],
626
+ DeltaToken: input.DeltaToken,
627
+ };
628
+ }
629
+ // ---------------------------------------------------------------------------
630
+ // Resolver
631
+ //
632
+ // All public capability flows through one `ListOperations` instance per
633
+ // request, constructed with the per-request read-write provider and the
634
+ // authenticated user. Auth is enforced at two layers: this resolver checks
635
+ // the user is authenticated (via UserPayload), and `ListOperations` itself
636
+ // enforces the drop-guard / token / staleness contract.
637
+ // ---------------------------------------------------------------------------
638
+ let ListOperationsResolver = class ListOperationsResolver extends ResolverBase {
639
+ async PreviewListDelta(input, ctx) {
640
+ const ops = this.buildOps(ctx);
641
+ const source = toCoreSource(input.Source);
642
+ const target = input.Target === 'new' ? 'new' : { kind: 'list', listId: input.Target };
643
+ const delta = await ops.ComputeDelta(target, source, input.Mode);
644
+ return fromCoreDelta(delta);
645
+ }
646
+ async ApplyListDelta(input, ctx) {
647
+ const ops = this.buildOps(ctx);
648
+ try {
649
+ const delta = rebuildDeltaFromInput(input);
650
+ const result = await ops.ApplyDelta(delta, {
651
+ ConfirmDrops: input.ConfirmDrops,
652
+ DeltaToken: input.DeltaToken,
653
+ });
654
+ return fromCoreApplyResult(result);
655
+ }
656
+ catch (e) {
657
+ return this.unexpectedFailure(e, 'ApplyListDelta');
658
+ }
659
+ }
660
+ async MaterializeListFromView(viewId, options, ctx) {
661
+ const ops = this.buildOps(ctx);
662
+ try {
663
+ const opts = {
664
+ ListName: options.ListName,
665
+ CategoryId: options.CategoryId,
666
+ Description: options.Description,
667
+ RememberLineage: options.RememberLineage,
668
+ UseSnapshot: options.UseSnapshot,
669
+ RefreshMode: options.RefreshMode,
670
+ };
671
+ const result = await ops.MaterializeFromView(viewId, opts);
672
+ return fromCoreApplyResult(result);
673
+ }
674
+ catch (e) {
675
+ return this.unexpectedFailure(e, 'MaterializeListFromView');
676
+ }
677
+ }
678
+ async AddViewResultsToList(viewId, listId, ctx) {
679
+ const ops = this.buildOps(ctx);
680
+ try {
681
+ const result = await ops.AddViewResultsToList(viewId, listId);
682
+ return fromCoreApplyResult(result);
683
+ }
684
+ catch (e) {
685
+ return this.unexpectedFailure(e, 'AddViewResultsToList');
686
+ }
687
+ }
688
+ async RefreshListFromSource(listId, mode, confirmDrops, ctx) {
689
+ const ops = this.buildOps(ctx);
690
+ try {
691
+ const result = await ops.RefreshFromSource(listId, mode, { ConfirmDrops: confirmDrops });
692
+ return fromCoreApplyResult(result);
693
+ }
694
+ catch (e) {
695
+ return this.unexpectedFailure(e, 'RefreshListFromSource');
696
+ }
697
+ }
698
+ async ComposeLists(input, ctx) {
699
+ const ops = this.buildOps(ctx);
700
+ const inputs = input.Inputs.map(toCoreSource);
701
+ const target = input.Target ? toCoreSource(input.Target) : undefined;
702
+ const delta = await ops.ComputeSetOp(input.Op, inputs, target);
703
+ return fromCoreDelta(delta);
704
+ }
705
+ // -----------------------------------------------------------------------
706
+ // Sharing (Phase 2). Auth is enforced at two layers — this resolver checks
707
+ // the user is authenticated; `ListSharing` itself enforces the audit-log /
708
+ // status-transition contracts. Server-side notification dispatch fires
709
+ // automatically through the registered share-notification handler.
710
+ // -----------------------------------------------------------------------
711
+ async ShareList(input, ctx) {
712
+ const sharing = this.buildSharing(ctx);
713
+ try {
714
+ const target = input.Target.Kind === 'user'
715
+ ? { kind: 'user', userId: requireField(input.Target.UserID, 'Target.UserID') }
716
+ : { kind: 'role', roleId: requireField(input.Target.RoleID, 'Target.RoleID') };
717
+ const result = await sharing.Share({
718
+ ListID: input.ListID,
719
+ Target: target,
720
+ PermissionLevel: input.PermissionLevel,
721
+ });
722
+ return result;
723
+ }
724
+ catch (e) {
725
+ return shareUnexpected(e, 'ShareList');
726
+ }
727
+ }
728
+ async UnshareList(permissionId, ctx) {
729
+ const sharing = this.buildSharing(ctx);
730
+ try {
731
+ return await sharing.Unshare(permissionId);
732
+ }
733
+ catch (e) {
734
+ return shareUnexpected(e, 'UnshareList');
735
+ }
736
+ }
737
+ async InviteToList(input, ctx) {
738
+ const sharing = this.buildSharing(ctx);
739
+ try {
740
+ return await sharing.Invite({
741
+ ListID: input.ListID,
742
+ Email: input.Email,
743
+ Role: input.Role,
744
+ TtlMs: input.TtlHours != null ? input.TtlHours * 60 * 60 * 1000 : undefined,
745
+ });
746
+ }
747
+ catch (e) {
748
+ return inviteUnexpected(e, 'InviteToList');
749
+ }
750
+ }
751
+ async AcceptListInvitation(token, ctx) {
752
+ const sharing = this.buildSharing(ctx);
753
+ try {
754
+ return await sharing.AcceptInvitation(token);
755
+ }
756
+ catch (e) {
757
+ return acceptInvitationUnexpected(e, 'AcceptListInvitation');
758
+ }
759
+ }
760
+ async RevokeListInvitation(invitationId, ctx) {
761
+ const sharing = this.buildSharing(ctx);
762
+ try {
763
+ return await sharing.RevokeInvitation(invitationId);
764
+ }
765
+ catch (e) {
766
+ return shareUnexpected(e, 'RevokeListInvitation');
767
+ }
768
+ }
769
+ async ListSharesForList(listId, ctx) {
770
+ const sharing = this.buildSharing(ctx);
771
+ const shares = await sharing.GetSharesForList(listId);
772
+ return shares.map(fromCoreShareSummary);
773
+ }
774
+ async ListsSharedWithMe(ctx) {
775
+ const sharing = this.buildSharing(ctx);
776
+ const summaries = await sharing.GetListsSharedWithUser();
777
+ return summaries.map((s) => ({
778
+ ListID: s.ListID,
779
+ ListName: s.ListName,
780
+ PermissionLevel: s.PermissionLevel,
781
+ SharedByUserID: s.SharedByUserID ?? undefined,
782
+ SharedAt: s.SharedAt,
783
+ }));
784
+ }
785
+ // --- private helpers ---------------------------------------------------
786
+ buildSharing(ctx) {
787
+ const user = this.requireUser(ctx);
788
+ const provider = GetReadWriteProvider(ctx.providers, { allowFallbackToReadOnly: false });
789
+ return new ListSharing(user, provider);
790
+ }
791
+ buildOps(ctx) {
792
+ const user = this.requireUser(ctx);
793
+ const provider = GetReadWriteProvider(ctx.providers, { allowFallbackToReadOnly: false });
794
+ return new ListOperations(user, provider);
795
+ }
796
+ requireUser(ctx) {
797
+ const user = ctx.userPayload.userRecord;
798
+ if (!user)
799
+ throw new Error('User is not authenticated');
800
+ return user;
801
+ }
802
+ unexpectedFailure(e, op) {
803
+ const message = e instanceof Error ? e.message : String(e);
804
+ LogError(`${op} threw: ${message}`);
805
+ return {
806
+ Success: false,
807
+ ResultCode: 'UNEXPECTED_ERROR',
808
+ Message: message,
809
+ };
810
+ }
811
+ };
812
+ __decorate([
813
+ Query(() => ListDeltaType, {
814
+ description: 'Preview a list operation. Returns a signed DeltaToken that ApplyListDelta will accept (subject to TTL + drift checks).',
815
+ }),
816
+ __param(0, Arg('input', () => ComputeDeltaInput)),
817
+ __param(1, Ctx()),
818
+ __metadata("design:type", Function),
819
+ __metadata("design:paramtypes", [ComputeDeltaInput, Object]),
820
+ __metadata("design:returntype", Promise)
821
+ ], ListOperationsResolver.prototype, "PreviewListDelta", null);
822
+ __decorate([
823
+ Mutation(() => ApplyListResultType, {
824
+ description: 'Apply a previously-previewed delta. Server enforces the drop-guard regardless of UI.',
825
+ }),
826
+ __param(0, Arg('input', () => ApplyDeltaInput)),
827
+ __param(1, Ctx()),
828
+ __metadata("design:type", Function),
829
+ __metadata("design:paramtypes", [ApplyDeltaInput, Object]),
830
+ __metadata("design:returntype", Promise)
831
+ ], ListOperationsResolver.prototype, "ApplyListDelta", null);
832
+ __decorate([
833
+ Mutation(() => ApplyListResultType),
834
+ __param(0, Arg('viewId', () => String)),
835
+ __param(1, Arg('options', () => MaterializeOptionsInput)),
836
+ __param(2, Ctx()),
837
+ __metadata("design:type", Function),
838
+ __metadata("design:paramtypes", [String, MaterializeOptionsInput, Object]),
839
+ __metadata("design:returntype", Promise)
840
+ ], ListOperationsResolver.prototype, "MaterializeListFromView", null);
841
+ __decorate([
842
+ Mutation(() => ApplyListResultType),
843
+ __param(0, Arg('viewId', () => String)),
844
+ __param(1, Arg('listId', () => String)),
845
+ __param(2, Ctx()),
846
+ __metadata("design:type", Function),
847
+ __metadata("design:paramtypes", [String, String, Object]),
848
+ __metadata("design:returntype", Promise)
849
+ ], ListOperationsResolver.prototype, "AddViewResultsToList", null);
850
+ __decorate([
851
+ Mutation(() => ApplyListResultType),
852
+ __param(0, Arg('listId', () => String)),
853
+ __param(1, Arg('mode', () => String)),
854
+ __param(2, Arg('confirmDrops', () => Boolean)),
855
+ __param(3, Ctx()),
856
+ __metadata("design:type", Function),
857
+ __metadata("design:paramtypes", [String, String, Boolean, Object]),
858
+ __metadata("design:returntype", Promise)
859
+ ], ListOperationsResolver.prototype, "RefreshListFromSource", null);
860
+ __decorate([
861
+ Mutation(() => ListDeltaType, {
862
+ description: 'Preview a set-op (union / intersection / difference) across N sources, optionally projected into a target list.',
863
+ }),
864
+ __param(0, Arg('input', () => ComposeListsInput)),
865
+ __param(1, Ctx()),
866
+ __metadata("design:type", Function),
867
+ __metadata("design:paramtypes", [ComposeListsInput, Object]),
868
+ __metadata("design:returntype", Promise)
869
+ ], ListOperationsResolver.prototype, "ComposeLists", null);
870
+ __decorate([
871
+ Mutation(() => ShareResultType),
872
+ __param(0, Arg('input', () => ShareListInput)),
873
+ __param(1, Ctx()),
874
+ __metadata("design:type", Function),
875
+ __metadata("design:paramtypes", [ShareListInput, Object]),
876
+ __metadata("design:returntype", Promise)
877
+ ], ListOperationsResolver.prototype, "ShareList", null);
878
+ __decorate([
879
+ Mutation(() => ShareResultType),
880
+ __param(0, Arg('permissionId', () => String)),
881
+ __param(1, Ctx()),
882
+ __metadata("design:type", Function),
883
+ __metadata("design:paramtypes", [String, Object]),
884
+ __metadata("design:returntype", Promise)
885
+ ], ListOperationsResolver.prototype, "UnshareList", null);
886
+ __decorate([
887
+ Mutation(() => InviteResultType),
888
+ __param(0, Arg('input', () => InviteToListInput)),
889
+ __param(1, Ctx()),
890
+ __metadata("design:type", Function),
891
+ __metadata("design:paramtypes", [InviteToListInput, Object]),
892
+ __metadata("design:returntype", Promise)
893
+ ], ListOperationsResolver.prototype, "InviteToList", null);
894
+ __decorate([
895
+ Mutation(() => AcceptInvitationResultType),
896
+ __param(0, Arg('token', () => String)),
897
+ __param(1, Ctx()),
898
+ __metadata("design:type", Function),
899
+ __metadata("design:paramtypes", [String, Object]),
900
+ __metadata("design:returntype", Promise)
901
+ ], ListOperationsResolver.prototype, "AcceptListInvitation", null);
902
+ __decorate([
903
+ Mutation(() => ShareResultType),
904
+ __param(0, Arg('invitationId', () => String)),
905
+ __param(1, Ctx()),
906
+ __metadata("design:type", Function),
907
+ __metadata("design:paramtypes", [String, Object]),
908
+ __metadata("design:returntype", Promise)
909
+ ], ListOperationsResolver.prototype, "RevokeListInvitation", null);
910
+ __decorate([
911
+ Query(() => [ListShareSummaryType]),
912
+ __param(0, Arg('listId', () => String)),
913
+ __param(1, Ctx()),
914
+ __metadata("design:type", Function),
915
+ __metadata("design:paramtypes", [String, Object]),
916
+ __metadata("design:returntype", Promise)
917
+ ], ListOperationsResolver.prototype, "ListSharesForList", null);
918
+ __decorate([
919
+ Query(() => [SharedListSummaryType]),
920
+ __param(0, Ctx()),
921
+ __metadata("design:type", Function),
922
+ __metadata("design:paramtypes", [Object]),
923
+ __metadata("design:returntype", Promise)
924
+ ], ListOperationsResolver.prototype, "ListsSharedWithMe", null);
925
+ ListOperationsResolver = __decorate([
926
+ Resolver()
927
+ ], ListOperationsResolver);
928
+ export { ListOperationsResolver };
929
+ export default ListOperationsResolver;
930
+ //# sourceMappingURL=ListOperationsResolver.js.map