@stndrds/schema 1.0.0-alpha.200 → 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/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var chunkFRCDMQER_js = require('./chunk-FRCDMQER.js');
4
4
  require('./chunk-PGERPYDR.js');
5
- var chunkM5QIBMIH_js = require('./chunk-M5QIBMIH.js');
5
+ var chunkNSM2JPC3_js = require('./chunk-NSM2JPC3.js');
6
6
  var chunkMZOEL7FN_js = require('./chunk-MZOEL7FN.js');
7
7
  require('./chunk-5WATIVCA.js');
8
8
  require('./chunk-O44XVGHE.js');
@@ -5207,310 +5207,6 @@ function isComputedFunctionName(name) {
5207
5207
  return Object.hasOwn(COMPUTED_FUNCTIONS, name);
5208
5208
  }
5209
5209
 
5210
- // src/computed/parser.ts
5211
- var ComputedFormulaParseError = class extends Error {
5212
- constructor(message) {
5213
- super(message);
5214
- this.name = "ComputedFormulaParseError";
5215
- }
5216
- };
5217
- function parseComputedFormula(expression) {
5218
- const parser = new Parser(tokenize(expression));
5219
- const ast = parser.parseExpression();
5220
- parser.expectEnd();
5221
- return ast;
5222
- }
5223
- function tokenize(expression) {
5224
- const tokens = [];
5225
- let index = 0;
5226
- while (index < expression.length) {
5227
- const char = expression[index];
5228
- if (char === " " || char === " " || char === "\n" || char === "\r") {
5229
- index += 1;
5230
- continue;
5231
- }
5232
- if (char === '"' || char === "'") {
5233
- const result = scanString(expression, index, char);
5234
- tokens.push({ kind: "string", value: result.value, position: index });
5235
- index = result.nextIndex;
5236
- continue;
5237
- }
5238
- if (isDigit(char)) {
5239
- const result = scanNumber(expression, index);
5240
- tokens.push({ kind: "number", value: result.value, position: index });
5241
- index = result.nextIndex;
5242
- continue;
5243
- }
5244
- if (isIdentifierStart(char)) {
5245
- const result = scanIdentifier(expression, index);
5246
- const canonical = result.value.toLowerCase();
5247
- if (canonical === "true") {
5248
- tokens.push({ kind: "boolean", value: true, position: index });
5249
- } else if (canonical === "false") {
5250
- tokens.push({ kind: "boolean", value: false, position: index });
5251
- } else if (canonical === "null") {
5252
- tokens.push({ kind: "null", position: index });
5253
- } else {
5254
- tokens.push({ kind: "identifier", value: result.value, position: index });
5255
- }
5256
- index = result.nextIndex;
5257
- continue;
5258
- }
5259
- const twoChar = expression.slice(index, index + 2);
5260
- if (twoChar === ">=" || twoChar === "<=" || twoChar === "==" || twoChar === "!=") {
5261
- tokens.push({ kind: "operator", value: twoChar, position: index });
5262
- index += 2;
5263
- continue;
5264
- }
5265
- if (char === ">" || char === "<" || char === "+" || char === "-" || char === "*" || char === "/") {
5266
- tokens.push({ kind: "operator", value: char, position: index });
5267
- index += 1;
5268
- continue;
5269
- }
5270
- if (char === "(" || char === ")" || char === "," || char === ".") {
5271
- tokens.push({ kind: "punctuation", value: char, position: index });
5272
- index += 1;
5273
- continue;
5274
- }
5275
- throw new ComputedFormulaParseError(`Unexpected character "${char}" at position ${index}`);
5276
- }
5277
- return tokens;
5278
- }
5279
- function scanString(expression, startIndex, delimiter = '"') {
5280
- let value = "";
5281
- let index = startIndex + 1;
5282
- while (index < expression.length) {
5283
- const char = expression[index];
5284
- if (char === delimiter) {
5285
- return { value, nextIndex: index + 1 };
5286
- }
5287
- if (char === "\\") {
5288
- const escaped = expression[index + 1];
5289
- if (escaped === void 0) {
5290
- throw new ComputedFormulaParseError(`Unterminated string literal at position ${index}`);
5291
- }
5292
- value += decodeEscape(escaped, index);
5293
- index += 2;
5294
- continue;
5295
- }
5296
- value += char;
5297
- index += 1;
5298
- }
5299
- throw new ComputedFormulaParseError(`Unterminated string literal at position ${startIndex}`);
5300
- }
5301
- function decodeEscape(char, position) {
5302
- switch (char) {
5303
- case '"':
5304
- case "\\":
5305
- return char;
5306
- case "n":
5307
- return "\n";
5308
- case "r":
5309
- return "\r";
5310
- case "t":
5311
- return " ";
5312
- default:
5313
- throw new ComputedFormulaParseError(
5314
- `Unknown escape sequence "\\${char}" at position ${position}`
5315
- );
5316
- }
5317
- }
5318
- function scanNumber(expression, startIndex) {
5319
- let index = startIndex;
5320
- while (index < expression.length && isDigit(expression[index])) {
5321
- index += 1;
5322
- }
5323
- if (expression[index] === ".") {
5324
- const decimalStart = index;
5325
- index += 1;
5326
- if (!isDigit(expression[index])) {
5327
- throw new ComputedFormulaParseError(`Invalid number literal at position ${decimalStart}`);
5328
- }
5329
- while (index < expression.length && isDigit(expression[index])) {
5330
- index += 1;
5331
- }
5332
- }
5333
- const raw = expression.slice(startIndex, index);
5334
- const value = Number(raw);
5335
- if (!Number.isFinite(value)) {
5336
- throw new ComputedFormulaParseError(`Invalid number literal "${raw}"`);
5337
- }
5338
- return { value, nextIndex: index };
5339
- }
5340
- function scanIdentifier(expression, startIndex) {
5341
- let index = startIndex + 1;
5342
- while (index < expression.length && isIdentifierPart(expression[index])) {
5343
- index += 1;
5344
- }
5345
- return { value: expression.slice(startIndex, index), nextIndex: index };
5346
- }
5347
- function isDigit(char) {
5348
- return char !== void 0 && char >= "0" && char <= "9";
5349
- }
5350
- function isIdentifierStart(char) {
5351
- return char !== void 0 && /[A-Za-z_]/.test(char);
5352
- }
5353
- function isIdentifierPart(char) {
5354
- return char !== void 0 && /[A-Za-z0-9_]/.test(char);
5355
- }
5356
- var Parser = class {
5357
- constructor(tokens) {
5358
- this.tokens = tokens;
5359
- this.position = 0;
5360
- }
5361
- parseExpression() {
5362
- return this.parseBinaryExpression(0);
5363
- }
5364
- expectEnd() {
5365
- const token = this.peek();
5366
- if (token !== void 0) {
5367
- throw new ComputedFormulaParseError(
5368
- `Unexpected token ${describeToken(token)} at position ${token.position}`
5369
- );
5370
- }
5371
- }
5372
- parseBinaryExpression(minPrecedence) {
5373
- let left = this.parsePrimary();
5374
- while (true) {
5375
- const token = this.peek();
5376
- if (token?.kind !== "operator") {
5377
- return left;
5378
- }
5379
- const precedence = getOperatorPrecedence(token.value);
5380
- if (precedence < minPrecedence) {
5381
- return left;
5382
- }
5383
- const operator = token.value;
5384
- this.consume();
5385
- const right = this.parseBinaryExpression(precedence + 1);
5386
- left = { kind: "binary", operator, left, right };
5387
- }
5388
- }
5389
- parsePrimary() {
5390
- const token = this.consume();
5391
- if (token === void 0) {
5392
- throw new ComputedFormulaParseError("Unexpected end of expression");
5393
- }
5394
- switch (token.kind) {
5395
- case "string":
5396
- case "number":
5397
- case "boolean":
5398
- return { kind: "literal", value: token.value };
5399
- case "null":
5400
- return { kind: "literal", value: null };
5401
- case "identifier":
5402
- return this.parseIdentifier(token.value);
5403
- case "punctuation":
5404
- if (token.value === "(") {
5405
- const expression = this.parseExpression();
5406
- this.expectPunctuation(")");
5407
- return expression;
5408
- }
5409
- break;
5410
- case "operator":
5411
- if (token.value === "-") {
5412
- const next = this.consume();
5413
- if (next?.kind === "number") {
5414
- return { kind: "literal", value: -next.value };
5415
- }
5416
- }
5417
- break;
5418
- }
5419
- throw new ComputedFormulaParseError(
5420
- `Expected literal, path, call, or parenthesized expression at position ${token.position}`
5421
- );
5422
- }
5423
- parseIdentifier(identifier) {
5424
- if (this.matchPunctuation("(")) {
5425
- const args = [];
5426
- if (!this.matchPunctuation(")")) {
5427
- do {
5428
- args.push(this.parseExpression());
5429
- } while (this.matchPunctuation(","));
5430
- this.expectPunctuation(")");
5431
- }
5432
- return { kind: "call", functionName: identifier.toLowerCase(), args };
5433
- }
5434
- const parts = [identifier];
5435
- while (this.matchPunctuation(".")) {
5436
- const next = this.consume();
5437
- if (next?.kind !== "identifier") {
5438
- const position = next?.position ?? this.previousPosition();
5439
- throw new ComputedFormulaParseError(
5440
- `Expected attribute name after path separator at position ${position}`
5441
- );
5442
- }
5443
- parts.push(next.value);
5444
- }
5445
- return { kind: "path", parts };
5446
- }
5447
- expectPunctuation(value) {
5448
- if (!this.matchPunctuation(value)) {
5449
- const token = this.peek();
5450
- const position = token?.position ?? this.previousPosition();
5451
- throw new ComputedFormulaParseError(`Expected "${value}" at position ${position}`);
5452
- }
5453
- }
5454
- matchPunctuation(value) {
5455
- const token = this.peek();
5456
- if (token?.kind === "punctuation" && token.value === value) {
5457
- this.consume();
5458
- return true;
5459
- }
5460
- return false;
5461
- }
5462
- peek() {
5463
- return this.tokens[this.position];
5464
- }
5465
- consume() {
5466
- const token = this.tokens[this.position];
5467
- this.position += 1;
5468
- return token;
5469
- }
5470
- previousPosition() {
5471
- const previous = this.tokens[this.position - 1];
5472
- return previous?.position ?? 0;
5473
- }
5474
- };
5475
- function describeToken(token) {
5476
- switch (token.kind) {
5477
- case "identifier":
5478
- case "number":
5479
- case "string":
5480
- case "boolean":
5481
- case "operator":
5482
- case "punctuation":
5483
- return `"${String(token.value)}"`;
5484
- case "null":
5485
- return '"null"';
5486
- default: {
5487
- const exhaustive = token;
5488
- return exhaustive;
5489
- }
5490
- }
5491
- }
5492
- function getOperatorPrecedence(operator) {
5493
- switch (operator) {
5494
- case "*":
5495
- case "/":
5496
- return 3;
5497
- case "+":
5498
- case "-":
5499
- return 2;
5500
- case ">":
5501
- case "<":
5502
- case ">=":
5503
- case "<=":
5504
- case "==":
5505
- case "!=":
5506
- return 1;
5507
- default: {
5508
- const exhaustive = operator;
5509
- return exhaustive;
5510
- }
5511
- }
5512
- }
5513
-
5514
5210
  // src/computed/compiler.ts
5515
5211
  var ComputedFormulaCompileError = class extends Error {
5516
5212
  constructor(message) {
@@ -5580,7 +5276,7 @@ function assertAcyclicComputedDependencies(nodes) {
5580
5276
  }
5581
5277
  function parseCompileFormula(expression) {
5582
5278
  try {
5583
- return parseComputedFormula(expression);
5279
+ return chunkNSM2JPC3_js.parseComputedFormula(expression);
5584
5280
  } catch (error) {
5585
5281
  if (error instanceof Error) {
5586
5282
  throw new ComputedFormulaCompileError(error.message);
@@ -6511,11 +6207,11 @@ function evaluateComputedAst(node, input) {
6511
6207
  return evaluateAst(node, input);
6512
6208
  }
6513
6209
  function evaluateComputedFormula(expression, input) {
6514
- return evaluateAst(parseComputedFormula(expression), input);
6210
+ return evaluateAst(chunkNSM2JPC3_js.parseComputedFormula(expression), input);
6515
6211
  }
6516
6212
  function evaluateComputedFormulaWithResult(expression, input, returnType, decimals) {
6517
6213
  try {
6518
- const raw = evaluateAst(parseComputedFormula(expression), input);
6214
+ const raw = evaluateAst(chunkNSM2JPC3_js.parseComputedFormula(expression), input);
6519
6215
  const value = returnType ? formatComputedResult(raw, returnType, decimals) : raw;
6520
6216
  return { value };
6521
6217
  } catch (error) {
@@ -7007,9 +6703,17 @@ Object.defineProperty(exports, "indexBy", {
7007
6703
  enumerable: true,
7008
6704
  get: function () { return chunkFRCDMQER_js.indexBy; }
7009
6705
  });
6706
+ Object.defineProperty(exports, "ComputedFormulaParseError", {
6707
+ enumerable: true,
6708
+ get: function () { return chunkNSM2JPC3_js.ComputedFormulaParseError; }
6709
+ });
7010
6710
  Object.defineProperty(exports, "parseAttributeConfig", {
7011
6711
  enumerable: true,
7012
- get: function () { return chunkM5QIBMIH_js.parseAttributeConfig; }
6712
+ get: function () { return chunkNSM2JPC3_js.parseAttributeConfig; }
6713
+ });
6714
+ Object.defineProperty(exports, "parseComputedFormula", {
6715
+ enumerable: true,
6716
+ get: function () { return chunkNSM2JPC3_js.parseComputedFormula; }
7013
6717
  });
7014
6718
  Object.defineProperty(exports, "AccessDeniedError", {
7015
6719
  enumerable: true,
@@ -7201,7 +6905,6 @@ exports.COMPUTED_FUNCTIONS = COMPUTED_FUNCTIONS;
7201
6905
  exports.COMPUTED_FUNCTION_METADATA = COMPUTED_FUNCTION_METADATA;
7202
6906
  exports.COMPUTED_FUNCTION_NAMES = COMPUTED_FUNCTION_NAMES;
7203
6907
  exports.ComputedFormulaCompileError = ComputedFormulaCompileError;
7204
- exports.ComputedFormulaParseError = ComputedFormulaParseError;
7205
6908
  exports.CustomTabConfig = CustomTabConfig;
7206
6909
  exports.DB_COLUMN_FIELDS = DB_COLUMN_FIELDS;
7207
6910
  exports.DEFAULT_DOCUMENT_SLOT = DEFAULT_DOCUMENT_SLOT;
@@ -7340,7 +7043,6 @@ exports.normalizeForEdgeRpc = normalizeForEdgeRpc;
7340
7043
  exports.number = number;
7341
7044
  exports.numberFlag = numberFlag;
7342
7045
  exports.object = object;
7343
- exports.parseComputedFormula = parseComputedFormula;
7344
7046
  exports.parseLiveChannelKey = parseLiveChannelKey;
7345
7047
  exports.parseLiveSubscribePayload = parseLiveSubscribePayload;
7346
7048
  exports.parseLiveUnsubscribePayload = parseLiveUnsubscribePayload;