@stndrds/schema 1.0.0-alpha.136 → 1.0.0-alpha.138
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/{helpers-BiGe0rbb.d.mts → helpers-CoFQtNfq.d.mts} +5 -5
- package/dist/{helpers-MWhnBsDK.d.ts → helpers-D-4aV3ki.d.ts} +5 -5
- package/dist/index.d.mts +275 -34
- package/dist/index.d.ts +275 -34
- package/dist/index.js +298 -11
- package/dist/index.mjs +297 -12
- package/dist/validation/all.d.mts +1 -1
- package/dist/validation/all.d.ts +1 -1
- package/dist/validation/object/index.d.mts +2 -2
- package/dist/validation/object/index.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -545,7 +545,7 @@ var RESERVED_ATTRIBUTE_NAMES = [
|
|
|
545
545
|
];
|
|
546
546
|
|
|
547
547
|
// src/types/permissions.ts
|
|
548
|
-
var ALL_ACTIONS = ["read", "create", "update", "delete"];
|
|
548
|
+
var ALL_ACTIONS = ["read", "create", "update", "delete", "manage"];
|
|
549
549
|
function actionsToAccessLevel(actions) {
|
|
550
550
|
if (actions.length === 0) return "none";
|
|
551
551
|
if (actions.length === 1 && actions[0] === "read") return "read-only";
|
|
@@ -615,7 +615,7 @@ var SYSTEM_ATTRIBUTES = {
|
|
|
615
615
|
system: true,
|
|
616
616
|
multiple: false,
|
|
617
617
|
icon: "user",
|
|
618
|
-
description: "
|
|
618
|
+
description: "Actor who created this record"
|
|
619
619
|
},
|
|
620
620
|
lastUpdatedBy: {
|
|
621
621
|
id: "system:lastUpdatedBy",
|
|
@@ -627,7 +627,7 @@ var SYSTEM_ATTRIBUTES = {
|
|
|
627
627
|
system: true,
|
|
628
628
|
multiple: false,
|
|
629
629
|
icon: "user",
|
|
630
|
-
description: "
|
|
630
|
+
description: "Actor who last modified this record"
|
|
631
631
|
},
|
|
632
632
|
/**
|
|
633
633
|
* System attribute for free-form document attachments.
|
|
@@ -947,8 +947,8 @@ function renderLabelExpression(template, values, fallback = DEFAULT_LABEL_FALLBA
|
|
|
947
947
|
break;
|
|
948
948
|
}
|
|
949
949
|
}
|
|
950
|
-
const
|
|
951
|
-
if (
|
|
950
|
+
const isEmpty2 = value == null || value === "";
|
|
951
|
+
if (isEmpty2 && pipes.length === 0) return "";
|
|
952
952
|
for (const pipeExpr of pipes) {
|
|
953
953
|
const { name: pipeName, args } = parsePipeExpression(pipeExpr);
|
|
954
954
|
const simpleFn = simplePipes[pipeName];
|
|
@@ -1009,17 +1009,45 @@ var SYSTEM_RESOURCES = {
|
|
|
1009
1009
|
/** Tenant settings, audit logs, workflow execution, document generation */
|
|
1010
1010
|
WORKSPACE: "workspace",
|
|
1011
1011
|
/** Object definitions, attributes, views, workflow definitions */
|
|
1012
|
-
ARCHITECT: "architect"
|
|
1012
|
+
ARCHITECT: "architect",
|
|
1013
|
+
/** Runtime feature toggles */
|
|
1014
|
+
FEATURE_FLAGS: "feature-flags",
|
|
1015
|
+
/** Uploaded files and file storage */
|
|
1016
|
+
FILES: "files",
|
|
1017
|
+
/** Saved object views */
|
|
1018
|
+
VIEWS: "views",
|
|
1019
|
+
/** Forms and form submissions */
|
|
1020
|
+
FORMS: "forms",
|
|
1021
|
+
/** Documents and document slots */
|
|
1022
|
+
DOCUMENTS: "documents",
|
|
1023
|
+
/** Audit log access */
|
|
1024
|
+
AUDIT: "audit",
|
|
1025
|
+
/** Programmatic access keys */
|
|
1026
|
+
API_KEYS: "api-keys"
|
|
1013
1027
|
};
|
|
1014
1028
|
var ALL_SYSTEM_RESOURCES = [
|
|
1015
1029
|
SYSTEM_RESOURCES.PEOPLE,
|
|
1016
1030
|
SYSTEM_RESOURCES.WORKSPACE,
|
|
1017
|
-
SYSTEM_RESOURCES.ARCHITECT
|
|
1031
|
+
SYSTEM_RESOURCES.ARCHITECT,
|
|
1032
|
+
SYSTEM_RESOURCES.FEATURE_FLAGS,
|
|
1033
|
+
SYSTEM_RESOURCES.FILES,
|
|
1034
|
+
SYSTEM_RESOURCES.VIEWS,
|
|
1035
|
+
SYSTEM_RESOURCES.FORMS,
|
|
1036
|
+
SYSTEM_RESOURCES.DOCUMENTS,
|
|
1037
|
+
SYSTEM_RESOURCES.AUDIT,
|
|
1038
|
+
SYSTEM_RESOURCES.API_KEYS
|
|
1018
1039
|
];
|
|
1019
1040
|
var SYSTEM_RESOURCE_LABELS = {
|
|
1020
1041
|
people: "People",
|
|
1021
1042
|
workspace: "Workspace",
|
|
1022
|
-
architect: "Architect"
|
|
1043
|
+
architect: "Architect",
|
|
1044
|
+
"feature-flags": "Feature flags",
|
|
1045
|
+
files: "Files",
|
|
1046
|
+
views: "Views",
|
|
1047
|
+
forms: "Forms",
|
|
1048
|
+
documents: "Documents",
|
|
1049
|
+
audit: "Audit",
|
|
1050
|
+
"api-keys": "API keys"
|
|
1023
1051
|
};
|
|
1024
1052
|
var DEFAULT_ROLES = {
|
|
1025
1053
|
/** Full platform access - can manage everything */
|
|
@@ -1035,7 +1063,7 @@ var DEFAULT_ROLE_DESCRIPTIONS = {
|
|
|
1035
1063
|
owner: "Full access to all platform features and data",
|
|
1036
1064
|
member: "Can view, create, edit and delete business data"
|
|
1037
1065
|
};
|
|
1038
|
-
var ALL_ACTIONS2 = ["read", "create", "update", "delete"];
|
|
1066
|
+
var ALL_ACTIONS2 = ["read", "create", "update", "delete", "manage"];
|
|
1039
1067
|
var DEFAULT_ROLE_PERMISSIONS = {
|
|
1040
1068
|
owner: {
|
|
1041
1069
|
system: [{ target: "*", actions: ALL_ACTIONS2 }],
|
|
@@ -2619,10 +2647,20 @@ var ObjectBuilder = class {
|
|
|
2619
2647
|
return this;
|
|
2620
2648
|
}
|
|
2621
2649
|
/**
|
|
2622
|
-
* Set metadata
|
|
2650
|
+
* Set metadata. Merges with any previously set metadata (preserves keys
|
|
2651
|
+
* written by other builder methods like `.order()`).
|
|
2623
2652
|
*/
|
|
2624
2653
|
metadata(value) {
|
|
2625
|
-
this.obj.metadata = value;
|
|
2654
|
+
this.obj.metadata = { ...this.obj.metadata, ...value };
|
|
2655
|
+
return this;
|
|
2656
|
+
}
|
|
2657
|
+
/**
|
|
2658
|
+
* Set the display order used by the sidebar (and any other UI that
|
|
2659
|
+
* surfaces objects). Lower values appear first; objects without an
|
|
2660
|
+
* order fall back to alphabetical order at the consumer level.
|
|
2661
|
+
*/
|
|
2662
|
+
order(value) {
|
|
2663
|
+
this.obj.metadata = { ...this.obj.metadata, order: value };
|
|
2626
2664
|
return this;
|
|
2627
2665
|
}
|
|
2628
2666
|
/**
|
|
@@ -5180,6 +5218,253 @@ function getRelationPath(path) {
|
|
|
5180
5218
|
return parts.slice(0, -1).join(".");
|
|
5181
5219
|
}
|
|
5182
5220
|
|
|
5221
|
+
// src/filters/operators.ts
|
|
5222
|
+
var isEmpty = (v) => v === null || v === void 0 || v === "" || Array.isArray(v) && v.length === 0;
|
|
5223
|
+
var toStr = (v) => v == null ? "" : String(v);
|
|
5224
|
+
var toNum = (v) => {
|
|
5225
|
+
if (v == null || v === "") return null;
|
|
5226
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
5227
|
+
return Number.isFinite(n) ? n : null;
|
|
5228
|
+
};
|
|
5229
|
+
var toDate = (v) => {
|
|
5230
|
+
if (v == null) return null;
|
|
5231
|
+
const d = v instanceof Date ? v : new Date(String(v));
|
|
5232
|
+
return Number.isNaN(d.getTime()) ? null : d;
|
|
5233
|
+
};
|
|
5234
|
+
var toArr = (v) => Array.isArray(v) ? v : v == null ? [] : [v];
|
|
5235
|
+
function relativeDateBoundary(rel) {
|
|
5236
|
+
const ms = {
|
|
5237
|
+
days: 864e5,
|
|
5238
|
+
weeks: 6048e5,
|
|
5239
|
+
months: 2592e6,
|
|
5240
|
+
years: 31536e6
|
|
5241
|
+
};
|
|
5242
|
+
const offset = rel.amount * ms[rel.unit] * (rel.direction === "future" ? 1 : -1);
|
|
5243
|
+
return new Date(Date.now() + offset);
|
|
5244
|
+
}
|
|
5245
|
+
var OPERATOR_SPECS = {
|
|
5246
|
+
// ---- text-style ----
|
|
5247
|
+
is: {
|
|
5248
|
+
appliesTo: ["text", "textarea", "phone", "status", "select", "date", "formula"],
|
|
5249
|
+
evaluateInMemory: (v, rv) => toStr(v) === toStr(rv)
|
|
5250
|
+
},
|
|
5251
|
+
is_not: {
|
|
5252
|
+
appliesTo: ["text", "textarea", "phone", "status", "select", "date", "formula"],
|
|
5253
|
+
evaluateInMemory: (v, rv) => toStr(v) !== toStr(rv)
|
|
5254
|
+
},
|
|
5255
|
+
contains: {
|
|
5256
|
+
appliesTo: [
|
|
5257
|
+
"text",
|
|
5258
|
+
"textarea",
|
|
5259
|
+
"phone",
|
|
5260
|
+
"location",
|
|
5261
|
+
"user",
|
|
5262
|
+
"multiselect",
|
|
5263
|
+
"relation",
|
|
5264
|
+
"document",
|
|
5265
|
+
"formula"
|
|
5266
|
+
],
|
|
5267
|
+
evaluateInMemory: (v, rv) => {
|
|
5268
|
+
if (Array.isArray(v)) return v.map(toStr).includes(toStr(rv));
|
|
5269
|
+
return toStr(v).toLowerCase().includes(toStr(rv).toLowerCase());
|
|
5270
|
+
}
|
|
5271
|
+
},
|
|
5272
|
+
not_contains: {
|
|
5273
|
+
appliesTo: [
|
|
5274
|
+
"text",
|
|
5275
|
+
"textarea",
|
|
5276
|
+
"phone",
|
|
5277
|
+
"user",
|
|
5278
|
+
"multiselect",
|
|
5279
|
+
"relation",
|
|
5280
|
+
"document",
|
|
5281
|
+
"formula"
|
|
5282
|
+
],
|
|
5283
|
+
evaluateInMemory: (v, rv) => {
|
|
5284
|
+
if (Array.isArray(v)) return !v.map(toStr).includes(toStr(rv));
|
|
5285
|
+
return !toStr(v).toLowerCase().includes(toStr(rv).toLowerCase());
|
|
5286
|
+
}
|
|
5287
|
+
},
|
|
5288
|
+
starts_with: {
|
|
5289
|
+
appliesTo: ["text", "textarea", "formula"],
|
|
5290
|
+
evaluateInMemory: (v, rv) => toStr(v).toLowerCase().startsWith(toStr(rv).toLowerCase())
|
|
5291
|
+
},
|
|
5292
|
+
ends_with: {
|
|
5293
|
+
appliesTo: ["text", "textarea", "formula"],
|
|
5294
|
+
evaluateInMemory: (v, rv) => toStr(v).toLowerCase().endsWith(toStr(rv).toLowerCase())
|
|
5295
|
+
},
|
|
5296
|
+
is_empty: {
|
|
5297
|
+
appliesTo: [
|
|
5298
|
+
"text",
|
|
5299
|
+
"textarea",
|
|
5300
|
+
"richtext",
|
|
5301
|
+
"number",
|
|
5302
|
+
"phone",
|
|
5303
|
+
"currency",
|
|
5304
|
+
"status",
|
|
5305
|
+
"select",
|
|
5306
|
+
"date",
|
|
5307
|
+
"multiselect",
|
|
5308
|
+
"location",
|
|
5309
|
+
"file",
|
|
5310
|
+
"user",
|
|
5311
|
+
"relation",
|
|
5312
|
+
"rating",
|
|
5313
|
+
"formula",
|
|
5314
|
+
"document"
|
|
5315
|
+
],
|
|
5316
|
+
evaluateInMemory: (v) => isEmpty(v)
|
|
5317
|
+
},
|
|
5318
|
+
is_not_empty: {
|
|
5319
|
+
appliesTo: [
|
|
5320
|
+
"text",
|
|
5321
|
+
"textarea",
|
|
5322
|
+
"richtext",
|
|
5323
|
+
"number",
|
|
5324
|
+
"phone",
|
|
5325
|
+
"currency",
|
|
5326
|
+
"status",
|
|
5327
|
+
"select",
|
|
5328
|
+
"date",
|
|
5329
|
+
"multiselect",
|
|
5330
|
+
"location",
|
|
5331
|
+
"file",
|
|
5332
|
+
"user",
|
|
5333
|
+
"relation",
|
|
5334
|
+
"rating",
|
|
5335
|
+
"formula",
|
|
5336
|
+
"document"
|
|
5337
|
+
],
|
|
5338
|
+
evaluateInMemory: (v) => !isEmpty(v)
|
|
5339
|
+
},
|
|
5340
|
+
// ---- numeric ----
|
|
5341
|
+
eq: {
|
|
5342
|
+
appliesTo: ["number", "currency", "rating", "formula"],
|
|
5343
|
+
evaluateInMemory: (v, rv) => toNum(v) === toNum(rv)
|
|
5344
|
+
},
|
|
5345
|
+
neq: {
|
|
5346
|
+
appliesTo: ["number", "currency", "rating", "formula"],
|
|
5347
|
+
evaluateInMemory: (v, rv) => toNum(v) !== toNum(rv)
|
|
5348
|
+
},
|
|
5349
|
+
lt: {
|
|
5350
|
+
appliesTo: ["number", "currency", "rating", "formula"],
|
|
5351
|
+
evaluateInMemory: (v, rv) => {
|
|
5352
|
+
const a = toNum(v);
|
|
5353
|
+
const b = toNum(rv);
|
|
5354
|
+
return a !== null && b !== null && a < b;
|
|
5355
|
+
}
|
|
5356
|
+
},
|
|
5357
|
+
gt: {
|
|
5358
|
+
appliesTo: ["number", "currency", "rating", "formula"],
|
|
5359
|
+
evaluateInMemory: (v, rv) => {
|
|
5360
|
+
const a = toNum(v);
|
|
5361
|
+
const b = toNum(rv);
|
|
5362
|
+
return a !== null && b !== null && a > b;
|
|
5363
|
+
}
|
|
5364
|
+
},
|
|
5365
|
+
lte: {
|
|
5366
|
+
appliesTo: ["number", "currency", "rating", "formula"],
|
|
5367
|
+
evaluateInMemory: (v, rv) => {
|
|
5368
|
+
const a = toNum(v);
|
|
5369
|
+
const b = toNum(rv);
|
|
5370
|
+
return a !== null && b !== null && a <= b;
|
|
5371
|
+
}
|
|
5372
|
+
},
|
|
5373
|
+
gte: {
|
|
5374
|
+
appliesTo: ["number", "currency", "rating", "formula"],
|
|
5375
|
+
evaluateInMemory: (v, rv) => {
|
|
5376
|
+
const a = toNum(v);
|
|
5377
|
+
const b = toNum(rv);
|
|
5378
|
+
return a !== null && b !== null && a >= b;
|
|
5379
|
+
}
|
|
5380
|
+
},
|
|
5381
|
+
// ---- checkbox ----
|
|
5382
|
+
is_checked: {
|
|
5383
|
+
appliesTo: ["checkbox"],
|
|
5384
|
+
evaluateInMemory: (v) => v === true
|
|
5385
|
+
},
|
|
5386
|
+
is_not_checked: {
|
|
5387
|
+
appliesTo: ["checkbox"],
|
|
5388
|
+
evaluateInMemory: (v) => v !== true
|
|
5389
|
+
},
|
|
5390
|
+
// ---- date ----
|
|
5391
|
+
before: {
|
|
5392
|
+
appliesTo: ["date"],
|
|
5393
|
+
evaluateInMemory: (v, rv) => {
|
|
5394
|
+
const a = toDate(v);
|
|
5395
|
+
const b = toDate(rv);
|
|
5396
|
+
return a !== null && b !== null && a < b;
|
|
5397
|
+
}
|
|
5398
|
+
},
|
|
5399
|
+
after: {
|
|
5400
|
+
appliesTo: ["date"],
|
|
5401
|
+
evaluateInMemory: (v, rv) => {
|
|
5402
|
+
const a = toDate(v);
|
|
5403
|
+
const b = toDate(rv);
|
|
5404
|
+
return a !== null && b !== null && a > b;
|
|
5405
|
+
}
|
|
5406
|
+
},
|
|
5407
|
+
on_or_before: {
|
|
5408
|
+
appliesTo: ["date"],
|
|
5409
|
+
evaluateInMemory: (v, rv) => {
|
|
5410
|
+
const a = toDate(v);
|
|
5411
|
+
const b = toDate(rv);
|
|
5412
|
+
return a !== null && b !== null && a <= b;
|
|
5413
|
+
}
|
|
5414
|
+
},
|
|
5415
|
+
on_or_after: {
|
|
5416
|
+
appliesTo: ["date"],
|
|
5417
|
+
evaluateInMemory: (v, rv) => {
|
|
5418
|
+
const a = toDate(v);
|
|
5419
|
+
const b = toDate(rv);
|
|
5420
|
+
return a !== null && b !== null && a >= b;
|
|
5421
|
+
}
|
|
5422
|
+
},
|
|
5423
|
+
is_within: {
|
|
5424
|
+
appliesTo: ["date"],
|
|
5425
|
+
evaluateInMemory: (v, rv) => {
|
|
5426
|
+
const d = toDate(v);
|
|
5427
|
+
if (!d) return false;
|
|
5428
|
+
const rel = rv;
|
|
5429
|
+
const boundary = relativeDateBoundary(rel);
|
|
5430
|
+
return rel.direction === "future" ? d >= /* @__PURE__ */ new Date() && d <= boundary : d >= boundary && d <= /* @__PURE__ */ new Date();
|
|
5431
|
+
}
|
|
5432
|
+
},
|
|
5433
|
+
// ---- select multi-value ----
|
|
5434
|
+
any_of: {
|
|
5435
|
+
appliesTo: ["status", "select", "relation", "document"],
|
|
5436
|
+
evaluateInMemory: (v, rv) => {
|
|
5437
|
+
const ruleArr = toArr(rv).map(toStr);
|
|
5438
|
+
const valArr = toArr(v).map(toStr);
|
|
5439
|
+
return valArr.some((x) => ruleArr.includes(x));
|
|
5440
|
+
}
|
|
5441
|
+
},
|
|
5442
|
+
none_of: {
|
|
5443
|
+
appliesTo: ["status", "select", "relation", "document"],
|
|
5444
|
+
evaluateInMemory: (v, rv) => {
|
|
5445
|
+
const ruleArr = toArr(rv).map(toStr);
|
|
5446
|
+
const valArr = toArr(v).map(toStr);
|
|
5447
|
+
return !valArr.some((x) => ruleArr.includes(x));
|
|
5448
|
+
}
|
|
5449
|
+
}
|
|
5450
|
+
};
|
|
5451
|
+
|
|
5452
|
+
// src/filters/evaluate.ts
|
|
5453
|
+
function evaluateFilterState(state, values, attributes) {
|
|
5454
|
+
if (state.rules.length === 0) return true;
|
|
5455
|
+
const attrByName = new Map(attributes.map((a) => [a.name, a]));
|
|
5456
|
+
const reducer = state.combinator === "or" ? "some" : "every";
|
|
5457
|
+
return state.rules[reducer]((rule) => evaluateRule(rule, values, attrByName));
|
|
5458
|
+
}
|
|
5459
|
+
function evaluateRule(rule, values, attrByName) {
|
|
5460
|
+
const attr = attrByName.get(rule.attribute);
|
|
5461
|
+
if (!attr) return false;
|
|
5462
|
+
const spec = OPERATOR_SPECS[rule.operator];
|
|
5463
|
+
if (!spec) return false;
|
|
5464
|
+
if (!spec.appliesTo.includes(attr.type)) return false;
|
|
5465
|
+
return spec.evaluateInMemory(values[rule.attribute], rule.value, attr);
|
|
5466
|
+
}
|
|
5467
|
+
|
|
5183
5468
|
Object.defineProperty(exports, "asTenantId", {
|
|
5184
5469
|
enumerable: true,
|
|
5185
5470
|
get: function () { return chunkFRCDMQER_js.asTenantId; }
|
|
@@ -5270,6 +5555,7 @@ exports.NoopGeocodingAdapter = NoopGeocodingAdapter;
|
|
|
5270
5555
|
exports.NotFoundError = NotFoundError;
|
|
5271
5556
|
exports.NotImplementedError = NotImplementedError;
|
|
5272
5557
|
exports.OPERATORS_BY_TYPE = OPERATORS_BY_TYPE;
|
|
5558
|
+
exports.OPERATOR_SPECS = OPERATOR_SPECS;
|
|
5273
5559
|
exports.ObjectBuilder = ObjectBuilder;
|
|
5274
5560
|
exports.ObjectNotFoundError = ObjectNotFoundError;
|
|
5275
5561
|
exports.ObjectReferencedError = ObjectReferencedError;
|
|
@@ -5310,6 +5596,7 @@ exports.currency = currency;
|
|
|
5310
5596
|
exports.date = date;
|
|
5311
5597
|
exports.detailView = detailView;
|
|
5312
5598
|
exports.document = document;
|
|
5599
|
+
exports.evaluateFilterState = evaluateFilterState;
|
|
5313
5600
|
exports.evaluateFormula = evaluateFormula;
|
|
5314
5601
|
exports.evaluateFormulaAttribute = evaluateFormulaAttribute;
|
|
5315
5602
|
exports.evaluateFormulaWithResult = evaluateFormulaWithResult;
|