@coffer-org/sdk 1.5.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.
@@ -39,6 +39,10 @@ export declare function internalApiToken(o: {
39
39
  key: string;
40
40
  label?: string;
41
41
  }): GroupEl;
42
+ export declare function internalOauthGrants(o: {
43
+ key: string;
44
+ label?: string;
45
+ }): GroupEl;
42
46
  export declare function slug(o: TextPresetOpts & {
43
47
  key: string;
44
48
  }): FieldItem;
@@ -247,5 +251,6 @@ export declare const presets: {
247
251
  dimensions: typeof dimensions;
248
252
  country: typeof country;
249
253
  internalApiToken: typeof internalApiToken;
254
+ internalOauthGrants: typeof internalOauthGrants;
250
255
  };
251
256
  export {};
@@ -65,6 +65,19 @@ export function internalApiToken(o) {
65
65
  ],
66
66
  });
67
67
  }
68
+ export function internalOauthGrants(o) {
69
+ return group({
70
+ key: o.key,
71
+ label: o.label ?? o.key,
72
+ multiple: true,
73
+ view: { kind: 'internalOauthGrants' },
74
+ fields: [
75
+ string({ key: 'clientName' }),
76
+ string({ key: 'createdAt' }),
77
+ string({ key: 'lastUsedAt' }),
78
+ ],
79
+ });
80
+ }
68
81
  const SLUG_RE = /^[a-z0-9-]+$/;
69
82
  export function slug(raw) {
70
83
  const o = normalizeOpts(raw);
@@ -324,4 +337,5 @@ export const presets = {
324
337
  dimensions,
325
338
  country,
326
339
  internalApiToken,
340
+ internalOauthGrants,
327
341
  };
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.5.0",
3
+ "version": "1.7.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"