@coffer-org/sdk 1.6.0 → 1.7.0

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/shelf.d.ts CHANGED
@@ -43,6 +43,9 @@ export declare function inlineText(m: ShelfDef, row: Record<string, unknown>): s
43
43
  export declare function tableKeys(m: ShelfDef): string[];
44
44
  export declare function groupableFields(m: ShelfDef): string[];
45
45
  export declare function defaultGroupField(m: ShelfDef): string | undefined;
46
+ export declare function coverKey(m: ShelfDef): string | undefined;
47
+ export declare function listKeys(m: ShelfDef): string[];
48
+ export declare function storageColumnsFor(m: ShelfDef, keys: string[]): string[];
46
49
  export declare function buildShape(fields: LayoutEl[], partial: boolean): z.ZodRawShape;
47
50
  export declare function buildZodObject(m: ShelfDef): z.ZodTypeAny;
48
51
  export declare function buildZodObjectPartial(m: ShelfDef): z.ZodTypeAny;
package/dist/shelf.js CHANGED
@@ -132,6 +132,45 @@ export function defaultGroupField(m) {
132
132
  }
133
133
  return groupableFields(m)[0];
134
134
  }
135
+ export function coverKey(m) {
136
+ return fieldEntries(m.fields).find(([, f]) => f.kind === 'cover')?.[0];
137
+ }
138
+ export function listKeys(m) {
139
+ const fm = fieldMap(m.fields);
140
+ const out = [];
141
+ const add = (k) => {
142
+ if (!k || k === 'id' || out.includes(k))
143
+ return;
144
+ if (!fm[k] || fm[k].virtual)
145
+ return;
146
+ out.push(k);
147
+ };
148
+ add(titleKey(m));
149
+ tableKeys(m).forEach(add);
150
+ groupableFields(m).forEach(add);
151
+ inlineKeys(m).forEach(add);
152
+ add(inlineImageKey(m));
153
+ add(coverKey(m));
154
+ const sel = m.views?.select;
155
+ if (sel) {
156
+ add(sel.icon);
157
+ (Array.isArray(sel.title) ? sel.title : [sel.title]).forEach(add);
158
+ add(sel.subtitle);
159
+ }
160
+ return ['id', ...out];
161
+ }
162
+ export function storageColumnsFor(m, keys) {
163
+ const fm = fieldMap(m.fields);
164
+ const out = new Set(['id']);
165
+ for (const k of keys) {
166
+ const f = fm[k];
167
+ if (!f || f.virtual)
168
+ continue;
169
+ for (const [col] of storageColumns(k, f))
170
+ out.add(col);
171
+ }
172
+ return [...out];
173
+ }
135
174
  export function buildShape(fields, partial) {
136
175
  const shape = {};
137
176
  for (const it of fields) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffer-org/sdk",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"