import { Schema } from 'effect';
import * as Mapping from '../../mapping/Mapping.js';
import * as Utils from '../../mapping/Utils.js';
export const TypesyncHypergraphSchemaStatus = /*#__PURE__*/Schema.NullOr(/*#__PURE__*/Schema.Literal(
// the type/property has been synced to the schema file and published to the Knowledge Graph
'published',
// the type/property has been synced to the schema file, but requires publishing to the Knowledge Graph
'synced',
// the type/property exists in the Knowledge Graph, has been added to the users schema through the Typesync UI, but requires syncing to the schema file
'published_not_synced'));
export const TypesyncHypergraphSchemaTypeProperty = /*#__PURE__*/Schema.Union(Mapping.SchemaTypePropertyPrimitive, Mapping.SchemaTypePropertyRelation).pipe(/*#__PURE__*/Schema.extend(/*#__PURE__*/Schema.Struct({
  status: TypesyncHypergraphSchemaStatus
})));
export class TypesyncHypergraphSchemaType extends /*#__PURE__*/Schema.Class('/Hypergraph/cli/models/TypesyncHypergraphSchemaType')({
  ... /*#__PURE__*/Mapping.SchemaType.omit('properties').fields,
  status: TypesyncHypergraphSchemaStatus,
  properties: /*#__PURE__*/Schema.Array(TypesyncHypergraphSchemaTypeProperty).pipe(/*#__PURE__*/Schema.minItems(1), /*#__PURE__*/Schema.filter(Utils.namesAreUnique, {
    identifier: 'DuplicatePropertyNames',
    jsonSchema: {},
    description: 'The property.name must be unique across all properties in the type'
  }))
}) {}
export class TypesyncHypergraphSchema extends /*#__PURE__*/Schema.Class('/Hypergraph/cli/models/TypesyncHypergraphSchema')({
  types: /*#__PURE__*/Schema.Array(TypesyncHypergraphSchemaType).pipe(/*#__PURE__*/Schema.minItems(1), /*#__PURE__*/Schema.filter(Utils.namesAreUnique, {
    identifier: 'DuplicateTypeNames',
    jsonSchema: {},
    description: 'The type.name must be unique across all types in the schema'
  }), /*#__PURE__*/Schema.filter(Mapping.allRelationPropertyTypesExist, {
    identifier: 'AllRelationTypesExist',
    jsonSchema: {},
    description: 'Each type property of dataType RELATION must have a type of the same name in the schema'
  }))
}) {}
/**
 * Extending the hypergraph [Mapping definition](../../mapping/Mapping.ts) to make it an effect Schema instance.
 * Allows decoding as well as passing in the api request payload
 */
export const TypesyncHypergraphMapping = /*#__PURE__*/Schema.Record({
  key: Schema.NonEmptyTrimmedString,
  value: /*#__PURE__*/Schema.Struct({
    typeIds: /*#__PURE__*/Schema.Array(Schema.UUID).pipe(/*#__PURE__*/Schema.minItems(1)),
    properties: /*#__PURE__*/Schema.optional(/*#__PURE__*/Schema.UndefinedOr(/*#__PURE__*/Schema.Record({
      key: Schema.NonEmptyTrimmedString,
      value: Schema.UUID
    }))),
    relations: /*#__PURE__*/Schema.optional(/*#__PURE__*/Schema.UndefinedOr(/*#__PURE__*/Schema.Record({
      key: Schema.NonEmptyTrimmedString,
      value: Schema.UUID
    })))
  })
});
//# sourceMappingURL=Model.js.map