@enonic-types/guillotine 8.0.0 → 9.0.0-B2

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/README.md CHANGED
@@ -38,7 +38,7 @@ export const extensions = (graphQL: GraphQL): Extensions => {
38
38
  },
39
39
  resolvers: {
40
40
  [ObjectTypeName.Content]: {
41
- [MY_FIELD_NAME]: () => {
41
+ [MY_FIELD_NAME]: (env) => {
42
42
  const {
43
43
  // args,
44
44
  // localContext,
package/Utils.d.ts CHANGED
@@ -18,6 +18,4 @@ export declare type PartialRecord<K extends keyof any, T> = {
18
18
  [P in K]?: T
19
19
  }
20
20
 
21
- type RecordValueType<T> = T extends Record<string, infer U> ? U : never;
22
-
23
21
  export declare type ValueOf<T> = T[keyof T]
package/advanced.ts CHANGED
@@ -43,32 +43,20 @@ export type {
43
43
  } from './brand'
44
44
 
45
45
  export type {
46
- // AnyResolver, // Not certain this should be exported
47
46
  CreationCallback,
48
47
  CreationCallbacks,
49
48
  DataFetchingEnvironment,
50
- Enum,
51
- Enums,
52
49
  Extensions,
53
- Field,
54
- Fields,
55
- InputType,
56
- InputTypeField,
57
- InputTypeFields,
58
- InputTypes,
59
50
  Resolver,
60
51
  Resolvers,
61
52
  Type,
62
- TypeResolver,
63
- TypeResolvers,
64
53
  Types,
65
- Union,
66
- Unions
67
54
  } from './extensions'
68
55
 
69
56
  export type {
70
57
  CreateDataFetcherResult,
71
58
  CreateDataFetcherResultParams,
59
+ DataFetcherResult,
72
60
  GraphQL,
73
61
  GraphQLArgs,
74
62
  GraphQLBaseScalars,
@@ -104,33 +92,61 @@ export type {
104
92
  export type {
105
93
  AccessControlEntry,
106
94
  Attachment,
95
+ AttachmentUrl,
107
96
  EnumTypeNames,
108
97
  InputTypeNames,
109
98
  ObjectTypeNames,
110
99
  ScalarTypeNames,
100
+ Component,
111
101
  Content,
112
102
  ContentConnection,
113
103
  ContentEdge,
114
104
  ContentType,
115
- Mixin,
105
+ FormInput,
116
106
  FormItem,
107
+ FormItemSet,
108
+ FormLayout,
109
+ FormOptionSet,
110
+ FormOptionSetOption,
111
+ FragmentComponentData,
117
112
  GeoPoint,
113
+ HeadlessCms,
118
114
  Icon,
115
+ Image,
116
+ ImageComponentData,
117
+ ImageSource,
118
+ ImageStyle,
119
+ ImageUrl,
120
+ LayoutComponentData,
121
+ Link,
122
+ Macro,
123
+ Media,
119
124
  media_Image,
120
125
  media_Image_Data,
121
126
  MediaFocalPoint,
122
127
  MediaUploader,
128
+ Mixin,
129
+ Mixin_base_ApplicationConfig,
130
+ Mixin_base_gpsInfo_DataConfig,
131
+ Mixin_media_ApplicationConfig,
132
+ Mixin_media_cameraInfo_DataConfig,
133
+ Mixin_media_imageInfo_DataConfig,
134
+ Occurrences,
135
+ PageComponentData,
123
136
  PageInfo,
137
+ PageUrl,
138
+ PartComponentData,
124
139
  Permissions,
125
140
  portal_Site,
126
141
  portal_Site_Data,
127
142
  PrincipalKey,
128
143
  PublishInfo,
129
- Mixin_base_ApplicationConfig,
130
- Mixin_base_gpsInfo_DataConfig,
131
- Mixin_media_ApplicationConfig,
132
- Mixin_media_cameraInfo_DataConfig,
133
- Mixin_media_imageInfo_DataConfig,
144
+ Query,
145
+ QueryDSLContentConnection,
146
+ RichText,
147
+ SiteConfigurator,
148
+ TextComponentData,
149
+ UntypedContent,
134
150
  } from './guillotine'
135
151
 
136
152
  export type {
@@ -145,7 +161,9 @@ export {
145
161
  InputTypeName,
146
162
  ObjectTypeName,
147
163
  ScalarTypeName,
164
+ ComponentType,
148
165
  FormItemType,
166
+ MediaIntentType,
149
167
  Permission,
150
168
  PrincipalType,
151
169
  } from './guillotine'
@@ -1,16 +1,15 @@
1
- import type {GraphQLArgs} from '../graphQL/InputTypes'
2
- import type {GraphQLObjectType} from '../graphQL/ObjectTypes'
1
+ import type {GraphQLInterfaceType} from '../graphQL/InterfaceTypes'
3
2
  import type {GraphQLInterfaceTypeReference} from '../graphQL/ReferenceTypes'
4
- import type {Fields} from './Field'
3
+ import type {Field} from './Field'
5
4
 
6
5
 
7
6
  export declare interface CreationCallback {
8
7
  (params: {
9
- addFields: (newFields: Fields) => void
10
- modifyFields: (existingFields: Fields) => void
8
+ addFields: (newFields: Record<string, Field>) => void
9
+ modifyFields: (existingFields: Record<string, Field>) => void
11
10
  removeFields: (existingFields: string[]) => void
12
11
  setDescription: (newDescription: string) => void
13
- setInterfaces: (reWrittenInterfaces: GraphQLInterfaceTypeReference[]) => void
12
+ setInterfaces: (reWrittenInterfaces: GraphQLInterfaceTypeReference<GraphQLInterfaceType>[]) => void
14
13
  }): void
15
14
  }
16
15
 
@@ -4,7 +4,7 @@ import type {GraphQLObjectTypeReference} from '../graphQL/ReferenceTypes'
4
4
  import type {GraphQLScalars} from '../graphQL/ScalarTypes'
5
5
 
6
6
 
7
- export declare interface Field {
7
+ export interface Field {
8
8
  args?: GraphQLArgs
9
9
  type:
10
10
  | GraphQLScalars
@@ -13,5 +13,3 @@ export declare interface Field {
13
13
  // | GraphQLEnumType doesn't make sense here?
14
14
  // | GraphQLInputType doesn't make sense here.
15
15
  }
16
-
17
- export declare type Fields = Record<string, Field>
@@ -8,19 +8,14 @@ import type {
8
8
  } from '../graphQL/'
9
9
 
10
10
 
11
- export declare type InputTypeField =
12
- | GraphQLEnumTypeReference<GraphQLEnumType>
13
- | GraphQLInputTypeReference<GraphQLInputType>
14
- | GraphQLScalars
15
-
16
- export declare type InputTypeFields = Record<
17
- string, // Could make a global InputTypeFieldsMap
18
- InputTypeField
19
- >
20
-
21
11
  export declare interface InputType {
22
12
  description?: string
23
- fields: InputTypeFields
13
+ fields: Record<
14
+ string, // Could make a global InputTypeFieldsMap
15
+ | GraphQLEnumTypeReference<GraphQLEnumType>
16
+ | GraphQLInputTypeReference<GraphQLInputType>
17
+ | GraphQLScalars
18
+ >
24
19
  }
25
20
 
26
21
  export declare type InputTypes = Record<GraphQLInputTypeName,InputType>
@@ -1,13 +1,13 @@
1
1
  import type {
2
2
  GraphQLInterfaceTypeName
3
3
  } from '../graphQL/InterfaceTypes'
4
- import type {Fields} from './Field'
4
+ import type {Field} from './Field'
5
5
 
6
6
 
7
7
  export declare type Interfaces = Record<
8
8
  GraphQLInterfaceTypeName,
9
9
  {
10
10
  description: string
11
- fields: Fields
11
+ fields: Record<string, Field>
12
12
  }
13
13
  >
@@ -1,16 +1,31 @@
1
- /// <reference path="./Global.Modifying.d.ts"/>
2
-
3
1
  import type {
4
2
  PartialRecord,
5
3
  ValueOf,
6
4
  } from '../Utils'
7
- import type {AnyResolver} from './Resolver'
5
+ import type {LocalContext} from '../graphQL/LocalContext'
6
+
7
+
8
+ export declare interface DataFetchingEnvironment<
9
+ Args extends Record<string, any> = Record<string, any>,
10
+ Source extends unknown = unknown,
11
+ > {
12
+ args: Args
13
+ localContext: LocalContext
14
+ source: Source
15
+ }
8
16
 
17
+ export declare interface Resolver<
18
+ Args extends Record<string, any> = Record<string, any>,
19
+ Source extends unknown = unknown,
20
+ Return = any
21
+ > {
22
+ (env: DataFetchingEnvironment<Args,Source>): Return
23
+ }
9
24
 
10
25
  export declare type Resolvers = PartialRecord<
11
26
  keyof GraphQLObjectTypeFieldsMap,
12
27
  Record<
13
28
  keyof ValueOf<GraphQLObjectTypeFieldsMap>,
14
- AnyResolver
29
+ Resolver
15
30
  >
16
31
  >
@@ -3,13 +3,13 @@ import type {
3
3
  GraphQLInterfaceTypeReference,
4
4
  GraphQLObjectType,
5
5
  } from '../graphQL'
6
- import type {Fields} from './Field'
6
+ import type {Field} from './Field'
7
7
 
8
8
 
9
9
  export declare interface Type {
10
10
  description: string
11
- fields: Fields
12
- interfaces: GraphQLInterfaceTypeReference<GraphQLInterfaceType>[]
11
+ fields: Record<string, Field>
12
+ interfaces?: GraphQLInterfaceTypeReference<GraphQLInterfaceType>[]
13
13
  }
14
14
 
15
15
  export declare type Types = Record<string, Type>
@@ -18,24 +18,16 @@ export type {
18
18
  Enums,
19
19
  } from './Enums'
20
20
 
21
- export type {
22
- Field,
23
- Fields,
24
- }
25
-
26
21
  export type {
27
22
  InputType,
28
- InputTypeField,
29
- InputTypeFields,
30
23
  InputTypes,
31
24
  } from './InputTypes'
32
25
 
33
- export type {DataFetchingEnvironment} from './DataFetchingEnvironment'
34
26
  export type {
35
- AnyResolver,
36
- Resolver
37
- } from './Resolver'
38
- export type {Resolvers} from './Resolvers'
27
+ DataFetchingEnvironment,
28
+ Resolver,
29
+ Resolvers,
30
+ } from './Resolvers'
39
31
 
40
32
  export type {
41
33
  Type,
@@ -1,54 +1,33 @@
1
- // Make sure ScriptValue type exists in global scope:
2
1
  /// <reference types="@enonic-types/global"/>
3
2
 
4
3
 
4
+ import type {ScriptValue} from '@enonic-types/core'
5
5
  import type {
6
6
  LocalContext,
7
7
  LocalContextRecord,
8
8
  } from './LocalContext'
9
9
 
10
10
 
11
- // https://developer.enonic.com/docs/guillotine/stable/extending/resolvers#createdatafetcherresult
12
- //
13
- // If parentLocalContext is not provided, then localContext will override
14
- // parentLocalContext.
15
- //
16
- // Otherwise, localContext will be merged with parentLocalContext and
17
- // localContext will override parentLocalContext if they have the same keys.
18
- //
19
- // If localContext is not provided, then parentLocalContext will be used as
20
- // localContext.
11
+ declare const __dataFetcherResult: unique symbol
21
12
 
22
13
 
23
14
  export declare interface CreateDataFetcherResultParams<
24
- DATA extends any,
25
- LOCAL_CONTEXT extends LocalContextRecord = LocalContext,
26
- PARENT_LOCAL_CONTEXT extends LocalContextRecord = LocalContext
15
+ In extends LocalContextRecord = LocalContextRecord,
16
+ Out extends LocalContextRecord = LocalContextRecord
27
17
  > {
28
- data: ScriptValue // NOTE: ScriptValue type is expected to exist in global scope
29
- localContext?: LocalContext<LOCAL_CONTEXT>
30
- parentLocalContext?: LocalContext<PARENT_LOCAL_CONTEXT>
18
+ // Objects and arrays must be wrapped with __.toScriptValue; primitives may be passed as is.
19
+ data: ScriptValue | string | number | boolean
20
+ localContext?: Out
21
+ parentLocalContext?: LocalContext<In>
31
22
  }
32
23
 
33
- // NOTE: Same as DataFetchingEnvironment without args.
34
- export interface DataFetcherResult<
35
- DATA extends any,
36
- LOCAL_CONTEXT extends LocalContextRecord = LocalContext
37
- > {
38
- // args, // Depends on the field resolver
39
- localContext: LocalContext<LOCAL_CONTEXT>
40
- source: DATA,
24
+ // Opaque value returned by createDataFetcherResult.
25
+ // Return it from a resolver as is; Guillotine unwraps data and localContext.
26
+ export declare interface DataFetcherResult {
27
+ readonly [__dataFetcherResult]: true
41
28
  }
42
29
 
43
30
  export declare type CreateDataFetcherResult = <
44
- DATA extends any,
45
- LOCAL_CONTEXT extends LocalContextRecord = LocalContext,
46
- PARENT_LOCAL_CONTEXT extends LocalContextRecord = LocalContext
47
- >(params: CreateDataFetcherResultParams<
48
- DATA,
49
- LOCAL_CONTEXT,
50
- PARENT_LOCAL_CONTEXT
51
- >) => DataFetcherResult<
52
- DATA,
53
- LocalContext<PARENT_LOCAL_CONTEXT & LOCAL_CONTEXT>
54
- >
31
+ In extends LocalContextRecord = LocalContextRecord,
32
+ Out extends LocalContextRecord = LocalContextRecord
33
+ >(params: CreateDataFetcherResultParams<In,Out>) => DataFetcherResult
@@ -1,19 +1,9 @@
1
1
  export declare type LocalContextRecord = Record<string,string|number|boolean|null>
2
2
 
3
-
4
- // The documentation:
5
- // https://developer.enonic.com/docs/guillotine/stable/extending/resolvers
6
- //
7
- // Says:
8
- // If parentLocalContext is not provided, then localContext will override
9
- // parentLocalContext.
10
- //
11
- // This means that is possible to remove branch, project and siteKey in some
12
- // parent createDataFetcherResult. Which is why the Partial<> is used.
13
3
  export declare type LocalContext<
14
4
  T extends LocalContextRecord = LocalContextRecord
15
- > = Partial<{
5
+ > = {
16
6
  branch: string
17
7
  project: string
18
8
  siteKey?: string
19
- }> & T
9
+ } & T
@@ -12,11 +12,7 @@ import type {
12
12
  PartialRecord,
13
13
  ValueOf,
14
14
  } from '../Utils'
15
- import type {
16
- CreateDataFetcherResult,
17
- CreateDataFetcherResultParams,
18
- DataFetcherResult,
19
- } from './CreateDataFetcherResult'
15
+ import type {CreateDataFetcherResult} from './CreateDataFetcherResult'
20
16
  import type {
21
17
  GraphQLEnumType,
22
18
  GraphQLEnumTypeName,
@@ -54,6 +50,7 @@ import type {
54
50
  export type {
55
51
  CreateDataFetcherResult,
56
52
  CreateDataFetcherResultParams,
53
+ DataFetcherResult,
57
54
  } from './CreateDataFetcherResult'
58
55
 
59
56
  export type {
@@ -1,7 +1,6 @@
1
1
  // This is a value, do not add declare.
2
2
  export enum EnumTypeName {
3
3
  ComponentType = 'ComponentType',
4
- ContentPathType = 'ContentPathType',
5
4
  DslGeoPointDistanceType = 'DslGeoPointDistanceType',
6
5
  DslOperatorType = 'DslOperatorType',
7
6
  DslSortDirectionType = 'DslSortDirectionType',
@@ -13,13 +12,22 @@ export enum EnumTypeName {
13
12
  MediaIntentType = 'MediaIntentType',
14
13
  Permission = 'Permission',
15
14
  PrincipalType = 'PrincipalType',
16
- UrlType = 'UrlType',
17
15
  }
18
16
 
19
17
  export declare type EnumTypeNames = keyof typeof EnumTypeName
20
18
 
21
19
  //──────────────────────────────────────────────────────────────────────────────
22
20
 
21
+ // This is a value, do not add declare.
22
+ export enum ComponentType {
23
+ page = 'page',
24
+ layout = 'layout',
25
+ image = 'image',
26
+ part = 'part',
27
+ text = 'text',
28
+ fragment = 'fragment',
29
+ }
30
+
23
31
  // This is a value, do not add declare.
24
32
  export enum FormItemType {
25
33
  ItemSet = 'ItemSet',
@@ -28,6 +36,12 @@ export enum FormItemType {
28
36
  OptionSet = 'OptionSet',
29
37
  }
30
38
 
39
+ // This is a value, do not add declare.
40
+ export enum MediaIntentType {
41
+ download = 'download',
42
+ inline = 'inline',
43
+ }
44
+
31
45
  // This is a value, do not add declare.
32
46
  export enum Permission {
33
47
  READ = 'READ',
@@ -10,29 +10,57 @@ export type {
10
10
  ObjectTypeNames,
11
11
  AccessControlEntry,
12
12
  Attachment,
13
+ AttachmentUrl,
14
+ Component,
13
15
  Content,
14
16
  ContentConnection,
15
17
  ContentEdge,
16
18
  ContentType,
17
- Mixin,
19
+ FormInput,
18
20
  FormItem,
21
+ FormItemSet,
22
+ FormLayout,
23
+ FormOptionSet,
24
+ FormOptionSetOption,
25
+ FragmentComponentData,
19
26
  GeoPoint,
27
+ HeadlessCms,
20
28
  Icon,
29
+ Image,
30
+ ImageComponentData,
31
+ ImageSource,
32
+ ImageStyle,
33
+ ImageUrl,
34
+ LayoutComponentData,
35
+ Link,
36
+ Macro,
37
+ Media,
21
38
  media_Image,
22
39
  media_Image_Data,
23
40
  MediaFocalPoint,
24
41
  MediaUploader,
42
+ Mixin,
43
+ Mixin_base_ApplicationConfig,
44
+ Mixin_base_gpsInfo_DataConfig,
45
+ Mixin_media_ApplicationConfig,
46
+ Mixin_media_cameraInfo_DataConfig,
47
+ Mixin_media_imageInfo_DataConfig,
48
+ Occurrences,
49
+ PageComponentData,
25
50
  PageInfo,
51
+ PageUrl,
52
+ PartComponentData,
26
53
  Permissions,
27
54
  portal_Site,
28
55
  portal_Site_Data,
29
56
  PrincipalKey,
30
57
  PublishInfo,
31
- Mixin_base_ApplicationConfig,
32
- Mixin_base_gpsInfo_DataConfig,
33
- Mixin_media_ApplicationConfig,
34
- Mixin_media_cameraInfo_DataConfig,
35
- Mixin_media_imageInfo_DataConfig,
58
+ Query,
59
+ QueryDSLContentConnection,
60
+ RichText,
61
+ SiteConfigurator,
62
+ TextComponentData,
63
+ UntypedContent,
36
64
  } from './objectTypes'
37
65
 
38
66
  export type {
@@ -42,8 +70,10 @@ export type {
42
70
 
43
71
 
44
72
  export {
73
+ ComponentType,
45
74
  EnumTypeName,
46
75
  FormItemType,
76
+ MediaIntentType,
47
77
  Permission,
48
78
  PrincipalType,
49
79
  } from './enumTypes'
@@ -2,30 +2,23 @@
2
2
  export enum InputTypeName {
3
3
  AggregationInput = 'AggregationInput',
4
4
  BooleanDSLExpressionInput = 'BooleanDSLExpressionInput',
5
- BooleanFilterInput = 'BooleanFilterInput',
6
5
  DSLExpressionValueInput = 'DSLExpressionValueInput',
7
6
  DateHistogramAggregationInput = 'DateHistogramAggregationInput',
8
7
  DateRangeAggregationInput = 'DateRangeAggregationInput',
9
8
  DateRangeInput = 'DateRangeInput',
10
9
  ExistsDSLExpressionInput = 'ExistsDSLExpressionInput',
11
- ExistsFilterInput = 'ExistsFilterInput',
12
- FilterInput = 'FilterInput',
13
- FormInput = 'FormInput',
14
10
  FulltextDSLExpressionInput = 'FulltextDSLExpressionInput',
15
11
  GeoDistanceAggregationInput = 'GeoDistanceAggregationInput',
16
12
  GeoPointInput = 'GeoPointInput',
17
13
  GeoPointSortDslInput = 'GeoPointSortDslInput',
18
- HasValueFilterInput = 'HasValueFilterInput',
19
14
  HighlightInputType = 'HighlightInputType',
20
15
  HighlightPropertiesInputType = 'HighlightPropertiesInputType',
21
- IdsFilterInput = 'IdsFilterInput',
22
16
  InDSLExpressionInput = 'InDSLExpressionInput',
23
17
  LikeDSLExpressionInput = 'LikeDSLExpressionInput',
24
18
  MatchAllDSLExpressionInput = 'MatchAllDSLExpressionInput',
25
19
  MaxAggregationInput = 'MaxAggregationInput',
26
20
  MinAggregationInput = 'MinAggregationInput',
27
21
  NgramDSLExpressionInput = 'NgramDSLExpressionInput',
28
- NotExistsFilterInput = 'NotExistsFilterInput',
29
22
  NumberRangeInput = 'NumberRangeInput',
30
23
  PathMatchDSLExpressionInput = 'PathMatchDSLExpressionInput',
31
24
  ProcessHtmlInput = 'ProcessHtmlInput',
@@ -4,7 +4,9 @@ import type {
4
4
  NonNull
5
5
  } from '../brand'
6
6
  import type {
7
+ ComponentType,
7
8
  FormItemType,
9
+ MediaIntentType,
8
10
  Permission,
9
11
  PrincipalType,
10
12
  } from './enumTypes'
@@ -28,6 +30,7 @@ import type {
28
30
  export enum ObjectTypeName {
29
31
  AccessControlEntry = 'AccessControlEntry',
30
32
  Attachment = 'Attachment',
33
+ AttachmentUrl = 'AttachmentUrl',
31
34
  base_Folder = 'base_Folder',
32
35
  base_Media = 'base_Media',
33
36
  base_Shortcut = 'base_Shortcut',
@@ -40,8 +43,7 @@ export enum ObjectTypeName {
40
43
  ContentConnection = 'ContentConnection',
41
44
  ContentEdge = 'ContentEdge',
42
45
  ContentType = 'ContentType',
43
- DefaultValue = 'DefaultValue',
44
- ExtraData = 'ExtraData',
46
+ FormInput = 'FormInput',
45
47
  FormItem = 'FormItem',
46
48
  FormItemSet = 'FormItemSet',
47
49
  FormLayout = 'FormLayout',
@@ -53,7 +55,9 @@ export enum ObjectTypeName {
53
55
  Icon = 'Icon',
54
56
  Image = 'Image',
55
57
  ImageComponentData = 'ImageComponentData',
58
+ ImageSource = 'ImageSource',
56
59
  ImageStyle = 'ImageStyle',
60
+ ImageUrl = 'ImageUrl',
57
61
  LayoutComponentData = 'LayoutComponentData',
58
62
  LayoutComponentDataConfig = 'LayoutComponentDataConfig',
59
63
  Link = 'Link',
@@ -64,6 +68,7 @@ export enum ObjectTypeName {
64
68
  Media = 'Media',
65
69
  MediaFocalPoint = 'MediaFocalPoint',
66
70
  MediaUploader = 'MediaUploader',
71
+ Mixin = 'Mixin',
67
72
  media_Archive = 'media_Archive',
68
73
  media_Archive_Data = 'media_Archive_Data',
69
74
  media_Audio = 'media_Audio',
@@ -97,6 +102,7 @@ export enum ObjectTypeName {
97
102
  PageComponentData = 'PageComponentData',
98
103
  PageComponentDataConfig = 'PageComponentDataConfig',
99
104
  PageInfo = 'PageInfo',
105
+ PageUrl = 'PageUrl',
100
106
  PartComponentData = 'PartComponentData',
101
107
  PartComponentDataConfig = 'PartComponentDataConfig',
102
108
  Permissions = 'Permissions',
@@ -108,18 +114,18 @@ export enum ObjectTypeName {
108
114
  portal_TemplateFolder = 'portal_TemplateFolder',
109
115
  PrincipalKey = 'PrincipalKey',
110
116
  PublishInfo = 'PublishInfo',
111
- QueryContentConnection = 'QueryContentConnection',
117
+ Query = 'Query',
112
118
  QueryDSLContentConnection = 'QueryDSLContentConnection',
113
119
  RichText = 'RichText',
114
120
  // RobotsTxt = 'RobotsTxt', // Not builtin?
115
121
  SiteConfigurator = 'SiteConfigurator',
116
122
  TextComponentData = 'TextComponentData',
117
123
  UntypedContent = 'UntypedContent',
118
- Mixin_base_ApplicationConfig = 'Mixin_base_ApplicationConfig',
119
- Mixin_base_gpsInfo_DataConfig = 'Mixin_base_gpsInfo_DataConfig',
120
- Mixin_media_ApplicationConfig = 'Mixin_media_ApplicationConfig',
121
- Mixin_media_cameraInfo_DataConfig = 'Mixin_media_cameraInfo_DataConfig',
122
- Mixin_media_imageInfo_DataConfig = 'Mixin_media_imageInfo_DataConfig',
124
+ Mixin_base_ApplicationConfig = 'Mixin_base_ApplicationConfig',
125
+ Mixin_base_gpsInfo_DataConfig = 'Mixin_base_gpsInfo_DataConfig',
126
+ Mixin_media_ApplicationConfig = 'Mixin_media_ApplicationConfig',
127
+ Mixin_media_cameraInfo_DataConfig = 'Mixin_media_cameraInfo_DataConfig',
128
+ Mixin_media_imageInfo_DataConfig = 'Mixin_media_imageInfo_DataConfig',
123
129
  }
124
130
 
125
131
  export declare type ObjectTypeNames = keyof typeof ObjectTypeName
@@ -137,7 +143,18 @@ export declare interface Attachment {
137
143
  label: GraphQLString
138
144
  size: GraphQLInt
139
145
  mimeType: GraphQLString
140
- attachmentUrl: GraphQLString
146
+ sha512: GraphQLString
147
+ attachmentUrl: AttachmentUrl
148
+ }
149
+
150
+ export declare interface AttachmentUrl {
151
+ path: GraphQLString
152
+ queryString: GraphQLString
153
+ context: GraphQLString
154
+ id: GraphQLString
155
+ fingerprint: GraphQLString
156
+ name: GraphQLString
157
+ intent: MediaIntentType
141
158
  }
142
159
 
143
160
  export declare type Content<
@@ -150,10 +167,12 @@ export declare type Content<
150
167
  _path: NonNull<GraphQLString>
151
168
  _references: Content[]
152
169
  _score: GraphQLFloat
170
+ _project: GraphQLString
171
+ _branch: GraphQLString
153
172
  attachments: Attachment[]
154
173
  children: Content[]
155
174
  childrenConnection: ContentConnection
156
- components: Content[]
175
+ components: Component[]
157
176
  contentType: ContentType
158
177
  createdTime: GraphQLDateTime
159
178
  creator: PrincipalKey
@@ -165,19 +184,30 @@ export declare type Content<
165
184
  owner: PrincipalKey
166
185
  pageAsJson: GraphQLJson
167
186
  pageTemplate: Content
168
- pageUrl: GraphQLString
187
+ pageUrl: PageUrl
169
188
  parent: Content
170
189
  permissions: Permissions
171
190
  publish: PublishInfo
172
191
  site: portal_Site
173
192
  type: GraphQLString
174
193
  valid: GraphQLBoolean
175
- x: Mixin
194
+ x: Mixin
176
195
  xAsJson: GraphQLJson
177
196
  } & Extensions,
178
197
  CoreContent
179
198
  >
180
199
 
200
+ export declare interface Component {
201
+ type: NonNull<ComponentType> // enum
202
+ path: NonNull<GraphQLString>
203
+ part: PartComponentData
204
+ page: PageComponentData
205
+ layout: LayoutComponentData
206
+ image: ImageComponentData
207
+ text: TextComponentData
208
+ fragment: FragmentComponentData
209
+ }
210
+
181
211
  export declare interface ContentConnection {
182
212
  totalCount: NonNull<GraphQLInt>
183
213
  edges?: ContentEdge[]
@@ -190,53 +220,168 @@ export declare interface ContentEdge {
190
220
  }
191
221
 
192
222
  export declare interface ContentType {
193
- name: GraphQLString
194
- title: GraphQLString
195
- titleI18nKey: GraphQLString
196
- displayName: GraphQLString
197
- description: GraphQLString
198
- descriptionI18nKey: GraphQLString
199
- superType: GraphQLString
200
- abstract: GraphQLBoolean
201
- final: GraphQLBoolean
202
- allowChildContent: GraphQLBoolean
223
+ name: GraphQLString
224
+ title: GraphQLString
225
+ titleI18nKey: GraphQLString
226
+ description: GraphQLString
227
+ descriptionI18nKey: GraphQLString
228
+ superType: GraphQLString
229
+ abstract: GraphQLBoolean
230
+ final: GraphQLBoolean
231
+ allowChildContent: GraphQLBoolean
203
232
  displayNameExpression: GraphQLString
204
233
  displayNameListExpression: GraphQLString
205
234
  displayNamePlaceholder: GraphQLString
206
235
  displayNamePlaceholderI18nKey: GraphQLString
207
- icon: Icon
208
- form: FormItem[]
209
- formAsJson: GraphQLJson
236
+ icon: Icon
237
+ form: FormItem[]
238
+ formAsJson: GraphQLJson
210
239
  }
211
240
 
212
241
  export declare interface Mixin {
213
- media: Mixin_media_ApplicationConfig
214
- base: Mixin_base_ApplicationConfig
242
+ media: Mixin_media_ApplicationConfig
243
+ base: Mixin_base_ApplicationConfig
244
+ }
245
+
246
+ export declare interface FormInput extends FormItem {
247
+ helpText: GraphQLString
248
+ inputType: GraphQLString
249
+ occurrences: Occurrences
250
+ configAsJson: GraphQLJson
215
251
  }
216
252
 
253
+ // Interface implemented by FormInput, FormItemSet, FormLayout and FormOptionSet.
217
254
  export declare interface FormItem {
218
255
  formItemType: FormItemType // enum
219
256
  name: GraphQLString
220
257
  label: GraphQLString
221
258
  }
222
259
 
260
+ export declare interface FormItemSet extends FormItem {
261
+ helpText: GraphQLString
262
+ occurrences: Occurrences
263
+ items: FormItem[]
264
+ }
265
+
266
+ export declare interface FormLayout extends FormItem {
267
+ items: FormItem[]
268
+ }
269
+
270
+ export declare interface FormOptionSet extends FormItem {
271
+ expanded: GraphQLBoolean
272
+ helpText: GraphQLString
273
+ occurrences: Occurrences
274
+ selection: Occurrences
275
+ options: FormOptionSetOption[]
276
+ }
277
+
278
+ export declare interface FormOptionSetOption {
279
+ name: GraphQLString
280
+ label: GraphQLString
281
+ helpText: GraphQLString
282
+ default: GraphQLBoolean
283
+ items: FormItem[]
284
+ }
285
+
286
+ export declare interface FragmentComponentData {
287
+ id: NonNull<GraphQLID>
288
+ fragment: Content
289
+ }
290
+
223
291
  export declare interface GeoPoint {
224
292
  value: GraphQLString
225
293
  latitude: GraphQLFloat
226
294
  longitude: GraphQLFloat
227
295
  }
228
296
 
297
+ // Type of the Query.guillotine field. Extensions may add fields via creationCallbacks.
298
+ export declare interface HeadlessCms {
299
+ get: Content
300
+ getChildren: Content[]
301
+ getChildrenConnection: ContentConnection
302
+ getPermissions: Permissions
303
+ getSite: portal_Site
304
+ queryDsl: Content[]
305
+ queryDslConnection: QueryDSLContentConnection
306
+ getType: ContentType
307
+ getTypes: ContentType[]
308
+ }
309
+
229
310
  export declare interface Icon {
230
311
  mimeType: GraphQLString
231
312
  modifiedTime: GraphQLString
232
313
  }
233
314
 
315
+ export declare interface Image {
316
+ image: Content
317
+ ref: GraphQLString
318
+ style: ImageStyle
319
+ src: ImageUrl
320
+ srcset: ImageSource[]
321
+ }
322
+
323
+ export declare interface ImageComponentData {
324
+ id: NonNull<GraphQLID>
325
+ caption: GraphQLString
326
+ image: media_Image
327
+ }
328
+
329
+ export declare interface ImageSource {
330
+ width: GraphQLInt
331
+ imageUrl: ImageUrl
332
+ }
333
+
334
+ export declare interface ImageStyle {
335
+ application: GraphQLString
336
+ name: GraphQLString
337
+ aspectRatio: GraphQLString
338
+ filter: GraphQLString
339
+ }
340
+
341
+ export declare interface ImageUrl {
342
+ path: GraphQLString
343
+ queryString: GraphQLString
344
+ context: GraphQLString
345
+ id: GraphQLString
346
+ fingerprint: GraphQLString
347
+ scale: GraphQLString
348
+ name: GraphQLString
349
+ }
350
+
351
+ export declare interface LayoutComponentData {
352
+ descriptor: NonNull<GraphQLString>
353
+ configAsJson: GraphQLJson
354
+ config: Record<string, unknown> // LayoutComponentDataConfig, generated from installed applications
355
+ }
356
+
357
+ export declare interface Link {
358
+ ref: GraphQLString
359
+ uri: GraphQLString
360
+ media: Media
361
+ content: Content
362
+ pageUrl: PageUrl
363
+ fragment: GraphQLString
364
+ }
365
+
366
+ export declare interface Macro {
367
+ ref: GraphQLString
368
+ name: GraphQLString
369
+ descriptor: GraphQLString
370
+ config: Record<string, unknown> // MacroConfig, generated from installed applications
371
+ }
372
+
373
+ export declare interface Media {
374
+ content: Content
375
+ intent: MediaIntentType // enum
376
+ mediaUrl: AttachmentUrl
377
+ }
378
+
234
379
  export declare type media_Image = BrandGraphQLObjectType<
235
380
  'media_Image',
236
381
  {
237
382
  data: media_Image_Data
238
- imageUrl: GraphQLString
239
- mediaUrl: GraphQLString
383
+ imageUrl: ImageUrl
384
+ mediaUrl: AttachmentUrl
240
385
  },
241
386
  MediaImageContent
242
387
  >
@@ -260,14 +405,38 @@ export declare interface MediaUploader {
260
405
  focalPoint: MediaFocalPoint
261
406
  }
262
407
 
408
+ export declare interface Occurrences {
409
+ maximum: GraphQLInt
410
+ minimum: GraphQLInt
411
+ }
412
+
413
+ export declare interface PageComponentData {
414
+ descriptor: GraphQLString
415
+ customized: GraphQLBoolean
416
+ template: Content
417
+ configAsJson: GraphQLJson
418
+ config: Record<string, unknown> // PageComponentDataConfig, generated from installed applications
419
+ }
420
+
263
421
  export declare interface PageInfo {
264
422
  startCursor: NonNull<GraphQLString>
265
423
  endCursor: NonNull<GraphQLString>
266
424
  hasNext: NonNull<GraphQLBoolean>
267
425
  }
268
426
 
427
+ export declare interface PageUrl {
428
+ baseUrl: GraphQLString
429
+ path: GraphQLString
430
+ queryString: GraphQLString
431
+ }
432
+
433
+ export declare interface PartComponentData {
434
+ descriptor: NonNull<GraphQLString>
435
+ configAsJson: GraphQLJson
436
+ config: Record<string, unknown> // PartComponentDataConfig, generated from installed applications
437
+ }
438
+
269
439
  export declare interface Permissions {
270
- inheritsPermissions: GraphQLBoolean
271
440
  permissions: AccessControlEntry[]
272
441
  }
273
442
 
@@ -291,24 +460,56 @@ export declare interface PrincipalKey {
291
460
  }
292
461
 
293
462
  export declare interface PublishInfo {
294
- from: GraphQLString
295
- to: GraphQLString
296
- first: GraphQLString
463
+ from: GraphQLDateTime
464
+ to: GraphQLDateTime
465
+ first: GraphQLDateTime
466
+ time: GraphQLDateTime
467
+ }
468
+
469
+ // Root query type. Extensions may add fields via creationCallbacks.
470
+ export declare interface Query {
471
+ guillotine: HeadlessCms
472
+ }
473
+
474
+ export declare interface QueryDSLContentConnection extends ContentConnection {
475
+ aggregationsAsJson: GraphQLJson
476
+ highlightAsJson: GraphQLJson
477
+ }
478
+
479
+ export declare interface RichText {
480
+ raw: GraphQLString
481
+ processedHtml: GraphQLString
482
+ macrosAsJson: GraphQLJson
483
+ macros: Macro[]
484
+ images: Image[]
485
+ links: Link[]
486
+ }
487
+
488
+ export declare interface SiteConfigurator {
489
+ applicationKey: GraphQLString
490
+ configAsJson: GraphQLJson
491
+ }
492
+
493
+ export declare interface TextComponentData {
494
+ value: NonNull<RichText>
297
495
  }
298
496
 
497
+ // Object type used for content whose content type is not part of the schema; same fields as Content.
498
+ export declare type UntypedContent = Content
499
+
299
500
  export declare interface Mixin_base_ApplicationConfig {
300
- gpsInfo: Mixin_base_gpsInfo_DataConfig
501
+ gpsInfo: Mixin_base_gpsInfo_DataConfig
301
502
  }
302
503
 
303
504
  export declare interface Mixin_base_gpsInfo_DataConfig {
304
- geoPoint: GeoPoint
305
- altitude: GraphQLString
306
- direction: GraphQLString
505
+ geoPoint: GeoPoint
506
+ altitude: GraphQLString
507
+ direction: GraphQLString
307
508
  }
308
509
 
309
510
  export declare interface Mixin_media_ApplicationConfig {
310
- imageInfo: Mixin_media_imageInfo_DataConfig
311
- cameraInfo: Mixin_media_cameraInfo_DataConfig
511
+ imageInfo: Mixin_media_imageInfo_DataConfig
512
+ cameraInfo: Mixin_media_cameraInfo_DataConfig
312
513
  }
313
514
 
314
515
  export declare interface Mixin_media_cameraInfo_DataConfig {
package/index.ts CHANGED
@@ -1,10 +1,10 @@
1
- // Make sure ScriptValue type exists in global scope:
2
1
  /// <reference types="@enonic-types/global"/>
3
2
 
4
- import type {CreateDataFetcherResult} from './graphQL/CreateDataFetcherResult'
5
- import type {AnyResolver} from './extensions/Resolver'
3
+ import type {ScriptValue} from '@enonic-types/core'
4
+
6
5
 
7
6
  declare const __name: unique symbol
7
+ declare const __dataFetcherResult: unique symbol
8
8
 
9
9
  declare type BrandGraphQLScalarType<
10
10
  GQL_SCALAR_TYPE_NAME extends string,
@@ -13,22 +13,6 @@ declare type BrandGraphQLScalarType<
13
13
  [__name]: GQL_SCALAR_TYPE_NAME
14
14
  }
15
15
 
16
-
17
- export type {
18
- CreateDataFetcherResult,
19
- CreateDataFetcherResultParams,
20
- DataFetcherResult,
21
- } from './graphQL/CreateDataFetcherResult'
22
-
23
- export type {
24
- LocalContext,
25
- LocalContextRecord,
26
- } from './graphQL/LocalContext'
27
-
28
- export type {DataFetchingEnvironment} from './extensions/DataFetchingEnvironment'
29
- export type {Resolver} from './extensions/Resolver'
30
-
31
-
32
16
  export declare type GraphQLBoolean = BrandGraphQLScalarType<'GraphQLBoolean', boolean>
33
17
  export declare type GraphQLDate = BrandGraphQLScalarType<'Date', string>
34
18
  export declare type GraphQLDateTime = BrandGraphQLScalarType<'DateTime', string>
@@ -42,6 +26,12 @@ export declare type GraphQLString = BrandGraphQLScalarType<'GraphQLString', stri
42
26
 
43
27
  export declare type GraphQLType = any
44
28
 
29
+ // Opaque value returned by GraphQL.createDataFetcherResult.
30
+ // Return it from a resolver as is; Guillotine unwraps data and localContext.
31
+ declare interface DataFetcherResult {
32
+ readonly [__dataFetcherResult]: true
33
+ }
34
+
45
35
  export declare interface GraphQL {
46
36
  Date: GraphQLDate
47
37
  DateTime: GraphQLDateTime
@@ -53,7 +43,12 @@ export declare interface GraphQL {
53
43
  Json: GraphQLJson
54
44
  LocalDateTime: GraphQLLocalDateTime
55
45
  LocalTime: GraphQLLocalTime
56
- createDataFetcherResult: CreateDataFetcherResult
46
+ createDataFetcherResult: (params: {
47
+ // Objects and arrays must be wrapped with __.toScriptValue; primitives may be passed as is.
48
+ data: ScriptValue | string | number | boolean
49
+ localContext?: LocalContextRecord
50
+ parentLocalContext?: LocalContext
51
+ }) => DataFetcherResult
57
52
  nonNull: (type: GraphQLType) => GraphQLType
58
53
  list: (type: GraphQLType) => GraphQLType[]
59
54
  reference: (typeName: string) => GraphQLType
@@ -61,81 +56,99 @@ export declare interface GraphQL {
61
56
 
62
57
  export declare type GraphQLArgs = Record<string, GraphQLType | GraphQLType[]>
63
58
 
64
- export declare interface Field {
65
- args?: GraphQLArgs
66
- type: GraphQLType | GraphQLType[]
67
- }
68
-
69
- export declare type Fields = Record<string, Field>
70
-
71
59
  export declare interface CreationCallback {
72
60
  (params: {
73
- addFields: (newFields: Fields) => void
74
- modifyFields: (existingFields: Fields) => void
61
+ addFields: (newFields: Record<string, {
62
+ args?: GraphQLArgs
63
+ type: GraphQLType | GraphQLType[]
64
+ }>) => void
65
+ modifyFields: (existingFields: Record<string, {
66
+ args?: GraphQLArgs
67
+ type: GraphQLType | GraphQLType[]
68
+ }>) => void
75
69
  removeFields: (existingFields: string[]) => void
76
70
  setDescription: (newDescription: string) => void
77
71
  setInterfaces: (reWrittenInterfaces: GraphQLType[]) => void
78
72
  }): void
79
73
  }
80
74
 
81
- export declare type CreationCallbacks = Record<string, CreationCallback>
82
-
83
75
  export declare interface Enum {
84
76
  description: string
85
77
  values: Record<string, string>
86
78
  }
87
79
 
88
- export declare type Enums = Record<string, Enum>
89
-
90
- export declare interface Type {
91
- description: string
92
- fields: Fields
80
+ export declare type LocalContextRecord = Record<string,string|number|boolean|null>
81
+
82
+ export declare type LocalContext<
83
+ T extends LocalContextRecord = LocalContextRecord
84
+ > = {
85
+ branch: string
86
+ project: string
87
+ siteKey?: string
88
+ } & T
89
+
90
+ export declare interface DataFetchingEnvironment<
91
+ Args extends Record<string, any> = Record<string, any>,
92
+ Source extends unknown = unknown,
93
+ > {
94
+ args: Args
95
+ localContext: LocalContext
96
+ source: Source
93
97
  }
94
98
 
95
- export declare type Types = Record<string, Type>
96
-
97
- export declare interface InputTypeField {
98
- type: GraphQLType | GraphQLType[]
99
+ export declare interface Resolver<
100
+ Args extends Record<string, any> = Record<string, any>,
101
+ Source extends unknown = unknown,
102
+ Return = any
103
+ > {
104
+ (env: DataFetchingEnvironment<Args,Source>): Return
99
105
  }
100
106
 
101
- export declare type InputTypeFields = Record<string, InputTypeField>
102
-
103
- export declare interface InputType {
104
- description?: string
105
- fields: InputTypeFields
106
- }
107
-
108
- export declare type InputTypes = Record<string, InputType>
109
-
110
- export declare interface Interface {
111
- description: string
112
- fields: Fields
113
- }
114
-
115
- export declare type Interfaces = Record<string, Interface>
116
-
117
- export declare interface Union {
118
- description: string
119
- types: GraphQLType[]
120
- }
121
-
122
- export declare type Unions = Record<string, Union>
123
-
124
107
  export declare interface Extensions {
125
- creationCallbacks?: CreationCallbacks
126
- enums?: Enums
127
- inputTypes?: InputTypes
128
- interfaces?: Interfaces
108
+ creationCallbacks?: Record<string, CreationCallback>
109
+ enums?: Record<
110
+ string,
111
+ Enum
112
+ >
113
+ inputTypes?: Record<
114
+ string,
115
+ {
116
+ description?: string
117
+ fields: Record<
118
+ string,
119
+ GraphQLType | GraphQLType[]
120
+ >
121
+ }
122
+ >
123
+ interfaces?: Record<string, {
124
+ description: string
125
+ fields: Record<string, {
126
+ args?: GraphQLArgs
127
+ type: GraphQLType | GraphQLType[]
128
+ }>
129
+ }>
130
+ // Resolvers may narrow Args and Source via DataFetchingEnvironment<Args, Source>,
131
+ // so the map must accept any resolver signature under strictFunctionTypes.
129
132
  resolvers?: Record<
130
133
  string,
131
134
  Record<
132
135
  string,
133
- AnyResolver
136
+ Resolver<any, any, any>
134
137
  >
135
138
  >
136
139
  typeResolvers?: Record<string, (param: any) => string>
137
- types?: Types
138
- unions?: Unions
140
+ types?: Record<string, {
141
+ description: string
142
+ fields: Record<string, {
143
+ args?: GraphQLArgs
144
+ type: GraphQLType | GraphQLType[]
145
+ }>
146
+ interfaces?: GraphQLType[]
147
+ }>
148
+ unions?: Record<string, {
149
+ description: string
150
+ types: GraphQLType[]
151
+ }>
139
152
  }
140
153
 
141
154
 
@@ -147,9 +160,11 @@ export type {
147
160
 
148
161
 
149
162
  export {
163
+ ComponentType,
150
164
  EnumTypeName,
151
165
  FormItemType,
152
166
  InputTypeName,
167
+ MediaIntentType,
153
168
  ObjectTypeName,
154
169
  Permission,
155
170
  PrincipalType,
package/package.json CHANGED
@@ -42,8 +42,8 @@
42
42
  },
43
43
  "scripts": {
44
44
  "check": "npx tsc --noEmit",
45
- "test": "tsd ./"
45
+ "test": "tsd ./ --files \"test-d/**/*.test-d.ts\""
46
46
  },
47
47
  "types": "index.ts",
48
- "version": "8.0.0"
48
+ "version": "9.0.0-B2"
49
49
  }
@@ -1,15 +0,0 @@
1
- import type {
2
- LocalContext,
3
- LocalContextRecord
4
- } from '../graphQL/LocalContext'
5
-
6
-
7
- export declare interface DataFetchingEnvironment<
8
- ARGS extends Record<string, any> = Record<string, any>,
9
- LOCAL_CONTEXT extends LocalContextRecord = LocalContextRecord,
10
- SOURCE = any,
11
- > {
12
- args: ARGS
13
- localContext: LocalContext<LOCAL_CONTEXT>
14
- source: SOURCE
15
- }
@@ -1,21 +0,0 @@
1
- import type {LocalContextRecord} from '../graphQL/LocalContext'
2
- import type {DataFetchingEnvironment} from './DataFetchingEnvironment'
3
-
4
-
5
- export declare interface AnyResolver<
6
- ARGS extends Record<string, any> = Record<string, any>,
7
- LOCAL_CONTEXT extends LocalContextRecord = any,
8
- SOURCE = any,
9
- RETURN_TYPE = any
10
- > {
11
- (env: DataFetchingEnvironment<ARGS,LOCAL_CONTEXT,SOURCE>): RETURN_TYPE
12
- }
13
-
14
- export declare interface Resolver<
15
- ARGS extends Record<string, any>,
16
- LOCAL_CONTEXT extends LocalContextRecord,
17
- SOURCE,
18
- RETURN_TYPE
19
- > {
20
- (env: DataFetchingEnvironment<ARGS,LOCAL_CONTEXT,SOURCE>): RETURN_TYPE
21
- }