@coffer-org/plugin-telegram 2.3.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/schema.js CHANGED
@@ -4946,7 +4946,8 @@ function source(raw) {
4946
4946
  hints: {
4947
4947
  ext,
4948
4948
  maxBytes,
4949
- noEditControl: true
4949
+ noEditControl: true,
4950
+ ...o.key ? { fileName: o.key } : {}
4950
4951
  },
4951
4952
  zod: optionalize(s, required)
4952
4953
  });
@@ -6074,6 +6075,15 @@ function wrapKey(opts, meta) {
6074
6075
  ...m,
6075
6076
  hidden: opts.hidden
6076
6077
  };
6078
+ if (opts.derive) m = {
6079
+ ...m,
6080
+ derive: opts.derive,
6081
+ derived: true,
6082
+ hints: {
6083
+ ...m.hints,
6084
+ noEditControl: true
6085
+ }
6086
+ };
6077
6087
  if (opts.key) return {
6078
6088
  key: opts.key,
6079
6089
  type: m
@@ -6412,10 +6422,27 @@ function select(raw) {
6412
6422
  zod: optionalize(s, required)
6413
6423
  }, o.multiple ?? false));
6414
6424
  }
6425
+ /**
6426
+ * Reject anything beyond a flat equality map: an operator key (`$in`, `$and`, …), an
6427
+ * object-valued entry (which is how a nested operator like `{ type: { $in: [...] } }`
6428
+ * would smuggle itself in), or an explicit `undefined` value all throw, naming the
6429
+ * offending key. `undefined` is rejected alongside objects because it would otherwise
6430
+ * slip through every later layer unnoticed: `Condition` types it as a valid value,
6431
+ * `conditionKeys` skips it so compose validates nothing against the target shelf, and
6432
+ * the picker's query-string builder turns it into the literal string `'undefined'`
6433
+ * (an empty picker with no error anywhere).
6434
+ */
6435
+ function assertFlatEqualityFilter(filter) {
6436
+ for (const [key, value] of Object.entries(filter)) {
6437
+ if (key.startsWith("$")) throw new Error(`[relation] filter key '${key}' is an operator — only flat equality is allowed here`);
6438
+ if (value === void 0 || value !== null && typeof value === "object") throw new Error(`[relation] filter key '${key}' has a non-scalar value — only flat equality is allowed here`);
6439
+ }
6440
+ }
6415
6441
  function relation(raw) {
6416
6442
  const o = normalizeOpts(raw);
6417
6443
  const required = o.required ?? false;
6418
6444
  const multi = o.multiple ?? false;
6445
+ if (raw.options.filter) assertFlatEqualityFilter(raw.options.filter);
6419
6446
  let s;
6420
6447
  if (multi) s = unknown().superRefine((raw, ctx) => {
6421
6448
  const arr = jsonValue(raw);
@@ -6437,7 +6464,8 @@ function relation(raw) {
6437
6464
  },
6438
6465
  relation: {
6439
6466
  library: raw.options.library,
6440
- shelf: raw.options.shelf
6467
+ shelf: raw.options.shelf,
6468
+ ...raw.options.filter && { filter: raw.options.filter }
6441
6469
  },
6442
6470
  ...multi && { json: true },
6443
6471
  zod: optionalize(s, required)
@@ -6596,6 +6624,47 @@ function measured(raw) {
6596
6624
  zod: optionalize(s, required)
6597
6625
  });
6598
6626
  }
6627
+ function unit(raw) {
6628
+ const o = normalizeOpts(raw);
6629
+ const required = o.required ?? false;
6630
+ const units = resolveUnits(o.options);
6631
+ const s = string$1(reqErr()).refine((v) => units.some((u) => u.value === v), { message: vmsg("measured_unit") });
6632
+ return wrapKey(o, {
6633
+ kind: "unit",
6634
+ label: o.label ?? "",
6635
+ required,
6636
+ prim: "select",
6637
+ column: "text",
6638
+ hints: { source: typeof o.options === "string" ? o.options : null },
6639
+ options: units.map((u) => ({
6640
+ value: u.value,
6641
+ title: u.label
6642
+ })),
6643
+ zod: optionalize(s, required)
6644
+ });
6645
+ }
6646
+ function amount(raw) {
6647
+ const o = normalizeOpts(raw);
6648
+ const required = o.required ?? false;
6649
+ const cfg = o.config ?? {};
6650
+ let s = number(typeErr());
6651
+ if (cfg.min != null) s = s.min(cfg.min, { message: vmsg("min", { min: cfg.min }) });
6652
+ if (cfg.max != null) s = s.max(cfg.max, { message: vmsg("max", { max: cfg.max }) });
6653
+ return wrapKey(o, {
6654
+ kind: "amount",
6655
+ label: o.label ?? "",
6656
+ required,
6657
+ prim: "number",
6658
+ column: "real",
6659
+ hints: {
6660
+ unitFrom: o.unitFrom,
6661
+ min: cfg.min,
6662
+ max: cfg.max,
6663
+ step: cfg.step ?? "any"
6664
+ },
6665
+ zod: optionalize(s, required)
6666
+ });
6667
+ }
6599
6668
  function money(raw) {
6600
6669
  const o = normalizeOpts(raw);
6601
6670
  const required = o.required ?? false;
@@ -7073,6 +7142,8 @@ var PRIMITIVES = {
7073
7142
  json,
7074
7143
  check,
7075
7144
  measured,
7145
+ unit,
7146
+ amount,
7076
7147
  money,
7077
7148
  code,
7078
7149
  geo,
@@ -7118,7 +7189,7 @@ var field = new Proxy({}, {
7118
7189
  has: (_t, k) => k in composedField()
7119
7190
  });
7120
7191
  function toClient(field) {
7121
- const { kind, label, required, prim, hints, options, relation, virtual, json, hidden } = field;
7192
+ const { kind, label, required, prim, hints, options, relation, virtual, json, hidden, derived } = field;
7122
7193
  return {
7123
7194
  kind,
7124
7195
  label,
@@ -7129,7 +7200,8 @@ function toClient(field) {
7129
7200
  relation,
7130
7201
  virtual,
7131
7202
  json,
7132
- hidden
7203
+ hidden,
7204
+ derived
7133
7205
  };
7134
7206
  }
7135
7207
  //#endregion
@@ -0,0 +1,23 @@
1
+ {
2
+ "telegram": {
3
+ "plugin": {
4
+ "label": "Telegram bot",
5
+ "description": "Connects Telegram to the orchestrator via GramJS."
6
+ },
7
+ "settings": {
8
+ "label": "Bot settings",
9
+ "api_id": "API ID",
10
+ "api_hash": "API Hash",
11
+ "bot_token": "Bot token",
12
+ "phone": "Phone number",
13
+ "reasoning_display": "Reasoning display",
14
+ "reasoning_display_off": "Hidden",
15
+ "reasoning_display_collapsible": "Collapsible block",
16
+ "reasoning_display_separate": "Separate messages"
17
+ },
18
+ "model": {
19
+ "prompt": "Choose a model:",
20
+ "confirm": "Done"
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "telegram": {
3
+ "plugin": {
4
+ "label": "Telegram-бот",
5
+ "description": "Подключает Telegram к оркестратору через GramJS."
6
+ },
7
+ "settings": {
8
+ "label": "Настройки бота",
9
+ "api_id": "API ID",
10
+ "api_hash": "API Hash",
11
+ "bot_token": "Токен бота",
12
+ "phone": "Номер телефона",
13
+ "reasoning_display": "Показ рассуждений",
14
+ "reasoning_display_off": "Не показывать",
15
+ "reasoning_display_collapsible": "Свёрнутым блоком",
16
+ "reasoning_display_separate": "Отдельными сообщениями"
17
+ },
18
+ "model": {
19
+ "prompt": "Выберите модель:",
20
+ "confirm": "Готово"
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "telegram": {
3
+ "plugin": {
4
+ "label": "Telegram-бот",
5
+ "description": "Підключає Telegram до оркестратора через GramJS."
6
+ },
7
+ "settings": {
8
+ "label": "Налаштування бота",
9
+ "api_id": "API ID",
10
+ "api_hash": "API Hash",
11
+ "bot_token": "Токен бота",
12
+ "phone": "Номер телефону",
13
+ "reasoning_display": "Показ міркувань",
14
+ "reasoning_display_off": "Не показувати",
15
+ "reasoning_display_collapsible": "Згорнутим блоком",
16
+ "reasoning_display_separate": "Окремими повідомленнями"
17
+ },
18
+ "model": {
19
+ "prompt": "Оберіть модель:",
20
+ "confirm": "Готово"
21
+ }
22
+ }
23
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@coffer-org/plugin-telegram",
3
- "version": "2.3.0",
3
+ "version": "3.0.1",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
7
7
  },
8
8
  "files": [
9
- "dist"
9
+ "dist",
10
+ "locales"
10
11
  ],
11
12
  "exports": {
12
13
  ".": {
@@ -25,9 +26,9 @@
25
26
  "test": "node --import tsx --test \"src/runtime/*.test.ts\""
26
27
  },
27
28
  "dependencies": {
28
- "@coffer-org/plugin-orchestrator": "^2.4.0",
29
- "@coffer-org/sdk": "^2.2.1",
30
- "@coffer-org/server": "^2.7.0",
29
+ "@coffer-org/plugin-orchestrator": "^3.1.1",
30
+ "@coffer-org/sdk": "^3.0.0",
31
+ "@coffer-org/server": "^3.0.0",
31
32
  "input": "^1.0.1",
32
33
  "teleproto": "^1.228.1"
33
34
  },