@stndrds/schema 0.1.0-alpha.63 → 0.1.0-alpha.65
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/{chunk-MUJVBSBL.mjs → chunk-A6T4UUZ2.mjs} +1308 -970
- package/dist/{chunk-KMAKDHCL.js → chunk-TOTUS3YS.js} +1615 -1277
- package/dist/index.d.mts +240 -326
- package/dist/index.d.ts +240 -326
- package/dist/index.js +51 -64
- package/dist/index.mjs +61 -74
- package/dist/{runtime-7G9tZJYC.d.ts → runtime-BgtwoMx5.d.ts} +359 -213
- package/dist/{runtime-C4U2ppAk.d.mts → runtime-DQlTgVZJ.d.mts} +359 -213
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +2 -4
- package/dist/runtime.mjs +1 -3
- package/dist/validation/validators.d.mts +1 -1
- package/dist/validation/validators.d.ts +1 -1
- package/dist/{validators-BIAmz0CD.d.mts → validators-BROsLGn4.d.mts} +47 -122
- package/dist/{validators-BPIB7Miq.d.ts → validators-CEzdvxEq.d.ts} +47 -122
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { IconName, CountryIso3, CurrencyCode, ColorId, MimeType } from '@stndrds/constants';
|
|
3
3
|
import { Uuid } from './utils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -152,9 +152,9 @@ interface FeatureFlagsConfig {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
|
-
* Allowed
|
|
155
|
+
* Allowed attribute types in .qualifyWith()
|
|
156
156
|
*
|
|
157
|
-
* IMPORTANT: Complex types (formula, rollup, relation, file, user, document)
|
|
157
|
+
* IMPORTANT: Complex types (formula, rollup, relation, file, user, document, richtext)
|
|
158
158
|
* are NOT supported to avoid duplicating backend behavior.
|
|
159
159
|
*/
|
|
160
160
|
type PropertyType = "text" | "textarea" | "number" | "checkbox" | "date" | "phone" | "currency" | "status" | "select" | "multiselect" | "rating" | "location";
|
|
@@ -164,132 +164,29 @@ type PropertyType = "text" | "textarea" | "number" | "checkbox" | "date" | "phon
|
|
|
164
164
|
declare const FORBIDDEN_PROPERTY_TYPES: readonly ["formula", "rollup", "relation", "file", "user", "document", "richtext"];
|
|
165
165
|
type ForbiddenPropertyType = (typeof FORBIDDEN_PROPERTY_TYPES)[number];
|
|
166
166
|
/**
|
|
167
|
-
*
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
label?: string;
|
|
172
|
-
required?: boolean;
|
|
173
|
-
description?: string;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Text property definition
|
|
177
|
-
*/
|
|
178
|
-
interface TextPropertyDefinition extends BasePropertyDefinition {
|
|
179
|
-
type: "text";
|
|
180
|
-
minLength?: number;
|
|
181
|
-
maxLength?: number;
|
|
182
|
-
pattern?: string;
|
|
183
|
-
placeholder?: string;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Textarea property definition
|
|
187
|
-
*/
|
|
188
|
-
interface TextareaPropertyDefinition extends BasePropertyDefinition {
|
|
189
|
-
type: "textarea";
|
|
190
|
-
minLength?: number;
|
|
191
|
-
maxLength?: number;
|
|
192
|
-
placeholder?: string;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Number property definition
|
|
196
|
-
*/
|
|
197
|
-
interface NumberPropertyDefinition extends BasePropertyDefinition {
|
|
198
|
-
type: "number";
|
|
199
|
-
min?: number;
|
|
200
|
-
max?: number;
|
|
201
|
-
decimal?: number;
|
|
202
|
-
integer?: boolean;
|
|
203
|
-
placeholder?: string;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Checkbox property definition
|
|
207
|
-
*/
|
|
208
|
-
interface CheckboxPropertyDefinition extends BasePropertyDefinition {
|
|
209
|
-
type: "checkbox";
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Date property definition
|
|
213
|
-
*/
|
|
214
|
-
interface DatePropertyDefinition extends BasePropertyDefinition {
|
|
215
|
-
type: "date";
|
|
216
|
-
includeTime?: boolean;
|
|
217
|
-
min?: string;
|
|
218
|
-
max?: string;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Phone property definition
|
|
222
|
-
*/
|
|
223
|
-
interface PhonePropertyDefinition extends BasePropertyDefinition {
|
|
224
|
-
type: "phone";
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Currency property definition
|
|
228
|
-
*/
|
|
229
|
-
interface CurrencyPropertyDefinition extends BasePropertyDefinition {
|
|
230
|
-
type: "currency";
|
|
231
|
-
currency?: CurrencyCode;
|
|
232
|
-
min?: number;
|
|
233
|
-
max?: number;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Status property definition
|
|
237
|
-
*/
|
|
238
|
-
interface StatusPropertyDefinition extends BasePropertyDefinition {
|
|
239
|
-
type: "status";
|
|
240
|
-
options: Array<Option & {
|
|
241
|
-
group: StatusGroup;
|
|
242
|
-
}>;
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Select property definition
|
|
246
|
-
*/
|
|
247
|
-
interface SelectPropertyDefinition extends BasePropertyDefinition {
|
|
248
|
-
type: "select";
|
|
249
|
-
options: Option[];
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Multiselect property definition
|
|
253
|
-
*/
|
|
254
|
-
interface MultiselectPropertyDefinition extends BasePropertyDefinition {
|
|
255
|
-
type: "multiselect";
|
|
256
|
-
options: Option[];
|
|
257
|
-
maxSelections?: number;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Rating property definition
|
|
261
|
-
*/
|
|
262
|
-
interface RatingPropertyDefinition extends BasePropertyDefinition {
|
|
263
|
-
type: "rating";
|
|
264
|
-
max?: number;
|
|
265
|
-
icon?: IconName;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Location property definition
|
|
269
|
-
*/
|
|
270
|
-
interface LocationPropertyDefinition extends BasePropertyDefinition {
|
|
271
|
-
type: "location";
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Union of all property definitions
|
|
167
|
+
* Union of attribute types allowed as qualified relation properties.
|
|
168
|
+
*
|
|
169
|
+
* These are the same Attribute types used for object attributes,
|
|
170
|
+
* restricted to simple types that don't require complex backend duplication.
|
|
275
171
|
*/
|
|
276
|
-
type
|
|
172
|
+
type PropertyAttribute = TextAttribute | TextAreaAttribute | NumberAttribute | CheckboxAttribute | DateAttribute | PhoneAttribute | CurrencyAttribute | StatusAttribute | SelectAttribute | MultiselectAttribute | RatingAttribute | LocationAttribute;
|
|
277
173
|
/**
|
|
278
|
-
* Schema defining properties for a qualified relation
|
|
174
|
+
* Schema defining properties for a qualified relation.
|
|
175
|
+
*
|
|
176
|
+
* Uses the same Attribute types as object attributes, enabling DRY builders:
|
|
279
177
|
*
|
|
280
178
|
* @example
|
|
281
179
|
* ```typescript
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
* { name: "
|
|
286
|
-
* { name: "
|
|
287
|
-
*
|
|
288
|
-
* };
|
|
180
|
+
* relation({ name: "companies", label: "Companies" })
|
|
181
|
+
* .to("companies").many()
|
|
182
|
+
* .qualifyWith(
|
|
183
|
+
* select({ name: "role", label: "Role" }).options([...]).required(),
|
|
184
|
+
* number({ name: "shares", label: "Shares" }).min(0),
|
|
185
|
+
* )
|
|
289
186
|
* ```
|
|
290
187
|
*/
|
|
291
188
|
interface PropertySchema {
|
|
292
|
-
definitions:
|
|
189
|
+
definitions: PropertyAttribute[];
|
|
293
190
|
}
|
|
294
191
|
|
|
295
192
|
type AttributeType = "text" | "textarea" | "richtext" | "number" | "checkbox" | "date" | "phone" | "currency" | "status" | "location" | "select" | "multiselect" | "file" | "user" | "relation" | "rating" | "formula" | "rollup" | "document";
|
|
@@ -448,6 +345,20 @@ interface UserAttribute extends BaseAttribute<string> {
|
|
|
448
345
|
* Use with `.toAny()` builder method
|
|
449
346
|
*/
|
|
450
347
|
declare const RELATION_TARGET_ANY: "*";
|
|
348
|
+
/**
|
|
349
|
+
* Configuration for bilateral synchronization (bidirectional relations)
|
|
350
|
+
*/
|
|
351
|
+
interface BilateralConfig {
|
|
352
|
+
/** Target object containing the inverse attribute */
|
|
353
|
+
object: string;
|
|
354
|
+
/** Name of the inverse attribute */
|
|
355
|
+
attribute: string;
|
|
356
|
+
/** Optional cardinality override (inferred by default) */
|
|
357
|
+
cardinality?: "one" | "many";
|
|
358
|
+
/** When true, this side owns the storage direction for qualified properties.
|
|
359
|
+
* Set to false on the inverse side (enriched at read time). */
|
|
360
|
+
storageOwner?: boolean;
|
|
361
|
+
}
|
|
451
362
|
/**
|
|
452
363
|
* Target object for a relation - defines which objects can be linked
|
|
453
364
|
*/
|
|
@@ -479,6 +390,8 @@ interface RelationAttributeBase extends Omit<BaseAttribute<unknown>, "defaultVal
|
|
|
479
390
|
targets: RelationTarget[];
|
|
480
391
|
/** Optional properties schema for qualified relations */
|
|
481
392
|
properties?: PropertySchema;
|
|
393
|
+
/** Configuration for bilateral synchronization (opt-in) */
|
|
394
|
+
bilateral?: BilateralConfig;
|
|
482
395
|
}
|
|
483
396
|
/**
|
|
484
397
|
* Single relation attribute (one-to-one or many-to-one)
|
|
@@ -537,6 +450,18 @@ type RelationAttribute = SingleRelationAttribute | MultiRelationAttribute;
|
|
|
537
450
|
* Universal relations have `targets: [{ object: "*" }]`
|
|
538
451
|
*/
|
|
539
452
|
declare function isUniversalRelation(attr: RelationAttribute): boolean;
|
|
453
|
+
/**
|
|
454
|
+
* Check if a relation attribute has bilateral synchronization enabled
|
|
455
|
+
*/
|
|
456
|
+
declare function isBilateralRelation(attr: RelationAttribute): attr is RelationAttribute & {
|
|
457
|
+
bilateral: BilateralConfig;
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* Infer the cardinality of the inverse relation
|
|
461
|
+
* - one → many (contact.company ↔ company.contacts)
|
|
462
|
+
* - many → many (contact.tags ↔ tag.contacts)
|
|
463
|
+
*/
|
|
464
|
+
declare function inferInverseCardinality(cardinality: "one" | "many"): "one" | "many";
|
|
540
465
|
interface TextAreaAttribute extends BaseAttribute<string> {
|
|
541
466
|
type: "textarea";
|
|
542
467
|
}
|
|
@@ -1628,4 +1553,4 @@ declare function isRecordComplete(objectDef: ObjectDefinition, data: Record<stri
|
|
|
1628
1553
|
*/
|
|
1629
1554
|
declare function computeRecordStatus(objectDef: ObjectDefinition, data: Record<string, unknown>): CompletionStatus;
|
|
1630
1555
|
|
|
1631
|
-
export {
|
|
1556
|
+
export { RESERVED_ATTRIBUTE_NAMES as $, type Attribute as A, type BilateralConfig as B, type CheckboxAttribute as C, type DateAttribute as D, type NumberUnit as E, type FeatureGate as F, type DateFormat as G, type DateValue as H, type Phone as I, type Currency as J, type Location as K, type LocationAttribute as L, type MultiselectAttribute as M, type NumberAttribute as N, type Option as O, type PhoneAttribute as P, type LocationGranularity as Q, type RichtextAttribute as R, type StatusAttribute as S, type TextAttribute as T, type UserAttribute as U, RELATION_TARGET_ANY as V, isUniversalRelation as W, isBilateralRelation as X, inferInverseCardinality as Y, type FlagOverride as Z, type FeatureFlagsConfig as _, type DocumentAttribute as a, type ValidationResult as a$, SYSTEM_FIELD_NAMES as a0, type ReservedAttributeName as a1, type SystemFieldName as a2, type Timestamps as a3, type SharingMode as a4, type ObjectAttribute as a5, type CompletionStatus as a6, type ObjectRecord as a7, type PropertyType as a8, FORBIDDEN_PROPERTY_TYPES as a9, getAttributeConfigSchema as aA, validateAttributeConfig as aB, parseAttributeConfig as aC, safeParseAttributeConfig as aD, createTextValidator as aE, createNumberValidator as aF, createCheckboxValidator as aG, createDateValidator as aH, createPhoneValidator as aI, createCurrencyValidator as aJ, createStatusValidator as aK, createSelectValidator as aL, createMultiselectValidator as aM, createLocationValidator as aN, createFileValidator as aO, createUserValidator as aP, createSingleRelationValidator as aQ, createMultiRelationValidator as aR, createRelationValidator as aS, createRatingValidator as aT, createFormulaValidator as aU, createRollupValidator as aV, createTextAreaValidator as aW, createRichtextValidator as aX, createAttributeValidator as aY, createFormAttributeValidator as aZ, createObjectValidator as a_, type ForbiddenPropertyType as aa, type PropertyAttribute as ab, type PropertySchema as ac, formatZodErrors as ad, type ValidationMessages as ae, DEFAULT_VALIDATION_MESSAGES as af, textConfigSchema as ag, textareaConfigSchema as ah, richtextConfigSchema as ai, numberConfigSchema as aj, checkboxConfigSchema as ak, dateConfigSchema as al, phoneConfigSchema as am, currencyConfigSchema as an, statusConfigSchema as ao, locationConfigSchema as ap, selectConfigSchema as aq, multiselectConfigSchema as ar, fileConfigSchema as as, userConfigSchema as at, relationConfigSchema as au, ratingConfigSchema as av, formulaConfigSchema as aw, rollupConfigSchema as ax, documentConfigSchema as ay, attributeConfigSchemas as az, type TextAreaAttribute as b, validateAttribute as b0, validateObject as b1, validateObjectOrThrow as b2, createDraftValidator as b3, validateDraft as b4, validateDraftOrThrow as b5, getMissingRequiredAttributes as b6, isRecordComplete as b7, computeRecordStatus as b8, type RichtextFeature as c, type CurrencyAttribute as d, type SelectAttribute as e, type FileAttribute as f, type RatingAttribute as g, type RelationAttribute as h, type SingleRelationAttribute as i, type MultiRelationAttribute as j, type RelationTarget as k, type FormulaAttribute as l, type FormulaReturnType as m, type RollupAttribute as n, type RollupFunction as o, type AttributeType as p, type ObjectDefinition as q, type FlagValueType as r, type FeatureFlagDefinition as s, type FlagLevel as t, type FeatureFlagsRepository as u, type StaticFlagDefault as v, type ResolvedFlag as w, type StatusGroup as x, type AttributeGroup as y, type BaseAttribute as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stndrds/schema",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.65",
|
|
4
4
|
"description": "Standard schema definitions and utilities",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"jose": "^6.1.3",
|
|
36
36
|
"pdf-lib": "^1.17.1",
|
|
37
37
|
"zod": "^4.2.1",
|
|
38
|
-
"@stndrds/constants": "0.1.0-alpha.
|
|
38
|
+
"@stndrds/constants": "0.1.0-alpha.65"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^25.0.3",
|