@contember/client 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/content/formatContentApiRelativeUrl.js +5 -0
- package/dist/development/content/formatContentApiRelativeUrl.js.map +1 -0
- package/dist/development/content/params/whereToFilter.js +17 -0
- package/dist/development/content/params/whereToFilter.js.map +1 -0
- package/dist/development/content/upload/FileUploadError.js +10 -0
- package/dist/development/content/upload/FileUploadError.js.map +1 -0
- package/dist/development/content/upload/GenerateUploadUrlMutationBuilder.js +35 -0
- package/dist/development/content/upload/GenerateUploadUrlMutationBuilder.js.map +1 -0
- package/dist/development/content/upload/S3FileUploader.js +108 -0
- package/dist/development/content/upload/S3FileUploader.js.map +1 -0
- package/dist/development/crudQueryBuilder/CrudQueryBuilder.js +104 -0
- package/dist/development/crudQueryBuilder/CrudQueryBuilder.js.map +1 -0
- package/dist/development/crudQueryBuilder/CrudQueryBuilderError.js +6 -0
- package/dist/development/crudQueryBuilder/CrudQueryBuilderError.js.map +1 -0
- package/dist/development/crudQueryBuilder/ErrorsRelationBuilder.js +15 -0
- package/dist/development/crudQueryBuilder/ErrorsRelationBuilder.js.map +1 -0
- package/dist/development/crudQueryBuilder/ReadBuilder.js +70 -0
- package/dist/development/crudQueryBuilder/ReadBuilder.js.map +1 -0
- package/dist/development/crudQueryBuilder/ValidationRelationBuilder.js +18 -0
- package/dist/development/crudQueryBuilder/ValidationRelationBuilder.js.map +1 -0
- package/dist/development/crudQueryBuilder/WriteBuilder.js +54 -0
- package/dist/development/crudQueryBuilder/WriteBuilder.js.map +1 -0
- package/dist/development/crudQueryBuilder/WriteDataBuilder.js +110 -0
- package/dist/development/crudQueryBuilder/WriteDataBuilder.js.map +1 -0
- package/dist/development/crudQueryBuilder/WriteManyRelationBuilder.js +77 -0
- package/dist/development/crudQueryBuilder/WriteManyRelationBuilder.js.map +1 -0
- package/dist/development/crudQueryBuilder/WriteOneRelationBuilder.js +51 -0
- package/dist/development/crudQueryBuilder/WriteOneRelationBuilder.js.map +1 -0
- package/dist/development/crudQueryBuilder/types.js +40 -0
- package/dist/development/crudQueryBuilder/types.js.map +1 -0
- package/dist/development/graphQlBuilder/GraphQlBuilderError.js +6 -0
- package/dist/development/graphQlBuilder/GraphQlBuilderError.js.map +1 -0
- package/dist/development/graphQlBuilder/GraphQlLiteral.js +12 -0
- package/dist/development/graphQlBuilder/GraphQlLiteral.js.map +1 -0
- package/dist/development/graphQlBuilder/ObjectBuilder.js +80 -0
- package/dist/development/graphQlBuilder/ObjectBuilder.js.map +1 -0
- package/dist/development/graphQlBuilder/QueryBuilder.js +22 -0
- package/dist/development/graphQlBuilder/QueryBuilder.js.map +1 -0
- package/dist/development/graphQlBuilder/QueryCompiler.js +101 -0
- package/dist/development/graphQlBuilder/QueryCompiler.js.map +1 -0
- package/dist/development/graphQlBuilder/RootObjectBuilder.js +31 -0
- package/dist/development/graphQlBuilder/RootObjectBuilder.js.map +1 -0
- package/dist/development/graphQlClient/GraphQlClient.js +33 -0
- package/dist/development/graphQlClient/GraphQlClient.js.map +1 -0
- package/dist/development/index.js +58 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/system/formatSystemApiRelativeUrl.js +5 -0
- package/dist/development/system/formatSystemApiRelativeUrl.js.map +1 -0
- package/dist/development/tenant/loginMutation.js +34 -0
- package/dist/development/tenant/loginMutation.js.map +1 -0
- package/dist/development/tenant/tenantApiRelativeUrl.js +5 -0
- package/dist/development/tenant/tenantApiRelativeUrl.js.map +1 -0
- package/dist/development/tenant/tenantErrorMessages.js +18 -0
- package/dist/development/tenant/tenantErrorMessages.js.map +1 -0
- package/dist/development/utils/isEmptyObject.js +12 -0
- package/dist/development/utils/isEmptyObject.js.map +1 -0
- package/dist/development/utils/readFileAsArrayBuffer.js +15 -0
- package/dist/development/utils/readFileAsArrayBuffer.js.map +1 -0
- package/dist/production/content/formatContentApiRelativeUrl.js +5 -0
- package/dist/production/content/formatContentApiRelativeUrl.js.map +1 -0
- package/dist/production/content/params/whereToFilter.js +17 -0
- package/dist/production/content/params/whereToFilter.js.map +1 -0
- package/dist/production/content/upload/FileUploadError.js +10 -0
- package/dist/production/content/upload/FileUploadError.js.map +1 -0
- package/dist/production/content/upload/GenerateUploadUrlMutationBuilder.js +35 -0
- package/dist/production/content/upload/GenerateUploadUrlMutationBuilder.js.map +1 -0
- package/dist/production/content/upload/S3FileUploader.js +108 -0
- package/dist/production/content/upload/S3FileUploader.js.map +1 -0
- package/dist/production/crudQueryBuilder/CrudQueryBuilder.js +104 -0
- package/dist/production/crudQueryBuilder/CrudQueryBuilder.js.map +1 -0
- package/dist/production/crudQueryBuilder/CrudQueryBuilderError.js +6 -0
- package/dist/production/crudQueryBuilder/CrudQueryBuilderError.js.map +1 -0
- package/dist/production/crudQueryBuilder/ErrorsRelationBuilder.js +15 -0
- package/dist/production/crudQueryBuilder/ErrorsRelationBuilder.js.map +1 -0
- package/dist/production/crudQueryBuilder/ReadBuilder.js +70 -0
- package/dist/production/crudQueryBuilder/ReadBuilder.js.map +1 -0
- package/dist/production/crudQueryBuilder/ValidationRelationBuilder.js +18 -0
- package/dist/production/crudQueryBuilder/ValidationRelationBuilder.js.map +1 -0
- package/dist/production/crudQueryBuilder/WriteBuilder.js +54 -0
- package/dist/production/crudQueryBuilder/WriteBuilder.js.map +1 -0
- package/dist/production/crudQueryBuilder/WriteDataBuilder.js +110 -0
- package/dist/production/crudQueryBuilder/WriteDataBuilder.js.map +1 -0
- package/dist/production/crudQueryBuilder/WriteManyRelationBuilder.js +77 -0
- package/dist/production/crudQueryBuilder/WriteManyRelationBuilder.js.map +1 -0
- package/dist/production/crudQueryBuilder/WriteOneRelationBuilder.js +51 -0
- package/dist/production/crudQueryBuilder/WriteOneRelationBuilder.js.map +1 -0
- package/dist/production/crudQueryBuilder/types.js +40 -0
- package/dist/production/crudQueryBuilder/types.js.map +1 -0
- package/dist/production/graphQlBuilder/GraphQlBuilderError.js +6 -0
- package/dist/production/graphQlBuilder/GraphQlBuilderError.js.map +1 -0
- package/dist/production/graphQlBuilder/GraphQlLiteral.js +12 -0
- package/dist/production/graphQlBuilder/GraphQlLiteral.js.map +1 -0
- package/dist/production/graphQlBuilder/ObjectBuilder.js +80 -0
- package/dist/production/graphQlBuilder/ObjectBuilder.js.map +1 -0
- package/dist/production/graphQlBuilder/QueryBuilder.js +22 -0
- package/dist/production/graphQlBuilder/QueryBuilder.js.map +1 -0
- package/dist/production/graphQlBuilder/QueryCompiler.js +101 -0
- package/dist/production/graphQlBuilder/QueryCompiler.js.map +1 -0
- package/dist/production/graphQlBuilder/RootObjectBuilder.js +31 -0
- package/dist/production/graphQlBuilder/RootObjectBuilder.js.map +1 -0
- package/dist/production/graphQlClient/GraphQlClient.js +33 -0
- package/dist/production/graphQlClient/GraphQlClient.js.map +1 -0
- package/dist/production/index.js +58 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/system/formatSystemApiRelativeUrl.js +5 -0
- package/dist/production/system/formatSystemApiRelativeUrl.js.map +1 -0
- package/dist/production/tenant/loginMutation.js +34 -0
- package/dist/production/tenant/loginMutation.js.map +1 -0
- package/dist/production/tenant/tenantApiRelativeUrl.js +5 -0
- package/dist/production/tenant/tenantApiRelativeUrl.js.map +1 -0
- package/dist/production/tenant/tenantErrorMessages.js +18 -0
- package/dist/production/tenant/tenantErrorMessages.js.map +1 -0
- package/dist/production/utils/isEmptyObject.js +12 -0
- package/dist/production/utils/isEmptyObject.js.map +1 -0
- package/dist/production/utils/readFileAsArrayBuffer.js +15 -0
- package/dist/production/utils/readFileAsArrayBuffer.js.map +1 -0
- package/dist/types/content/formatContentApiRelativeUrl.d.ts +2 -0
- package/dist/types/content/formatContentApiRelativeUrl.d.ts.map +1 -0
- package/dist/types/content/index.d.ts +4 -0
- package/dist/types/content/index.d.ts.map +1 -0
- package/dist/types/content/params/index.d.ts +2 -0
- package/dist/types/content/params/index.d.ts.map +1 -0
- package/dist/types/content/params/whereToFilter.d.ts +4 -0
- package/dist/types/content/params/whereToFilter.d.ts.map +1 -0
- package/dist/types/content/upload/FileUploadError.d.ts +9 -0
- package/dist/types/content/upload/FileUploadError.d.ts.map +1 -0
- package/dist/types/content/upload/FileUploadProgress.d.ts +4 -0
- package/dist/types/content/upload/FileUploadProgress.d.ts.map +1 -0
- package/dist/types/content/upload/FileUploader.d.ts +15 -0
- package/dist/types/content/upload/FileUploader.d.ts.map +1 -0
- package/dist/types/content/upload/GenerateUploadUrlMutationBuilder.d.ts +35 -0
- package/dist/types/content/upload/GenerateUploadUrlMutationBuilder.d.ts.map +1 -0
- package/dist/types/content/upload/S3FileUploader.d.ts +33 -0
- package/dist/types/content/upload/S3FileUploader.d.ts.map +1 -0
- package/dist/types/content/upload/SwitchFileUploader.d.ts +13 -0
- package/dist/types/content/upload/SwitchFileUploader.d.ts.map +1 -0
- package/dist/types/content/upload/UploadedFileMetadata.d.ts +4 -0
- package/dist/types/content/upload/UploadedFileMetadata.d.ts.map +1 -0
- package/dist/types/content/upload/index.d.ts +8 -0
- package/dist/types/content/upload/index.d.ts.map +1 -0
- package/dist/types/crudQueryBuilder/CrudQueryBuilder.d.ts +21 -0
- package/dist/types/crudQueryBuilder/CrudQueryBuilder.d.ts.map +1 -0
- package/dist/types/crudQueryBuilder/CrudQueryBuilderError.d.ts +3 -0
- package/dist/types/crudQueryBuilder/CrudQueryBuilderError.d.ts.map +1 -0
- package/dist/types/crudQueryBuilder/ErrorsRelationBuilder.d.ts +5 -0
- package/dist/types/crudQueryBuilder/ErrorsRelationBuilder.d.ts.map +1 -0
- package/dist/types/crudQueryBuilder/ReadBuilder.d.ts +31 -0
- package/dist/types/crudQueryBuilder/ReadBuilder.d.ts.map +1 -0
- package/dist/types/crudQueryBuilder/ValidationRelationBuilder.d.ts +5 -0
- package/dist/types/crudQueryBuilder/ValidationRelationBuilder.d.ts.map +1 -0
- package/dist/types/crudQueryBuilder/WriteBuilder.d.ts +24 -0
- package/dist/types/crudQueryBuilder/WriteBuilder.d.ts.map +1 -0
- package/dist/types/crudQueryBuilder/WriteDataBuilder.d.ts +24 -0
- package/dist/types/crudQueryBuilder/WriteDataBuilder.d.ts.map +1 -0
- package/dist/types/crudQueryBuilder/WriteManyRelationBuilder.d.ts +27 -0
- package/dist/types/crudQueryBuilder/WriteManyRelationBuilder.d.ts.map +1 -0
- package/dist/types/crudQueryBuilder/WriteOneRelationBuilder.d.ts +28 -0
- package/dist/types/crudQueryBuilder/WriteOneRelationBuilder.d.ts.map +1 -0
- package/dist/types/crudQueryBuilder/index.d.ts +8 -0
- package/dist/types/crudQueryBuilder/index.d.ts.map +1 -0
- package/dist/types/crudQueryBuilder/types.d.ts +45 -0
- package/dist/types/crudQueryBuilder/types.d.ts.map +1 -0
- package/dist/types/graphQlBuilder/GraphQlBuilderError.d.ts +3 -0
- package/dist/types/graphQlBuilder/GraphQlBuilderError.d.ts.map +1 -0
- package/dist/types/graphQlBuilder/GraphQlLiteral.d.ts +6 -0
- package/dist/types/graphQlBuilder/GraphQlLiteral.d.ts.map +1 -0
- package/dist/types/graphQlBuilder/ObjectBuilder.d.ts +28 -0
- package/dist/types/graphQlBuilder/ObjectBuilder.d.ts.map +1 -0
- package/dist/types/graphQlBuilder/QueryBuilder.d.ts +17 -0
- package/dist/types/graphQlBuilder/QueryBuilder.d.ts.map +1 -0
- package/dist/types/graphQlBuilder/QueryCompiler.d.ts +13 -0
- package/dist/types/graphQlBuilder/QueryCompiler.d.ts.map +1 -0
- package/dist/types/graphQlBuilder/RootObjectBuilder.d.ts +17 -0
- package/dist/types/graphQlBuilder/RootObjectBuilder.d.ts.map +1 -0
- package/dist/types/graphQlBuilder/index.d.ts +6 -0
- package/dist/types/graphQlBuilder/index.d.ts.map +1 -0
- package/dist/types/graphQlClient/GraphQlClient.d.ts +19 -0
- package/dist/types/graphQlClient/GraphQlClient.d.ts.map +1 -0
- package/dist/types/graphQlClient/index.d.ts +2 -0
- package/dist/types/graphQlClient/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +45 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/system/events/RelationFilter.d.ts +5 -0
- package/dist/types/system/events/RelationFilter.d.ts.map +1 -0
- package/dist/types/system/events/SystemEvent.d.ts +10 -0
- package/dist/types/system/events/SystemEvent.d.ts.map +1 -0
- package/dist/types/system/events/TreeFilter.d.ts +7 -0
- package/dist/types/system/events/TreeFilter.d.ts.map +1 -0
- package/dist/types/system/events/index.d.ts +4 -0
- package/dist/types/system/events/index.d.ts.map +1 -0
- package/dist/types/system/formatSystemApiRelativeUrl.d.ts +2 -0
- package/dist/types/system/formatSystemApiRelativeUrl.d.ts.map +1 -0
- package/dist/types/system/index.d.ts +3 -0
- package/dist/types/system/index.d.ts.map +1 -0
- package/dist/types/tenant/index.d.ts +4 -0
- package/dist/types/tenant/index.d.ts.map +1 -0
- package/dist/types/tenant/loginMutation.d.ts +32 -0
- package/dist/types/tenant/loginMutation.d.ts.map +1 -0
- package/dist/types/tenant/tenantApiRelativeUrl.d.ts +2 -0
- package/dist/types/tenant/tenantApiRelativeUrl.d.ts.map +1 -0
- package/dist/types/tenant/tenantErrorMessages.d.ts +5 -0
- package/dist/types/tenant/tenantErrorMessages.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/isEmptyObject.d.ts +2 -0
- package/dist/types/utils/isEmptyObject.d.ts.map +1 -0
- package/dist/types/utils/readFileAsArrayBuffer.d.ts +2 -0
- package/dist/types/utils/readFileAsArrayBuffer.d.ts.map +1 -0
- package/package.json +35 -0
- package/src/content/formatContentApiRelativeUrl.ts +2 -0
- package/src/content/index.ts +4 -0
- package/src/content/params/index.ts +1 -0
- package/src/content/params/whereToFilter.ts +19 -0
- package/src/content/upload/FileUploadError.ts +10 -0
- package/src/content/upload/FileUploadProgress.ts +3 -0
- package/src/content/upload/FileUploader.ts +19 -0
- package/src/content/upload/GenerateUploadUrlMutationBuilder.ts +72 -0
- package/src/content/upload/S3FileUploader.ts +151 -0
- package/src/content/upload/SwitchFileUploader.ts +40 -0
- package/src/content/upload/UploadedFileMetadata.ts +3 -0
- package/src/content/upload/index.ts +7 -0
- package/src/crudQueryBuilder/CrudQueryBuilder.ts +168 -0
- package/src/crudQueryBuilder/CrudQueryBuilderError.ts +1 -0
- package/src/crudQueryBuilder/ErrorsRelationBuilder.ts +16 -0
- package/src/crudQueryBuilder/ReadBuilder.ts +106 -0
- package/src/crudQueryBuilder/ValidationRelationBuilder.ts +17 -0
- package/src/crudQueryBuilder/WriteBuilder.ts +79 -0
- package/src/crudQueryBuilder/WriteDataBuilder.ts +153 -0
- package/src/crudQueryBuilder/WriteManyRelationBuilder.ts +141 -0
- package/src/crudQueryBuilder/WriteOneRelationBuilder.ts +101 -0
- package/src/crudQueryBuilder/index.ts +7 -0
- package/src/crudQueryBuilder/types.ts +73 -0
- package/src/graphQlBuilder/GraphQlBuilderError.ts +1 -0
- package/src/graphQlBuilder/GraphQlLiteral.ts +7 -0
- package/src/graphQlBuilder/ObjectBuilder.ts +87 -0
- package/src/graphQlBuilder/QueryBuilder.ts +34 -0
- package/src/graphQlBuilder/QueryCompiler.ts +115 -0
- package/src/graphQlBuilder/RootObjectBuilder.ts +36 -0
- package/src/graphQlBuilder/index.ts +5 -0
- package/src/graphQlClient/GraphQlClient.ts +52 -0
- package/src/graphQlClient/index.ts +1 -0
- package/src/index.ts +49 -0
- package/src/system/events/RelationFilter.ts +4 -0
- package/src/system/events/SystemEvent.ts +9 -0
- package/src/system/events/TreeFilter.ts +7 -0
- package/src/system/events/index.ts +3 -0
- package/src/system/formatSystemApiRelativeUrl.ts +1 -0
- package/src/system/index.ts +2 -0
- package/src/tenant/index.ts +3 -0
- package/src/tenant/loginMutation.ts +61 -0
- package/src/tenant/tenantApiRelativeUrl.ts +1 -0
- package/src/tenant/tenantErrorMessages.ts +14 -0
- package/src/tsconfig.json +6 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/isEmptyObject.ts +9 -0
- package/src/utils/readFileAsArrayBuffer.ts +12 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Input } from '@contember/schema'
|
|
2
|
+
import type { GraphQlLiteral } from '../graphQlBuilder'
|
|
3
|
+
import type { WriteOperation, WriteRelationOps } from './types'
|
|
4
|
+
import { WriteDataBuilder } from './WriteDataBuilder'
|
|
5
|
+
|
|
6
|
+
class WriteOneRelationBuilder<
|
|
7
|
+
Op extends WriteOperation.ContentfulOperation,
|
|
8
|
+
Allowed extends WriteRelationOps[Op['op']] = WriteRelationOps[Op['op']],
|
|
9
|
+
D extends WriteOneRelationBuilder.DataFormat[Op['op']] | undefined = WriteOneRelationBuilder.DataFormat[Op['op']],
|
|
10
|
+
> {
|
|
11
|
+
protected constructor(public readonly data: D = undefined as D) {}
|
|
12
|
+
|
|
13
|
+
public static instantiate<
|
|
14
|
+
Op extends WriteOperation.ContentfulOperation,
|
|
15
|
+
Allowed extends WriteRelationOps[Op['op']] = WriteRelationOps[Op['op']],
|
|
16
|
+
D extends WriteOneRelationBuilder.DataFormat[Op['op']] | undefined = WriteOneRelationBuilder.DataFormat[Op['op']],
|
|
17
|
+
>(data: D = undefined as D): WriteOneRelationBuilder.Builder<Op, Allowed, D> {
|
|
18
|
+
return new WriteOneRelationBuilder<Op, Allowed, D>(data)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static instantiateFromFactory<
|
|
22
|
+
Op extends WriteOperation.ContentfulOperation,
|
|
23
|
+
Allowed extends WriteRelationOps[Op['op']] = WriteRelationOps[Op['op']],
|
|
24
|
+
D extends WriteOneRelationBuilder.DataFormat[Op['op']] | undefined = WriteOneRelationBuilder.DataFormat[Op['op']],
|
|
25
|
+
>(builder: WriteOneRelationBuilder.BuilderFactory<Op, Allowed, D>): WriteOneRelationBuilder.Builder<Op, never, D> {
|
|
26
|
+
if (typeof builder === 'function') {
|
|
27
|
+
return builder(WriteOneRelationBuilder.instantiate())
|
|
28
|
+
}
|
|
29
|
+
if (builder && 'data' in builder!) {
|
|
30
|
+
return WriteOneRelationBuilder.instantiate(builder.data)
|
|
31
|
+
}
|
|
32
|
+
return WriteOneRelationBuilder.instantiate(builder)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public create(data: WriteDataBuilder.DataLike<WriteOperation.Create>) {
|
|
36
|
+
const resolvedData = WriteDataBuilder.resolveData(data)
|
|
37
|
+
return resolvedData === undefined
|
|
38
|
+
? this
|
|
39
|
+
: WriteOneRelationBuilder.instantiate<Op, never>({
|
|
40
|
+
create: resolvedData,
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public connect(where: Input.UniqueWhere<GraphQlLiteral>) {
|
|
45
|
+
return WriteOneRelationBuilder.instantiate<Op, never>({ connect: where })
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public delete() {
|
|
49
|
+
return WriteOneRelationBuilder.instantiate<WriteOperation.Update, never>({ delete: true })
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public disconnect() {
|
|
53
|
+
return WriteOneRelationBuilder.instantiate<WriteOperation.Update, never>({ disconnect: true })
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public update(data: WriteDataBuilder.DataLike<WriteOperation.Update>) {
|
|
57
|
+
const resolvedData = WriteDataBuilder.resolveData(data)
|
|
58
|
+
return resolvedData === undefined ? this : new WriteOneRelationBuilder({ update: resolvedData })
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public upsert(
|
|
62
|
+
update: WriteDataBuilder.DataLike<WriteOperation.Update>,
|
|
63
|
+
create: WriteDataBuilder.DataLike<WriteOperation.Create>,
|
|
64
|
+
) {
|
|
65
|
+
const resolvedCreate = WriteDataBuilder.resolveData(create)
|
|
66
|
+
const resolvedUpdate = WriteDataBuilder.resolveData(update)
|
|
67
|
+
|
|
68
|
+
return resolvedUpdate === undefined && resolvedCreate === undefined
|
|
69
|
+
? this
|
|
70
|
+
: WriteOneRelationBuilder.instantiate<WriteOperation.Update, never>({
|
|
71
|
+
upsert: {
|
|
72
|
+
update: resolvedUpdate || {},
|
|
73
|
+
create: resolvedCreate || {},
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
namespace WriteOneRelationBuilder {
|
|
80
|
+
export interface DataFormat {
|
|
81
|
+
create: Input.CreateOneRelationInput<GraphQlLiteral>
|
|
82
|
+
update: Input.UpdateOneRelationInput<GraphQlLiteral>
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type Builder<
|
|
86
|
+
Op extends WriteOperation.ContentfulOperation,
|
|
87
|
+
Allowed extends WriteRelationOps[Op['op']] = WriteRelationOps[Op['op']],
|
|
88
|
+
D extends WriteOneRelationBuilder.DataFormat[Op['op']] | undefined = WriteOneRelationBuilder.DataFormat[Op['op']],
|
|
89
|
+
> = Omit<
|
|
90
|
+
WriteOneRelationBuilder<Op, Allowed, D>,
|
|
91
|
+
Exclude<WriteRelationOps[WriteOperation.ContentfulOperation['op']], Allowed>
|
|
92
|
+
>
|
|
93
|
+
|
|
94
|
+
export type BuilderFactory<
|
|
95
|
+
Op extends WriteOperation.ContentfulOperation,
|
|
96
|
+
Allowed extends WriteRelationOps[Op['op']] = WriteRelationOps[Op['op']],
|
|
97
|
+
D extends WriteOneRelationBuilder.DataFormat[Op['op']] | undefined = WriteOneRelationBuilder.DataFormat[Op['op']],
|
|
98
|
+
> = D | Builder<Op, never, D> | ((builder: Builder<Op, Allowed, D>) => Builder<Op, never, D>)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { WriteOneRelationBuilder }
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { GraphQlLiteral } from '../graphQlBuilder'
|
|
2
|
+
|
|
3
|
+
export type Mutations = 'create' | 'update' | 'delete'
|
|
4
|
+
|
|
5
|
+
export type Queries = 'get' | 'list' | 'paginate'
|
|
6
|
+
|
|
7
|
+
export type GetQueryArguments = 'by'
|
|
8
|
+
|
|
9
|
+
export type ListQueryArguments = 'filter' | 'orderBy' | 'offset' | 'limit'
|
|
10
|
+
|
|
11
|
+
export type PaginateQueryArguments = 'filter' | 'orderBy' | 'skip' | 'first'
|
|
12
|
+
|
|
13
|
+
export type CreateMutationArguments = 'data'
|
|
14
|
+
|
|
15
|
+
export type UpdateMutationArguments = 'data' | 'by'
|
|
16
|
+
|
|
17
|
+
export type DeleteMutationArguments = 'by'
|
|
18
|
+
|
|
19
|
+
export type ReductionArguments = 'filter' | 'by'
|
|
20
|
+
|
|
21
|
+
export type HasOneArguments = 'filter'
|
|
22
|
+
|
|
23
|
+
export type HasManyArguments = 'filter' | 'orderBy' | 'offset' | 'limit'
|
|
24
|
+
|
|
25
|
+
export type UpdateMutationFields = 'ok' | 'validation' | 'errors' | 'errorMessage' | 'node'
|
|
26
|
+
|
|
27
|
+
export type CreateMutationFields = 'ok' | 'validation' | 'errors' | 'errorMessage' | 'node'
|
|
28
|
+
|
|
29
|
+
export type DeleteMutationFields = 'ok' | 'node' | 'errors' | 'errorMessage'
|
|
30
|
+
|
|
31
|
+
export type WriteArguments = CreateMutationArguments | UpdateMutationArguments | DeleteMutationArguments
|
|
32
|
+
|
|
33
|
+
export type WriteFields = UpdateMutationFields | CreateMutationFields
|
|
34
|
+
|
|
35
|
+
export type ReadArguments =
|
|
36
|
+
| GetQueryArguments
|
|
37
|
+
| ListQueryArguments
|
|
38
|
+
| PaginateQueryArguments
|
|
39
|
+
| HasOneArguments
|
|
40
|
+
| HasManyArguments
|
|
41
|
+
|
|
42
|
+
export interface WriteRelationOps {
|
|
43
|
+
create: 'create' | 'connect'
|
|
44
|
+
update: 'create' | 'connect' | 'delete' | 'disconnect' | 'update' | 'upsert'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type OrderDirection = GraphQlLiteral<'asc'> | GraphQlLiteral<'desc'>
|
|
48
|
+
|
|
49
|
+
// TODO Silly enums because TS does not support enum extension 🙄
|
|
50
|
+
// https://github.com/Microsoft/TypeScript/issues/17592
|
|
51
|
+
export namespace WriteOperation {
|
|
52
|
+
export interface Operation {
|
|
53
|
+
op: 'create' | 'update' | 'delete'
|
|
54
|
+
}
|
|
55
|
+
export abstract class Operation implements Operation {}
|
|
56
|
+
|
|
57
|
+
export interface ContentfulOperation {
|
|
58
|
+
op: 'create' | 'update'
|
|
59
|
+
}
|
|
60
|
+
export abstract class ContentfulOperation extends Operation implements ContentfulOperation {}
|
|
61
|
+
|
|
62
|
+
export class Update extends ContentfulOperation {
|
|
63
|
+
override readonly op = 'update' as const
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class Create extends ContentfulOperation {
|
|
67
|
+
override readonly op = 'create' as const
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export class Delete extends Operation {
|
|
71
|
+
override readonly op = 'delete' as const
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class GraphQlBuilderError extends Error {}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export class ObjectBuilder {
|
|
2
|
+
constructor(
|
|
3
|
+
public readonly fields: string[] = [],
|
|
4
|
+
public readonly objects: { [name: string]: ObjectBuilder } = {},
|
|
5
|
+
public readonly args: { [name: string]: any } = {},
|
|
6
|
+
public readonly fragmentApplications: string[] = [],
|
|
7
|
+
public readonly inlineFragments: { [typeName: string]: ObjectBuilder } = {},
|
|
8
|
+
public readonly objectName?: string,
|
|
9
|
+
) {}
|
|
10
|
+
|
|
11
|
+
public argument(name: string, value: any): ObjectBuilder {
|
|
12
|
+
return new ObjectBuilder(
|
|
13
|
+
this.fields,
|
|
14
|
+
this.objects,
|
|
15
|
+
{ ...this.args, [name]: value },
|
|
16
|
+
this.fragmentApplications,
|
|
17
|
+
this.inlineFragments,
|
|
18
|
+
this.objectName,
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public name(name: string): ObjectBuilder {
|
|
23
|
+
return new ObjectBuilder(
|
|
24
|
+
this.fields,
|
|
25
|
+
this.objects,
|
|
26
|
+
this.args,
|
|
27
|
+
this.fragmentApplications,
|
|
28
|
+
this.inlineFragments,
|
|
29
|
+
name,
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public field(name: string): ObjectBuilder {
|
|
34
|
+
return new ObjectBuilder(
|
|
35
|
+
[...this.fields, name],
|
|
36
|
+
this.objects,
|
|
37
|
+
this.args,
|
|
38
|
+
this.fragmentApplications,
|
|
39
|
+
this.inlineFragments,
|
|
40
|
+
this.objectName,
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public object(name: string, builder: ((builder: ObjectBuilder) => ObjectBuilder) | ObjectBuilder): ObjectBuilder {
|
|
45
|
+
if (!(builder instanceof ObjectBuilder)) {
|
|
46
|
+
builder = builder(new ObjectBuilder())
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return new ObjectBuilder(
|
|
50
|
+
this.fields,
|
|
51
|
+
{ ...this.objects, [name]: builder },
|
|
52
|
+
this.args,
|
|
53
|
+
this.fragmentApplications,
|
|
54
|
+
this.inlineFragments,
|
|
55
|
+
this.objectName,
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public inlineFragment(
|
|
60
|
+
typeName: string,
|
|
61
|
+
builder: ((builder: ObjectBuilder) => ObjectBuilder) | ObjectBuilder,
|
|
62
|
+
): ObjectBuilder {
|
|
63
|
+
if (!(builder instanceof ObjectBuilder)) {
|
|
64
|
+
builder = builder(new ObjectBuilder())
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return new ObjectBuilder(
|
|
68
|
+
this.fields,
|
|
69
|
+
this.objects,
|
|
70
|
+
this.args,
|
|
71
|
+
this.fragmentApplications,
|
|
72
|
+
{ ...this.inlineFragments, [typeName]: builder },
|
|
73
|
+
this.objectName,
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public applyFragment(fragmentName: string): ObjectBuilder {
|
|
78
|
+
return new ObjectBuilder(
|
|
79
|
+
this.fields,
|
|
80
|
+
this.objects,
|
|
81
|
+
this.args,
|
|
82
|
+
[...this.fragmentApplications, fragmentName],
|
|
83
|
+
this.inlineFragments,
|
|
84
|
+
this.objectName,
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { GraphQlLiteral } from './GraphQlLiteral'
|
|
2
|
+
import { QueryCompiler } from './QueryCompiler'
|
|
3
|
+
import { RootObjectBuilder } from './RootObjectBuilder'
|
|
4
|
+
|
|
5
|
+
class QueryBuilder {
|
|
6
|
+
query(builder: ((builder: RootObjectBuilder) => RootObjectBuilder) | RootObjectBuilder): string {
|
|
7
|
+
if (!(builder instanceof RootObjectBuilder)) {
|
|
8
|
+
builder = builder(new RootObjectBuilder())
|
|
9
|
+
}
|
|
10
|
+
const compiler = new QueryCompiler('query', builder)
|
|
11
|
+
return compiler.create()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
mutation(builder: ((builder: RootObjectBuilder) => RootObjectBuilder) | RootObjectBuilder): string {
|
|
15
|
+
if (!(builder instanceof RootObjectBuilder)) {
|
|
16
|
+
builder = builder(new RootObjectBuilder())
|
|
17
|
+
}
|
|
18
|
+
const compiler = new QueryCompiler('mutation', builder)
|
|
19
|
+
return compiler.create()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
namespace QueryBuilder {
|
|
24
|
+
export interface Object {
|
|
25
|
+
[key: string]: Value
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface List extends Array<Value> {}
|
|
29
|
+
|
|
30
|
+
export type AtomicValue = string | null | number | boolean | GraphQlLiteral
|
|
31
|
+
export type Value = AtomicValue | QueryBuilder.Object | List
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { QueryBuilder }
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { GraphQlLiteral } from './GraphQlLiteral'
|
|
2
|
+
import type { ObjectBuilder } from './ObjectBuilder'
|
|
3
|
+
import type { RootObjectBuilder } from './RootObjectBuilder'
|
|
4
|
+
|
|
5
|
+
export class QueryCompiler {
|
|
6
|
+
constructor(private operation: 'query' | 'mutation', private builder: RootObjectBuilder) {}
|
|
7
|
+
|
|
8
|
+
public create(): string {
|
|
9
|
+
const rootObjects = this.formatRootObjects(this.builder.objects)
|
|
10
|
+
const fragmentDefinitions = this.formatFragmentDefinitions(this.builder.fragmentDefinitions)
|
|
11
|
+
|
|
12
|
+
return `${this.operation} {\n${rootObjects}\n}${fragmentDefinitions ? `\n${fragmentDefinitions}` : ''}`
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private formatFragmentDefinitions(fragments: RootObjectBuilder['fragmentDefinitions']): string {
|
|
16
|
+
const lines: string[] = []
|
|
17
|
+
|
|
18
|
+
for (const name in fragments) {
|
|
19
|
+
const object = fragments[name]
|
|
20
|
+
|
|
21
|
+
lines.push(`fragment ${name} on ${object.objectName!} {`)
|
|
22
|
+
lines.push(...this.formatObjectBody(object))
|
|
23
|
+
lines.push('}')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return lines.join('\n')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private formatRootObjects(objects: RootObjectBuilder['objects']): string {
|
|
30
|
+
const lines: string[] = []
|
|
31
|
+
|
|
32
|
+
for (const alias in objects) {
|
|
33
|
+
lines.push(...this.formatObject(alias, objects[alias]).map(val => `\t${val}`))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return lines.join('\n')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private formatObject(alias: string, builder: ObjectBuilder): string[] {
|
|
40
|
+
const result = []
|
|
41
|
+
|
|
42
|
+
result.push(`${alias}${builder.objectName ? `: ${builder.objectName}` : ''}${this.formatArgs(builder.args, 0)} {`)
|
|
43
|
+
|
|
44
|
+
result.push(...this.formatObjectBody(builder))
|
|
45
|
+
|
|
46
|
+
result.push('}')
|
|
47
|
+
|
|
48
|
+
return result
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private formatObjectBody(builder: ObjectBuilder): string[] {
|
|
52
|
+
const result = ['__typename']
|
|
53
|
+
for (const fieldName of builder.fields) {
|
|
54
|
+
result.push(fieldName)
|
|
55
|
+
}
|
|
56
|
+
for (const fragmentName of builder.fragmentApplications) {
|
|
57
|
+
result.push(`... ${fragmentName}`)
|
|
58
|
+
}
|
|
59
|
+
for (const typeName in builder.inlineFragments) {
|
|
60
|
+
const fragment = builder.inlineFragments[typeName]
|
|
61
|
+
result.push(`... on ${typeName} {`, ...this.formatObjectBody(fragment), '}')
|
|
62
|
+
}
|
|
63
|
+
for (const alias in builder.objects) {
|
|
64
|
+
result.push(...this.formatObject(alias, builder.objects[alias]))
|
|
65
|
+
}
|
|
66
|
+
return result.map(val => `\t${val}`)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private formatArgs(args: any, level: number): string {
|
|
70
|
+
if (args === null) {
|
|
71
|
+
return 'null'
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (typeof args === 'number') {
|
|
75
|
+
return args.toString()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (typeof args === 'boolean') {
|
|
79
|
+
return args ? 'true' : 'false'
|
|
80
|
+
}
|
|
81
|
+
if (typeof args === 'string') {
|
|
82
|
+
return JSON.stringify(args)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (Array.isArray(args)) {
|
|
86
|
+
const vals = args.map(val => this.formatArgs(val, level + 1))
|
|
87
|
+
return `[${vals.join(', ')}]`
|
|
88
|
+
}
|
|
89
|
+
if (args instanceof GraphQlLiteral) {
|
|
90
|
+
return args.value
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (typeof args === 'object') {
|
|
94
|
+
let result = ''
|
|
95
|
+
for (let key in args) {
|
|
96
|
+
const argValue = args[key]
|
|
97
|
+
if (argValue === undefined) {
|
|
98
|
+
continue
|
|
99
|
+
}
|
|
100
|
+
result += `${key}: ${this.formatArgs(argValue, level + 1)}, `
|
|
101
|
+
}
|
|
102
|
+
if (result.length > 0) {
|
|
103
|
+
result = result.substring(0, result.length - 2)
|
|
104
|
+
}
|
|
105
|
+
if (level > 0) {
|
|
106
|
+
return `{${result}}`
|
|
107
|
+
} else if (result.length > 0) {
|
|
108
|
+
return `(${result})`
|
|
109
|
+
}
|
|
110
|
+
return ''
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
throw new Error(typeof args)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isEmptyObject } from '../utils'
|
|
2
|
+
import { GraphQlBuilderError } from './GraphQlBuilderError'
|
|
3
|
+
import { ObjectBuilder } from './ObjectBuilder'
|
|
4
|
+
|
|
5
|
+
export class RootObjectBuilder {
|
|
6
|
+
constructor(
|
|
7
|
+
public readonly objects: { [name: string]: ObjectBuilder } = {},
|
|
8
|
+
public readonly fragmentDefinitions: { [name: string]: ObjectBuilder } = {},
|
|
9
|
+
) {}
|
|
10
|
+
|
|
11
|
+
public fragment(
|
|
12
|
+
name: string,
|
|
13
|
+
builder: ((builder: ObjectBuilder) => ObjectBuilder) | ObjectBuilder,
|
|
14
|
+
): RootObjectBuilder {
|
|
15
|
+
if (!(builder instanceof ObjectBuilder)) {
|
|
16
|
+
builder = builder(new ObjectBuilder())
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!isEmptyObject(builder.args)) {
|
|
20
|
+
throw new GraphQlBuilderError(`Cannot supply args to Graph QL fragments!`)
|
|
21
|
+
}
|
|
22
|
+
if (!builder.objectName) {
|
|
23
|
+
throw new GraphQlBuilderError(`Object names are mandatory for Graph QL fragments!`)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return new RootObjectBuilder(this.objects, { ...this.fragmentDefinitions, [name]: builder })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public object(name: string, builder: ((builder: ObjectBuilder) => ObjectBuilder) | ObjectBuilder): RootObjectBuilder {
|
|
30
|
+
if (!(builder instanceof ObjectBuilder)) {
|
|
31
|
+
builder = builder(new ObjectBuilder())
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return new RootObjectBuilder({ ...this.objects, [name]: builder }, this.fragmentDefinitions)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface GraphQlClientRequestOptions {
|
|
2
|
+
variables?: GraphQlClientVariables
|
|
3
|
+
apiTokenOverride?: string
|
|
4
|
+
signal?: AbortSignal
|
|
5
|
+
headers?: Record<string, string>
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface GraphQlClientVariables {
|
|
9
|
+
[name: string]: any
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type GraphQlClientFailedRequestMetadata = Pick<Response, 'status' | 'statusText'> & {
|
|
13
|
+
responseText: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class GraphQlClient {
|
|
17
|
+
constructor(public readonly apiUrl: string, private readonly apiToken?: string) { }
|
|
18
|
+
|
|
19
|
+
async sendRequest<T = unknown>(
|
|
20
|
+
query: string,
|
|
21
|
+
{ apiTokenOverride, signal, variables, headers }: GraphQlClientRequestOptions = {},
|
|
22
|
+
): Promise<T> {
|
|
23
|
+
const resolvedHeaders: Record<string, string> = { 'Content-Type': 'application/json', ...headers }
|
|
24
|
+
const resolvedToken = apiTokenOverride ?? this.apiToken
|
|
25
|
+
|
|
26
|
+
if (resolvedToken !== undefined) {
|
|
27
|
+
resolvedHeaders['Authorization'] = `Bearer ${resolvedToken}`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.debug(query)
|
|
31
|
+
|
|
32
|
+
const response = await fetch(this.apiUrl, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
headers: resolvedHeaders,
|
|
35
|
+
signal,
|
|
36
|
+
body: JSON.stringify({ query, variables }),
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
if (response.ok) {
|
|
40
|
+
// It may still have errors (e.g. unfilled fields) but as far as the request goes, it is ok.
|
|
41
|
+
return await response.json()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const failedRequest: GraphQlClientFailedRequestMetadata = {
|
|
45
|
+
status: response.status,
|
|
46
|
+
statusText: response.statusText,
|
|
47
|
+
responseText: await response.text(),
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return Promise.reject(failedRequest)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GraphQlClient'
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as CrudQueryBuilderTmp from './crudQueryBuilder'
|
|
2
|
+
|
|
3
|
+
import * as GraphQlBuilderTmp from './graphQlBuilder'
|
|
4
|
+
export { GraphQlLiteral } from './graphQlBuilder'
|
|
5
|
+
|
|
6
|
+
export namespace GraphQlBuilder {
|
|
7
|
+
export import GraphqlLiteral = GraphQlBuilderTmp.GraphQlLiteral
|
|
8
|
+
export import GraphQlLiteral = GraphQlBuilderTmp.GraphQlLiteral
|
|
9
|
+
export import ObjectBuilder = GraphQlBuilderTmp.ObjectBuilder
|
|
10
|
+
export import QueryCompiler = GraphQlBuilderTmp.QueryCompiler
|
|
11
|
+
export import QueryBuilder = GraphQlBuilderTmp.QueryBuilder
|
|
12
|
+
export import RootObjectBuilder = GraphQlBuilderTmp.RootObjectBuilder
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export namespace CrudQueryBuilder {
|
|
16
|
+
export import CrudQueryBuilder = CrudQueryBuilderTmp.CrudQueryBuilder
|
|
17
|
+
export import ReadBuilder = CrudQueryBuilderTmp.ReadBuilder
|
|
18
|
+
export import WriteBuilder = CrudQueryBuilderTmp.WriteBuilder
|
|
19
|
+
export import WriteDataBuilder = CrudQueryBuilderTmp.WriteDataBuilder
|
|
20
|
+
export import WriteManyRelationBuilder = CrudQueryBuilderTmp.WriteManyRelationBuilder
|
|
21
|
+
export import WriteOneRelationBuilder = CrudQueryBuilderTmp.WriteOneRelationBuilder
|
|
22
|
+
export import WriteOperation = CrudQueryBuilderTmp.WriteOperation
|
|
23
|
+
export type CreateMutationArguments = CrudQueryBuilderTmp.CreateMutationArguments
|
|
24
|
+
export type CreateMutationFields = CrudQueryBuilderTmp.CreateMutationFields
|
|
25
|
+
export type DeleteMutationArguments = CrudQueryBuilderTmp.DeleteMutationArguments
|
|
26
|
+
export type DeleteMutationFields = CrudQueryBuilderTmp.DeleteMutationFields
|
|
27
|
+
export type GetQueryArguments = CrudQueryBuilderTmp.GetQueryArguments
|
|
28
|
+
export type HasManyArguments = CrudQueryBuilderTmp.HasManyArguments
|
|
29
|
+
export type HasOneArguments = CrudQueryBuilderTmp.HasOneArguments
|
|
30
|
+
export type ListQueryArguments = CrudQueryBuilderTmp.ListQueryArguments
|
|
31
|
+
export type Mutations = CrudQueryBuilderTmp.Mutations
|
|
32
|
+
export type OrderDirection = CrudQueryBuilderTmp.OrderDirection
|
|
33
|
+
export type PaginateQueryArguments = CrudQueryBuilderTmp.PaginateQueryArguments
|
|
34
|
+
export type Queries = CrudQueryBuilderTmp.Queries
|
|
35
|
+
export type ReadArguments = CrudQueryBuilderTmp.ReadArguments
|
|
36
|
+
export type ReductionArguments = CrudQueryBuilderTmp.ReductionArguments
|
|
37
|
+
export type UpdateMutationArguments = CrudQueryBuilderTmp.UpdateMutationArguments
|
|
38
|
+
export type UpdateMutationFields = CrudQueryBuilderTmp.UpdateMutationFields
|
|
39
|
+
export type WriteArguments = CrudQueryBuilderTmp.WriteArguments
|
|
40
|
+
export type WriteFields = CrudQueryBuilderTmp.WriteFields
|
|
41
|
+
export type WriteRelationOps = CrudQueryBuilderTmp.WriteRelationOps
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export * from './content'
|
|
45
|
+
export * from './graphQlClient'
|
|
46
|
+
export * from './system'
|
|
47
|
+
export * from './tenant'
|
|
48
|
+
|
|
49
|
+
export type { Input, Value, Result, Writable } from '@contember/schema'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const formatSystemApiRelativeUrl = (projectSlug: string) => `/system/${projectSlug}`
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface LoginMutationResponse {
|
|
2
|
+
data: {
|
|
3
|
+
signIn: {
|
|
4
|
+
ok: boolean
|
|
5
|
+
errors: Array<{
|
|
6
|
+
endUserMessage: string | null
|
|
7
|
+
code: string
|
|
8
|
+
}>
|
|
9
|
+
result: {
|
|
10
|
+
token: string
|
|
11
|
+
person: {
|
|
12
|
+
id: string
|
|
13
|
+
email: string
|
|
14
|
+
identity: {
|
|
15
|
+
id: string
|
|
16
|
+
projects: Array<{
|
|
17
|
+
project: {
|
|
18
|
+
id: string
|
|
19
|
+
slug: string
|
|
20
|
+
}
|
|
21
|
+
memberships: Array<{
|
|
22
|
+
role: string
|
|
23
|
+
}>
|
|
24
|
+
}>
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
} | null
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const loginMutation = `
|
|
33
|
+
mutation($email: String!, $password: String!, $expiration: Int) {
|
|
34
|
+
signIn(email: $email, password: $password, expiration: $expiration) {
|
|
35
|
+
ok
|
|
36
|
+
errors {
|
|
37
|
+
endUserMessage
|
|
38
|
+
code
|
|
39
|
+
}
|
|
40
|
+
result {
|
|
41
|
+
token
|
|
42
|
+
person {
|
|
43
|
+
id
|
|
44
|
+
email
|
|
45
|
+
identity {
|
|
46
|
+
id
|
|
47
|
+
projects {
|
|
48
|
+
project {
|
|
49
|
+
id
|
|
50
|
+
slug
|
|
51
|
+
}
|
|
52
|
+
memberships {
|
|
53
|
+
role
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`
|