@kubun/graphql 0.17.2 → 0.18.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/lib/context.d.ts +199 -9
- package/lib/context.js +11 -9
- package/lib/index.d.ts +1 -1
- package/lib/schema.js +715 -7
- package/lib/types.d.ts +1 -0
- package/package.json +26 -17
package/lib/context.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DocumentID } from '@kubun/id';
|
|
2
2
|
import type { AggregateHaving, AggregateSpec, AggregateValues, DocumentData, DocumentFilter, DocumentNode, DocumentOrderBy, GroupedAggregateOrderTerm, GroupedAggregateValue } from '@kubun/protocol';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SignedRecord } from '@kubun/records';
|
|
4
|
+
import type { CatalogDefinition, CatalogLevel, CatalogRuleConflict, CatalogRuleResolutionInput, DocumentHold, DocumentScopeView, SearchDocumentResult, SearchDocumentsParams, StoredAccessDefaultRow, ViewerReadAccess } from '@kubun/store-graph';
|
|
4
5
|
import type { Tracer } from '@sozai/otel';
|
|
5
6
|
import type { GraphQLResolveInfo } from 'graphql';
|
|
6
7
|
import type { Connection, Edge } from './relay.js';
|
|
@@ -34,7 +35,10 @@ export type ReadContextDB = {
|
|
|
34
35
|
filter?: DocumentFilter;
|
|
35
36
|
orderBy?: DocumentOrderBy;
|
|
36
37
|
owner?: string;
|
|
37
|
-
|
|
38
|
+
catalogRef?: {
|
|
39
|
+
owner: string;
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
38
42
|
first?: number | null;
|
|
39
43
|
last?: number | null;
|
|
40
44
|
before?: string | null;
|
|
@@ -54,7 +58,10 @@ export type ReadContextDB = {
|
|
|
54
58
|
modelIDs: Array<string>;
|
|
55
59
|
filter?: DocumentFilter;
|
|
56
60
|
owner?: string;
|
|
57
|
-
|
|
61
|
+
catalogRef?: {
|
|
62
|
+
owner: string;
|
|
63
|
+
id: string;
|
|
64
|
+
};
|
|
58
65
|
count: boolean;
|
|
59
66
|
aggregates: Array<AggregateSpec>;
|
|
60
67
|
readAccess?: ViewerReadAccess;
|
|
@@ -63,7 +70,10 @@ export type ReadContextDB = {
|
|
|
63
70
|
modelIDs: Array<string>;
|
|
64
71
|
filter?: DocumentFilter;
|
|
65
72
|
owner?: string;
|
|
66
|
-
|
|
73
|
+
catalogRef?: {
|
|
74
|
+
owner: string;
|
|
75
|
+
id: string;
|
|
76
|
+
};
|
|
67
77
|
count: boolean;
|
|
68
78
|
aggregates: Array<AggregateSpec>;
|
|
69
79
|
groupBy: Array<{
|
|
@@ -86,7 +96,10 @@ export type AggregateScope = {
|
|
|
86
96
|
modelIDs: Array<string>;
|
|
87
97
|
filter?: DocumentFilter;
|
|
88
98
|
owner?: string;
|
|
89
|
-
|
|
99
|
+
catalogRef?: {
|
|
100
|
+
owner: string;
|
|
101
|
+
id: string;
|
|
102
|
+
};
|
|
90
103
|
};
|
|
91
104
|
/**
|
|
92
105
|
* Connection value returned by {@link QueryContext.resolveConnection}. Extends
|
|
@@ -103,7 +116,10 @@ export type ScopedConnection = Connection<DocumentNode> & {
|
|
|
103
116
|
export type ResolveAggregateParams = {
|
|
104
117
|
filter?: DocumentFilter;
|
|
105
118
|
owner?: string;
|
|
106
|
-
|
|
119
|
+
catalogRef?: {
|
|
120
|
+
owner: string;
|
|
121
|
+
id: string;
|
|
122
|
+
};
|
|
107
123
|
count: boolean;
|
|
108
124
|
aggregates: Array<AggregateSpec>;
|
|
109
125
|
};
|
|
@@ -116,7 +132,10 @@ export type ResolveAggregateParams = {
|
|
|
116
132
|
export type ResolveGroupedAggregateParams = {
|
|
117
133
|
filter?: DocumentFilter;
|
|
118
134
|
owner?: string;
|
|
119
|
-
|
|
135
|
+
catalogRef?: {
|
|
136
|
+
owner: string;
|
|
137
|
+
id: string;
|
|
138
|
+
};
|
|
120
139
|
count: boolean;
|
|
121
140
|
aggregates: Array<AggregateSpec>;
|
|
122
141
|
groupBy: Array<{
|
|
@@ -158,6 +177,176 @@ export type SubscriptionContext = {
|
|
|
158
177
|
* Query and subscription functions requiring server implementation
|
|
159
178
|
*/
|
|
160
179
|
export type ReadOnlyContext = QueryContext & SubscriptionContext;
|
|
180
|
+
export type CatalogRuleInput = Omit<CatalogRuleValue, 'id'> & {
|
|
181
|
+
id?: string;
|
|
182
|
+
};
|
|
183
|
+
export type CatalogRuleValue = {
|
|
184
|
+
id: string;
|
|
185
|
+
models?: Array<string>;
|
|
186
|
+
owners?: Array<string>;
|
|
187
|
+
maxAge?: string;
|
|
188
|
+
maxAhead?: string;
|
|
189
|
+
dateField?: string;
|
|
190
|
+
};
|
|
191
|
+
export type CatalogValue = {
|
|
192
|
+
id: string;
|
|
193
|
+
headVersionID: string;
|
|
194
|
+
upstream?: CatalogVersionRef;
|
|
195
|
+
name: string;
|
|
196
|
+
description?: string;
|
|
197
|
+
rules: Array<CatalogRuleValue>;
|
|
198
|
+
app?: string;
|
|
199
|
+
};
|
|
200
|
+
export type CatalogListing = {
|
|
201
|
+
id: string;
|
|
202
|
+
app: string | null;
|
|
203
|
+
name: string;
|
|
204
|
+
deletedAt: string | null;
|
|
205
|
+
catalog: CatalogValue | null;
|
|
206
|
+
};
|
|
207
|
+
export type CatalogVersionRef = {
|
|
208
|
+
catalogID: string;
|
|
209
|
+
versionID: string;
|
|
210
|
+
};
|
|
211
|
+
export type CatalogVersion = {
|
|
212
|
+
id: string;
|
|
213
|
+
catalogID: string;
|
|
214
|
+
parents: Array<CatalogVersionRef>;
|
|
215
|
+
catalog: CatalogValue;
|
|
216
|
+
};
|
|
217
|
+
export type CatalogVersionConnection = {
|
|
218
|
+
edges: Array<{
|
|
219
|
+
cursor: string;
|
|
220
|
+
node: CatalogVersion;
|
|
221
|
+
}>;
|
|
222
|
+
pageInfo: {
|
|
223
|
+
endCursor: string | null;
|
|
224
|
+
hasNextPage: boolean;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
export type CatalogDraft = {
|
|
228
|
+
catalogID: string;
|
|
229
|
+
baseVersionID: string;
|
|
230
|
+
dirty: boolean;
|
|
231
|
+
updateAvailable: boolean;
|
|
232
|
+
catalog: CatalogValue;
|
|
233
|
+
};
|
|
234
|
+
export type CatalogUpdateInput = {
|
|
235
|
+
name?: string;
|
|
236
|
+
description?: string;
|
|
237
|
+
rules?: Array<CatalogRuleInput>;
|
|
238
|
+
};
|
|
239
|
+
export type FetchCatalogHeadVersionParams = {
|
|
240
|
+
catalogID: string;
|
|
241
|
+
versionID: string;
|
|
242
|
+
groupID: string;
|
|
243
|
+
peerDID: string;
|
|
244
|
+
/** Aborts once another member's copy decided the lookup. */
|
|
245
|
+
signal?: AbortSignal;
|
|
246
|
+
};
|
|
247
|
+
export type CatalogUpstreamUnavailableReason = 'NO_LIVE_OFFER' | 'UPSTREAM_DELETED' | 'BASE_MISSING' | 'VERSION_PENDING';
|
|
248
|
+
export type CatalogUpstreamStatus = {
|
|
249
|
+
upstream: CatalogVersionRef | null;
|
|
250
|
+
latestVersionID: string | null;
|
|
251
|
+
updateAvailable: boolean;
|
|
252
|
+
unavailableReason: CatalogUpstreamUnavailableReason | null;
|
|
253
|
+
};
|
|
254
|
+
export type CatalogUpstreamLookup = {
|
|
255
|
+
status(id: string): Promise<CatalogUpstreamStatus>;
|
|
256
|
+
held(ref: CatalogVersionRef): Promise<SignedRecord | null>;
|
|
257
|
+
fetch(params: FetchCatalogHeadVersionParams): Promise<SignedRecord | null>;
|
|
258
|
+
eligible(catalogID: string): Promise<boolean>;
|
|
259
|
+
};
|
|
260
|
+
export type { CatalogRuleResolutionInput } from '@kubun/store-graph';
|
|
261
|
+
export type CatalogPullPreview = {
|
|
262
|
+
baseVersionID: string;
|
|
263
|
+
localRevisionID: string;
|
|
264
|
+
upstreamVersionID: string;
|
|
265
|
+
merged: CatalogDefinition & {
|
|
266
|
+
id: string;
|
|
267
|
+
};
|
|
268
|
+
conflicts: Array<CatalogRuleConflict>;
|
|
269
|
+
};
|
|
270
|
+
export type CatalogPullResult = {
|
|
271
|
+
catalog: CatalogListing;
|
|
272
|
+
draft: CatalogDraft | null;
|
|
273
|
+
published: boolean;
|
|
274
|
+
};
|
|
275
|
+
export type ResolveCatalogPullParams = {
|
|
276
|
+
id: string;
|
|
277
|
+
baseVersionID: string;
|
|
278
|
+
localRevisionID: string;
|
|
279
|
+
upstreamVersionID: string;
|
|
280
|
+
resolutions: Array<CatalogRuleResolutionInput>;
|
|
281
|
+
publish: boolean;
|
|
282
|
+
};
|
|
283
|
+
export type CatalogDeviceStorage = {
|
|
284
|
+
catalogID: string;
|
|
285
|
+
level: CatalogLevel | null;
|
|
286
|
+
state: 'READY' | 'NEEDS_ROUTE';
|
|
287
|
+
matchingLocalDocuments: number;
|
|
288
|
+
};
|
|
289
|
+
export type CustodyStatus = 'NONE' | 'PENDING' | 'PARTIAL' | 'READY';
|
|
290
|
+
export type CatalogCustody = {
|
|
291
|
+
catalogID: string;
|
|
292
|
+
custodians: Array<string>;
|
|
293
|
+
accepted: Array<string>;
|
|
294
|
+
/** Named custodians whose last word is that they take no custody. */
|
|
295
|
+
declined: Array<string>;
|
|
296
|
+
status: CustodyStatus;
|
|
297
|
+
};
|
|
298
|
+
export type CatalogContext = {
|
|
299
|
+
previewCatalogPull(id: string): Promise<CatalogPullPreview>;
|
|
300
|
+
resolveCatalogPull(params: ResolveCatalogPullParams): Promise<CatalogPullResult>;
|
|
301
|
+
cloneCatalog(id: string): Promise<CatalogListing>;
|
|
302
|
+
catalogUpstreamStatus(id: string): Promise<CatalogUpstreamStatus>;
|
|
303
|
+
createCatalog(input: {
|
|
304
|
+
name: string;
|
|
305
|
+
description?: string;
|
|
306
|
+
rules: Array<CatalogRuleInput>;
|
|
307
|
+
app?: string;
|
|
308
|
+
}): Promise<CatalogListing>;
|
|
309
|
+
updateCatalog(id: string, input: {
|
|
310
|
+
name?: string;
|
|
311
|
+
description?: string;
|
|
312
|
+
rules?: Array<CatalogRuleInput>;
|
|
313
|
+
}): Promise<CatalogListing>;
|
|
314
|
+
deleteCatalog(id: string): Promise<boolean>;
|
|
315
|
+
deduplicateAppCatalogs(app: string, name: string): Promise<CatalogListing | null>;
|
|
316
|
+
setCatalogDeviceLevel(id: string, level: CatalogLevel): Promise<CatalogDeviceStorage>;
|
|
317
|
+
catalogDeviceStorage(id: string): Promise<CatalogDeviceStorage>;
|
|
318
|
+
catalogCustody(id: string): Promise<CatalogCustody>;
|
|
319
|
+
/**
|
|
320
|
+
* Assign the catalog's custodians, superseding the current assignment. A custodian no longer
|
|
321
|
+
* named keeps its pins until a named custodian has accepted and answered held, so an empty list
|
|
322
|
+
* releases nothing: the old custodians keep their copies.
|
|
323
|
+
*/
|
|
324
|
+
setCatalogCustodians(id: string, deviceDIDs: Array<string>): Promise<CatalogCustody>;
|
|
325
|
+
/** Whether this device accepts custody assignments; kept locally, over the engine default. */
|
|
326
|
+
setDeviceCustodyEligible(eligible: boolean): Promise<boolean>;
|
|
327
|
+
/**
|
|
328
|
+
* Write the next assignment without this device. Refused (`CUSTODY_ONLY_COPY`) while no other
|
|
329
|
+
* custodian accepted the current one, unless `force`. Pins go after another custodian's receipt,
|
|
330
|
+
* or at once with `force`, which deletes nothing.
|
|
331
|
+
*/
|
|
332
|
+
leaveCatalogCustody(id: string, force: boolean): Promise<CatalogCustody>;
|
|
333
|
+
catalogs(includeDeleted: boolean): Promise<Array<CatalogListing>>;
|
|
334
|
+
catalogVersions(params: {
|
|
335
|
+
id: string;
|
|
336
|
+
first: number;
|
|
337
|
+
after?: string;
|
|
338
|
+
}): Promise<CatalogVersionConnection>;
|
|
339
|
+
catalogDraft(id: string): Promise<CatalogDraft | null>;
|
|
340
|
+
editCatalogDraft(id: string, input: CatalogUpdateInput): Promise<CatalogDraft>;
|
|
341
|
+
discardCatalogDraft(id: string): Promise<boolean>;
|
|
342
|
+
publishCatalogDraft(id: string, expectedHeadVersionID: string): Promise<CatalogListing>;
|
|
343
|
+
documentScope(id: string): Promise<DocumentScopeView>;
|
|
344
|
+
retainDocument(documentID: string, options: {
|
|
345
|
+
reason?: string;
|
|
346
|
+
expiresAt?: string;
|
|
347
|
+
}): Promise<DocumentHold>;
|
|
348
|
+
releaseDocumentHold(holdID: string): Promise<boolean>;
|
|
349
|
+
};
|
|
161
350
|
export type AccessChecker = (doc: DocumentNode, permissionType: 'read' | 'write') => Promise<boolean>;
|
|
162
351
|
export type AccessWarning = {
|
|
163
352
|
message: string;
|
|
@@ -174,7 +363,6 @@ export type ReadContextParams = {
|
|
|
174
363
|
store: ReadContextDB;
|
|
175
364
|
events?: DocumentEventEmitter;
|
|
176
365
|
viewerDID: string;
|
|
177
|
-
catalogID?: string;
|
|
178
366
|
accessChecker?: AccessChecker;
|
|
179
367
|
viewerReadAccess?: ViewerReadAccess;
|
|
180
368
|
warnings?: Array<AccessWarning>;
|
|
@@ -303,4 +491,6 @@ export type MutationContext = {
|
|
|
303
491
|
*/
|
|
304
492
|
export interface PluginContextMap {
|
|
305
493
|
}
|
|
306
|
-
export type Context = ReadOnlyContext & MutationContext &
|
|
494
|
+
export type Context = ReadOnlyContext & MutationContext & {
|
|
495
|
+
catalog?: CatalogContext;
|
|
496
|
+
} & Partial<PluginContextMap>;
|
package/lib/context.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DocumentID } from '@kubun/id';
|
|
1
|
+
import { CatalogID, DocumentID } from '@kubun/id';
|
|
2
2
|
import { getKubunLogger } from '@kubun/logger';
|
|
3
3
|
import { KubunAttributeKeys, KubunSpanNames } from '@kubun/protocol';
|
|
4
4
|
import { defer } from '@sozai/async';
|
|
@@ -243,8 +243,9 @@ export function createReadContext(params) {
|
|
|
243
243
|
modelIDs,
|
|
244
244
|
filter: args.filter,
|
|
245
245
|
owner: args.owner,
|
|
246
|
-
catalogID:
|
|
246
|
+
catalogRef: args.catalogID == null ? undefined : CatalogID.fromString(args.catalogID).toRecordKey()
|
|
247
247
|
};
|
|
248
|
+
const catalogRef = aggregateScope.catalogRef;
|
|
248
249
|
const result = await traced(KubunSpanNames.DATA_QUERY, {
|
|
249
250
|
[KubunAttributeKeys.MODEL_ID]: modelIDs.join(',')
|
|
250
251
|
}, async ()=>{
|
|
@@ -253,7 +254,8 @@ export function createReadContext(params) {
|
|
|
253
254
|
const searchResults = await store.searchDocuments({
|
|
254
255
|
query: args.search,
|
|
255
256
|
modelIDs,
|
|
256
|
-
first: 200
|
|
257
|
+
first: 200,
|
|
258
|
+
catalogRef
|
|
257
259
|
});
|
|
258
260
|
if (searchResults.length === 0) {
|
|
259
261
|
if (params.complexity != null) {
|
|
@@ -314,7 +316,7 @@ export function createReadContext(params) {
|
|
|
314
316
|
const { entries, hasMore } = await store.queryDocuments({
|
|
315
317
|
...args,
|
|
316
318
|
modelIDs,
|
|
317
|
-
|
|
319
|
+
catalogRef
|
|
318
320
|
});
|
|
319
321
|
if (params.complexity != null) {
|
|
320
322
|
params.complexity.resolverCount++;
|
|
@@ -357,7 +359,7 @@ export function createReadContext(params) {
|
|
|
357
359
|
const { entries, hasMore } = await store.queryDocuments({
|
|
358
360
|
...args,
|
|
359
361
|
modelIDs,
|
|
360
|
-
|
|
362
|
+
catalogRef,
|
|
361
363
|
first: UNBOUNDED_SCAN_BATCH_SIZE,
|
|
362
364
|
after: cursor
|
|
363
365
|
});
|
|
@@ -399,7 +401,7 @@ export function createReadContext(params) {
|
|
|
399
401
|
const { entries, hasMore } = await store.queryDocuments({
|
|
400
402
|
...args,
|
|
401
403
|
modelIDs,
|
|
402
|
-
|
|
404
|
+
catalogRef,
|
|
403
405
|
first: fetchSize,
|
|
404
406
|
after: cursor
|
|
405
407
|
});
|
|
@@ -430,7 +432,7 @@ export function createReadContext(params) {
|
|
|
430
432
|
const { entries, hasMore } = await store.queryDocuments({
|
|
431
433
|
...args,
|
|
432
434
|
modelIDs,
|
|
433
|
-
|
|
435
|
+
catalogRef,
|
|
434
436
|
last: fetchSize,
|
|
435
437
|
before: cursor
|
|
436
438
|
});
|
|
@@ -539,7 +541,7 @@ export function createReadContext(params) {
|
|
|
539
541
|
modelIDs,
|
|
540
542
|
filter: aggregateParams.filter,
|
|
541
543
|
owner: aggregateParams.owner,
|
|
542
|
-
|
|
544
|
+
catalogRef: aggregateParams.catalogRef,
|
|
543
545
|
count: aggregateParams.count,
|
|
544
546
|
aggregates: aggregateParams.aggregates,
|
|
545
547
|
readAccess: viewerReadAccess
|
|
@@ -565,7 +567,7 @@ export function createReadContext(params) {
|
|
|
565
567
|
modelIDs,
|
|
566
568
|
filter: groupedParams.filter,
|
|
567
569
|
owner: groupedParams.owner,
|
|
568
|
-
|
|
570
|
+
catalogRef: groupedParams.catalogRef,
|
|
569
571
|
count: groupedParams.count,
|
|
570
572
|
aggregates: groupedParams.aggregates,
|
|
571
573
|
groupBy: groupedParams.groupBy,
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { AccessWarning, AggregateScope, ComplexityStats, Context, CreateMutationParams, DocumentEventEmitter, DocumentSavedEvent, MutationContext, PluginContextMap, QueryContext, ReadContextDB, ReadContextParams, ReadOnlyContext, RemoveMutationParams, ScopedConnection, SetDocumentAccessOverrideParams, SetModelAccessDefaultsParams, SetMutationParams, SubscriptionContext, UpdateMutationParams, } from './context.js';
|
|
1
|
+
export type { AccessWarning, AggregateScope, CatalogContext, CatalogCustody, CatalogDeviceStorage, CatalogDraft, CatalogListing, CatalogPullPreview, CatalogPullResult, CatalogRuleInput, CatalogRuleResolutionInput, CatalogRuleValue, CatalogUpdateInput, CatalogUpstreamLookup, CatalogUpstreamStatus, CatalogUpstreamUnavailableReason, CatalogValue, CatalogVersion, CatalogVersionConnection, CatalogVersionRef, ComplexityStats, Context, CreateMutationParams, CustodyStatus, DocumentEventEmitter, DocumentSavedEvent, FetchCatalogHeadVersionParams, MutationContext, PluginContextMap, QueryContext, ReadContextDB, ReadContextParams, ReadOnlyContext, RemoveMutationParams, ResolveCatalogPullParams, ScopedConnection, SetDocumentAccessOverrideParams, SetModelAccessDefaultsParams, SetMutationParams, SubscriptionContext, UpdateMutationParams, } from './context.js';
|
|
2
2
|
export { createReadContext } from './context.js';
|
|
3
3
|
export { GraphQLAttachmentID, GraphQLCredentialEntryID, GraphQLDocID, } from './identifiers.js';
|
|
4
4
|
export type { ExtensionResolvers, SchemaBuilderParams, SharedDefinitions, } from './schema.js';
|
package/lib/schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AttachmentID, DocumentID, DocumentModelID, decodeID, PluginNodeID } from '@kubun/id';
|
|
1
|
+
import { AttachmentID, CatalogID, DocumentID, DocumentModelID, decodeID, PluginNodeID } from '@kubun/id';
|
|
2
2
|
import { REFERENCE_PREFIX } from '@kubun/protocol';
|
|
3
3
|
import { pascalCase } from 'change-case';
|
|
4
|
-
import { extendSchema, GraphQLBoolean, GraphQLEnumType, GraphQLFloat, GraphQLID, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLSchema, GraphQLString, isEnumType, isListType, isNonNullType, isObjectType, isScalarType, Kind, parse as parseGraphQL } from 'graphql';
|
|
4
|
+
import { extendSchema, GraphQLBoolean, GraphQLEnumType, GraphQLError, GraphQLFloat, GraphQLID, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLSchema, GraphQLString, isEnumType, isListType, isNonNullType, isObjectType, isScalarType, Kind, parse as parseGraphQL } from 'graphql';
|
|
5
5
|
import { GraphQLDateTimeISO, GraphQLDID, GraphQLDuration, GraphQLEmailAddress, GraphQLJSON, GraphQLJSONObject } from 'graphql-scalars';
|
|
6
6
|
import { GraphQLAttachmentID, GraphQLCredentialEntryID, GraphQLDocID } from './identifiers.js';
|
|
7
7
|
import { connectionArgs, connectionDefinitions, mutationWithClientMutationId, nodeDefinitions } from './relay.js';
|
|
@@ -358,6 +358,411 @@ const ModelAccessDefaults = new GraphQLObjectType({
|
|
|
358
358
|
}
|
|
359
359
|
})
|
|
360
360
|
});
|
|
361
|
+
const CatalogRuleInput = new GraphQLInputObjectType({
|
|
362
|
+
name: 'CatalogRuleInput',
|
|
363
|
+
fields: {
|
|
364
|
+
id: {
|
|
365
|
+
type: GraphQLID
|
|
366
|
+
},
|
|
367
|
+
models: {
|
|
368
|
+
type: toList(GraphQLString)
|
|
369
|
+
},
|
|
370
|
+
owners: {
|
|
371
|
+
type: toList(GraphQLString)
|
|
372
|
+
},
|
|
373
|
+
maxAge: {
|
|
374
|
+
type: GraphQLString
|
|
375
|
+
},
|
|
376
|
+
maxAhead: {
|
|
377
|
+
type: GraphQLString
|
|
378
|
+
},
|
|
379
|
+
dateField: {
|
|
380
|
+
type: GraphQLString
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
const CatalogRule = new GraphQLObjectType({
|
|
385
|
+
name: 'CatalogRule',
|
|
386
|
+
fields: {
|
|
387
|
+
id: {
|
|
388
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
389
|
+
},
|
|
390
|
+
models: {
|
|
391
|
+
type: toOuputList(GraphQLString)
|
|
392
|
+
},
|
|
393
|
+
owners: {
|
|
394
|
+
type: toOuputList(GraphQLString)
|
|
395
|
+
},
|
|
396
|
+
maxAge: {
|
|
397
|
+
type: GraphQLString
|
|
398
|
+
},
|
|
399
|
+
maxAhead: {
|
|
400
|
+
type: GraphQLString
|
|
401
|
+
},
|
|
402
|
+
dateField: {
|
|
403
|
+
type: GraphQLString
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
const CatalogVersionRef = new GraphQLObjectType({
|
|
408
|
+
name: 'CatalogVersionRef',
|
|
409
|
+
fields: {
|
|
410
|
+
catalogID: {
|
|
411
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
412
|
+
},
|
|
413
|
+
versionID: {
|
|
414
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
const CatalogUpdateInput = new GraphQLInputObjectType({
|
|
419
|
+
name: 'CatalogUpdateInput',
|
|
420
|
+
fields: {
|
|
421
|
+
name: {
|
|
422
|
+
type: GraphQLString
|
|
423
|
+
},
|
|
424
|
+
description: {
|
|
425
|
+
type: GraphQLString
|
|
426
|
+
},
|
|
427
|
+
rules: {
|
|
428
|
+
type: toList(CatalogRuleInput)
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
const Catalog = new GraphQLObjectType({
|
|
433
|
+
name: 'Catalog',
|
|
434
|
+
fields: {
|
|
435
|
+
headVersionID: {
|
|
436
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
437
|
+
},
|
|
438
|
+
upstream: {
|
|
439
|
+
type: CatalogVersionRef
|
|
440
|
+
},
|
|
441
|
+
id: {
|
|
442
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
443
|
+
},
|
|
444
|
+
name: {
|
|
445
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
446
|
+
},
|
|
447
|
+
description: {
|
|
448
|
+
type: GraphQLString
|
|
449
|
+
},
|
|
450
|
+
rules: {
|
|
451
|
+
type: new GraphQLNonNull(toOuputList(CatalogRule))
|
|
452
|
+
},
|
|
453
|
+
app: {
|
|
454
|
+
type: GraphQLString
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
const CatalogListing = new GraphQLObjectType({
|
|
459
|
+
name: 'CatalogListing',
|
|
460
|
+
fields: {
|
|
461
|
+
id: {
|
|
462
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
463
|
+
},
|
|
464
|
+
app: {
|
|
465
|
+
type: GraphQLString
|
|
466
|
+
},
|
|
467
|
+
name: {
|
|
468
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
469
|
+
},
|
|
470
|
+
deletedAt: {
|
|
471
|
+
type: GraphQLString
|
|
472
|
+
},
|
|
473
|
+
catalog: {
|
|
474
|
+
type: Catalog
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
const CatalogVersion = new GraphQLObjectType({
|
|
479
|
+
name: 'CatalogVersion',
|
|
480
|
+
fields: {
|
|
481
|
+
id: {
|
|
482
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
483
|
+
},
|
|
484
|
+
catalogID: {
|
|
485
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
486
|
+
},
|
|
487
|
+
parents: {
|
|
488
|
+
type: new GraphQLNonNull(toOuputList(CatalogVersionRef))
|
|
489
|
+
},
|
|
490
|
+
catalog: {
|
|
491
|
+
type: new GraphQLNonNull(Catalog)
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
const CatalogVersionEdge = new GraphQLObjectType({
|
|
496
|
+
name: 'CatalogVersionEdge',
|
|
497
|
+
fields: {
|
|
498
|
+
cursor: {
|
|
499
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
500
|
+
},
|
|
501
|
+
node: {
|
|
502
|
+
type: new GraphQLNonNull(CatalogVersion)
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
const CatalogVersionPageInfo = new GraphQLObjectType({
|
|
507
|
+
name: 'CatalogVersionPageInfo',
|
|
508
|
+
fields: {
|
|
509
|
+
endCursor: {
|
|
510
|
+
type: GraphQLString
|
|
511
|
+
},
|
|
512
|
+
hasNextPage: {
|
|
513
|
+
type: new GraphQLNonNull(GraphQLBoolean)
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
const CatalogVersionConnection = new GraphQLObjectType({
|
|
518
|
+
name: 'CatalogVersionConnection',
|
|
519
|
+
fields: {
|
|
520
|
+
edges: {
|
|
521
|
+
type: new GraphQLNonNull(toOuputList(CatalogVersionEdge))
|
|
522
|
+
},
|
|
523
|
+
pageInfo: {
|
|
524
|
+
type: new GraphQLNonNull(CatalogVersionPageInfo)
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
const CatalogDraft = new GraphQLObjectType({
|
|
529
|
+
name: 'CatalogDraft',
|
|
530
|
+
fields: {
|
|
531
|
+
catalogID: {
|
|
532
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
533
|
+
},
|
|
534
|
+
baseVersionID: {
|
|
535
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
536
|
+
},
|
|
537
|
+
dirty: {
|
|
538
|
+
type: new GraphQLNonNull(GraphQLBoolean)
|
|
539
|
+
},
|
|
540
|
+
updateAvailable: {
|
|
541
|
+
type: new GraphQLNonNull(GraphQLBoolean)
|
|
542
|
+
},
|
|
543
|
+
catalog: {
|
|
544
|
+
type: new GraphQLNonNull(Catalog)
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
const CatalogDeviceLevel = new GraphQLEnumType({
|
|
549
|
+
name: 'CatalogDeviceLevel',
|
|
550
|
+
values: {
|
|
551
|
+
KNOWN: {},
|
|
552
|
+
OFFLINE: {},
|
|
553
|
+
SERVE_ONLY: {}
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
const CatalogLevelState = new GraphQLEnumType({
|
|
557
|
+
name: 'CatalogLevelState',
|
|
558
|
+
values: {
|
|
559
|
+
READY: {},
|
|
560
|
+
NEEDS_ROUTE: {}
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
const CatalogDeviceStorage = new GraphQLObjectType({
|
|
564
|
+
name: 'CatalogDeviceStorage',
|
|
565
|
+
fields: {
|
|
566
|
+
catalogID: {
|
|
567
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
568
|
+
},
|
|
569
|
+
level: {
|
|
570
|
+
type: CatalogDeviceLevel
|
|
571
|
+
},
|
|
572
|
+
state: {
|
|
573
|
+
type: new GraphQLNonNull(CatalogLevelState)
|
|
574
|
+
},
|
|
575
|
+
matchingLocalDocuments: {
|
|
576
|
+
type: new GraphQLNonNull(GraphQLInt)
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
const CustodyStatus = new GraphQLEnumType({
|
|
581
|
+
name: 'CustodyStatus',
|
|
582
|
+
values: {
|
|
583
|
+
NONE: {},
|
|
584
|
+
PENDING: {},
|
|
585
|
+
PARTIAL: {},
|
|
586
|
+
READY: {}
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
const CatalogCustody = new GraphQLObjectType({
|
|
590
|
+
name: 'CatalogCustody',
|
|
591
|
+
fields: {
|
|
592
|
+
catalogID: {
|
|
593
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
594
|
+
},
|
|
595
|
+
custodians: {
|
|
596
|
+
type: new GraphQLNonNull(toOuputList(GraphQLString))
|
|
597
|
+
},
|
|
598
|
+
accepted: {
|
|
599
|
+
type: new GraphQLNonNull(toOuputList(GraphQLString))
|
|
600
|
+
},
|
|
601
|
+
declined: {
|
|
602
|
+
type: new GraphQLNonNull(toOuputList(GraphQLString))
|
|
603
|
+
},
|
|
604
|
+
status: {
|
|
605
|
+
type: new GraphQLNonNull(CustodyStatus)
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
const DocumentRetainHold = new GraphQLObjectType({
|
|
610
|
+
name: 'DocumentRetainHold',
|
|
611
|
+
fields: {
|
|
612
|
+
id: {
|
|
613
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
614
|
+
},
|
|
615
|
+
documentID: {
|
|
616
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
617
|
+
},
|
|
618
|
+
reason: {
|
|
619
|
+
type: GraphQLString
|
|
620
|
+
},
|
|
621
|
+
expiresAt: {
|
|
622
|
+
type: GraphQLDateTimeISO,
|
|
623
|
+
resolve: (hold)=>hold.expiresAt == null ? null : new Date(hold.expiresAt)
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
const DocumentAvailability = new GraphQLEnumType({
|
|
628
|
+
name: 'DocumentAvailability',
|
|
629
|
+
values: {
|
|
630
|
+
LOCAL: {},
|
|
631
|
+
UNAVAILABLE: {}
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
const DocumentScope = new GraphQLObjectType({
|
|
635
|
+
name: 'DocumentScope',
|
|
636
|
+
fields: {
|
|
637
|
+
scope: {
|
|
638
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
639
|
+
},
|
|
640
|
+
availability: {
|
|
641
|
+
type: DocumentAvailability
|
|
642
|
+
},
|
|
643
|
+
retained: {
|
|
644
|
+
type: new GraphQLNonNull(GraphQLBoolean)
|
|
645
|
+
},
|
|
646
|
+
refs: {
|
|
647
|
+
type: new GraphQLNonNull(toOuputList(GraphQLString))
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
const CatalogUpstreamUnavailableReason = new GraphQLEnumType({
|
|
652
|
+
name: 'CatalogUpstreamUnavailableReason',
|
|
653
|
+
values: {
|
|
654
|
+
NO_LIVE_OFFER: {},
|
|
655
|
+
UPSTREAM_DELETED: {},
|
|
656
|
+
BASE_MISSING: {},
|
|
657
|
+
VERSION_PENDING: {}
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
const CatalogUpstreamStatus = new GraphQLObjectType({
|
|
661
|
+
name: 'CatalogUpstreamStatus',
|
|
662
|
+
fields: {
|
|
663
|
+
upstream: {
|
|
664
|
+
type: CatalogVersionRef
|
|
665
|
+
},
|
|
666
|
+
latestVersionID: {
|
|
667
|
+
type: GraphQLID
|
|
668
|
+
},
|
|
669
|
+
updateAvailable: {
|
|
670
|
+
type: new GraphQLNonNull(GraphQLBoolean)
|
|
671
|
+
},
|
|
672
|
+
unavailableReason: {
|
|
673
|
+
type: CatalogUpstreamUnavailableReason
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
const CatalogRuleConflict = new GraphQLObjectType({
|
|
678
|
+
name: 'CatalogRuleConflict',
|
|
679
|
+
fields: {
|
|
680
|
+
ruleID: {
|
|
681
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
682
|
+
},
|
|
683
|
+
base: {
|
|
684
|
+
type: CatalogRule
|
|
685
|
+
},
|
|
686
|
+
local: {
|
|
687
|
+
type: CatalogRule
|
|
688
|
+
},
|
|
689
|
+
upstream: {
|
|
690
|
+
type: CatalogRule
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
const CatalogPullPreview = new GraphQLObjectType({
|
|
695
|
+
name: 'CatalogPullPreview',
|
|
696
|
+
fields: {
|
|
697
|
+
baseVersionID: {
|
|
698
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
699
|
+
},
|
|
700
|
+
localRevisionID: {
|
|
701
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
702
|
+
},
|
|
703
|
+
upstreamVersionID: {
|
|
704
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
705
|
+
},
|
|
706
|
+
merged: {
|
|
707
|
+
type: new GraphQLNonNull(Catalog)
|
|
708
|
+
},
|
|
709
|
+
conflicts: {
|
|
710
|
+
type: new GraphQLNonNull(toOuputList(CatalogRuleConflict))
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
const CatalogPullResult = new GraphQLObjectType({
|
|
715
|
+
name: 'CatalogPullResult',
|
|
716
|
+
fields: {
|
|
717
|
+
catalog: {
|
|
718
|
+
type: new GraphQLNonNull(CatalogListing)
|
|
719
|
+
},
|
|
720
|
+
draft: {
|
|
721
|
+
type: CatalogDraft
|
|
722
|
+
},
|
|
723
|
+
published: {
|
|
724
|
+
type: new GraphQLNonNull(GraphQLBoolean)
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
const CatalogPullSide = new GraphQLEnumType({
|
|
729
|
+
name: 'CatalogPullSide',
|
|
730
|
+
values: {
|
|
731
|
+
LOCAL: {},
|
|
732
|
+
UPSTREAM: {}
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
const CatalogRuleResolutionInput = new GraphQLInputObjectType({
|
|
736
|
+
name: 'CatalogRuleResolutionInput',
|
|
737
|
+
fields: {
|
|
738
|
+
ruleID: {
|
|
739
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
740
|
+
},
|
|
741
|
+
side: {
|
|
742
|
+
type: new GraphQLNonNull(CatalogPullSide)
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
function requireCatalog(ctx) {
|
|
747
|
+
if (ctx.catalog === undefined) throw new Error('Catalog context is unavailable');
|
|
748
|
+
return ctx.catalog;
|
|
749
|
+
}
|
|
750
|
+
async function catalogOperation(operation) {
|
|
751
|
+
try {
|
|
752
|
+
return await operation();
|
|
753
|
+
} catch (error) {
|
|
754
|
+
if (error instanceof Error && 'code' in error && (error.code === 'CATALOG_PULL_STALE' || error.code === 'CATALOG_RULES_EMPTY' || error.code === 'CATALOG_RULE_LIMIT_EXCEEDED' || error.code === 'INVALID_CATALOG_RULE' || error.code === 'CATALOG_DEVICE_LEVEL_DENIED' || error.code === 'CUSTODIAN_UNAVAILABLE' || error.code === 'CUSTODY_SIGNER_REQUIRED' || error.code === 'CUSTODY_ONLY_COPY' || error.code === 'DEVICE_OWNER_REQUIRED' || error.code === 'DOCUMENT_HOLD_DENIED' || error.code === 'DOCUMENT_HOLD_INVALID_EXPIRY' || error.code === 'DOCUMENT_NOT_HOLDABLE')) {
|
|
755
|
+
// biome-ignore lint/style/useErrorCause: GraphQLError retains the cause as originalError.
|
|
756
|
+
throw new GraphQLError(error.message, {
|
|
757
|
+
originalError: error,
|
|
758
|
+
extensions: {
|
|
759
|
+
code: error.code
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
throw error;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
361
766
|
export class SchemaBuilder {
|
|
362
767
|
// Mapping of model or references IDs to their GraphQL object names
|
|
363
768
|
_aliases;
|
|
@@ -540,7 +945,90 @@ export class SchemaBuilder {
|
|
|
540
945
|
this._definitions = definitions;
|
|
541
946
|
const queryFields = {
|
|
542
947
|
nodes: definitions.nodesField,
|
|
543
|
-
...definitions.queryFields
|
|
948
|
+
...definitions.queryFields,
|
|
949
|
+
previewCatalogPull: {
|
|
950
|
+
type: new GraphQLNonNull(CatalogPullPreview),
|
|
951
|
+
args: {
|
|
952
|
+
id: {
|
|
953
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).previewCatalogPull(args.id))
|
|
957
|
+
},
|
|
958
|
+
catalogVersions: {
|
|
959
|
+
type: new GraphQLNonNull(CatalogVersionConnection),
|
|
960
|
+
args: {
|
|
961
|
+
id: {
|
|
962
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
963
|
+
},
|
|
964
|
+
first: {
|
|
965
|
+
type: new GraphQLNonNull(GraphQLInt)
|
|
966
|
+
},
|
|
967
|
+
after: {
|
|
968
|
+
type: GraphQLString
|
|
969
|
+
}
|
|
970
|
+
},
|
|
971
|
+
resolve: async (_root, args, ctx)=>await requireCatalog(ctx).catalogVersions({
|
|
972
|
+
id: args.id,
|
|
973
|
+
first: args.first,
|
|
974
|
+
after: args.after ?? undefined
|
|
975
|
+
})
|
|
976
|
+
},
|
|
977
|
+
catalogUpstreamStatus: {
|
|
978
|
+
type: new GraphQLNonNull(CatalogUpstreamStatus),
|
|
979
|
+
args: {
|
|
980
|
+
id: {
|
|
981
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
982
|
+
}
|
|
983
|
+
},
|
|
984
|
+
resolve: async (_root, args, ctx)=>await requireCatalog(ctx).catalogUpstreamStatus(args.id)
|
|
985
|
+
},
|
|
986
|
+
catalogDraft: {
|
|
987
|
+
type: CatalogDraft,
|
|
988
|
+
args: {
|
|
989
|
+
id: {
|
|
990
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
991
|
+
}
|
|
992
|
+
},
|
|
993
|
+
resolve: async (_root, args, ctx)=>await requireCatalog(ctx).catalogDraft(args.id)
|
|
994
|
+
},
|
|
995
|
+
catalogs: {
|
|
996
|
+
type: new GraphQLNonNull(toOuputList(CatalogListing)),
|
|
997
|
+
args: {
|
|
998
|
+
includeDeleted: {
|
|
999
|
+
type: GraphQLBoolean,
|
|
1000
|
+
defaultValue: false
|
|
1001
|
+
}
|
|
1002
|
+
},
|
|
1003
|
+
resolve: async (_root, args, ctx)=>await requireCatalog(ctx).catalogs(args.includeDeleted === true)
|
|
1004
|
+
},
|
|
1005
|
+
catalogDeviceStorage: {
|
|
1006
|
+
type: new GraphQLNonNull(CatalogDeviceStorage),
|
|
1007
|
+
args: {
|
|
1008
|
+
catalogID: {
|
|
1009
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1010
|
+
}
|
|
1011
|
+
},
|
|
1012
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).catalogDeviceStorage(args.catalogID))
|
|
1013
|
+
},
|
|
1014
|
+
catalogCustody: {
|
|
1015
|
+
type: new GraphQLNonNull(CatalogCustody),
|
|
1016
|
+
args: {
|
|
1017
|
+
catalogID: {
|
|
1018
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1019
|
+
}
|
|
1020
|
+
},
|
|
1021
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).catalogCustody(args.catalogID))
|
|
1022
|
+
},
|
|
1023
|
+
documentScope: {
|
|
1024
|
+
type: DocumentScope,
|
|
1025
|
+
args: {
|
|
1026
|
+
id: {
|
|
1027
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
1030
|
+
resolve: async (_root, args, ctx)=>await requireCatalog(ctx).documentScope(args.id)
|
|
1031
|
+
}
|
|
544
1032
|
};
|
|
545
1033
|
for (const id of this._includedModelIDs){
|
|
546
1034
|
this._buildDocument(id);
|
|
@@ -558,6 +1046,9 @@ export class SchemaBuilder {
|
|
|
558
1046
|
},
|
|
559
1047
|
search: {
|
|
560
1048
|
type: GraphQLString
|
|
1049
|
+
},
|
|
1050
|
+
catalogID: {
|
|
1051
|
+
type: GraphQLID
|
|
561
1052
|
}
|
|
562
1053
|
},
|
|
563
1054
|
resolve: async (_, args, ctx)=>{
|
|
@@ -616,10 +1107,13 @@ export class SchemaBuilder {
|
|
|
616
1107
|
},
|
|
617
1108
|
after: {
|
|
618
1109
|
type: GraphQLString
|
|
1110
|
+
},
|
|
1111
|
+
catalogID: {
|
|
1112
|
+
type: GraphQLID
|
|
619
1113
|
}
|
|
620
1114
|
},
|
|
621
1115
|
resolve: async (_root, args, ctx)=>{
|
|
622
|
-
const { query, models, first, after } = args;
|
|
1116
|
+
const { query, models, first, after, catalogID } = args;
|
|
623
1117
|
if (query.trim() === '') {
|
|
624
1118
|
throw new Error('Search query must not be empty');
|
|
625
1119
|
}
|
|
@@ -637,7 +1131,8 @@ export class SchemaBuilder {
|
|
|
637
1131
|
query,
|
|
638
1132
|
modelIDs,
|
|
639
1133
|
first: pageSize + 1,
|
|
640
|
-
offset
|
|
1134
|
+
offset,
|
|
1135
|
+
catalogRef: catalogID == null ? undefined : CatalogID.fromString(catalogID).toRecordKey()
|
|
641
1136
|
});
|
|
642
1137
|
const hasNextPage = hits.length > pageSize;
|
|
643
1138
|
const page = hasNextPage ? hits.slice(0, pageSize) : hits;
|
|
@@ -886,6 +1381,219 @@ export class SchemaBuilder {
|
|
|
886
1381
|
}
|
|
887
1382
|
};
|
|
888
1383
|
}
|
|
1384
|
+
if (this._includeMutations) {
|
|
1385
|
+
this._mutations.editCatalogDraft = {
|
|
1386
|
+
type: new GraphQLNonNull(CatalogDraft),
|
|
1387
|
+
args: {
|
|
1388
|
+
id: {
|
|
1389
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1390
|
+
},
|
|
1391
|
+
input: {
|
|
1392
|
+
type: new GraphQLNonNull(CatalogUpdateInput)
|
|
1393
|
+
}
|
|
1394
|
+
},
|
|
1395
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).editCatalogDraft(args.id, args.input))
|
|
1396
|
+
};
|
|
1397
|
+
this._mutations.discardCatalogDraft = {
|
|
1398
|
+
type: new GraphQLNonNull(GraphQLBoolean),
|
|
1399
|
+
args: {
|
|
1400
|
+
id: {
|
|
1401
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1402
|
+
}
|
|
1403
|
+
},
|
|
1404
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).discardCatalogDraft(args.id))
|
|
1405
|
+
};
|
|
1406
|
+
this._mutations.publishCatalogDraft = {
|
|
1407
|
+
type: new GraphQLNonNull(CatalogListing),
|
|
1408
|
+
args: {
|
|
1409
|
+
id: {
|
|
1410
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1411
|
+
},
|
|
1412
|
+
expectedHeadVersionID: {
|
|
1413
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1414
|
+
}
|
|
1415
|
+
},
|
|
1416
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).publishCatalogDraft(args.id, args.expectedHeadVersionID))
|
|
1417
|
+
};
|
|
1418
|
+
this._mutations.resolveCatalogPull = {
|
|
1419
|
+
type: new GraphQLNonNull(CatalogPullResult),
|
|
1420
|
+
args: {
|
|
1421
|
+
id: {
|
|
1422
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1423
|
+
},
|
|
1424
|
+
baseVersionID: {
|
|
1425
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1426
|
+
},
|
|
1427
|
+
localRevisionID: {
|
|
1428
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1429
|
+
},
|
|
1430
|
+
upstreamVersionID: {
|
|
1431
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1432
|
+
},
|
|
1433
|
+
resolutions: {
|
|
1434
|
+
type: new GraphQLNonNull(toList(CatalogRuleResolutionInput))
|
|
1435
|
+
},
|
|
1436
|
+
publish: {
|
|
1437
|
+
type: new GraphQLNonNull(GraphQLBoolean)
|
|
1438
|
+
}
|
|
1439
|
+
},
|
|
1440
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).resolveCatalogPull(args))
|
|
1441
|
+
};
|
|
1442
|
+
this._mutations.cloneCatalog = {
|
|
1443
|
+
type: new GraphQLNonNull(CatalogListing),
|
|
1444
|
+
args: {
|
|
1445
|
+
id: {
|
|
1446
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).cloneCatalog(args.id))
|
|
1450
|
+
};
|
|
1451
|
+
this._mutations.createCatalog = {
|
|
1452
|
+
type: Catalog,
|
|
1453
|
+
args: {
|
|
1454
|
+
name: {
|
|
1455
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
1456
|
+
},
|
|
1457
|
+
description: {
|
|
1458
|
+
type: GraphQLString
|
|
1459
|
+
},
|
|
1460
|
+
rules: {
|
|
1461
|
+
type: new GraphQLNonNull(toList(CatalogRuleInput))
|
|
1462
|
+
},
|
|
1463
|
+
app: {
|
|
1464
|
+
type: GraphQLString
|
|
1465
|
+
}
|
|
1466
|
+
},
|
|
1467
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(async ()=>{
|
|
1468
|
+
const listing = await requireCatalog(ctx).createCatalog({
|
|
1469
|
+
name: args.name,
|
|
1470
|
+
description: args.description ?? undefined,
|
|
1471
|
+
rules: args.rules,
|
|
1472
|
+
app: args.app ?? undefined
|
|
1473
|
+
});
|
|
1474
|
+
return listing.catalog;
|
|
1475
|
+
})
|
|
1476
|
+
};
|
|
1477
|
+
this._mutations.updateCatalog = {
|
|
1478
|
+
type: Catalog,
|
|
1479
|
+
args: {
|
|
1480
|
+
id: {
|
|
1481
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1482
|
+
},
|
|
1483
|
+
name: {
|
|
1484
|
+
type: GraphQLString
|
|
1485
|
+
},
|
|
1486
|
+
description: {
|
|
1487
|
+
type: GraphQLString
|
|
1488
|
+
},
|
|
1489
|
+
rules: {
|
|
1490
|
+
type: toList(CatalogRuleInput)
|
|
1491
|
+
}
|
|
1492
|
+
},
|
|
1493
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(async ()=>{
|
|
1494
|
+
const listing = await requireCatalog(ctx).updateCatalog(args.id, {
|
|
1495
|
+
name: args.name ?? undefined,
|
|
1496
|
+
description: args.description ?? undefined,
|
|
1497
|
+
rules: args.rules ?? undefined
|
|
1498
|
+
});
|
|
1499
|
+
return listing.catalog;
|
|
1500
|
+
})
|
|
1501
|
+
};
|
|
1502
|
+
this._mutations.deleteCatalog = {
|
|
1503
|
+
type: GraphQLBoolean,
|
|
1504
|
+
args: {
|
|
1505
|
+
id: {
|
|
1506
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1507
|
+
}
|
|
1508
|
+
},
|
|
1509
|
+
resolve: async (_root, args, ctx)=>await requireCatalog(ctx).deleteCatalog(args.id)
|
|
1510
|
+
};
|
|
1511
|
+
this._mutations.deduplicateAppCatalogs = {
|
|
1512
|
+
type: Catalog,
|
|
1513
|
+
args: {
|
|
1514
|
+
app: {
|
|
1515
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
1516
|
+
},
|
|
1517
|
+
name: {
|
|
1518
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
1519
|
+
}
|
|
1520
|
+
},
|
|
1521
|
+
resolve: async (_root, args, ctx)=>(await requireCatalog(ctx).deduplicateAppCatalogs(args.app, args.name))?.catalog ?? null
|
|
1522
|
+
};
|
|
1523
|
+
this._mutations.setCatalogDeviceLevel = {
|
|
1524
|
+
type: new GraphQLNonNull(CatalogDeviceStorage),
|
|
1525
|
+
args: {
|
|
1526
|
+
catalogID: {
|
|
1527
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1528
|
+
},
|
|
1529
|
+
level: {
|
|
1530
|
+
type: new GraphQLNonNull(CatalogDeviceLevel)
|
|
1531
|
+
}
|
|
1532
|
+
},
|
|
1533
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).setCatalogDeviceLevel(args.catalogID, args.level))
|
|
1534
|
+
};
|
|
1535
|
+
this._mutations.setCatalogCustodians = {
|
|
1536
|
+
type: new GraphQLNonNull(CatalogCustody),
|
|
1537
|
+
args: {
|
|
1538
|
+
catalogID: {
|
|
1539
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1540
|
+
},
|
|
1541
|
+
deviceDIDs: {
|
|
1542
|
+
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(GraphQLString)))
|
|
1543
|
+
}
|
|
1544
|
+
},
|
|
1545
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).setCatalogCustodians(args.catalogID, args.deviceDIDs))
|
|
1546
|
+
};
|
|
1547
|
+
this._mutations.setDeviceCustodyEligible = {
|
|
1548
|
+
type: new GraphQLNonNull(GraphQLBoolean),
|
|
1549
|
+
args: {
|
|
1550
|
+
eligible: {
|
|
1551
|
+
type: new GraphQLNonNull(GraphQLBoolean)
|
|
1552
|
+
}
|
|
1553
|
+
},
|
|
1554
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).setDeviceCustodyEligible(args.eligible))
|
|
1555
|
+
};
|
|
1556
|
+
this._mutations.leaveCatalogCustody = {
|
|
1557
|
+
type: new GraphQLNonNull(CatalogCustody),
|
|
1558
|
+
args: {
|
|
1559
|
+
catalogID: {
|
|
1560
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1561
|
+
},
|
|
1562
|
+
force: {
|
|
1563
|
+
type: GraphQLBoolean,
|
|
1564
|
+
defaultValue: false
|
|
1565
|
+
}
|
|
1566
|
+
},
|
|
1567
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).leaveCatalogCustody(args.catalogID, args.force === true))
|
|
1568
|
+
};
|
|
1569
|
+
this._mutations.retainDocument = {
|
|
1570
|
+
type: new GraphQLNonNull(DocumentRetainHold),
|
|
1571
|
+
args: {
|
|
1572
|
+
documentID: {
|
|
1573
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1574
|
+
},
|
|
1575
|
+
reason: {
|
|
1576
|
+
type: GraphQLString
|
|
1577
|
+
},
|
|
1578
|
+
expiresAt: {
|
|
1579
|
+
type: GraphQLDateTimeISO
|
|
1580
|
+
}
|
|
1581
|
+
},
|
|
1582
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).retainDocument(args.documentID, {
|
|
1583
|
+
reason: args.reason ?? undefined,
|
|
1584
|
+
expiresAt: args.expiresAt?.toISOString()
|
|
1585
|
+
}))
|
|
1586
|
+
};
|
|
1587
|
+
this._mutations.releaseDocumentHold = {
|
|
1588
|
+
type: new GraphQLNonNull(GraphQLBoolean),
|
|
1589
|
+
args: {
|
|
1590
|
+
holdID: {
|
|
1591
|
+
type: new GraphQLNonNull(GraphQLID)
|
|
1592
|
+
}
|
|
1593
|
+
},
|
|
1594
|
+
resolve: async (_root, args, ctx)=>await catalogOperation(()=>requireCatalog(ctx).releaseDocumentHold(args.holdID))
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
889
1597
|
const config = {
|
|
890
1598
|
query: new GraphQLObjectType({
|
|
891
1599
|
name: 'Query',
|
|
@@ -1400,7 +2108,7 @@ export class SchemaBuilder {
|
|
|
1400
2108
|
return await ctx.resolveAggregate(scope.modelIDs, {
|
|
1401
2109
|
filter: scope.filter,
|
|
1402
2110
|
owner: scope.owner,
|
|
1403
|
-
|
|
2111
|
+
catalogRef: scope.catalogRef,
|
|
1404
2112
|
count,
|
|
1405
2113
|
aggregates
|
|
1406
2114
|
});
|
|
@@ -1442,7 +2150,7 @@ export class SchemaBuilder {
|
|
|
1442
2150
|
return await ctx.resolveGroupedAggregate(scope.modelIDs, {
|
|
1443
2151
|
filter: scope.filter,
|
|
1444
2152
|
owner: scope.owner,
|
|
1445
|
-
|
|
2153
|
+
catalogRef: scope.catalogRef,
|
|
1446
2154
|
count,
|
|
1447
2155
|
aggregates,
|
|
1448
2156
|
groupBy,
|
package/lib/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/graphql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"license": "see LICENSE.md",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -15,27 +15,36 @@
|
|
|
15
15
|
"LICENSE.md"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@kubun/hlc": "^0.
|
|
19
|
-
"@kubun/id": "^0.
|
|
20
|
-
"@kubun/logger": "^0.
|
|
21
|
-
"@kubun/protocol": "^0.
|
|
22
|
-
"@
|
|
23
|
-
"@sozai/
|
|
24
|
-
"@sozai/
|
|
25
|
-
"@sozai/
|
|
18
|
+
"@kubun/hlc": "^0.18.0",
|
|
19
|
+
"@kubun/id": "^0.18.0",
|
|
20
|
+
"@kubun/logger": "^0.18.0",
|
|
21
|
+
"@kubun/protocol": "^0.18.0",
|
|
22
|
+
"@kubun/records": "^0.18.0",
|
|
23
|
+
"@sozai/async": "^0.4.1",
|
|
24
|
+
"@sozai/codec": "^0.4.3",
|
|
25
|
+
"@sozai/event": "^0.1.6",
|
|
26
|
+
"@sozai/otel": "^0.3.3",
|
|
26
27
|
"change-case": "^5.4.4",
|
|
27
28
|
"graphql": "^17.0.2",
|
|
28
|
-
"graphql-scalars": "^2.0.
|
|
29
|
+
"graphql-scalars": "^2.0.1",
|
|
29
30
|
"multiformats": "^14.0.5"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@kokuin/capability": "^0.
|
|
33
|
-
"@kokuin/token": "^0.5.
|
|
34
|
-
"@kubun/
|
|
35
|
-
"@kubun/
|
|
36
|
-
"@kubun/
|
|
37
|
-
"@kubun/
|
|
38
|
-
"@kubun/
|
|
33
|
+
"@kokuin/capability": "^0.4.2",
|
|
34
|
+
"@kokuin/token": "^0.5.1",
|
|
35
|
+
"@kubun/connector": "^0.18.0",
|
|
36
|
+
"@kubun/connector-google-calendar": "^0.18.0",
|
|
37
|
+
"@kubun/db": "^0.18.0",
|
|
38
|
+
"@kubun/db-adapter": "^0.18.0",
|
|
39
|
+
"@kubun/db-better-sqlite": "^0.18.0",
|
|
40
|
+
"@kubun/db-postgres": "^0.18.0",
|
|
41
|
+
"@kubun/models-calendar": "^0.18.0",
|
|
42
|
+
"@kubun/models-core": "^0.18.0",
|
|
43
|
+
"@kubun/scalars": "^0.18.0",
|
|
44
|
+
"@kubun/store-graph": "^0.18.0",
|
|
45
|
+
"@kubun/test-utils": "^0.0.0",
|
|
46
|
+
"@testcontainers/postgresql": "^12.2.1",
|
|
47
|
+
"kysely": "^0.29.7"
|
|
39
48
|
},
|
|
40
49
|
"publishConfig": {
|
|
41
50
|
"access": "public"
|