@ufira/vibma 0.3.2 → 1.0.0-rc2

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.
@@ -43,11 +43,20 @@ var flexJson = (inner) => import_zod.z.preprocess((v) => {
43
43
  // src/tools/endpoint.ts
44
44
  function pickFields(obj, fields) {
45
45
  if (fields.includes("*")) return obj;
46
- const keep = /* @__PURE__ */ new Set([...fields, "id", "name", "type"]);
46
+ const identity = ["id", "name", "type"];
47
+ const keep = /* @__PURE__ */ new Set([...fields, ...identity]);
47
48
  const out = {};
48
49
  for (const key of Object.keys(obj)) {
49
50
  if (keep.has(key)) out[key] = obj[key];
50
51
  }
52
+ const requested = fields.filter((f) => !identity.includes(f));
53
+ if (requested.length > 0) {
54
+ const found = requested.filter((f) => f in obj);
55
+ if (found.length === 0) {
56
+ const available = Object.keys(obj).filter((k) => !identity.includes(k));
57
+ out._warning = `Requested fields [${requested.join(", ")}] not found. Available: [${available.join(", ")}]`;
58
+ }
59
+ }
51
60
  return out;
52
61
  }
53
62
  function paginate(items, offset = 0, limit = 100) {
@@ -17,11 +17,20 @@ var flexJson = (inner) => z.preprocess((v) => {
17
17
  // src/tools/endpoint.ts
18
18
  function pickFields(obj, fields) {
19
19
  if (fields.includes("*")) return obj;
20
- const keep = /* @__PURE__ */ new Set([...fields, "id", "name", "type"]);
20
+ const identity = ["id", "name", "type"];
21
+ const keep = /* @__PURE__ */ new Set([...fields, ...identity]);
21
22
  const out = {};
22
23
  for (const key of Object.keys(obj)) {
23
24
  if (keep.has(key)) out[key] = obj[key];
24
25
  }
26
+ const requested = fields.filter((f) => !identity.includes(f));
27
+ if (requested.length > 0) {
28
+ const found = requested.filter((f) => f in obj);
29
+ if (found.length === 0) {
30
+ const available = Object.keys(obj).filter((k) => !identity.includes(k));
31
+ out._warning = `Requested fields [${requested.join(", ")}] not found. Available: [${available.join(", ")}]`;
32
+ }
33
+ }
25
34
  return out;
26
35
  }
27
36
  function paginate(items, offset = 0, limit = 100) {