diff --git a/src/component.ts b/src/component.ts new file mode 100644 index 0000000..a241dd9 --- /dev/null +++ b/src/component.ts @@ -0,0 +1,687 @@ +import { Field, FieldType } from "./field"; +import { MutationMode, PartialBy, RelationType } from "./util"; +import { ChangeItem, ChangeListener, MigrationChange } from "./migration"; +import { Renderer } from "./renderer"; +import { + GraphQLBatchMigrationCreateComponentFieldInput, + GraphQLBatchMigrationCreateComponentInput, + GraphQLBatchMigrationCreateComponentUnionFieldInput, + GraphQLBatchMigrationCreateEnumerableFieldInput, + GraphQLBatchMigrationCreateRelationalFieldInput, + GraphQLBatchMigrationCreateReverseRelationalFieldInput, + GraphQLBatchMigrationCreateReverseUnionFieldInput, + GraphQLBatchMigrationCreateSimpleFieldInput, + GraphQLBatchMigrationCreateUnionFieldInput, + GraphQLBatchMigrationUpdateComponentFieldInput, + GraphQLBatchMigrationUpdateComponentInput, + GraphQLBatchMigrationUpdateEnumerableFieldInput, + GraphQLBatchMigrationUpdateRelationalFieldInput, + GraphQLBatchMigrationUpdateSimpleFieldInput, + GraphQLBatchMigrationUpdateUnionFieldInput, + GraphQLFieldValidationFloatRangeInput, + GraphQLFieldValidationIntRangeInput, + GraphQLFieldValidationRegExInput, + GraphQLRelationalFieldType, + GraphQLSimpleFieldType, + GraphQLSimpleFieldValidationsInput, +} from "./generated/schema"; + +type ComponentArgs = + | GraphQLBatchMigrationCreateComponentInput + | GraphQLBatchMigrationUpdateComponentInput; + +/** + * Relational Fields + */ +interface RelationalFieldArgs + extends Omit< + GraphQLBatchMigrationCreateRelationalFieldInput, + "reverseField" | "isHidden" + > { + relationType: RelationType; + component: string; + /** + * @deprecated Use visibility instead. + */ + isHidden: GraphQLBatchMigrationCreateRelationalFieldInput["isHidden"]; + reverseField?: Omit< + GraphQLBatchMigrationCreateReverseRelationalFieldInput, + "modelApiId" | "isList" | "isHidden" + > & { + /** + * @deprecated Use visibility instead. + */ + isHidden?: GraphQLBatchMigrationCreateReverseRelationalFieldInput["isHidden"]; + }; +} + +/** + * Create Union Field + */ +interface CreateUnionFieldArgs + extends Omit< + GraphQLBatchMigrationCreateUnionFieldInput, + "reverseField" | "isHidden" + > { + relationType: RelationType; + models: string[]; + /** + * @deprecated Use visibility instead. + */ + isHidden: GraphQLBatchMigrationCreateRelationalFieldInput["isHidden"]; + reverseField?: Omit< + GraphQLBatchMigrationCreateReverseUnionFieldInput, + "modelApiIds" | "isList" | "isHidden" + > & { + /** + * @deprecated Use visibility instead. + */ + isHidden?: GraphQLBatchMigrationCreateReverseUnionFieldInput["isHidden"]; + }; +} + +/** + * Update Union Field + */ +interface UpdateUnionFieldArgs + extends Omit { + models?: string[]; +} + +interface FieldValidationArgs { + range?: GraphQLFieldValidationFloatRangeInput; + characters?: GraphQLFieldValidationIntRangeInput; + listItemCount?: GraphQLFieldValidationIntRangeInput; + matches?: GraphQLFieldValidationRegExInput; + notMatches?: GraphQLFieldValidationRegExInput; +} + +/** + * Create Simple Field + */ +interface CreateSimpleFieldArgs + extends Omit< + GraphQLBatchMigrationCreateSimpleFieldInput, + "validations" | "modelApiId" | "isHidden" + > { + validations?: FieldValidationArgs; + /** + * @deprecated Use visibility instead. + */ + isHidden?: GraphQLBatchMigrationCreateSimpleFieldInput["isHidden"]; +} + +interface UpdateSimpleFieldArgs + extends Omit< + GraphQLBatchMigrationUpdateSimpleFieldInput, + "validations" | "modelApiId" | "isHidden" + > { + validations?: FieldValidationArgs; + /** + * @deprecated Use visibility instead. + */ + isHidden?: GraphQLBatchMigrationCreateSimpleFieldInput["isHidden"]; +} + +/** + * Create Component Field + */ +interface CreateComponentFieldArgs + extends Omit< + GraphQLBatchMigrationCreateComponentFieldInput, + "componentApiId" + > { + component?: string; + componentApiIds: string[]; + componentApiId: string; +} + +/** + * Update Component Field + */ +interface UpdateComponentFieldArgs + extends Omit< + GraphQLBatchMigrationUpdateComponentFieldInput, + "componentApiId" + > { + component?: string; + componentApiIds: string[]; + componentApiId: string; +} + +/** + * Create Component Field + */ +interface CreateComponentUnionFieldArgs + extends Omit< + GraphQLBatchMigrationCreateComponentUnionFieldInput, + "componentApiId" + > { + component?: string; + componentApiIds: string[]; + componentApiId: string; +} + +/** + * Update Component Union Field + */ +interface UpdateComponentUnionFieldArgs + extends Omit< + GraphQLBatchMigrationUpdateComponentFieldInput, + "componentApiId" + > { + components?: string[]; + componentApiIds: string[]; + componentApiId: string; +} + +/** + * Create Component Union Field + */ +interface CreateComponentUnionFieldArgs + extends Omit< + GraphQLBatchMigrationCreateComponentFieldInput, + "componentApiId" + > { + components?: string[]; + componentApiIds: string[]; + componentApiId: string; +} + +interface UpdateRelationalFieldArgs + extends Omit< + GraphQLBatchMigrationUpdateRelationalFieldInput, + "modelApiId" | "isHidden" + > { + /** + * @deprecated Use visibility instead. + */ + isHidden?: GraphQLBatchMigrationUpdateRelationalFieldInput["isHidden"]; +} + +interface CreateEnumerableFieldArgs + extends Omit< + GraphQLBatchMigrationCreateEnumerableFieldInput, + "modelApiId" | "isHidden" + > { + /** + * @deprecated Use visibility instead. + */ + isHidden?: GraphQLBatchMigrationCreateEnumerableFieldInput["isHidden"]; +} + +interface UpdateEnumerableFieldArgs + extends Omit< + GraphQLBatchMigrationUpdateEnumerableFieldInput, + "modelApiId" | "isHidden" + > { + /** + * @deprecated Use visibility instead. + */ + isHidden?: GraphQLBatchMigrationUpdateEnumerableFieldInput["isHidden"]; +} + +/** + * GraphCMS Component + */ +interface Component { + /** + * Add a new field to the model. + * @param field options for the field. + */ + addSimpleField(field: CreateSimpleFieldArgs): Component; + + /** + * Update an existing field + * @param field options for the field. + */ + updateSimpleField(field: UpdateSimpleFieldArgs): Component; + + /** + * Add a relational field + * @param field options for the relational field. + */ + addRelationalField( + field: Omit, "modelApiId"> + ): Component; + + /** + * Update a relational field + * @param field options for the relational field. + */ + updateRelationalField(field: UpdateRelationalFieldArgs): Component; + + /** + * Add a union field + * @param field options for the union field. + */ + addUnionField(field: Omit): Component; + + /** + * Update a union field. + * @param field options for the union field. + */ + updateUnionField(field: Omit): Component; + + /** + * Add a new component to the model. + * @param field options for the field. + */ + addComponentField( + field: Omit< + CreateComponentFieldArgs, + "modelApiId" | "parentApiId" | "componentApiIds" + > + ): Component; + + /** + * Add a new component union field to the model. + * @param field options for the field. + */ + addComponentUnionField( + field: Omit< + CreateComponentFieldArgs, + "modelApiId" | "parentApiId" | "componentApiId" + > + ): Component; + + /** + * Add a new component union field to the model. + * @param field options for the field. + */ + addComponentUnionField( + field: Omit< + CreateComponentUnionFieldArgs, + "modelApiId" | "parentApiId" | "componentApiId" + > + ): Component; + + /** + * update a component field + * @param field options for the field. + */ + updateComponentField(field: UpdateComponentFieldArgs): Component; + + /** + * update a component union field + * @param field options for the field. + */ + updateComponentUnionField(field: UpdateComponentUnionFieldArgs): Component; + + /** + * Create an enumerable field. + * @param field options for the enumerable field. + */ + addEnumerableField(field: CreateEnumerableFieldArgs): Component; + + /** + * Update an enumerable field + * @param field options for the enumerable field. + */ + updateEnumerableField(field: UpdateEnumerableFieldArgs): Component; + + /** + * Delete a field + * @param apiId the apiId of the field to delete. + */ + deleteField(apiId: string): void; +} + +/** + * @ignore + */ +class ComponentClass implements Component, ChangeItem { + constructor( + private listener: ChangeListener, + private mode: MutationMode, + private args: ComponentArgs + ) {} + + addSimpleField(passedFieldArgs: any): Component { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + if (fieldArgs.type === GraphQLSimpleFieldType.String) { + fieldArgs.formRenderer = fieldArgs.formRenderer || Renderer.SingleLine; + } + + if (fieldArgs.validations) { + fieldArgs.validations = extractFieldValidations(fieldArgs); + } + + const field = new Field(fieldArgs, MutationMode.Create); + this.listener.registerChange(field); + return this; + } + + updateSimpleField(passedFieldArgs: any): Component { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + + if (fieldArgs.validations) { + fieldArgs.validations = extractFieldValidations(fieldArgs); + } + + const { type, ...fieldChanges } = fieldArgs; + const field = new Field(fieldChanges, MutationMode.Update); + this.listener.registerChange(field); + return this; + } + + addRelationalField(passedFieldArgs: any): Component { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + + fieldArgs.reverseField = { + modelApiId: fieldArgs.model, + isUnidirectional: true, + apiId: `related${fieldArgs.apiId}`, + displayName: `Related ${fieldArgs.apiId}`, + }; + + const fieldTypeUpper = fieldArgs.type?.toUpperCase(); + const fieldModelUpper = fieldArgs.model?.toUpperCase(); + + if ( + fieldTypeUpper === GraphQLRelationalFieldType.Asset || + fieldModelUpper === GraphQLRelationalFieldType.Asset + ) { + fieldArgs.type = GraphQLRelationalFieldType.Asset; + } else { + fieldArgs.type = GraphQLRelationalFieldType.Relation; + } + + fieldArgs.isList = + fieldArgs.relationType === RelationType.OneToMany || + fieldArgs.relationType === RelationType.OneToMany; + + if (fieldArgs.type === GraphQLRelationalFieldType.Asset) { + // Asset needs the isRequired field + if (fieldArgs.isRequired === undefined) { + fieldArgs.isRequired = false; + } + } else { + // we have to drop them on relation fields: + delete fieldArgs.isRequired; + } + + // remove convenience fields + delete fieldArgs.model; + delete fieldArgs.relationType; + + const field = new Field( + fieldArgs, + MutationMode.Create, + FieldType.RelationalField + ); + this.listener.registerChange(field); + return this; + } + + addUnionField(passedFieldArgs: any): Component { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + if (!fieldArgs.models || fieldArgs.models.length === 0) { + throw new Error(`models cannot be empty`); + } + + fieldArgs.reverseField = { + modelApiIds: fieldArgs.models, + apiId: `related${fieldArgs.apiId}`, + displayName: `Related ${fieldArgs.apiId}`, + }; + + fieldArgs.isList = + fieldArgs.relationType === RelationType.OneToMany || + fieldArgs.relationType === RelationType.ManyToMany; + + // remove convenience fields + delete fieldArgs.models; + delete fieldArgs.relationType; + + const field = new Field( + fieldArgs, + MutationMode.Create, + FieldType.UnionField + ); + this.listener.registerChange(field); + return this; + } + + updateUnionField(passedFieldArgs: any): Component { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.modelApiId = this.args.apiId; + fieldArgs.reverseField = { + ...passedFieldArgs?.reverseField, + modelApiIds: fieldArgs.models, + }; + + // remove convenience field + delete fieldArgs.models; + + const field = new Field( + fieldArgs, + MutationMode.Update, + FieldType.UnionField + ); + + this.listener.registerChange(field); + return this; + } + + updateRelationalField(passedFieldArgs: any): Component { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + fieldArgs.reverseField = { + ...passedFieldArgs?.reverseField, + modelApiId: fieldArgs.model, + isUnidirectional: true, + }; + + if ( + fieldArgs.parentApiId?.toUpperCase() === + GraphQLRelationalFieldType.Asset && + fieldArgs.isRequired !== undefined + ) { + fieldArgs.isRequired = Boolean(fieldArgs.isRequired); + } + + const field = new Field( + fieldArgs, + MutationMode.Update, + FieldType.RelationalField + ); + this.listener.registerChange(field); + return this; + } + + addComponentField(passedFieldArgs: CreateComponentFieldArgs): Component { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + if (!fieldArgs.component) { + throw new Error(`components cannot be empty`); + } + + fieldArgs.componentApiId = fieldArgs?.component; + // remove convenience field + delete fieldArgs.component; + + const field = new Field( + fieldArgs, + MutationMode.Create, + FieldType.ComponentField + ); + this.listener.registerChange(field); + return this; + } + + updateComponentField(passedFieldArgs: UpdateComponentFieldArgs): Component { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + if (!fieldArgs.component) { + throw new Error(`components cannot be empty`); + } + + // remove convenience field + delete fieldArgs.component; + + const field = new Field( + fieldArgs, + MutationMode.Update, + FieldType.ComponentField + ); + this.listener.registerChange(field); + return this; + } + + addComponentUnionField( + passedFieldArgs: CreateComponentUnionFieldArgs + ): Component { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + if (!fieldArgs.components || fieldArgs.components.length === 0) { + throw new Error(`components cannot be empty`); + } + + fieldArgs.componentApiIds = fieldArgs?.components; + // remove convenience field + delete fieldArgs.components; + + const field = new Field( + fieldArgs, + MutationMode.Create, + FieldType.ComponentUnionField + ); + this.listener.registerChange(field); + return this; + } + + updateComponentUnionField( + passedFieldArgs: UpdateComponentUnionFieldArgs + ): Component { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + if (!fieldArgs.components || fieldArgs.components.length === 0) { + throw new Error(`components cannot be empty`); + } + + fieldArgs.componentApiIds = fieldArgs?.components; + // remove convenience field + delete fieldArgs.components; + + const field = new Field( + fieldArgs, + MutationMode.Update, + FieldType.ComponentUnionField + ); + this.listener.registerChange(field); + return this; + } + + addEnumerableField(passedFieldArgs: any): Component { + const fieldArgs = { ...passedFieldArgs }; + if (!fieldArgs.enumerationApiId) { + throw new Error("enumerationApiId is required for enumerable field"); + } + fieldArgs.parentApiId = this.args.apiId; + const field = new Field( + fieldArgs, + MutationMode.Create, + FieldType.EnumerableField + ); + this.listener.registerChange(field); + return this; + } + + updateEnumerableField(passedFieldArgs: any): Component { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + + const field = new Field( + fieldArgs, + MutationMode.Update, + FieldType.EnumerableField + ); + this.listener.registerChange(field); + return this; + } + + deleteField(apiId: string): Component { + const field = new Field( + { apiId, modelApiId: this.args.apiId }, + MutationMode.Delete + ); + this.listener.registerChange(field); + return this; + } + + hasChanges(): boolean { + // all modes are guaranteed to have changes except Update. + if (this.mode !== MutationMode.Update) { + return true; + } + // apiId is always a requirement, length of 1 means its apiId only. + return Object.keys(this.args).length > 1; + } + + generateChange(): MigrationChange { + let action: string; + switch (this.mode) { + case MutationMode.Create: + action = "createComponent"; + break; + case MutationMode.Update: + action = "updateComponent"; + break; + case MutationMode.Delete: + action = "deleteComponent"; + break; + } + + const change: { [key: string]: any } = {}; + change[action] = this.args; + return change; + } +} + +/** + * @ignore + * @param fieldArgs + */ +function extractFieldValidations( + fieldArgs: CreateSimpleFieldArgs +): GraphQLSimpleFieldValidationsInput { + const validations: GraphQLSimpleFieldValidationsInput = {}; + switch (fieldArgs.type) { + case GraphQLSimpleFieldType.Int: + validations.Int = { range: fieldArgs.validations?.range }; + if (fieldArgs.isList) { + validations.Int.listItemCount = fieldArgs.validations?.listItemCount; + } + break; + + case GraphQLSimpleFieldType.Float: + validations.Float = { range: fieldArgs.validations?.range }; + if (fieldArgs.isList) { + validations.Float.listItemCount = fieldArgs.validations?.listItemCount; + } + break; + + case GraphQLSimpleFieldType.String: + validations.String = { + characters: fieldArgs.validations?.characters, + matches: fieldArgs.validations?.matches, + notMatches: fieldArgs.validations?.notMatches, + }; + if (fieldArgs.isList) { + validations.String.listItemCount = fieldArgs.validations?.listItemCount; + } + break; + + default: + throw new Error(`field validations not supported for ${fieldArgs.type}`); + } + + return validations; +} + +export { ComponentClass, Component }; diff --git a/src/field.ts b/src/field.ts index 7a2d1c4..e727963 100644 --- a/src/field.ts +++ b/src/field.ts @@ -1,11 +1,15 @@ import { ChangeItem, MigrationChange } from "./migration"; import { MutationMode } from "./util"; import { + GraphQLBatchMigrationCreateComponentFieldInput, + GraphQLBatchMigrationCreateComponentUnionFieldInput, GraphQLBatchMigrationCreateEnumerableFieldInput, GraphQLBatchMigrationCreateRelationalFieldInput, GraphQLBatchMigrationCreateRemoteFieldInput, GraphQLBatchMigrationCreateSimpleFieldInput, GraphQLBatchMigrationCreateUnionFieldInput, + GraphQLBatchMigrationUpdateComponentFieldInput, + GraphQLBatchMigrationUpdateComponentUnionFieldInput, GraphQLBatchMigrationUpdateRelationalFieldInput, GraphQLBatchMigrationUpdateSimpleFieldInput, GraphQLBatchMigrationUpdateUnionFieldInput, @@ -19,7 +23,11 @@ export type FieldArgs = | GraphQLBatchMigrationCreateEnumerableFieldInput | GraphQLBatchMigrationCreateUnionFieldInput | GraphQLBatchMigrationUpdateUnionFieldInput - | GraphQLBatchMigrationCreateRemoteFieldInput; + | GraphQLBatchMigrationCreateRemoteFieldInput + | GraphQLBatchMigrationCreateComponentFieldInput + | GraphQLBatchMigrationUpdateComponentFieldInput + | GraphQLBatchMigrationCreateComponentUnionFieldInput + | GraphQLBatchMigrationUpdateComponentUnionFieldInput; enum FieldType { SimpleField = 1, @@ -27,6 +35,8 @@ enum FieldType { EnumerableField, UnionField, RemoteField, + ComponentField, + ComponentUnionField, } /** diff --git a/src/generated/schema.ts b/src/generated/schema.ts index 6977b13..95390e9 100644 --- a/src/generated/schema.ts +++ b/src/generated/schema.ts @@ -23,7 +23,6 @@ export enum GraphQLCacheControlScope { Private = "PRIVATE", } -/** ### ASSETS: */ export type GraphQLIAssetConfig = { apiKey: Scalars["String"]; }; @@ -215,7 +214,7 @@ export type GraphQLCreateContentViewInput = { export type GraphQLUpdateContentViewInput = { id: Scalars["ID"]; - name: Scalars["String"]; + name?: Maybe; description?: Maybe; columns: Array; orderBy?: Maybe; @@ -244,12 +243,14 @@ export type GraphQLInvite = { project: GraphQLProject; acceptedAt?: Maybe; roles: Array; + origin?: Maybe; }; export type GraphQLSendInviteInput = { email: Scalars["String"]; projectId: Scalars["ID"]; roleIds: Array; + origin?: Maybe; }; export type GraphQLRevokeInviteInput = { @@ -330,11 +331,8 @@ export type GraphQLStats = { export type GraphQLMetrics = { __typename?: "Metrics"; - /** The number of API operations */ apiOperations: Array; - /** The asset traffic in Byte */ assetTraffic: Array; - /** The number of used asset transformations */ assetTransformations: Array; }; @@ -425,7 +423,6 @@ export type GraphQLLeaveTrialInput = { projectId: Scalars["ID"]; }; -/** ### TOKENS: */ export enum GraphQLPermanentAuthTokenAudience { ContentApi = "CONTENT_API", ManagementApi = "MANAGEMENT_API", @@ -474,127 +471,101 @@ export type GraphQLDeletePermanentAuthTokenPayload = { }; export enum GraphQLPermissionAction { - /** - * Project-level - * Virtual permission used to perform a project ownership check - */ ProjectClone = "PROJECT_CLONE", ProjectUpdate = "PROJECT_UPDATE", - /** Virtual permission used to perform a project ownership check */ ProjectDelete = "PROJECT_DELETE", - /** Virtual permission used to perform a project ownership check */ ManagePayment = "MANAGE_PAYMENT", PlaygroundUse = "PLAYGROUND_USE", AuditLogsRead = "AUDIT_LOGS_READ", - /** View Permissions that need to be moved to a new concept eventually */ ViewTeamMemberSettings = "VIEW_TEAM_MEMBER_SETTINGS", ViewRolePermissionSettings = "VIEW_ROLE_PERMISSION_SETTINGS", - /** Environments */ + ViewSchema = "VIEW_SCHEMA", EnvironmentCreate = "ENVIRONMENT_CREATE", EnvironmentRead = "ENVIRONMENT_READ", EnvironmentUpdate = "ENVIRONMENT_UPDATE", EnvironmentDelete = "ENVIRONMENT_DELETE", EnvironmentPromote = "ENVIRONMENT_PROMOTE", - /** Models */ ModelCreate = "MODEL_CREATE", ModelRead = "MODEL_READ", ModelUpdate = "MODEL_UPDATE", ModelDelete = "MODEL_DELETE", - /** Components */ ComponentCreate = "COMPONENT_CREATE", ComponentRead = "COMPONENT_READ", ComponentUpdate = "COMPONENT_UPDATE", ComponentDelete = "COMPONENT_DELETE", - /** Locales */ LocaleCreate = "LOCALE_CREATE", LocaleRead = "LOCALE_READ", LocaleUpdate = "LOCALE_UPDATE", LocaleDelete = "LOCALE_DELETE", - /** Stages */ StageCreate = "STAGE_CREATE", StageRead = "STAGE_READ", StageUpdate = "STAGE_UPDATE", StageDelete = "STAGE_DELETE", - /** Enumerations */ EnumerationCreate = "ENUMERATION_CREATE", EnumerationRead = "ENUMERATION_READ", EnumerationUpdate = "ENUMERATION_UPDATE", EnumerationDelete = "ENUMERATION_DELETE", - /** Fields */ FieldCreate = "FIELD_CREATE", FieldRead = "FIELD_READ", FieldUpdate = "FIELD_UPDATE", FieldDelete = "FIELD_DELETE", - /** Remote Sources */ RemoteSourceCreate = "REMOTE_SOURCE_CREATE", RemoteSourceRead = "REMOTE_SOURCE_READ", RemoteSourceUpdate = "REMOTE_SOURCE_UPDATE", RemoteSourceDelete = "REMOTE_SOURCE_DELETE", - /** PATs */ PatCreate = "PAT_CREATE", PatRead = "PAT_READ", PatUpdate = "PAT_UPDATE", PatDelete = "PAT_DELETE", - /** Content Views */ ContentviewCreate = "CONTENTVIEW_CREATE", ContentviewRead = "CONTENTVIEW_READ", ContentviewUpdate = "CONTENTVIEW_UPDATE", ContentviewSystemUpdate = "CONTENTVIEW_SYSTEM_UPDATE", ContentviewDelete = "CONTENTVIEW_DELETE", - /** Project Storage Buckets */ StorageBucketCreate = "STORAGE_BUCKET_CREATE", StorageBucketRead = "STORAGE_BUCKET_READ", StorageBucketUpdate = "STORAGE_BUCKET_UPDATE", StorageBucketDelete = "STORAGE_BUCKET_DELETE", - /** Roles */ RoleCreate = "ROLE_CREATE", RoleUpdate = "ROLE_UPDATE", RoleDelete = "ROLE_DELETE", - /** Webhooks */ WebhookCreate = "WEBHOOK_CREATE", WebhookRead = "WEBHOOK_READ", WebhookUpdate = "WEBHOOK_UPDATE", WebhookDelete = "WEBHOOK_DELETE", - /** Users */ UserInvite = "USER_INVITE", UserAssignrole = "USER_ASSIGNROLE", UserRemove = "USER_REMOVE", - /** View Groups */ ViewGroupCreate = "VIEW_GROUP_CREATE", ViewGroupRead = "VIEW_GROUP_READ", ViewGroupUpdate = "VIEW_GROUP_UPDATE", ViewGroupDelete = "VIEW_GROUP_DELETE", - /** - * deprecated! - * Content (actual Content API permission) - */ ContentCreate = "CONTENT_CREATE", ContentRead = "CONTENT_READ", ContentUpdate = "CONTENT_UPDATE", ContentDelete = "CONTENT_DELETE", ContentPublish = "CONTENT_PUBLISH", ContentUpdatePublished = "CONTENT_UPDATE_PUBLISHED", - /** Content Permissions */ ContentPermissionCreate = "CONTENT_PERMISSION_CREATE", ContentPermissionRead = "CONTENT_PERMISSION_READ", ContentPermissionUpdate = "CONTENT_PERMISSION_UPDATE", ContentPermissionDelete = "CONTENT_PERMISSION_DELETE", - /** Integration */ IntegrationCreate = "INTEGRATION_CREATE", IntegrationRead = "INTEGRATION_READ", IntegrationUpdate = "INTEGRATION_UPDATE", IntegrationDelete = "INTEGRATION_DELETE", NetlifyTriggerBuild = "NETLIFY_TRIGGER_BUILD", VercelTriggerBuild = "VERCEL_TRIGGER_BUILD", - /** Extension */ ExtensionCreate = "EXTENSION_CREATE", ExtensionRead = "EXTENSION_READ", ExtensionUpdate = "EXTENSION_UPDATE", ExtensionDelete = "EXTENSION_DELETE", - /** Sidebar elements */ - SidebarElementCreate = "SIDEBAR_ELEMENT_CREATE", - SidebarElementUpdate = "SIDEBAR_ELEMENT_UPDATE", - SidebarElementDelete = "SIDEBAR_ELEMENT_DELETE", + AppCreate = "APP_CREATE", + AppUpdate = "APP_UPDATE", + AppDelete = "APP_DELETE", + AppInstallationCreate = "APP_INSTALLATION_CREATE", + AppInstallationUpdate = "APP_INSTALLATION_UPDATE", + AppInstallationDelete = "APP_INSTALLATION_DELETE", } export type GraphQLPermanentAuthTokenDefaultsInput = { @@ -795,14 +766,12 @@ export type GraphQLProject = { subscription: GraphQLPaymentSubscription; invites: Array; owner: GraphQLMember; - /** Will be null if viewer is not a user */ viewerAsMember?: Maybe; region: GraphQLRegion; existingRoles: Array; existingRole: GraphQLRole; environments: Array; environment: GraphQLEnvironment; - /** List of all members of the given project */ members: Array; membersConnection: GraphQLMembersConnection; quotas: GraphQLQuota; @@ -812,11 +781,12 @@ export type GraphQLProject = { isCloning?: Maybe; meta: Scalars["JSON"]; auditLogs: GraphQLAuditLogsPayload; - /** List all Permissions usable/assignable to roles in this project */ availableManagementPermissions: Array; cloningProjects: Array; /** if this is `null` it means the project is not publicly clone-able */ publicCloneAccess?: Maybe; + defaultPaginationSize?: Maybe; + maxPaginationSize?: Maybe; }; export type GraphQLProjectExistingRoleArgs = { @@ -904,6 +874,15 @@ export type GraphQL_SwitchOwnerPayload = { gcms?: Maybe; }; +export type GraphQL_ResetContentConfigInput = { + gcms?: Maybe; +}; + +export type GraphQL_ResetContentConfigPayload = { + __typename?: "_ResetContentConfigPayload"; + gcms?: Maybe; +}; + export type GraphQL_BookOverLimitInput = { gcms?: Maybe; }; @@ -1061,7 +1040,6 @@ export type GraphQLRole = { */ contentPermissions: Array; managementPermissions: Array; - /** List of all members that have at least this role */ members: Array; membersConnection: GraphQLMembersConnection; }; @@ -1120,7 +1098,6 @@ export type GraphQLIContentPermission = { updatedAt: Scalars["DateTime"]; enabled: Scalars["Boolean"]; target: GraphQLContentPermissionTarget; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; }; @@ -1131,20 +1108,14 @@ export type GraphQLReadContentPermission = GraphQLIContentPermission & { updatedAt: Scalars["DateTime"]; enabled: Scalars["Boolean"]; target: GraphQLContentPermissionTarget; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows only access to specific stages. If null all stages are allowed */ stages?: Maybe>; - /** Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. */ condition?: Maybe; }; export type GraphQLCreateReadContentPermissionModelInput = { - /** model id */ id: Scalars["ID"]; - /** Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. */ condition?: Maybe; }; @@ -1170,22 +1141,15 @@ export type GraphQLCreateContentPermissionTargetInput = { export type GraphQLCreateReadContentPermissionInput = { target: GraphQLCreateContentPermissionTargetInput; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows only access to specific stages. If null all stages are allowed */ stages?: Maybe>; }; export type GraphQLUpdateReadContentPermissionInput = { - /** Id of the read permission that should be updated. */ permissionId: Scalars["ID"]; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows only access to specific stages. If null all stages are allowed */ stages?: Maybe>; }; @@ -1206,20 +1170,16 @@ export type GraphQLReadVersionContentPermission = GraphQLIContentPermission & { updatedAt: Scalars["DateTime"]; enabled: Scalars["Boolean"]; target: GraphQLContentPermissionTarget; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; }; export type GraphQLCreateReadVersionContentPermissionInput = { target: GraphQLCreateContentPermissionTargetInput; - /** Allows only access to this model. If null, all models are allowed. */ modelId?: Maybe; }; export type GraphQLUpdateReadVersionContentPermissionInput = { - /** Id of the read permission that should be updated. */ permissionId: Scalars["ID"]; - /** Allows only access to this model. If null, all models are allowed. */ modelId?: Maybe; }; @@ -1240,35 +1200,25 @@ export type GraphQLCreateContentPermission = GraphQLIContentPermission & { updatedAt: Scalars["DateTime"]; enabled: Scalars["Boolean"]; target: GraphQLContentPermissionTarget; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. */ condition?: Maybe; }; export type GraphQLCreateCreateContentPermissionModelInput = { - /** model id */ id: Scalars["ID"]; - /** Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. */ condition?: Maybe; }; export type GraphQLCreateCreateContentPermissionInput = { target: GraphQLCreateContentPermissionTargetInput; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; }; export type GraphQLUpdateCreateContentPermissionInput = { - /** Id of the read permission that should be updated. */ permissionId: Scalars["ID"]; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; }; @@ -1289,35 +1239,25 @@ export type GraphQLUpdateContentPermission = GraphQLIContentPermission & { updatedAt: Scalars["DateTime"]; enabled: Scalars["Boolean"]; target: GraphQLContentPermissionTarget; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. */ condition?: Maybe; }; export type GraphQLCreateUpdateContentPermissionModelInput = { - /** model id */ id: Scalars["ID"]; - /** Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. */ condition?: Maybe; }; export type GraphQLCreateUpdateContentPermissionInput = { target: GraphQLCreateContentPermissionTargetInput; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; }; export type GraphQLUpdateUpdateContentPermissionInput = { - /** Id of the update permission that should be updated. */ permissionId: Scalars["ID"]; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; }; @@ -1338,35 +1278,25 @@ export type GraphQLDeleteContentPermission = GraphQLIContentPermission & { updatedAt: Scalars["DateTime"]; enabled: Scalars["Boolean"]; target: GraphQLContentPermissionTarget; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. */ condition?: Maybe; }; export type GraphQLCreateDeleteContentPermissionModelInput = { - /** model id */ id: Scalars["ID"]; - /** Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. */ condition?: Maybe; }; export type GraphQLCreateDeleteContentPermissionInput = { target: GraphQLCreateContentPermissionTargetInput; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; }; export type GraphQLUpdateDeleteContentPermissionInput = { - /** Id of the delete permission that should be updated. */ permissionId: Scalars["ID"]; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; }; @@ -1387,37 +1317,23 @@ export type GraphQLPublishContentPermission = GraphQLIContentPermission & { updatedAt: Scalars["DateTime"]; enabled: Scalars["Boolean"]; target: GraphQLContentPermissionTarget; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows only to publish from specific stages. If null all stages are allowed */ fromStages?: Maybe>; - /** Allows only to publish to specific stages. If null all stages are allowed */ toStages?: Maybe>; - /** Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. */ condition?: Maybe; }; export type GraphQLCreatePublishContentPermissionModelInput = { - /** model id */ id: Scalars["ID"]; - /** - * Allows only access to specific fields. If null, all fields are allowed - * Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. - */ condition?: Maybe; }; export type GraphQLCreatePublishContentPermissionInput = { target: GraphQLCreateContentPermissionTargetInput; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows only to publish from specific stages. If null all stages are allowed */ fromStages?: Maybe>; - /** Allows only to publish to specific stages. If null all stages are allowed */ toStages?: Maybe>; }; @@ -1427,25 +1343,15 @@ export type GraphQLCreatePublishContentPermissionPayload = { }; export type GraphQLUpdatePublishContentPermissionModelInput = { - /** model id */ id: Scalars["ID"]; - /** - * Allows only access to specific fields. If null, all fields are allowed - * Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. - */ condition?: Maybe; }; export type GraphQLUpdatePublishContentPermissionInput = { - /** Id of the delete permission that should be updated. */ permissionId: Scalars["ID"]; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows only to publish from specific stages. If null all stages are allowed */ fromStages?: Maybe>; - /** Allows only to publish to specific stages. If null all stages are allowed */ toStages?: Maybe>; }; @@ -1461,33 +1367,21 @@ export type GraphQLUnpublishContentPermission = GraphQLIContentPermission & { updatedAt: Scalars["DateTime"]; enabled: Scalars["Boolean"]; target: GraphQLContentPermissionTarget; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows only to publish from specific stages. If null all stages are allowed */ stages?: Maybe>; - /** Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. */ condition?: Maybe; }; export type GraphQLCreateUnpublishContentPermissionModelInput = { - /** model id */ id: Scalars["ID"]; - /** - * Allows only access to specific fields. If null, all fields are allowed - * Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. - */ condition?: Maybe; }; export type GraphQLCreateUnpublishContentPermissionInput = { target: GraphQLCreateContentPermissionTargetInput; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows only to publish from specific stages. If null all stages are allowed */ stages?: Maybe>; }; @@ -1497,23 +1391,14 @@ export type GraphQLCreateUnpublishContentPermissionPayload = { }; export type GraphQLUpdateUnpublishContentPermissionModelInput = { - /** model id */ id: Scalars["ID"]; - /** - * Allows only access to specific fields. If null, all fields are allowed - * Allows access when conditions are met. Condition is a stringified JSON matching a usual where input. Ignored if there are no conditions. - */ condition?: Maybe; }; export type GraphQLUpdateUnpublishContentPermissionInput = { - /** Id of the delete permission that should be updated. */ permissionId: Scalars["ID"]; - /** Allows only access to this model. If null, all models are allowed. */ model?: Maybe; - /** Allows only access to specific locales. If null, all locales are allowed */ locales?: Maybe>; - /** Allows only to publish from specific stages. If null all stages are allowed */ stages?: Maybe>; }; @@ -1674,6 +1559,13 @@ export type GraphQLRemoteTypeDefinitionsConnection = { aggregate: GraphQLRemoteTypeDefinitionsAggregate; }; +export type GraphQLCommentingConfig = { + __typename?: "CommentingConfig"; + url: Scalars["String"]; + token: Scalars["String"]; + userKey: Scalars["String"]; +}; + export type GraphQLEnvironment = { __typename?: "Environment"; id: Scalars["ID"]; @@ -1707,7 +1599,10 @@ export type GraphQLEnvironment = { integration: GraphQLIIntegration; extensions: Array; extension: GraphQLIExtension; + appInstallations: Array; + appInstallation: GraphQLAppInstallation; diff: GraphQLDiffEnvironmentPayload; + commentingConfig?: Maybe; }; export type GraphQLEnvironmentWebhookArgs = { @@ -1739,6 +1634,14 @@ export type GraphQLEnvironmentExtensionArgs = { id: Scalars["ID"]; }; +export type GraphQLEnvironmentAppInstallationsArgs = { + status?: Maybe; +}; + +export type GraphQLEnvironmentAppInstallationArgs = { + appApiId: Scalars["String"]; +}; + export type GraphQLEnvironmentDiffArgs = { environmentName: Scalars["String"]; }; @@ -1751,7 +1654,6 @@ export type GraphQLPublicContentApiDefauts = { export type GraphQLPublicContentApi = { __typename?: "PublicContentAPI"; defaults: GraphQLPublicContentApiDefauts; - /** returns configured content permissions used for public access of the environment */ contentPermissions: Array; }; @@ -1907,9 +1809,14 @@ export type GraphQLStage = { export type GraphQLProfile = { __typename?: "Profile"; + id: Scalars["ID"]; email: Scalars["String"]; name: Scalars["String"]; picture?: Maybe; + role?: Maybe; + purpose?: Maybe; + companyName?: Maybe; + companySize?: Maybe; }; export type GraphQLIUser = { @@ -1981,10 +1888,6 @@ export type GraphQLTechnologyStack = { url?: Maybe; }; -/** - * Represents the logged in user - * Will be removed soon - */ export type GraphQLViewer = GraphQLIUser & { __typename?: "Viewer"; id: Scalars["ID"]; @@ -2005,26 +1908,14 @@ export type GraphQLViewer = GraphQLIUser & { availableExtensionPermissions: Array; }; -/** - * Represents the logged in user - * Will be removed soon - */ export type GraphQLViewerPendingInviteArgs = { code: Scalars["String"]; }; -/** - * Represents the logged in user - * Will be removed soon - */ export type GraphQLViewerProjectArgs = { id: Scalars["ID"]; }; -/** - * Represents the logged in user - * Will be removed soon - */ export type GraphQLViewerPaymentAccountArgs = { id: Scalars["ID"]; }; @@ -2071,6 +1962,8 @@ export type GraphQLUserViewer = GraphQLIViewer & { projects: Array; project?: Maybe; commonAssetConfig: GraphQLCommonFilestack; + apps: Array; + app: GraphQLApp; }; export type GraphQLUserViewerPendingInviteArgs = { @@ -2089,6 +1982,10 @@ export type GraphQLUserViewerProjectArgs = { id?: Maybe; }; +export type GraphQLUserViewerAppArgs = { + apiId: Scalars["String"]; +}; + export type GraphQLTokenViewer = GraphQLIViewer & { __typename?: "TokenViewer"; id: Scalars["ID"]; @@ -2105,7 +2002,6 @@ export type GraphQLTokenViewerProjectArgs = { id?: Maybe; }; -/** Represents a user in a project */ export type GraphQLMember = GraphQLIUser & { __typename?: "Member"; id: Scalars["ID"]; @@ -2183,6 +2079,10 @@ export type GraphQLUpdateProfileInput = { jobTitle?: Maybe; jobRole?: Maybe; picture?: Maybe; + role?: Maybe; + purpose?: Maybe; + companyName?: Maybe; + companySize?: Maybe; }; export enum GraphQLProfileJobRole { @@ -2356,59 +2256,14 @@ export enum GraphQLWebhookLogOrderByInput { export type GraphQLWebhookLog = { __typename?: "WebhookLog"; id: Scalars["String"]; - /** - * """ - * Payload that was send as the payload - * """ - */ requestPayload?: Maybe; - /** - * """ - * Payload that was return by the webhook - * """ - */ responsePayload?: Maybe; - /** - * """ - * Size of the response payload in bytes - * """ - */ responsePayloadSize?: Maybe; - /** - * """ - * Time when the webhook was called - * """ - */ calledAt: Scalars["DateTime"]; - /** - * """ - * Status code of the response - * """ - */ statusCode: Scalars["Int"]; - /** - * """ - * Model on which the webhook was triggered - * """ - */ model?: Maybe; - /** - * """ - * Action which triggered the webhook - * """ - */ triggerAction: GraphQLWebhookTriggerAction; - /** - * """ - * In case of errors shows how many retry attempts happened - * """ - */ attempts: Scalars["Int"]; - /** - * """ - * Duration the request call took in milliseconds - * """ - */ duration: Scalars["Float"]; }; @@ -2710,6 +2565,203 @@ export type GraphQLDeleteExtensionInput = { extensionId: Scalars["ID"]; }; +export enum GraphQLAppPublicationStatus { + Private = "PRIVATE", + Pending = "PENDING", + Public = "PUBLIC", +} + +export type GraphQLApp = { + __typename?: "App"; + id: Scalars["ID"]; + author: Scalars["ID"]; + name: Scalars["String"]; + apiId: Scalars["String"]; + setupUrl: Scalars["String"]; + webhookUrl?: Maybe; + configurationUrl?: Maybe; + elements?: Maybe>; + avatarUrl: Scalars["String"]; + description: Scalars["String"]; + createdAt: Scalars["DateTime"]; + updatedAt: Scalars["DateTime"]; + publicationStatus: GraphQLAppPublicationStatus; +}; + +export enum GraphQLAppElementType { + Field = "field", + FormSidebar = "formSidebar", + Page = "page", +} + +export type GraphQLIAppElement = { + id: Scalars["ID"]; + name: Scalars["String"]; + apiId: Scalars["String"]; + type: GraphQLAppElementType; + description?: Maybe; + config?: Maybe; + createdAt: Scalars["DateTime"]; + updatedAt: Scalars["DateTime"]; + src: Scalars["String"]; + app: GraphQLApp; +}; + +export enum GraphQLFieldAppElementFeature { + FieldRenderer = "FieldRenderer", + ListRenderer = "ListRenderer", + TableRenderer = "TableRenderer", +} + +export type GraphQLFieldAppElement = GraphQLIAppElement & { + __typename?: "FieldAppElement"; + id: Scalars["ID"]; + name: Scalars["String"]; + apiId: Scalars["String"]; + type: GraphQLAppElementType; + description?: Maybe; + config?: Maybe; + createdAt: Scalars["DateTime"]; + updatedAt: Scalars["DateTime"]; + src: Scalars["String"]; + features: Array; + fieldType: GraphQLSimpleFieldType; + app: GraphQLApp; +}; + +export type GraphQLFormSidebarAppElement = GraphQLIAppElement & { + __typename?: "FormSidebarAppElement"; + id: Scalars["ID"]; + name: Scalars["String"]; + apiId: Scalars["String"]; + type: GraphQLAppElementType; + description?: Maybe; + config?: Maybe; + createdAt: Scalars["DateTime"]; + updatedAt: Scalars["DateTime"]; + src: Scalars["String"]; + app: GraphQLApp; +}; + +export type GraphQLPageAppElement = GraphQLIAppElement & { + __typename?: "PageAppElement"; + id: Scalars["ID"]; + name: Scalars["String"]; + apiId: Scalars["String"]; + type: GraphQLAppElementType; + description?: Maybe; + config?: Maybe; + createdAt: Scalars["DateTime"]; + updatedAt: Scalars["DateTime"]; + src: Scalars["String"]; + app: GraphQLApp; +}; + +export type GraphQLCreateAppInput = { + name: Scalars["String"]; + apiId: Scalars["String"]; + setupUrl: Scalars["String"]; + avatarUrl: Scalars["String"]; + description: Scalars["String"]; + webhookUrl?: Maybe; + elements?: Maybe>; + configurationUrl?: Maybe; +}; + +export type GraphQLAppElementInput = { + id: Scalars["ID"]; + apiId: Scalars["String"]; + name: Scalars["String"]; + type: GraphQLAppElementType; + description?: Maybe; + config?: Maybe; + src: Scalars["String"]; + features?: Maybe>; + fieldType?: Maybe; +}; + +export type GraphQLUpdateAppInput = { + apiId: Scalars["String"]; + name?: Maybe; + setupUrl?: Maybe; + webhookUrl?: Maybe; + elements?: Maybe>; + avatarUrl?: Maybe; + description?: Maybe; + configurationUrl?: Maybe; +}; + +export type GraphQLDeleteAppInput = { + apiId: Scalars["String"]; +}; + +export type GraphQLCreateAppPayload = { + __typename?: "CreateAppPayload"; + createdApp: GraphQLApp; +}; + +export type GraphQLUpdateAppPayload = { + __typename?: "UpdateAppPayload"; + updatedApp: GraphQLApp; +}; + +export type GraphQLDeleteAppPayload = { + __typename?: "DeleteAppPayload"; + deletedAppId: Scalars["ID"]; +}; + +export enum GraphQLAppInstallationStatus { + Pending = "PENDING", + Completed = "COMPLETED", + Disabled = "DISABLED", +} + +export type GraphQLAppInstallation = { + __typename?: "AppInstallation"; + id: Scalars["ID"]; + environment: GraphQLEnvironment; + fields: Array; + sidebarElements: Array; + app: GraphQLApp; + config: Scalars["JSON"]; + status: GraphQLAppInstallationStatus; + authToken: Scalars["String"]; + createdAt: Scalars["DateTime"]; + updatedAt: Scalars["DateTime"]; +}; + +export type GraphQLCreateAppInstallationInput = { + environment: Scalars["ID"]; + appApiId: Scalars["String"]; + status?: Maybe; + config: Scalars["JSON"]; +}; + +export type GraphQLUpdateAppInstallationInput = { + appInstallationId: Scalars["ID"]; + config: Scalars["JSON"]; + status?: Maybe; +}; + +export type GraphQLDeleteAppInstallationInput = { + appInstallationId: Scalars["ID"]; +}; + +export type GraphQLCreateAppInstallationPayload = { + __typename?: "CreateAppInstallationPayload"; + createdAppInstallation: GraphQLAppInstallation; +}; + +export type GraphQLUpdateAppInstallationPayload = { + __typename?: "UpdateAppInstallationPayload"; + updatedAppInstallation: GraphQLAppInstallation; +}; + +export type GraphQLDeleteAppInstallationPayload = { + __typename?: "DeleteAppInstallationPayload"; + deletedAppInstallationId: Scalars["ID"]; +}; + export type GraphQLEnumerationValue = { __typename?: "EnumerationValue"; id: Scalars["ID"]; @@ -2963,7 +3015,6 @@ export type GraphQLSimpleField = GraphQLIField & validations?: Maybe; meta?: Maybe; embedsEnabled?: Maybe; - /** list of embeddable models */ embeddableModels?: Maybe>; }; @@ -3171,7 +3222,6 @@ export type GraphQLComponentField = GraphQLIField & meta?: Maybe; }; -/** rename to RelationUnionField maybe at some point */ export type GraphQLUnionField = GraphQLIField & GraphQLIUnionField & { __typename?: "UnionField"; @@ -3203,7 +3253,6 @@ export type GraphQLUnionField = GraphQLIField & meta?: Maybe; }; -/** TODO: ModularComponentField is the name the designs use right now?! */ export type GraphQLComponentUnionField = GraphQLIField & GraphQLIRequireableField & { __typename?: "ComponentUnionField"; @@ -3256,6 +3305,8 @@ export type GraphQLFieldConfig = { id: Scalars["String"]; renderer: Scalars["String"]; extension?: Maybe; + appInstallation?: Maybe; + appElement?: Maybe; }; export type GraphQLMoveFieldPayload = { @@ -3334,7 +3385,6 @@ export type GraphQLUpdateSimpleFieldInput = { validations?: Maybe; meta?: Maybe; embedsEnabled?: Maybe; - /** id's of embeddable models. */ embeddableModels?: Maybe; }; @@ -3424,8 +3474,8 @@ export type GraphQLUpdateComponentUnionFieldInput = { export type GraphQLCreateMemberFieldInput = { /** ID of member model to add */ modelId: Scalars["ID"]; - apiId: Scalars["String"]; - displayName: Scalars["String"]; + apiId?: Maybe; + displayName?: Maybe; description?: Maybe; isHidden?: Maybe; visibility?: Maybe; @@ -3463,6 +3513,8 @@ export type GraphQLFieldConfigInput = { renderer: Scalars["String"]; config: Scalars["JSON"]; extensionId?: Maybe; + appInstallationId?: Maybe; + appElementId?: Maybe; }; export type GraphQLFieldConfigUpdateInput = { @@ -3498,7 +3550,6 @@ export type GraphQLCreateSimpleFieldInput = { meta?: Maybe; position?: Maybe; embedsEnabled?: Maybe; - /** id's of embeddable models. Optional, but should be provided if embedsEnabled is true */ embeddableModels?: Maybe>; }; @@ -3764,7 +3815,7 @@ export type GraphQLCreateUnionFieldInput = { isList: Scalars["Boolean"]; isHidden?: Maybe; visibility?: Maybe; - reverseSide: GraphQLCreateReverseField; + reverseSide?: Maybe; tableConfig?: Maybe; formConfig?: Maybe; extensions?: Maybe; @@ -3838,10 +3889,12 @@ export type GraphQLUpdateSidebarElementPayload = { export type GraphQLCreateCustomSidebarElementInput = { modelId: Scalars["ID"]; - extensionId: Scalars["ID"]; + extensionId?: Maybe; displayName: Scalars["String"]; description?: Maybe; config?: Maybe; + appElementId?: Maybe; + appInstallationId?: Maybe; }; export type GraphQLCreateSystemSidebarElementInput = { @@ -3947,6 +4000,8 @@ export type GraphQLIModelContentViewsArgs = { export type GraphQLSidebarElements = | GraphQLSystemSidebarElement + | GraphQLAppSidebarElement + | GraphQLExtensionSidebarElement | GraphQLCustomSidebarElement; export type GraphQLISidebarElement = { @@ -3961,6 +4016,20 @@ export type GraphQLISidebarElement = { model: GraphQLIModel; }; +export type GraphQLCustomSidebarElement = GraphQLISidebarElement & { + __typename?: "CustomSidebarElement"; + id: Scalars["ID"]; + createdAt: Scalars["DateTime"]; + updatedAt: Scalars["DateTime"]; + displayName: Scalars["String"]; + description?: Maybe; + config?: Maybe; + position: Scalars["Int"]; + isEnabled: Scalars["Boolean"]; + model: GraphQLIModel; + extension: GraphQLSidebarExtension; +}; + export enum GraphQLSystemSidebarElementType { Information = "INFORMATION", Stages = "STAGES", @@ -3984,8 +4053,8 @@ export type GraphQLSystemSidebarElement = GraphQLISidebarElement & { type: GraphQLSystemSidebarElementType; }; -export type GraphQLCustomSidebarElement = GraphQLISidebarElement & { - __typename?: "CustomSidebarElement"; +export type GraphQLExtensionSidebarElement = GraphQLISidebarElement & { + __typename?: "ExtensionSidebarElement"; id: Scalars["ID"]; createdAt: Scalars["DateTime"]; updatedAt: Scalars["DateTime"]; @@ -3998,6 +4067,21 @@ export type GraphQLCustomSidebarElement = GraphQLISidebarElement & { extension: GraphQLSidebarExtension; }; +export type GraphQLAppSidebarElement = GraphQLISidebarElement & { + __typename?: "AppSidebarElement"; + id: Scalars["ID"]; + createdAt: Scalars["DateTime"]; + updatedAt: Scalars["DateTime"]; + displayName: Scalars["String"]; + description?: Maybe; + config?: Maybe; + position: Scalars["Int"]; + isEnabled: Scalars["Boolean"]; + model: GraphQLIModel; + appElement: GraphQLFormSidebarAppElement; + appInstallation: GraphQLAppInstallation; +}; + export type GraphQLModel = GraphQLIModel & GraphQLIFieldParent & { __typename?: "Model"; @@ -4383,6 +4467,15 @@ export type GraphQLUpdateEnvironmentPayload = { updatedEnvironment: GraphQLEnvironment; }; +export type GraphQLCommentingInfoInput = { + gcms?: Maybe; +}; + +export type GraphQLCommentingInfoPayload = { + __typename?: "CommentingInfoPayload"; + gcms?: Maybe; +}; + export type GraphQLQuery = { __typename?: "Query"; metaInfo: GraphQLMetaInfo; @@ -4440,9 +4533,13 @@ export type GraphQLDeleteEnvironmentPayload = { /** Creating a model. */ export type GraphQLBatchMigrationCreateModelInput = { + /** The model apiId */ apiId: Scalars["String"]; + /** The models plural apiId. This is used for lists */ apiIdPlural: Scalars["String"]; + /** Display name that is used to render the model in the webapp */ displayName: Scalars["String"]; + /** Optional description of the model */ description?: Maybe; }; @@ -4534,7 +4631,6 @@ export type GraphQLBatchMigrationCreateStageInput = { /** Deleting a field. */ export type GraphQLBatchMigrationDeleteFieldInput = { apiId: Scalars["String"]; - /** either modelApiId or parentApiId needs to be set */ modelApiId?: Maybe; parentApiId?: Maybe; }; @@ -4548,7 +4644,6 @@ export type GraphQLBatchMigrationEmbeddableModelsInput = { /** Creating a simple field. */ export type GraphQLBatchMigrationCreateSimpleFieldInput = { apiId: Scalars["String"]; - /** either modelApiId or parentApiId needs to be set */ modelApiId?: Maybe; parentApiId?: Maybe; type: GraphQLSimpleFieldType; @@ -4571,15 +4666,9 @@ export type GraphQLBatchMigrationCreateSimpleFieldInput = { validations?: Maybe; migrationValue?: Maybe; embedsEnabled?: Maybe; - /** id's of embeddable models. Optional, but should be provided if embedsEnabled is true */ embeddableModels?: Maybe>; }; -/** - * """ - * Creating a remote field. - * """ - */ export type GraphQLBatchMigrationCreateRemoteFieldInput = { apiId: Scalars["String"]; parentApiId: Scalars["String"]; @@ -4620,7 +4709,6 @@ export type GraphQLBatchMigrationUpdateRemoteFieldInput = { /** Creating an enumerable field. */ export type GraphQLBatchMigrationCreateEnumerableFieldInput = { apiId: Scalars["String"]; - /** either modelApiId or parentApiId needs to be set */ modelApiId?: Maybe; parentApiId?: Maybe; enumerationApiId: Scalars["String"]; @@ -4644,7 +4732,6 @@ export type GraphQLBatchMigrationCreateEnumerableFieldInput = { export type GraphQLBatchMigrationUpdateUnionFieldInput = { apiId: Scalars["String"]; newApiId?: Maybe; - /** either modelApiId or parentApiId needs to be set */ modelApiId?: Maybe; parentApiId?: Maybe; displayName?: Maybe; @@ -4656,7 +4743,6 @@ export type GraphQLBatchMigrationUpdateUnionFieldInput = { /** Creating a union field */ export type GraphQLBatchMigrationCreateUnionFieldInput = { apiId: Scalars["String"]; - /** either modelApiId or parentApiId needs to be set */ modelApiId?: Maybe; parentApiId?: Maybe; displayName: Scalars["String"]; @@ -4699,9 +4785,9 @@ export type GraphQLBatchMigrationCreateComponentUnionFieldInput = { /** reverse field args */ export type GraphQLBatchMigrationCreateReverseUnionFieldInput = { - apiId: Scalars["String"]; + apiId?: Maybe; modelApiIds: Array; - displayName: Scalars["String"]; + displayName?: Maybe; description?: Maybe; isList?: Maybe; isHidden?: Maybe; @@ -4716,7 +4802,6 @@ export type GraphQLBatchMigrationUpdateReverseUnionFieldInput = { /** Creating a relational field */ export type GraphQLBatchMigrationCreateRelationalFieldInput = { apiId: Scalars["String"]; - /** either modelApiId or parentApiId needs to be set */ modelApiId?: Maybe; parentApiId?: Maybe; type: GraphQLRelationalFieldType; @@ -4740,7 +4825,6 @@ export type GraphQLBatchMigrationCreateRelationalFieldInput = { /** Creating a component field */ export type GraphQLBatchMigrationCreateComponentFieldInput = { apiId: Scalars["String"]; - /** model or content */ parentApiId: Scalars["String"]; displayName: Scalars["String"]; description?: Maybe; @@ -4771,7 +4855,6 @@ export type GraphQLBatchMigrationCreateReverseRelationalFieldInput = { export type GraphQLBatchMigrationUpdateRelationalFieldInput = { apiId: Scalars["String"]; newApiId?: Maybe; - /** either modelApiId or parentApiId needs to be set */ modelApiId?: Maybe; parentApiId?: Maybe; displayName?: Maybe; @@ -4803,7 +4886,6 @@ export type GraphQLBatchMigrationUpdateComponentFieldInput = { export type GraphQLBatchMigrationUpdateSimpleFieldInput = { apiId: Scalars["String"]; newApiId?: Maybe; - /** either modelApiId or parentApiId needs to be set */ modelApiId?: Maybe; parentApiId?: Maybe; displayName?: Maybe; @@ -4826,7 +4908,6 @@ export type GraphQLBatchMigrationUpdateSimpleFieldInput = { formExtension?: Maybe; formConfig?: Maybe; tableConfig?: Maybe; - /** id's of embeddable models. */ embeddableModels?: Maybe; }; @@ -4834,7 +4915,6 @@ export type GraphQLBatchMigrationUpdateSimpleFieldInput = { export type GraphQLBatchMigrationUpdateEnumerableFieldInput = { apiId: Scalars["String"]; newApiId?: Maybe; - /** either modelApiId or parentApiId needs to be set */ modelApiId?: Maybe; parentApiId?: Maybe; displayName?: Maybe; @@ -4986,16 +5066,40 @@ export type GraphQLBatchMigrationDeleteRemoteSourceInput = { prefix: Scalars["String"]; }; +/** Creating a custom sidebar element with app element */ +export type GraphQLBatchMigrationCreateCustomSidebarElementInput = { + /** Api Id of the model associated with the custom sidebar element */ + modelApiId: Scalars["String"]; + /** Display name for the sidebar element */ + displayName: Scalars["String"]; + /** Description name for the sidebar element */ + description?: Maybe; + /** Json metadata associated with the sidebar element */ + config?: Maybe; + /** Api Id of the App element to create custom sidebar element with */ + appElementApiId: Scalars["String"]; + /** Api Id of the App */ + appApiId: Scalars["String"]; +}; + +/** Deleting a custom sidebar element created by app element */ +export type GraphQLBatchMigrationDeleteCustomSidebarElementInput = { + /** Api Id of the App */ + appApiId: Scalars["String"]; + /** Api Id of the App element associated with the custom sidebar element */ + appElementApiId: Scalars["String"]; + /** Api Id of the model associated with the custom sidebar element */ + modelApiId: Scalars["String"]; +}; + export type GraphQLBatchMigrationChangeInput = { - /** Models */ + /** creates a new model */ createModel?: Maybe; updateModel?: Maybe; deleteModel?: Maybe; - /** Components */ createComponent?: Maybe; updateComponent?: Maybe; deleteComponent?: Maybe; - /** Fields */ createSimpleField?: Maybe; updateSimpleField?: Maybe; createRemoteField?: Maybe; @@ -5023,19 +5127,21 @@ export type GraphQLBatchMigrationChangeInput = { GraphQLBatchMigrationUpdateEnumerableFieldInput >; deleteField?: Maybe; - /** Enumerations */ + createCustomSidebarElement?: Maybe< + GraphQLBatchMigrationCreateCustomSidebarElementInput + >; + deleteCustomSidebarElement?: Maybe< + GraphQLBatchMigrationDeleteCustomSidebarElementInput + >; createEnumeration?: Maybe; updateEnumeration?: Maybe; deleteEnumeration?: Maybe; - /** Stage */ createStage?: Maybe; deleteStage?: Maybe; updateStage?: Maybe; - /** Locale */ createLocale?: Maybe; deleteLocale?: Maybe; updateLocale?: Maybe; - /** Remote Sources */ createGraphQLRemoteSource?: Maybe< GraphQLBatchMigrationCreateGraphQlRemoteSourceInput >; @@ -5481,6 +5587,12 @@ export type GraphQLMutation = { moveSidebarElement: GraphQLMoveSidebarElementPayload; updateSidebarElement: GraphQLUpdateSidebarElementPayload; resetSidebarElements: GraphQLResetSidebarElementsPayload; + createApp: GraphQLCreateAppPayload; + updateApp: GraphQLUpdateAppPayload; + deleteApp: GraphQLDeleteAppPayload; + createAppInstallation: GraphQLCreateAppInstallationPayload; + updateAppInstallation: GraphQLUpdateAppInstallationPayload; + deleteAppInstallation: GraphQLDeleteAppInstallationPayload; createStage: GraphQLAsyncOperationPayload; updateStage: GraphQLAsyncOperationPayload; deleteStage: GraphQLAsyncOperationPayload; @@ -5845,6 +5957,30 @@ export type GraphQLMutationResetSidebarElementsArgs = { data: GraphQLResetSidebarElementsInput; }; +export type GraphQLMutationCreateAppArgs = { + data: GraphQLCreateAppInput; +}; + +export type GraphQLMutationUpdateAppArgs = { + data: GraphQLUpdateAppInput; +}; + +export type GraphQLMutationDeleteAppArgs = { + data: GraphQLDeleteAppInput; +}; + +export type GraphQLMutationCreateAppInstallationArgs = { + data: GraphQLCreateAppInstallationInput; +}; + +export type GraphQLMutationUpdateAppInstallationArgs = { + data: GraphQLUpdateAppInstallationInput; +}; + +export type GraphQLMutationDeleteAppInstallationArgs = { + data: GraphQLDeleteAppInstallationInput; +}; + export type GraphQLMutationCreateStageArgs = { data: GraphQLCreateStageInput; }; @@ -6064,7 +6200,6 @@ export type GraphQLVercelIntegrationCallbackPayload = { error?: Maybe; }; -/** Base pending project with common information */ export type GraphQLIPendingProject = { id: Scalars["ID"]; name: Scalars["String"]; @@ -6072,13 +6207,11 @@ export type GraphQLIPendingProject = { picture?: Maybe; }; -/** Can clone from project or template */ export type GraphQLCloningFrom = | GraphQLProject | GraphQLTemplate | GraphQLStarterTemplate; -/** Cloning project with source */ export type GraphQLCloningProject = GraphQLIPendingProject & { __typename?: "CloningProject"; id: Scalars["ID"]; @@ -6088,7 +6221,6 @@ export type GraphQLCloningProject = GraphQLIPendingProject & { cloningFrom: GraphQLCloningFrom; }; -/** Add subscription to notify about changes in projects */ export type GraphQLProjectChangeCompletedCloning = { __typename?: "ProjectChangeCompletedCloning"; clonedProject: GraphQLProject; diff --git a/src/migration.ts b/src/migration.ts index 56ae6c6..2e6ed39 100644 --- a/src/migration.ts +++ b/src/migration.ts @@ -8,6 +8,8 @@ import { submitMigration, } from "./util"; import { + GraphQLBatchMigrationCreateComponentInput, + GraphQLBatchMigrationUpdateComponentInput, GraphQLBatchMigrationCreateEnumerationInput, GraphQLBatchMigrationCreateModelInput, GraphQLBatchMigrationUpdateModelInput, @@ -31,6 +33,7 @@ import { import { Stage, StageClass } from "./stage"; import { Locale, LocaleClass } from "./locale"; import { RemoteSource, RemoteSourceClass } from "./remoteSource"; +import { Component, ComponentClass } from "./component"; /** * @ignore @@ -214,6 +217,30 @@ interface Migration { * @param apiId the `apiId` of the locale to delete. */ deleteLocale(apiId: string): void; + + /** + * Fetch an existing component + * @param apiId the `apiId` for the component. + */ + component(apiId: string): Component; + + /** + * Create a new component + * @param args options for the new component. + */ + createComponent(args: GraphQLBatchMigrationCreateComponentInput): Component; + + /** + * Update an existing component + * @param args options for component update. + */ + updateComponent(args: GraphQLBatchMigrationUpdateComponentInput): Component; + + /** + * Delete a component + * @param apiId the `apiId` of the component to delete. + */ + deleteComponent(apiId: string): void; } /** @@ -280,6 +307,29 @@ class MigrationClass implements Migration, ChangeListener { return model; } + component(apiId: string): Component { + const component = new ComponentClass(this, MutationMode.Update, { apiId }); + return component; + } + + createComponent(args: any): Component { + const component = new ComponentClass(this, MutationMode.Create, args); + this.registerChange(component); + return component; + } + + updateComponent(args: any): Component { + const component = new ComponentClass(this, MutationMode.Update, args); + this.registerChange(component); + return component; + } + + deleteComponent(apiId: string) { + const component = new ComponentClass(this, MutationMode.Delete, { apiId }); + this.registerChange(component); + return component; + } + createGraphQLRemoteSource(args: any): RemoteSource { const remoteSource = new RemoteSourceClass( MutationMode.Create, diff --git a/src/model.ts b/src/model.ts index 62a4dfa..2bb14ab 100644 --- a/src/model.ts +++ b/src/model.ts @@ -3,6 +3,7 @@ import { MutationMode, PartialBy, RelationType } from "./util"; import { ChangeItem, ChangeListener, MigrationChange } from "./migration"; import { Renderer } from "./renderer"; import { + GraphQLBatchMigrationCreateComponentFieldInput, GraphQLBatchMigrationCreateEnumerableFieldInput, GraphQLBatchMigrationCreateModelInput, GraphQLBatchMigrationCreateRelationalFieldInput, @@ -11,6 +12,7 @@ import { GraphQLBatchMigrationCreateReverseUnionFieldInput, GraphQLBatchMigrationCreateSimpleFieldInput, GraphQLBatchMigrationCreateUnionFieldInput, + GraphQLBatchMigrationUpdateComponentFieldInput, GraphQLBatchMigrationUpdateEnumerableFieldInput, GraphQLBatchMigrationUpdateModelInput, GraphQLBatchMigrationUpdateRelationalFieldInput, @@ -110,6 +112,9 @@ interface CreateSimpleFieldArgs isHidden?: GraphQLBatchMigrationCreateSimpleFieldInput["isHidden"]; } +/** + * update Simple Field + */ interface UpdateSimpleFieldArgs extends Omit< GraphQLBatchMigrationUpdateSimpleFieldInput, @@ -122,6 +127,71 @@ interface UpdateSimpleFieldArgs isHidden?: GraphQLBatchMigrationCreateSimpleFieldInput["isHidden"]; } +/** + * Create Component Field + */ +interface CreateComponentFieldArgs + extends Omit< + GraphQLBatchMigrationCreateComponentFieldInput, + "componentApiId" + > { + component?: string; + componentApiIds: string[]; + componentApiId: string; +} + +/** + * Update Component Field + */ +interface UpdateComponentFieldArgs + extends Omit< + GraphQLBatchMigrationUpdateComponentFieldInput, + "componentApiId" + > { + component?: string; + componentApiIds: string[]; + componentApiId: string; +} + +/** + * Create Component Field + */ +interface CreateComponentFieldArgs + extends Omit< + GraphQLBatchMigrationCreateComponentFieldInput, + "componentApiId" + > { + component?: string; + componentApiIds: string[]; + componentApiId: string; +} + +/** + * Update Component Union Field + */ +interface UpdateComponentUnionFieldArgs + extends Omit< + GraphQLBatchMigrationUpdateComponentFieldInput, + "componentApiId" + > { + components?: string[]; + componentApiIds: string[]; + componentApiId: string; +} + +/** + * Create Component Union Field + */ +interface CreateComponentUnionFieldArgs + extends Omit< + GraphQLBatchMigrationCreateComponentFieldInput, + "componentApiId" + > { + components?: string[]; + componentApiIds: string[]; + componentApiId: string; +} + interface UpdateRelationalFieldArgs extends Omit< GraphQLBatchMigrationUpdateRelationalFieldInput, @@ -208,6 +278,40 @@ interface Model { */ updateUnionField(field: Omit): Model; + /** + * Add a new component to the model. + * @param field options for the field. + */ + addComponentField( + field: Omit< + CreateComponentFieldArgs, + "modelApiId" | "parentApiId" | "componentApiIds" + > + ): Model; + + /** + * Add a new component union field to the model. + * @param field options for the field. + */ + addComponentUnionField( + field: Omit< + CreateComponentUnionFieldArgs, + "modelApiId" | "parentApiId" | "componentApiId" + > + ): Model; + + /** + * update a component field + * @param field options for the field. + */ + updateComponentField(field: UpdateComponentFieldArgs): Model; + + /** + * update a component field + * @param field options for the field. + */ + updateComponentUnionField(field: UpdateComponentUnionFieldArgs): Model; + /** * Create an enumerable field. * @param field options for the enumerable field. @@ -415,6 +519,89 @@ class ModelClass implements Model, ChangeItem { return this; } + addComponentField(passedFieldArgs: CreateComponentFieldArgs): Model { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + if (!fieldArgs.component) { + throw new Error(`components cannot be empty`); + } + + fieldArgs.componentApiId = fieldArgs?.component; + // remove convenience field + delete fieldArgs.component; + + const field = new Field( + fieldArgs, + MutationMode.Create, + FieldType.ComponentField + ); + this.listener.registerChange(field); + return this; + } + + updateComponentField(passedFieldArgs: UpdateComponentFieldArgs): Model { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + if (!fieldArgs.component) { + throw new Error(`components cannot be empty`); + } + + // remove convenience field + delete fieldArgs.component; + + const field = new Field( + fieldArgs, + MutationMode.Update, + FieldType.ComponentField + ); + this.listener.registerChange(field); + return this; + } + + addComponentUnionField( + passedFieldArgs: CreateComponentUnionFieldArgs + ): Model { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + if (!fieldArgs.components || fieldArgs.components.length === 0) { + throw new Error(`components cannot be empty`); + } + + fieldArgs.componentApiIds = fieldArgs?.components; + // remove convenience field + delete fieldArgs.components; + + const field = new Field( + fieldArgs, + MutationMode.Create, + FieldType.ComponentUnionField + ); + this.listener.registerChange(field); + return this; + } + + updateComponentUnionField( + passedFieldArgs: UpdateComponentUnionFieldArgs + ): Model { + const fieldArgs = { ...passedFieldArgs }; + fieldArgs.parentApiId = this.args.apiId; + if (!fieldArgs.components || fieldArgs.components.length === 0) { + throw new Error(`components cannot be empty`); + } + + fieldArgs.componentApiIds = fieldArgs?.components; + // remove convenience field + delete fieldArgs.components; + + const field = new Field( + fieldArgs, + MutationMode.Update, + FieldType.ComponentUnionField + ); + this.listener.registerChange(field); + return this; + } + addEnumerableField(passedFieldArgs: any): Model { const fieldArgs = { ...passedFieldArgs }; if (!fieldArgs.enumerationApiId) {