From 943ccd7c29ce4cb2a236f43c7e667e49b7165298 Mon Sep 17 00:00:00 2001 From: BadMadJohn Date: Wed, 25 Nov 2026 10:12:35 +0500 Subject: [PATCH 1/5] feat(1c-metadata-manage): meta-compile `modules: false` skips the empty module stubs meta-compile always wrote empty ObjectModule / ManagerModule / ValueManagerModule / RecordSetModule files for the types that have them, so a report on a DCS with no code needed them deleted by hand. The top-level key `modules: false` (default true) skips them without creating Ext/ for them. Module.bsl of CommonModule / HTTPService / WebService and CommandModule.bsl of CommonCommand are unaffected; existing files are never deleted. Documented in meta-dsl-spec.md and meta-manage.md. Co-Authored-By: Claude Opus 5.5 --- .../1c-metadata-manage/docs/CHANGELOG.md | 4 +++ .../1c-metadata-manage/docs/meta-manage.md | 2 ++ .../tools/1c-meta-compile/meta-dsl-spec.md | 1 + .../1c-meta-compile/scripts/meta-compile.ps1 | 19 ++++++++---- tools/tests/metadata-tools-regression.ps1 | 30 +++++++++++++++++++ 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/content/skills/1c-metadata-manage/docs/CHANGELOG.md b/content/skills/1c-metadata-manage/docs/CHANGELOG.md index 951675b6..46c07ade 100644 --- a/content/skills/1c-metadata-manage/docs/CHANGELOG.md +++ b/content/skills/1c-metadata-manage/docs/CHANGELOG.md @@ -460,6 +460,10 @@ The PowerShell scripts under `tools/1c-interface-manage/scripts/` were refreshed ## meta-manage.md +### Local feature `2026-11-25` — `modules: false` + +`meta-compile` v1.130 → **v1.131**, local: it always wrote empty `Ext/ObjectModule.bsl`, `ManagerModule.bsl`, `ValueManagerModule.bsl` and `RecordSetModule.bsl` stubs for the types that have them, so a report on a DCS with no code needed the files deleted by hand. The top-level definition key `modules: false` (default `true`) skips them and creates no `Ext/` directory just for them. `Module.bsl` of CommonModule / HTTPService / WebService and `CommandModule.bsl` of CommonCommand are not affected, existing files are never deleted. A non-boolean value is refused before anything is written. Pinned by `tools/tests/metadata-tools-regression.ps1`. + ### Upstream sync 2026-11-17 (4fc37e1) `meta-compile` v1.126 → **v1.130**, `meta-edit` v1.73 → **v1.77** (both runtimes), `meta-validate` v1.45 → **v1.47** (both runtimes), `meta-info` v1.16 → **v1.17**. `meta-remove` did not change. `meta-decompile` is not vendored. diff --git a/content/skills/1c-metadata-manage/docs/meta-manage.md b/content/skills/1c-metadata-manage/docs/meta-manage.md index f739874a..b35da208 100644 --- a/content/skills/1c-metadata-manage/docs/meta-manage.md +++ b/content/skills/1c-metadata-manage/docs/meta-manage.md @@ -68,6 +68,8 @@ The **complete `meta-compile` DSL grammar** — every object type with its type- } ``` +Object modules: by default the compiler creates empty `Ext/ObjectModule.bsl` / `ManagerModule.bsl` / `ValueManagerModule.bsl` / `RecordSetModule.bsl` stubs for the types that have them. Pass `"modules": false` to skip them (a report on a DCS with no code): `{ "type": "Report", "name": "Sales", "modules": false }`. It does not affect `Module.bsl` of CommonModule / HTTPService / WebService or `CommandModule.bsl` of CommonCommand (there the module is the object's content), and it never deletes an existing file. + ### Attributes — Shorthand ``` diff --git a/content/skills/1c-metadata-manage/tools/1c-meta-compile/meta-dsl-spec.md b/content/skills/1c-metadata-manage/tools/1c-meta-compile/meta-dsl-spec.md index 21c21ef8..b4c423c4 100644 --- a/content/skills/1c-metadata-manage/tools/1c-meta-compile/meta-dsl-spec.md +++ b/content/skills/1c-metadata-manage/tools/1c-meta-compile/meta-dsl-spec.md @@ -32,6 +32,7 @@ JSON DSL для описания объектов метаданных конф | `name` | string | да | Имя объекта (идентификатор 1С) | | `synonym` | string | нет | Синоним; если не указан — авто из CamelCase (§2) | | `comment` | string | нет | Комментарий | +| `modules` | boolean | нет | Локально: `false` — не создавать пустые заготовки `Ext/ObjectModule.bsl`, `ManagerModule.bsl`, `ValueManagerModule.bsl`, `RecordSetModule.bsl` (отчёт на СКД без кода; каталог `Ext/` ради них не создаётся). По умолчанию `true`. Не действует на `Module.bsl` общих модулей и сервисов и `CommandModule.bsl` общей команды: там модуль и есть содержимое объекта. Существующие файлы модулей не удаляются. | Дополнительные поля зависят от типа (§7). diff --git a/content/skills/1c-metadata-manage/tools/1c-meta-compile/scripts/meta-compile.ps1 b/content/skills/1c-metadata-manage/tools/1c-meta-compile/scripts/meta-compile.ps1 index 8850adb5..ccd026f9 100644 --- a/content/skills/1c-metadata-manage/tools/1c-meta-compile/scripts/meta-compile.ps1 +++ b/content/skills/1c-metadata-manage/tools/1c-meta-compile/scripts/meta-compile.ps1 @@ -1,10 +1,12 @@ -# meta-compile v1.130 — Compile 1C metadata object from JSON +# meta-compile v1.131 — Compile 1C metadata object from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Local: an existing object is refused unless -Force (upstream only warns; a recompile # gives the object a new uuid). NEW_OBJECT_POSITION and SUPPORT_GUARD come from .dev.env # first (.v8-project.json is the fallback); the support guard fails closed on an # unreadable Ext/ParentConfigurations.bin. An object left unregistered (no # Configuration.xml / ChildObjects) exits 3. Batch mode re-runs the same PowerShell edition. +# Local (2026-11-25): top-level `modules: false` skips the empty ObjectModule / ManagerModule / +# ValueManagerModule / RecordSetModule stubs (a report on a DCS with no code). [CmdletBinding(PositionalBinding=$false)] param( [Parameter(Mandatory)] @@ -644,6 +646,13 @@ if (-not $def.name) { $objName = "$($def.name)" +# Ключ `modules` (дефолт true): false — не создавать пустые заготовки ObjectModule / ManagerModule / +# ValueManagerModule / RecordSetModule (отчёт на СКД без кода). На Module.bsl общих модулей и сервисов +# и CommandModule.bsl общей команды не влияет: модуль там и есть содержимое объекта. +# Читается здесь, до первой записи: неверное значение — ошибка без файлов. +$createObjectModules = Get-DslBool $def @('modules') $true + + # --- 2. XML helpers --- $script:xml = New-Object System.Text.StringBuilder 32768 @@ -5810,7 +5819,7 @@ $typesWithValueManagerModule = @("Constant") # Types with Module.bsl (general) $typesWithModule = @("CommonModule","HTTPService","WebService") -if ($objType -in $typesWithObjectModule) { +if ($createObjectModules -and $objType -in $typesWithObjectModule) { $modulePath = Join-Path $extDir "ObjectModule.bsl" if (-not (Test-Path $modulePath)) { Ensure-ExtDir @@ -5818,7 +5827,7 @@ if ($objType -in $typesWithObjectModule) { $modulesCreated += $modulePath } } -if ($objType -in $typesWithManagerModule) { +if ($createObjectModules -and $objType -in $typesWithManagerModule) { $modulePath = Join-Path $extDir "ManagerModule.bsl" if (-not (Test-Path $modulePath)) { Ensure-ExtDir @@ -5826,7 +5835,7 @@ if ($objType -in $typesWithManagerModule) { $modulesCreated += $modulePath } } -if ($objType -in $typesWithValueManagerModule) { +if ($createObjectModules -and $objType -in $typesWithValueManagerModule) { $modulePath = Join-Path $extDir "ValueManagerModule.bsl" if (-not (Test-Path $modulePath)) { Ensure-ExtDir @@ -5834,7 +5843,7 @@ if ($objType -in $typesWithValueManagerModule) { $modulesCreated += $modulePath } } -if ($objType -in $typesWithRecordSetModule) { +if ($createObjectModules -and $objType -in $typesWithRecordSetModule) { $modulePath = Join-Path $extDir "RecordSetModule.bsl" if (-not (Test-Path $modulePath)) { Ensure-ExtDir diff --git a/tools/tests/metadata-tools-regression.ps1 b/tools/tests/metadata-tools-regression.ps1 index 5861aef6..3e74ed1c 100644 --- a/tools/tests/metadata-tools-regression.ps1 +++ b/tools/tests/metadata-tools-regression.ps1 @@ -1086,6 +1086,36 @@ Register-Case 'meta-compile: a brand-new type group lands in canonical type orde Assert-Equal 1 $delta.Added.Count "registration must add exactly one line, added: $($delta.Added -join ' | ')" } +# Writes a definition JSON next to the fixture and compiles it; returns the tool run. +function Invoke-MetaCompileJson([string]$Work, [string]$Json, [string]$FileName = 'def.json', [string[]]$Extra = @()) { + [System.IO.File]::WriteAllText((Join-Path $Work $FileName), $Json, (New-Object System.Text.UTF8Encoding($false))) + return (Invoke-Tool $MetaCompile (@('-JsonPath', (Join-Path $Work $FileName), '-OutputDir', $Work) + $Extra) $Work) +} + +Register-Case 'meta-compile: modules=false skips the empty object / manager module stubs, default keeps them' { + param($Work) + Copy-Fixture 'config-dump' $Work "`n" + $run = Invoke-MetaCompileJson $Work '{"type":"Report","name":"NoCodeReport","modules":false}' 'no-modules.json' + Assert-Equal 0 $run.ExitCode "meta-compile modules=false (stderr: $($run.StdErr))" + Assert-True (Test-Path -LiteralPath (Join-Path $Work 'Reports\NoCodeReport.xml')) 'the report XML was not written' + Assert-True (-not (Test-Path -LiteralPath (Join-Path $Work 'Reports\NoCodeReport\Ext\ObjectModule.bsl'))) 'ObjectModule.bsl was created despite modules=false' + Assert-True (-not (Test-Path -LiteralPath (Join-Path $Work 'Reports\NoCodeReport\Ext\ManagerModule.bsl'))) 'ManagerModule.bsl was created despite modules=false' + + $run = Invoke-MetaCompileJson $Work '{"type":"Report","name":"CodeReport"}' 'with-modules.json' + Assert-Equal 0 $run.ExitCode "meta-compile default modules (stderr: $($run.StdErr))" + Assert-True (Test-Path -LiteralPath (Join-Path $Work 'Reports\CodeReport\Ext\ObjectModule.bsl')) 'default: ObjectModule.bsl is missing' + Assert-True (Test-Path -LiteralPath (Join-Path $Work 'Reports\CodeReport\Ext\ManagerModule.bsl')) 'default: ManagerModule.bsl is missing' + + # modules=false never touches the module of a common module: there the module is the object's content. + $run = Invoke-MetaCompileJson $Work '{"type":"CommonModule","name":"NoStubModule","modules":false}' 'common-module.json' + Assert-Equal 0 $run.ExitCode "meta-compile CommonModule modules=false (stderr: $($run.StdErr))" + Assert-True (Test-Path -LiteralPath (Join-Path $Work 'CommonModules\NoStubModule\Ext\Module.bsl')) 'CommonModule Module.bsl must stay' + + $run = Invoke-MetaCompileJson $Work '{"type":"Report","name":"BadFlag","modules":"maybe"}' 'bad-flag.json' + Assert-True ($run.ExitCode -ne 0) 'a non-boolean modules value was accepted' + Assert-True (-not (Test-Path -LiteralPath (Join-Path $Work 'Reports\BadFlag.xml'))) 'a refused definition wrote the report' +} + Register-Case 'meta-compile: re-registering the same object is a no-op' { param($Work) Copy-Fixture 'config-dump' $Work "`n" From 0363315a1a843e76a7a5907d2b5f982ff0807da9 Mon Sep 17 00:00:00 2001 From: BadMadJohn Date: Wed, 25 Nov 2026 10:13:10 +0500 Subject: [PATCH 2/5] feat(1c-metadata-manage): meta-compile writes Ext/Schedule.xml for a ScheduledJob `schedule` Only the object properties of a ScheduledJob were written, so no tool could set a schedule and agents copied Schedule.xml from a neighbouring job. The new `schedule` key (beginTime, endTime, completionTime, beginDate, endDate, daysRepeatPeriod, weeksPeriod, repeatPeriodInDay, repeatPause, completionInterval, dayInMonth, weekDayInMonth, weekDays, months) writes the file in the Designer shape (UTF-8 BOM, CRLF, version = detected format). Without the key nothing changes. An unknown key or a bad value is refused before anything is written. DetailedDailySchedules is not supported. Regression cases cover the file, the absent key and the refusal. Co-Authored-By: Claude Opus 5.5 --- .../1c-metadata-manage/docs/CHANGELOG.md | 4 + .../1c-metadata-manage/docs/meta-manage.md | 2 + .../tools/1c-meta-compile/meta-dsl-spec.md | 29 ++++++ .../1c-meta-compile/scripts/meta-compile.ps1 | 96 ++++++++++++++++++- tools/tests/metadata-tools-regression.ps1 | 61 ++++++++++++ 5 files changed, 190 insertions(+), 2 deletions(-) diff --git a/content/skills/1c-metadata-manage/docs/CHANGELOG.md b/content/skills/1c-metadata-manage/docs/CHANGELOG.md index 46c07ade..a19a846d 100644 --- a/content/skills/1c-metadata-manage/docs/CHANGELOG.md +++ b/content/skills/1c-metadata-manage/docs/CHANGELOG.md @@ -460,6 +460,10 @@ The PowerShell scripts under `tools/1c-interface-manage/scripts/` were refreshed ## meta-manage.md +### Local feature `2026-11-25` — ScheduledJob `schedule` writes `Ext/Schedule.xml` + +`meta-compile` v1.131 → **v1.132**, local: only the object properties of a `ScheduledJob` were written, so no tool could set a schedule and agents copied `Ext/Schedule.xml` from a neighbouring job. The new key `schedule` (all sub-keys optional: `beginTime` / `endTime` / `completionTime`, `beginDate` / `endDate`, `daysRepeatPeriod`, `weeksPeriod`, `repeatPeriodInDay`, `repeatPause`, `completionInterval`, `dayInMonth`, `weekDayInMonth`, `weekDays`, `months`) writes `ScheduledJobs//Ext/Schedule.xml` in the Designer shape (UTF-8 BOM, tabs, CRLF, `version` = detected format). No key, no file. An unknown sub-key or an out-of-range value is refused before anything is written; `schedule` on another object type is refused. `ent:DetailedDailySchedules` is out of scope. Pinned by `tools/tests/metadata-tools-regression.ps1`; verified by loading the result into a file infobase on 8.3.24 and dumping it back. + ### Local feature `2026-11-25` — `modules: false` `meta-compile` v1.130 → **v1.131**, local: it always wrote empty `Ext/ObjectModule.bsl`, `ManagerModule.bsl`, `ValueManagerModule.bsl` and `RecordSetModule.bsl` stubs for the types that have them, so a report on a DCS with no code needed the files deleted by hand. The top-level definition key `modules: false` (default `true`) skips them and creates no `Ext/` directory just for them. `Module.bsl` of CommonModule / HTTPService / WebService and `CommandModule.bsl` of CommonCommand are not affected, existing files are never deleted. A non-boolean value is refused before anything is written. Pinned by `tools/tests/metadata-tools-regression.ps1`. diff --git a/content/skills/1c-metadata-manage/docs/meta-manage.md b/content/skills/1c-metadata-manage/docs/meta-manage.md index b35da208..7a774e41 100644 --- a/content/skills/1c-metadata-manage/docs/meta-manage.md +++ b/content/skills/1c-metadata-manage/docs/meta-manage.md @@ -70,6 +70,8 @@ The **complete `meta-compile` DSL grammar** — every object type with its type- Object modules: by default the compiler creates empty `Ext/ObjectModule.bsl` / `ManagerModule.bsl` / `ValueManagerModule.bsl` / `RecordSetModule.bsl` stubs for the types that have them. Pass `"modules": false` to skip them (a report on a DCS with no code): `{ "type": "Report", "name": "Sales", "modules": false }`. It does not affect `Module.bsl` of CommonModule / HTTPService / WebService or `CommandModule.bsl` of CommonCommand (there the module is the object's content), and it never deletes an existing file. +Scheduled job: add `"schedule"` to write `Ext/Schedule.xml` (without it no file is written and the job has no schedule): `{ "type": "ScheduledJob", "name": "LoadRates", "methodName": "Rates.Load", "use": true, "schedule": { "beginTime": "08:15", "weekDays": [1,2,3,4,5] } }`. Keys (all optional): `beginTime`, `endTime`, `completionTime` (`HH:MM[:SS]`), `beginDate`, `endDate` (`YYYY-MM-DD`), `daysRepeatPeriod`, `weeksPeriod`, `repeatPeriodInDay` (seconds; `600` = every 10 minutes during the day), `repeatPause`, `completionInterval`, `dayInMonth` (0–31), `weekDayInMonth` (0–5), `weekDays` (1–7, default all), `months` (1–12, default all). Detailed daily schedules (`DetailedDailySchedules`) are not supported. An unknown key or a bad value is refused before anything is written. Full table: [`meta-dsl-spec.md`](../tools/1c-meta-compile/meta-dsl-spec.md) §7.9. + ### Attributes — Shorthand ``` diff --git a/content/skills/1c-metadata-manage/tools/1c-meta-compile/meta-dsl-spec.md b/content/skills/1c-metadata-manage/tools/1c-meta-compile/meta-dsl-spec.md index b4c423c4..0e2c6cec 100644 --- a/content/skills/1c-metadata-manage/tools/1c-meta-compile/meta-dsl-spec.md +++ b/content/skills/1c-metadata-manage/tools/1c-meta-compile/meta-dsl-spec.md @@ -1140,9 +1140,38 @@ ChildObjects и модулей. | `predefined` | `false` | Predefined | | `restartCountOnFailure` | `3` | RestartCountOnFailure | | `restartIntervalOnFailure` | `10` | RestartIntervalOnFailure | +| `schedule` | нет | Локально: объект, по которому пишется `Ext/Schedule.xml` (см. ниже). Нет ключа — файла нет | Без ChildObjects и модулей. +#### `schedule` — расписание (`ScheduledJobs/<Имя>/Ext/Schedule.xml`) + +Все ключи необязательные, имена — camelCase. Неизвестный ключ или значение вне диапазона — ошибка в stderr, exit 1, ничего не записано. Подробные дневные расписания (`ent:DetailedDailySchedules`) не поддерживаются. Формат файла берётся из конфигурации (`version` = формат выгрузки). + +| Ключ | Умолчание | Атрибут / элемент `Schedule` | Значение | +|------|-----------|------------------------------|----------| +| `beginTime` | `00:00:00` | BeginTime | `HH:MM:SS`, допускается `HH:MM` | +| `endTime` | `00:00:00` | EndTime | то же | +| `completionTime` | `00:00:00` | CompletionTime | то же | +| `beginDate` | `0001-01-01` | BeginDate | `YYYY-MM-DD` | +| `endDate` | `0001-01-01` | EndDate | `YYYY-MM-DD` | +| `daysRepeatPeriod` | `1` | DaysRepeatPeriod | целое ≥ 0 | +| `weeksPeriod` | `1` | WeeksPeriod | целое ≥ 0 | +| `repeatPeriodInDay` | `0` | RepeatPeriodInDay | секунды между запусками в течение дня (`600` — каждые 10 минут); `0` — раз в день | +| `repeatPause` | `0` | RepeatPause | секунды, 0–86400 | +| `completionInterval` | `0` | CompletionInterval | секунды, 0–86400 | +| `dayInMonth` | `0` | DayInMonth | 0–31 | +| `weekDayInMonth` | `0` | WeekDayInMonth | 0–5 | +| `weekDays` | все: `[1,2,3,4,5,6,7]` | `ent:WeekDays` | массив 1–7 (1 — понедельник); `[]` пишет `` | +| `months` | все: `[1..12]` | `ent:Months` | массив 1–12; `[]` пишет `` | + +```json +{ "type": "ScheduledJob", "name": "ЗагрузкаКурсов", "methodName": "РаботаСКурсами.Загрузить", "use": true, + "schedule": { "beginTime": "08:15", "weekDays": [1,2,3,4,5] } } +``` + +Каждые 10 минут в течение дня: `"schedule": { "repeatPeriodInDay": 600 }`. + Формат `methodName`: `"МодульСервер.Процедура"` — при компиляции авто-дополняется до `CommonModule.МодульСервер.Процедура`. Если уже содержит `CommonModule.` — оставляется как есть. ```json diff --git a/content/skills/1c-metadata-manage/tools/1c-meta-compile/scripts/meta-compile.ps1 b/content/skills/1c-metadata-manage/tools/1c-meta-compile/scripts/meta-compile.ps1 index ccd026f9..d0894683 100644 --- a/content/skills/1c-metadata-manage/tools/1c-meta-compile/scripts/meta-compile.ps1 +++ b/content/skills/1c-metadata-manage/tools/1c-meta-compile/scripts/meta-compile.ps1 @@ -1,4 +1,4 @@ -# meta-compile v1.131 — Compile 1C metadata object from JSON +# meta-compile v1.132 — Compile 1C metadata object from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Local: an existing object is refused unless -Force (upstream only warns; a recompile # gives the object a new uuid). NEW_OBJECT_POSITION and SUPPORT_GUARD come from .dev.env @@ -6,7 +6,8 @@ # unreadable Ext/ParentConfigurations.bin. An object left unregistered (no # Configuration.xml / ChildObjects) exits 3. Batch mode re-runs the same PowerShell edition. # Local (2026-11-25): top-level `modules: false` skips the empty ObjectModule / ManagerModule / -# ValueManagerModule / RecordSetModule stubs (a report on a DCS with no code). +# ValueManagerModule / RecordSetModule stubs (a report on a DCS with no code); ScheduledJob key +# `schedule` writes Ext/Schedule.xml (validated before any write). [CmdletBinding(PositionalBinding=$false)] param( [Parameter(Mandatory)] @@ -646,12 +647,87 @@ if (-not $def.name) { $objName = "$($def.name)" +# --- Расписание регламентного задания (ключ `schedule`) → Ext/Schedule.xml --- +# Разбирается и проверяется ДО любой записи: неверный ключ или значение — ошибка в stderr, exit 1, +# файлов нет. Подробные дневные расписания (ent:DetailedDailySchedules) не поддержаны. +function Get-ScheduleParams($sched) { + $fail = { param($m) [Console]::Error.WriteLine("[ERROR] schedule: $m"); exit 1 } + if ($sched -isnot [System.Management.Automation.PSCustomObject] -and $sched -isnot [System.Collections.IDictionary]) { + & $fail "expected an object, e.g. {""beginTime"": ""08:15"", ""weekDays"": [1,2,3,4,5]}" + } + $known = @('beginTime','endTime','completionTime','beginDate','endDate','daysRepeatPeriod','weeksPeriod', + 'repeatPeriodInDay','repeatPause','completionInterval','dayInMonth','weekDayInMonth','weekDays','months') + $given = @{} + $names = if ($sched -is [System.Collections.IDictionary]) { @($sched.Keys) } else { @($sched.PSObject.Properties | ForEach-Object { $_.Name }) } + foreach ($n in $names) { + $canon = $known | Where-Object { $_ -ceq $n } | Select-Object -First 1 + if (-not $canon) { & $fail "unknown key '$n'. Valid: $($known -join ', ')" } + $given[$canon] = if ($sched -is [System.Collections.IDictionary]) { $sched[$n] } else { $sched.PSObject.Properties[$n].Value } + } + $p = [ordered]@{} + foreach ($k in 'beginTime','endTime','completionTime') { + $v = if ($given.ContainsKey($k) -and $null -ne $given[$k]) { "$($given[$k])".Trim() } else { '00:00:00' } + if ($v -match '^(\d{1,2}):(\d{2})$') { $v = "${v}:00" } + if ($v -notmatch '^(\d{1,2}):(\d{2}):(\d{2})$' -or [int]$Matches[1] -gt 23 -or [int]$Matches[2] -gt 59 -or [int]$Matches[3] -gt 59) { + & $fail "$k = ""$($given[$k])"": expected HH:MM:SS (or HH:MM), 00:00:00..23:59:59" + } + $p[$k] = '{0:00}:{1}:{2}' -f [int]$Matches[1], $Matches[2], $Matches[3] + } + foreach ($k in 'beginDate','endDate') { + $v = if ($given.ContainsKey($k) -and $null -ne $given[$k]) { "$($given[$k])".Trim() } else { '0001-01-01' } + $dt = [datetime]::MinValue + if ($v -notmatch '^\d{4}-\d{2}-\d{2}$' -or -not [datetime]::TryParseExact($v, 'yyyy-MM-dd', [Globalization.CultureInfo]::InvariantCulture, [Globalization.DateTimeStyles]::None, [ref]$dt)) { + & $fail "$k = ""$($given[$k])"": expected a date YYYY-MM-DD" + } + $p[$k] = $v + } + $ints = [ordered]@{ daysRepeatPeriod = @(1, 0, 1000000); weeksPeriod = @(1, 0, 1000000); repeatPeriodInDay = @(0, 0, 86400); + repeatPause = @(0, 0, 86400); completionInterval = @(0, 0, 86400); dayInMonth = @(0, 0, 31); weekDayInMonth = @(0, 0, 5) } + foreach ($k in $ints.Keys) { + $def0, $min, $max = $ints[$k] + $v = $def0 + if ($given.ContainsKey($k) -and $null -ne $given[$k]) { + $raw = $given[$k] + $isInt = ($raw -is [int] -or $raw -is [long]) -or ($raw -is [string] -and $raw -match '^\d+$') + if (-not $isInt) { & $fail "$k = ${raw}: expected an integer $min..$max" } + $v = [long]"$raw" + if ($v -lt $min -or $v -gt $max) { & $fail "$k = ${v}: expected an integer $min..$max" } + } + $p[$k] = "$v" + } + foreach ($lk in @(@('weekDays', 7), @('months', 12))) { + $k = $lk[0]; $max = $lk[1] + $all = (1..$max) -join ' ' + if (-not $given.ContainsKey($k) -or $null -eq $given[$k]) { $p[$k] = $all; continue } + $vals = @() + foreach ($e in @($given[$k])) { + $isInt = ($e -is [int] -or $e -is [long]) -or ($e -is [string] -and $e -match '^\d+$') + if (-not $isInt -or [long]"$e" -lt 1 -or [long]"$e" -gt $max) { + & $fail "$k contains ""$e"": expected integers 1..$max" + } + $vals += [int]"$e" + } + $p[$k] = (@($vals | Sort-Object -Unique) -join ' ') + } + return $p +} # Ключ `modules` (дефолт true): false — не создавать пустые заготовки ObjectModule / ManagerModule / # ValueManagerModule / RecordSetModule (отчёт на СКД без кода). На Module.bsl общих модулей и сервисов # и CommandModule.bsl общей команды не влияет: модуль там и есть содержимое объекта. # Читается здесь, до первой записи: неверное значение — ошибка без файлов. $createObjectModules = Get-DslBool $def @('modules') $true +$scheduleParams = $null +$schedProp = $null +if ($def -is [System.Collections.IDictionary]) { if ($def.Contains('schedule')) { $schedProp = @{ v = $def['schedule'] } } } +elseif ($def.PSObject.Properties['schedule']) { $schedProp = @{ v = $def.PSObject.Properties['schedule'].Value } } +if ($schedProp -and $null -ne $schedProp.v) { + if ($objType -ne 'ScheduledJob') { + [Console]::Error.WriteLine("[ERROR] schedule is only valid for type ScheduledJob (got $objType)") + exit 1 + } + $scheduleParams = Get-ScheduleParams $schedProp.v +} # --- 2. XML helpers --- @@ -5959,6 +6035,22 @@ if ($objType -eq "BusinessProcess") { } } +# Расписание регламентного задания (Ext/Schedule.xml) — только при ключе `schedule`; параметры разобраны выше. +if ($objType -eq "ScheduledJob" -and $scheduleParams) { + $sp = $scheduleParams + Ensure-ExtDir + $schedPath = Join-Path $extDir "Schedule.xml" + $schedNs = 'xmlns="http://v8.1c.ru/8.3/xcf/extrnprops" xmlns:ent="http://v8.1c.ru/8.1/data/enterprise" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' + $schedAttrs = "BeginDate=`"$($sp.beginDate)`" EndDate=`"$($sp.endDate)`" BeginTime=`"$($sp.beginTime)`" EndTime=`"$($sp.endTime)`" CompletionTime=`"$($sp.completionTime)`" CompletionInterval=`"$($sp.completionInterval)`" RepeatPeriodInDay=`"$($sp.repeatPeriodInDay)`" RepeatPause=`"$($sp.repeatPause)`" WeekDayInMonth=`"$($sp.weekDayInMonth)`" DayInMonth=`"$($sp.dayInMonth)`" WeeksPeriod=`"$($sp.weeksPeriod)`" DaysRepeatPeriod=`"$($sp.daysRepeatPeriod)`"" + $schedXml = "`r`n`r`n`t`r`n" + foreach ($lt in @(@('WeekDays', $sp.weekDays), @('Months', $sp.months))) { + $schedXml += if ($lt[1]) { "`t`t$($lt[1])`r`n" } else { "`t`t`r`n" } + } + $schedXml += "`t`r`n`r`n" + Write-XmlFileKeepEol $schedPath $schedXml $enc + $modulesCreated += $schedPath +} + # Предопределённые элементы (Ext/Predefined.xml). Root-элемент — по типу. Пусто/нет ключа → файл не создаём. $predefRootByType = @{ 'Catalog' = 'CatalogPredefinedItems'; 'ChartOfCharacteristicTypes' = 'PlanOfCharacteristicKindPredefinedItems' } if ($objType -eq 'ChartOfAccounts' -and $def.predefined -and @($def.predefined).Count -gt 0) { diff --git a/tools/tests/metadata-tools-regression.ps1 b/tools/tests/metadata-tools-regression.ps1 index 3e74ed1c..efd7d5fb 100644 --- a/tools/tests/metadata-tools-regression.ps1 +++ b/tools/tests/metadata-tools-regression.ps1 @@ -1116,6 +1116,67 @@ Register-Case 'meta-compile: modules=false skips the empty object / manager modu Assert-True (-not (Test-Path -LiteralPath (Join-Path $Work 'Reports\BadFlag.xml'))) 'a refused definition wrote the report' } +Register-Case 'meta-compile: ScheduledJob schedule writes Ext/Schedule.xml in the Designer shape' { + param($Work) + Copy-Fixture 'config-dump' $Work "`n" + $json = '{"type":"ScheduledJob","name":"TestJob","methodName":"TestModule.Run","schedule":{"beginTime":"08:15","weekDays":[1,2,3,4,5],"repeatPeriodInDay":600}}' + $run = Invoke-MetaCompileJson $Work $json 'job.json' + Assert-Equal 0 $run.ExitCode "meta-compile ScheduledJob (stderr: $($run.StdErr))" + $sched = Join-Path $Work 'ScheduledJobs\TestJob\Ext\Schedule.xml' + Assert-True (Test-Path -LiteralPath $sched) 'Ext/Schedule.xml was not written' + $facts = Get-FileFacts $sched + Assert-True $facts.Bom 'Schedule.xml has no UTF-8 BOM' + Assert-Equal 0 $facts.LoneLf 'Schedule.xml must use CRLF only' + Assert-True ($facts.Crlf -gt 0) 'Schedule.xml has no CRLF' + $doc = New-Object System.Xml.XmlDocument + $doc.LoadXml($facts.Text) + $root = $doc.DocumentElement + Assert-Equal 'JobSchedule' $root.LocalName 'root element' + Assert-Equal '2.17' $root.GetAttribute('version') 'version follows the configuration format' + $node = $root.FirstChild + while ($node -and $node.NodeType -ne 'Element') { $node = $node.NextSibling } + Assert-Equal 'Schedule' $node.LocalName 'child element' + Assert-Equal '08:15:00' $node.GetAttribute('BeginTime') 'BeginTime' + Assert-Equal '00:00:00' $node.GetAttribute('EndTime') 'EndTime' + Assert-Equal '600' $node.GetAttribute('RepeatPeriodInDay') 'RepeatPeriodInDay' + Assert-Equal '0' $node.GetAttribute('RepeatPause') 'RepeatPause' + Assert-Equal '0001-01-01' $node.GetAttribute('BeginDate') 'BeginDate' + Assert-Equal '1' $node.GetAttribute('WeeksPeriod') 'WeeksPeriod' + Assert-Equal '1' $node.GetAttribute('DaysRepeatPeriod') 'DaysRepeatPeriod' + Assert-Equal '1 2 3 4 5' ($node.SelectSingleNode("*[local-name()='WeekDays']").InnerText) 'WeekDays' + Assert-Equal '1 2 3 4 5 6 7 8 9 10 11 12' ($node.SelectSingleNode("*[local-name()='Months']").InnerText) 'Months' + Assert-True ($facts.Text -match '\t') 'attribute order of differs from Designer' +} + +Register-Case 'meta-compile: ScheduledJob without schedule writes no Schedule.xml' { + param($Work) + Copy-Fixture 'config-dump' $Work "`n" + $run = Invoke-MetaCompileJson $Work '{"type":"ScheduledJob","name":"PlainJob","methodName":"TestModule.Run"}' 'plain-job.json' + Assert-Equal 0 $run.ExitCode "meta-compile ScheduledJob (stderr: $($run.StdErr))" + Assert-True (Test-Path -LiteralPath (Join-Path $Work 'ScheduledJobs\PlainJob.xml')) 'the job XML was not written' + Assert-True (-not (Test-Path -LiteralPath (Join-Path $Work 'ScheduledJobs\PlainJob'))) 'a Schedule directory appeared without a schedule key' +} + +Register-Case 'meta-compile: an invalid ScheduledJob schedule is refused before anything is written' { + param($Work) + Copy-Fixture 'config-dump' $Work "`n" + $configBefore = (Get-FileHash -LiteralPath (Join-Path $Work 'Configuration.xml') -Algorithm SHA256).Hash + $bad = @( + @{ Name = 'BadDay'; Json = '{"type":"ScheduledJob","name":"BadDay","schedule":{"weekDays":[8]}}'; Pattern = 'weekDays' }, + @{ Name = 'BadKey'; Json = '{"type":"ScheduledJob","name":"BadKey","schedule":{"beginTim":"08:15"}}'; Pattern = "unknown key 'beginTim'" }, + @{ Name = 'BadTime'; Json = '{"type":"ScheduledJob","name":"BadTime","schedule":{"beginTime":"25:00"}}'; Pattern = 'beginTime' }, + @{ Name = 'BadDate'; Json = '{"type":"ScheduledJob","name":"BadDate","schedule":{"beginDate":"2026-13-01"}}'; Pattern = 'beginDate' } + ) + foreach ($case in $bad) { + $run = Invoke-MetaCompileJson $Work $case.Json "$($case.Name).json" + Assert-True ($run.ExitCode -ne 0) "$($case.Name): an invalid schedule was accepted" + Assert-True ("$($run.StdErr)" -match [regex]::Escape($case.Pattern)) "$($case.Name): no clear message: $($run.StdErr)" + Assert-True (-not (Test-Path -LiteralPath (Join-Path $Work "ScheduledJobs\$($case.Name).xml"))) "$($case.Name): the job XML was written" + Assert-True (-not (Test-Path -LiteralPath (Join-Path $Work "ScheduledJobs\$($case.Name)"))) "$($case.Name): the job directory was created" + } + Assert-Equal $configBefore (Get-FileHash -LiteralPath (Join-Path $Work 'Configuration.xml') -Algorithm SHA256).Hash 'Configuration.xml changed although every definition was refused' +} + Register-Case 'meta-compile: re-registering the same object is a no-op' { param($Work) Copy-Fixture 'config-dump' $Work "`n" From 7886fcc0e01839c40c9509df24636761878753ee Mon Sep 17 00:00:00 2001 From: BadMadJohn Date: Wed, 25 Nov 2026 10:13:42 +0500 Subject: [PATCH 3/5] docs(1c-metadata-manage): run examples pass -ExecutionPolicy Bypass The docs told agents to run `powershell.exe -NoProfile -File