using ZB.MOM.WW.ScadaBridge.Commons.Entities.Instances; using ZB.MOM.WW.ScadaBridge.Commons.Entities.Scripts; using ZB.MOM.WW.ScadaBridge.Commons.Entities.Templates; namespace ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories; public interface ITemplateEngineRepository { // Template /// Retrieves a template by ID. /// The template ID. /// Cancellation token. Task GetTemplateByIdAsync(int id, CancellationToken cancellationToken = default); /// Retrieves a template with its child entities by ID. /// The template ID. /// Cancellation token. Task GetTemplateWithChildrenAsync(int id, CancellationToken cancellationToken = default); /// /// Bulk variant of /// that fetches every template whose matches one of /// in a single SQL/EF query, eager-loading /// Attributes / Alarms / Scripts / Compositions. Resolves the Transport-008 /// N+1 in BundleImporter.PreviewAsync — names that don't match an /// existing template are omitted from the result rather than producing a /// null entry, so callers should look up by name into the returned list. /// /// Template names to load. Duplicate / null / empty names are filtered out. /// Cancellation token. Task> GetTemplatesWithChildrenAsync(IEnumerable names, CancellationToken cancellationToken = default); /// Retrieves all templates. /// Cancellation token. Task> GetAllTemplatesAsync(CancellationToken cancellationToken = default); /// /// Returns every template that contains a composition referencing /// . Each result is eager-loaded with /// its Attributes / Scripts / Compositions so the caller can build a /// CompositionContext without a follow-up round-trip per parent. /// /// The composed template ID. /// Cancellation token. Task> GetTemplatesComposingAsync(int composedTemplateId, CancellationToken cancellationToken = default); /// Adds a new template. /// The template to add. /// Cancellation token. Task AddTemplateAsync(Template template, CancellationToken cancellationToken = default); /// Updates an existing template. /// The template to update. /// Cancellation token. Task UpdateTemplateAsync(Template template, CancellationToken cancellationToken = default); /// Deletes a template by ID. /// The template ID. /// Cancellation token. Task DeleteTemplateAsync(int id, CancellationToken cancellationToken = default); // TemplateAttribute /// Retrieves a template attribute by ID. /// The attribute ID. /// Cancellation token. Task GetTemplateAttributeByIdAsync(int id, CancellationToken cancellationToken = default); /// Retrieves attributes for a template. /// The template ID. /// Cancellation token. Task> GetAttributesByTemplateIdAsync(int templateId, CancellationToken cancellationToken = default); /// Adds a new template attribute. /// The attribute to add. /// Cancellation token. Task AddTemplateAttributeAsync(TemplateAttribute attribute, CancellationToken cancellationToken = default); /// Updates an existing template attribute. /// The attribute to update. /// Cancellation token. Task UpdateTemplateAttributeAsync(TemplateAttribute attribute, CancellationToken cancellationToken = default); /// Deletes a template attribute by ID. /// The attribute ID. /// Cancellation token. Task DeleteTemplateAttributeAsync(int id, CancellationToken cancellationToken = default); // TemplateAlarm /// Retrieves a template alarm by ID. /// The alarm ID. /// Cancellation token. Task GetTemplateAlarmByIdAsync(int id, CancellationToken cancellationToken = default); /// Retrieves alarms for a template. /// The template ID. /// Cancellation token. Task> GetAlarmsByTemplateIdAsync(int templateId, CancellationToken cancellationToken = default); /// Adds a new template alarm. /// The alarm to add. /// Cancellation token. Task AddTemplateAlarmAsync(TemplateAlarm alarm, CancellationToken cancellationToken = default); /// Updates an existing template alarm. /// The alarm to update. /// Cancellation token. Task UpdateTemplateAlarmAsync(TemplateAlarm alarm, CancellationToken cancellationToken = default); /// Deletes a template alarm by ID. /// The alarm ID. /// Cancellation token. Task DeleteTemplateAlarmAsync(int id, CancellationToken cancellationToken = default); // TemplateNativeAlarmSource /// Retrieves a template native alarm source by ID. Task GetTemplateNativeAlarmSourceByIdAsync(int id, CancellationToken cancellationToken = default); /// Retrieves native alarm sources for a template. Task> GetNativeAlarmSourcesByTemplateIdAsync(int templateId, CancellationToken cancellationToken = default); /// Adds a new template native alarm source. Task AddTemplateNativeAlarmSourceAsync(TemplateNativeAlarmSource source, CancellationToken cancellationToken = default); /// Updates an existing template native alarm source. Task UpdateTemplateNativeAlarmSourceAsync(TemplateNativeAlarmSource source, CancellationToken cancellationToken = default); /// Deletes a template native alarm source by ID. Task DeleteTemplateNativeAlarmSourceAsync(int id, CancellationToken cancellationToken = default); // TemplateScript /// Retrieves a template script by ID. /// The script ID. /// Cancellation token. Task GetTemplateScriptByIdAsync(int id, CancellationToken cancellationToken = default); /// Retrieves scripts for a template. /// The template ID. /// Cancellation token. Task> GetScriptsByTemplateIdAsync(int templateId, CancellationToken cancellationToken = default); /// Adds a new template script. /// The script to add. /// Cancellation token. Task AddTemplateScriptAsync(TemplateScript script, CancellationToken cancellationToken = default); /// Updates an existing template script. /// The script to update. /// Cancellation token. Task UpdateTemplateScriptAsync(TemplateScript script, CancellationToken cancellationToken = default); /// Deletes a template script by ID. /// The script ID. /// Cancellation token. Task DeleteTemplateScriptAsync(int id, CancellationToken cancellationToken = default); // TemplateComposition /// Retrieves a template composition by ID. /// The composition ID. /// Cancellation token. Task GetTemplateCompositionByIdAsync(int id, CancellationToken cancellationToken = default); /// Retrieves compositions for a template. /// The template ID. /// Cancellation token. Task> GetCompositionsByTemplateIdAsync(int templateId, CancellationToken cancellationToken = default); /// Adds a new template composition. /// The composition to add. /// Cancellation token. Task AddTemplateCompositionAsync(TemplateComposition composition, CancellationToken cancellationToken = default); /// Updates an existing template composition. /// The composition to update. /// Cancellation token. Task UpdateTemplateCompositionAsync(TemplateComposition composition, CancellationToken cancellationToken = default); /// Deletes a template composition by ID. /// The composition ID. /// Cancellation token. Task DeleteTemplateCompositionAsync(int id, CancellationToken cancellationToken = default); // Instance /// Retrieves an instance by ID. /// The instance ID. /// Cancellation token. Task GetInstanceByIdAsync(int id, CancellationToken cancellationToken = default); /// Retrieves all instances. /// Cancellation token. Task> GetAllInstancesAsync(CancellationToken cancellationToken = default); /// Retrieves instances for a template. /// The template ID. /// Cancellation token. Task> GetInstancesByTemplateIdAsync(int templateId, CancellationToken cancellationToken = default); /// Retrieves instances for a site. /// The site ID. /// Cancellation token. Task> GetInstancesBySiteIdAsync(int siteId, CancellationToken cancellationToken = default); /// Retrieves an instance by unique name. /// The unique instance name. /// Cancellation token. Task GetInstanceByUniqueNameAsync(string uniqueName, CancellationToken cancellationToken = default); /// Adds a new instance. /// The instance to add. /// Cancellation token. Task AddInstanceAsync(Instance instance, CancellationToken cancellationToken = default); /// Updates an existing instance. /// The instance to update. /// Cancellation token. Task UpdateInstanceAsync(Instance instance, CancellationToken cancellationToken = default); /// Deletes an instance by ID. /// The instance ID. /// Cancellation token. Task DeleteInstanceAsync(int id, CancellationToken cancellationToken = default); // InstanceAttributeOverride /// Retrieves attribute overrides for an instance. /// The instance ID. /// Cancellation token. Task> GetOverridesByInstanceIdAsync(int instanceId, CancellationToken cancellationToken = default); /// Adds a new instance attribute override. /// The override to add. /// Cancellation token. Task AddInstanceAttributeOverrideAsync(InstanceAttributeOverride attributeOverride, CancellationToken cancellationToken = default); /// Updates an existing instance attribute override. /// The override to update. /// Cancellation token. Task UpdateInstanceAttributeOverrideAsync(InstanceAttributeOverride attributeOverride, CancellationToken cancellationToken = default); /// Deletes an instance attribute override by ID. /// The override ID. /// Cancellation token. Task DeleteInstanceAttributeOverrideAsync(int id, CancellationToken cancellationToken = default); // InstanceAlarmOverride /// Retrieves alarm overrides for an instance. /// The instance ID. /// Cancellation token. Task> GetAlarmOverridesByInstanceIdAsync(int instanceId, CancellationToken cancellationToken = default); /// Retrieves an alarm override by instance and alarm name. /// The instance ID. /// The alarm canonical name. /// Cancellation token. Task GetAlarmOverrideAsync(int instanceId, string alarmCanonicalName, CancellationToken cancellationToken = default); /// Adds a new instance alarm override. /// The override to add. /// Cancellation token. Task AddInstanceAlarmOverrideAsync(InstanceAlarmOverride alarmOverride, CancellationToken cancellationToken = default); /// Updates an existing instance alarm override. /// The override to update. /// Cancellation token. Task UpdateInstanceAlarmOverrideAsync(InstanceAlarmOverride alarmOverride, CancellationToken cancellationToken = default); /// Deletes an instance alarm override by ID. /// The override ID. /// Cancellation token. Task DeleteInstanceAlarmOverrideAsync(int id, CancellationToken cancellationToken = default); // InstanceNativeAlarmSourceOverride /// Retrieves native alarm source overrides for an instance. Task> GetNativeAlarmSourceOverridesByInstanceIdAsync(int instanceId, CancellationToken cancellationToken = default); /// Retrieves a single native alarm source override by instance + source canonical name. Task GetNativeAlarmSourceOverrideAsync(int instanceId, string sourceCanonicalName, CancellationToken cancellationToken = default); /// Adds a new instance native alarm source override. Task AddInstanceNativeAlarmSourceOverrideAsync(InstanceNativeAlarmSourceOverride ovr, CancellationToken cancellationToken = default); /// Updates an existing instance native alarm source override. Task UpdateInstanceNativeAlarmSourceOverrideAsync(InstanceNativeAlarmSourceOverride ovr, CancellationToken cancellationToken = default); /// Deletes an instance native alarm source override by ID. Task DeleteInstanceNativeAlarmSourceOverrideAsync(int id, CancellationToken cancellationToken = default); // InstanceConnectionBinding /// Retrieves connection bindings for an instance. /// The instance ID. /// Cancellation token. Task> GetBindingsByInstanceIdAsync(int instanceId, CancellationToken cancellationToken = default); /// Adds a new instance connection binding. /// The binding to add. /// Cancellation token. Task AddInstanceConnectionBindingAsync(InstanceConnectionBinding binding, CancellationToken cancellationToken = default); /// Updates an existing instance connection binding. /// The binding to update. /// Cancellation token. Task UpdateInstanceConnectionBindingAsync(InstanceConnectionBinding binding, CancellationToken cancellationToken = default); /// Deletes an instance connection binding by ID. /// The binding ID. /// Cancellation token. Task DeleteInstanceConnectionBindingAsync(int id, CancellationToken cancellationToken = default); // Area /// Retrieves an area by ID. /// The area ID. /// Cancellation token. Task GetAreaByIdAsync(int id, CancellationToken cancellationToken = default); /// Retrieves areas for a site. /// The site ID. /// Cancellation token. Task> GetAreasBySiteIdAsync(int siteId, CancellationToken cancellationToken = default); /// Adds a new area. /// The area to add. /// Cancellation token. Task AddAreaAsync(Area area, CancellationToken cancellationToken = default); /// Updates an existing area. /// The area to update. /// Cancellation token. Task UpdateAreaAsync(Area area, CancellationToken cancellationToken = default); /// Deletes an area by ID. /// The area ID. /// Cancellation token. Task DeleteAreaAsync(int id, CancellationToken cancellationToken = default); // SharedScript /// Retrieves a shared script by ID. /// The script ID. /// Cancellation token. Task GetSharedScriptByIdAsync(int id, CancellationToken cancellationToken = default); /// Retrieves a shared script by name. /// The script name. /// Cancellation token. Task GetSharedScriptByNameAsync(string name, CancellationToken cancellationToken = default); /// Retrieves all shared scripts. /// Cancellation token. Task> GetAllSharedScriptsAsync(CancellationToken cancellationToken = default); /// Adds a new shared script. /// The script to add. /// Cancellation token. Task AddSharedScriptAsync(SharedScript sharedScript, CancellationToken cancellationToken = default); /// Updates an existing shared script. /// The script to update. /// Cancellation token. Task UpdateSharedScriptAsync(SharedScript sharedScript, CancellationToken cancellationToken = default); /// Deletes a shared script by ID. /// The script ID. /// Cancellation token. Task DeleteSharedScriptAsync(int id, CancellationToken cancellationToken = default); // TemplateFolder /// Retrieves a template folder by ID. /// The folder ID. /// Cancellation token. Task GetFolderByIdAsync(int id, CancellationToken cancellationToken = default); /// Retrieves all template folders. /// Cancellation token. Task> GetAllFoldersAsync(CancellationToken cancellationToken = default); /// Adds a new template folder. /// The folder to add. /// Cancellation token. Task AddFolderAsync(TemplateFolder folder, CancellationToken cancellationToken = default); /// Updates an existing template folder. /// The folder to update. /// Cancellation token. Task UpdateFolderAsync(TemplateFolder folder, CancellationToken cancellationToken = default); /// Deletes a template folder by ID. /// The folder ID. /// Cancellation token. Task DeleteFolderAsync(int id, CancellationToken cancellationToken = default); /// Saves pending changes to the database. /// Cancellation token. Task SaveChangesAsync(CancellationToken cancellationToken = default); }