diff --git a/build/api/binding.api.md b/build/api/binding.api.md index d11a82430c..f5655b1c4d 100644 --- a/build/api/binding.api.md +++ b/build/api/binding.api.md @@ -4,17 +4,20 @@ ```ts +import { ContentQueryBuilder } from '@contember/client'; import type { CrudQueryBuilder } from '@contember/client'; import { EmbeddedActionsParser } from 'chevrotain'; import { v4 as generateUuid } from 'uuid'; import { GraphQlBuilder } from '@contember/client'; -import type { GraphQlClient } from '@contember/client'; -import type { GraphQlClientFailedRequestMetadata } from '@contember/client'; +import { GraphQlClient } from '@contember/client'; +import { GraphQlClientError } from '@contember/client'; import type { GraphQlClientRequestOptions } from '@contember/client'; import { GraphQlLiteral } from '@contember/client'; import { Input } from '@contember/client'; +import { MutationResult } from '@contember/client'; import type { Result } from '@contember/client'; import { TokenType } from 'chevrotain'; +import { TransactionResult } from '@contember/client'; import type { TreeFilter } from '@contember/client'; // @public (undocumented) @@ -112,9 +115,12 @@ export class Config { setValue(name: Name, value: BindingConfig[Name]): this; } +// @public (undocumented) +export const createQueryBuilder: (schema: Schema) => ContentQueryBuilder; + // @public (undocumented) export class DataBinding { - constructor(contentApiClient: GraphQlClient, systemApiClient: GraphQlClient, tenantApiClient: GraphQlClient, treeStore: TreeStore, environment: Environment, createMarkerTree: (node: Node, environment: Environment) => MarkerTreeRoot, batchedUpdates: (callback: () => any) => void, onUpdate: (newData: TreeRootAccessor, binding: DataBinding) => void, onError: (error: RequestError, binding: DataBinding) => void, onPersistSuccess: (result: SuccessfulPersistResult, binding: DataBinding) => void, options: { + constructor(contentApiClient: GraphQlClient, systemApiClient: GraphQlClient, tenantApiClient: GraphQlClient, treeStore: TreeStore, environment: Environment, createMarkerTree: (node: Node, environment: Environment) => MarkerTreeRoot, batchedUpdates: (callback: () => any) => void, onUpdate: (newData: TreeRootAccessor, binding: DataBinding) => void, onError: (error: GraphQlClientError, binding: DataBinding) => void, onPersistSuccess: (result: SuccessfulPersistResult, binding: DataBinding) => void, options: { skipStateUpdateAfterPersist: boolean; }); // (undocumented) @@ -124,6 +130,9 @@ export class DataBinding { // @public (undocumented) export const DataBindingExtendAborted: unique symbol; +// @public (undocumented) +export type DataBindingTransactionResult = TransactionResult>>; + // @public (undocumented) export class DirtinessTracker { // (undocumented) @@ -706,10 +715,7 @@ export namespace ErrorAccessor { } // @public (undocumented) -export type ErrorPathNodeType = FieldPathErrorFragment | IndexPathErrorFragment; - -// @public (undocumented) -export type ErrorPersistResult = InvalidInputPersistResult | RequestError | InvalidResponseResult; +export type ErrorPersistResult = InvalidInputPersistResult | InvalidResponseResult; // Warning: (ae-forgotten-export) The symbol "GenericEventsMap" needs to be exported by the entry point index.d.ts // @@ -788,16 +794,6 @@ export class EventManager { triggerOnPersistSuccess(options: PersistSuccessOptions): Promise; } -// @public (undocumented) -export interface ExecutionError { - // (undocumented) - message: string | null; - // (undocumented) - path: MutationErrorPath; - // (undocumented) - type: Result.ExecutionErrorType; -} - // @public (undocumented) export type ExpectedEntityCount = 'upToOne' | 'possiblyMany'; @@ -931,14 +927,6 @@ export class FieldMarker { // @public (undocumented) export type FieldName = string; -// @public (undocumented) -export interface FieldPathErrorFragment { - // (undocumented) - __typename: '_FieldPathFragment'; - // (undocumented) - field: string; -} - // @public (undocumented) export type FieldValue = JsonValue; @@ -956,19 +944,6 @@ export type GetEntityListSubTree = (parametersOrAlias: Alias | SugaredQualifiedE // @public (undocumented) export type GetEntitySubTree = (parametersOrAlias: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity, treeId?: TreeRootId, environment?: Environment) => EntityAccessor; -// @public (undocumented) -export interface GqlError { - // (undocumented) - errors: { - message: string; - path?: string[]; - }[]; - // (undocumented) - query: string; - // (undocumented) - type: 'gqlError'; -} - // @public (undocumented) export interface HasManyRelation extends Relation, EntityListParameters, EntityListEventListeners { } @@ -1009,16 +984,6 @@ export class HasOneRelationMarker { readonly placeholderName: string; } -// @public (undocumented) -export interface IndexPathErrorFragment { - // (undocumented) - __typename: '_IndexPathFragment'; - // (undocumented) - alias: string | null; - // (undocumented) - index: number; -} - // @public (undocumented) export interface InvalidInputPersistResult { // (undocumented) @@ -1154,64 +1119,6 @@ export class MarkerTreeRoot { // @public (undocumented) export type MeaningfulMarker = FieldMarker | HasOneRelationMarker | HasManyRelationMarker | EntityListSubTreeMarker | EntitySubTreeMarker; -// @public (undocumented) -export const metadataToRequestError: (metadata: GraphQlClientFailedRequestMetadata) => RequestError; - -// @public (undocumented) -export interface MutationDataResponse { - // (undocumented) - [alias: string]: MutationResponse; -} - -// @public (undocumented) -export type MutationErrorPath = ErrorPathNodeType[]; - -// @public (undocumented) -export interface MutationRequestResponse { - // (undocumented) - data: MutationTransactionResponse | null; - // (undocumented) - errors?: { - message: string; - path?: string[]; - }[]; -} - -// @public (undocumented) -export interface MutationResponse { - // (undocumented) - errorMessage: string | null; - // (undocumented) - errors: ExecutionError[]; - // (undocumented) - node: ReceivedEntityData; - // (undocumented) - ok: boolean; - // (undocumented) - validation: { - valid: boolean; - errors: ValidationError[]; - } | undefined; -} - -// @public (undocumented) -export interface MutationTransactionResponse { - // (undocumented) - transaction: (MutationDataResponse & { - __typename: 'MutationTransaction'; - ok: boolean; - errorMessage: string | null; - }); -} - -// @public (undocumented) -export interface NetworkErrorRequestError { - // (undocumented) - metadata: GraphQlClientFailedRequestMetadata; - // (undocumented) - type: 'networkError'; -} - // @public (undocumented) export const NIL_UUID = "00000000-0000-0000-0000-000000000000"; @@ -1538,9 +1445,6 @@ export type RelativeSingleField = AnyField & LeafField & { // @public (undocumented) export type RemovalType = 'disconnect' | 'delete'; -// @public (undocumented) -export type RequestError = UnauthorizedRequestError | NetworkErrorRequestError | GqlError | UnknownErrorRequestError; - // @public (undocumented) export type RuntimeId = ServerId | ClientGeneratedUuid | UnpersistedEntityDummyId; @@ -2055,12 +1959,6 @@ export class TreeStore { // @public (undocumented) export const TYPENAME_KEY_NAME = "__typename"; -// @public (undocumented) -export interface UnauthorizedRequestError { - // (undocumented) - type: 'unauthorized'; -} - // @public (undocumented) export interface UnconstrainedQualifiedEntityList extends QualifiedEntityParameters, EntityCreationParameters, EntityListEventListeners, EntityListPreferences { // (undocumented) @@ -2089,12 +1987,6 @@ export type UniqueEntityId = string & { // @public (undocumented) export type UniqueWhere = Input.UniqueWhere; -// @public (undocumented) -export interface UnknownErrorRequestError { - // (undocumented) - type: 'unknownError'; -} - // @public (undocumented) export class UnpersistedEntityDummyId implements RuntimeIdSpec { constructor(); @@ -2229,16 +2121,6 @@ export interface UnsugarableUnconstrainedQualifiedSingleEntity extends Unsugarab isUnpersisted?: boolean; } -// @public (undocumented) -export interface ValidationError { - // (undocumented) - message: { - text: string; - }; - // (undocumented) - path: MutationErrorPath; -} - // @public (undocumented) export class VariableFieldValue { constructor(variableName: string); diff --git a/build/api/client-content-generator.api.md b/build/api/client-content-generator.api.md new file mode 100644 index 0000000000..b28564f613 --- /dev/null +++ b/build/api/client-content-generator.api.md @@ -0,0 +1,37 @@ +## API Report File for "@contember/client-content-generator" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { Model } from '@contember/schema'; +import { SchemaNames } from '@contember/client-content'; + +// @public (undocumented) +export class ContemberClientGenerator { + constructor(nameSchemaGenerator?: NameSchemaGenerator, enumTypeSchemaGenerator?: EnumTypeSchemaGenerator, entityTypeSchemaGenerator?: EntityTypeSchemaGenerator); + // (undocumented) + generate(model: Model.Schema): Record; +} + +// @public (undocumented) +export class EntityTypeSchemaGenerator { + // (undocumented) + generate(model: Model.Schema): string; +} + +// @public (undocumented) +export class EnumTypeSchemaGenerator { + // (undocumented) + generate(model: Model.Schema): string; +} + +// @public (undocumented) +export class NameSchemaGenerator { + // (undocumented) + generate(model: Model.Schema): SchemaNames; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/build/api/client-content.api.md b/build/api/client-content.api.md new file mode 100644 index 0000000000..f81165f75c --- /dev/null +++ b/build/api/client-content.api.md @@ -0,0 +1,523 @@ +## API Report File for "@contember/client-content" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { GraphQlClientRequestOptions } from '@contember/graphql-client'; +import { GraphQlFieldTypedArgs } from '@contember/graphql-builder'; +import { GraphQlSelectionSet } from '@contember/graphql-builder'; +import { Input } from '@contember/schema'; +import { JSONObject } from '@contember/schema'; +import { Result } from '@contember/schema'; + +// @public (undocumented) +export class ContentClient { + constructor(executor: QueryExecutor); + // (undocumented) + mutate(mutation: ContentMutation, options?: QueryExecutorOptions): Promise; + // (undocumented) + mutate(mutations: ContentMutation[], options?: QueryExecutorOptions): Promise; + // (undocumented) + mutate>(mutations: { + [K in keyof Values]: ContentMutation | ContentQuery; + }, options?: QueryExecutorOptions): Promise; + // (undocumented) + query(query: ContentQuery, options?: QueryExecutorOptions): Promise; + // (undocumented) + query>(queries: { + [K in keyof Values]: ContentQuery; + }, options?: QueryExecutorOptions): Promise; +} + +// @public (undocumented) +export namespace ContentClientInput { + // (undocumented) + export type AnyListQueryInput = Omit & { + readonly orderBy?: AnyOrderBy; + }; + // (undocumented) + export type AnyOrderBy = Input.OrderBy<`${Input.OrderDirection}`>[]; + // (undocumented) + export type ConnectOrCreateInput = { + readonly connect: UniqueWhere; + readonly create: CreateDataInput; + }; + // (undocumented) + export type ConnectOrCreateRelationInput = { + readonly connectOrCreate: ConnectOrCreateInput; + }; + // (undocumented) + export type ConnectRelationInput = { + readonly connect: UniqueWhere; + }; + // (undocumented) + export type CreateDataInput = { + readonly [key in keyof TEntity['columns']]?: TEntity['columns'][key]['tsType']; + } & { + readonly [key in keyof TEntity['hasMany']]?: CreateManyRelationInput; + } & { + readonly [key in keyof TEntity['hasOne']]?: CreateOneRelationInput; + }; + // (undocumented) + export type CreateInput = { + readonly data: CreateDataInput; + }; + // (undocumented) + export type CreateManyRelationInput = readonly CreateOneRelationInput[]; + // (undocumented) + export type CreateOneRelationInput = ConnectRelationInput | CreateRelationInput | ConnectOrCreateRelationInput; + // (undocumented) + export type CreateRelationInput = { + readonly create: CreateDataInput; + }; + // (undocumented) + export type DeleteInput = { + readonly by: UniqueWhere; + readonly filter?: Where; + }; + // (undocumented) + export type DeleteRelationInput = { + readonly delete: true; + }; + // (undocumented) + export type DeleteSpecifiedRelationInput = { + readonly delete: UniqueWhere; + }; + // (undocumented) + export type DisconnectRelationInput = { + readonly disconnect: true; + }; + // (undocumented) + export type DisconnectSpecifiedRelationInput = { + readonly disconnect: UniqueWhere; + }; + // (undocumented) + export type FieldOrderBy = { + readonly [key in keyof TEntity['columns']]?: `${Input.OrderDirection}` | null; + } & { + readonly [key in keyof TEntity['hasMany']]?: FieldOrderBy | null; + } & { + readonly [key in keyof TEntity['hasOne']]?: FieldOrderBy | null; + }; + // (undocumented) + export type HasManyByRelationInput = { + readonly by: TUnique; + readonly filter?: Where; + }; + // (undocumented) + export type HasManyRelationInput = ListQueryInput; + // (undocumented) + export type HasManyRelationPaginateInput = PaginationQueryInput; + // (undocumented) + export type HasOneRelationInput = { + readonly filter?: Where; + }; + // (undocumented) + export type ListQueryInput = { + readonly filter?: Where; + readonly orderBy?: readonly OrderBy[]; + readonly offset?: number; + readonly limit?: number; + }; + // (undocumented) + export type OrderBy = { + readonly _random?: boolean; + readonly _randomSeeded?: number; + } & FieldOrderBy; + // (undocumented) + export type PaginationQueryInput = { + readonly filter?: Where; + readonly orderBy?: readonly OrderBy[]; + readonly skip?: number; + readonly first?: number; + }; + // (undocumented) + export type UniqueQueryInput = { + readonly by: UniqueWhere; + readonly filter?: Where; + }; + // (undocumented) + export type UniqueWhere = TEntity['unique']; + // (undocumented) + export type UpdateDataInput = { + readonly [key in keyof TEntity['columns']]?: TEntity['columns'][key]['tsType']; + } & { + readonly [key in keyof TEntity['hasMany']]?: UpdateManyRelationInput; + } & { + readonly [key in keyof TEntity['hasOne']]?: UpdateOneRelationInput; + }; + // (undocumented) + export type UpdateInput = { + readonly by: UniqueWhere; + readonly filter?: Where; + readonly data: UpdateDataInput; + }; + // (undocumented) + export type UpdateManyRelationInput = Array>; + // (undocumented) + export type UpdateManyRelationInputItem = CreateRelationInput | ConnectRelationInput | ConnectOrCreateRelationInput | DeleteSpecifiedRelationInput | DisconnectSpecifiedRelationInput | UpdateSpecifiedRelationInput | UpsertSpecifiedRelationInput; + // (undocumented) + export type UpdateOneRelationInput = CreateRelationInput | ConnectRelationInput | ConnectOrCreateRelationInput | DeleteRelationInput | DisconnectRelationInput | UpdateRelationInput | UpsertRelationInput; + // (undocumented) + export type UpdateRelationInput = { + readonly update: UpdateDataInput; + }; + // (undocumented) + export type UpdateSpecifiedRelationInput = { + readonly update: { + readonly by: UniqueWhere; + readonly data: UpdateDataInput; + }; + }; + // (undocumented) + export type UpsertInput = { + readonly by: UniqueWhere; + readonly filter?: Where; + readonly update: UpdateDataInput; + readonly create: CreateDataInput; + }; + // (undocumented) + export type UpsertRelationInput = { + readonly upsert: { + readonly update: UpdateDataInput; + readonly create: CreateDataInput; + }; + }; + // (undocumented) + export type UpsertSpecifiedRelationInput = { + readonly upsert: { + readonly by: UniqueWhere; + readonly update: UpdateDataInput; + readonly create: CreateDataInput; + }; + }; + // (undocumented) + export type Where = { + readonly and?: (readonly (Where)[]) | null; + readonly or?: (readonly (Where)[]) | null; + readonly not?: Where | null; + } & { + readonly [key in keyof TEntity['columns']]?: Input.Condition | null; + } & { + readonly [key in keyof TEntity['hasMany']]?: Where | null; + } & { + readonly [key in keyof TEntity['hasOne']]?: Where | null; + }; +} + +// @public (undocumented) +export class ContentEntitySelection { + // (undocumented) + $$(): ContentEntitySelection; + // (undocumented) + $(field: string, args?: EntitySelectionColumnArgs): ContentEntitySelection; + // (undocumented) + $(field: string, args: EntitySelectionManyArgs, selection: ContentEntitySelectionOrCallback): ContentEntitySelection; + // (undocumented) + $(field: string, args: EntitySelectionManyByArgs, selection: ContentEntitySelectionOrCallback): ContentEntitySelection; + // (undocumented) + $(field: string, args: EntitySelectionOneArgs, selection: ContentEntitySelectionOrCallback): ContentEntitySelection; + // (undocumented) + $(field: string, selection: ContentEntitySelectionOrCallback): ContentEntitySelection; + // @internal + constructor( + context: ContentEntitySelectionContext, + selectionSet: GraphQlSelectionSet); + // @internal (undocumented) + readonly context: ContentEntitySelectionContext; + // @internal (undocumented) + readonly selectionSet: GraphQlSelectionSet; +} + +// @public (undocumented) +export type ContentEntitySelectionCallback = (select: ContentEntitySelection) => ContentEntitySelection; + +// @internal (undocumented) +export type ContentEntitySelectionContext = { + entity: SchemaEntityNames; + schema: SchemaNames; +}; + +// @public (undocumented) +export type ContentEntitySelectionOrCallback = ContentEntitySelectionCallback | ContentEntitySelection; + +// @public (undocumented) +export type ContentMutation = ContentOperation; + +// @public (undocumented) +export class ContentOperation { + // @internal + constructor( + type: TType, + fieldName: string, + args?: GraphQlFieldTypedArgs, + selection?: GraphQlSelectionSet | undefined, + parse?: (value: any) => TValue); + // @internal (undocumented) + readonly args: GraphQlFieldTypedArgs; + // @internal (undocumented) + readonly fieldName: string; + // @internal (undocumented) + readonly parse: (value: any) => TValue; + // @internal (undocumented) + readonly selection?: GraphQlSelectionSet | undefined; + // @internal (undocumented) + readonly type: TType; +} + +// @public (undocumented) +export type ContentQuery = ContentOperation; + +// @public (undocumented) +export class ContentQueryBuilder { + constructor(schema: SchemaNames); + // (undocumented) + count(name: string, args: Pick): ContentQuery; + // (undocumented) + create(name: string, args: Input.CreateInput, fields?: EntitySelectionOrCallback): ContentMutation; + // (undocumented) + delete(name: string, args: Input.UniqueQueryInput, fields?: EntitySelectionOrCallback): ContentMutation; + // (undocumented) + fragment(name: string, fieldsCallback?: ContentEntitySelectionCallback): ContentEntitySelection; + // (undocumented) + get(name: string, args: Input.UniqueQueryInput, fields: EntitySelectionOrCallback): ContentQuery | null>; + // (undocumented) + list(name: string, args: ContentClientInput.AnyListQueryInput, fields: EntitySelectionOrCallback): ContentQuery; + // (undocumented) + transaction(input: Record | ContentQuery> | ContentMutation | ContentMutation[], options?: MutationTransactionOptions): ContentMutation>; + // (undocumented) + update(name: string, args: Input.UpdateInput, fields?: EntitySelectionOrCallback): ContentMutation; + // (undocumented) + upsert(name: string, args: Input.UpsertInput, fields?: EntitySelectionOrCallback): ContentMutation; +} + +// @public (undocumented) +export type EntitySelectionAnyArgs = EntitySelectionColumnArgs | EntitySelectionManyArgs | EntitySelectionManyByArgs | EntitySelectionOneArgs; + +// @public (undocumented) +export type EntitySelectionColumnArgs = EntitySelectionCommonInput; + +// @public (undocumented) +export type EntitySelectionCommonInput = { + as?: Alias; +}; + +// @public (undocumented) +export type EntitySelectionManyArgs = ContentClientInput.AnyListQueryInput & EntitySelectionCommonInput; + +// @public (undocumented) +export type EntitySelectionManyByArgs = { + by: Input.UniqueWhere; + filter?: Input.Where; +} & EntitySelectionCommonInput; + +// @public (undocumented) +export type EntitySelectionOneArgs = { + filter?: Input.Where; +} & EntitySelectionCommonInput; + +// @public (undocumented) +export type EntitySelectionOrCallback = ContentEntitySelection | ContentEntitySelectionCallback; + +// @public (undocumented) +export type EntityTypeLike = { + name: string; + unique: JSONObject; + columns: { + [columnName: string]: any; + }; + hasOne: { + [relationName: string]: EntityTypeLike; + }; + hasMany: { + [relationName: string]: EntityTypeLike; + }; + hasManyBy: { + [relationName: string]: { + entity: EntityTypeLike; + by: JSONObject; + }; + }; +}; + +// @public (undocumented) +export type FieldPath = { + readonly field: string; +}; + +// @public (undocumented) +export type IndexPath = { + readonly index: number; + readonly alias: string | null; +}; + +// @public (undocumented) +export type MutationError = { + readonly paths: Path[]; + readonly message: string; + readonly type: Result.ExecutionErrorType; +}; + +// @public (undocumented) +export type MutationResult = { + readonly ok: boolean; + readonly errorMessage: string | null; + readonly errors: MutationError[]; + readonly node: Value | null; + readonly validation?: ValidationResult; +}; + +// @public (undocumented) +export type MutationTransactionOptions = { + deferForeignKeyConstraints?: boolean; + deferUniqueConstraints?: boolean; +}; + +// @public (undocumented) +export type Path = Array; + +// @public (undocumented) +export type QueryExecutor = (query: string, options: GraphQlClientRequestOptions) => Promise; + +// @public (undocumented) +export type QueryExecutorOptions = GraphQlClientRequestOptions; + +// @public (undocumented) +export type SchemaEntityNames = { + readonly name: Name; + readonly scalars: string[]; + readonly fields: { + readonly [fieldName: string]: { + readonly type: 'column'; + } | { + readonly type: 'many' | 'one'; + readonly entity: string; + }; + }; +}; + +// @public (undocumented) +export type SchemaNames = { + entities: { + [entityName: string]: SchemaEntityNames; + }; +}; + +// @public (undocumented) +export type SchemaTypeLike = { + entities: { + [entityName: string]: EntityTypeLike; + }; +}; + +// @public (undocumented) +export type TransactionResult = { + readonly ok: boolean; + readonly errorMessage: string | null; + readonly errors: MutationError[]; + readonly validation: ValidationResult; + readonly data: V; +}; + +// @public (undocumented) +export type TypedContentEntitySelectionOrCallback = TypedEntitySelection | TypedEntitySelectionCallback; + +// @public (undocumented) +export interface TypedContentQueryBuilder { + // (undocumented) + count(name: EntityName, args: Pick, 'filter'>): ContentQuery; + // (undocumented) + create(name: EntityName, args: ContentClientInput.CreateInput, fields?: TypedContentEntitySelectionOrCallback): ContentMutation>; + // (undocumented) + delete(name: EntityName, args: ContentClientInput.UniqueQueryInput, fields?: TypedContentEntitySelectionOrCallback): ContentMutation>; + // (undocumented) + fragment(name: EntityName): TypedEntitySelection; + // (undocumented) + fragment(name: EntityName, fieldsCallback: TypedEntitySelectionCallback): TypedEntitySelection; + // (undocumented) + get(name: EntityName, args: ContentClientInput.UniqueQueryInput, fields: TypedContentEntitySelectionOrCallback): ContentQuery; + // (undocumented) + list(name: EntityName, args: ContentClientInput.ListQueryInput, fields: TypedContentEntitySelectionOrCallback): ContentQuery; + // (undocumented) + transaction(mutation: ContentMutation, options?: MutationTransactionOptions): ContentMutation>; + // (undocumented) + transaction(mutations: ContentMutation[], options?: MutationTransactionOptions): ContentMutation>; + // (undocumented) + transaction>(mutations: { + [K in keyof Values]: ContentMutation | ContentQuery; + }, options?: MutationTransactionOptions): ContentMutation>; + // (undocumented) + update(name: EntityName, args: ContentClientInput.UpdateInput, fields?: TypedContentEntitySelectionOrCallback): ContentMutation>; + // (undocumented) + upsert(name: EntityName, args: ContentClientInput.UpsertInput, fields?: TypedContentEntitySelectionOrCallback): ContentMutation>; +} + +// @public (undocumented) +export interface TypedEntitySelection { + // (undocumented) + $$(): TypedEntitySelection; + // (undocumented) + $(name: TKey, args?: { + as?: TAlias; + }): TypedEntitySelection; + // (undocumented) + $(name: TNestedKey, args: ContentClientInput.HasManyRelationInput & { + as?: TAlias; + }, fields: TypedEntitySelectionCallback | TypedEntitySelection): TypedEntitySelection; + // (undocumented) + $(name: TNestedKey, fields: TypedEntitySelectionCallback | TypedEntitySelection): TypedEntitySelection; + // (undocumented) + $(name: TNestedKey, args: ContentClientInput.HasManyByRelationInput & { + as?: TAlias; + }, fields: TypedEntitySelectionCallback | TypedEntitySelection): TypedEntitySelection; + // (undocumented) + $(name: TNestedKey, fields: TypedEntitySelectionCallback | TypedEntitySelection): TypedEntitySelection; + // (undocumented) + $(name: TNestedKey, args: ContentClientInput.HasOneRelationInput & { + as?: TAlias; + }, fields: TypedEntitySelectionCallback | TypedEntitySelection): TypedEntitySelection; + // (undocumented) + $(name: TNestedKey, fields: TypedEntitySelectionCallback | TypedEntitySelection): TypedEntitySelection; +} + +// @public (undocumented) +export type TypedEntitySelectionCallback = (select: TypedEntitySelection) => TypedEntitySelection; + +// @public (undocumented) +export type ValidationError = { + readonly path: Path; + readonly message: { + text: string; + }; +}; + +// @public (undocumented) +export type ValidationResult = { + readonly valid: boolean; + readonly errors: ValidationError[]; +}; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/build/api/client-generator.api.md b/build/api/client-generator.api.md new file mode 100644 index 0000000000..f9fc3082c8 --- /dev/null +++ b/build/api/client-generator.api.md @@ -0,0 +1,37 @@ +## API Report File for "@contember/client-generator" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { Model } from '@contember/schema'; +import { SchemaNames } from '@contember/client'; + +// @public (undocumented) +export class ContemberClientGenerator { + constructor(nameSchemaGenerator?: NameSchemaGenerator, enumTypeSchemaGenerator?: EnumTypeSchemaGenerator, entityTypeSchemaGenerator?: EntityTypeSchemaGenerator); + // (undocumented) + generate(model: Model.Schema): Record; +} + +// @public (undocumented) +export class EntityTypeSchemaGenerator { + // (undocumented) + generate(model: Model.Schema): string; +} + +// @public (undocumented) +export class EnumTypeSchemaGenerator { + // (undocumented) + generate(model: Model.Schema): string; +} + +// @public (undocumented) +export class NameSchemaGenerator { + // (undocumented) + generate(model: Model.Schema): SchemaNames; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/build/api/client.api.md b/build/api/client.api.md index a8e3b9897f..fdfa17dc65 100644 --- a/build/api/client.api.md +++ b/build/api/client.api.md @@ -4,6 +4,13 @@ ```ts +import { GraphQlClient as GraphQlClient_2 } from '@contember/graphql-client'; +import { GraphQlClientError } from '@contember/graphql-client'; +import { GraphQlClientRequestOptions as GraphQlClientRequestOptions_2 } from '@contember/graphql-client'; +import { GraphQlClientVariables } from '@contember/graphql-client'; +import { GraphQlErrorRequest } from '@contember/graphql-client'; +import { GraphQlErrorType } from '@contember/graphql-client'; +import { GraphQlPrintResult } from '@contember/graphql-builder'; import { Input } from '@contember/schema'; import { Result } from '@contember/schema'; import { Value } from '@contember/schema'; @@ -11,53 +18,10 @@ import { Writable } from '@contember/schema'; // @public (undocumented) export namespace CrudQueryBuilder { - import CrudQueryBuilder = CrudQueryBuilderTmp.CrudQueryBuilder; - import ReadBuilder = CrudQueryBuilderTmp.ReadBuilder; - import WriteBuilder = CrudQueryBuilderTmp.WriteBuilder; - import WriteDataBuilder = CrudQueryBuilderTmp.WriteDataBuilder; - import WriteManyRelationBuilder = CrudQueryBuilderTmp.WriteManyRelationBuilder; - import WriteOneRelationBuilder = CrudQueryBuilderTmp.WriteOneRelationBuilder; - import WriteOperation = CrudQueryBuilderTmp.WriteOperation; // Warning: (ae-forgotten-export) The symbol "CrudQueryBuilderTmp" needs to be exported by the entry point index.d.ts // // (undocumented) - export type CreateMutationArguments = CrudQueryBuilderTmp.CreateMutationArguments; - // (undocumented) - export type CreateMutationFields = CrudQueryBuilderTmp.CreateMutationFields; - // (undocumented) - export type DeleteMutationArguments = CrudQueryBuilderTmp.DeleteMutationArguments; - // (undocumented) - export type DeleteMutationFields = CrudQueryBuilderTmp.DeleteMutationFields; - // (undocumented) - export type GetQueryArguments = CrudQueryBuilderTmp.GetQueryArguments; - // (undocumented) - export type HasManyArguments = CrudQueryBuilderTmp.HasManyArguments; - // (undocumented) - export type HasOneArguments = CrudQueryBuilderTmp.HasOneArguments; - // (undocumented) - export type ListQueryArguments = CrudQueryBuilderTmp.ListQueryArguments; - // (undocumented) - export type Mutations = CrudQueryBuilderTmp.Mutations; - // (undocumented) export type OrderDirection = CrudQueryBuilderTmp.OrderDirection; - // (undocumented) - export type PaginateQueryArguments = CrudQueryBuilderTmp.PaginateQueryArguments; - // (undocumented) - export type Queries = CrudQueryBuilderTmp.Queries; - // (undocumented) - export type ReadArguments = CrudQueryBuilderTmp.ReadArguments; - // (undocumented) - export type ReductionArguments = CrudQueryBuilderTmp.ReductionArguments; - // (undocumented) - export type UpdateMutationArguments = CrudQueryBuilderTmp.UpdateMutationArguments; - // (undocumented) - export type UpdateMutationFields = CrudQueryBuilderTmp.UpdateMutationFields; - // (undocumented) - export type WriteArguments = CrudQueryBuilderTmp.WriteArguments; - // (undocumented) - export type WriteFields = CrudQueryBuilderTmp.WriteFields; - // (undocumented) - export type WriteRelationOps = CrudQueryBuilderTmp.WriteRelationOps; } // @public (undocumented) @@ -109,33 +73,25 @@ export const formatSystemApiRelativeUrl: (projectSlug: string) => string; // @public (undocumented) export class GenerateUploadUrlMutationBuilder { - // (undocumented) - static buildQuery(parameters: GenerateUploadUrlMutationBuilder.MutationParameters): string; + // @internal (undocumented) + static buildQuery(parameters: GenerateUploadUrlMutationBuilder.MutationParameters): GraphQlPrintResult; } // @public (undocumented) export namespace GenerateUploadUrlMutationBuilder { // (undocumented) - export type Acl = GraphQlLiteral<'PUBLIC_READ' | 'PRIVATE' | 'NONE'>; + export type Acl = 'PUBLIC_READ' | 'PRIVATE' | 'NONE' | GraphQlLiteral<'PUBLIC_READ' | 'PRIVATE' | 'NONE'>; // (undocumented) - export interface FileParameters { - // (undocumented) - acl?: Acl; - // (undocumented) + export type FileParameters = { contentType: string; - // (undocumented) expiration?: number; - // (undocumented) - extension?: string; - // (undocumented) - fileName?: string; - // (undocumented) - prefix?: string; - // (undocumented) size?: number; - // (undocumented) + prefix?: string; + extension?: string; suffix?: string; - } + fileName?: string; + acl?: Acl; + }; // (undocumented) export interface MutationParameters { // (undocumented) @@ -169,45 +125,34 @@ export const getTenantErrorMessage: (errorCode: string) => string; export namespace GraphQlBuilder { import GraphqlLiteral = GraphQlBuilderTmp.GraphQlLiteral; import GraphQlLiteral = GraphQlBuilderTmp.GraphQlLiteral; - import ObjectBuilder = GraphQlBuilderTmp.ObjectBuilder; - import QueryCompiler = GraphQlBuilderTmp.QueryCompiler; - import QueryBuilder = GraphQlBuilderTmp.QueryBuilder; - import RootObjectBuilder = GraphQlBuilderTmp.RootObjectBuilder; } // @public (undocumented) -export class GraphQlClient { - constructor(apiUrl: string, apiToken?: string | undefined); - // (undocumented) - readonly apiUrl: string; - // (undocumented) - sendRequest(query: string, { apiTokenOverride, signal, variables, headers }?: GraphQlClientRequestOptions): Promise; +export class GraphQlClient extends GraphQlClient_2 { + // @deprecated (undocumented) + sendRequest(query: string, options?: GraphQlClientRequestOptions): Promise; } +export { GraphQlClientError } + // @public (undocumented) export type GraphQlClientFailedRequestMetadata = Pick & { responseText: string; }; // @public (undocumented) -export interface GraphQlClientRequestOptions { - // (undocumented) +export interface GraphQlClientRequestOptions extends GraphQlClientRequestOptions_2 { + // @deprecated (undocumented) apiTokenOverride?: string; - // (undocumented) - headers?: Record; - // (undocumented) - signal?: AbortSignal; - // (undocumented) - variables?: GraphQlClientVariables; } -// @public (undocumented) -export interface GraphQlClientVariables { - // (undocumented) - [name: string]: any; -} +export { GraphQlClientVariables } -// @public (undocumented) +export { GraphQlErrorRequest } + +export { GraphQlErrorType } + +// @public @deprecated (undocumented) export class GraphQlLiteral { constructor(value: Value); // (undocumented) @@ -262,6 +207,14 @@ export interface RelationFilter { relations: RelationFilter[]; } +// @public (undocumented) +export type ReplaceGraphQlLiteral = T extends GraphQlLiteral ? Value : T extends string | number | boolean | null ? T : T extends {} ? { + [K in keyof T]: ReplaceGraphQlLiteral; +} : T extends any[] ? ReplaceGraphQlLiteral[] : T; + +// @public (undocumented) +export const replaceGraphQlLiteral: (input: T) => ReplaceGraphQlLiteral; + export { Result } // @public (undocumented) @@ -357,6 +310,9 @@ export const whereToFilter: (by: Input.UniqueWhere) => Input.Whe export { Writable } + +export * from "@contember/client-content"; + // (No @packageDocumentation comment for this package) ``` diff --git a/build/api/graphql-builder.api.md b/build/api/graphql-builder.api.md new file mode 100644 index 0000000000..2293e8bf47 --- /dev/null +++ b/build/api/graphql-builder.api.md @@ -0,0 +1,75 @@ +## API Report File for "@contember/graphql-builder" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { JSONValue } from '@contember/schema'; + +// @public (undocumented) +export class GraphQlField { + constructor(alias: string | null, name: string, args?: GraphQlFieldTypedArgs, selectionSet?: GraphQlSelectionSet | undefined); + // (undocumented) + readonly alias: string | null; + // (undocumented) + readonly args: GraphQlFieldTypedArgs; + // (undocumented) + readonly name: string; + // (undocumented) + readonly selectionSet?: GraphQlSelectionSet | undefined; +} + +// @public (undocumented) +export type GraphQlFieldTypedArgs = Record; + +// @public (undocumented) +export class GraphQlFragment { + constructor(name: string, type: string, selectionSet: GraphQlSelectionSet); + // (undocumented) + readonly name: string; + // (undocumented) + readonly selectionSet: GraphQlSelectionSet; + // (undocumented) + readonly type: string; +} + +// @public (undocumented) +export class GraphQlFragmentSpread { + constructor(name: string); + // (undocumented) + readonly name: string; +} + +// @public (undocumented) +export class GraphQlInlineFragment { + constructor(type: string, selectionSet: GraphQlSelectionSet); + // (undocumented) + readonly selectionSet: GraphQlSelectionSet; + // (undocumented) + readonly type: string; +} + +// @public (undocumented) +export type GraphQlPrintResult = { + query: string; + variables: Record; +}; + +// @public (undocumented) +export class GraphQlQueryPrinter { + // (undocumented) + printDocument(operation: 'query' | 'mutation', select: GraphQlSelectionSet, fragments: Record): GraphQlPrintResult; +} + +// @public (undocumented) +export type GraphQlSelectionSet = GraphQlSelectionSetItem[]; + +// @public (undocumented) +export type GraphQlSelectionSetItem = GraphQlField | GraphQlFragmentSpread | GraphQlInlineFragment; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/build/api/graphql-client.api.md b/build/api/graphql-client.api.md new file mode 100644 index 0000000000..6cd1d9c1a9 --- /dev/null +++ b/build/api/graphql-client.api.md @@ -0,0 +1,72 @@ +## API Report File for "@contember/graphql-client" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +// @public (undocumented) +export class GraphQlClient { + constructor(apiUrl: string, apiToken?: string | undefined); + // (undocumented) + readonly apiUrl: string; + // (undocumented) + protected doExecute(query: string, { apiToken, signal, variables, headers }?: GraphQlClientRequestOptions): Promise; + // (undocumented) + execute(query: string, options?: GraphQlClientRequestOptions): Promise; +} + +// @public (undocumented) +export class GraphQlClientError extends Error { + constructor(message: string, type: GraphQlErrorType, request: GraphQlErrorRequest, response?: Response | undefined, errors?: readonly any[] | undefined, details?: string | undefined, cause?: unknown); + // (undocumented) + readonly details?: string | undefined; + // (undocumented) + readonly errors?: readonly any[] | undefined; + // (undocumented) + readonly request: GraphQlErrorRequest; + // (undocumented) + readonly response?: Response | undefined; + // (undocumented) + readonly type: GraphQlErrorType; +} + +// @public (undocumented) +export interface GraphQlClientRequestOptions { + // (undocumented) + apiToken?: string; + // (undocumented) + headers?: Record; + // (undocumented) + onBeforeRequest?: (query: { + query: string; + variables: GraphQlClientVariables; + }) => void; + // (undocumented) + onData?: (json: unknown) => void; + // (undocumented) + onResponse?: (response: Response) => void; + // (undocumented) + signal?: AbortSignal; + // (undocumented) + variables?: GraphQlClientVariables; +} + +// @public (undocumented) +export interface GraphQlClientVariables { + // (undocumented) + [name: string]: any; +} + +// @public (undocumented) +export type GraphQlErrorRequest = { + url: string; + query: string; + variables: Record; +}; + +// @public (undocumented) +export type GraphQlErrorType = 'aborted' | 'network error' | 'invalid response body' | 'bad request' | 'unauthorized' | 'forbidden' | 'server error' | 'response errors'; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/build/api/react-binding.api.md b/build/api/react-binding.api.md index 7b198c23f0..a5ec56a757 100644 --- a/build/api/react-binding.api.md +++ b/build/api/react-binding.api.md @@ -21,6 +21,7 @@ import type { FieldName } from '@contember/binding'; import { FieldValue } from '@contember/binding'; import { Filter } from '@contember/binding'; import type { GetEntityByKey } from '@contember/binding'; +import { GraphQlClientError } from '@contember/react-client'; import type { HasManyRelationMarker } from '@contember/binding'; import type { HasOneRelationMarker } from '@contember/binding'; import { MarkerTreeRoot } from '@contember/binding'; @@ -32,7 +33,6 @@ import { ReactNode } from 'react'; import type { RelativeEntityList } from '@contember/binding'; import type { RelativeSingleEntity } from '@contember/binding'; import { RelativeSingleField } from '@contember/binding'; -import type { RequestError } from '@contember/binding'; import type { SugaredParentEntityParameters } from '@contember/binding'; import type { SugaredQualifiedEntityList } from '@contember/binding'; import type { SugaredQualifiedSingleEntity } from '@contember/binding'; @@ -72,7 +72,7 @@ export type AccessorTreeStateAction = { binding: DataBinding; } | { type: 'failWithError'; - error: RequestError; + error: GraphQlClientError; binding: DataBinding; } | { type: 'reset'; @@ -316,7 +316,7 @@ export interface ErrorAccessorTreeState { // (undocumented) environment: Environment; // (undocumented) - error: RequestError; + error: GraphQlClientError; // (undocumented) name: 'error'; }