@stndrds/schema 1.0.0-alpha.279 → 1.0.0-alpha.281
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/all-BVp3k9Hi.d.ts +471 -0
- package/dist/all-CnIU2anT.d.mts +471 -0
- package/dist/{chunk-PQEOIDXD.mjs → chunk-A5PPZ2FM.mjs} +1 -1
- package/dist/{chunk-ZEPGMHCK.js → chunk-E47WAI5K.js} +4 -4
- package/dist/{chunk-ZBWTAKZO.js → chunk-HWZRSXFB.js} +6 -1
- package/dist/{chunk-DEHBEFGO.js → chunk-LRFLSFIA.js} +3 -3
- package/dist/{chunk-QUZ3PN36.mjs → chunk-MLTXSBOB.mjs} +1 -1
- package/dist/{chunk-5PLJHYSL.mjs → chunk-ORPCS24B.mjs} +5 -11
- package/dist/{chunk-FRCDMQER.js → chunk-OYHBQMC7.js} +34 -0
- package/dist/{chunk-V2WJFUZW.mjs → chunk-SYQDFZ74.mjs} +6 -1
- package/dist/{chunk-QMAVKX3Y.js → chunk-TU6ECJFZ.js} +37 -43
- package/dist/chunk-XCLVXM7F.mjs +74 -0
- package/dist/exceptions.d.mts +5 -0
- package/dist/exceptions.d.ts +5 -0
- package/dist/exceptions.js +39 -39
- package/dist/exceptions.mjs +1 -1
- package/dist/{index-C3P5Dnwt.d.mts → index-DWoqObyG.d.mts} +13 -22
- package/dist/{index-SpFpkWVC.d.ts → index-TMlrIKAY.d.ts} +13 -22
- package/dist/index.d.mts +259 -94
- package/dist/index.d.ts +259 -94
- package/dist/index.js +1178 -317
- package/dist/index.mjs +970 -124
- package/dist/utils.d.mts +16 -1
- package/dist/utils.d.ts +16 -1
- package/dist/utils.js +11 -6
- package/dist/utils.mjs +2 -1
- package/dist/validation/all.d.mts +2 -2
- package/dist/validation/all.d.ts +2 -2
- package/dist/validation/all.js +29 -29
- package/dist/validation/all.mjs +4 -4
- package/dist/validation/config/index.d.mts +1 -1
- package/dist/validation/config/index.d.ts +1 -1
- package/dist/validation/config/index.js +11 -11
- package/dist/validation/config/index.mjs +2 -2
- package/dist/validation/object/index.js +14 -14
- package/dist/validation/object/index.mjs +2 -2
- package/package.json +2 -2
- package/dist/all-Bk8cRKsu.d.mts +0 -482
- package/dist/all-C_tC90ZM.d.ts +0 -482
- package/dist/chunk-QY6QFRRV.mjs +0 -41
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { generateId } from './chunk-
|
|
2
|
-
export { asTenantId, asUserId, deepEqual, generateId, indexBy } from './chunk-
|
|
3
|
-
import { SYSTEM_FILTER_ATTRIBUTE_TYPES, RESERVED_OBJECT_NAMES, listViewConfigSchema, detailViewConfigSchema, RESERVED_ATTRIBUTE_NAMES, isAttributeSortable, getAttributeCapabilities, resolveIsWithinBounds, normalizeForEdgeRpc, getOperatorPolarity, extractCurrencyFilterValue } from './chunk-
|
|
4
|
-
export { ATTRIBUTE_FILTER_OPERATORS, LIST_VIEW_TAB_VISIBILITIES, NO_VALUE_OPERATORS, OPERATORS_BY_TYPE, REMOVED_OPERATOR_REPLACEMENTS, RESERVED_ATTRIBUTE_NAMES, RESERVED_OBJECT_NAMES, RESOURCE_VISIBILITIES, SYNONYM_ALIASES, SYSTEM_ATTRIBUTES, SYSTEM_ATTRIBUTE_I18N_KEYS, SYSTEM_FIELD_NAMES, SYSTEM_FILTER_ATTRIBUTE_TYPES, canonicalizeFilterValue, collectQualifiedRuleIssues, currentActor, detailTabSchema, detailViewConfigSchema, extractCurrencyFilterValue, extractFilterValue, getAttributeCapabilities, getAttributeFilterOperators, getOperatorPolarity, getRollupFilterOperators, getSystemAttributeI18nKey, getSystemAttributeList, inverseSourceSchema, isAttributeFilterable, isAttributeGroupable, isAttributeKanbanGroupable, isAttributeSearchable, isDynamicValue, isManagedSystemAttribute, isNoValueOperator, isRelativeDateValue, isSetMembershipOperator, listViewConfigSchema, listViewTabSchema, normalizeFilterRule, normalizeForEdgeRpc, normalizeOperator, now, parseResourceVisibility, parseViewConfig, relationSourceSchema, resolveEffectiveFilterType, resolveIsWithinBounds, resolveUtcDayBounds, tableSourceSchema, toMultiValueOperator, toUtcDayString, today, validateQualifiedRule, viewConfigByTypeSchema, viewTypeSchema } from './chunk-
|
|
5
|
-
import { iconNameSchema, parseAttributeConfigForCreate, parseComputedFormula } from './chunk-
|
|
6
|
-
export { ComputedFormulaParseError, SCHEMA_LIMITS, colorIdSchema, iconNameSchema, multiselectOptionWriteSchema, parseAttributeConfig, parseAttributeConfigForCreate, parseAttributeConfigForUpdate, parseComputedFormula, selectOptionWriteSchema, statusGroupSchema, statusOptionWriteSchema } from './chunk-
|
|
7
|
-
import { createObjectValidator, createAttributeValidator, isNullishOrEmptyString } from './chunk-
|
|
8
|
-
export { createFormAttributeValidator, isNullishOrEmptyString, isValuePresent, rejectUnknownAttributesOrThrow, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow } from './chunk-
|
|
1
|
+
import { canonicalStringify, generateId } from './chunk-XCLVXM7F.mjs';
|
|
2
|
+
export { asTenantId, asUserId, canonicalStringify, deepEqual, generateId, indexBy } from './chunk-XCLVXM7F.mjs';
|
|
3
|
+
import { SYSTEM_FILTER_ATTRIBUTE_TYPES, RESERVED_OBJECT_NAMES, listViewConfigSchema, detailViewConfigSchema, LIST_VIEW_TAB_VISIBILITIES, RESERVED_ATTRIBUTE_NAMES, isAttributeSortable, getAttributeCapabilities, resolveIsWithinBounds, normalizeForEdgeRpc, getOperatorPolarity, extractCurrencyFilterValue } from './chunk-ORPCS24B.mjs';
|
|
4
|
+
export { ATTRIBUTE_FILTER_OPERATORS, LIST_VIEW_TAB_VISIBILITIES, NO_VALUE_OPERATORS, OPERATORS_BY_TYPE, REMOVED_OPERATOR_REPLACEMENTS, RESERVED_ATTRIBUTE_NAMES, RESERVED_OBJECT_NAMES, RESOURCE_VISIBILITIES, SYNONYM_ALIASES, SYSTEM_ATTRIBUTES, SYSTEM_ATTRIBUTE_I18N_KEYS, SYSTEM_FIELD_NAMES, SYSTEM_FILTER_ATTRIBUTE_TYPES, canonicalizeFilterValue, collectQualifiedRuleIssues, currentActor, detailTabSchema, detailViewConfigSchema, extractCurrencyFilterValue, extractFilterValue, getAttributeCapabilities, getAttributeFilterOperators, getOperatorPolarity, getRollupFilterOperators, getSystemAttributeI18nKey, getSystemAttributeList, inverseSourceSchema, isAttributeFilterable, isAttributeGroupable, isAttributeKanbanGroupable, isAttributeSearchable, isDynamicValue, isManagedSystemAttribute, isNoValueOperator, isRelativeDateValue, isSetMembershipOperator, listViewConfigSchema, listViewTabSchema, normalizeFilterRule, normalizeForEdgeRpc, normalizeOperator, now, parseResourceVisibility, parseViewConfig, relationSourceSchema, resolveEffectiveFilterType, resolveIsWithinBounds, resolveUtcDayBounds, tableSourceSchema, toMultiValueOperator, toUtcDayString, today, validateQualifiedRule, viewConfigByTypeSchema, viewTypeSchema } from './chunk-ORPCS24B.mjs';
|
|
5
|
+
import { iconNameSchema, parseAttributeConfigForCreate, parseComputedFormula } from './chunk-A5PPZ2FM.mjs';
|
|
6
|
+
export { ComputedFormulaParseError, SCHEMA_LIMITS, colorIdSchema, iconNameSchema, multiselectOptionWriteSchema, parseAttributeConfig, parseAttributeConfigForCreate, parseAttributeConfigForUpdate, parseComputedFormula, selectOptionWriteSchema, statusGroupSchema, statusOptionWriteSchema } from './chunk-A5PPZ2FM.mjs';
|
|
7
|
+
import { createObjectValidator, createAttributeValidator, isNullishOrEmptyString } from './chunk-MLTXSBOB.mjs';
|
|
8
|
+
export { createFormAttributeValidator, isNullishOrEmptyString, isValuePresent, rejectUnknownAttributesOrThrow, validateDraft, validateDraftOrThrow, validateObject, validateObjectOrThrow } from './chunk-MLTXSBOB.mjs';
|
|
9
9
|
import './chunk-QVLQPW3O.mjs';
|
|
10
10
|
import './chunk-ZDQ5AP26.mjs';
|
|
11
11
|
import './chunk-LV3FEUKU.mjs';
|
|
@@ -15,8 +15,8 @@ export { createCheckboxValidator } from './chunk-OSSGN43B.mjs';
|
|
|
15
15
|
export { createDateValidator } from './chunk-Q44QKLN4.mjs';
|
|
16
16
|
export { createNumberValidator } from './chunk-UANQJ2GH.mjs';
|
|
17
17
|
export { TEXT_FORMAT_PATTERNS, createTextValidator, resolveTextPattern } from './chunk-O73ROMWQ.mjs';
|
|
18
|
-
import { SchemaError, SchemaErrorCode, ValidationError, DuplicateError, NotFoundError } from './chunk-
|
|
19
|
-
export { AccessDeniedError, AttributeInUseError, AttributeNotFoundError, ChangeTypeNotSupportedError, ConcurrentModificationError, DestructiveSyncNotAllowedError, DuplicateError, ForbiddenError, MemoryNotFoundError, MigrationTimeoutError, NotFoundError, NotImplementedError, ObjectNotFoundError, ObjectReferencedError, OrphanSystemAttributeError, ProtectedResourceError, ProtectedRoleError, RecordNotFoundError, RecordReferencedError, RepositoryError, RoleNotFoundError, SchemaError, SchemaErrorCode, SchemaPlanNotFoundError, SearchBackendError, StorageError, SyncCascadeError, SyncConflictError, SyncError, SystemEntityImmutableError, ValidationError, isAttributeInUseError, isNotFoundError, isObjectReferencedError, isProtectedResourceError, isRecordReferencedError, isSchemaError, isValidationError } from './chunk-
|
|
18
|
+
import { SchemaError, SchemaErrorCode, ValidationError, DuplicateError, NotFoundError } from './chunk-SYQDFZ74.mjs';
|
|
19
|
+
export { AccessDeniedError, AttributeInUseError, AttributeNotFoundError, ChangeTypeNotSupportedError, ConcurrentModificationError, DestructiveSyncNotAllowedError, DuplicateError, ForbiddenError, MemoryNotFoundError, MigrationTimeoutError, NotFoundError, NotImplementedError, ObjectNotFoundError, ObjectReferencedError, OrphanSystemAttributeError, ProtectedResourceError, ProtectedRoleError, RecordNotFoundError, RecordReferencedError, RepositoryError, RoleNotFoundError, SchemaError, SchemaErrorCode, SchemaPlanNotFoundError, SearchBackendError, StorageError, SyncCascadeError, SyncConflictError, SyncError, SystemEntityImmutableError, ValidationError, isAttributeInUseError, isNotFoundError, isObjectReferencedError, isProtectedResourceError, isRecordReferencedError, isSchemaError, isValidationError } from './chunk-SYQDFZ74.mjs';
|
|
20
20
|
import './chunk-AYVHMVKQ.mjs';
|
|
21
21
|
import './chunk-YUFTHPOE.mjs';
|
|
22
22
|
import { formatPhoneForDisplay, normalizeCountrylessPhoneNumber, normalizePhoneNumber } from './chunk-R5LAJCBU.mjs';
|
|
@@ -184,6 +184,18 @@ var SESSION_TERMINAL_STATUSES = [
|
|
|
184
184
|
function isTerminalSessionStatus(status2) {
|
|
185
185
|
return SESSION_TERMINAL_STATUSES.includes(status2);
|
|
186
186
|
}
|
|
187
|
+
var CLAIMABLE_SESSION_STATUSES = [
|
|
188
|
+
"idle",
|
|
189
|
+
"completed",
|
|
190
|
+
"waiting_human",
|
|
191
|
+
"waiting_agents",
|
|
192
|
+
"cancelled",
|
|
193
|
+
"failed",
|
|
194
|
+
"timeout"
|
|
195
|
+
];
|
|
196
|
+
function isClaimableSessionStatus(status2) {
|
|
197
|
+
return CLAIMABLE_SESSION_STATUSES.includes(status2);
|
|
198
|
+
}
|
|
187
199
|
var DEFAULT_APPROVAL_POLICY = Object.freeze({
|
|
188
200
|
mutation: "ask",
|
|
189
201
|
destructive: "ask",
|
|
@@ -375,9 +387,6 @@ function isListView(view) {
|
|
|
375
387
|
function isFieldGroup(group2) {
|
|
376
388
|
return group2.type === "fields";
|
|
377
389
|
}
|
|
378
|
-
function isRelationGroup(group2) {
|
|
379
|
-
return group2.type === "relation";
|
|
380
|
-
}
|
|
381
390
|
|
|
382
391
|
// src/types/pagination.ts
|
|
383
392
|
var COUNT_MODES = ["none", "estimated", "exact"];
|
|
@@ -2798,6 +2807,21 @@ var ObjectBuilder = class {
|
|
|
2798
2807
|
this.obj.metadata = { ...this.obj.metadata, order: value };
|
|
2799
2808
|
return this;
|
|
2800
2809
|
}
|
|
2810
|
+
/**
|
|
2811
|
+
* Hide this object from navigation surfaces — the sidebar data section and
|
|
2812
|
+
* the command palette, which already honour `metadata.hidden`. For objects
|
|
2813
|
+
* that own a dedicated surface: `drives` has the Drive page, so listing it
|
|
2814
|
+
* beside business objects would offer the same thing twice under two
|
|
2815
|
+
* different affordances.
|
|
2816
|
+
*
|
|
2817
|
+
* The object stays whole everywhere else: API, search, permissions, agent
|
|
2818
|
+
* tools, filters and record pages all continue to see it. This hides a
|
|
2819
|
+
* navigation entry; it never restricts access.
|
|
2820
|
+
*/
|
|
2821
|
+
hidden() {
|
|
2822
|
+
this.obj.metadata = { ...this.obj.metadata, hidden: true };
|
|
2823
|
+
return this;
|
|
2824
|
+
}
|
|
2801
2825
|
/**
|
|
2802
2826
|
* Set the label expression template for displaying records
|
|
2803
2827
|
* This is REQUIRED for every object.
|
|
@@ -3047,74 +3071,6 @@ var GroupBuilder = class {
|
|
|
3047
3071
|
return this.data;
|
|
3048
3072
|
}
|
|
3049
3073
|
};
|
|
3050
|
-
var RelationGroupBuilder = class {
|
|
3051
|
-
constructor(id, label, attribute) {
|
|
3052
|
-
this.data = { type: "relation" };
|
|
3053
|
-
this.data.id = id;
|
|
3054
|
-
this.data.label = label;
|
|
3055
|
-
this.data.attribute = attribute;
|
|
3056
|
-
}
|
|
3057
|
-
/**
|
|
3058
|
-
* Set group description
|
|
3059
|
-
*/
|
|
3060
|
-
description(value) {
|
|
3061
|
-
this.data.description = value;
|
|
3062
|
-
return this;
|
|
3063
|
-
}
|
|
3064
|
-
/**
|
|
3065
|
-
* Make group collapsible
|
|
3066
|
-
* @param collapsed - Initial collapsed state (default: false)
|
|
3067
|
-
*/
|
|
3068
|
-
collapsible(collapsed = false) {
|
|
3069
|
-
this.data.collapsible = true;
|
|
3070
|
-
this.data.collapsed = collapsed;
|
|
3071
|
-
return this;
|
|
3072
|
-
}
|
|
3073
|
-
/**
|
|
3074
|
-
* Set display order
|
|
3075
|
-
*/
|
|
3076
|
-
order(value) {
|
|
3077
|
-
this.data.order = value;
|
|
3078
|
-
return this;
|
|
3079
|
-
}
|
|
3080
|
-
/**
|
|
3081
|
-
* Set columns to display in the relations table
|
|
3082
|
-
* @example .columns("name", "email", "phone")
|
|
3083
|
-
*/
|
|
3084
|
-
columns(...names) {
|
|
3085
|
-
this.data.columns = names;
|
|
3086
|
-
return this;
|
|
3087
|
-
}
|
|
3088
|
-
/**
|
|
3089
|
-
* Set the group as read-only (no add/remove/edit)
|
|
3090
|
-
*/
|
|
3091
|
-
readOnly(value = true) {
|
|
3092
|
-
this.data.readOnly = value;
|
|
3093
|
-
return this;
|
|
3094
|
-
}
|
|
3095
|
-
/**
|
|
3096
|
-
* Allow creating new related records inline
|
|
3097
|
-
*/
|
|
3098
|
-
allowCreate(value = true) {
|
|
3099
|
-
this.data.allowCreate = value;
|
|
3100
|
-
return this;
|
|
3101
|
-
}
|
|
3102
|
-
/**
|
|
3103
|
-
* Build the relation group definition
|
|
3104
|
-
*/
|
|
3105
|
-
build() {
|
|
3106
|
-
if (!this.data.id) {
|
|
3107
|
-
throw new Error("[RelationGroupBuilder] id is required");
|
|
3108
|
-
}
|
|
3109
|
-
if (!this.data.label) {
|
|
3110
|
-
throw new Error("[RelationGroupBuilder] label is required");
|
|
3111
|
-
}
|
|
3112
|
-
if (!this.data.attribute) {
|
|
3113
|
-
throw new Error("[RelationGroupBuilder] attribute is required");
|
|
3114
|
-
}
|
|
3115
|
-
return this.data;
|
|
3116
|
-
}
|
|
3117
|
-
};
|
|
3118
3074
|
var TableTabConfig = class {
|
|
3119
3075
|
/** @internal */
|
|
3120
3076
|
constructor(view, tabData) {
|
|
@@ -3465,7 +3421,7 @@ var TabBuilder = class {
|
|
|
3465
3421
|
// ─────────────────────────────────────────────────────────────────────────
|
|
3466
3422
|
/**
|
|
3467
3423
|
* Create a form tab with groups
|
|
3468
|
-
* @example .form(group("info", "Info").fields("name", "email")
|
|
3424
|
+
* @example .form(group("info", "Info").fields("name", "email"))
|
|
3469
3425
|
*/
|
|
3470
3426
|
form(...groups) {
|
|
3471
3427
|
if (groups.length === 0) {
|
|
@@ -3476,9 +3432,7 @@ var TabBuilder = class {
|
|
|
3476
3432
|
const tab = {
|
|
3477
3433
|
...this.base,
|
|
3478
3434
|
type: "form",
|
|
3479
|
-
groups: groups.map(
|
|
3480
|
-
(g) => g instanceof GroupBuilder || g instanceof RelationGroupBuilder ? g.build() : g
|
|
3481
|
-
)
|
|
3435
|
+
groups: groups.map((g) => g instanceof GroupBuilder ? g.build() : g)
|
|
3482
3436
|
};
|
|
3483
3437
|
return this.view._addTab(tab);
|
|
3484
3438
|
}
|
|
@@ -4022,9 +3976,6 @@ function listView(name, label) {
|
|
|
4022
3976
|
function group(id, label) {
|
|
4023
3977
|
return new GroupBuilder(id, label);
|
|
4024
3978
|
}
|
|
4025
|
-
function relationGroup(id, label, attribute) {
|
|
4026
|
-
return new RelationGroupBuilder(id, label, attribute);
|
|
4027
|
-
}
|
|
4028
3979
|
|
|
4029
3980
|
// src/feature-flags/flag-builder.ts
|
|
4030
3981
|
function validateFlagName(name) {
|
|
@@ -4361,7 +4312,25 @@ var FlagService = class {
|
|
|
4361
4312
|
* @returns Map of flag names to resolved values
|
|
4362
4313
|
*/
|
|
4363
4314
|
async resolveAll(context = {}) {
|
|
4364
|
-
const
|
|
4315
|
+
const flagNames = this.collectFlagNames();
|
|
4316
|
+
const overrides = this.repository && flagNames.size > 0 ? await this.getAllOverrides(context, [...flagNames]) : emptyOverrides();
|
|
4317
|
+
return this.resolveNames(flagNames, overrides, context);
|
|
4318
|
+
}
|
|
4319
|
+
/**
|
|
4320
|
+
* Resolve every flag from static defaults only, never touching the
|
|
4321
|
+
* overrides repository.
|
|
4322
|
+
*
|
|
4323
|
+
* For callers running outside any tenant context (e.g. tenant-less public
|
|
4324
|
+
* HTTP routes such as the connectors OAuth callback): overrides are
|
|
4325
|
+
* tenant-scoped in storage, so without a tenant there is nothing to fetch —
|
|
4326
|
+
* and asking the repository anyway would require the very context that is
|
|
4327
|
+
* absent.
|
|
4328
|
+
*/
|
|
4329
|
+
resolveAllStatic() {
|
|
4330
|
+
return this.resolveNames(this.collectFlagNames(), emptyOverrides(), {});
|
|
4331
|
+
}
|
|
4332
|
+
/** Flag names known to this service: registry entries plus static defaults. */
|
|
4333
|
+
collectFlagNames() {
|
|
4365
4334
|
const flagNames = /* @__PURE__ */ new Set();
|
|
4366
4335
|
for (const name of this.registry.listNames()) {
|
|
4367
4336
|
flagNames.add(name);
|
|
@@ -4369,10 +4338,12 @@ var FlagService = class {
|
|
|
4369
4338
|
for (const name of this.staticDefaults.keys()) {
|
|
4370
4339
|
flagNames.add(name);
|
|
4371
4340
|
}
|
|
4372
|
-
|
|
4341
|
+
return flagNames;
|
|
4342
|
+
}
|
|
4343
|
+
resolveNames(flagNames, overrides, context) {
|
|
4344
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
4373
4345
|
for (const name of flagNames) {
|
|
4374
|
-
|
|
4375
|
-
resolved.set(name, value);
|
|
4346
|
+
resolved.set(name, this.resolveValue(name, overrides, context));
|
|
4376
4347
|
}
|
|
4377
4348
|
return resolved;
|
|
4378
4349
|
}
|
|
@@ -4760,6 +4731,12 @@ var MEMORY_VIEW = detailView("memory-detail", "Memory").for("memory").default().
|
|
|
4760
4731
|
}).tab("content", "Content").richtext("content").titleAttribute("name").build();
|
|
4761
4732
|
var MEMORY_LIST_VIEW = listView("memory-list", "Memories").for("memory").default().tab("workspace", "Memories").default().icon("table").visibility("workspace").table().columns("name", "kind", "description", "createdAt").sort("name", "asc").tab("mine", "My memories").icon("lock").visibility("private").table().columns("name", "kind", "description", "createdAt").sort("name", "asc").build();
|
|
4762
4733
|
|
|
4734
|
+
// src/native/drive.object.ts
|
|
4735
|
+
var DRIVE_OBJECT_NAME = "drives";
|
|
4736
|
+
var DRIVE_OBJECT = object({ name: DRIVE_OBJECT_NAME, label: "Drive" }).sealed().icon("folder").hidden().pluralLabel("Drives").labelExpression("{{ name }}").embeddingExpression("{{ name }}\n{{ description }}").attribute(text({ name: "name", label: "Name" }).required()).attribute(text({ name: "description", label: "Description" }).multiline()).build();
|
|
4737
|
+
var DRIVE_VIEW = detailView("drive-detail", "Drive").for(DRIVE_OBJECT_NAME).default().sidePanel({ attributes: ["description"] }).tab("documents", "Documents").documents().build();
|
|
4738
|
+
var DRIVE_LIST_VIEW = listView("drive-list", "Drives").for(DRIVE_OBJECT_NAME).default().tab("workspace", "Shared").default().icon("users").visibility("workspace").table().columns("name", "description", "updatedAt").sort("name", "asc").tab("mine", "My drives").icon("lock").visibility("private").table().columns("name", "description", "updatedAt").sort("name", "asc").build();
|
|
4739
|
+
|
|
4763
4740
|
// src/views/registry.ts
|
|
4764
4741
|
function cloneViewDefinition(view) {
|
|
4765
4742
|
return structuredClone(view);
|
|
@@ -7049,37 +7026,6 @@ var CONNECTOR_CALLBACK_PARAM = {
|
|
|
7049
7026
|
provider: "connector_provider"
|
|
7050
7027
|
};
|
|
7051
7028
|
|
|
7052
|
-
// src/utils/canonical-json.ts
|
|
7053
|
-
function canonicalStringify(value) {
|
|
7054
|
-
const seen = /* @__PURE__ */ new Set();
|
|
7055
|
-
function encode(v) {
|
|
7056
|
-
if (v === null) return "null";
|
|
7057
|
-
switch (typeof v) {
|
|
7058
|
-
case "string":
|
|
7059
|
-
case "number":
|
|
7060
|
-
case "boolean":
|
|
7061
|
-
return JSON.stringify(v);
|
|
7062
|
-
case "undefined":
|
|
7063
|
-
return void 0;
|
|
7064
|
-
case "object":
|
|
7065
|
-
break;
|
|
7066
|
-
default:
|
|
7067
|
-
throw new ValidationError(`Cannot canonicalize value of type ${typeof v}`, []);
|
|
7068
|
-
}
|
|
7069
|
-
const obj = v;
|
|
7070
|
-
if (seen.has(obj)) throw new ValidationError("Cannot canonicalize circular structure", []);
|
|
7071
|
-
seen.add(obj);
|
|
7072
|
-
try {
|
|
7073
|
-
if (Array.isArray(obj)) return `[${obj.map((e) => encode(e) ?? "null").join(",")}]`;
|
|
7074
|
-
const entries = Object.entries(obj).map(([k, val]) => [k, encode(val)]).filter((pair) => pair[1] !== void 0).sort(([a], [b]) => a < b ? -1 : 1);
|
|
7075
|
-
return `{${entries.map(([k, val]) => `${JSON.stringify(k)}:${val}`).join(",")}}`;
|
|
7076
|
-
} finally {
|
|
7077
|
-
seen.delete(obj);
|
|
7078
|
-
}
|
|
7079
|
-
}
|
|
7080
|
-
return encode(value) ?? "null";
|
|
7081
|
-
}
|
|
7082
|
-
|
|
7083
7029
|
// src/utils/attribute-defaults.ts
|
|
7084
7030
|
var TODAY_DEFAULT = "today";
|
|
7085
7031
|
function dateInTimezone(date2, timezone) {
|
|
@@ -7537,4 +7483,904 @@ var persistedSchemaPlanSchema = z.preprocess(
|
|
|
7537
7483
|
structuralPersistedSchemaPlanSchema
|
|
7538
7484
|
);
|
|
7539
7485
|
|
|
7540
|
-
|
|
7486
|
+
// src/architect/define-operation.ts
|
|
7487
|
+
function defineOperation(def) {
|
|
7488
|
+
return def;
|
|
7489
|
+
}
|
|
7490
|
+
var operationBase = { id: z.string().min(1) };
|
|
7491
|
+
var viewOperationBase = { ...operationBase, viewId: z.string().min(1) };
|
|
7492
|
+
function mapView(state, viewId, fn) {
|
|
7493
|
+
if (!state.views.some((v) => v.id === viewId)) {
|
|
7494
|
+
throw new ValidationError(`View "${viewId}" is not in the draftable state`, []);
|
|
7495
|
+
}
|
|
7496
|
+
return { ...state, views: state.views.map((v) => v.id === viewId ? fn(v) : v) };
|
|
7497
|
+
}
|
|
7498
|
+
function moveWithin(items, from, toIndex) {
|
|
7499
|
+
const next = [...items];
|
|
7500
|
+
const [item] = next.splice(from, 1);
|
|
7501
|
+
next.splice(toIndex, 0, item);
|
|
7502
|
+
return next;
|
|
7503
|
+
}
|
|
7504
|
+
function reorderById(items, order, what) {
|
|
7505
|
+
if (order.length !== items.length) {
|
|
7506
|
+
throw new ValidationError(
|
|
7507
|
+
`${what} order lists ${order.length} ids for ${items.length} items`,
|
|
7508
|
+
[]
|
|
7509
|
+
);
|
|
7510
|
+
}
|
|
7511
|
+
return order.map((id) => {
|
|
7512
|
+
const found = items.find((item) => item.id === id);
|
|
7513
|
+
if (!found) throw new ValidationError(`${what} "${id}" is not in this collection`, []);
|
|
7514
|
+
return found;
|
|
7515
|
+
});
|
|
7516
|
+
}
|
|
7517
|
+
|
|
7518
|
+
// src/architect/operations/detail-view.ts
|
|
7519
|
+
function mapFormTab(view, tabId, fn) {
|
|
7520
|
+
const found = view.tabs.find((t) => t.id === tabId);
|
|
7521
|
+
if (!found) throw new ValidationError(`Tab "${tabId}" is not in view "${view.id}"`, []);
|
|
7522
|
+
if (found.type !== "form") {
|
|
7523
|
+
throw new ValidationError(`Tab "${tabId}" is not a form tab`, []);
|
|
7524
|
+
}
|
|
7525
|
+
return { ...view, tabs: view.tabs.map((t) => t.id === tabId ? fn(found) : t) };
|
|
7526
|
+
}
|
|
7527
|
+
function requireGroup(tab, groupId) {
|
|
7528
|
+
const found = tab.groups.find((g) => g.id === groupId);
|
|
7529
|
+
if (!found) throw new ValidationError(`Group "${groupId}" is not in tab "${tab.id}"`, []);
|
|
7530
|
+
return found;
|
|
7531
|
+
}
|
|
7532
|
+
function locateField(tab, fieldId) {
|
|
7533
|
+
for (const group2 of tab.groups) {
|
|
7534
|
+
const field = group2.fields.find((f) => f.id === fieldId);
|
|
7535
|
+
if (field) return { group: group2, field };
|
|
7536
|
+
}
|
|
7537
|
+
throw new ValidationError(`Field slot "${fieldId}" is not in tab "${tab.id}"`, []);
|
|
7538
|
+
}
|
|
7539
|
+
var tabPayload = z.custom(
|
|
7540
|
+
(value) => typeof value === "object" && value !== null && "id" in value && "type" in value,
|
|
7541
|
+
{ message: "A tab must be an object carrying id and type" }
|
|
7542
|
+
);
|
|
7543
|
+
var groupPayload = z.custom(
|
|
7544
|
+
(value) => typeof value === "object" && value !== null && "id" in value && "fields" in value,
|
|
7545
|
+
{ message: "A group must be an object carrying id and fields" }
|
|
7546
|
+
);
|
|
7547
|
+
var fieldPayload = z.custom(
|
|
7548
|
+
(value) => typeof value === "object" && value !== null && "id" in value,
|
|
7549
|
+
{ message: "A field slot must be an object carrying an id" }
|
|
7550
|
+
);
|
|
7551
|
+
var addTabSchema = z.object({
|
|
7552
|
+
...viewOperationBase,
|
|
7553
|
+
type: z.literal("add_tab"),
|
|
7554
|
+
tab: tabPayload
|
|
7555
|
+
});
|
|
7556
|
+
var addTab = defineOperation({
|
|
7557
|
+
type: "add_tab",
|
|
7558
|
+
schema: addTabSchema,
|
|
7559
|
+
apply: (state, op) => mapView(state, op.viewId, (view) => {
|
|
7560
|
+
if (view.tabs.some((t) => t.id === op.tab.id)) {
|
|
7561
|
+
throw new ValidationError(`Tab "${op.tab.id}" already exists in view "${op.viewId}"`, []);
|
|
7562
|
+
}
|
|
7563
|
+
return { ...view, tabs: [...view.tabs, op.tab] };
|
|
7564
|
+
}),
|
|
7565
|
+
focus: (op) => ({ viewId: op.viewId, tabId: op.tab.id }),
|
|
7566
|
+
describe: (op) => `Ajoute l'onglet \xAB ${op.tab.label} \xBB`
|
|
7567
|
+
});
|
|
7568
|
+
var removeTabSchema = z.object({
|
|
7569
|
+
...viewOperationBase,
|
|
7570
|
+
type: z.literal("remove_tab"),
|
|
7571
|
+
tabId: z.string().min(1)
|
|
7572
|
+
});
|
|
7573
|
+
var removeTab = defineOperation({
|
|
7574
|
+
type: "remove_tab",
|
|
7575
|
+
schema: removeTabSchema,
|
|
7576
|
+
apply: (state, op) => mapView(state, op.viewId, (view) => {
|
|
7577
|
+
if (!view.tabs.some((t) => t.id === op.tabId)) {
|
|
7578
|
+
throw new ValidationError(`Tab "${op.tabId}" is not in view "${op.viewId}"`, []);
|
|
7579
|
+
}
|
|
7580
|
+
return { ...view, tabs: view.tabs.filter((t) => t.id !== op.tabId) };
|
|
7581
|
+
}),
|
|
7582
|
+
focus: (op) => ({ viewId: op.viewId }),
|
|
7583
|
+
describe: (op) => `Supprime l'onglet ${op.tabId}`
|
|
7584
|
+
});
|
|
7585
|
+
var updateTabSchema = z.object({
|
|
7586
|
+
...viewOperationBase,
|
|
7587
|
+
type: z.literal("update_tab"),
|
|
7588
|
+
tabId: z.string().min(1),
|
|
7589
|
+
changes: z.object({
|
|
7590
|
+
label: z.string().min(1).optional(),
|
|
7591
|
+
icon: z.custom((v) => typeof v === "string" && v.length > 0).optional(),
|
|
7592
|
+
order: z.number().int().optional()
|
|
7593
|
+
}).refine((c) => Object.keys(c).length > 0, "update_tab needs at least one change")
|
|
7594
|
+
});
|
|
7595
|
+
var updateTab = defineOperation({
|
|
7596
|
+
type: "update_tab",
|
|
7597
|
+
schema: updateTabSchema,
|
|
7598
|
+
apply: (state, op) => mapView(state, op.viewId, (view) => {
|
|
7599
|
+
if (!view.tabs.some((t) => t.id === op.tabId)) {
|
|
7600
|
+
throw new ValidationError(`Tab "${op.tabId}" is not in view "${op.viewId}"`, []);
|
|
7601
|
+
}
|
|
7602
|
+
return {
|
|
7603
|
+
...view,
|
|
7604
|
+
tabs: view.tabs.map((t) => t.id === op.tabId ? { ...t, ...op.changes } : t)
|
|
7605
|
+
};
|
|
7606
|
+
}),
|
|
7607
|
+
focus: (op) => ({ viewId: op.viewId, tabId: op.tabId }),
|
|
7608
|
+
describe: (op) => op.changes.label ? `Renomme l'onglet en \xAB ${op.changes.label} \xBB` : `Modifie l'onglet ${op.tabId}`
|
|
7609
|
+
});
|
|
7610
|
+
var reorderTabsSchema = z.object({
|
|
7611
|
+
...viewOperationBase,
|
|
7612
|
+
type: z.literal("reorder_tabs"),
|
|
7613
|
+
tabOrder: z.array(z.string().min(1))
|
|
7614
|
+
});
|
|
7615
|
+
var reorderTabs = defineOperation({
|
|
7616
|
+
type: "reorder_tabs",
|
|
7617
|
+
schema: reorderTabsSchema,
|
|
7618
|
+
apply: (state, op) => mapView(state, op.viewId, (view) => ({
|
|
7619
|
+
...view,
|
|
7620
|
+
tabs: reorderById(view.tabs, op.tabOrder, "Tab")
|
|
7621
|
+
})),
|
|
7622
|
+
focus: (op) => ({ viewId: op.viewId }),
|
|
7623
|
+
describe: () => "R\xE9ordonne les onglets"
|
|
7624
|
+
});
|
|
7625
|
+
var addGroupSchema = z.object({
|
|
7626
|
+
...viewOperationBase,
|
|
7627
|
+
type: z.literal("add_group"),
|
|
7628
|
+
tabId: z.string().min(1),
|
|
7629
|
+
group: groupPayload
|
|
7630
|
+
});
|
|
7631
|
+
var addGroup = defineOperation({
|
|
7632
|
+
type: "add_group",
|
|
7633
|
+
schema: addGroupSchema,
|
|
7634
|
+
apply: (state, op) => mapView(
|
|
7635
|
+
state,
|
|
7636
|
+
op.viewId,
|
|
7637
|
+
(view) => mapFormTab(view, op.tabId, (tab) => {
|
|
7638
|
+
if (tab.groups.some((g) => g.id === op.group.id)) {
|
|
7639
|
+
throw new ValidationError(
|
|
7640
|
+
`Group "${op.group.id}" already exists in tab "${op.tabId}"`,
|
|
7641
|
+
[]
|
|
7642
|
+
);
|
|
7643
|
+
}
|
|
7644
|
+
return { ...tab, groups: [...tab.groups, op.group] };
|
|
7645
|
+
})
|
|
7646
|
+
),
|
|
7647
|
+
focus: (op) => ({ viewId: op.viewId, tabId: op.tabId, groupId: op.group.id }),
|
|
7648
|
+
describe: (op) => `Ajoute le groupe \xAB ${op.group.label} \xBB`
|
|
7649
|
+
});
|
|
7650
|
+
var removeGroupSchema = z.object({
|
|
7651
|
+
...viewOperationBase,
|
|
7652
|
+
type: z.literal("remove_group"),
|
|
7653
|
+
tabId: z.string().min(1),
|
|
7654
|
+
groupId: z.string().min(1)
|
|
7655
|
+
});
|
|
7656
|
+
var removeGroup = defineOperation({
|
|
7657
|
+
type: "remove_group",
|
|
7658
|
+
schema: removeGroupSchema,
|
|
7659
|
+
apply: (state, op) => mapView(
|
|
7660
|
+
state,
|
|
7661
|
+
op.viewId,
|
|
7662
|
+
(view) => mapFormTab(view, op.tabId, (tab) => {
|
|
7663
|
+
requireGroup(tab, op.groupId);
|
|
7664
|
+
return { ...tab, groups: tab.groups.filter((g) => g.id !== op.groupId) };
|
|
7665
|
+
})
|
|
7666
|
+
),
|
|
7667
|
+
focus: (op) => ({ viewId: op.viewId, tabId: op.tabId }),
|
|
7668
|
+
describe: (op) => `Supprime le groupe ${op.groupId}`
|
|
7669
|
+
});
|
|
7670
|
+
var setGroupLabelSchema = z.object({
|
|
7671
|
+
...viewOperationBase,
|
|
7672
|
+
type: z.literal("set_group_label"),
|
|
7673
|
+
tabId: z.string().min(1),
|
|
7674
|
+
groupId: z.string().min(1),
|
|
7675
|
+
label: z.string().min(1)
|
|
7676
|
+
});
|
|
7677
|
+
var setGroupLabel = defineOperation({
|
|
7678
|
+
type: "set_group_label",
|
|
7679
|
+
schema: setGroupLabelSchema,
|
|
7680
|
+
apply: (state, op) => mapView(
|
|
7681
|
+
state,
|
|
7682
|
+
op.viewId,
|
|
7683
|
+
(view) => mapFormTab(view, op.tabId, (tab) => {
|
|
7684
|
+
requireGroup(tab, op.groupId);
|
|
7685
|
+
return {
|
|
7686
|
+
...tab,
|
|
7687
|
+
groups: tab.groups.map((g) => g.id === op.groupId ? { ...g, label: op.label } : g)
|
|
7688
|
+
};
|
|
7689
|
+
})
|
|
7690
|
+
),
|
|
7691
|
+
focus: (op) => ({ viewId: op.viewId, tabId: op.tabId, groupId: op.groupId }),
|
|
7692
|
+
describe: (op) => `Renomme le groupe en \xAB ${op.label} \xBB`
|
|
7693
|
+
});
|
|
7694
|
+
var reorderGroupsSchema = z.object({
|
|
7695
|
+
...viewOperationBase,
|
|
7696
|
+
type: z.literal("reorder_groups"),
|
|
7697
|
+
tabId: z.string().min(1),
|
|
7698
|
+
groupOrder: z.array(z.string().min(1))
|
|
7699
|
+
});
|
|
7700
|
+
var reorderGroups = defineOperation({
|
|
7701
|
+
type: "reorder_groups",
|
|
7702
|
+
schema: reorderGroupsSchema,
|
|
7703
|
+
apply: (state, op) => mapView(
|
|
7704
|
+
state,
|
|
7705
|
+
op.viewId,
|
|
7706
|
+
(view) => mapFormTab(view, op.tabId, (tab) => ({
|
|
7707
|
+
...tab,
|
|
7708
|
+
groups: reorderById(tab.groups, op.groupOrder, "Group")
|
|
7709
|
+
}))
|
|
7710
|
+
),
|
|
7711
|
+
focus: (op) => ({ viewId: op.viewId, tabId: op.tabId }),
|
|
7712
|
+
describe: () => "R\xE9ordonne les groupes"
|
|
7713
|
+
});
|
|
7714
|
+
var addFieldSchema = z.object({
|
|
7715
|
+
...viewOperationBase,
|
|
7716
|
+
type: z.literal("add_field"),
|
|
7717
|
+
tabId: z.string().min(1),
|
|
7718
|
+
groupId: z.string().min(1),
|
|
7719
|
+
field: fieldPayload,
|
|
7720
|
+
index: z.number().int().min(0).optional()
|
|
7721
|
+
});
|
|
7722
|
+
var addField = defineOperation({
|
|
7723
|
+
type: "add_field",
|
|
7724
|
+
schema: addFieldSchema,
|
|
7725
|
+
apply: (state, op) => mapView(
|
|
7726
|
+
state,
|
|
7727
|
+
op.viewId,
|
|
7728
|
+
(view) => mapFormTab(view, op.tabId, (tab) => {
|
|
7729
|
+
requireGroup(tab, op.groupId);
|
|
7730
|
+
if (tab.groups.some((g) => g.fields.some((f) => f.id === op.field.id))) {
|
|
7731
|
+
throw new ValidationError(
|
|
7732
|
+
`Field slot "${op.field.id}" already exists in tab "${op.tabId}"`,
|
|
7733
|
+
[]
|
|
7734
|
+
);
|
|
7735
|
+
}
|
|
7736
|
+
return {
|
|
7737
|
+
...tab,
|
|
7738
|
+
groups: tab.groups.map((group2) => {
|
|
7739
|
+
if (group2.id !== op.groupId) return group2;
|
|
7740
|
+
const at = op.index ?? group2.fields.length;
|
|
7741
|
+
return {
|
|
7742
|
+
...group2,
|
|
7743
|
+
fields: [...group2.fields.slice(0, at), op.field, ...group2.fields.slice(at)]
|
|
7744
|
+
};
|
|
7745
|
+
})
|
|
7746
|
+
};
|
|
7747
|
+
})
|
|
7748
|
+
),
|
|
7749
|
+
focus: (op) => ({
|
|
7750
|
+
viewId: op.viewId,
|
|
7751
|
+
tabId: op.tabId,
|
|
7752
|
+
groupId: op.groupId,
|
|
7753
|
+
fieldId: op.field.id
|
|
7754
|
+
}),
|
|
7755
|
+
describe: (op) => `Ajoute le champ ${op.field.attribute ?? op.field.id}`
|
|
7756
|
+
});
|
|
7757
|
+
var removeFieldSchema = z.object({
|
|
7758
|
+
...viewOperationBase,
|
|
7759
|
+
type: z.literal("remove_field"),
|
|
7760
|
+
tabId: z.string().min(1),
|
|
7761
|
+
fieldId: z.string().min(1)
|
|
7762
|
+
});
|
|
7763
|
+
var removeField = defineOperation({
|
|
7764
|
+
type: "remove_field",
|
|
7765
|
+
schema: removeFieldSchema,
|
|
7766
|
+
apply: (state, op) => mapView(
|
|
7767
|
+
state,
|
|
7768
|
+
op.viewId,
|
|
7769
|
+
(view) => mapFormTab(view, op.tabId, (tab) => {
|
|
7770
|
+
const { group: group2 } = locateField(tab, op.fieldId);
|
|
7771
|
+
return {
|
|
7772
|
+
...tab,
|
|
7773
|
+
groups: tab.groups.map(
|
|
7774
|
+
(g) => g.id === group2.id ? { ...g, fields: g.fields.filter((f) => f.id !== op.fieldId) } : g
|
|
7775
|
+
)
|
|
7776
|
+
};
|
|
7777
|
+
})
|
|
7778
|
+
),
|
|
7779
|
+
focus: (op) => ({ viewId: op.viewId, tabId: op.tabId }),
|
|
7780
|
+
describe: (op) => `Retire le champ ${op.fieldId}`
|
|
7781
|
+
});
|
|
7782
|
+
var moveFieldSchema = z.object({
|
|
7783
|
+
...viewOperationBase,
|
|
7784
|
+
type: z.literal("move_field"),
|
|
7785
|
+
tabId: z.string().min(1),
|
|
7786
|
+
fieldId: z.string().min(1),
|
|
7787
|
+
toGroupId: z.string().min(1),
|
|
7788
|
+
toIndex: z.number().int().min(0)
|
|
7789
|
+
});
|
|
7790
|
+
var moveField = defineOperation({
|
|
7791
|
+
type: "move_field",
|
|
7792
|
+
schema: moveFieldSchema,
|
|
7793
|
+
apply: (state, op) => mapView(
|
|
7794
|
+
state,
|
|
7795
|
+
op.viewId,
|
|
7796
|
+
(view) => mapFormTab(view, op.tabId, (tab) => {
|
|
7797
|
+
const { group: source, field } = locateField(tab, op.fieldId);
|
|
7798
|
+
const target = requireGroup(tab, op.toGroupId);
|
|
7799
|
+
if (source.id === target.id) {
|
|
7800
|
+
const from = source.fields.findIndex((f) => f.id === op.fieldId);
|
|
7801
|
+
return {
|
|
7802
|
+
...tab,
|
|
7803
|
+
groups: tab.groups.map(
|
|
7804
|
+
(g) => g.id === source.id ? { ...g, fields: moveWithin(g.fields, from, op.toIndex) } : g
|
|
7805
|
+
)
|
|
7806
|
+
};
|
|
7807
|
+
}
|
|
7808
|
+
return {
|
|
7809
|
+
...tab,
|
|
7810
|
+
groups: tab.groups.map((group2) => {
|
|
7811
|
+
if (group2.id === source.id) {
|
|
7812
|
+
return { ...group2, fields: group2.fields.filter((f) => f.id !== op.fieldId) };
|
|
7813
|
+
}
|
|
7814
|
+
if (group2.id === target.id) {
|
|
7815
|
+
return {
|
|
7816
|
+
...group2,
|
|
7817
|
+
fields: [
|
|
7818
|
+
...group2.fields.slice(0, op.toIndex),
|
|
7819
|
+
field,
|
|
7820
|
+
...group2.fields.slice(op.toIndex)
|
|
7821
|
+
]
|
|
7822
|
+
};
|
|
7823
|
+
}
|
|
7824
|
+
return group2;
|
|
7825
|
+
})
|
|
7826
|
+
};
|
|
7827
|
+
})
|
|
7828
|
+
),
|
|
7829
|
+
focus: (op) => ({
|
|
7830
|
+
viewId: op.viewId,
|
|
7831
|
+
tabId: op.tabId,
|
|
7832
|
+
groupId: op.toGroupId,
|
|
7833
|
+
fieldId: op.fieldId
|
|
7834
|
+
}),
|
|
7835
|
+
describe: (op) => `D\xE9place le champ ${op.fieldId} vers le groupe ${op.toGroupId}`
|
|
7836
|
+
});
|
|
7837
|
+
var updateFieldSchema = z.object({
|
|
7838
|
+
...viewOperationBase,
|
|
7839
|
+
type: z.literal("update_field"),
|
|
7840
|
+
tabId: z.string().min(1),
|
|
7841
|
+
fieldId: z.string().min(1),
|
|
7842
|
+
changes: z.object({
|
|
7843
|
+
label: z.string().optional(),
|
|
7844
|
+
readOnly: z.boolean().optional(),
|
|
7845
|
+
span: z.number().int().min(1).max(12).optional()
|
|
7846
|
+
}).refine((c) => Object.keys(c).length > 0, "update_field needs at least one change")
|
|
7847
|
+
});
|
|
7848
|
+
var updateField = defineOperation({
|
|
7849
|
+
type: "update_field",
|
|
7850
|
+
schema: updateFieldSchema,
|
|
7851
|
+
apply: (state, op) => mapView(
|
|
7852
|
+
state,
|
|
7853
|
+
op.viewId,
|
|
7854
|
+
(view) => mapFormTab(view, op.tabId, (tab) => {
|
|
7855
|
+
locateField(tab, op.fieldId);
|
|
7856
|
+
return {
|
|
7857
|
+
...tab,
|
|
7858
|
+
groups: tab.groups.map((group2) => ({
|
|
7859
|
+
...group2,
|
|
7860
|
+
fields: group2.fields.map(
|
|
7861
|
+
(f) => f.id === op.fieldId ? { ...f, ...op.changes } : f
|
|
7862
|
+
)
|
|
7863
|
+
}))
|
|
7864
|
+
};
|
|
7865
|
+
})
|
|
7866
|
+
),
|
|
7867
|
+
focus: (op) => ({ viewId: op.viewId, tabId: op.tabId, fieldId: op.fieldId }),
|
|
7868
|
+
describe: (op) => `Modifie le champ ${op.fieldId}`
|
|
7869
|
+
});
|
|
7870
|
+
var setSidePanelSchema = z.object({
|
|
7871
|
+
...viewOperationBase,
|
|
7872
|
+
type: z.literal("set_side_panel"),
|
|
7873
|
+
sidePanel: z.object({ attributes: z.array(z.string().min(1)), width: z.number().int().min(1).optional() }).nullable()
|
|
7874
|
+
});
|
|
7875
|
+
var setSidePanel = defineOperation({
|
|
7876
|
+
type: "set_side_panel",
|
|
7877
|
+
schema: setSidePanelSchema,
|
|
7878
|
+
apply: (state, op) => mapView(state, op.viewId, (view) => ({
|
|
7879
|
+
...view,
|
|
7880
|
+
config: {
|
|
7881
|
+
...view.config,
|
|
7882
|
+
sidePanel: op.sidePanel ?? void 0
|
|
7883
|
+
}
|
|
7884
|
+
})),
|
|
7885
|
+
focus: (op) => ({ viewId: op.viewId }),
|
|
7886
|
+
describe: (op) => op.sidePanel ? "Active le panneau lat\xE9ral" : "Retire le panneau lat\xE9ral"
|
|
7887
|
+
});
|
|
7888
|
+
var DETAIL_VIEW_OPERATIONS = [
|
|
7889
|
+
addTab,
|
|
7890
|
+
removeTab,
|
|
7891
|
+
updateTab,
|
|
7892
|
+
reorderTabs,
|
|
7893
|
+
addGroup,
|
|
7894
|
+
removeGroup,
|
|
7895
|
+
setGroupLabel,
|
|
7896
|
+
reorderGroups,
|
|
7897
|
+
addField,
|
|
7898
|
+
removeField,
|
|
7899
|
+
moveField,
|
|
7900
|
+
updateField,
|
|
7901
|
+
setSidePanel
|
|
7902
|
+
];
|
|
7903
|
+
var listTabBase = { ...viewOperationBase, tabId: z.string().min(1) };
|
|
7904
|
+
function mapListTab(state, viewId, tabId, fn) {
|
|
7905
|
+
return mapView(state, viewId, (view) => {
|
|
7906
|
+
const tabs = view.config.tabs ?? [];
|
|
7907
|
+
if (!tabs.some((t) => t.id === tabId)) {
|
|
7908
|
+
throw new ValidationError(`List tab "${tabId}" is not in view "${viewId}"`, []);
|
|
7909
|
+
}
|
|
7910
|
+
return {
|
|
7911
|
+
...view,
|
|
7912
|
+
config: { ...view.config, tabs: tabs.map((t) => t.id === tabId ? fn(t) : t) }
|
|
7913
|
+
};
|
|
7914
|
+
});
|
|
7915
|
+
}
|
|
7916
|
+
var listTabPayload = z.custom(
|
|
7917
|
+
(value) => typeof value === "object" && value !== null && "id" in value,
|
|
7918
|
+
{ message: "A list tab must be an object carrying an id" }
|
|
7919
|
+
);
|
|
7920
|
+
var filterGroupPayload = z.custom(
|
|
7921
|
+
(value) => value === null || typeof value === "object"
|
|
7922
|
+
);
|
|
7923
|
+
var sortRulesPayload = z.custom((value) => Array.isArray(value));
|
|
7924
|
+
function setOnTab(type, key, valueSchema, describe) {
|
|
7925
|
+
const schema = z.object({ ...listTabBase, type: z.literal(type), value: valueSchema });
|
|
7926
|
+
return defineOperation({
|
|
7927
|
+
type,
|
|
7928
|
+
schema,
|
|
7929
|
+
apply: (state, op) => mapListTab(state, op.viewId, op.tabId, (tab) => {
|
|
7930
|
+
if (op.value === null) {
|
|
7931
|
+
const { [key]: _dropped, ...rest } = tab;
|
|
7932
|
+
return rest;
|
|
7933
|
+
}
|
|
7934
|
+
return { ...tab, [key]: op.value };
|
|
7935
|
+
}),
|
|
7936
|
+
focus: (op) => ({ viewId: op.viewId, tabId: op.tabId }),
|
|
7937
|
+
describe: (op) => describe(op.value)
|
|
7938
|
+
});
|
|
7939
|
+
}
|
|
7940
|
+
var addListTabSchema = z.object({
|
|
7941
|
+
...viewOperationBase,
|
|
7942
|
+
type: z.literal("add_list_tab"),
|
|
7943
|
+
tab: listTabPayload
|
|
7944
|
+
});
|
|
7945
|
+
var addListTab = defineOperation({
|
|
7946
|
+
type: "add_list_tab",
|
|
7947
|
+
schema: addListTabSchema,
|
|
7948
|
+
apply: (state, op) => mapView(state, op.viewId, (view) => {
|
|
7949
|
+
const tabs = view.config.tabs ?? [];
|
|
7950
|
+
if (tabs.some((t) => t.id === op.tab.id)) {
|
|
7951
|
+
throw new ValidationError(
|
|
7952
|
+
`List tab "${op.tab.id}" already exists in view "${op.viewId}"`,
|
|
7953
|
+
[]
|
|
7954
|
+
);
|
|
7955
|
+
}
|
|
7956
|
+
return { ...view, config: { ...view.config, tabs: [...tabs, op.tab] } };
|
|
7957
|
+
}),
|
|
7958
|
+
focus: (op) => ({ viewId: op.viewId, tabId: op.tab.id }),
|
|
7959
|
+
describe: (op) => `Ajoute l'onglet \xAB ${op.tab.label} \xBB`
|
|
7960
|
+
});
|
|
7961
|
+
var removeListTabSchema = z.object({
|
|
7962
|
+
...listTabBase,
|
|
7963
|
+
type: z.literal("remove_list_tab")
|
|
7964
|
+
});
|
|
7965
|
+
var removeListTab = defineOperation({
|
|
7966
|
+
type: "remove_list_tab",
|
|
7967
|
+
schema: removeListTabSchema,
|
|
7968
|
+
apply: (state, op) => mapView(state, op.viewId, (view) => {
|
|
7969
|
+
const tabs = view.config.tabs ?? [];
|
|
7970
|
+
if (!tabs.some((t) => t.id === op.tabId)) {
|
|
7971
|
+
throw new ValidationError(`List tab "${op.tabId}" is not in view "${op.viewId}"`, []);
|
|
7972
|
+
}
|
|
7973
|
+
return {
|
|
7974
|
+
...view,
|
|
7975
|
+
config: { ...view.config, tabs: tabs.filter((t) => t.id !== op.tabId) }
|
|
7976
|
+
};
|
|
7977
|
+
}),
|
|
7978
|
+
focus: (op) => ({ viewId: op.viewId }),
|
|
7979
|
+
describe: (op) => `Supprime l'onglet ${op.tabId}`
|
|
7980
|
+
});
|
|
7981
|
+
var updateListTabSchema = z.object({
|
|
7982
|
+
...listTabBase,
|
|
7983
|
+
type: z.literal("update_list_tab"),
|
|
7984
|
+
changes: z.object({
|
|
7985
|
+
label: z.string().min(1).optional(),
|
|
7986
|
+
icon: z.custom((v) => typeof v === "string" && v.length > 0).optional(),
|
|
7987
|
+
default: z.boolean().optional(),
|
|
7988
|
+
visibility: z.enum(LIST_VIEW_TAB_VISIBILITIES).optional()
|
|
7989
|
+
}).refine((c) => Object.keys(c).length > 0, "update_list_tab needs at least one change")
|
|
7990
|
+
});
|
|
7991
|
+
var updateListTab = defineOperation({
|
|
7992
|
+
type: "update_list_tab",
|
|
7993
|
+
schema: updateListTabSchema,
|
|
7994
|
+
apply: (state, op) => mapListTab(state, op.viewId, op.tabId, (tab) => ({ ...tab, ...op.changes })),
|
|
7995
|
+
focus: (op) => ({ viewId: op.viewId, tabId: op.tabId }),
|
|
7996
|
+
describe: (op) => op.changes.label ? `Renomme l'onglet en \xAB ${op.changes.label} \xBB` : `Modifie l'onglet ${op.tabId}`
|
|
7997
|
+
});
|
|
7998
|
+
var reorderListTabsSchema = z.object({
|
|
7999
|
+
...viewOperationBase,
|
|
8000
|
+
type: z.literal("reorder_list_tabs"),
|
|
8001
|
+
tabOrder: z.array(z.string().min(1))
|
|
8002
|
+
});
|
|
8003
|
+
var reorderListTabs = defineOperation({
|
|
8004
|
+
type: "reorder_list_tabs",
|
|
8005
|
+
schema: reorderListTabsSchema,
|
|
8006
|
+
apply: (state, op) => mapView(state, op.viewId, (view) => ({
|
|
8007
|
+
...view,
|
|
8008
|
+
config: {
|
|
8009
|
+
...view.config,
|
|
8010
|
+
tabs: reorderById(view.config.tabs ?? [], op.tabOrder, "List tab")
|
|
8011
|
+
}
|
|
8012
|
+
})),
|
|
8013
|
+
focus: (op) => ({ viewId: op.viewId }),
|
|
8014
|
+
describe: () => "R\xE9ordonne les onglets"
|
|
8015
|
+
});
|
|
8016
|
+
var setColumns = setOnTab(
|
|
8017
|
+
"set_columns",
|
|
8018
|
+
"columns",
|
|
8019
|
+
z.array(z.string().min(1)),
|
|
8020
|
+
// Defensive on shape: a summary is rendered in a list beside other summaries,
|
|
8021
|
+
// and one malformed payload must not take the page down with it.
|
|
8022
|
+
(value) => `Affiche ${Array.isArray(value) ? value.length : 0} colonne(s)`
|
|
8023
|
+
);
|
|
8024
|
+
var setColumnSizing = setOnTab(
|
|
8025
|
+
"set_column_sizing",
|
|
8026
|
+
"columnSizing",
|
|
8027
|
+
z.record(z.string(), z.number().int().positive()),
|
|
8028
|
+
() => "Ajuste la largeur des colonnes"
|
|
8029
|
+
);
|
|
8030
|
+
var setLayout = setOnTab(
|
|
8031
|
+
"set_layout",
|
|
8032
|
+
"layout",
|
|
8033
|
+
z.enum(["table", "kanban"]),
|
|
8034
|
+
(value) => `Passe en affichage ${value}`
|
|
8035
|
+
);
|
|
8036
|
+
var setGroupBy = setOnTab(
|
|
8037
|
+
"set_group_by",
|
|
8038
|
+
"groupByAttribute",
|
|
8039
|
+
z.string().min(1).nullable(),
|
|
8040
|
+
(value) => value ? `Regroupe par ${value}` : "Retire le regroupement"
|
|
8041
|
+
);
|
|
8042
|
+
var setFilters = setOnTab(
|
|
8043
|
+
"set_filters",
|
|
8044
|
+
"filters",
|
|
8045
|
+
filterGroupPayload.nullable(),
|
|
8046
|
+
(value) => value ? "Modifie les filtres" : "Retire les filtres"
|
|
8047
|
+
);
|
|
8048
|
+
var setSorts = setOnTab(
|
|
8049
|
+
"set_sorts",
|
|
8050
|
+
"sorts",
|
|
8051
|
+
sortRulesPayload.nullable(),
|
|
8052
|
+
(value) => value ? "Modifie le tri" : "Retire le tri"
|
|
8053
|
+
);
|
|
8054
|
+
var setCreateMode = setOnTab(
|
|
8055
|
+
"set_create_mode",
|
|
8056
|
+
"createMode",
|
|
8057
|
+
z.enum(["redirect", "inline", "peek"]),
|
|
8058
|
+
(value) => `Cr\xE9ation en mode ${value}`
|
|
8059
|
+
);
|
|
8060
|
+
var setReadOnly = setOnTab(
|
|
8061
|
+
"set_read_only",
|
|
8062
|
+
"readOnly",
|
|
8063
|
+
z.boolean(),
|
|
8064
|
+
(value) => value ? "Passe l'onglet en lecture seule" : "Rend l'onglet modifiable"
|
|
8065
|
+
);
|
|
8066
|
+
var setCardUserAttribute = setOnTab(
|
|
8067
|
+
"set_card_user_attribute",
|
|
8068
|
+
"cardUserAttribute",
|
|
8069
|
+
z.string().min(1).nullable(),
|
|
8070
|
+
(value) => value ? `Affiche ${value} sur les cartes` : "Retire l'utilisateur des cartes"
|
|
8071
|
+
);
|
|
8072
|
+
var setCardDateAttribute = setOnTab(
|
|
8073
|
+
"set_card_date_attribute",
|
|
8074
|
+
"cardDateAttribute",
|
|
8075
|
+
z.string().min(1).nullable(),
|
|
8076
|
+
(value) => value ? `Affiche ${value} sur les cartes` : "Retire la date des cartes"
|
|
8077
|
+
);
|
|
8078
|
+
var LIST_VIEW_OPERATIONS = [
|
|
8079
|
+
addListTab,
|
|
8080
|
+
removeListTab,
|
|
8081
|
+
updateListTab,
|
|
8082
|
+
reorderListTabs,
|
|
8083
|
+
setColumns,
|
|
8084
|
+
setColumnSizing,
|
|
8085
|
+
setLayout,
|
|
8086
|
+
setGroupBy,
|
|
8087
|
+
setFilters,
|
|
8088
|
+
setSorts,
|
|
8089
|
+
setCreateMode,
|
|
8090
|
+
setReadOnly,
|
|
8091
|
+
setCardUserAttribute,
|
|
8092
|
+
setCardDateAttribute
|
|
8093
|
+
];
|
|
8094
|
+
function requireObject(state, objectId) {
|
|
8095
|
+
if (!state.objects.some((o) => o.id === objectId)) {
|
|
8096
|
+
throw new ValidationError(`Object "${objectId}" is not in the draftable state`, []);
|
|
8097
|
+
}
|
|
8098
|
+
}
|
|
8099
|
+
var objectOperationBase = { ...operationBase, objectId: z.string().min(1) };
|
|
8100
|
+
var addObjectSchema = z.object({
|
|
8101
|
+
...objectOperationBase,
|
|
8102
|
+
type: z.literal("add_object"),
|
|
8103
|
+
name: z.string().min(1),
|
|
8104
|
+
label: z.string().min(1),
|
|
8105
|
+
icon: z.string().min(1).optional()
|
|
8106
|
+
});
|
|
8107
|
+
var addObject = defineOperation({
|
|
8108
|
+
type: "add_object",
|
|
8109
|
+
schema: addObjectSchema,
|
|
8110
|
+
apply: (state, op) => {
|
|
8111
|
+
if (state.objects.some((o) => o.name === op.name)) {
|
|
8112
|
+
throw new ValidationError(`Object "${op.name}" already exists`, []);
|
|
8113
|
+
}
|
|
8114
|
+
if (state.objects.some((o) => o.id === op.objectId)) {
|
|
8115
|
+
throw new ValidationError(`Object id "${op.objectId}" is already taken`, []);
|
|
8116
|
+
}
|
|
8117
|
+
const created = {
|
|
8118
|
+
id: op.objectId,
|
|
8119
|
+
name: op.name,
|
|
8120
|
+
label: op.label,
|
|
8121
|
+
...op.icon === void 0 ? {} : { icon: op.icon }
|
|
8122
|
+
};
|
|
8123
|
+
return { ...state, objects: [...state.objects, created] };
|
|
8124
|
+
},
|
|
8125
|
+
// The caller generates objectId, so a draft object is addressable by route
|
|
8126
|
+
// before it exists — that is what lets the app navigate to it live.
|
|
8127
|
+
focus: (op) => ({ objectId: op.objectId }),
|
|
8128
|
+
describe: (op) => `Cr\xE9e l'objet \xAB ${op.label} \xBB`
|
|
8129
|
+
});
|
|
8130
|
+
var updateObjectSchema = z.object({
|
|
8131
|
+
...objectOperationBase,
|
|
8132
|
+
type: z.literal("update_object"),
|
|
8133
|
+
changes: z.object({ label: z.string().min(1).optional(), icon: z.string().min(1).optional() }).refine((c) => Object.keys(c).length > 0, "update_object needs at least one change")
|
|
8134
|
+
});
|
|
8135
|
+
var updateObject = defineOperation({
|
|
8136
|
+
type: "update_object",
|
|
8137
|
+
schema: updateObjectSchema,
|
|
8138
|
+
apply: (state, op) => {
|
|
8139
|
+
requireObject(state, op.objectId);
|
|
8140
|
+
return {
|
|
8141
|
+
...state,
|
|
8142
|
+
objects: state.objects.map((o) => o.id === op.objectId ? { ...o, ...op.changes } : o)
|
|
8143
|
+
};
|
|
8144
|
+
},
|
|
8145
|
+
focus: (op) => ({ objectId: op.objectId }),
|
|
8146
|
+
describe: (op) => op.changes.label ? `Renomme l'objet en \xAB ${op.changes.label} \xBB` : "Modifie l'objet"
|
|
8147
|
+
});
|
|
8148
|
+
var removeObjectSchema = z.object({ ...objectOperationBase, type: z.literal("remove_object") });
|
|
8149
|
+
var removeObject = defineOperation({
|
|
8150
|
+
type: "remove_object",
|
|
8151
|
+
schema: removeObjectSchema,
|
|
8152
|
+
apply: (state, op) => {
|
|
8153
|
+
requireObject(state, op.objectId);
|
|
8154
|
+
return {
|
|
8155
|
+
...state,
|
|
8156
|
+
objects: state.objects.filter((o) => o.id !== op.objectId),
|
|
8157
|
+
attributes: state.attributes.filter((a) => a.objectId !== op.objectId),
|
|
8158
|
+
sampleRecords: state.sampleRecords.filter((r) => r.objectId !== op.objectId),
|
|
8159
|
+
views: state.views.filter((v) => v.objectId !== op.objectId)
|
|
8160
|
+
};
|
|
8161
|
+
},
|
|
8162
|
+
focus: () => ({}),
|
|
8163
|
+
describe: (op) => `Supprime l'objet ${op.objectId}`
|
|
8164
|
+
});
|
|
8165
|
+
var addAttributeSchema = z.object({
|
|
8166
|
+
...objectOperationBase,
|
|
8167
|
+
type: z.literal("add_attribute"),
|
|
8168
|
+
attributeId: z.string().min(1),
|
|
8169
|
+
name: z.string().min(1),
|
|
8170
|
+
label: z.string().min(1),
|
|
8171
|
+
attributeType: z.string().min(1)
|
|
8172
|
+
});
|
|
8173
|
+
var addAttribute = defineOperation({
|
|
8174
|
+
type: "add_attribute",
|
|
8175
|
+
schema: addAttributeSchema,
|
|
8176
|
+
apply: (state, op) => {
|
|
8177
|
+
requireObject(state, op.objectId);
|
|
8178
|
+
if (state.attributes.some((a) => a.objectId === op.objectId && a.name === op.name)) {
|
|
8179
|
+
throw new ValidationError(
|
|
8180
|
+
`Attribute "${op.name}" already exists on object "${op.objectId}"`,
|
|
8181
|
+
[]
|
|
8182
|
+
);
|
|
8183
|
+
}
|
|
8184
|
+
return {
|
|
8185
|
+
...state,
|
|
8186
|
+
attributes: [
|
|
8187
|
+
...state.attributes,
|
|
8188
|
+
{
|
|
8189
|
+
id: op.attributeId,
|
|
8190
|
+
objectId: op.objectId,
|
|
8191
|
+
name: op.name,
|
|
8192
|
+
label: op.label,
|
|
8193
|
+
attributeType: op.attributeType
|
|
8194
|
+
}
|
|
8195
|
+
]
|
|
8196
|
+
};
|
|
8197
|
+
},
|
|
8198
|
+
focus: (op) => ({ objectId: op.objectId }),
|
|
8199
|
+
describe: (op) => `Ajoute l'attribut \xAB ${op.label} \xBB`
|
|
8200
|
+
});
|
|
8201
|
+
var updateAttributeSchema = z.object({
|
|
8202
|
+
...operationBase,
|
|
8203
|
+
type: z.literal("update_attribute"),
|
|
8204
|
+
attributeId: z.string().min(1),
|
|
8205
|
+
changes: z.object({ label: z.string().min(1).optional() }).refine((c) => Object.keys(c).length > 0, "update_attribute needs at least one change")
|
|
8206
|
+
});
|
|
8207
|
+
var updateAttribute = defineOperation({
|
|
8208
|
+
type: "update_attribute",
|
|
8209
|
+
schema: updateAttributeSchema,
|
|
8210
|
+
apply: (state, op) => {
|
|
8211
|
+
if (!state.attributes.some((a) => a.id === op.attributeId)) {
|
|
8212
|
+
throw new ValidationError(`Attribute "${op.attributeId}" is not in the draftable state`, []);
|
|
8213
|
+
}
|
|
8214
|
+
return {
|
|
8215
|
+
...state,
|
|
8216
|
+
attributes: state.attributes.map(
|
|
8217
|
+
(a) => a.id === op.attributeId ? { ...a, ...op.changes } : a
|
|
8218
|
+
)
|
|
8219
|
+
};
|
|
8220
|
+
},
|
|
8221
|
+
focus: () => ({}),
|
|
8222
|
+
describe: (op) => op.changes.label ? `Renomme l'attribut en \xAB ${op.changes.label} \xBB` : "Modifie l'attribut"
|
|
8223
|
+
});
|
|
8224
|
+
var removeAttributeSchema = z.object({
|
|
8225
|
+
...operationBase,
|
|
8226
|
+
type: z.literal("remove_attribute"),
|
|
8227
|
+
attributeId: z.string().min(1)
|
|
8228
|
+
});
|
|
8229
|
+
var removeAttribute = defineOperation({
|
|
8230
|
+
type: "remove_attribute",
|
|
8231
|
+
schema: removeAttributeSchema,
|
|
8232
|
+
apply: (state, op) => {
|
|
8233
|
+
if (!state.attributes.some((a) => a.id === op.attributeId)) {
|
|
8234
|
+
throw new ValidationError(`Attribute "${op.attributeId}" is not in the draftable state`, []);
|
|
8235
|
+
}
|
|
8236
|
+
return { ...state, attributes: state.attributes.filter((a) => a.id !== op.attributeId) };
|
|
8237
|
+
},
|
|
8238
|
+
focus: () => ({}),
|
|
8239
|
+
describe: (op) => `Supprime l'attribut ${op.attributeId}`
|
|
8240
|
+
});
|
|
8241
|
+
var addSampleRecordSchema = z.object({
|
|
8242
|
+
...objectOperationBase,
|
|
8243
|
+
type: z.literal("add_sample_record"),
|
|
8244
|
+
recordId: z.string().min(1),
|
|
8245
|
+
values: z.record(z.string(), z.unknown())
|
|
8246
|
+
});
|
|
8247
|
+
var addSampleRecord = defineOperation({
|
|
8248
|
+
type: "add_sample_record",
|
|
8249
|
+
schema: addSampleRecordSchema,
|
|
8250
|
+
apply: (state, op) => {
|
|
8251
|
+
requireObject(state, op.objectId);
|
|
8252
|
+
if (state.sampleRecords.some((r) => r.id === op.recordId)) {
|
|
8253
|
+
throw new ValidationError(`Sample record "${op.recordId}" already exists`, []);
|
|
8254
|
+
}
|
|
8255
|
+
return {
|
|
8256
|
+
...state,
|
|
8257
|
+
sampleRecords: [
|
|
8258
|
+
...state.sampleRecords,
|
|
8259
|
+
{ id: op.recordId, objectId: op.objectId, values: op.values }
|
|
8260
|
+
]
|
|
8261
|
+
};
|
|
8262
|
+
},
|
|
8263
|
+
// A sample is a draft record, not a render-time fiction: publishing
|
|
8264
|
+
// materialises it, discarding the draft discards it.
|
|
8265
|
+
focus: (op) => ({ objectId: op.objectId, recordId: op.recordId }),
|
|
8266
|
+
describe: () => "Ajoute un exemple"
|
|
8267
|
+
});
|
|
8268
|
+
var removeSampleRecordSchema = z.object({
|
|
8269
|
+
...operationBase,
|
|
8270
|
+
type: z.literal("remove_sample_record"),
|
|
8271
|
+
recordId: z.string().min(1)
|
|
8272
|
+
});
|
|
8273
|
+
var removeSampleRecord = defineOperation({
|
|
8274
|
+
type: "remove_sample_record",
|
|
8275
|
+
schema: removeSampleRecordSchema,
|
|
8276
|
+
apply: (state, op) => {
|
|
8277
|
+
if (!state.sampleRecords.some((r) => r.id === op.recordId)) {
|
|
8278
|
+
throw new ValidationError(`Sample record "${op.recordId}" is not in the draft`, []);
|
|
8279
|
+
}
|
|
8280
|
+
return { ...state, sampleRecords: state.sampleRecords.filter((r) => r.id !== op.recordId) };
|
|
8281
|
+
},
|
|
8282
|
+
focus: () => ({}),
|
|
8283
|
+
describe: () => "Retire un exemple"
|
|
8284
|
+
});
|
|
8285
|
+
var SCHEMA_OPERATIONS = [
|
|
8286
|
+
addObject,
|
|
8287
|
+
updateObject,
|
|
8288
|
+
removeObject,
|
|
8289
|
+
addAttribute,
|
|
8290
|
+
updateAttribute,
|
|
8291
|
+
removeAttribute,
|
|
8292
|
+
addSampleRecord,
|
|
8293
|
+
removeSampleRecord
|
|
8294
|
+
];
|
|
8295
|
+
|
|
8296
|
+
// src/architect/registry.ts
|
|
8297
|
+
function build() {
|
|
8298
|
+
const map = /* @__PURE__ */ new Map();
|
|
8299
|
+
for (const definition of [
|
|
8300
|
+
...SCHEMA_OPERATIONS,
|
|
8301
|
+
...DETAIL_VIEW_OPERATIONS,
|
|
8302
|
+
...LIST_VIEW_OPERATIONS
|
|
8303
|
+
]) {
|
|
8304
|
+
if (map.has(definition.type)) {
|
|
8305
|
+
throw new DuplicateError("architect operation", definition.type);
|
|
8306
|
+
}
|
|
8307
|
+
map.set(definition.type, definition);
|
|
8308
|
+
}
|
|
8309
|
+
return map;
|
|
8310
|
+
}
|
|
8311
|
+
var OPERATION_REGISTRY = build();
|
|
8312
|
+
var ALL_OPERATION_TYPES = [...OPERATION_REGISTRY.keys()];
|
|
8313
|
+
|
|
8314
|
+
// src/architect/apply.ts
|
|
8315
|
+
function defOf(operation) {
|
|
8316
|
+
const definition = OPERATION_REGISTRY.get(operation.type);
|
|
8317
|
+
if (!definition) {
|
|
8318
|
+
throw new ValidationError(
|
|
8319
|
+
`Operation "${operation.id}" has unknown type "${operation.type}"`,
|
|
8320
|
+
[]
|
|
8321
|
+
);
|
|
8322
|
+
}
|
|
8323
|
+
return definition;
|
|
8324
|
+
}
|
|
8325
|
+
function applyOperations(state, operations) {
|
|
8326
|
+
return operations.reduce(
|
|
8327
|
+
(acc, operation) => defOf(operation).apply(acc, operation),
|
|
8328
|
+
state
|
|
8329
|
+
);
|
|
8330
|
+
}
|
|
8331
|
+
function focusOf(operation) {
|
|
8332
|
+
return defOf(operation).focus(operation);
|
|
8333
|
+
}
|
|
8334
|
+
function describeOperations(operations, ctx) {
|
|
8335
|
+
return operations.map((operation) => defOf(operation).describe(operation, ctx));
|
|
8336
|
+
}
|
|
8337
|
+
function parseOperation(candidate) {
|
|
8338
|
+
if (typeof candidate !== "object" || candidate === null || !("type" in candidate)) {
|
|
8339
|
+
throw new ValidationError("An operation must be an object carrying a type", []);
|
|
8340
|
+
}
|
|
8341
|
+
const type = candidate.type;
|
|
8342
|
+
if (typeof type !== "string") {
|
|
8343
|
+
throw new ValidationError("An operation's type must be a string", []);
|
|
8344
|
+
}
|
|
8345
|
+
const definition = OPERATION_REGISTRY.get(type);
|
|
8346
|
+
if (!definition) {
|
|
8347
|
+
throw new ValidationError(`Unknown operation type "${type}"`, []);
|
|
8348
|
+
}
|
|
8349
|
+
const parsed = definition.schema.safeParse(candidate);
|
|
8350
|
+
if (!parsed.success) {
|
|
8351
|
+
throw new ValidationError(
|
|
8352
|
+
`Operation "${type}" is invalid: ${parsed.error.issues.map((i) => `${i.path.join(".")} ${i.message}`).join("; ")}`,
|
|
8353
|
+
[]
|
|
8354
|
+
);
|
|
8355
|
+
}
|
|
8356
|
+
return parsed.data;
|
|
8357
|
+
}
|
|
8358
|
+
|
|
8359
|
+
// src/architect/field-ids.ts
|
|
8360
|
+
function makeFieldId(groupId, seed, collisionIndex) {
|
|
8361
|
+
const base = `fld_${groupId}_${seed}`;
|
|
8362
|
+
return collisionIndex === 0 ? base : `${base}_${collisionIndex}`;
|
|
8363
|
+
}
|
|
8364
|
+
function seedOf(field, index) {
|
|
8365
|
+
if (field.attributeGroup) return field.attributeGroup.id;
|
|
8366
|
+
if (field.attribute) return field.attribute;
|
|
8367
|
+
return `slot${index}`;
|
|
8368
|
+
}
|
|
8369
|
+
function withIds(group2) {
|
|
8370
|
+
const seen = /* @__PURE__ */ new Map();
|
|
8371
|
+
const fields = group2.fields.map((field, index) => {
|
|
8372
|
+
if (field.id) return field;
|
|
8373
|
+
const seed = seedOf(field, index);
|
|
8374
|
+
const collisionIndex = seen.get(seed) ?? 0;
|
|
8375
|
+
seen.set(seed, collisionIndex + 1);
|
|
8376
|
+
return { ...field, id: makeFieldId(group2.id, seed, collisionIndex) };
|
|
8377
|
+
});
|
|
8378
|
+
return { ...group2, fields };
|
|
8379
|
+
}
|
|
8380
|
+
function ensureFieldIds(tabs) {
|
|
8381
|
+
return tabs.map(
|
|
8382
|
+
(tab) => tab.type === "form" ? { ...tab, groups: tab.groups.map(withIds) } : tab
|
|
8383
|
+
);
|
|
8384
|
+
}
|
|
8385
|
+
|
|
8386
|
+
export { AGENT_UI_BATCH_MAX_BYTES, AGENT_UI_BATCH_MAX_ITEMS, ALLOWED_PROPERTY_TYPES, ALL_ACTIONS, ALL_OPERATION_TYPES, ALL_SYSTEM_RESOURCES, AUDIT_ACTIONS, AUDIT_RESOURCE_TYPES, ActivityTabConfig, AgentBuilder, BEHAVIOR_PROPERTIES, BROWSER_PREVIEW_STATUSES, BYTE_UNIT_LABELS, CLAIMABLE_SESSION_STATUSES, COMPUTED_FUNCTIONS, COMPUTED_FUNCTION_METADATA, COMPUTED_FUNCTION_NAMES, CONNECTOR_CALLBACK_PARAM, COUNT_MODES, ComputedFormulaCompileError, CustomTabConfig, DB_COLUMN_FIELDS, DEFAULT_AGENT_EXECUTION_CONFIG, DEFAULT_APPROVAL_POLICY, DEFAULT_LABEL_FALLBACK, DEFAULT_ROLES, DEFAULT_ROLE_DESCRIPTIONS, DEFAULT_ROLE_LABELS, DEFAULT_ROLE_PERMISSIONS, DOCUMENT_SYSTEM_ATTRIBUTES, DRIVE_LIST_VIEW, DRIVE_OBJECT, DRIVE_OBJECT_NAME, DRIVE_VIEW, DetailViewBuilder, DocumentsTabConfig, EMPTY_VALUE_PLACEHOLDER, ESTIMATED_COUNT_CAP, EmailsTabConfig, FORM_FORBIDDEN_ATTRIBUTE_TYPES, FlagRegistry, FlagService, FormBuilder, FormRegistry, FormRowBuilder, FormStepBuilder, GroupBuilder, IDENTITY_PROPERTIES, LIVE_EVENT_TYPES, ListViewBuilder, ListViewTabConfigBuilder, MAX_PRESET_DEPTH, MAX_TODOS, MAX_TODO_DESCRIPTION_CHARS, MAX_TODO_ID_CHARS, MAX_TODO_RESULT_CHARS, MEMORY_LIST_VIEW, MEMORY_OBJECT, MEMORY_VIEW, MeetingsTabConfig, NATIVE_AGENT_UI_PART_IDS_METADATA_KEY, NATIVE_AGENT_UI_PART_IDS_METADATA_SCHEMA_VERSION, NOTIFICATION_INBOX_STATES, NOTIFICATION_KINDS, NOTIFICATION_PRIORITIES, NOTIFICATION_SENSITIVITIES, NOTIFICATION_TYPES_V1, NOTIFICATION_TYPE_AGENT_QUESTION_REQUESTED, NOTIFICATION_TYPE_AGENT_SESSION_COMPLETED, NOTIFICATION_TYPE_AGENT_SESSION_FAILED, NOTIFICATION_TYPE_AGENT_SESSION_TIMEOUT, NOTIFICATION_TYPE_AGENT_SESSION_WAITING_HUMAN, NOTIFICATION_TYPE_AGENT_TASK_ASSIGNED, NOTIFICATION_WORK_STATES, NoopGeocodingAdapter, OPERATION_REGISTRY, OPERATOR_SPECS, ObjectBuilder, PRESENTATION_PROPERTIES, QUALIFIED_SEPARATOR, RECORD_CREATOR_ROOT_ACTOR_METADATA_KEY, RELATION_TARGET_ANY, RichtextTabConfig, SCHEMA_PLAN_LIMITS, SESSION_TERMINAL_STATUSES, SKILL_LIST_VIEW, SKILL_OBJECT, SKILL_VIEW, STANDARD_SCHEMA_VENDOR, SYSTEM_RESOURCES, SYSTEM_RESOURCE_LABELS, TODAY_DEFAULT, TODO_PLAN_STATUSES, TODO_STATUSES, TabBuilder, TableTabConfig, USER_STATUSES, USER_WORK_POSTURES, accessLevelToActions, actionsToAccessLevel, agent, agentDisplayName, applyOperations, applyPipes, applyRelationProps, assertAcyclicComputedDependencies, booleanFlag, buildAgentFallbackTitle, buildPermissionFlags, buildPropertySchema, buildQualifiedAttribute, checkbox, compileComputedFormula, compileRollupAttribute, computeByteMagnitude, conversationDisplayTitle, createFlagRegistry, createFlagService, createStandardSchemaProps, currency, date, dateInTimezone, dateValueStart, defineOperation, deriveInitials, describeOperations, destructiveSchema, detailView, document, ensureFieldIds, evaluateComputedAst, evaluateComputedFormula, evaluateComputedFormulaWithResult, evaluateFilterState, evaluateRecordFilterState, extractAttributeNames, extractValueRefs, flagRegistry, focusOf, form, formRegistry, formatAttributeValue, formatByteSize, formatComputedResult, formatLocationValue, formula, generateDefaultDetailView, generateDefaultListView, getActiveTab, getErrorMessage, getLiveProtocolPayloadChannel, getRecordCreatorPrincipalId, getSlotFieldTargets, getUserDisplayName, group, hasDestructiveEntries, hasOptions, includesAction, inferInverseCardinality, inferRollupReturnType, isAgentUIMessageBatch, isAttributeSortable2 as isAttributeSortable, isBilateralRelation, isCheckboxEquality, isClaimableSessionStatus, isComputedFunctionName, isDateRangeValue, isDefaultRole, isDetailView, isDocumentAttribute, isEmptyObject, isFieldGroup, isFormDefinition, isFormFieldsRow, isFormFreeFieldRef, isFormHeadingRow, isFormSeparatorRow, isFormSlotFieldRef, isFormTextRow, isLabelExpression, isListView, isLiveEventEnvelope, isLiveEventPayload, isLiveEventPayloadForType, isLiveEventType, isNotEmpty, isPlainRecord2 as isPlainRecord, isStandardSchema, isTerminalSessionStatus, isTerminalState, isUniversalRelation, jsonFlag, legacyStatusToSessionState, listView, liveChannelKey, location, makeFieldId, matchesAccepts, multiselect, nativeAgentUIPartIdMetadataKey, normalizeDateValue, number, numberFlag, object, parseCountMode, parseLiveChannelKey, parseNativeAgentUIPartIdsMetadata, parseOperation, parseOptionalCountMode, parseQualifiedAttribute, persistedDefaultViewTargetSchema, persistedSchemaPlanSchema, phone, plannedAttributeSchema, plannedInlineAttributeSchema, plannedObjectSchema, proposedDefaultViewTargetSchema, registry, relation, relationPropertyDefs, renderLabelExpression, resetViewToDefault, resolveAttributeDefaultValue, resolveFieldRequired, resolvePropertyDefinitions, richtext, rollup, rollupToFormulaExpression, schemaPlanSchema, select, sessionStateToLegacyStatus, status, stringFlag, text, toUndefinedIfEmpty, user, validateAttributeName, validateLabelExpression, validateObjectName, validateViewName, viewRegistry, viewStateKey, viewSyncPayload };
|