@coffer-org/sdk 2.2.0 → 2.2.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/countries.js +6 -1
- package/dist/field-presets.js +150 -23
- package/dist/fields.d.ts +2 -2
- package/dist/fields.js +25 -8
- package/package.json +1 -1
package/dist/countries.js
CHANGED
|
@@ -144,7 +144,12 @@ export const COUNTRIES = [
|
|
|
144
144
|
{ code: 'RW', name: 'Руанда', nameRu: 'Руанда', nameEn: 'Rwanda' },
|
|
145
145
|
{ code: 'KN', name: 'Сент-Кітс і Невіс', nameRu: 'Сент-Китс и Невис', nameEn: 'St. Kitts & Nevis' },
|
|
146
146
|
{ code: 'LC', name: 'Сент-Люсія', nameRu: 'Сент-Люсия', nameEn: 'St. Lucia' },
|
|
147
|
-
{
|
|
147
|
+
{
|
|
148
|
+
code: 'VC',
|
|
149
|
+
name: 'Сент-Вінсент і Гренадіни',
|
|
150
|
+
nameRu: 'Сент-Винсент и Гренадины',
|
|
151
|
+
nameEn: 'St. Vincent & Grenadines',
|
|
152
|
+
},
|
|
148
153
|
{ code: 'WS', name: 'Самоа', nameRu: 'Самоа', nameEn: 'Samoa' },
|
|
149
154
|
{ code: 'SM', name: 'Сан-Марино', nameRu: 'Сан-Марино', nameEn: 'San Marino' },
|
|
150
155
|
{ code: 'ST', name: 'Сан-Томе і Принсіпі', nameRu: 'Сан-Томе и Принсипи', nameEn: 'São Tomé & Príncipe' },
|
package/dist/field-presets.js
CHANGED
|
@@ -71,11 +71,7 @@ export function internalOauthGrants(o) {
|
|
|
71
71
|
label: o.label ?? o.key,
|
|
72
72
|
multiple: true,
|
|
73
73
|
view: { kind: 'internalOauthGrants' },
|
|
74
|
-
fields: [
|
|
75
|
-
string({ key: 'clientName' }),
|
|
76
|
-
string({ key: 'createdAt' }),
|
|
77
|
-
string({ key: 'lastUsedAt' }),
|
|
78
|
-
],
|
|
74
|
+
fields: [string({ key: 'clientName' }), string({ key: 'createdAt' }), string({ key: 'lastUsedAt' })],
|
|
79
75
|
});
|
|
80
76
|
}
|
|
81
77
|
const SLUG_RE = /^[a-z0-9-]+$/;
|
|
@@ -164,24 +160,155 @@ export function link(raw) {
|
|
|
164
160
|
const TEL_RE = /^\+?[\d\s()-]{4,}$/;
|
|
165
161
|
const LINK_RE = /^([a-z][a-z0-9+.-]*:\/\/\S+|[\w-]+(\.[\w-]+)+(:\d+)?(\/\S*)?)$/i;
|
|
166
162
|
const CSS_COLOR_NAMES = new Set([
|
|
167
|
-
'aliceblue',
|
|
168
|
-
'
|
|
169
|
-
'
|
|
170
|
-
'
|
|
171
|
-
'
|
|
172
|
-
'
|
|
173
|
-
'
|
|
174
|
-
'
|
|
175
|
-
'
|
|
176
|
-
'
|
|
177
|
-
'
|
|
178
|
-
'
|
|
179
|
-
'
|
|
180
|
-
'
|
|
181
|
-
'
|
|
182
|
-
'
|
|
183
|
-
'
|
|
184
|
-
'
|
|
163
|
+
'aliceblue',
|
|
164
|
+
'antiquewhite',
|
|
165
|
+
'aqua',
|
|
166
|
+
'aquamarine',
|
|
167
|
+
'azure',
|
|
168
|
+
'beige',
|
|
169
|
+
'bisque',
|
|
170
|
+
'black',
|
|
171
|
+
'blanchedalmond',
|
|
172
|
+
'blue',
|
|
173
|
+
'blueviolet',
|
|
174
|
+
'brown',
|
|
175
|
+
'burlywood',
|
|
176
|
+
'cadetblue',
|
|
177
|
+
'chartreuse',
|
|
178
|
+
'chocolate',
|
|
179
|
+
'coral',
|
|
180
|
+
'cornflowerblue',
|
|
181
|
+
'cornsilk',
|
|
182
|
+
'crimson',
|
|
183
|
+
'cyan',
|
|
184
|
+
'darkblue',
|
|
185
|
+
'darkcyan',
|
|
186
|
+
'darkgoldenrod',
|
|
187
|
+
'darkgray',
|
|
188
|
+
'darkgreen',
|
|
189
|
+
'darkgrey',
|
|
190
|
+
'darkkhaki',
|
|
191
|
+
'darkmagenta',
|
|
192
|
+
'darkolivegreen',
|
|
193
|
+
'darkorange',
|
|
194
|
+
'darkorchid',
|
|
195
|
+
'darkred',
|
|
196
|
+
'darksalmon',
|
|
197
|
+
'darkseagreen',
|
|
198
|
+
'darkslateblue',
|
|
199
|
+
'darkslategray',
|
|
200
|
+
'darkslategrey',
|
|
201
|
+
'darkturquoise',
|
|
202
|
+
'darkviolet',
|
|
203
|
+
'deeppink',
|
|
204
|
+
'deepskyblue',
|
|
205
|
+
'dimgray',
|
|
206
|
+
'dimgrey',
|
|
207
|
+
'dodgerblue',
|
|
208
|
+
'firebrick',
|
|
209
|
+
'floralwhite',
|
|
210
|
+
'forestgreen',
|
|
211
|
+
'fuchsia',
|
|
212
|
+
'gainsboro',
|
|
213
|
+
'ghostwhite',
|
|
214
|
+
'gold',
|
|
215
|
+
'goldenrod',
|
|
216
|
+
'gray',
|
|
217
|
+
'green',
|
|
218
|
+
'greenyellow',
|
|
219
|
+
'grey',
|
|
220
|
+
'honeydew',
|
|
221
|
+
'hotpink',
|
|
222
|
+
'indianred',
|
|
223
|
+
'indigo',
|
|
224
|
+
'ivory',
|
|
225
|
+
'khaki',
|
|
226
|
+
'lavender',
|
|
227
|
+
'lavenderblush',
|
|
228
|
+
'lawngreen',
|
|
229
|
+
'lemonchiffon',
|
|
230
|
+
'lightblue',
|
|
231
|
+
'lightcoral',
|
|
232
|
+
'lightcyan',
|
|
233
|
+
'lightgoldenrodyellow',
|
|
234
|
+
'lightgray',
|
|
235
|
+
'lightgreen',
|
|
236
|
+
'lightgrey',
|
|
237
|
+
'lightpink',
|
|
238
|
+
'lightsalmon',
|
|
239
|
+
'lightseagreen',
|
|
240
|
+
'lightskyblue',
|
|
241
|
+
'lightslategray',
|
|
242
|
+
'lightslategrey',
|
|
243
|
+
'lightsteelblue',
|
|
244
|
+
'lightyellow',
|
|
245
|
+
'lime',
|
|
246
|
+
'limegreen',
|
|
247
|
+
'linen',
|
|
248
|
+
'magenta',
|
|
249
|
+
'maroon',
|
|
250
|
+
'mediumaquamarine',
|
|
251
|
+
'mediumblue',
|
|
252
|
+
'mediumorchid',
|
|
253
|
+
'mediumpurple',
|
|
254
|
+
'mediumseagreen',
|
|
255
|
+
'mediumslateblue',
|
|
256
|
+
'mediumspringgreen',
|
|
257
|
+
'mediumturquoise',
|
|
258
|
+
'mediumvioletred',
|
|
259
|
+
'midnightblue',
|
|
260
|
+
'mintcream',
|
|
261
|
+
'mistyrose',
|
|
262
|
+
'moccasin',
|
|
263
|
+
'navajowhite',
|
|
264
|
+
'navy',
|
|
265
|
+
'oldlace',
|
|
266
|
+
'olive',
|
|
267
|
+
'olivedrab',
|
|
268
|
+
'orange',
|
|
269
|
+
'orangered',
|
|
270
|
+
'orchid',
|
|
271
|
+
'palegoldenrod',
|
|
272
|
+
'palegreen',
|
|
273
|
+
'paleturquoise',
|
|
274
|
+
'palevioletred',
|
|
275
|
+
'papayawhip',
|
|
276
|
+
'peachpuff',
|
|
277
|
+
'peru',
|
|
278
|
+
'pink',
|
|
279
|
+
'plum',
|
|
280
|
+
'powderblue',
|
|
281
|
+
'purple',
|
|
282
|
+
'rebeccapurple',
|
|
283
|
+
'red',
|
|
284
|
+
'rosybrown',
|
|
285
|
+
'royalblue',
|
|
286
|
+
'saddlebrown',
|
|
287
|
+
'salmon',
|
|
288
|
+
'sandybrown',
|
|
289
|
+
'seagreen',
|
|
290
|
+
'seashell',
|
|
291
|
+
'sienna',
|
|
292
|
+
'silver',
|
|
293
|
+
'skyblue',
|
|
294
|
+
'slateblue',
|
|
295
|
+
'slategray',
|
|
296
|
+
'slategrey',
|
|
297
|
+
'snow',
|
|
298
|
+
'springgreen',
|
|
299
|
+
'steelblue',
|
|
300
|
+
'tan',
|
|
301
|
+
'teal',
|
|
302
|
+
'thistle',
|
|
303
|
+
'tomato',
|
|
304
|
+
'turquoise',
|
|
305
|
+
'violet',
|
|
306
|
+
'wheat',
|
|
307
|
+
'white',
|
|
308
|
+
'whitesmoke',
|
|
309
|
+
'yellow',
|
|
310
|
+
'yellowgreen',
|
|
311
|
+
'transparent',
|
|
185
312
|
]);
|
|
186
313
|
export function tag(raw) {
|
|
187
314
|
const o = normalizeOpts(raw);
|
package/dist/fields.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export { vmsg, reqErr, typeErr, reqTypeErr, jsonRefined, optionalize, jsonValue, decodeVmsg, validateField } from './fields/validation.ts';
|
|
2
|
+
export { vmsg, reqErr, typeErr, reqTypeErr, jsonRefined, optionalize, jsonValue, decodeVmsg, validateField, } from './fields/validation.ts';
|
|
3
3
|
import type { Condition } from './condition.ts';
|
|
4
4
|
export type { Rules, View, FieldConfig } from './fields/normalize.ts';
|
|
5
5
|
export { normalizeOpts } from './fields/normalize.ts';
|
|
@@ -355,7 +355,7 @@ export declare function triState(o: TriStateOpts & {
|
|
|
355
355
|
value?: undefined;
|
|
356
356
|
}): FieldMeta;
|
|
357
357
|
export interface SelectOpts extends FieldCoreOpts {
|
|
358
|
-
options?:
|
|
358
|
+
options?: string | (OptionItem | string)[];
|
|
359
359
|
}
|
|
360
360
|
export declare function select(o: SelectOpts & {
|
|
361
361
|
key: string;
|
package/dist/fields.js
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { resolveUnits } from "./units.js";
|
|
3
3
|
import { isCurrencyCode } from "./currencies.js";
|
|
4
4
|
import { vmsg, reqErr, typeErr, reqTypeErr, jsonRefined, optionalize, jsonValue } from "./fields/validation.js";
|
|
5
|
-
export { vmsg, reqErr, typeErr, reqTypeErr, jsonRefined, optionalize, jsonValue, decodeVmsg, validateField } from "./fields/validation.js";
|
|
5
|
+
export { vmsg, reqErr, typeErr, reqTypeErr, jsonRefined, optionalize, jsonValue, decodeVmsg, validateField, } from "./fields/validation.js";
|
|
6
6
|
export { normalizeOpts } from "./fields/normalize.js";
|
|
7
7
|
import { normalizeOpts } from "./fields/normalize.js";
|
|
8
8
|
import { presets } from "./field-presets.js";
|
|
@@ -185,7 +185,13 @@ export function applyMultiple(base, multiple) {
|
|
|
185
185
|
if (!multiple)
|
|
186
186
|
return base;
|
|
187
187
|
const s = multipleZod(base.zod);
|
|
188
|
-
return {
|
|
188
|
+
return {
|
|
189
|
+
...base,
|
|
190
|
+
column: 'text',
|
|
191
|
+
hints: { ...base.hints, multiple: true },
|
|
192
|
+
json: true,
|
|
193
|
+
zod: optionalize(s, base.required),
|
|
194
|
+
};
|
|
189
195
|
}
|
|
190
196
|
export function string(raw) {
|
|
191
197
|
const o = normalizeOpts(raw);
|
|
@@ -421,11 +427,14 @@ export function triState(raw) {
|
|
|
421
427
|
};
|
|
422
428
|
return wrapKey(o, meta);
|
|
423
429
|
}
|
|
430
|
+
function toOptionItem(o) {
|
|
431
|
+
return typeof o === 'string' ? { value: o, title: o } : o;
|
|
432
|
+
}
|
|
424
433
|
export function select(raw) {
|
|
425
434
|
const o = normalizeOpts(raw);
|
|
426
435
|
const required = o.required ?? false;
|
|
427
436
|
const source = typeof o.options === 'string' ? o.options : null;
|
|
428
|
-
const inlineOpts = Array.isArray(o.options) ? o.options : [];
|
|
437
|
+
const inlineOpts = Array.isArray(o.options) ? o.options.map(toOptionItem) : [];
|
|
429
438
|
const s = inlineOpts.length > 0
|
|
430
439
|
? z.enum(inlineOpts.map((x) => x.value), { error: () => vmsg('enum') })
|
|
431
440
|
: z.string(reqErr());
|
|
@@ -455,7 +464,10 @@ export function relation(raw) {
|
|
|
455
464
|
});
|
|
456
465
|
}
|
|
457
466
|
else {
|
|
458
|
-
s = z.coerce
|
|
467
|
+
s = z.coerce
|
|
468
|
+
.number()
|
|
469
|
+
.int()
|
|
470
|
+
.positive({ message: vmsg('int') });
|
|
459
471
|
}
|
|
460
472
|
const meta = {
|
|
461
473
|
kind: 'relation',
|
|
@@ -509,9 +521,7 @@ export function check(raw) {
|
|
|
509
521
|
const required = o.required ?? false;
|
|
510
522
|
const multiple = o.multiple ?? false;
|
|
511
523
|
const slots = o.slots && o.slots.length > 0 ? o.slots : [''];
|
|
512
|
-
const contentFields = o.fields?.length
|
|
513
|
-
? o.fields
|
|
514
|
-
: [string({ key: 'text', label: 'core.fields.text' })];
|
|
524
|
+
const contentFields = o.fields?.length ? o.fields : [string({ key: 'text', label: 'core.fields.text' })];
|
|
515
525
|
const contentKeys = new Set();
|
|
516
526
|
for (const f of contentFields) {
|
|
517
527
|
if (contentKeys.has(f.key))
|
|
@@ -525,7 +535,14 @@ export function check(raw) {
|
|
|
525
535
|
const checkFields = slots.map((label, i) => boolean({ key: `check${i}`, label: label || 'core.fields.check' }));
|
|
526
536
|
if (multiple) {
|
|
527
537
|
const fields = [...checkFields, ...contentFields];
|
|
528
|
-
return group({
|
|
538
|
+
return group({
|
|
539
|
+
key: o.key,
|
|
540
|
+
label: o.label ?? o.key,
|
|
541
|
+
multiple: true,
|
|
542
|
+
required: required,
|
|
543
|
+
fields,
|
|
544
|
+
view: { kind: 'checklist' },
|
|
545
|
+
});
|
|
529
546
|
}
|
|
530
547
|
const shape = {};
|
|
531
548
|
const columns = {};
|