tshex-cli 1.0.25 → 1.0.27

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,62 @@
1
+ /**
2
+ * @description HTTP error with a specific status code and message.
3
+ */
4
+ export class HttpError extends Error {
5
+ public static readonly messages: { [code: number]: string } = Object.freeze({
6
+ 400: 'Bad Request',
7
+ 401: 'Unauthorized',
8
+ 402: 'Payment Required',
9
+ 403: 'Forbidden',
10
+ 404: 'Not Found',
11
+ 405: 'Method Not Allowed',
12
+ 406: 'Not Acceptable',
13
+ 407: 'Proxy Authentication Required',
14
+ 408: 'Request Timeout',
15
+ 409: 'Conflict',
16
+ 410: 'Gone',
17
+ 411: 'Length Required',
18
+ 412: 'Precondition Failed',
19
+ 413: 'Content Too Large',
20
+ 414: 'URI Too Long',
21
+ 415: 'Unsupported Media Type',
22
+ 416: 'Range Not Satisfiable',
23
+ 417: 'Expectation Failed',
24
+ 418: "I'm a teapot",
25
+ 421: 'Misdirected Request',
26
+ 422: 'Unprocessable Content',
27
+ 423: 'Locked',
28
+ 424: 'Failed Dependency',
29
+ 425: 'Too Early',
30
+ 426: 'Upgrade Required',
31
+ 428: 'Precondition Required',
32
+ 429: 'Too Many Requests',
33
+ 431: 'Request Header Fields Too Large',
34
+ 451: 'Unavailable For Legal Reasons',
35
+ 500: 'Internal Server Error',
36
+ 501: 'Not Implemented',
37
+ 502: 'Bad Gateway',
38
+ 503: 'Service Unavailable',
39
+ 504: 'Gateway Timeout',
40
+ 505: 'HTTP Version Not Supported',
41
+ 506: 'Variant Also Negotiates',
42
+ 507: 'Insufficient Storage',
43
+ 508: 'Loop Detected',
44
+ 510: 'Not Extended',
45
+ 511: 'Network Authentication Required'
46
+ })
47
+
48
+ public readonly code: number
49
+
50
+ /**
51
+ * Creates an instance of HttpError.
52
+ *
53
+ * @constructor
54
+ * @param {number} code - The HTTP status code.
55
+ * @param {string} [message] - Fallback message if the status code is not recognized.
56
+ */
57
+ constructor(code: number, message?: string) {
58
+ super(message ?? HttpError.messages[code] ?? 'Unknown Error')
59
+ this.code = code
60
+ this.name = 'HttpError'
61
+ }
62
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @description Http request handler to process incoming requests and generate responses.
3
+ */
4
+ export interface HttpRequestHandler {
5
+ handle(request: Request): Response | Promise<Response>
6
+ }
7
+
8
+ /**
9
+ * @description An HTTP middleware that pipes requests through handlers.
10
+ */
11
+ export interface HttpMiddleware {
12
+ process(request: Request, handler: HttpRequestHandler): Response | Promise<Response>
13
+ }
@@ -0,0 +1,611 @@
1
+ import type { JsonObject, JsonPrimitive } from '../../../types/json'
2
+
3
+ /**
4
+ * JSON:API v1.1 type definitions.
5
+ *
6
+ * Specification: https://jsonapi.org/format/
7
+ * Official Atomic Operations extension: https://jsonapi.org/ext/atomic/
8
+ *
9
+ * These declarations provide compile-time structure only. Rules that depend on
10
+ * runtime values, URI validity, document-wide uniqueness, full linkage, HTTP
11
+ * semantics, or member-name character validation still require runtime checks.
12
+ */
13
+
14
+ export type JsonApiId = string
15
+ export type JsonApiLocalId = string
16
+ export type JsonApiType = string
17
+ export type JsonApiUri = string
18
+ export type JsonApiMemberName = string
19
+
20
+ export type JsonApiNonEmptyArray<T> = readonly [T, ...T[]]
21
+
22
+ /** Converts a domain type into its readonly JSON-compatible representation. */
23
+ export type JsonApiJson<T> = T extends JsonPrimitive
24
+ ? T
25
+ : T extends (...args: never[]) => unknown
26
+ ? never
27
+ : T extends readonly (infer TItem)[]
28
+ ? readonly JsonApiJson<TItem>[]
29
+ : T extends object
30
+ ? { readonly [TKey in keyof T]: JsonApiJson<T[TKey]> }
31
+ : never
32
+
33
+ /** Requires one or more selected properties to be present. */
34
+ export type JsonApiRequireAtLeastOne<TObject, TKeys extends keyof TObject = keyof TObject> = Pick<
35
+ TObject,
36
+ Exclude<keyof TObject, TKeys>
37
+ > &
38
+ {
39
+ [TKey in TKeys]-?: Required<Pick<TObject, TKey>> &
40
+ Partial<Pick<TObject, Exclude<TKeys, TKey>>>
41
+ }[TKeys]
42
+
43
+ /** Permits zero or one of the selected properties. */
44
+ export type JsonApiAtMostOne<TObject, TKeys extends keyof TObject> = Pick<
45
+ TObject,
46
+ Exclude<keyof TObject, TKeys>
47
+ > &
48
+ (
49
+ | {
50
+ [TKey in TKeys]-?: Required<Pick<TObject, TKey>> &
51
+ Partial<Record<Exclude<TKeys, TKey>, never>>
52
+ }[TKeys]
53
+ | Partial<Record<TKeys, never>>
54
+ )
55
+
56
+ /** Requires exactly one of two object shapes. */
57
+ export type JsonApiExclusive<TLeft extends object, TRight extends object> =
58
+ | (TLeft & { readonly [TKey in keyof TRight]?: never })
59
+ | (TRight & { readonly [TKey in keyof TLeft]?: never })
60
+
61
+ /**
62
+ * Extension and @-members are composable through intersections.
63
+ *
64
+ * Example:
65
+ * type VersionedResource = JsonApiResourceObject &
66
+ * JsonApiExtensionMembers<'version', { id: string }>
67
+ */
68
+ export type JsonApiExtensionMembers<TNamespace extends string, TMembers extends object> = {
69
+ readonly [TKey in keyof TMembers as `${TNamespace}:${Extract<TKey, string>}`]: JsonApiJson<
70
+ TMembers[TKey]
71
+ >
72
+ }
73
+
74
+ export type JsonApiAtMembers<TMembers extends object> = {
75
+ readonly [TKey in keyof TMembers as `@${Extract<TKey, string>}`]: JsonApiJson<TMembers[TKey]>
76
+ }
77
+
78
+ // -----------------------------------------------------------------------------
79
+ // Meta and links
80
+ // -----------------------------------------------------------------------------
81
+
82
+ export type JsonApiMeta = JsonObject
83
+ export type JsonApiAttributes = JsonObject
84
+
85
+ export type JsonApiLink = JsonApiUri | JsonApiLinkObject | null
86
+
87
+ export interface JsonApiLinkObject<TMeta extends object = JsonObject> {
88
+ readonly href: JsonApiUri
89
+ readonly rel?: string
90
+ readonly describedby?: JsonApiLink
91
+ readonly title?: string
92
+ readonly type?: string
93
+ readonly hreflang?: string | readonly string[]
94
+ readonly meta?: JsonApiJson<TMeta>
95
+ }
96
+
97
+ export interface JsonApiPaginationLinks {
98
+ readonly first?: JsonApiLink
99
+ readonly last?: JsonApiLink
100
+ readonly prev?: JsonApiLink
101
+ readonly next?: JsonApiLink
102
+ }
103
+
104
+ export interface JsonApiTopLevelLinks extends JsonApiPaginationLinks {
105
+ readonly self?: JsonApiLink
106
+ readonly related?: JsonApiLink
107
+ readonly describedby?: JsonApiLink
108
+ }
109
+
110
+ export interface JsonApiResourceLinks {
111
+ readonly self?: JsonApiLink
112
+ }
113
+
114
+ export interface JsonApiRelationshipLinks extends JsonApiPaginationLinks {
115
+ readonly self?: JsonApiLink
116
+ readonly related?: JsonApiLink
117
+ }
118
+
119
+ export interface JsonApiErrorLinks {
120
+ readonly about?: JsonApiLink
121
+ readonly type?: JsonApiLink
122
+ }
123
+
124
+ // -----------------------------------------------------------------------------
125
+ // Resource identifiers and linkage
126
+ // -----------------------------------------------------------------------------
127
+
128
+ export interface JsonApiPersistedResourceIdentifier<
129
+ TType extends JsonApiType = JsonApiType,
130
+ TMeta extends object = JsonObject
131
+ > {
132
+ readonly type: TType
133
+ readonly id: JsonApiId
134
+ readonly lid?: JsonApiLocalId
135
+ readonly meta?: JsonApiJson<TMeta>
136
+ }
137
+
138
+ export interface JsonApiLocalResourceIdentifier<
139
+ TType extends JsonApiType = JsonApiType,
140
+ TMeta extends object = JsonObject
141
+ > {
142
+ readonly type: TType
143
+ readonly id?: never
144
+ readonly lid: JsonApiLocalId
145
+ readonly meta?: JsonApiJson<TMeta>
146
+ }
147
+
148
+ export type JsonApiResourceIdentifier<
149
+ TType extends JsonApiType = JsonApiType,
150
+ TMeta extends object = JsonObject
151
+ > = JsonApiPersistedResourceIdentifier<TType, TMeta> | JsonApiLocalResourceIdentifier<TType, TMeta>
152
+
153
+ export type JsonApiToOneLinkage<
154
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier
155
+ > = TIdentifier | null
156
+
157
+ export type JsonApiToManyLinkage<
158
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier
159
+ > = readonly TIdentifier[]
160
+
161
+ export type JsonApiResourceLinkage<
162
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier
163
+ > = JsonApiToOneLinkage<TIdentifier> | JsonApiToManyLinkage<TIdentifier>
164
+
165
+ // -----------------------------------------------------------------------------
166
+ // Relationships
167
+ // -----------------------------------------------------------------------------
168
+
169
+ export interface JsonApiRelationshipMembers<
170
+ TData extends JsonApiResourceLinkage = JsonApiResourceLinkage,
171
+ TMeta extends object = JsonObject
172
+ > {
173
+ readonly links?: JsonApiRelationshipLinks
174
+ readonly data?: TData
175
+ readonly meta?: JsonApiJson<TMeta>
176
+ }
177
+
178
+ /** A base-spec relationship must contain links, data, or meta. */
179
+ export type JsonApiRelationship<
180
+ TData extends JsonApiResourceLinkage = JsonApiResourceLinkage,
181
+ TMeta extends object = JsonObject
182
+ > = JsonApiRequireAtLeastOne<JsonApiRelationshipMembers<TData, TMeta>, 'links' | 'data' | 'meta'>
183
+
184
+ export type JsonApiToOneRelationship<
185
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier,
186
+ TMeta extends object = JsonObject
187
+ > = JsonApiRelationship<JsonApiToOneLinkage<TIdentifier>, TMeta>
188
+
189
+ export type JsonApiToManyRelationship<
190
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier,
191
+ TMeta extends object = JsonObject
192
+ > = JsonApiRelationship<JsonApiToManyLinkage<TIdentifier>, TMeta>
193
+
194
+ export type JsonApiRelationships = Readonly<Record<JsonApiMemberName, JsonApiRelationship>>
195
+
196
+ /** Validates every property in a domain relationship map. */
197
+ export type JsonApiRelationshipMap<TRelationships extends object> = {
198
+ readonly [TKey in keyof TRelationships]: TRelationships[TKey] extends JsonApiRelationship
199
+ ? TRelationships[TKey]
200
+ : never
201
+ }
202
+
203
+ // -----------------------------------------------------------------------------
204
+ // Resource objects
205
+ // -----------------------------------------------------------------------------
206
+
207
+ export interface JsonApiResourceFields<
208
+ TAttributes extends object = JsonObject,
209
+ TRelationships extends object = JsonApiRelationships,
210
+ TMeta extends object = JsonObject
211
+ > {
212
+ readonly attributes?: JsonApiJson<TAttributes>
213
+ readonly relationships?: JsonApiRelationshipMap<TRelationships>
214
+ readonly links?: JsonApiResourceLinks
215
+ readonly meta?: JsonApiJson<TMeta>
216
+ }
217
+
218
+ /** A server-originated or otherwise persisted resource. */
219
+ export interface JsonApiResourceObject<
220
+ TType extends JsonApiType = JsonApiType,
221
+ TAttributes extends object = JsonObject,
222
+ TRelationships extends object = JsonApiRelationships,
223
+ TMeta extends object = JsonObject
224
+ > extends JsonApiResourceFields<TAttributes, TRelationships, TMeta> {
225
+ readonly type: TType
226
+ readonly id: JsonApiId
227
+ readonly lid?: JsonApiLocalId
228
+ }
229
+
230
+ /** A client-originated resource that has not received a server id. */
231
+ export interface JsonApiNewResourceObject<
232
+ TType extends JsonApiType = JsonApiType,
233
+ TAttributes extends object = JsonObject,
234
+ TRelationships extends object = JsonApiRelationships,
235
+ TMeta extends object = JsonObject
236
+ > extends JsonApiResourceFields<TAttributes, TRelationships, TMeta> {
237
+ readonly type: TType
238
+ readonly id?: never
239
+ readonly lid?: JsonApiLocalId
240
+ }
241
+
242
+ /** A resource accepted in create requests, including client-generated ids. */
243
+ export type JsonApiCreateResourceObject<
244
+ TType extends JsonApiType = JsonApiType,
245
+ TAttributes extends object = JsonObject,
246
+ TRelationships extends object = JsonApiRelationships,
247
+ TMeta extends object = JsonObject
248
+ > =
249
+ | JsonApiResourceObject<TType, TAttributes, TRelationships, TMeta>
250
+ | JsonApiNewResourceObject<TType, TAttributes, TRelationships, TMeta>
251
+
252
+ export type JsonApiAnyResourceObject = JsonApiCreateResourceObject
253
+
254
+ // -----------------------------------------------------------------------------
255
+ // JSON:API implementation object
256
+ // -----------------------------------------------------------------------------
257
+
258
+ export interface JsonApiObject<TMeta extends object = JsonObject> {
259
+ readonly version?: string
260
+ readonly ext?: readonly JsonApiUri[]
261
+ readonly profile?: readonly JsonApiUri[]
262
+ readonly meta?: JsonApiJson<TMeta>
263
+ }
264
+
265
+ // -----------------------------------------------------------------------------
266
+ // Errors
267
+ // -----------------------------------------------------------------------------
268
+
269
+ export interface JsonApiErrorSource {
270
+ readonly pointer?: string
271
+ readonly parameter?: string
272
+ readonly header?: string
273
+ }
274
+
275
+ export interface JsonApiErrorMembers<TMeta extends object = JsonObject> {
276
+ readonly id?: string
277
+ readonly links?: JsonApiErrorLinks
278
+ readonly status?: string
279
+ readonly code?: string
280
+ readonly title?: string
281
+ readonly detail?: string
282
+ readonly source?: JsonApiErrorSource
283
+ readonly meta?: JsonApiJson<TMeta>
284
+ }
285
+
286
+ export type JsonApiError<TMeta extends object = JsonObject> = JsonApiRequireAtLeastOne<
287
+ JsonApiErrorMembers<TMeta>
288
+ >
289
+
290
+ // -----------------------------------------------------------------------------
291
+ // Documents
292
+ // -----------------------------------------------------------------------------
293
+
294
+ export type JsonApiPrimaryData<
295
+ TResource extends JsonApiResourceObject = JsonApiResourceObject,
296
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier
297
+ > = TResource | TIdentifier | null | readonly TResource[] | readonly TIdentifier[]
298
+
299
+ export interface JsonApiDocumentMembers<TMeta extends object = JsonObject> {
300
+ readonly jsonapi?: JsonApiObject
301
+ readonly links?: JsonApiTopLevelLinks
302
+ readonly meta?: JsonApiJson<TMeta>
303
+ }
304
+
305
+ export interface JsonApiDataDocument<
306
+ TData extends JsonApiPrimaryData = JsonApiPrimaryData,
307
+ TIncluded extends JsonApiResourceObject = JsonApiResourceObject,
308
+ TMeta extends object = JsonObject
309
+ > extends JsonApiDocumentMembers<TMeta> {
310
+ readonly data: TData
311
+ readonly errors?: never
312
+ readonly included?: readonly TIncluded[]
313
+ }
314
+
315
+ export interface JsonApiErrorDocument<
316
+ TError extends JsonApiError = JsonApiError,
317
+ TMeta extends object = JsonObject
318
+ > extends JsonApiDocumentMembers<TMeta> {
319
+ readonly data?: never
320
+ readonly errors: JsonApiNonEmptyArray<TError>
321
+ readonly included?: never
322
+ }
323
+
324
+ /** A valid document whose required top-level member is meta. */
325
+ export interface JsonApiMetaDocument<
326
+ TMeta extends object = JsonObject
327
+ > extends JsonApiDocumentMembers<TMeta> {
328
+ readonly data?: never
329
+ readonly errors?: never
330
+ readonly included?: never
331
+ readonly meta: JsonApiJson<TMeta>
332
+ }
333
+
334
+ export type JsonApiDocument<
335
+ TData extends JsonApiPrimaryData = JsonApiPrimaryData,
336
+ TIncluded extends JsonApiResourceObject = JsonApiResourceObject,
337
+ TError extends JsonApiError = JsonApiError,
338
+ TMeta extends object = JsonObject
339
+ > =
340
+ | JsonApiDataDocument<TData, TIncluded, TMeta>
341
+ | JsonApiErrorDocument<TError, TMeta>
342
+ | JsonApiMetaDocument<TMeta>
343
+
344
+ export type JsonApiSingleResourceDocument<
345
+ TResource extends JsonApiResourceObject = JsonApiResourceObject,
346
+ TIncluded extends JsonApiResourceObject = JsonApiResourceObject,
347
+ TMeta extends object = JsonObject
348
+ > = JsonApiDataDocument<TResource | null, TIncluded, TMeta>
349
+
350
+ export type JsonApiResourceCollectionDocument<
351
+ TResource extends JsonApiResourceObject = JsonApiResourceObject,
352
+ TIncluded extends JsonApiResourceObject = JsonApiResourceObject,
353
+ TMeta extends object = JsonObject
354
+ > = JsonApiDataDocument<readonly TResource[], TIncluded, TMeta>
355
+
356
+ export type JsonApiSingleIdentifierDocument<
357
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier,
358
+ TMeta extends object = JsonObject
359
+ > = JsonApiDataDocument<TIdentifier | null, never, TMeta>
360
+
361
+ export type JsonApiIdentifierCollectionDocument<
362
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier,
363
+ TMeta extends object = JsonObject
364
+ > = JsonApiDataDocument<readonly TIdentifier[], never, TMeta>
365
+
366
+ export type JsonApiRelationshipDocument<
367
+ TLinkage extends JsonApiResourceLinkage = JsonApiResourceLinkage,
368
+ TMeta extends object = JsonObject
369
+ > = JsonApiDataDocument<TLinkage, never, TMeta>
370
+
371
+ // -----------------------------------------------------------------------------
372
+ // Request documents
373
+ // -----------------------------------------------------------------------------
374
+
375
+ export interface JsonApiCreateDocument<
376
+ TResource extends JsonApiCreateResourceObject = JsonApiCreateResourceObject,
377
+ TMeta extends object = JsonObject
378
+ > extends JsonApiDocumentMembers<TMeta> {
379
+ readonly data: TResource
380
+ readonly errors?: never
381
+ readonly included?: never
382
+ }
383
+
384
+ export interface JsonApiUpdateDocument<
385
+ TResource extends JsonApiResourceObject = JsonApiResourceObject,
386
+ TMeta extends object = JsonObject
387
+ > extends JsonApiDocumentMembers<TMeta> {
388
+ readonly data: TResource
389
+ readonly errors?: never
390
+ readonly included?: never
391
+ }
392
+
393
+ export interface JsonApiRelationshipUpdateDocument<
394
+ TLinkage extends JsonApiResourceLinkage = JsonApiResourceLinkage,
395
+ TMeta extends object = JsonObject
396
+ > extends JsonApiDocumentMembers<TMeta> {
397
+ readonly data: TLinkage
398
+ readonly errors?: never
399
+ readonly included?: never
400
+ }
401
+
402
+ // -----------------------------------------------------------------------------
403
+ // Query parameters
404
+ // -----------------------------------------------------------------------------
405
+
406
+ export interface JsonApiQueryParameters {
407
+ readonly include?: string
408
+ readonly sort?: string
409
+ readonly filter?: string
410
+ readonly page?: string
411
+ readonly [name: `fields[${string}]`]: string | undefined
412
+ readonly [name: `filter[${string}]`]: string | undefined
413
+ readonly [name: `page[${string}]`]: string | undefined
414
+ }
415
+
416
+ // -----------------------------------------------------------------------------
417
+ // Official Atomic Operations extension
418
+ // -----------------------------------------------------------------------------
419
+
420
+ export type JsonApiAtomicExtensionUri = 'https://jsonapi.org/ext/atomic'
421
+
422
+ export type JsonApiAtomicOperationCode = 'add' | 'update' | 'remove'
423
+
424
+ export interface JsonApiAtomicPersistedResourceRef<TType extends JsonApiType = JsonApiType> {
425
+ readonly type: TType
426
+ readonly id: JsonApiId
427
+ readonly lid?: never
428
+ readonly relationship?: never
429
+ }
430
+
431
+ export interface JsonApiAtomicLocalResourceRef<TType extends JsonApiType = JsonApiType> {
432
+ readonly type: TType
433
+ readonly id?: never
434
+ readonly lid: JsonApiLocalId
435
+ readonly relationship?: never
436
+ }
437
+
438
+ export type JsonApiAtomicResourceRef<TType extends JsonApiType = JsonApiType> =
439
+ JsonApiAtomicPersistedResourceRef<TType> | JsonApiAtomicLocalResourceRef<TType>
440
+
441
+ export interface JsonApiAtomicPersistedRelationshipRef<TType extends JsonApiType = JsonApiType> {
442
+ readonly type: TType
443
+ readonly id: JsonApiId
444
+ readonly lid?: never
445
+ readonly relationship: JsonApiMemberName
446
+ }
447
+
448
+ export interface JsonApiAtomicLocalRelationshipRef<TType extends JsonApiType = JsonApiType> {
449
+ readonly type: TType
450
+ readonly id?: never
451
+ readonly lid: JsonApiLocalId
452
+ readonly relationship: JsonApiMemberName
453
+ }
454
+
455
+ export type JsonApiAtomicRelationshipRef<TType extends JsonApiType = JsonApiType> =
456
+ JsonApiAtomicPersistedRelationshipRef<TType> | JsonApiAtomicLocalRelationshipRef<TType>
457
+
458
+ export type JsonApiAtomicRef = JsonApiAtomicResourceRef | JsonApiAtomicRelationshipRef
459
+
460
+ export type JsonApiAtomicTarget<TRef extends JsonApiAtomicRef = JsonApiAtomicRef> =
461
+ JsonApiExclusive<{ readonly ref: TRef }, { readonly href: JsonApiUri }>
462
+
463
+ export type JsonApiAtomicOptionalTarget<TRef extends JsonApiAtomicRef = JsonApiAtomicRef> =
464
+ JsonApiAtomicTarget<TRef> | { readonly ref?: never; readonly href?: never }
465
+
466
+ export type JsonApiAtomicPrimaryData =
467
+ | JsonApiAnyResourceObject
468
+ | JsonApiResourceIdentifier
469
+ | null
470
+ | readonly JsonApiAnyResourceObject[]
471
+ | readonly JsonApiResourceIdentifier[]
472
+
473
+ export interface JsonApiAtomicOperationMembers<
474
+ TData = JsonApiAtomicPrimaryData,
475
+ TMeta extends object = JsonObject
476
+ > {
477
+ readonly op: JsonApiAtomicOperationCode
478
+ readonly ref?: JsonApiAtomicRef
479
+ readonly href?: JsonApiUri
480
+ readonly data?: TData
481
+ readonly meta?: JsonApiJson<TMeta>
482
+ }
483
+
484
+ /** Structural operation object from the extension's Document Structure section. */
485
+ export type JsonApiAtomicOperation<
486
+ TData = JsonApiAtomicPrimaryData,
487
+ TMeta extends object = JsonObject
488
+ > = JsonApiAtMostOne<JsonApiAtomicOperationMembers<TData, TMeta>, 'ref' | 'href'>
489
+
490
+ export type JsonApiAtomicAddResourceOperation<
491
+ TResource extends JsonApiCreateResourceObject = JsonApiCreateResourceObject,
492
+ TMeta extends object = JsonObject
493
+ > = {
494
+ readonly op: 'add'
495
+ readonly ref?: never
496
+ readonly href?: JsonApiUri
497
+ readonly data: TResource
498
+ readonly meta?: JsonApiJson<TMeta>
499
+ }
500
+
501
+ export type JsonApiAtomicUpdateResourceOperation<
502
+ TResource extends JsonApiResourceObject = JsonApiResourceObject,
503
+ TMeta extends object = JsonObject
504
+ > = JsonApiAtomicOptionalTarget<JsonApiAtomicResourceRef> & {
505
+ readonly op: 'update'
506
+ readonly data: TResource
507
+ readonly meta?: JsonApiJson<TMeta>
508
+ }
509
+
510
+ export type JsonApiAtomicRemoveResourceOperation<TMeta extends object = JsonObject> =
511
+ JsonApiAtomicTarget<JsonApiAtomicResourceRef> & {
512
+ readonly op: 'remove'
513
+ readonly data?: never
514
+ readonly meta?: JsonApiJson<TMeta>
515
+ }
516
+
517
+ export type JsonApiAtomicUpdateToOneRelationshipOperation<
518
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier,
519
+ TMeta extends object = JsonObject
520
+ > = JsonApiAtomicTarget<JsonApiAtomicRelationshipRef> & {
521
+ readonly op: 'update'
522
+ readonly data: JsonApiToOneLinkage<TIdentifier>
523
+ readonly meta?: JsonApiJson<TMeta>
524
+ }
525
+
526
+ export type JsonApiAtomicAddToManyRelationshipOperation<
527
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier,
528
+ TMeta extends object = JsonObject
529
+ > = JsonApiAtomicTarget<JsonApiAtomicRelationshipRef> & {
530
+ readonly op: 'add'
531
+ readonly data: JsonApiToManyLinkage<TIdentifier>
532
+ readonly meta?: JsonApiJson<TMeta>
533
+ }
534
+
535
+ export type JsonApiAtomicUpdateToManyRelationshipOperation<
536
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier,
537
+ TMeta extends object = JsonObject
538
+ > = JsonApiAtomicTarget<JsonApiAtomicRelationshipRef> & {
539
+ readonly op: 'update'
540
+ readonly data: JsonApiToManyLinkage<TIdentifier>
541
+ readonly meta?: JsonApiJson<TMeta>
542
+ }
543
+
544
+ export type JsonApiAtomicRemoveFromManyRelationshipOperation<
545
+ TIdentifier extends JsonApiResourceIdentifier = JsonApiResourceIdentifier,
546
+ TMeta extends object = JsonObject
547
+ > = JsonApiAtomicTarget<JsonApiAtomicRelationshipRef> & {
548
+ readonly op: 'remove'
549
+ readonly data: JsonApiToManyLinkage<TIdentifier>
550
+ readonly meta?: JsonApiJson<TMeta>
551
+ }
552
+
553
+ export type JsonApiAtomicStrictOperation =
554
+ | JsonApiAtomicAddResourceOperation
555
+ | JsonApiAtomicUpdateResourceOperation
556
+ | JsonApiAtomicRemoveResourceOperation
557
+ | JsonApiAtomicUpdateToOneRelationshipOperation
558
+ | JsonApiAtomicAddToManyRelationshipOperation
559
+ | JsonApiAtomicUpdateToManyRelationshipOperation
560
+ | JsonApiAtomicRemoveFromManyRelationshipOperation
561
+
562
+ export interface JsonApiAtomicResult<
563
+ TData extends JsonApiPrimaryData = JsonApiPrimaryData,
564
+ TMeta extends object = JsonObject
565
+ > {
566
+ readonly data?: TData
567
+ readonly meta?: JsonApiJson<TMeta>
568
+ }
569
+
570
+ export interface JsonApiAtomicOperationsDocument<
571
+ TOperation extends JsonApiAtomicOperation = JsonApiAtomicStrictOperation,
572
+ TMeta extends object = JsonObject
573
+ > extends JsonApiDocumentMembers<TMeta> {
574
+ readonly data?: never
575
+ readonly errors?: never
576
+ readonly included?: never
577
+ readonly 'atomic:operations': JsonApiNonEmptyArray<TOperation>
578
+ readonly 'atomic:results'?: never
579
+ }
580
+
581
+ export interface JsonApiAtomicResultsDocument<
582
+ TResult extends JsonApiAtomicResult = JsonApiAtomicResult,
583
+ TMeta extends object = JsonObject
584
+ > extends JsonApiDocumentMembers<TMeta> {
585
+ readonly data?: never
586
+ readonly errors?: never
587
+ readonly included?: never
588
+ readonly 'atomic:operations'?: never
589
+ readonly 'atomic:results': JsonApiNonEmptyArray<TResult>
590
+ }
591
+
592
+ export type JsonApiAtomicRequestDocument<
593
+ TOperation extends JsonApiAtomicOperation = JsonApiAtomicStrictOperation,
594
+ TMeta extends object = JsonObject
595
+ > = JsonApiAtomicOperationsDocument<TOperation, TMeta>
596
+
597
+ export type JsonApiAtomicResponseDocument<
598
+ TResult extends JsonApiAtomicResult = JsonApiAtomicResult,
599
+ TError extends JsonApiError = JsonApiError,
600
+ TMeta extends object = JsonObject
601
+ > = JsonApiAtomicResultsDocument<TResult, TMeta> | JsonApiErrorDocument<TError, TMeta>
602
+
603
+ export type JsonApiAtomicDocument<
604
+ TOperation extends JsonApiAtomicOperation = JsonApiAtomicStrictOperation,
605
+ TResult extends JsonApiAtomicResult = JsonApiAtomicResult,
606
+ TError extends JsonApiError = JsonApiError,
607
+ TMeta extends object = JsonObject
608
+ > =
609
+ | JsonApiAtomicOperationsDocument<TOperation, TMeta>
610
+ | JsonApiAtomicResultsDocument<TResult, TMeta>
611
+ | JsonApiErrorDocument<TError, TMeta>