@stndrds/schema 1.0.0-alpha.199 → 1.0.0-alpha.201
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-AAXJJNY6.mjs +509 -0
- package/dist/chunk-NSM2JPC3.js +515 -0
- package/dist/index.js +13 -311
- package/dist/index.mjs +3 -306
- package/dist/validation/all.js +2 -2
- package/dist/validation/all.mjs +1 -1
- package/dist/validation/config/index.js +4 -4
- package/dist/validation/config/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-HXDDJLHD.mjs +0 -190
- package/dist/chunk-M5QIBMIH.js +0 -194
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { generateId } from './chunk-QY6QFRRV.mjs';
|
|
2
2
|
export { asTenantId, asUserId, deepEqual, generateId, indexBy } from './chunk-QY6QFRRV.mjs';
|
|
3
3
|
import './chunk-SP3PNHYF.mjs';
|
|
4
|
-
|
|
4
|
+
import { parseComputedFormula } from './chunk-AAXJJNY6.mjs';
|
|
5
|
+
export { ComputedFormulaParseError, parseAttributeConfig, parseComputedFormula } from './chunk-AAXJJNY6.mjs';
|
|
5
6
|
import { createObjectValidator, SchemaError, SchemaErrorCode, ValidationError, createAttributeValidator } from './chunk-PMKCDRRO.mjs';
|
|
6
7
|
export { AccessDeniedError, AttributeInUseError, AttributeNotFoundError, ChangeTypeNotSupportedError, ConcurrentModificationError, DestructiveSyncNotAllowedError, DuplicateError, ForbiddenError, MemoryNotFoundError, MigrationTimeoutError, NotFoundError, NotImplementedError, ObjectNotFoundError, ObjectReferencedError, OrphanSystemAttributeError, ProtectedResourceError, ProtectedRoleError, RecordNotFoundError, RecordReferencedError, RepositoryError, RoleNotFoundError, SchemaError, SchemaErrorCode, StorageError, SyncCascadeError, SyncConflictError, SyncError, SystemEntityImmutableError, ValidationError, computeRecordStatus, createFormAttributeValidator, isAttributeInUseError, isNotFoundError, isObjectReferencedError, isProtectedResourceError, isRecordReferencedError, isSchemaError, isValidationError, rejectUnknownAttributesOrThrow, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow } from './chunk-PMKCDRRO.mjs';
|
|
7
8
|
import './chunk-OSSGN43B.mjs';
|
|
@@ -5203,310 +5204,6 @@ function isComputedFunctionName(name) {
|
|
|
5203
5204
|
return Object.hasOwn(COMPUTED_FUNCTIONS, name);
|
|
5204
5205
|
}
|
|
5205
5206
|
|
|
5206
|
-
// src/computed/parser.ts
|
|
5207
|
-
var ComputedFormulaParseError = class extends Error {
|
|
5208
|
-
constructor(message) {
|
|
5209
|
-
super(message);
|
|
5210
|
-
this.name = "ComputedFormulaParseError";
|
|
5211
|
-
}
|
|
5212
|
-
};
|
|
5213
|
-
function parseComputedFormula(expression) {
|
|
5214
|
-
const parser = new Parser(tokenize(expression));
|
|
5215
|
-
const ast = parser.parseExpression();
|
|
5216
|
-
parser.expectEnd();
|
|
5217
|
-
return ast;
|
|
5218
|
-
}
|
|
5219
|
-
function tokenize(expression) {
|
|
5220
|
-
const tokens = [];
|
|
5221
|
-
let index = 0;
|
|
5222
|
-
while (index < expression.length) {
|
|
5223
|
-
const char = expression[index];
|
|
5224
|
-
if (char === " " || char === " " || char === "\n" || char === "\r") {
|
|
5225
|
-
index += 1;
|
|
5226
|
-
continue;
|
|
5227
|
-
}
|
|
5228
|
-
if (char === '"' || char === "'") {
|
|
5229
|
-
const result = scanString(expression, index, char);
|
|
5230
|
-
tokens.push({ kind: "string", value: result.value, position: index });
|
|
5231
|
-
index = result.nextIndex;
|
|
5232
|
-
continue;
|
|
5233
|
-
}
|
|
5234
|
-
if (isDigit(char)) {
|
|
5235
|
-
const result = scanNumber(expression, index);
|
|
5236
|
-
tokens.push({ kind: "number", value: result.value, position: index });
|
|
5237
|
-
index = result.nextIndex;
|
|
5238
|
-
continue;
|
|
5239
|
-
}
|
|
5240
|
-
if (isIdentifierStart(char)) {
|
|
5241
|
-
const result = scanIdentifier(expression, index);
|
|
5242
|
-
const canonical = result.value.toLowerCase();
|
|
5243
|
-
if (canonical === "true") {
|
|
5244
|
-
tokens.push({ kind: "boolean", value: true, position: index });
|
|
5245
|
-
} else if (canonical === "false") {
|
|
5246
|
-
tokens.push({ kind: "boolean", value: false, position: index });
|
|
5247
|
-
} else if (canonical === "null") {
|
|
5248
|
-
tokens.push({ kind: "null", position: index });
|
|
5249
|
-
} else {
|
|
5250
|
-
tokens.push({ kind: "identifier", value: result.value, position: index });
|
|
5251
|
-
}
|
|
5252
|
-
index = result.nextIndex;
|
|
5253
|
-
continue;
|
|
5254
|
-
}
|
|
5255
|
-
const twoChar = expression.slice(index, index + 2);
|
|
5256
|
-
if (twoChar === ">=" || twoChar === "<=" || twoChar === "==" || twoChar === "!=") {
|
|
5257
|
-
tokens.push({ kind: "operator", value: twoChar, position: index });
|
|
5258
|
-
index += 2;
|
|
5259
|
-
continue;
|
|
5260
|
-
}
|
|
5261
|
-
if (char === ">" || char === "<" || char === "+" || char === "-" || char === "*" || char === "/") {
|
|
5262
|
-
tokens.push({ kind: "operator", value: char, position: index });
|
|
5263
|
-
index += 1;
|
|
5264
|
-
continue;
|
|
5265
|
-
}
|
|
5266
|
-
if (char === "(" || char === ")" || char === "," || char === ".") {
|
|
5267
|
-
tokens.push({ kind: "punctuation", value: char, position: index });
|
|
5268
|
-
index += 1;
|
|
5269
|
-
continue;
|
|
5270
|
-
}
|
|
5271
|
-
throw new ComputedFormulaParseError(`Unexpected character "${char}" at position ${index}`);
|
|
5272
|
-
}
|
|
5273
|
-
return tokens;
|
|
5274
|
-
}
|
|
5275
|
-
function scanString(expression, startIndex, delimiter = '"') {
|
|
5276
|
-
let value = "";
|
|
5277
|
-
let index = startIndex + 1;
|
|
5278
|
-
while (index < expression.length) {
|
|
5279
|
-
const char = expression[index];
|
|
5280
|
-
if (char === delimiter) {
|
|
5281
|
-
return { value, nextIndex: index + 1 };
|
|
5282
|
-
}
|
|
5283
|
-
if (char === "\\") {
|
|
5284
|
-
const escaped = expression[index + 1];
|
|
5285
|
-
if (escaped === void 0) {
|
|
5286
|
-
throw new ComputedFormulaParseError(`Unterminated string literal at position ${index}`);
|
|
5287
|
-
}
|
|
5288
|
-
value += decodeEscape(escaped, index);
|
|
5289
|
-
index += 2;
|
|
5290
|
-
continue;
|
|
5291
|
-
}
|
|
5292
|
-
value += char;
|
|
5293
|
-
index += 1;
|
|
5294
|
-
}
|
|
5295
|
-
throw new ComputedFormulaParseError(`Unterminated string literal at position ${startIndex}`);
|
|
5296
|
-
}
|
|
5297
|
-
function decodeEscape(char, position) {
|
|
5298
|
-
switch (char) {
|
|
5299
|
-
case '"':
|
|
5300
|
-
case "\\":
|
|
5301
|
-
return char;
|
|
5302
|
-
case "n":
|
|
5303
|
-
return "\n";
|
|
5304
|
-
case "r":
|
|
5305
|
-
return "\r";
|
|
5306
|
-
case "t":
|
|
5307
|
-
return " ";
|
|
5308
|
-
default:
|
|
5309
|
-
throw new ComputedFormulaParseError(
|
|
5310
|
-
`Unknown escape sequence "\\${char}" at position ${position}`
|
|
5311
|
-
);
|
|
5312
|
-
}
|
|
5313
|
-
}
|
|
5314
|
-
function scanNumber(expression, startIndex) {
|
|
5315
|
-
let index = startIndex;
|
|
5316
|
-
while (index < expression.length && isDigit(expression[index])) {
|
|
5317
|
-
index += 1;
|
|
5318
|
-
}
|
|
5319
|
-
if (expression[index] === ".") {
|
|
5320
|
-
const decimalStart = index;
|
|
5321
|
-
index += 1;
|
|
5322
|
-
if (!isDigit(expression[index])) {
|
|
5323
|
-
throw new ComputedFormulaParseError(`Invalid number literal at position ${decimalStart}`);
|
|
5324
|
-
}
|
|
5325
|
-
while (index < expression.length && isDigit(expression[index])) {
|
|
5326
|
-
index += 1;
|
|
5327
|
-
}
|
|
5328
|
-
}
|
|
5329
|
-
const raw = expression.slice(startIndex, index);
|
|
5330
|
-
const value = Number(raw);
|
|
5331
|
-
if (!Number.isFinite(value)) {
|
|
5332
|
-
throw new ComputedFormulaParseError(`Invalid number literal "${raw}"`);
|
|
5333
|
-
}
|
|
5334
|
-
return { value, nextIndex: index };
|
|
5335
|
-
}
|
|
5336
|
-
function scanIdentifier(expression, startIndex) {
|
|
5337
|
-
let index = startIndex + 1;
|
|
5338
|
-
while (index < expression.length && isIdentifierPart(expression[index])) {
|
|
5339
|
-
index += 1;
|
|
5340
|
-
}
|
|
5341
|
-
return { value: expression.slice(startIndex, index), nextIndex: index };
|
|
5342
|
-
}
|
|
5343
|
-
function isDigit(char) {
|
|
5344
|
-
return char !== void 0 && char >= "0" && char <= "9";
|
|
5345
|
-
}
|
|
5346
|
-
function isIdentifierStart(char) {
|
|
5347
|
-
return char !== void 0 && /[A-Za-z_]/.test(char);
|
|
5348
|
-
}
|
|
5349
|
-
function isIdentifierPart(char) {
|
|
5350
|
-
return char !== void 0 && /[A-Za-z0-9_]/.test(char);
|
|
5351
|
-
}
|
|
5352
|
-
var Parser = class {
|
|
5353
|
-
constructor(tokens) {
|
|
5354
|
-
this.tokens = tokens;
|
|
5355
|
-
this.position = 0;
|
|
5356
|
-
}
|
|
5357
|
-
parseExpression() {
|
|
5358
|
-
return this.parseBinaryExpression(0);
|
|
5359
|
-
}
|
|
5360
|
-
expectEnd() {
|
|
5361
|
-
const token = this.peek();
|
|
5362
|
-
if (token !== void 0) {
|
|
5363
|
-
throw new ComputedFormulaParseError(
|
|
5364
|
-
`Unexpected token ${describeToken(token)} at position ${token.position}`
|
|
5365
|
-
);
|
|
5366
|
-
}
|
|
5367
|
-
}
|
|
5368
|
-
parseBinaryExpression(minPrecedence) {
|
|
5369
|
-
let left = this.parsePrimary();
|
|
5370
|
-
while (true) {
|
|
5371
|
-
const token = this.peek();
|
|
5372
|
-
if (token?.kind !== "operator") {
|
|
5373
|
-
return left;
|
|
5374
|
-
}
|
|
5375
|
-
const precedence = getOperatorPrecedence(token.value);
|
|
5376
|
-
if (precedence < minPrecedence) {
|
|
5377
|
-
return left;
|
|
5378
|
-
}
|
|
5379
|
-
const operator = token.value;
|
|
5380
|
-
this.consume();
|
|
5381
|
-
const right = this.parseBinaryExpression(precedence + 1);
|
|
5382
|
-
left = { kind: "binary", operator, left, right };
|
|
5383
|
-
}
|
|
5384
|
-
}
|
|
5385
|
-
parsePrimary() {
|
|
5386
|
-
const token = this.consume();
|
|
5387
|
-
if (token === void 0) {
|
|
5388
|
-
throw new ComputedFormulaParseError("Unexpected end of expression");
|
|
5389
|
-
}
|
|
5390
|
-
switch (token.kind) {
|
|
5391
|
-
case "string":
|
|
5392
|
-
case "number":
|
|
5393
|
-
case "boolean":
|
|
5394
|
-
return { kind: "literal", value: token.value };
|
|
5395
|
-
case "null":
|
|
5396
|
-
return { kind: "literal", value: null };
|
|
5397
|
-
case "identifier":
|
|
5398
|
-
return this.parseIdentifier(token.value);
|
|
5399
|
-
case "punctuation":
|
|
5400
|
-
if (token.value === "(") {
|
|
5401
|
-
const expression = this.parseExpression();
|
|
5402
|
-
this.expectPunctuation(")");
|
|
5403
|
-
return expression;
|
|
5404
|
-
}
|
|
5405
|
-
break;
|
|
5406
|
-
case "operator":
|
|
5407
|
-
if (token.value === "-") {
|
|
5408
|
-
const next = this.consume();
|
|
5409
|
-
if (next?.kind === "number") {
|
|
5410
|
-
return { kind: "literal", value: -next.value };
|
|
5411
|
-
}
|
|
5412
|
-
}
|
|
5413
|
-
break;
|
|
5414
|
-
}
|
|
5415
|
-
throw new ComputedFormulaParseError(
|
|
5416
|
-
`Expected literal, path, call, or parenthesized expression at position ${token.position}`
|
|
5417
|
-
);
|
|
5418
|
-
}
|
|
5419
|
-
parseIdentifier(identifier) {
|
|
5420
|
-
if (this.matchPunctuation("(")) {
|
|
5421
|
-
const args = [];
|
|
5422
|
-
if (!this.matchPunctuation(")")) {
|
|
5423
|
-
do {
|
|
5424
|
-
args.push(this.parseExpression());
|
|
5425
|
-
} while (this.matchPunctuation(","));
|
|
5426
|
-
this.expectPunctuation(")");
|
|
5427
|
-
}
|
|
5428
|
-
return { kind: "call", functionName: identifier.toLowerCase(), args };
|
|
5429
|
-
}
|
|
5430
|
-
const parts = [identifier];
|
|
5431
|
-
while (this.matchPunctuation(".")) {
|
|
5432
|
-
const next = this.consume();
|
|
5433
|
-
if (next?.kind !== "identifier") {
|
|
5434
|
-
const position = next?.position ?? this.previousPosition();
|
|
5435
|
-
throw new ComputedFormulaParseError(
|
|
5436
|
-
`Expected attribute name after path separator at position ${position}`
|
|
5437
|
-
);
|
|
5438
|
-
}
|
|
5439
|
-
parts.push(next.value);
|
|
5440
|
-
}
|
|
5441
|
-
return { kind: "path", parts };
|
|
5442
|
-
}
|
|
5443
|
-
expectPunctuation(value) {
|
|
5444
|
-
if (!this.matchPunctuation(value)) {
|
|
5445
|
-
const token = this.peek();
|
|
5446
|
-
const position = token?.position ?? this.previousPosition();
|
|
5447
|
-
throw new ComputedFormulaParseError(`Expected "${value}" at position ${position}`);
|
|
5448
|
-
}
|
|
5449
|
-
}
|
|
5450
|
-
matchPunctuation(value) {
|
|
5451
|
-
const token = this.peek();
|
|
5452
|
-
if (token?.kind === "punctuation" && token.value === value) {
|
|
5453
|
-
this.consume();
|
|
5454
|
-
return true;
|
|
5455
|
-
}
|
|
5456
|
-
return false;
|
|
5457
|
-
}
|
|
5458
|
-
peek() {
|
|
5459
|
-
return this.tokens[this.position];
|
|
5460
|
-
}
|
|
5461
|
-
consume() {
|
|
5462
|
-
const token = this.tokens[this.position];
|
|
5463
|
-
this.position += 1;
|
|
5464
|
-
return token;
|
|
5465
|
-
}
|
|
5466
|
-
previousPosition() {
|
|
5467
|
-
const previous = this.tokens[this.position - 1];
|
|
5468
|
-
return previous?.position ?? 0;
|
|
5469
|
-
}
|
|
5470
|
-
};
|
|
5471
|
-
function describeToken(token) {
|
|
5472
|
-
switch (token.kind) {
|
|
5473
|
-
case "identifier":
|
|
5474
|
-
case "number":
|
|
5475
|
-
case "string":
|
|
5476
|
-
case "boolean":
|
|
5477
|
-
case "operator":
|
|
5478
|
-
case "punctuation":
|
|
5479
|
-
return `"${String(token.value)}"`;
|
|
5480
|
-
case "null":
|
|
5481
|
-
return '"null"';
|
|
5482
|
-
default: {
|
|
5483
|
-
const exhaustive = token;
|
|
5484
|
-
return exhaustive;
|
|
5485
|
-
}
|
|
5486
|
-
}
|
|
5487
|
-
}
|
|
5488
|
-
function getOperatorPrecedence(operator) {
|
|
5489
|
-
switch (operator) {
|
|
5490
|
-
case "*":
|
|
5491
|
-
case "/":
|
|
5492
|
-
return 3;
|
|
5493
|
-
case "+":
|
|
5494
|
-
case "-":
|
|
5495
|
-
return 2;
|
|
5496
|
-
case ">":
|
|
5497
|
-
case "<":
|
|
5498
|
-
case ">=":
|
|
5499
|
-
case "<=":
|
|
5500
|
-
case "==":
|
|
5501
|
-
case "!=":
|
|
5502
|
-
return 1;
|
|
5503
|
-
default: {
|
|
5504
|
-
const exhaustive = operator;
|
|
5505
|
-
return exhaustive;
|
|
5506
|
-
}
|
|
5507
|
-
}
|
|
5508
|
-
}
|
|
5509
|
-
|
|
5510
5207
|
// src/computed/compiler.ts
|
|
5511
5208
|
var ComputedFormulaCompileError = class extends Error {
|
|
5512
5209
|
constructor(message) {
|
|
@@ -6983,4 +6680,4 @@ function validateQualifiedRule(rule, context) {
|
|
|
6983
6680
|
assertOperatorForType(rule.operator, propDef.type, "property");
|
|
6984
6681
|
}
|
|
6985
6682
|
|
|
6986
|
-
export { ALLOWED_PROPERTY_TYPES, ALL_ACTIONS, ALL_SYSTEM_RESOURCES, ATTRIBUTE_FILTER_OPERATORS, ActivityTabConfig, BEHAVIOR_PROPERTIES, COMPUTED_FUNCTIONS, COMPUTED_FUNCTION_METADATA, COMPUTED_FUNCTION_NAMES, ComputedFormulaCompileError,
|
|
6683
|
+
export { ALLOWED_PROPERTY_TYPES, ALL_ACTIONS, ALL_SYSTEM_RESOURCES, ATTRIBUTE_FILTER_OPERATORS, ActivityTabConfig, BEHAVIOR_PROPERTIES, COMPUTED_FUNCTIONS, COMPUTED_FUNCTION_METADATA, COMPUTED_FUNCTION_NAMES, ComputedFormulaCompileError, CustomTabConfig, DB_COLUMN_FIELDS, DEFAULT_DOCUMENT_SLOT, DEFAULT_ROLES, DEFAULT_ROLE_DESCRIPTIONS, DEFAULT_ROLE_LABELS, DEFAULT_ROLE_PERMISSIONS, DOCUMENT_SYSTEM_ATTRIBUTES, DetailViewBuilder, DocumentSlotValidationError, DocumentsTabConfig, EMPTY_VALUE_PLACEHOLDER, FORM_FORBIDDEN_ATTRIBUTE_TYPES, FlagRegistry, FlagService, FormBuilder, FormRegistry, FormRowBuilder, FormStepBuilder, GroupBuilder, IDENTITY_PROPERTIES, LIVE_EVENT_TYPES, LIVE_STREAM_START_CURSOR, ListViewBuilder, ListViewTabConfigBuilder, MAX_PRESET_DEPTH, NO_VALUE_OPERATORS, NoopGeocodingAdapter, OPERATORS_BY_TYPE, OPERATOR_SPECS, ObjectBuilder, PRESENTATION_PROPERTIES, QUALIFIED_SEPARATOR, RELATION_TARGET_ANY, RESERVED_ATTRIBUTE_NAMES, RelationGroupBuilder, RichtextTabConfig, STANDARD_SCHEMA_VENDOR, SYSTEM_ATTRIBUTES, SYSTEM_ATTRIBUTE_I18N_KEYS, SYSTEM_FIELD_NAMES, SYSTEM_RESOURCES, SYSTEM_RESOURCE_LABELS, TabBuilder, TableTabConfig, USER_STATUSES, accessLevelToActions, actionsToAccessLevel, applyPipes, assertAcyclicComputedDependencies, assertLiveStreamCursor, booleanFlag, buildPropertySchema, buildQualifiedAttribute, checkbox, compareLiveStreamCursors, compileComputedFormula, compileRollupAttribute, createFlagRegistry, createFlagService, createStandardSchemaProps, currency, date, detailView, document, evaluateComputedAst, evaluateComputedFormula, evaluateComputedFormulaWithResult, evaluateFilterState, extractAttributeNames, file, flagRegistry, form, formRegistry, formatAttributeValue, formatComputedResult, formula, generateDefaultDetailView, generateDefaultListView, getActiveTab, getAttributeCapabilities, getAttributeFilterOperators, getErrorMessage, getLiveProtocolPayloadChannel, getOperatorPolarity, getRollupFilterOperators2 as getRollupFilterOperators, getSystemAttributeI18nKey, getSystemAttributeList, group, hasOptions, inferInverseCardinality, inferRollupReturnType, isAttributeFilterable, isAttributeGroupable, isAttributeKanbanGroupable, isAttributeSearchable, isAttributeSortable2 as isAttributeSortable, isBilateralRelation, isComputedFunctionName, isDefaultRole, isDetailView, isDocumentAttribute, isEmptyObject, isFieldGroup, isFormDefinition, isFormFieldsRow, isFormFreeFieldRef, isFormHeadingRow, isFormSeparatorRow, isFormSlotFieldRef, isFormTextRow, isLabelExpression, isListView, isLiveErrorPayload, isLiveEventEnvelope, isLiveEventPayload, isLiveEventPayloadForType, isLiveEventType, isLiveGapPayload, isLiveReplayCompletePayload, isLiveStreamCursor, isNoValueOperator, isNotEmpty, isPlainRecord, isRelationGroup, isStandardSchema, isUniversalRelation, jsonFlag, listView, liveChannelKey, location, matchesMime, multiselect, normaliseDocumentSlots, normalizeForEdgeRpc, number, numberFlag, object, parseLiveChannelKey, parseLiveSubscribePayload, parseLiveUnsubscribePayload, parseQualifiedAttribute, phone, registry, relation, relationGroup, renderLabelExpression, resetViewToDefault, richtext, rollup, rollupToFormulaExpression, select, status, stringFlag, text, toUndefinedIfEmpty, user, validateAttributeName, validateQualifiedRule, validateSlotAgainstConfig, viewRegistry };
|
package/dist/validation/all.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('../chunk-PGERPYDR.js');
|
|
4
|
-
var
|
|
4
|
+
var chunkNSM2JPC3_js = require('../chunk-NSM2JPC3.js');
|
|
5
5
|
var chunkMZOEL7FN_js = require('../chunk-MZOEL7FN.js');
|
|
6
6
|
require('../chunk-5WATIVCA.js');
|
|
7
7
|
require('../chunk-O44XVGHE.js');
|
|
@@ -23,7 +23,7 @@ var chunkYKWSHBT5_js = require('../chunk-YKWSHBT5.js');
|
|
|
23
23
|
|
|
24
24
|
Object.defineProperty(exports, "parseAttributeConfig", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkNSM2JPC3_js.parseAttributeConfig; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "computeRecordStatus", {
|
|
29
29
|
enumerable: true,
|
package/dist/validation/all.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../chunk-SP3PNHYF.mjs';
|
|
2
|
-
export { parseAttributeConfig } from '../chunk-
|
|
2
|
+
export { parseAttributeConfig } from '../chunk-AAXJJNY6.mjs';
|
|
3
3
|
export { computeRecordStatus, createFormAttributeValidator, rejectUnknownAttributesOrThrow, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow } from '../chunk-PMKCDRRO.mjs';
|
|
4
4
|
import '../chunk-OSSGN43B.mjs';
|
|
5
5
|
import '../chunk-6I2R22CX.mjs';
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNSM2JPC3_js = require('../../chunk-NSM2JPC3.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "attributeConfigSchemas", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkNSM2JPC3_js.attributeConfigSchemas; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "getAttributeConfigSchema", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkNSM2JPC3_js.getAttributeConfigSchema; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "parseAttributeConfig", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkNSM2JPC3_js.parseAttributeConfig; }
|
|
18
18
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { attributeConfigSchemas, getAttributeConfigSchema, parseAttributeConfig } from '../../chunk-
|
|
1
|
+
export { attributeConfigSchemas, getAttributeConfigSchema, parseAttributeConfig } from '../../chunk-AAXJJNY6.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stndrds/schema",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.201",
|
|
4
4
|
"description": "Standard schema definitions and utilities",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"@standard-schema/spec": "^1.1.0",
|
|
121
121
|
"libphonenumber-js": "^1.12.31",
|
|
122
122
|
"zod": "^4.2.1",
|
|
123
|
-
"@stndrds/constants": "1.0.0-alpha.
|
|
123
|
+
"@stndrds/constants": "1.0.0-alpha.201"
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@types/node": "^25.0.3",
|
package/dist/chunk-HXDDJLHD.mjs
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
// src/validation/config/schemas.ts
|
|
4
|
-
var baseConfigSchema = z.object({
|
|
5
|
-
placeholder: z.string().optional(),
|
|
6
|
-
description: z.string().optional(),
|
|
7
|
-
defaultValue: z.unknown().optional(),
|
|
8
|
-
icon: z.string().optional(),
|
|
9
|
-
order: z.number().int().optional(),
|
|
10
|
-
hidden: z.boolean().optional(),
|
|
11
|
-
archived: z.boolean().optional(),
|
|
12
|
-
deprecated: z.boolean().optional(),
|
|
13
|
-
metadata: z.record(z.string(), z.unknown()).optional()
|
|
14
|
-
});
|
|
15
|
-
var optionSchema = z.object({
|
|
16
|
-
value: z.string().min(1),
|
|
17
|
-
label: z.string().min(1),
|
|
18
|
-
color: z.string().optional(),
|
|
19
|
-
description: z.string().optional(),
|
|
20
|
-
group: z.enum(["idle", "in_progress", "finished"]).optional(),
|
|
21
|
-
inverse: z.string().optional(),
|
|
22
|
-
archived: z.boolean().optional()
|
|
23
|
-
}).strict();
|
|
24
|
-
var optionsArraySchema = z.array(optionSchema).min(1).refine(
|
|
25
|
-
(options) => {
|
|
26
|
-
const values = options.map((o) => o.value);
|
|
27
|
-
return new Set(values).size === values.length;
|
|
28
|
-
},
|
|
29
|
-
{ message: "Duplicate option values are not allowed" }
|
|
30
|
-
);
|
|
31
|
-
var relationTargetSchema = z.object({
|
|
32
|
-
object: z.string().min(1),
|
|
33
|
-
displayTemplate: z.string().optional(),
|
|
34
|
-
filter: z.record(z.string(), z.unknown()).optional()
|
|
35
|
-
});
|
|
36
|
-
var bilateralConfigSchema = z.object({
|
|
37
|
-
object: z.string().min(1),
|
|
38
|
-
attribute: z.string().min(1),
|
|
39
|
-
cardinality: z.enum(["one", "many"]).optional(),
|
|
40
|
-
storageOwner: z.boolean().optional()
|
|
41
|
-
});
|
|
42
|
-
var computedOptionsSourceSchema = z.object({
|
|
43
|
-
objectName: z.string().min(1),
|
|
44
|
-
attributeName: z.string().min(1),
|
|
45
|
-
attributeId: z.string().optional()
|
|
46
|
-
});
|
|
47
|
-
var textConfigSchema = baseConfigSchema.extend({
|
|
48
|
-
multiline: z.boolean().optional(),
|
|
49
|
-
minLength: z.number().int().min(0).optional(),
|
|
50
|
-
maxLength: z.number().int().min(1).optional(),
|
|
51
|
-
pattern: z.string().optional(),
|
|
52
|
-
format: z.enum(["email", "url", "slug"]).optional()
|
|
53
|
-
});
|
|
54
|
-
var richtextConfigSchema = baseConfigSchema;
|
|
55
|
-
var numberConfigSchema = baseConfigSchema.extend({
|
|
56
|
-
renderAs: z.enum(["number", "rating"]).optional(),
|
|
57
|
-
min: z.number().optional(),
|
|
58
|
-
max: z.number().optional(),
|
|
59
|
-
unit: z.enum(["integer", "decimal", "percentage"]).optional(),
|
|
60
|
-
decimals: z.number().int().min(0).max(10).optional()
|
|
61
|
-
});
|
|
62
|
-
var checkboxConfigSchema = baseConfigSchema;
|
|
63
|
-
var dateConfigSchema = baseConfigSchema.extend({
|
|
64
|
-
dateFormat: z.enum(["short", "long", "full", "relative"]).optional(),
|
|
65
|
-
minDate: z.string().optional(),
|
|
66
|
-
maxDate: z.string().optional()
|
|
67
|
-
});
|
|
68
|
-
var phoneConfigSchema = baseConfigSchema.extend({
|
|
69
|
-
defaultCountryCode: z.string().length(3).optional()
|
|
70
|
-
});
|
|
71
|
-
var currencyConfigSchema = baseConfigSchema.extend({
|
|
72
|
-
defaultCurrency: z.string().length(3).optional(),
|
|
73
|
-
allowedCurrencies: z.array(z.string().length(3)).optional(),
|
|
74
|
-
allowNegative: z.boolean().optional()
|
|
75
|
-
});
|
|
76
|
-
var statusConfigSchema = baseConfigSchema.extend({
|
|
77
|
-
options: optionsArraySchema
|
|
78
|
-
});
|
|
79
|
-
var locationConfigSchema = baseConfigSchema.extend({
|
|
80
|
-
granularity: z.enum(["full", "address", "city", "state", "country", "coordinates"]).optional(),
|
|
81
|
-
defaultCountry: z.string().length(3).optional(),
|
|
82
|
-
allowedCountries: z.array(z.string().length(3)).optional()
|
|
83
|
-
});
|
|
84
|
-
var selectConfigSchema = baseConfigSchema.extend({
|
|
85
|
-
options: optionsArraySchema
|
|
86
|
-
});
|
|
87
|
-
var multiselectConfigSchema = baseConfigSchema.extend({
|
|
88
|
-
options: optionsArraySchema
|
|
89
|
-
});
|
|
90
|
-
var fileConfigSchema = baseConfigSchema.extend({
|
|
91
|
-
maxFiles: z.number().int().min(1).optional(),
|
|
92
|
-
maxSize: z.number().int().min(1).optional(),
|
|
93
|
-
allowedTypes: z.array(z.string()).optional(),
|
|
94
|
-
multiple: z.boolean().optional()
|
|
95
|
-
});
|
|
96
|
-
var userConfigSchema = baseConfigSchema.extend({
|
|
97
|
-
types: z.array(z.enum(["user", "agent"])).min(1).optional(),
|
|
98
|
-
multiple: z.boolean().optional()
|
|
99
|
-
});
|
|
100
|
-
var relationConfigSchema = baseConfigSchema.extend({
|
|
101
|
-
targets: z.array(relationTargetSchema).min(1),
|
|
102
|
-
cardinality: z.enum(["one", "many"]),
|
|
103
|
-
maxItems: z.number().int().min(1).optional(),
|
|
104
|
-
bilateral: bilateralConfigSchema.optional(),
|
|
105
|
-
/**
|
|
106
|
-
* PropertySchema declared via `.qualifyWith()`. Pass-through; structural
|
|
107
|
-
* validation happens at the builder level — see `propertySchemaPassthrough`
|
|
108
|
-
* comment further below for the rationale.
|
|
109
|
-
*/
|
|
110
|
-
properties: z.object({ definitions: z.array(z.record(z.string(), z.unknown())) }).passthrough().optional()
|
|
111
|
-
});
|
|
112
|
-
var formulaConfigSchema = baseConfigSchema.extend({
|
|
113
|
-
expression: z.string().min(1),
|
|
114
|
-
returnType: z.enum(["text", "number", "boolean", "date", "select", "multiselect"]),
|
|
115
|
-
decimals: z.number().int().min(0).max(10).optional(),
|
|
116
|
-
allowRelations: z.boolean().optional(),
|
|
117
|
-
optionsSource: computedOptionsSourceSchema.optional()
|
|
118
|
-
});
|
|
119
|
-
var rollupConfigSchema = baseConfigSchema.extend({
|
|
120
|
-
relationAttribute: z.string().min(1).optional(),
|
|
121
|
-
relationPath: z.string().optional(),
|
|
122
|
-
targetAttribute: z.string().min(1),
|
|
123
|
-
function: z.enum([
|
|
124
|
-
"sum",
|
|
125
|
-
"avg",
|
|
126
|
-
"earliest",
|
|
127
|
-
"latest",
|
|
128
|
-
"count",
|
|
129
|
-
"countValues",
|
|
130
|
-
"countUniqueValues",
|
|
131
|
-
"countEmpty",
|
|
132
|
-
"percentEmpty",
|
|
133
|
-
"percentNotEmpty",
|
|
134
|
-
"original"
|
|
135
|
-
]),
|
|
136
|
-
decimals: z.number().int().min(0).max(10).optional(),
|
|
137
|
-
targetAttributeType: z.string().optional(),
|
|
138
|
-
targetAttributeOptions: z.array(optionSchema).optional(),
|
|
139
|
-
optionsSource: computedOptionsSourceSchema.optional()
|
|
140
|
-
});
|
|
141
|
-
var propertySchemaPassthrough = z.object({ definitions: z.array(z.record(z.string(), z.unknown())) }).passthrough();
|
|
142
|
-
var documentSlotConfigPassthrough = z.object({
|
|
143
|
-
name: z.string(),
|
|
144
|
-
label: z.string().optional(),
|
|
145
|
-
description: z.string().optional(),
|
|
146
|
-
required: z.boolean().optional(),
|
|
147
|
-
acceptedMimeTypes: z.array(z.string()).optional(),
|
|
148
|
-
maxSizeBytes: z.number().optional()
|
|
149
|
-
}).passthrough();
|
|
150
|
-
var documentConfigSchema = baseConfigSchema.extend({
|
|
151
|
-
/**
|
|
152
|
-
* PropertySchema declared via `.qualifyWith()` on a document attribute.
|
|
153
|
-
* Drives hydration into `[{id, props}]` shape and write-time validation.
|
|
154
|
-
*/
|
|
155
|
-
properties: propertySchemaPassthrough.optional(),
|
|
156
|
-
/** File slots declared via `.slots(...)`. */
|
|
157
|
-
slots: z.array(documentSlotConfigPassthrough).optional()
|
|
158
|
-
});
|
|
159
|
-
var attributeConfigSchemas = {
|
|
160
|
-
text: textConfigSchema,
|
|
161
|
-
richtext: richtextConfigSchema,
|
|
162
|
-
number: numberConfigSchema,
|
|
163
|
-
checkbox: checkboxConfigSchema,
|
|
164
|
-
date: dateConfigSchema,
|
|
165
|
-
phone: phoneConfigSchema,
|
|
166
|
-
currency: currencyConfigSchema,
|
|
167
|
-
status: statusConfigSchema,
|
|
168
|
-
location: locationConfigSchema,
|
|
169
|
-
select: selectConfigSchema,
|
|
170
|
-
multiselect: multiselectConfigSchema,
|
|
171
|
-
file: fileConfigSchema,
|
|
172
|
-
user: userConfigSchema,
|
|
173
|
-
relation: relationConfigSchema,
|
|
174
|
-
formula: formulaConfigSchema,
|
|
175
|
-
rollup: rollupConfigSchema,
|
|
176
|
-
document: documentConfigSchema
|
|
177
|
-
};
|
|
178
|
-
function getAttributeConfigSchema(type) {
|
|
179
|
-
const schema = attributeConfigSchemas[type];
|
|
180
|
-
if (!schema) {
|
|
181
|
-
throw new Error(`Unsupported attribute type: ${type}`);
|
|
182
|
-
}
|
|
183
|
-
return schema;
|
|
184
|
-
}
|
|
185
|
-
function parseAttributeConfig(type, config) {
|
|
186
|
-
const schema = getAttributeConfigSchema(type);
|
|
187
|
-
return schema.strip().parse(config);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export { attributeConfigSchemas, getAttributeConfigSchema, parseAttributeConfig };
|