@stndrds/schema 1.0.0-alpha.351 → 1.0.0-alpha.353

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.
Files changed (89) hide show
  1. package/dist/{all-CxrR3FfQ.d.mts → all-0XBkyLI_.d.mts} +39 -50
  2. package/dist/{all-DgCMEIjc.d.ts → all-PHJaq-9U.d.ts} +39 -50
  3. package/dist/{attributes-BrWmES5w.d.mts → attributes-0MFN3D1T.d.mts} +1 -1
  4. package/dist/{attributes-DF899HOt.d.ts → attributes-D3wn8qoZ.d.ts} +1 -1
  5. package/dist/capabilities.d.mts +5 -13
  6. package/dist/capabilities.d.ts +5 -13
  7. package/dist/capabilities.js +1 -1
  8. package/dist/capabilities.mjs +1 -1
  9. package/dist/{checkbox-Clb_FZ4C.d.mts → checkbox-DO1Komkk.d.mts} +2 -2
  10. package/dist/{checkbox-DdyYfy8E.d.ts → checkbox-DbL9Kc0_.d.ts} +2 -2
  11. package/dist/{config-CiAtjzem.mjs → config-BkMUw1Ho.mjs} +4 -4
  12. package/dist/{config-CYuFravl.js → config-CQj1KDVm.js} +1 -1
  13. package/dist/{date-CXp1zJM4.d.mts → date-BYjdx-FS.d.mts} +2 -2
  14. package/dist/{date-DhwNqFU4.d.ts → date-D1M2lsRo.d.ts} +2 -2
  15. package/dist/{exceptions-DrrzAhuA.d.mts → exceptions-BG2LUDOt.d.mts} +55 -25
  16. package/dist/{exceptions-DrrzAhuA.d.ts → exceptions-BG2LUDOt.d.ts} +55 -25
  17. package/dist/exceptions.d.mts +2 -2
  18. package/dist/exceptions.d.ts +2 -2
  19. package/dist/exceptions.js +1 -1
  20. package/dist/exceptions.mjs +1 -1
  21. package/dist/{index-BOibflWy.d.ts → index-BQ7N0iEr.d.ts} +14 -2
  22. package/dist/{index-Bfvc4AZB.d.mts → index-BRGf8Pj9.d.mts} +14 -2
  23. package/dist/{index-OvRk1isl.d.ts → index-BxM_oMmi.d.ts} +1 -1
  24. package/dist/{index-Lp5dhlhc.d.mts → index-C9eOBRL6.d.mts} +50 -11
  25. package/dist/{index-DggAjGTr.d.mts → index-D9Zkc3Zp.d.mts} +1 -1
  26. package/dist/{index-DCw-X_sc.d.ts → index-DcLDUWZd.d.ts} +50 -11
  27. package/dist/index.d.mts +1248 -1230
  28. package/dist/index.d.ts +1248 -1230
  29. package/dist/index.js +9 -9
  30. package/dist/index.mjs +9 -9
  31. package/dist/{number-CoTBX03I.d.ts → number-B6nCPYSp.d.ts} +2 -2
  32. package/dist/{number-C_ZN3qJO.d.mts → number-Bz2mxDQV.d.mts} +2 -2
  33. package/dist/{object-AqI3n2CP.mjs → object-sbH7KtsH.mjs} +1 -1
  34. package/dist/{object-BEwZx-Fu.js → object-xwmmQZ8z.js} +1 -1
  35. package/dist/{phone-MN6Li5Wx.js → phone-BXTenBvF.js} +1 -1
  36. package/dist/{phone-CsV9QNwF.mjs → phone-CRbCvH20.mjs} +1 -1
  37. package/dist/{text-D_rs4VYZ.d.mts → text-BWe-JTsH.d.mts} +2 -2
  38. package/dist/{text-Z8QjbxUx.d.ts → text-CbUS9lxj.d.ts} +2 -2
  39. package/dist/{utils-Cuz_wSKI.d.ts → utils-ByfbrMxt.d.mts} +3 -3
  40. package/dist/{utils-Cl3b_6d8.d.mts → utils-DiHsvBLK.d.ts} +3 -3
  41. package/dist/utils.d.mts +1 -1
  42. package/dist/utils.d.ts +1 -1
  43. package/dist/validation/all.d.mts +5 -5
  44. package/dist/validation/all.d.ts +5 -5
  45. package/dist/validation/all.js +1 -1
  46. package/dist/validation/all.mjs +1 -1
  47. package/dist/validation/complex/currency.d.mts +2 -2
  48. package/dist/validation/complex/currency.d.ts +2 -2
  49. package/dist/validation/complex/location.d.mts +2 -2
  50. package/dist/validation/complex/location.d.ts +2 -2
  51. package/dist/validation/complex/phone.d.mts +2 -2
  52. package/dist/validation/complex/phone.d.ts +2 -2
  53. package/dist/validation/complex/phone.js +1 -1
  54. package/dist/validation/complex/phone.mjs +1 -1
  55. package/dist/validation/complex/relation.d.mts +2 -2
  56. package/dist/validation/complex/relation.d.ts +2 -2
  57. package/dist/validation/complex/richtext.d.mts +2 -2
  58. package/dist/validation/complex/richtext.d.ts +2 -2
  59. package/dist/validation/complex/select.d.mts +2 -2
  60. package/dist/validation/complex/select.d.ts +2 -2
  61. package/dist/validation/complex/user.d.mts +2 -2
  62. package/dist/validation/complex/user.d.ts +2 -2
  63. package/dist/validation/computed/formula.d.mts +2 -2
  64. package/dist/validation/computed/formula.d.ts +2 -2
  65. package/dist/validation/computed/rollup.d.mts +2 -2
  66. package/dist/validation/computed/rollup.d.ts +2 -2
  67. package/dist/validation/config/index.d.mts +2 -2
  68. package/dist/validation/config/index.d.ts +2 -2
  69. package/dist/validation/config/index.js +1 -1
  70. package/dist/validation/config/index.mjs +1 -1
  71. package/dist/validation/core/index.d.mts +1 -1
  72. package/dist/validation/core/index.d.ts +1 -1
  73. package/dist/validation/object/index.d.mts +1 -1
  74. package/dist/validation/object/index.d.ts +1 -1
  75. package/dist/validation/object/index.js +1 -1
  76. package/dist/validation/object/index.mjs +1 -1
  77. package/dist/validation/primitives/checkbox.d.mts +1 -1
  78. package/dist/validation/primitives/checkbox.d.ts +1 -1
  79. package/dist/validation/primitives/date.d.mts +1 -1
  80. package/dist/validation/primitives/date.d.ts +1 -1
  81. package/dist/validation/primitives/number.d.mts +1 -1
  82. package/dist/validation/primitives/number.d.ts +1 -1
  83. package/dist/validation/primitives/text.d.mts +1 -1
  84. package/dist/validation/primitives/text.d.ts +1 -1
  85. package/dist/view-config.schema-Cn3vLXu0.js +2 -0
  86. package/dist/view-config.schema-CvT5GfbA.mjs +2 -0
  87. package/package.json +2 -2
  88. package/dist/view-config.schema-CCrM5b-O.mjs +0 -2
  89. package/dist/view-config.schema-CgU86fLj.js +0 -2
@@ -1,5 +1,5 @@
1
1
 
2
- import { r as Uuid } from "./utils-Cl3b_6d8.mjs";
2
+ import { r as Uuid } from "./utils-ByfbrMxt.mjs";
3
3
  import { ColorId, CountryIso3, CurrencyCode, IconName } from "@stndrds/constants";
4
4
  //#region src/computed/parser.d.ts
5
5
  type ComputedFormulaAstNode = ComputedFormulaLiteralNode | ComputedFormulaPathNode | ComputedFormulaCallNode | ComputedFormulaBinaryNode;
@@ -1,5 +1,5 @@
1
1
 
2
- import { r as Uuid } from "./utils-Cuz_wSKI.js";
2
+ import { r as Uuid } from "./utils-DiHsvBLK.js";
3
3
  import { ColorId, CountryIso3, CurrencyCode, IconName } from "@stndrds/constants";
4
4
  //#region src/computed/parser.d.ts
5
5
  type ComputedFormulaAstNode = ComputedFormulaLiteralNode | ComputedFormulaPathNode | ComputedFormulaCallNode | ComputedFormulaBinaryNode;
@@ -51,17 +51,14 @@ export declare const sortsSchema: z$1.ZodArray<z$1.ZodObject<{
51
51
  */
52
52
  export type FilterStateInput = z$1.infer<typeof filtersSchema>;
53
53
  export type FilterRuleInput = FilterStateInput["rules"][number];
54
- /** How a capability mutates data, which decides whether a rehearsal captures it. */
54
+ /** How a capability mutates data, which decides its tool risk. */
55
55
  export type CapabilityKind = "read" | "create" | "update" | "delete";
56
56
  /**
57
- * Every capability a Reflex may call, defined once.
57
+ * The single-record capabilities, defined once.
58
58
  *
59
- * Deliberately five entries — the single-record tools whose input the gateway can
60
- * turn into a faithful `RunEffect`. Excluded on purpose: `get_schema`,
61
- * `global_search` and `bulk_search`, which are not scoped to one object and so
62
- * yield no object to grant a permission on; and the `bulk_*` record tools, where
63
- * one call mutates many records and would be recorded as a single effect, making
64
- * an effects report understate what happened.
59
+ * Deliberately five entries: each is scoped to one object, so its kind maps to
60
+ * one permission. `get_schema`, `global_search` and the `bulk_*`
61
+ * record tools are not single-record operations and live elsewhere.
65
62
  *
66
63
  * `description` is NOT here: the tools compute it per call from their config
67
64
  * (`schemaInContext` changes the wording), and `schema-tools-descriptions.test.ts`
@@ -145,9 +142,4 @@ export type RecordCapabilityName = keyof typeof RECORD_CAPABILITIES;
145
142
  * would have filled in anyway.
146
143
  */
147
144
  export type CapabilityInput<N extends RecordCapabilityName> = z$1.input<(typeof RECORD_CAPABILITIES)[N]["input"]>;
148
- /**
149
- * The capability → kind projection, derived rather than restated. The reflexes
150
- * module reads this instead of maintaining its own table (D26/D28).
151
- */
152
- export declare const RECORD_CAPABILITY_KINDS: Readonly<Record<RecordCapabilityName, CapabilityKind>>;
153
145
  //#endregion
@@ -51,17 +51,14 @@ export declare const sortsSchema: z$1.ZodArray<z$1.ZodObject<{
51
51
  */
52
52
  export type FilterStateInput = z$1.infer<typeof filtersSchema>;
53
53
  export type FilterRuleInput = FilterStateInput["rules"][number];
54
- /** How a capability mutates data, which decides whether a rehearsal captures it. */
54
+ /** How a capability mutates data, which decides its tool risk. */
55
55
  export type CapabilityKind = "read" | "create" | "update" | "delete";
56
56
  /**
57
- * Every capability a Reflex may call, defined once.
57
+ * The single-record capabilities, defined once.
58
58
  *
59
- * Deliberately five entries — the single-record tools whose input the gateway can
60
- * turn into a faithful `RunEffect`. Excluded on purpose: `get_schema`,
61
- * `global_search` and `bulk_search`, which are not scoped to one object and so
62
- * yield no object to grant a permission on; and the `bulk_*` record tools, where
63
- * one call mutates many records and would be recorded as a single effect, making
64
- * an effects report understate what happened.
59
+ * Deliberately five entries: each is scoped to one object, so its kind maps to
60
+ * one permission. `get_schema`, `global_search` and the `bulk_*`
61
+ * record tools are not single-record operations and live elsewhere.
65
62
  *
66
63
  * `description` is NOT here: the tools compute it per call from their config
67
64
  * (`schemaInContext` changes the wording), and `schema-tools-descriptions.test.ts`
@@ -145,9 +142,4 @@ export type RecordCapabilityName = keyof typeof RECORD_CAPABILITIES;
145
142
  * would have filled in anyway.
146
143
  */
147
144
  export type CapabilityInput<N extends RecordCapabilityName> = z$1.input<(typeof RECORD_CAPABILITIES)[N]["input"]>;
148
- /**
149
- * The capability → kind projection, derived rather than restated. The reflexes
150
- * module reads this instead of maintaining its own table (D26/D28).
151
- */
152
- export declare const RECORD_CAPABILITY_KINDS: Readonly<Record<RecordCapabilityName, CapabilityKind>>;
153
145
  //#endregion
@@ -1,2 +1,2 @@
1
1
  /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("zod");const t=`Object UUID, kebab-case name (e.g., 'contacts'), or display label (e.g., 'Personne physique'). All three are accepted; UUID is most precise.`,n=`Relevance ranking for a name or a phrase — matches tokens, not values. Exact criteria go in filters with NO query.`,r=` For large text content (> a few KB), write it to a sandbox file first and pass {"$fromSandboxFile": "/workspace/<file>"} as the attribute value — the server substitutes the file content.`,i=e.z.object({combinator:e.z.enum([`and`,`or`]).default(`and`),rules:e.z.array(e.z.object({attribute:e.z.string().describe(`Attribute name on the object being searched`),property:e.z.string().optional().describe(`Optional, and the only way to read one part of a compound value. On a relation / document / user attribute declared with .qualifyWith({...}) it names an EDGE property (not the linked record); on a location attribute it is one of city | postalCode | country, which is how a postal code or a city is filtered exactly. The operator must be valid for that property's type. See <filter_operators>.`),operator:e.z.string().describe(`Filter operator (canonical: is, is_not, contains, not_contains, starts_with, ends_with, less_than, greater_than, less_or_equal, greater_or_equal, is_within, on_day_month, any_of, none_of, is_empty, is_not_empty). Short codes (lt, gt, lte, gte, eq, neq, in) are accepted as input and auto-normalized to the canonical names. The valid set depends on the attribute type (or property type when 'property' is set) — see <filter_operators>.`),value:e.z.unknown().nullable().describe(`Value matching the attribute (or property) type: scalar for is/contains/less_than/etc (checkbox is: true|false); array (string[]) for any_of/none_of; null for is_empty/is_not_empty; { amount, unit, direction } for is_within; { day, month } for on_day_month.`)}))}),a=e.z.array(e.z.object({attribute:e.z.string().describe(`Attribute name`),direction:e.z.enum([`asc`,`desc`])})),o=e.z.object({recordId:e.z.string().describe(`Record UUID`),fields:e.z.array(e.z.string()).optional().describe(`Attribute names to return`)}),s=e.z.object({objectId:e.z.string().describe(t),_displayLabel:e.z.string().optional().describe(`Display label`),query:e.z.string().optional().describe(n),limit:e.z.number().optional().describe(`Max results per call: 1-1000 (default 20). Paginate via offset for more.`),offset:e.z.number().optional().describe(`Skip N records (default 0)`),fields:e.z.array(e.z.string()).optional().describe(`Attribute names to include in values`),filters:i.optional().describe(`Structured filter: { combinator: 'and'|'or', rules: [{attribute, operator, value, property?}] }. Operators are constrained per attribute type — see <filter_operators>. Use 'property' on a rule to filter on a qualified edge property.`),sorts:a.optional().describe(`Sorts: [{ attribute, direction: 'asc'|'desc' }]`)}),c=e.z.object({objectId:e.z.string().describe(t),_displayLabel:e.z.string().optional().describe(`Display label`),data:e.z.record(e.z.string(),e.z.unknown()).describe(`Record data.${r}`)}),l=e.z.object({recordId:e.z.string().describe(`Record UUID`),data:e.z.record(e.z.string(),e.z.unknown()).describe(`Fields to update.${r}`)}),u=e.z.object({recordId:e.z.string().describe(`Record UUID`)}),d={get_record:{name:`get_record`,kind:`read`,input:o},search_records:{name:`search_records`,kind:`read`,input:s},create_record:{name:`create_record`,kind:`create`,input:c},update_record:{name:`update_record`,kind:`update`,input:l},delete_record:{name:`delete_record`,kind:`delete`,input:u}},f=Object.freeze(Object.fromEntries(Object.values(d).map(e=>[e.name,e.kind])));exports.OBJECT_ID_DESCRIPTION=t,exports.QUERY_DESCRIPTION=n,exports.RECORD_CAPABILITIES=d,exports.RECORD_CAPABILITY_KINDS=f,exports.SANDBOX_FILE_DATA_HINT=r,exports.filtersSchema=i,exports.sortsSchema=a;
2
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("zod");const t=`Object UUID, kebab-case name (e.g., 'contacts'), or display label (e.g., 'Personne physique'). All three are accepted; UUID is most precise.`,n=`Relevance ranking for a name or a phrase — matches tokens, not values. Exact criteria go in filters with NO query.`,r=` For large text content (> a few KB), write it to a sandbox file first and pass {"$fromSandboxFile": "/workspace/<file>"} as the attribute value — the server substitutes the file content.`,i=e.z.object({combinator:e.z.enum([`and`,`or`]).default(`and`),rules:e.z.array(e.z.object({attribute:e.z.string().describe(`Attribute name on the object being searched`),property:e.z.string().optional().describe(`Optional, and the only way to read one part of a compound value. On a relation / document / user attribute declared with .qualifyWith({...}) it names an EDGE property (not the linked record); on a location attribute it is one of city | postalCode | country, which is how a postal code or a city is filtered exactly. The operator must be valid for that property's type. See <filter_operators>.`),operator:e.z.string().describe(`Filter operator (canonical: is, is_not, contains, not_contains, starts_with, ends_with, less_than, greater_than, less_or_equal, greater_or_equal, is_within, on_day_month, any_of, none_of, is_empty, is_not_empty). Short codes (lt, gt, lte, gte, eq, neq, in) are accepted as input and auto-normalized to the canonical names. The valid set depends on the attribute type (or property type when 'property' is set) — see <filter_operators>.`),value:e.z.unknown().nullable().describe(`Value matching the attribute (or property) type: scalar for is/contains/less_than/etc (checkbox is: true|false); array (string[]) for any_of/none_of; null for is_empty/is_not_empty; { amount, unit, direction } for is_within; { day, month } for on_day_month.`)}))}),a=e.z.array(e.z.object({attribute:e.z.string().describe(`Attribute name`),direction:e.z.enum([`asc`,`desc`])})),o=e.z.object({recordId:e.z.string().describe(`Record UUID`),fields:e.z.array(e.z.string()).optional().describe(`Attribute names to return`)}),s=e.z.object({objectId:e.z.string().describe(t),_displayLabel:e.z.string().optional().describe(`Display label`),query:e.z.string().optional().describe(n),limit:e.z.number().optional().describe(`Max results per call: 1-1000 (default 20). Paginate via offset for more.`),offset:e.z.number().optional().describe(`Skip N records (default 0)`),fields:e.z.array(e.z.string()).optional().describe(`Attribute names to include in values`),filters:i.optional().describe(`Structured filter: { combinator: 'and'|'or', rules: [{attribute, operator, value, property?}] }. Operators are constrained per attribute type — see <filter_operators>. Use 'property' on a rule to filter on a qualified edge property.`),sorts:a.optional().describe(`Sorts: [{ attribute, direction: 'asc'|'desc' }]`)}),c=e.z.object({objectId:e.z.string().describe(t),_displayLabel:e.z.string().optional().describe(`Display label`),data:e.z.record(e.z.string(),e.z.unknown()).describe(`Record data.${r}`)}),l=e.z.object({recordId:e.z.string().describe(`Record UUID`),data:e.z.record(e.z.string(),e.z.unknown()).describe(`Fields to update.${r}`)}),u=e.z.object({recordId:e.z.string().describe(`Record UUID`)}),d={get_record:{name:`get_record`,kind:`read`,input:o},search_records:{name:`search_records`,kind:`read`,input:s},create_record:{name:`create_record`,kind:`create`,input:c},update_record:{name:`update_record`,kind:`update`,input:l},delete_record:{name:`delete_record`,kind:`delete`,input:u}};exports.OBJECT_ID_DESCRIPTION=t,exports.QUERY_DESCRIPTION=n,exports.RECORD_CAPABILITIES=d,exports.SANDBOX_FILE_DATA_HINT=r,exports.filtersSchema=i,exports.sortsSchema=a;
@@ -1,2 +1,2 @@
1
1
  /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
- import{z as e}from"zod";const t=`Object UUID, kebab-case name (e.g., 'contacts'), or display label (e.g., 'Personne physique'). All three are accepted; UUID is most precise.`,n=`Relevance ranking for a name or a phrase — matches tokens, not values. Exact criteria go in filters with NO query.`,r=` For large text content (> a few KB), write it to a sandbox file first and pass {"$fromSandboxFile": "/workspace/<file>"} as the attribute value — the server substitutes the file content.`,i=e.object({combinator:e.enum([`and`,`or`]).default(`and`),rules:e.array(e.object({attribute:e.string().describe(`Attribute name on the object being searched`),property:e.string().optional().describe(`Optional, and the only way to read one part of a compound value. On a relation / document / user attribute declared with .qualifyWith({...}) it names an EDGE property (not the linked record); on a location attribute it is one of city | postalCode | country, which is how a postal code or a city is filtered exactly. The operator must be valid for that property's type. See <filter_operators>.`),operator:e.string().describe(`Filter operator (canonical: is, is_not, contains, not_contains, starts_with, ends_with, less_than, greater_than, less_or_equal, greater_or_equal, is_within, on_day_month, any_of, none_of, is_empty, is_not_empty). Short codes (lt, gt, lte, gte, eq, neq, in) are accepted as input and auto-normalized to the canonical names. The valid set depends on the attribute type (or property type when 'property' is set) — see <filter_operators>.`),value:e.unknown().nullable().describe(`Value matching the attribute (or property) type: scalar for is/contains/less_than/etc (checkbox is: true|false); array (string[]) for any_of/none_of; null for is_empty/is_not_empty; { amount, unit, direction } for is_within; { day, month } for on_day_month.`)}))}),a=e.array(e.object({attribute:e.string().describe(`Attribute name`),direction:e.enum([`asc`,`desc`])})),o=e.object({recordId:e.string().describe(`Record UUID`),fields:e.array(e.string()).optional().describe(`Attribute names to return`)}),s=e.object({objectId:e.string().describe(t),_displayLabel:e.string().optional().describe(`Display label`),query:e.string().optional().describe(n),limit:e.number().optional().describe(`Max results per call: 1-1000 (default 20). Paginate via offset for more.`),offset:e.number().optional().describe(`Skip N records (default 0)`),fields:e.array(e.string()).optional().describe(`Attribute names to include in values`),filters:i.optional().describe(`Structured filter: { combinator: 'and'|'or', rules: [{attribute, operator, value, property?}] }. Operators are constrained per attribute type — see <filter_operators>. Use 'property' on a rule to filter on a qualified edge property.`),sorts:a.optional().describe(`Sorts: [{ attribute, direction: 'asc'|'desc' }]`)}),c=e.object({objectId:e.string().describe(t),_displayLabel:e.string().optional().describe(`Display label`),data:e.record(e.string(),e.unknown()).describe(`Record data.${r}`)}),l=e.object({recordId:e.string().describe(`Record UUID`),data:e.record(e.string(),e.unknown()).describe(`Fields to update.${r}`)}),u=e.object({recordId:e.string().describe(`Record UUID`)}),d={get_record:{name:`get_record`,kind:`read`,input:o},search_records:{name:`search_records`,kind:`read`,input:s},create_record:{name:`create_record`,kind:`create`,input:c},update_record:{name:`update_record`,kind:`update`,input:l},delete_record:{name:`delete_record`,kind:`delete`,input:u}},f=Object.freeze(Object.fromEntries(Object.values(d).map(e=>[e.name,e.kind])));export{t as OBJECT_ID_DESCRIPTION,n as QUERY_DESCRIPTION,d as RECORD_CAPABILITIES,f as RECORD_CAPABILITY_KINDS,r as SANDBOX_FILE_DATA_HINT,i as filtersSchema,a as sortsSchema};
2
+ import{z as e}from"zod";const t=`Object UUID, kebab-case name (e.g., 'contacts'), or display label (e.g., 'Personne physique'). All three are accepted; UUID is most precise.`,n=`Relevance ranking for a name or a phrase — matches tokens, not values. Exact criteria go in filters with NO query.`,r=` For large text content (> a few KB), write it to a sandbox file first and pass {"$fromSandboxFile": "/workspace/<file>"} as the attribute value — the server substitutes the file content.`,i=e.object({combinator:e.enum([`and`,`or`]).default(`and`),rules:e.array(e.object({attribute:e.string().describe(`Attribute name on the object being searched`),property:e.string().optional().describe(`Optional, and the only way to read one part of a compound value. On a relation / document / user attribute declared with .qualifyWith({...}) it names an EDGE property (not the linked record); on a location attribute it is one of city | postalCode | country, which is how a postal code or a city is filtered exactly. The operator must be valid for that property's type. See <filter_operators>.`),operator:e.string().describe(`Filter operator (canonical: is, is_not, contains, not_contains, starts_with, ends_with, less_than, greater_than, less_or_equal, greater_or_equal, is_within, on_day_month, any_of, none_of, is_empty, is_not_empty). Short codes (lt, gt, lte, gte, eq, neq, in) are accepted as input and auto-normalized to the canonical names. The valid set depends on the attribute type (or property type when 'property' is set) — see <filter_operators>.`),value:e.unknown().nullable().describe(`Value matching the attribute (or property) type: scalar for is/contains/less_than/etc (checkbox is: true|false); array (string[]) for any_of/none_of; null for is_empty/is_not_empty; { amount, unit, direction } for is_within; { day, month } for on_day_month.`)}))}),a=e.array(e.object({attribute:e.string().describe(`Attribute name`),direction:e.enum([`asc`,`desc`])})),o=e.object({recordId:e.string().describe(`Record UUID`),fields:e.array(e.string()).optional().describe(`Attribute names to return`)}),s=e.object({objectId:e.string().describe(t),_displayLabel:e.string().optional().describe(`Display label`),query:e.string().optional().describe(n),limit:e.number().optional().describe(`Max results per call: 1-1000 (default 20). Paginate via offset for more.`),offset:e.number().optional().describe(`Skip N records (default 0)`),fields:e.array(e.string()).optional().describe(`Attribute names to include in values`),filters:i.optional().describe(`Structured filter: { combinator: 'and'|'or', rules: [{attribute, operator, value, property?}] }. Operators are constrained per attribute type — see <filter_operators>. Use 'property' on a rule to filter on a qualified edge property.`),sorts:a.optional().describe(`Sorts: [{ attribute, direction: 'asc'|'desc' }]`)}),c=e.object({objectId:e.string().describe(t),_displayLabel:e.string().optional().describe(`Display label`),data:e.record(e.string(),e.unknown()).describe(`Record data.${r}`)}),l=e.object({recordId:e.string().describe(`Record UUID`),data:e.record(e.string(),e.unknown()).describe(`Fields to update.${r}`)}),u=e.object({recordId:e.string().describe(`Record UUID`)}),d={get_record:{name:`get_record`,kind:`read`,input:o},search_records:{name:`search_records`,kind:`read`,input:s},create_record:{name:`create_record`,kind:`create`,input:c},update_record:{name:`update_record`,kind:`update`,input:l},delete_record:{name:`delete_record`,kind:`delete`,input:u}};export{t as OBJECT_ID_DESCRIPTION,n as QUERY_DESCRIPTION,d as RECORD_CAPABILITIES,r as SANDBOX_FILE_DATA_HINT,i as filtersSchema,a as sortsSchema};
@@ -1,6 +1,6 @@
1
1
 
2
- import { s as CheckboxAttribute } from "./attributes-BrWmES5w.mjs";
3
- import { r as ValidationMessages } from "./index-DggAjGTr.mjs";
2
+ import { s as CheckboxAttribute } from "./attributes-0MFN3D1T.mjs";
3
+ import { r as ValidationMessages } from "./index-D9Zkc3Zp.mjs";
4
4
  import { z as z$1 } from "zod";
5
5
  //#region src/validation/primitives/checkbox.d.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
1
 
2
- import { s as CheckboxAttribute } from "./attributes-DF899HOt.js";
3
- import { r as ValidationMessages } from "./index-OvRk1isl.js";
2
+ import { s as CheckboxAttribute } from "./attributes-D3wn8qoZ.js";
3
+ import { r as ValidationMessages } from "./index-BxM_oMmi.js";
4
4
  import { z as z$1 } from "zod";
5
5
  //#region src/validation/primitives/checkbox.d.ts
6
6
  /**
@@ -1,13 +1,13 @@
1
1
  /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
- import{SchemaError as e,SchemaErrorCode as t,ValidationError as n}from"./exceptions.mjs";import{t as r}from"./empty-BgAwlO54.mjs";import i,{z as a}from"zod";import{COLORS as o,ICONS as s}from"@stndrds/constants";const c=[`skill`,`memory`,`drives`,`artifact`,`meeting`];function isNativeObjectName(e){return c.includes(e)}const l=[`workspace`,`private`],ee=[`all`,...l];function parseResourceVisibility(e){if(typeof e==`string`&&l.includes(e))return e;throw new n(`visibility must be one of: ${l.join(`, `)} (received: ${String(e)})`,[])}const u=[`id`,`createdAt`,`updatedAt`,`createdBy`,`lastUpdatedBy`,`visibility`,`ownedBy`],d=[...u,`objectId`,`label`,`embeddingText`,`values`,`metadata`,`deletedAt`,`deletedBy`,`schemaVersion`,`owned_by`],te=c,f={attributesPerObject:300,tabsPerView:24,groupsPerFormTab:12,fieldsPerGroup:60,fieldsPerFormTab:150,columnsPerTab:50,optionsPerAttribute:200,sidePanelAttributes:100,sidePanelPanes:20,filterRulesPerTab:50,sortsPerTab:20,emailAttributesPerTab:30,objectsPerPlan:20,mutationsPerPlan:500,planBytes:524288,historyDefault:20,historyMax:50,iconQueries:5,iconResults:20,labelLength:128},ne=Object.keys(o),p=new Set(s),m=a.enum(ne).describe(`A color id from the palette`),h=a.string().superRefine((e,t)=>{p.has(e)||t.addIssue({code:`custom`,message:`Invalid icon name`})}).transform(e=>e);function isDateRangeValue(e){return typeof e==`object`&&!!e&&typeof e.start==`string`}function normalizeDateValue(e,t){return r(e)?null:isDateRangeValue(e)?t.endDate?{start:e.start,end:e.end??null}:e.start:typeof e==`string`?t.endDate?{start:e,end:null}:e:null}function dateValueStart(e){return typeof e==`string`&&e!==``?e:isDateRangeValue(e)&&e.start!==``?e.start:null}const re=new Set(s),g=/^[a-zA-Z_][a-zA-Z0-9_]*$/,ie=/^[a-z][a-z0-9-]*$/,_=f.labelLength,v=i.string().min(1,`Object name cannot be empty`).max(63,`Object name is too long (max 63 characters)`).regex(/^[a-z][a-z0-9-]*$/,{message:`Invalid object name format.
2
+ import{SchemaError as e,SchemaErrorCode as t,ValidationError as n}from"./exceptions.mjs";import{t as r}from"./empty-BgAwlO54.mjs";import i,{z as a}from"zod";import{COLORS as o,ICONS as s}from"@stndrds/constants";const c=[`skill`,`memory`,`drives`,`artifact`,`meeting`];function isNativeObjectName(e){return c.includes(e)}const l=[`workspace`,`private`],u=[`all`,...l];function parseResourceVisibility(e){if(typeof e==`string`&&l.includes(e))return e;throw new n(`visibility must be one of: ${l.join(`, `)} (received: ${String(e)})`,[])}const d=[`id`,`createdAt`,`updatedAt`,`createdBy`,`lastUpdatedBy`,`visibility`,`ownedBy`],f=[...d,`objectId`,`label`,`embeddingText`,`values`,`metadata`,`deletedAt`,`deletedBy`,`schemaVersion`,`owned_by`],ee=c,p={attributesPerObject:300,tabsPerView:24,groupsPerFormTab:12,fieldsPerGroup:60,fieldsPerFormTab:150,columnsPerTab:50,optionsPerAttribute:200,sidePanelAttributes:100,sidePanelPanes:20,filterRulesPerTab:50,sortsPerTab:20,emailAttributesPerTab:30,objectsPerPlan:20,mutationsPerPlan:500,planBytes:524288,historyDefault:20,historyMax:50,iconQueries:5,iconResults:20,labelLength:128},te=Object.keys(o),ne=new Set(s),m=a.enum(te).describe(`A color id from the palette`),h=a.string().superRefine((e,t)=>{ne.has(e)||t.addIssue({code:`custom`,message:`Invalid icon name`})}).transform(e=>e);function isDateRangeValue(e){return typeof e==`object`&&!!e&&typeof e.start==`string`}function normalizeDateValue(e,t){return r(e)?null:isDateRangeValue(e)?t.endDate?{start:e.start,end:e.end??null}:e.start:typeof e==`string`?t.endDate?{start:e,end:null}:e:null}function dateValueStart(e){return typeof e==`string`&&e!==``?e:isDateRangeValue(e)&&e.start!==``?e.start:null}const re=new Set(s),g=/^[a-zA-Z_][a-zA-Z0-9_]*$/,ie=/^[a-z][a-z0-9-]*$/,_=p.labelLength,v=i.string().min(1,`Object name cannot be empty`).max(63,`Object name is too long (max 63 characters)`).regex(/^[a-z][a-z0-9-]*$/,{message:`Invalid object name format.
3
3
  Name must be in kebab-case (slug format):
4
4
  ✅ Valid: 'products', 'user-profiles', 'order-items'
5
5
  ❌ Invalid: 'Products', 'userProfiles', 'user_profiles'`});function validateObjectName(n){try{v.parse(n)}catch(n){throw n instanceof i.ZodError?new e(n.issues[0].message,t.INVALID_OBJECT_NAME):n}}function validateViewName(e){if(!e||e.length===0)throw new n(`View name cannot be empty`,[{path:[`name`],message:`View name cannot be empty`}]);if(e.length>63)throw new n(`View name is too long`,[{path:[`name`],message:`View name is too long (max 63 characters)`}]);if(!ie.test(e))throw new n(`Invalid view name format`,[{path:[`name`],message:`View name must be in kebab-case (e.g., 'detail', 'list-view')`}])}function assertUniqueBy(e,t,n){let r=new Set;for(let i of e){let e=t(i);if(r.has(e))throw n(e);r.add(e)}}const y=i.string().min(1,`Attribute name cannot be empty`).max(63,`Attribute name is too long (max 63 characters)`).regex(g,{message:`Invalid attribute name format.
6
6
  Name must be a valid variable identifier:
7
7
  ✅ Valid: 'firstName', 'first_name', 'FirstName', 'FIRST_NAME'
8
- ❌ Invalid: 'first-name', 'first name', '123name', 'first.name'`}).refine(e=>!d.includes(e),{message:`This is a reserved attribute name. Reserved names: ${d.join(`, `)}`});function validateAttributeName(e){if(!e||e.length===0)throw Error(`[AttributeBuilder] Attribute name cannot be empty`);if(e.length>63)throw Error(`[AttributeBuilder] Attribute name is too long (max 63 characters)`);if(!g.test(e))throw Error(`[AttributeBuilder] Invalid attribute name format.
8
+ ❌ Invalid: 'first-name', 'first name', '123name', 'first.name'`}).refine(e=>!f.includes(e),{message:`This is a reserved attribute name. Reserved names: ${f.join(`, `)}`});function validateAttributeName(e){if(!e||e.length===0)throw Error(`[AttributeBuilder] Attribute name cannot be empty`);if(e.length>63)throw Error(`[AttributeBuilder] Attribute name is too long (max 63 characters)`);if(!g.test(e))throw Error(`[AttributeBuilder] Invalid attribute name format.
9
9
  Name must be a valid variable identifier:
10
10
  ✅ Valid: 'firstName', 'first_name', 'FirstName', 'FIRST_NAME'
11
- ❌ Invalid: 'first-name', 'first name', '123name', 'first.name'`);if(d.includes(e))throw Error(`[AttributeBuilder] "${e}" is a reserved name and cannot be used as an attribute name.\nReserved names: ${d.join(`, `)}`)}function validateLabel(e){if(!e||e.length===0)throw Error(`[AttributeBuilder] Attribute label cannot be empty`);if(e.length>_)throw Error(`[AttributeBuilder] Attribute label is too long (max ${_} characters)`)}function validateIconName(e,t){if(!re.has(e))throw Error(`[AttributeBuilder] Invalid icon "${e}" in ${t}.\nIcon must be one of the predefined icons from @stndrds/constants.`)}function validateOptions(e,t){let n=new Set;for(let r of t){if(!r.value?.trim())throw Error(`[AttributeBuilder] Option in "${e}" has an empty or missing value.`);if(!r.label?.trim())throw Error(`[AttributeBuilder] Option "${r.value}" in "${e}" has an empty or missing label.`);if(n.has(r.value))throw Error(`[AttributeBuilder] Duplicate option value "${r.value}" in "${e}".`);n.add(r.value)}for(let n of t){if(n.inverse===void 0)continue;let r=t.find(e=>e.value===n.inverse);if(!r)throw Error(`[AttributeBuilder] Option "${n.value}" in "${e}" has inverse "${n.inverse}" which does not match any option value.`);if(r.inverse!==n.value)throw Error(`[AttributeBuilder] Inverse mismatch in "${e}": "${n.value}" points to "${n.inverse}", but "${n.inverse}" points to "${r.inverse??`(none)`}". Inverse pairs must be symmetric.`)}}const ae=[`if`,`concat`,`sum`,`avg`,`count`,`min`,`max`,`earliest`,`latest`,`unique`,`first`,`percent_empty`,`percent_not_empty`,`count_empty`,`count_not_empty`,`count_unique`],b={if:{name:`if`,returnType:`branch`,minArgs:3,maxArgs:3},concat:{name:`concat`,returnType:{kind:`scalar`,type:`text`},minArgs:1},sum:{name:`sum`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},avg:{name:`avg`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count:{name:`count`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},min:{name:`min`,returnType:`source_item`,minArgs:1,maxArgs:1},max:{name:`max`,returnType:`source_item`,minArgs:1,maxArgs:1},earliest:{name:`earliest`,returnType:{kind:`scalar`,type:`date`},minArgs:1,maxArgs:1},latest:{name:`latest`,returnType:{kind:`scalar`,type:`date`},minArgs:1,maxArgs:1},unique:{name:`unique`,returnType:`argument`,minArgs:1,maxArgs:1},first:{name:`first`,returnType:`source_item`,minArgs:1,maxArgs:1},percent_empty:{name:`percent_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},percent_not_empty:{name:`percent_not_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count_empty:{name:`count_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count_not_empty:{name:`count_not_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count_unique:{name:`count_unique`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1}};function isComputedFunctionName(e){return Object.hasOwn(b,e)}var ComputedFormulaParseError=class extends Error{constructor(e){super(e),this.name=`ComputedFormulaParseError`}};function parseComputedFormula(e){let t=new Parser(tokenize(e)),n=t.parseExpression();return t.expectEnd(),n}function tokenize(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===` `||r===` `||r===`
11
+ ❌ Invalid: 'first-name', 'first name', '123name', 'first.name'`);if(f.includes(e))throw Error(`[AttributeBuilder] "${e}" is a reserved name and cannot be used as an attribute name.\nReserved names: ${f.join(`, `)}`)}function validateLabel(e){if(!e||e.length===0)throw Error(`[AttributeBuilder] Attribute label cannot be empty`);if(e.length>_)throw Error(`[AttributeBuilder] Attribute label is too long (max ${_} characters)`)}function validateIconName(e,t){if(!re.has(e))throw Error(`[AttributeBuilder] Invalid icon "${e}" in ${t}.\nIcon must be one of the predefined icons from @stndrds/constants.`)}function validateOptions(e,t){let n=new Set;for(let r of t){if(!r.value?.trim())throw Error(`[AttributeBuilder] Option in "${e}" has an empty or missing value.`);if(!r.label?.trim())throw Error(`[AttributeBuilder] Option "${r.value}" in "${e}" has an empty or missing label.`);if(n.has(r.value))throw Error(`[AttributeBuilder] Duplicate option value "${r.value}" in "${e}".`);n.add(r.value)}for(let n of t){if(n.inverse===void 0)continue;let r=t.find(e=>e.value===n.inverse);if(!r)throw Error(`[AttributeBuilder] Option "${n.value}" in "${e}" has inverse "${n.inverse}" which does not match any option value.`);if(r.inverse!==n.value)throw Error(`[AttributeBuilder] Inverse mismatch in "${e}": "${n.value}" points to "${n.inverse}", but "${n.inverse}" points to "${r.inverse??`(none)`}". Inverse pairs must be symmetric.`)}}const ae=[`if`,`concat`,`sum`,`avg`,`count`,`min`,`max`,`earliest`,`latest`,`unique`,`first`,`percent_empty`,`percent_not_empty`,`count_empty`,`count_not_empty`,`count_unique`],b={if:{name:`if`,returnType:`branch`,minArgs:3,maxArgs:3},concat:{name:`concat`,returnType:{kind:`scalar`,type:`text`},minArgs:1},sum:{name:`sum`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},avg:{name:`avg`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count:{name:`count`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},min:{name:`min`,returnType:`source_item`,minArgs:1,maxArgs:1},max:{name:`max`,returnType:`source_item`,minArgs:1,maxArgs:1},earliest:{name:`earliest`,returnType:{kind:`scalar`,type:`date`},minArgs:1,maxArgs:1},latest:{name:`latest`,returnType:{kind:`scalar`,type:`date`},minArgs:1,maxArgs:1},unique:{name:`unique`,returnType:`argument`,minArgs:1,maxArgs:1},first:{name:`first`,returnType:`source_item`,minArgs:1,maxArgs:1},percent_empty:{name:`percent_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},percent_not_empty:{name:`percent_not_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count_empty:{name:`count_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count_not_empty:{name:`count_not_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count_unique:{name:`count_unique`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1}};function isComputedFunctionName(e){return Object.hasOwn(b,e)}var ComputedFormulaParseError=class extends Error{constructor(e){super(e),this.name=`ComputedFormulaParseError`}};function parseComputedFormula(e){let t=new Parser(tokenize(e)),n=t.parseExpression();return t.expectEnd(),n}function tokenize(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===` `||r===` `||r===`
12
12
  `||r===`\r`){n+=1;continue}if(r===`"`||r===`'`){let i=scanString(e,n,r);t.push({kind:`string`,value:i.value,position:n}),n=i.nextIndex;continue}if(isDigit(r)){let r=scanNumber(e,n);t.push({kind:`number`,value:r.value,position:n}),n=r.nextIndex;continue}if(isIdentifierStart(r)){let r=scanIdentifier(e,n),i=r.value.toLowerCase();i===`true`?t.push({kind:`boolean`,value:!0,position:n}):i===`false`?t.push({kind:`boolean`,value:!1,position:n}):i===`null`?t.push({kind:`null`,position:n}):t.push({kind:`identifier`,value:r.value,position:n}),n=r.nextIndex;continue}let i=e.slice(n,n+2);if(i===`>=`||i===`<=`||i===`==`||i===`!=`){t.push({kind:`operator`,value:i,position:n}),n+=2;continue}if(r===`>`||r===`<`||r===`+`||r===`-`||r===`*`||r===`/`){t.push({kind:`operator`,value:r,position:n}),n+=1;continue}if(r===`(`||r===`)`||r===`,`||r===`.`){t.push({kind:`punctuation`,value:r,position:n}),n+=1;continue}throw new ComputedFormulaParseError(`Unexpected character "${r}" at position ${n}`)}return t}function scanString(e,t,n=`"`){let r=``,i=t+1;for(;i<e.length;){let t=e[i];if(t===n)return{value:r,nextIndex:i+1};if(t===`\\`){let t=e[i+1];if(t===void 0)throw new ComputedFormulaParseError(`Unterminated string literal at position ${i}`);r+=decodeEscape(t,i),i+=2;continue}r+=t,i+=1}throw new ComputedFormulaParseError(`Unterminated string literal at position ${t}`)}function decodeEscape(e,t){switch(e){case`"`:case`\\`:return e;case`n`:return`
13
- `;case`r`:return`\r`;case`t`:return` `;default:throw new ComputedFormulaParseError(`Unknown escape sequence "\\${e}" at position ${t}`)}}function scanNumber(e,t){let n=t;for(;n<e.length&&isDigit(e[n]);)n+=1;if(e[n]===`.`){let t=n;if(n+=1,!isDigit(e[n]))throw new ComputedFormulaParseError(`Invalid number literal at position ${t}`);for(;n<e.length&&isDigit(e[n]);)n+=1}let r=e.slice(t,n),i=Number(r);if(!Number.isFinite(i))throw new ComputedFormulaParseError(`Invalid number literal "${r}"`);return{value:i,nextIndex:n}}function scanIdentifier(e,t){let n=t+1;for(;n<e.length&&isIdentifierPart(e[n]);)n+=1;return{value:e.slice(t,n),nextIndex:n}}function isDigit(e){return e!==void 0&&e>=`0`&&e<=`9`}function isIdentifierStart(e){return e!==void 0&&/[A-Za-z_]/.test(e)}function isIdentifierPart(e){return e!==void 0&&/[A-Za-z0-9_]/.test(e)}var Parser=class{constructor(e){this.tokens=e,this.position=0}parseExpression(){return this.parseBinaryExpression(0)}expectEnd(){let e=this.peek();if(e!==void 0)throw new ComputedFormulaParseError(`Unexpected token ${describeToken(e)} at position ${e.position}`)}parseBinaryExpression(e){let t=this.parsePrimary();for(;;){let n=this.peek();if(n?.kind!==`operator`)return t;let r=getOperatorPrecedence(n.value);if(r<e)return t;let i=n.value;this.consume();let a=this.parseBinaryExpression(r+1);t={kind:`binary`,operator:i,left:t,right:a}}}parsePrimary(){let e=this.consume();if(e===void 0)throw new ComputedFormulaParseError(`Unexpected end of expression`);switch(e.kind){case`string`:case`number`:case`boolean`:return{kind:`literal`,value:e.value};case`null`:return{kind:`literal`,value:null};case`identifier`:return this.parseIdentifier(e.value);case`punctuation`:if(e.value===`(`){let e=this.parseExpression();return this.expectPunctuation(`)`),e}break;case`operator`:if(e.value===`-`){let e=this.consume();if(e?.kind===`number`)return{kind:`literal`,value:-e.value}}}throw new ComputedFormulaParseError(`Expected literal, path, call, or parenthesized expression at position ${e.position}`)}parseIdentifier(e){if(this.matchPunctuation(`(`)){let t=[];if(!this.matchPunctuation(`)`)){do t.push(this.parseExpression());while(this.matchPunctuation(`,`));this.expectPunctuation(`)`)}return{kind:`call`,functionName:e.toLowerCase(),args:t}}let t=[e];for(;this.matchPunctuation(`.`);){let e=this.consume();if(e?.kind!==`identifier`)throw new ComputedFormulaParseError(`Expected attribute name after path separator at position ${e?.position??this.previousPosition()}`);t.push(e.value)}return{kind:`path`,parts:t}}expectPunctuation(e){if(!this.matchPunctuation(e))throw new ComputedFormulaParseError(`Expected "${e}" at position ${this.peek()?.position??this.previousPosition()}`)}matchPunctuation(e){let t=this.peek();return t?.kind===`punctuation`&&t.value===e&&(this.consume(),!0)}peek(){return this.tokens[this.position]}consume(){let e=this.tokens[this.position];return this.position+=1,e}previousPosition(){return this.tokens[this.position-1]?.position??0}};function describeToken(e){switch(e.kind){case`identifier`:case`number`:case`string`:case`boolean`:case`operator`:case`punctuation`:return`"${String(e.value)}"`;case`null`:return`"null"`;default:return e}}function getOperatorPrecedence(e){switch(e){case`*`:case`/`:return 3;case`+`:case`-`:return 2;case`>`:case`<`:case`>=`:case`<=`:case`==`:case`!=`:return 1;default:return e}}function evaluateAst(e,t){switch(e.kind){case`literal`:return e.value;case`path`:return resolvePath(t,e.parts);case`binary`:return evaluateBinary(e.operator,evaluateAst(e.left,t),evaluateAst(e.right,t));case`call`:return evaluateCallNode(e.functionName,e.args,t);default:return unreachable(e)}}function evaluateCallNode(e,t,n){if(assertComputedFunctionName(e),validateArity(e,t.length),e===`if`){let e=evaluateAst(t[0],n);return e===null?null:evaluateAst(e?t[1]:t[2],n)}return evaluateCall(e,t.map(e=>evaluateAst(e,n)))}function resolvePath(e,t){return t.reduce((e,t)=>resolvePathPart(e,t),e)}function resolvePathPart(e,t){if(Array.isArray(e))return e.map(e=>resolvePathPart(e,t));if(!isPlainRecord(e))return null;if(Object.hasOwn(e,t))return e[t]??null;let n=e.values;return isPlainRecord(n)&&Object.hasOwn(n,t)?n[t]??null:null}function evaluateBinary(e,t,n){switch(e){case`+`:return add(t,n);case`-`:return numericBinary(t,n,(e,t)=>e-t);case`*`:return numericBinary(t,n,(e,t)=>e*t);case`/`:return numericBinary(t,n,(e,t)=>e/t);case`>`:return compareWith(t,n,e=>e>0);case`<`:return compareWith(t,n,e=>e<0);case`>=`:return compareWith(t,n,e=>e>=0);case`<=`:return compareWith(t,n,e=>e<=0);case`==`:return equalScalar(t,n);case`!=`:{let e=equalScalar(t,n);return e===null?null:!e}default:return unreachable(e)}}function add(e,t){return typeof e==`string`||typeof t==`string`?`${e??``}${t??``}`:numericBinary(e,t,(e,t)=>e+t)}function compareWith(e,t,n){let r=compare(e,t);return r===null?null:n(r)}function compare(e,t){if(!areCommensurable([e,t]))return null;let n=toFiniteNumber(e),r=toFiniteNumber(t);if(n!==null&&r!==null)return n-r;let i=toDate(e),a=toDate(t);return i&&a?i.getTime()-a.getTime():null}function equalScalar(e,t){return e===t?!0:e==null||t==null?!1:areCommensurable([e,t])?compare(e,t)===0:null}function assertComputedFunctionName(e){if(!isComputedFunctionName(e))throw Error(`Unknown computed function "${e}"`)}function validateArity(e,t){let{minArgs:n,maxArgs:r}=b[e];if(t>=n&&t<=(r??1/0))return;let i=r===void 0?`at least ${n}`:`between ${n} and ${r}`;throw Error(`Function "${e}" expects ${i} arguments, received ${t}`)}function evaluateCall(e,t){switch(e){case`concat`:return t.filter(e=>e!=null).map(String).join(``);case`sum`:return areCommensurable(t)?numericValues(t).reduce((e,t)=>e+t,0):null;case`avg`:{if(!areCommensurable(t))return null;let e=numericValues(t);return e.length>0?e.reduce((e,t)=>e+t,0)/e.length:null}case`count`:return collectionItems(t[0]).length;case`min`:return minMax(t,`min`);case`max`:return minMax(t,`max`);case`earliest`:return dateMinMax(t,`min`);case`latest`:return dateMinMax(t,`max`);case`unique`:return uniqueNonEmpty(collectionItems(t[0]));case`first`:return collectionItems(t[0]).find(e=>e!=null)??null;case`percent_empty`:return percentByEmptyState(t[0],!0);case`percent_not_empty`:return percentByEmptyState(t[0],!1);case`count_empty`:return collectionItems(t[0]).filter(r).length;case`count_not_empty`:return collectionItems(t[0]).filter(e=>!r(e)).length;case`count_unique`:return uniqueNonEmpty(collectionItems(t[0])).length;default:return unreachable(e)}}function unreachable(e){return e}function numericValues(e){return flatten(e).map(toFiniteNumber).filter(e=>e!==null)}function areCommensurable(e){let t=new Set;for(let n of flatten(e))isCurrencyValue(n)&&t.add(currencyCode(n));return t.size<=1}function currencyCode(e){return e.code.toUpperCase()}function numericBinary(e,t,n){if(!areCommensurable([e,t]))return null;let r=toFiniteNumber(e),i=toFiniteNumber(t);if(r===null||i===null)return null;let a=n(r,i);return Number.isFinite(a)?a:null}function minMax(e,t){if(!areCommensurable(e))return null;let n=numericValues(e);return n.length>0?t===`min`?Math.min(...n):Math.max(...n):dateMinMax(e,t)}function dateMinMax(e,t){let n=flatten(e).map(toDate).filter(e=>e!==null);if(n.length===0)return null;let r=n.map(e=>e.getTime()),i=t===`min`?Math.min(...r):Math.max(...r);return new Date(i).toISOString()}function percentByEmptyState(e,t){let n=collectionItems(e);return n.length===0?0:n.filter(e=>r(e)===t).length/n.length}function uniqueNonEmpty(e){let t=new Set,n=[];for(let i of e){if(r(i))continue;let e=uniqueKey(i);t.has(e)||(t.add(e),n.push(i))}return n}function collectionItems(e){return e==null?[]:Array.isArray(e)?flatten(e):[e]}function flatten(e){return e.flat(1/0)}function toFiniteNumber(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return isCurrencyValue(e)&&Number.isFinite(e.value)?e.value:null}function isCurrencyValue(e){return typeof e==`object`&&!!e&&typeof e.value==`number`&&typeof e.code==`string`}function toDate(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e!=`string`){let t=dateValueStart(e);if(t===null)return null;let n=new Date(t);return Number.isNaN(n.getTime())?null:n}let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function uniqueKey(e){if(isCurrencyValue(e))return`currency:${currencyCode(e)}:${e.value}`;let t=toFiniteNumber(e);return t===null?e instanceof Date?`date:${e.toISOString()}`:`${typeof e}:${JSON.stringify(e)}`:`number:${t}`}function isPlainRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function formatComputedResult(e,t,n){if(e==null)return null;let stringifyScalar=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Date?String(e):null;switch(t){case`number`:{let t=typeof e==`number`?e:Number(e);return Number.isNaN(t)?null:n===void 0?t:Number(t.toFixed(n))}case`boolean`:return!!e;case`date`:return e instanceof Date?e.toISOString():typeof e==`string`?e:null;case`text`:return String(e);case`select`:if(Array.isArray(e)){for(let t of e){if(t==null)continue;let e=stringifyScalar(t);if(e!==null)return e}return null}return stringifyScalar(e);case`multiselect`:return Array.isArray(e)?e.flatMap(e=>{if(e==null)return[];let t=stringifyScalar(e);return t===null?[]:[t]}):stringifyScalar(e)===null?[]:[String(e)];default:throw Error(`Unsupported computed return type: ${t}`)}}function evaluateComputedAst(e,t){return evaluateAst(e,t)}function evaluateComputedFormula(e,t){return evaluateAst(parseComputedFormula(e),t)}function evaluateComputedFormulaWithResult(e,t,n,r){try{let i=evaluateAst(parseComputedFormula(e),t);return{value:n?formatComputedResult(i,n,r):i}}catch(e){return{value:null,error:e instanceof Error?e.message:String(e)}}}const x=a.object({placeholder:a.string().optional(),description:a.string().optional(),defaultValue:a.unknown().optional(),icon:a.string().optional(),order:a.number().int().optional(),hidden:a.boolean().optional(),archived:a.boolean().optional(),deprecated:a.boolean().optional(),metadata:a.record(a.string(),a.unknown()).optional()}),S=[`placeholder`,`description`,`defaultValue`,`icon`,`order`,`hidden`,`archived`,`deprecated`,`metadata`];function refuseForeignKeys(e,t,n=[]){let r=new Set(n);return function refuse(n,i,a,o=[]){let s=e[n];if(s!==void 0&&i!==void 0)for(let e of Object.keys(i))s.has(e)||r.has(e)||a.addIssue({code:`custom`,path:[...o,e],message:`"${e}" is not a ${n} ${t}; keys of ${n}: ${[...s].join(`, `)}`})}}const C=a.object({value:a.string().min(1).describe(`Stored value`),label:a.string().min(1).describe(`Label people see`),description:a.string().describe(`Extra context`).optional(),inverse:a.string().describe(`Paired option's value (symmetric)`).optional(),archived:a.boolean().describe(`Hides without deleting`).optional()}),w=a.enum([`idle`,`in_progress`,`finished`]).describe(`Workflow stage`),T=C.extend({color:m}).strict(),E=T,D=C.extend({color:m,group:w}).strict(),O=C.extend({color:a.string().optional().describe(`A color id`),group:w.optional()}).strict(),k=new Set(O.keyof().options),oe=[`options`,`targetAttributeOptions`];function withoutUnknownOptionKeys(e){let t=e;for(let n of oe){let r=e[n];if(!Array.isArray(r))continue;let i=!1,a=r.map(e=>!isPlainRecord(e)||Object.keys(e).every(e=>k.has(e))?e:(i=!0,Object.fromEntries(Object.entries(e).filter(([e])=>k.has(e)))));i&&(t={...t,[n]:a})}let n=e.properties;if(isPlainRecord(n)&&Array.isArray(n.definitions)){let e=n.definitions,r=e.map(e=>isPlainRecord(e)?withoutUnknownOptionKeys(e):e);r.some((t,n)=>t!==e[n])&&(t={...t,properties:{...n,definitions:r}})}return t}const A=a.array(O).min(1).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`});function writeOptionsArraySchema(e){return a.array(e).min(1).max(f.optionsPerAttribute).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`})}const j=writeOptionsArraySchema(T),M=writeOptionsArraySchema(E),N=writeOptionsArraySchema(D),se=a.object({object:a.string().min(1).describe(`Target object`),displayTemplate:a.string().optional().describe(`Linked record label template`),filter:a.record(a.string(),a.unknown()).optional().describe(`Restricts linkable records`)}),ce=a.object({object:a.string().min(1).describe(`Other side's object`),attribute:a.string().min(1).describe(`Other side's attribute`),cardinality:a.enum([`one`,`many`]).optional().describe(`Other side's cardinality`),label:a.string().min(1).optional().describe(`Other side's label`),storageOwner:a.boolean().optional().describe(`Owns the join storage`)}),P=a.object({objectName:a.string().min(1).describe(`API name of the object whose options are mirrored`),attributeName:a.string().min(1).describe(`API name of the select/status attribute to mirror options from`),attributeId:a.string().optional().describe(`Id of the source attribute, resolved by the server`)}),F=x.extend({multiline:a.boolean().describe(`Renders as a multi-line textarea`).optional(),minLength:a.number().int().min(0).describe(`Minimum character count`).optional(),maxLength:a.number().int().min(1).describe(`Maximum character count`).optional(),pattern:a.string().describe(`Regular expression the value must match`).optional(),format:a.enum([`email`,`url`,`slug`]).describe(`Validates and renders as this format`).optional()}),I=x,L=x.extend({renderAs:a.enum([`number`,`rating`]).describe(`Plain number or a star rating`).optional(),min:a.number().describe(`Minimum allowed value`).optional(),max:a.number().describe(`Maximum allowed value`).optional(),unit:a.enum([`integer`,`decimal`,`percentage`]).describe(`How the value is stored and rendered`).optional(),decimals:a.number().int().min(0).max(10).describe(`Decimal places shown`).optional()}),R=x,z=x.extend({dateFormat:a.enum([`short`,`long`,`full`,`relative`]).describe(`How the date is rendered`).optional(),minDate:a.string().describe(`Earliest allowed date (ISO)`).optional(),maxDate:a.string().describe(`Latest allowed date (ISO)`).optional(),includeTime:a.boolean().describe(`Also captures a time of day`).optional(),endDate:a.boolean().describe(`Paired with another date attribute as a range's end`).optional(),timeFormat:a.enum([`12h`,`24h`]).describe(`Clock format when a time is included`).optional()}),B=x.extend({defaultCountryCode:a.string().length(3).describe(`ISO country code preselected in the dialer`).optional()}),V=x.extend({defaultCurrency:a.string().length(3).describe(`ISO currency code preselected for new values`).optional(),allowedCurrencies:a.array(a.string().length(3)).describe(`ISO currency codes a value may use; any currency when omitted`).optional(),allowNegative:a.boolean().describe(`Whether a negative amount is accepted`).optional()}),H=x.extend({options:A.describe(`The workflow statuses, in order`)}),U=x.extend({granularity:a.enum([`full`,`address`,`city`,`state`,`country`,`coordinates`]).describe(`How precise a location must be captured`).optional(),defaultCountry:a.string().length(3).describe(`ISO country code preselected for new values`).optional(),allowedCountries:a.array(a.string().length(3)).describe(`ISO country codes a value may use; any country when omitted`).optional()}),W=x.extend({options:A.describe(`Options`),renderAs:a.literal(`badges`).optional().describe(`Renders the chosen option as a colored badge`)}),G=x.extend({options:A.describe(`Options`),renderAs:a.literal(`badges`).optional().describe(`Renders the chosen options as colored badges`)}),le=x.extend({types:a.array(a.enum([`user`,`agent`])).min(1).optional().describe(`Which kinds of actor can be picked; both when omitted`),multiple:a.boolean().optional().describe(`Whether more than one actor can be picked`)}),K={name:y.describe(`Property API name`),label:a.string().min(1).describe(`Label people see`),required:a.boolean().describe(`Required on every edge`).optional()},ue={id:a.string().optional(),objectId:a.string().optional(),system:a.boolean().optional(),unique:a.boolean().optional()},de=Object.fromEntries(S.map(e=>[e,!0])),q=[`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`location`],J=[...q,`select`,`multiselect`,`status`],Y={text:F,number:L,checkbox:R,date:z,phone:B,currency:V,location:U,select:W,multiselect:G,status:H},fe={...Y,select:W.extend({options:j.describe(`Options`)}),multiselect:G.extend({options:M.describe(`Options`)}),status:H.extend({options:N.describe(`Statuses`)})},propertyWireConfigShapeFor=e=>fe[e].omit(de).shape,storedPropertyMember=e=>a.object({...K,...ue,type:a.literal(e).describe(`Property type`),...Y[e].shape}).strip(),X=a.discriminatedUnion(`type`,J.map(storedPropertyMember)),Z=a.object({definitions:a.array(X).min(1).max(f.optionsPerAttribute).describe(`Edge properties`)}).strip().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),pe=refuseForeignKeys(Object.fromEntries(J.map(e=>[e,new Set(Object.keys(propertyWireConfigShapeFor(e)))])),`property key`,[...Object.keys(K),`type`]);function refuseForeignPropertyKeys(e,t){pe(e.type,e,t)}const me=q.reduce((e,t)=>(Object.assign(e,propertyWireConfigShapeFor(t)),e),{}),optionPropertyWireMember=e=>a.object({...K,type:e.length===1?a.literal(e[0]).describe(`Property type`):a.enum(e).describe(`Property type`),...propertyWireConfigShapeFor(e[0])}).strict(),Q=a.discriminatedUnion(`type`,[optionPropertyWireMember([`select`,`multiselect`]),optionPropertyWireMember([`status`]),a.object({...K,type:a.enum(q).describe(`Property type`),...me}).strict().superRefine(refuseForeignPropertyKeys)]),he=a.object({definitions:a.array(Q).min(1).max(f.optionsPerAttribute).describe(`Edge properties`)}).strict().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),ge=x.extend({targets:a.array(se).min(1).describe(`Target object(s)`),cardinality:a.enum([`one`,`many`]).describe(`one or many`),maxItems:a.number().int().min(1).optional().describe(`Max linked records`),bilateral:ce.optional().describe(`Syncs the other side's attribute`),properties:Z.optional()}),_e=x.extend({expression:a.string().min(1).superRefine((e,t)=>{try{parseComputedFormula(e)}catch(e){t.addIssue({code:a.ZodIssueCode.custom,message:e instanceof Error?e.message:`Invalid formula expression`})}}).describe(`The formula expression, compiled against this object's attributes`),returnType:a.enum([`text`,`number`,`boolean`,`date`,`select`,`multiselect`]).describe(`The formula's result type`),decimals:a.number().int().min(0).max(10).optional().describe(`Decimal places shown for a number result`),currencyCode:a.string().length(3).optional().describe(`ISO 4217 code a number result renders with; presentation only`),allowRelations:a.boolean().optional().describe(`Whether the expression may read across a relation`),optionsSource:P.optional().describe(`Mirrors an option set`)}),ve=x.extend({relationAttribute:a.string().min(1).optional().describe(`API name of the relation this rollup aggregates through`),relationPath:a.string().optional().describe(`Not supported yet — single-hop only`),targetAttribute:a.string().min(1).optional().describe(`API name of the attribute aggregated on the relation's target object; not read by count`),function:a.enum([`sum`,`avg`,`earliest`,`latest`,`count`,`countValues`,`countUniqueValues`,`countEmpty`,`percentEmpty`,`percentNotEmpty`,`original`]).describe(`The aggregation applied across the linked records`),decimals:a.number().int().min(0).max(10).optional().describe(`Decimal places shown for a numeric result`),targetAttributeType:a.string().optional().describe(`Server-set`),targetAttributeOptions:a.array(O).optional().describe(`Server-set`),targetCurrencyCode:a.string().length(3).optional().describe(`Server-set`),optionsSource:P.optional().describe(`Mirrors an option set`)});function rollupTargetIssue(e,t){if(e===`rollup`&&t.function!==`count`&&t.targetAttribute===void 0)return{path:[`targetAttribute`],message:`targetAttribute is required for a "${String(t.function)}" rollup`}}const $={text:F,richtext:I,number:L,checkbox:R,date:z,phone:B,currency:V,status:H,location:U,select:W,multiselect:G,user:le,relation:ge,formula:_e,rollup:ve,document:x.extend({properties:Z.optional(),accepts:a.array(a.string().min(1)).optional().describe("MIME prefixes or globs a file must match (e.g. `image/*`, `*.pdf`)"),maxFileSize:a.number().int().min(1).optional().describe(`Maximum file size in bytes`)})};function getAttributeConfigSchema(e){let t=$[e];if(!t)throw new n(`Unsupported attribute type: ${e}`,[]);return t}function parseAttributeConfig(e,t){let n=getAttributeConfigSchema(e).strip().parse(t),r=rollupTargetIssue(e,n);if(r)throw validationErrorFromIssues([r]);return n}function getAttributeConfigWriteSchema(e){let t=getAttributeConfigSchema(e).extend({icon:h.optional()});switch(e){case`select`:return t.extend({options:j.describe(`Options`)});case`multiselect`:return t.extend({options:M.describe(`Options`)});case`status`:return t.extend({options:N.describe(`Statuses`)});default:return t}}function validationErrorFromIssues(e){return n.fromZodErrors(e.map(e=>({path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message})))}function parseWriteSchema(e,t){let n=getAttributeConfigWriteSchema(e).strip().safeParse(t);if(!n.success)throw validationErrorFromIssues(n.error.issues);let r=rollupTargetIssue(e,n.data);if(r)throw validationErrorFromIssues([r]);return n.data}function parseAttributeConfigForCreate(e,t){return parseWriteSchema(e,t)}function validatePatchedIcon(e){if(!Object.prototype.hasOwnProperty.call(e,`icon`))return;let t=h.optional().safeParse(e.icon);if(!t.success)throw n.fromZodErrors(t.error.issues.map(e=>({path:[`icon`,...e.path.map(e=>typeof e==`symbol`?String(e):e)],message:e.message})))}function isSelectLike(e){return e===`select`||e===`multiselect`||e===`status`}function parseAttributeConfigForUpdate(e,t){let n=Object.prototype.hasOwnProperty.call(t,`options`),r=Object.prototype.hasOwnProperty.call(t,`icon`),i={...e,...t};if(validatePatchedIcon(t),n){let{icon:t,...n}=i,a=parseWriteSchema(e.type,r?i:n);return!r&&t!==void 0&&(a.icon=t),a}let a=e.options;isSelectLike(e.type)&&(i.options=[{value:`__legacy__`,label:`__legacy__`}]);let o=getAttributeConfigSchema(e.type).strip().safeParse(i);if(!o.success)throw validationErrorFromIssues(o.error.issues);let s=o.data;return isSelectLike(e.type)&&(s.options=a),s}export{v as A,normalizeDateValue as B,isPlainRecord as C,ae as D,b as E,validateObjectName as F,d as G,h as H,validateOptions as I,u as J,te as K,validateViewName as L,validateAttributeName as M,validateIconName as N,isComputedFunctionName as O,validateLabel as P,dateValueStart as R,formatComputedResult as S,parseComputedFormula as T,f as U,m as V,ee as W,c as X,parseResourceVisibility as Y,isNativeObjectName as Z,D as _,getAttributeConfigWriteSchema as a,evaluateComputedFormula as b,parseAttributeConfigForCreate as c,Q as d,Z as f,w as g,T as h,getAttributeConfigSchema as i,assertUniqueBy as j,y as k,parseAttributeConfigForUpdate as l,refuseForeignKeys as m,S as n,E as o,he as p,l as q,$ as r,parseAttributeConfig as s,q as t,X as u,withoutUnknownOptionKeys as v,ComputedFormulaParseError as w,evaluateComputedFormulaWithResult as x,evaluateComputedAst as y,isDateRangeValue as z};
13
+ `;case`r`:return`\r`;case`t`:return` `;default:throw new ComputedFormulaParseError(`Unknown escape sequence "\\${e}" at position ${t}`)}}function scanNumber(e,t){let n=t;for(;n<e.length&&isDigit(e[n]);)n+=1;if(e[n]===`.`){let t=n;if(n+=1,!isDigit(e[n]))throw new ComputedFormulaParseError(`Invalid number literal at position ${t}`);for(;n<e.length&&isDigit(e[n]);)n+=1}let r=e.slice(t,n),i=Number(r);if(!Number.isFinite(i))throw new ComputedFormulaParseError(`Invalid number literal "${r}"`);return{value:i,nextIndex:n}}function scanIdentifier(e,t){let n=t+1;for(;n<e.length&&isIdentifierPart(e[n]);)n+=1;return{value:e.slice(t,n),nextIndex:n}}function isDigit(e){return e!==void 0&&e>=`0`&&e<=`9`}function isIdentifierStart(e){return e!==void 0&&/[A-Za-z_]/.test(e)}function isIdentifierPart(e){return e!==void 0&&/[A-Za-z0-9_]/.test(e)}var Parser=class{constructor(e){this.tokens=e,this.position=0}parseExpression(){return this.parseBinaryExpression(0)}expectEnd(){let e=this.peek();if(e!==void 0)throw new ComputedFormulaParseError(`Unexpected token ${describeToken(e)} at position ${e.position}`)}parseBinaryExpression(e){let t=this.parsePrimary();for(;;){let n=this.peek();if(n?.kind!==`operator`)return t;let r=getOperatorPrecedence(n.value);if(r<e)return t;let i=n.value;this.consume();let a=this.parseBinaryExpression(r+1);t={kind:`binary`,operator:i,left:t,right:a}}}parsePrimary(){let e=this.consume();if(e===void 0)throw new ComputedFormulaParseError(`Unexpected end of expression`);switch(e.kind){case`string`:case`number`:case`boolean`:return{kind:`literal`,value:e.value};case`null`:return{kind:`literal`,value:null};case`identifier`:return this.parseIdentifier(e.value);case`punctuation`:if(e.value===`(`){let e=this.parseExpression();return this.expectPunctuation(`)`),e}break;case`operator`:if(e.value===`-`){let e=this.consume();if(e?.kind===`number`)return{kind:`literal`,value:-e.value}}}throw new ComputedFormulaParseError(`Expected literal, path, call, or parenthesized expression at position ${e.position}`)}parseIdentifier(e){if(this.matchPunctuation(`(`)){let t=[];if(!this.matchPunctuation(`)`)){do t.push(this.parseExpression());while(this.matchPunctuation(`,`));this.expectPunctuation(`)`)}return{kind:`call`,functionName:e.toLowerCase(),args:t}}let t=[e];for(;this.matchPunctuation(`.`);){let e=this.consume();if(e?.kind!==`identifier`)throw new ComputedFormulaParseError(`Expected attribute name after path separator at position ${e?.position??this.previousPosition()}`);t.push(e.value)}return{kind:`path`,parts:t}}expectPunctuation(e){if(!this.matchPunctuation(e))throw new ComputedFormulaParseError(`Expected "${e}" at position ${this.peek()?.position??this.previousPosition()}`)}matchPunctuation(e){let t=this.peek();return t?.kind===`punctuation`&&t.value===e&&(this.consume(),!0)}peek(){return this.tokens[this.position]}consume(){let e=this.tokens[this.position];return this.position+=1,e}previousPosition(){return this.tokens[this.position-1]?.position??0}};function describeToken(e){switch(e.kind){case`identifier`:case`number`:case`string`:case`boolean`:case`operator`:case`punctuation`:return`"${String(e.value)}"`;case`null`:return`"null"`;default:return e}}function getOperatorPrecedence(e){switch(e){case`*`:case`/`:return 3;case`+`:case`-`:return 2;case`>`:case`<`:case`>=`:case`<=`:case`==`:case`!=`:return 1;default:return e}}function evaluateAst(e,t){switch(e.kind){case`literal`:return e.value;case`path`:return resolvePath(t,e.parts);case`binary`:return evaluateBinary(e.operator,evaluateAst(e.left,t),evaluateAst(e.right,t));case`call`:return evaluateCallNode(e.functionName,e.args,t);default:return unreachable(e)}}function evaluateCallNode(e,t,n){if(assertComputedFunctionName(e),validateArity(e,t.length),e===`if`){let e=evaluateAst(t[0],n);return e===null?null:evaluateAst(e?t[1]:t[2],n)}return evaluateCall(e,t.map(e=>evaluateAst(e,n)))}function resolvePath(e,t){return t.reduce((e,t)=>resolvePathPart(e,t),e)}function resolvePathPart(e,t){if(Array.isArray(e))return e.map(e=>resolvePathPart(e,t));if(!isPlainRecord(e))return null;if(Object.hasOwn(e,t))return e[t]??null;let n=e.values;return isPlainRecord(n)&&Object.hasOwn(n,t)?n[t]??null:null}function evaluateBinary(e,t,n){switch(e){case`+`:return add(t,n);case`-`:return numericBinary(t,n,(e,t)=>e-t);case`*`:return numericBinary(t,n,(e,t)=>e*t);case`/`:return numericBinary(t,n,(e,t)=>e/t);case`>`:return compareWith(t,n,e=>e>0);case`<`:return compareWith(t,n,e=>e<0);case`>=`:return compareWith(t,n,e=>e>=0);case`<=`:return compareWith(t,n,e=>e<=0);case`==`:return equalScalar(t,n);case`!=`:{let e=equalScalar(t,n);return e===null?null:!e}default:return unreachable(e)}}function add(e,t){return typeof e==`string`||typeof t==`string`?`${e??``}${t??``}`:numericBinary(e,t,(e,t)=>e+t)}function compareWith(e,t,n){let r=compare(e,t);return r===null?null:n(r)}function compare(e,t){if(!areCommensurable([e,t]))return null;let n=toFiniteNumber(e),r=toFiniteNumber(t);if(n!==null&&r!==null)return n-r;let i=toDate(e),a=toDate(t);return i&&a?i.getTime()-a.getTime():null}function equalScalar(e,t){return e===t?!0:e==null||t==null?!1:areCommensurable([e,t])?compare(e,t)===0:null}function assertComputedFunctionName(e){if(!isComputedFunctionName(e))throw Error(`Unknown computed function "${e}"`)}function validateArity(e,t){let{minArgs:n,maxArgs:r}=b[e];if(t>=n&&t<=(r??1/0))return;let i=r===void 0?`at least ${n}`:`between ${n} and ${r}`;throw Error(`Function "${e}" expects ${i} arguments, received ${t}`)}function evaluateCall(e,t){switch(e){case`concat`:return t.filter(e=>e!=null).map(String).join(``);case`sum`:return areCommensurable(t)?numericValues(t).reduce((e,t)=>e+t,0):null;case`avg`:{if(!areCommensurable(t))return null;let e=numericValues(t);return e.length>0?e.reduce((e,t)=>e+t,0)/e.length:null}case`count`:return collectionItems(t[0]).length;case`min`:return minMax(t,`min`);case`max`:return minMax(t,`max`);case`earliest`:return dateMinMax(t,`min`);case`latest`:return dateMinMax(t,`max`);case`unique`:return uniqueNonEmpty(collectionItems(t[0]));case`first`:return collectionItems(t[0]).find(e=>e!=null)??null;case`percent_empty`:return percentByEmptyState(t[0],!0);case`percent_not_empty`:return percentByEmptyState(t[0],!1);case`count_empty`:return collectionItems(t[0]).filter(r).length;case`count_not_empty`:return collectionItems(t[0]).filter(e=>!r(e)).length;case`count_unique`:return uniqueNonEmpty(collectionItems(t[0])).length;default:return unreachable(e)}}function unreachable(e){return e}function numericValues(e){return flatten(e).map(toFiniteNumber).filter(e=>e!==null)}function areCommensurable(e){let t=new Set;for(let n of flatten(e))isCurrencyValue(n)&&t.add(currencyCode(n));return t.size<=1}function currencyCode(e){return e.code.toUpperCase()}function numericBinary(e,t,n){if(!areCommensurable([e,t]))return null;let r=toFiniteNumber(e),i=toFiniteNumber(t);if(r===null||i===null)return null;let a=n(r,i);return Number.isFinite(a)?a:null}function minMax(e,t){if(!areCommensurable(e))return null;let n=numericValues(e);return n.length>0?t===`min`?Math.min(...n):Math.max(...n):dateMinMax(e,t)}function dateMinMax(e,t){let n=flatten(e).map(toDate).filter(e=>e!==null);if(n.length===0)return null;let r=n.map(e=>e.getTime()),i=t===`min`?Math.min(...r):Math.max(...r);return new Date(i).toISOString()}function percentByEmptyState(e,t){let n=collectionItems(e);return n.length===0?0:n.filter(e=>r(e)===t).length/n.length}function uniqueNonEmpty(e){let t=new Set,n=[];for(let i of e){if(r(i))continue;let e=uniqueKey(i);t.has(e)||(t.add(e),n.push(i))}return n}function collectionItems(e){return e==null?[]:Array.isArray(e)?flatten(e):[e]}function flatten(e){return e.flat(1/0)}function toFiniteNumber(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return isCurrencyValue(e)&&Number.isFinite(e.value)?e.value:null}function isCurrencyValue(e){return typeof e==`object`&&!!e&&typeof e.value==`number`&&typeof e.code==`string`}function toDate(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e!=`string`){let t=dateValueStart(e);if(t===null)return null;let n=new Date(t);return Number.isNaN(n.getTime())?null:n}let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function uniqueKey(e){if(isCurrencyValue(e))return`currency:${currencyCode(e)}:${e.value}`;let t=toFiniteNumber(e);return t===null?e instanceof Date?`date:${e.toISOString()}`:`${typeof e}:${JSON.stringify(e)}`:`number:${t}`}function isPlainRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function formatComputedResult(e,t,n){if(e==null)return null;let stringifyScalar=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Date?String(e):null;switch(t){case`number`:{let t=typeof e==`number`?e:Number(e);return Number.isNaN(t)?null:n===void 0?t:Number(t.toFixed(n))}case`boolean`:return!!e;case`date`:return e instanceof Date?e.toISOString():typeof e==`string`?e:null;case`text`:return String(e);case`select`:if(Array.isArray(e)){for(let t of e){if(t==null)continue;let e=stringifyScalar(t);if(e!==null)return e}return null}return stringifyScalar(e);case`multiselect`:return Array.isArray(e)?e.flatMap(e=>{if(e==null)return[];let t=stringifyScalar(e);return t===null?[]:[t]}):stringifyScalar(e)===null?[]:[String(e)];default:throw Error(`Unsupported computed return type: ${t}`)}}function evaluateComputedAst(e,t){return evaluateAst(e,t)}function evaluateComputedFormula(e,t){return evaluateAst(parseComputedFormula(e),t)}function evaluateComputedFormulaWithResult(e,t,n,r){try{let i=evaluateAst(parseComputedFormula(e),t);return{value:n?formatComputedResult(i,n,r):i}}catch(e){return{value:null,error:e instanceof Error?e.message:String(e)}}}const x=a.object({placeholder:a.string().optional(),description:a.string().optional(),defaultValue:a.unknown().optional(),icon:a.string().optional(),order:a.number().int().optional(),hidden:a.boolean().optional(),archived:a.boolean().optional(),deprecated:a.boolean().optional(),metadata:a.record(a.string(),a.unknown()).optional()}),S=[`placeholder`,`description`,`defaultValue`,`icon`,`order`,`hidden`,`archived`,`deprecated`,`metadata`],C={relation:{icon:h.optional().describe(`Field icon from search_icons`)}};function wireOmittedConfigKeysFor(e){let t=C[e]??{};return S.filter(e=>!(e in t))}function refuseForeignKeys(e,t,n=[]){let r=new Set(n);return function refuse(n,i,a,o=[]){let s=e[n];if(s!==void 0&&i!==void 0)for(let e of Object.keys(i))s.has(e)||r.has(e)||a.addIssue({code:`custom`,path:[...o,e],message:`"${e}" is not a ${n} ${t}; keys of ${n}: ${[...s].join(`, `)}`})}}const w=a.object({value:a.string().min(1).describe(`Stored value`),label:a.string().min(1).describe(`Label people see`),description:a.string().describe(`Extra context`).optional(),inverse:a.string().describe(`Paired option's value (symmetric)`).optional(),archived:a.boolean().describe(`Hides without deleting`).optional()}),T=a.enum([`idle`,`in_progress`,`finished`]).describe(`Workflow stage`),E=w.extend({color:m}).strict(),D=E,O=w.extend({color:m,group:T}).strict(),k=w.extend({color:a.string().optional().describe(`A color id`),group:T.optional()}).strict(),A=new Set(k.keyof().options),oe=[`options`,`targetAttributeOptions`];function withoutUnknownOptionKeys(e){let t=e;for(let n of oe){let r=e[n];if(!Array.isArray(r))continue;let i=!1,a=r.map(e=>!isPlainRecord(e)||Object.keys(e).every(e=>A.has(e))?e:(i=!0,Object.fromEntries(Object.entries(e).filter(([e])=>A.has(e)))));i&&(t={...t,[n]:a})}let n=e.properties;if(isPlainRecord(n)&&Array.isArray(n.definitions)){let e=n.definitions,r=e.map(e=>isPlainRecord(e)?withoutUnknownOptionKeys(e):e);r.some((t,n)=>t!==e[n])&&(t={...t,properties:{...n,definitions:r}})}return t}const j=a.array(k).min(1).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`});function writeOptionsArraySchema(e){return a.array(e).min(1).max(p.optionsPerAttribute).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`})}const M=writeOptionsArraySchema(E),N=writeOptionsArraySchema(D),P=writeOptionsArraySchema(O),se=a.object({object:a.string().min(1).describe(`Target object`),displayTemplate:a.string().optional().describe(`Linked record label template`),filter:a.record(a.string(),a.unknown()).optional().describe(`Restricts linkable records`)}),ce=a.object({object:a.string().min(1).describe(`Other side's object`),attribute:a.string().min(1).describe(`Other side's attribute`),cardinality:a.enum([`one`,`many`]).optional().describe(`Other side's cardinality`),label:a.string().min(1).optional().describe(`Other side's label`),storageOwner:a.boolean().optional().describe(`Owns the join storage`)}),F=a.object({objectName:a.string().min(1).describe(`API name of the object whose options are mirrored`),attributeName:a.string().min(1).describe(`API name of the select/status attribute to mirror options from`),attributeId:a.string().optional().describe(`Id of the source attribute, resolved by the server`)}),I=x.extend({multiline:a.boolean().describe(`Renders as a multi-line textarea`).optional(),minLength:a.number().int().min(0).describe(`Minimum character count`).optional(),maxLength:a.number().int().min(1).describe(`Maximum character count`).optional(),pattern:a.string().describe(`Regular expression the value must match`).optional(),format:a.enum([`email`,`url`,`slug`]).describe(`Validates and renders as this format`).optional()}),le=x,L=x.extend({renderAs:a.enum([`number`,`rating`]).describe(`Plain number or a star rating`).optional(),min:a.number().describe(`Minimum allowed value`).optional(),max:a.number().describe(`Maximum allowed value`).optional(),unit:a.enum([`integer`,`decimal`,`percentage`]).describe(`How the value is stored and rendered`).optional(),decimals:a.number().int().min(0).max(10).describe(`Decimal places shown`).optional()}),R=x,z=x.extend({dateFormat:a.enum([`short`,`long`,`full`,`relative`]).describe(`How the date is rendered`).optional(),minDate:a.string().describe(`Earliest allowed date (ISO)`).optional(),maxDate:a.string().describe(`Latest allowed date (ISO)`).optional(),includeTime:a.boolean().describe(`Also captures a time of day`).optional(),endDate:a.boolean().describe(`Paired with another date attribute as a range's end`).optional(),timeFormat:a.enum([`12h`,`24h`]).describe(`Clock format when a time is included`).optional()}),B=x.extend({defaultCountryCode:a.string().length(3).describe(`ISO country code preselected in the dialer`).optional()}),V=x.extend({defaultCurrency:a.string().length(3).describe(`ISO currency code preselected for new values`).optional(),allowedCurrencies:a.array(a.string().length(3)).describe(`ISO currency codes a value may use; any currency when omitted`).optional(),allowNegative:a.boolean().describe(`Whether a negative amount is accepted`).optional()}),H=x.extend({options:j.describe(`The workflow statuses, in order`)}),U=x.extend({granularity:a.enum([`full`,`address`,`city`,`state`,`country`,`coordinates`]).describe(`How precise a location must be captured`).optional(),defaultCountry:a.string().length(3).describe(`ISO country code preselected for new values`).optional(),allowedCountries:a.array(a.string().length(3)).describe(`ISO country codes a value may use; any country when omitted`).optional()}),W=x.extend({options:j.describe(`Options`),renderAs:a.literal(`badges`).optional().describe(`Renders the chosen option as a colored badge`)}),G=x.extend({options:j.describe(`Options`),renderAs:a.literal(`badges`).optional().describe(`Renders the chosen options as colored badges`)}),ue=x.extend({types:a.array(a.enum([`user`,`agent`])).min(1).optional().describe(`Which kinds of actor can be picked; both when omitted`),multiple:a.boolean().optional().describe(`Whether more than one actor can be picked`)}),K={name:y.describe(`Property API name`),label:a.string().min(1).describe(`Label people see`),required:a.boolean().describe(`Required on every edge`).optional()},de={id:a.string().optional(),objectId:a.string().optional(),system:a.boolean().optional(),unique:a.boolean().optional()},fe=Object.fromEntries(S.map(e=>[e,!0])),q=[`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`location`],J=[...q,`select`,`multiselect`,`status`],Y={text:I,number:L,checkbox:R,date:z,phone:B,currency:V,location:U,select:W,multiselect:G,status:H},pe={...Y,select:W.extend({options:M.describe(`Options`)}),multiselect:G.extend({options:N.describe(`Options`)}),status:H.extend({options:P.describe(`Statuses`)})},propertyWireConfigShapeFor=e=>pe[e].omit(fe).shape,storedPropertyMember=e=>a.object({...K,...de,type:a.literal(e).describe(`Property type`),...Y[e].shape}).strip(),X=a.discriminatedUnion(`type`,J.map(storedPropertyMember)),Z=a.object({definitions:a.array(X).min(1).max(p.optionsPerAttribute).describe(`Edge properties`)}).strip().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),me=refuseForeignKeys(Object.fromEntries(J.map(e=>[e,new Set(Object.keys(propertyWireConfigShapeFor(e)))])),`property key`,[...Object.keys(K),`type`]);function refuseForeignPropertyKeys(e,t){me(e.type,e,t)}const he=q.reduce((e,t)=>(Object.assign(e,propertyWireConfigShapeFor(t)),e),{}),optionPropertyWireMember=e=>a.object({...K,type:e.length===1?a.literal(e[0]).describe(`Property type`):a.enum(e).describe(`Property type`),...propertyWireConfigShapeFor(e[0])}).strict(),Q=a.discriminatedUnion(`type`,[optionPropertyWireMember([`select`,`multiselect`]),optionPropertyWireMember([`status`]),a.object({...K,type:a.enum(q).describe(`Property type`),...he}).strict().superRefine(refuseForeignPropertyKeys)]),ge=a.object({definitions:a.array(Q).min(1).max(p.optionsPerAttribute).describe(`Edge properties`)}).strict().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),_e=x.extend({targets:a.array(se).min(1).describe(`Target object(s)`),cardinality:a.enum([`one`,`many`]).describe(`one or many`),maxItems:a.number().int().min(1).optional().describe(`Max linked records`),bilateral:ce.optional().describe(`Syncs the other side's attribute`),properties:Z.optional()}),ve=x.extend({expression:a.string().min(1).superRefine((e,t)=>{try{parseComputedFormula(e)}catch(e){t.addIssue({code:a.ZodIssueCode.custom,message:e instanceof Error?e.message:`Invalid formula expression`})}}).describe(`The formula expression, compiled against this object's attributes`),returnType:a.enum([`text`,`number`,`boolean`,`date`,`select`,`multiselect`]).describe(`The formula's result type`),decimals:a.number().int().min(0).max(10).optional().describe(`Decimal places shown for a number result`),currencyCode:a.string().length(3).optional().describe(`ISO 4217 code a number result renders with; presentation only`),allowRelations:a.boolean().optional().describe(`Whether the expression may read across a relation`),optionsSource:F.optional().describe(`Mirrors an option set`)}),ye=x.extend({relationAttribute:a.string().min(1).optional().describe(`API name of the relation this rollup aggregates through`),relationPath:a.string().optional().describe(`Not supported yet — single-hop only`),targetAttribute:a.string().min(1).optional().describe(`API name of the attribute aggregated on the relation's target object; not read by count`),function:a.enum([`sum`,`avg`,`earliest`,`latest`,`count`,`countValues`,`countUniqueValues`,`countEmpty`,`percentEmpty`,`percentNotEmpty`,`original`]).describe(`The aggregation applied across the linked records`),decimals:a.number().int().min(0).max(10).optional().describe(`Decimal places shown for a numeric result`),targetAttributeType:a.string().optional().describe(`Server-set`),targetAttributeOptions:a.array(k).optional().describe(`Server-set`),targetCurrencyCode:a.string().length(3).optional().describe(`Server-set`),optionsSource:F.optional().describe(`Mirrors an option set`)});function rollupTargetIssue(e,t){if(e===`rollup`&&t.function!==`count`&&t.targetAttribute===void 0)return{path:[`targetAttribute`],message:`targetAttribute is required for a "${String(t.function)}" rollup`}}const $={text:I,richtext:le,number:L,checkbox:R,date:z,phone:B,currency:V,status:H,location:U,select:W,multiselect:G,user:ue,relation:_e,formula:ve,rollup:ye,document:x.extend({properties:Z.optional(),accepts:a.array(a.string().min(1)).optional().describe("MIME prefixes or globs a file must match (e.g. `image/*`, `*.pdf`)"),maxFileSize:a.number().int().min(1).optional().describe(`Maximum file size in bytes`)})};function getAttributeConfigSchema(e){let t=$[e];if(!t)throw new n(`Unsupported attribute type: ${e}`,[]);return t}function parseAttributeConfig(e,t){let n=getAttributeConfigSchema(e).strip().parse(t),r=rollupTargetIssue(e,n);if(r)throw validationErrorFromIssues([r]);return n}function getAttributeConfigWriteSchema(e){let t=getAttributeConfigSchema(e).extend({icon:h.optional()});switch(e){case`select`:return t.extend({options:M.describe(`Options`)});case`multiselect`:return t.extend({options:N.describe(`Options`)});case`status`:return t.extend({options:P.describe(`Statuses`)});default:return t}}function validationErrorFromIssues(e){return n.fromZodErrors(e.map(e=>({path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message})))}function parseWriteSchema(e,t){let n=getAttributeConfigWriteSchema(e).strip().safeParse(t);if(!n.success)throw validationErrorFromIssues(n.error.issues);let r=rollupTargetIssue(e,n.data);if(r)throw validationErrorFromIssues([r]);return n.data}function parseAttributeConfigForCreate(e,t){return parseWriteSchema(e,t)}function validatePatchedIcon(e){if(!Object.prototype.hasOwnProperty.call(e,`icon`))return;let t=h.optional().safeParse(e.icon);if(!t.success)throw n.fromZodErrors(t.error.issues.map(e=>({path:[`icon`,...e.path.map(e=>typeof e==`symbol`?String(e):e)],message:e.message})))}function isSelectLike(e){return e===`select`||e===`multiselect`||e===`status`}function parseAttributeConfigForUpdate(e,t){let n=Object.prototype.hasOwnProperty.call(t,`options`),r=Object.prototype.hasOwnProperty.call(t,`icon`),i={...e,...t};if(validatePatchedIcon(t),n){let{icon:t,...n}=i,a=parseWriteSchema(e.type,r?i:n);return!r&&t!==void 0&&(a.icon=t),a}let a=e.options;isSelectLike(e.type)&&(i.options=[{value:`__legacy__`,label:`__legacy__`}]);let o=getAttributeConfigSchema(e.type).strip().safeParse(i);if(!o.success)throw validationErrorFromIssues(o.error.issues);let s=o.data;return isSelectLike(e.type)&&(s.options=a),s}export{isNativeObjectName as $,isComputedFunctionName as A,dateValueStart as B,evaluateComputedFormulaWithResult as C,parseComputedFormula as D,ComputedFormulaParseError as E,validateIconName as F,p as G,normalizeDateValue as H,validateLabel as I,ee as J,u as K,validateObjectName as L,v as M,assertUniqueBy as N,b as O,validateAttributeName as P,c as Q,validateOptions as R,evaluateComputedFormula as S,isPlainRecord as T,m as U,isDateRangeValue as V,h as W,d as X,l as Y,parseResourceVisibility as Z,T as _,getAttributeConfigSchema as a,withoutUnknownOptionKeys as b,parseAttributeConfig as c,X as d,Q as f,E as g,refuseForeignKeys as h,$ as i,y as j,ae as k,parseAttributeConfigForCreate as l,ge as m,C as n,getAttributeConfigWriteSchema as o,Z as p,f as q,S as r,D as s,q as t,parseAttributeConfigForUpdate as u,O as v,formatComputedResult as w,evaluateComputedAst as x,wireOmittedConfigKeysFor as y,validateViewName as z};
@@ -10,4 +10,4 @@ Name must be a valid variable identifier:
10
10
  ✅ Valid: 'firstName', 'first_name', 'FirstName', 'FIRST_NAME'
11
11
  ❌ Invalid: 'first-name', 'first name', '123name', 'first.name'`);if(p.includes(e))throw Error(`[AttributeBuilder] "${e}" is a reserved name and cannot be used as an attribute name.\nReserved names: ${p.join(`, `)}`)}function validateLabel(e){if(!e||e.length===0)throw Error(`[AttributeBuilder] Attribute label cannot be empty`);if(e.length>v)throw Error(`[AttributeBuilder] Attribute label is too long (max ${v} characters)`)}function validateIconName(e,t){if(!ie.has(e))throw Error(`[AttributeBuilder] Invalid icon "${e}" in ${t}.\nIcon must be one of the predefined icons from @stndrds/constants.`)}function validateOptions(e,t){let n=new Set;for(let r of t){if(!r.value?.trim())throw Error(`[AttributeBuilder] Option in "${e}" has an empty or missing value.`);if(!r.label?.trim())throw Error(`[AttributeBuilder] Option "${r.value}" in "${e}" has an empty or missing label.`);if(n.has(r.value))throw Error(`[AttributeBuilder] Duplicate option value "${r.value}" in "${e}".`);n.add(r.value)}for(let n of t){if(n.inverse===void 0)continue;let r=t.find(e=>e.value===n.inverse);if(!r)throw Error(`[AttributeBuilder] Option "${n.value}" in "${e}" has inverse "${n.inverse}" which does not match any option value.`);if(r.inverse!==n.value)throw Error(`[AttributeBuilder] Inverse mismatch in "${e}": "${n.value}" points to "${n.inverse}", but "${n.inverse}" points to "${r.inverse??`(none)`}". Inverse pairs must be symmetric.`)}}const oe=[`if`,`concat`,`sum`,`avg`,`count`,`min`,`max`,`earliest`,`latest`,`unique`,`first`,`percent_empty`,`percent_not_empty`,`count_empty`,`count_not_empty`,`count_unique`],x={if:{name:`if`,returnType:`branch`,minArgs:3,maxArgs:3},concat:{name:`concat`,returnType:{kind:`scalar`,type:`text`},minArgs:1},sum:{name:`sum`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},avg:{name:`avg`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count:{name:`count`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},min:{name:`min`,returnType:`source_item`,minArgs:1,maxArgs:1},max:{name:`max`,returnType:`source_item`,minArgs:1,maxArgs:1},earliest:{name:`earliest`,returnType:{kind:`scalar`,type:`date`},minArgs:1,maxArgs:1},latest:{name:`latest`,returnType:{kind:`scalar`,type:`date`},minArgs:1,maxArgs:1},unique:{name:`unique`,returnType:`argument`,minArgs:1,maxArgs:1},first:{name:`first`,returnType:`source_item`,minArgs:1,maxArgs:1},percent_empty:{name:`percent_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},percent_not_empty:{name:`percent_not_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count_empty:{name:`count_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count_not_empty:{name:`count_not_empty`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1},count_unique:{name:`count_unique`,returnType:{kind:`scalar`,type:`number`},minArgs:1,maxArgs:1}};function isComputedFunctionName(e){return Object.hasOwn(x,e)}var ComputedFormulaParseError=class extends Error{constructor(e){super(e),this.name=`ComputedFormulaParseError`}};function parseComputedFormula(e){let t=new Parser(tokenize(e)),n=t.parseExpression();return t.expectEnd(),n}function tokenize(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===` `||r===` `||r===`
12
12
  `||r===`\r`){n+=1;continue}if(r===`"`||r===`'`){let i=scanString(e,n,r);t.push({kind:`string`,value:i.value,position:n}),n=i.nextIndex;continue}if(isDigit(r)){let r=scanNumber(e,n);t.push({kind:`number`,value:r.value,position:n}),n=r.nextIndex;continue}if(isIdentifierStart(r)){let r=scanIdentifier(e,n),i=r.value.toLowerCase();i===`true`?t.push({kind:`boolean`,value:!0,position:n}):i===`false`?t.push({kind:`boolean`,value:!1,position:n}):i===`null`?t.push({kind:`null`,position:n}):t.push({kind:`identifier`,value:r.value,position:n}),n=r.nextIndex;continue}let i=e.slice(n,n+2);if(i===`>=`||i===`<=`||i===`==`||i===`!=`){t.push({kind:`operator`,value:i,position:n}),n+=2;continue}if(r===`>`||r===`<`||r===`+`||r===`-`||r===`*`||r===`/`){t.push({kind:`operator`,value:r,position:n}),n+=1;continue}if(r===`(`||r===`)`||r===`,`||r===`.`){t.push({kind:`punctuation`,value:r,position:n}),n+=1;continue}throw new ComputedFormulaParseError(`Unexpected character "${r}" at position ${n}`)}return t}function scanString(e,t,n=`"`){let r=``,i=t+1;for(;i<e.length;){let t=e[i];if(t===n)return{value:r,nextIndex:i+1};if(t===`\\`){let t=e[i+1];if(t===void 0)throw new ComputedFormulaParseError(`Unterminated string literal at position ${i}`);r+=decodeEscape(t,i),i+=2;continue}r+=t,i+=1}throw new ComputedFormulaParseError(`Unterminated string literal at position ${t}`)}function decodeEscape(e,t){switch(e){case`"`:case`\\`:return e;case`n`:return`
13
- `;case`r`:return`\r`;case`t`:return` `;default:throw new ComputedFormulaParseError(`Unknown escape sequence "\\${e}" at position ${t}`)}}function scanNumber(e,t){let n=t;for(;n<e.length&&isDigit(e[n]);)n+=1;if(e[n]===`.`){let t=n;if(n+=1,!isDigit(e[n]))throw new ComputedFormulaParseError(`Invalid number literal at position ${t}`);for(;n<e.length&&isDigit(e[n]);)n+=1}let r=e.slice(t,n),i=Number(r);if(!Number.isFinite(i))throw new ComputedFormulaParseError(`Invalid number literal "${r}"`);return{value:i,nextIndex:n}}function scanIdentifier(e,t){let n=t+1;for(;n<e.length&&isIdentifierPart(e[n]);)n+=1;return{value:e.slice(t,n),nextIndex:n}}function isDigit(e){return e!==void 0&&e>=`0`&&e<=`9`}function isIdentifierStart(e){return e!==void 0&&/[A-Za-z_]/.test(e)}function isIdentifierPart(e){return e!==void 0&&/[A-Za-z0-9_]/.test(e)}var Parser=class{constructor(e){this.tokens=e,this.position=0}parseExpression(){return this.parseBinaryExpression(0)}expectEnd(){let e=this.peek();if(e!==void 0)throw new ComputedFormulaParseError(`Unexpected token ${describeToken(e)} at position ${e.position}`)}parseBinaryExpression(e){let t=this.parsePrimary();for(;;){let n=this.peek();if(n?.kind!==`operator`)return t;let r=getOperatorPrecedence(n.value);if(r<e)return t;let i=n.value;this.consume();let a=this.parseBinaryExpression(r+1);t={kind:`binary`,operator:i,left:t,right:a}}}parsePrimary(){let e=this.consume();if(e===void 0)throw new ComputedFormulaParseError(`Unexpected end of expression`);switch(e.kind){case`string`:case`number`:case`boolean`:return{kind:`literal`,value:e.value};case`null`:return{kind:`literal`,value:null};case`identifier`:return this.parseIdentifier(e.value);case`punctuation`:if(e.value===`(`){let e=this.parseExpression();return this.expectPunctuation(`)`),e}break;case`operator`:if(e.value===`-`){let e=this.consume();if(e?.kind===`number`)return{kind:`literal`,value:-e.value}}}throw new ComputedFormulaParseError(`Expected literal, path, call, or parenthesized expression at position ${e.position}`)}parseIdentifier(e){if(this.matchPunctuation(`(`)){let t=[];if(!this.matchPunctuation(`)`)){do t.push(this.parseExpression());while(this.matchPunctuation(`,`));this.expectPunctuation(`)`)}return{kind:`call`,functionName:e.toLowerCase(),args:t}}let t=[e];for(;this.matchPunctuation(`.`);){let e=this.consume();if(e?.kind!==`identifier`)throw new ComputedFormulaParseError(`Expected attribute name after path separator at position ${e?.position??this.previousPosition()}`);t.push(e.value)}return{kind:`path`,parts:t}}expectPunctuation(e){if(!this.matchPunctuation(e))throw new ComputedFormulaParseError(`Expected "${e}" at position ${this.peek()?.position??this.previousPosition()}`)}matchPunctuation(e){let t=this.peek();return t?.kind===`punctuation`&&t.value===e&&(this.consume(),!0)}peek(){return this.tokens[this.position]}consume(){let e=this.tokens[this.position];return this.position+=1,e}previousPosition(){return this.tokens[this.position-1]?.position??0}};function describeToken(e){switch(e.kind){case`identifier`:case`number`:case`string`:case`boolean`:case`operator`:case`punctuation`:return`"${String(e.value)}"`;case`null`:return`"null"`;default:return e}}function getOperatorPrecedence(e){switch(e){case`*`:case`/`:return 3;case`+`:case`-`:return 2;case`>`:case`<`:case`>=`:case`<=`:case`==`:case`!=`:return 1;default:return e}}function evaluateAst(e,t){switch(e.kind){case`literal`:return e.value;case`path`:return resolvePath(t,e.parts);case`binary`:return evaluateBinary(e.operator,evaluateAst(e.left,t),evaluateAst(e.right,t));case`call`:return evaluateCallNode(e.functionName,e.args,t);default:return unreachable(e)}}function evaluateCallNode(e,t,n){if(assertComputedFunctionName(e),validateArity(e,t.length),e===`if`){let e=evaluateAst(t[0],n);return e===null?null:evaluateAst(e?t[1]:t[2],n)}return evaluateCall(e,t.map(e=>evaluateAst(e,n)))}function resolvePath(e,t){return t.reduce((e,t)=>resolvePathPart(e,t),e)}function resolvePathPart(e,t){if(Array.isArray(e))return e.map(e=>resolvePathPart(e,t));if(!isPlainRecord(e))return null;if(Object.hasOwn(e,t))return e[t]??null;let n=e.values;return isPlainRecord(n)&&Object.hasOwn(n,t)?n[t]??null:null}function evaluateBinary(e,t,n){switch(e){case`+`:return add(t,n);case`-`:return numericBinary(t,n,(e,t)=>e-t);case`*`:return numericBinary(t,n,(e,t)=>e*t);case`/`:return numericBinary(t,n,(e,t)=>e/t);case`>`:return compareWith(t,n,e=>e>0);case`<`:return compareWith(t,n,e=>e<0);case`>=`:return compareWith(t,n,e=>e>=0);case`<=`:return compareWith(t,n,e=>e<=0);case`==`:return equalScalar(t,n);case`!=`:{let e=equalScalar(t,n);return e===null?null:!e}default:return unreachable(e)}}function add(e,t){return typeof e==`string`||typeof t==`string`?`${e??``}${t??``}`:numericBinary(e,t,(e,t)=>e+t)}function compareWith(e,t,n){let r=compare(e,t);return r===null?null:n(r)}function compare(e,t){if(!areCommensurable([e,t]))return null;let n=toFiniteNumber(e),r=toFiniteNumber(t);if(n!==null&&r!==null)return n-r;let i=toDate(e),a=toDate(t);return i&&a?i.getTime()-a.getTime():null}function equalScalar(e,t){return e===t?!0:e==null||t==null?!1:areCommensurable([e,t])?compare(e,t)===0:null}function assertComputedFunctionName(e){if(!isComputedFunctionName(e))throw Error(`Unknown computed function "${e}"`)}function validateArity(e,t){let{minArgs:n,maxArgs:r}=x[e];if(t>=n&&t<=(r??1/0))return;let i=r===void 0?`at least ${n}`:`between ${n} and ${r}`;throw Error(`Function "${e}" expects ${i} arguments, received ${t}`)}function evaluateCall(e,t){switch(e){case`concat`:return t.filter(e=>e!=null).map(String).join(``);case`sum`:return areCommensurable(t)?numericValues(t).reduce((e,t)=>e+t,0):null;case`avg`:{if(!areCommensurable(t))return null;let e=numericValues(t);return e.length>0?e.reduce((e,t)=>e+t,0)/e.length:null}case`count`:return collectionItems(t[0]).length;case`min`:return minMax(t,`min`);case`max`:return minMax(t,`max`);case`earliest`:return dateMinMax(t,`min`);case`latest`:return dateMinMax(t,`max`);case`unique`:return uniqueNonEmpty(collectionItems(t[0]));case`first`:return collectionItems(t[0]).find(e=>e!=null)??null;case`percent_empty`:return percentByEmptyState(t[0],!0);case`percent_not_empty`:return percentByEmptyState(t[0],!1);case`count_empty`:return collectionItems(t[0]).filter(s.t).length;case`count_not_empty`:return collectionItems(t[0]).filter(e=>!s.t(e)).length;case`count_unique`:return uniqueNonEmpty(collectionItems(t[0])).length;default:return unreachable(e)}}function unreachable(e){return e}function numericValues(e){return flatten(e).map(toFiniteNumber).filter(e=>e!==null)}function areCommensurable(e){let t=new Set;for(let n of flatten(e))isCurrencyValue(n)&&t.add(currencyCode(n));return t.size<=1}function currencyCode(e){return e.code.toUpperCase()}function numericBinary(e,t,n){if(!areCommensurable([e,t]))return null;let r=toFiniteNumber(e),i=toFiniteNumber(t);if(r===null||i===null)return null;let a=n(r,i);return Number.isFinite(a)?a:null}function minMax(e,t){if(!areCommensurable(e))return null;let n=numericValues(e);return n.length>0?t===`min`?Math.min(...n):Math.max(...n):dateMinMax(e,t)}function dateMinMax(e,t){let n=flatten(e).map(toDate).filter(e=>e!==null);if(n.length===0)return null;let r=n.map(e=>e.getTime()),i=t===`min`?Math.min(...r):Math.max(...r);return new Date(i).toISOString()}function percentByEmptyState(e,t){let n=collectionItems(e);return n.length===0?0:n.filter(e=>s.t(e)===t).length/n.length}function uniqueNonEmpty(e){let t=new Set,n=[];for(let r of e){if(s.t(r))continue;let e=uniqueKey(r);t.has(e)||(t.add(e),n.push(r))}return n}function collectionItems(e){return e==null?[]:Array.isArray(e)?flatten(e):[e]}function flatten(e){return e.flat(1/0)}function toFiniteNumber(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return isCurrencyValue(e)&&Number.isFinite(e.value)?e.value:null}function isCurrencyValue(e){return typeof e==`object`&&!!e&&typeof e.value==`number`&&typeof e.code==`string`}function toDate(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e!=`string`){let t=dateValueStart(e);if(t===null)return null;let n=new Date(t);return Number.isNaN(n.getTime())?null:n}let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function uniqueKey(e){if(isCurrencyValue(e))return`currency:${currencyCode(e)}:${e.value}`;let t=toFiniteNumber(e);return t===null?e instanceof Date?`date:${e.toISOString()}`:`${typeof e}:${JSON.stringify(e)}`:`number:${t}`}function isPlainRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function formatComputedResult(e,t,n){if(e==null)return null;let stringifyScalar=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Date?String(e):null;switch(t){case`number`:{let t=typeof e==`number`?e:Number(e);return Number.isNaN(t)?null:n===void 0?t:Number(t.toFixed(n))}case`boolean`:return!!e;case`date`:return e instanceof Date?e.toISOString():typeof e==`string`?e:null;case`text`:return String(e);case`select`:if(Array.isArray(e)){for(let t of e){if(t==null)continue;let e=stringifyScalar(t);if(e!==null)return e}return null}return stringifyScalar(e);case`multiselect`:return Array.isArray(e)?e.flatMap(e=>{if(e==null)return[];let t=stringifyScalar(e);return t===null?[]:[t]}):stringifyScalar(e)===null?[]:[String(e)];default:throw Error(`Unsupported computed return type: ${t}`)}}function evaluateComputedAst(e,t){return evaluateAst(e,t)}function evaluateComputedFormula(e,t){return evaluateAst(parseComputedFormula(e),t)}function evaluateComputedFormulaWithResult(e,t,n,r){try{let i=evaluateAst(parseComputedFormula(e),t);return{value:n?formatComputedResult(i,n,r):i}}catch(e){return{value:null,error:e instanceof Error?e.message:String(e)}}}const S=c.z.object({placeholder:c.z.string().optional(),description:c.z.string().optional(),defaultValue:c.z.unknown().optional(),icon:c.z.string().optional(),order:c.z.number().int().optional(),hidden:c.z.boolean().optional(),archived:c.z.boolean().optional(),deprecated:c.z.boolean().optional(),metadata:c.z.record(c.z.string(),c.z.unknown()).optional()}),C=[`placeholder`,`description`,`defaultValue`,`icon`,`order`,`hidden`,`archived`,`deprecated`,`metadata`];function refuseForeignKeys(e,t,n=[]){let r=new Set(n);return function refuse(n,i,a,o=[]){let s=e[n];if(s!==void 0&&i!==void 0)for(let e of Object.keys(i))s.has(e)||r.has(e)||a.addIssue({code:`custom`,path:[...o,e],message:`"${e}" is not a ${n} ${t}; keys of ${n}: ${[...s].join(`, `)}`})}}const w=c.z.object({value:c.z.string().min(1).describe(`Stored value`),label:c.z.string().min(1).describe(`Label people see`),description:c.z.string().describe(`Extra context`).optional(),inverse:c.z.string().describe(`Paired option's value (symmetric)`).optional(),archived:c.z.boolean().describe(`Hides without deleting`).optional()}),T=c.z.enum([`idle`,`in_progress`,`finished`]).describe(`Workflow stage`),E=w.extend({color:h}).strict(),D=E,O=w.extend({color:h,group:T}).strict(),k=w.extend({color:c.z.string().optional().describe(`A color id`),group:T.optional()}).strict(),A=new Set(k.keyof().options),se=[`options`,`targetAttributeOptions`];function withoutUnknownOptionKeys(e){let t=e;for(let n of se){let r=e[n];if(!Array.isArray(r))continue;let i=!1,a=r.map(e=>!isPlainRecord(e)||Object.keys(e).every(e=>A.has(e))?e:(i=!0,Object.fromEntries(Object.entries(e).filter(([e])=>A.has(e)))));i&&(t={...t,[n]:a})}let n=e.properties;if(isPlainRecord(n)&&Array.isArray(n.definitions)){let e=n.definitions,r=e.map(e=>isPlainRecord(e)?withoutUnknownOptionKeys(e):e);r.some((t,n)=>t!==e[n])&&(t={...t,properties:{...n,definitions:r}})}return t}const j=c.z.array(k).min(1).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`});function writeOptionsArraySchema(e){return c.z.array(e).min(1).max(m.optionsPerAttribute).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`})}const M=writeOptionsArraySchema(E),N=writeOptionsArraySchema(D),P=writeOptionsArraySchema(O),ce=c.z.object({object:c.z.string().min(1).describe(`Target object`),displayTemplate:c.z.string().optional().describe(`Linked record label template`),filter:c.z.record(c.z.string(),c.z.unknown()).optional().describe(`Restricts linkable records`)}),le=c.z.object({object:c.z.string().min(1).describe(`Other side's object`),attribute:c.z.string().min(1).describe(`Other side's attribute`),cardinality:c.z.enum([`one`,`many`]).optional().describe(`Other side's cardinality`),label:c.z.string().min(1).optional().describe(`Other side's label`),storageOwner:c.z.boolean().optional().describe(`Owns the join storage`)}),F=c.z.object({objectName:c.z.string().min(1).describe(`API name of the object whose options are mirrored`),attributeName:c.z.string().min(1).describe(`API name of the select/status attribute to mirror options from`),attributeId:c.z.string().optional().describe(`Id of the source attribute, resolved by the server`)}),I=S.extend({multiline:c.z.boolean().describe(`Renders as a multi-line textarea`).optional(),minLength:c.z.number().int().min(0).describe(`Minimum character count`).optional(),maxLength:c.z.number().int().min(1).describe(`Maximum character count`).optional(),pattern:c.z.string().describe(`Regular expression the value must match`).optional(),format:c.z.enum([`email`,`url`,`slug`]).describe(`Validates and renders as this format`).optional()}),ue=S,L=S.extend({renderAs:c.z.enum([`number`,`rating`]).describe(`Plain number or a star rating`).optional(),min:c.z.number().describe(`Minimum allowed value`).optional(),max:c.z.number().describe(`Maximum allowed value`).optional(),unit:c.z.enum([`integer`,`decimal`,`percentage`]).describe(`How the value is stored and rendered`).optional(),decimals:c.z.number().int().min(0).max(10).describe(`Decimal places shown`).optional()}),R=S,z=S.extend({dateFormat:c.z.enum([`short`,`long`,`full`,`relative`]).describe(`How the date is rendered`).optional(),minDate:c.z.string().describe(`Earliest allowed date (ISO)`).optional(),maxDate:c.z.string().describe(`Latest allowed date (ISO)`).optional(),includeTime:c.z.boolean().describe(`Also captures a time of day`).optional(),endDate:c.z.boolean().describe(`Paired with another date attribute as a range's end`).optional(),timeFormat:c.z.enum([`12h`,`24h`]).describe(`Clock format when a time is included`).optional()}),B=S.extend({defaultCountryCode:c.z.string().length(3).describe(`ISO country code preselected in the dialer`).optional()}),V=S.extend({defaultCurrency:c.z.string().length(3).describe(`ISO currency code preselected for new values`).optional(),allowedCurrencies:c.z.array(c.z.string().length(3)).describe(`ISO currency codes a value may use; any currency when omitted`).optional(),allowNegative:c.z.boolean().describe(`Whether a negative amount is accepted`).optional()}),H=S.extend({options:j.describe(`The workflow statuses, in order`)}),U=S.extend({granularity:c.z.enum([`full`,`address`,`city`,`state`,`country`,`coordinates`]).describe(`How precise a location must be captured`).optional(),defaultCountry:c.z.string().length(3).describe(`ISO country code preselected for new values`).optional(),allowedCountries:c.z.array(c.z.string().length(3)).describe(`ISO country codes a value may use; any country when omitted`).optional()}),W=S.extend({options:j.describe(`Options`),renderAs:c.z.literal(`badges`).optional().describe(`Renders the chosen option as a colored badge`)}),G=S.extend({options:j.describe(`Options`),renderAs:c.z.literal(`badges`).optional().describe(`Renders the chosen options as colored badges`)}),de=S.extend({types:c.z.array(c.z.enum([`user`,`agent`])).min(1).optional().describe(`Which kinds of actor can be picked; both when omitted`),multiple:c.z.boolean().optional().describe(`Whether more than one actor can be picked`)}),K={name:b.describe(`Property API name`),label:c.z.string().min(1).describe(`Label people see`),required:c.z.boolean().describe(`Required on every edge`).optional()},fe={id:c.z.string().optional(),objectId:c.z.string().optional(),system:c.z.boolean().optional(),unique:c.z.boolean().optional()},pe=Object.fromEntries(C.map(e=>[e,!0])),q=[`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`location`],J=[...q,`select`,`multiselect`,`status`],Y={text:I,number:L,checkbox:R,date:z,phone:B,currency:V,location:U,select:W,multiselect:G,status:H},me={...Y,select:W.extend({options:M.describe(`Options`)}),multiselect:G.extend({options:N.describe(`Options`)}),status:H.extend({options:P.describe(`Statuses`)})},propertyWireConfigShapeFor=e=>me[e].omit(pe).shape,storedPropertyMember=e=>c.z.object({...K,...fe,type:c.z.literal(e).describe(`Property type`),...Y[e].shape}).strip(),X=c.z.discriminatedUnion(`type`,J.map(storedPropertyMember)),Z=c.z.object({definitions:c.z.array(X).min(1).max(m.optionsPerAttribute).describe(`Edge properties`)}).strip().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),he=refuseForeignKeys(Object.fromEntries(J.map(e=>[e,new Set(Object.keys(propertyWireConfigShapeFor(e)))])),`property key`,[...Object.keys(K),`type`]);function refuseForeignPropertyKeys(e,t){he(e.type,e,t)}const ge=q.reduce((e,t)=>(Object.assign(e,propertyWireConfigShapeFor(t)),e),{}),optionPropertyWireMember=e=>c.z.object({...K,type:e.length===1?c.z.literal(e[0]).describe(`Property type`):c.z.enum(e).describe(`Property type`),...propertyWireConfigShapeFor(e[0])}).strict(),Q=c.z.discriminatedUnion(`type`,[optionPropertyWireMember([`select`,`multiselect`]),optionPropertyWireMember([`status`]),c.z.object({...K,type:c.z.enum(q).describe(`Property type`),...ge}).strict().superRefine(refuseForeignPropertyKeys)]),_e=c.z.object({definitions:c.z.array(Q).min(1).max(m.optionsPerAttribute).describe(`Edge properties`)}).strict().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),ve=S.extend({targets:c.z.array(ce).min(1).describe(`Target object(s)`),cardinality:c.z.enum([`one`,`many`]).describe(`one or many`),maxItems:c.z.number().int().min(1).optional().describe(`Max linked records`),bilateral:le.optional().describe(`Syncs the other side's attribute`),properties:Z.optional()}),ye=S.extend({expression:c.z.string().min(1).superRefine((e,t)=>{try{parseComputedFormula(e)}catch(e){t.addIssue({code:c.z.ZodIssueCode.custom,message:e instanceof Error?e.message:`Invalid formula expression`})}}).describe(`The formula expression, compiled against this object's attributes`),returnType:c.z.enum([`text`,`number`,`boolean`,`date`,`select`,`multiselect`]).describe(`The formula's result type`),decimals:c.z.number().int().min(0).max(10).optional().describe(`Decimal places shown for a number result`),currencyCode:c.z.string().length(3).optional().describe(`ISO 4217 code a number result renders with; presentation only`),allowRelations:c.z.boolean().optional().describe(`Whether the expression may read across a relation`),optionsSource:F.optional().describe(`Mirrors an option set`)}),be=S.extend({relationAttribute:c.z.string().min(1).optional().describe(`API name of the relation this rollup aggregates through`),relationPath:c.z.string().optional().describe(`Not supported yet — single-hop only`),targetAttribute:c.z.string().min(1).optional().describe(`API name of the attribute aggregated on the relation's target object; not read by count`),function:c.z.enum([`sum`,`avg`,`earliest`,`latest`,`count`,`countValues`,`countUniqueValues`,`countEmpty`,`percentEmpty`,`percentNotEmpty`,`original`]).describe(`The aggregation applied across the linked records`),decimals:c.z.number().int().min(0).max(10).optional().describe(`Decimal places shown for a numeric result`),targetAttributeType:c.z.string().optional().describe(`Server-set`),targetAttributeOptions:c.z.array(k).optional().describe(`Server-set`),targetCurrencyCode:c.z.string().length(3).optional().describe(`Server-set`),optionsSource:F.optional().describe(`Mirrors an option set`)});function rollupTargetIssue(e,t){if(e===`rollup`&&t.function!==`count`&&t.targetAttribute===void 0)return{path:[`targetAttribute`],message:`targetAttribute is required for a "${String(t.function)}" rollup`}}const $={text:I,richtext:ue,number:L,checkbox:R,date:z,phone:B,currency:V,status:H,location:U,select:W,multiselect:G,user:de,relation:ve,formula:ye,rollup:be,document:S.extend({properties:Z.optional(),accepts:c.z.array(c.z.string().min(1)).optional().describe("MIME prefixes or globs a file must match (e.g. `image/*`, `*.pdf`)"),maxFileSize:c.z.number().int().min(1).optional().describe(`Maximum file size in bytes`)})};function getAttributeConfigSchema(e){let t=$[e];if(!t)throw new o.ValidationError(`Unsupported attribute type: ${e}`,[]);return t}function parseAttributeConfig(e,t){let n=getAttributeConfigSchema(e).strip().parse(t),r=rollupTargetIssue(e,n);if(r)throw validationErrorFromIssues([r]);return n}function getAttributeConfigWriteSchema(e){let t=getAttributeConfigSchema(e).extend({icon:g.optional()});switch(e){case`select`:return t.extend({options:M.describe(`Options`)});case`multiselect`:return t.extend({options:N.describe(`Options`)});case`status`:return t.extend({options:P.describe(`Statuses`)});default:return t}}function validationErrorFromIssues(e){return o.ValidationError.fromZodErrors(e.map(e=>({path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message})))}function parseWriteSchema(e,t){let n=getAttributeConfigWriteSchema(e).strip().safeParse(t);if(!n.success)throw validationErrorFromIssues(n.error.issues);let r=rollupTargetIssue(e,n.data);if(r)throw validationErrorFromIssues([r]);return n.data}function parseAttributeConfigForCreate(e,t){return parseWriteSchema(e,t)}function validatePatchedIcon(e){if(!Object.prototype.hasOwnProperty.call(e,`icon`))return;let t=g.optional().safeParse(e.icon);if(!t.success)throw o.ValidationError.fromZodErrors(t.error.issues.map(e=>({path:[`icon`,...e.path.map(e=>typeof e==`symbol`?String(e):e)],message:e.message})))}function isSelectLike(e){return e===`select`||e===`multiselect`||e===`status`}function parseAttributeConfigForUpdate(e,t){let n=Object.prototype.hasOwnProperty.call(t,`options`),r=Object.prototype.hasOwnProperty.call(t,`icon`),i={...e,...t};if(validatePatchedIcon(t),n){let{icon:t,...n}=i,a=parseWriteSchema(e.type,r?i:n);return!r&&t!==void 0&&(a.icon=t),a}let a=e.options;isSelectLike(e.type)&&(i.options=[{value:`__legacy__`,label:`__legacy__`}]);let o=getAttributeConfigSchema(e.type).strip().safeParse(i);if(!o.success)throw validationErrorFromIssues(o.error.issues);let s=o.data;return isSelectLike(e.type)&&(s.options=a),s}Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return normalizeDateValue}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return isPlainRecord}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return validateObjectName}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return validateOptions}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return validateViewName}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return validateAttributeName}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return validateIconName}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return isComputedFunctionName}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return validateLabel}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return dateValueStart}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return formatComputedResult}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return parseComputedFormula}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return parseResourceVisibility}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return isNativeObjectName}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return getAttributeConfigWriteSchema}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return evaluateComputedFormula}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return parseAttributeConfigForCreate}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return getAttributeConfigSchema}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return assertUniqueBy}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return parseAttributeConfigForUpdate}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return refuseForeignKeys}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return parseAttributeConfig}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return withoutUnknownOptionKeys}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return ComputedFormulaParseError}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return evaluateComputedFormulaWithResult}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return evaluateComputedAst}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return isDateRangeValue}});
13
+ `;case`r`:return`\r`;case`t`:return` `;default:throw new ComputedFormulaParseError(`Unknown escape sequence "\\${e}" at position ${t}`)}}function scanNumber(e,t){let n=t;for(;n<e.length&&isDigit(e[n]);)n+=1;if(e[n]===`.`){let t=n;if(n+=1,!isDigit(e[n]))throw new ComputedFormulaParseError(`Invalid number literal at position ${t}`);for(;n<e.length&&isDigit(e[n]);)n+=1}let r=e.slice(t,n),i=Number(r);if(!Number.isFinite(i))throw new ComputedFormulaParseError(`Invalid number literal "${r}"`);return{value:i,nextIndex:n}}function scanIdentifier(e,t){let n=t+1;for(;n<e.length&&isIdentifierPart(e[n]);)n+=1;return{value:e.slice(t,n),nextIndex:n}}function isDigit(e){return e!==void 0&&e>=`0`&&e<=`9`}function isIdentifierStart(e){return e!==void 0&&/[A-Za-z_]/.test(e)}function isIdentifierPart(e){return e!==void 0&&/[A-Za-z0-9_]/.test(e)}var Parser=class{constructor(e){this.tokens=e,this.position=0}parseExpression(){return this.parseBinaryExpression(0)}expectEnd(){let e=this.peek();if(e!==void 0)throw new ComputedFormulaParseError(`Unexpected token ${describeToken(e)} at position ${e.position}`)}parseBinaryExpression(e){let t=this.parsePrimary();for(;;){let n=this.peek();if(n?.kind!==`operator`)return t;let r=getOperatorPrecedence(n.value);if(r<e)return t;let i=n.value;this.consume();let a=this.parseBinaryExpression(r+1);t={kind:`binary`,operator:i,left:t,right:a}}}parsePrimary(){let e=this.consume();if(e===void 0)throw new ComputedFormulaParseError(`Unexpected end of expression`);switch(e.kind){case`string`:case`number`:case`boolean`:return{kind:`literal`,value:e.value};case`null`:return{kind:`literal`,value:null};case`identifier`:return this.parseIdentifier(e.value);case`punctuation`:if(e.value===`(`){let e=this.parseExpression();return this.expectPunctuation(`)`),e}break;case`operator`:if(e.value===`-`){let e=this.consume();if(e?.kind===`number`)return{kind:`literal`,value:-e.value}}}throw new ComputedFormulaParseError(`Expected literal, path, call, or parenthesized expression at position ${e.position}`)}parseIdentifier(e){if(this.matchPunctuation(`(`)){let t=[];if(!this.matchPunctuation(`)`)){do t.push(this.parseExpression());while(this.matchPunctuation(`,`));this.expectPunctuation(`)`)}return{kind:`call`,functionName:e.toLowerCase(),args:t}}let t=[e];for(;this.matchPunctuation(`.`);){let e=this.consume();if(e?.kind!==`identifier`)throw new ComputedFormulaParseError(`Expected attribute name after path separator at position ${e?.position??this.previousPosition()}`);t.push(e.value)}return{kind:`path`,parts:t}}expectPunctuation(e){if(!this.matchPunctuation(e))throw new ComputedFormulaParseError(`Expected "${e}" at position ${this.peek()?.position??this.previousPosition()}`)}matchPunctuation(e){let t=this.peek();return t?.kind===`punctuation`&&t.value===e&&(this.consume(),!0)}peek(){return this.tokens[this.position]}consume(){let e=this.tokens[this.position];return this.position+=1,e}previousPosition(){return this.tokens[this.position-1]?.position??0}};function describeToken(e){switch(e.kind){case`identifier`:case`number`:case`string`:case`boolean`:case`operator`:case`punctuation`:return`"${String(e.value)}"`;case`null`:return`"null"`;default:return e}}function getOperatorPrecedence(e){switch(e){case`*`:case`/`:return 3;case`+`:case`-`:return 2;case`>`:case`<`:case`>=`:case`<=`:case`==`:case`!=`:return 1;default:return e}}function evaluateAst(e,t){switch(e.kind){case`literal`:return e.value;case`path`:return resolvePath(t,e.parts);case`binary`:return evaluateBinary(e.operator,evaluateAst(e.left,t),evaluateAst(e.right,t));case`call`:return evaluateCallNode(e.functionName,e.args,t);default:return unreachable(e)}}function evaluateCallNode(e,t,n){if(assertComputedFunctionName(e),validateArity(e,t.length),e===`if`){let e=evaluateAst(t[0],n);return e===null?null:evaluateAst(e?t[1]:t[2],n)}return evaluateCall(e,t.map(e=>evaluateAst(e,n)))}function resolvePath(e,t){return t.reduce((e,t)=>resolvePathPart(e,t),e)}function resolvePathPart(e,t){if(Array.isArray(e))return e.map(e=>resolvePathPart(e,t));if(!isPlainRecord(e))return null;if(Object.hasOwn(e,t))return e[t]??null;let n=e.values;return isPlainRecord(n)&&Object.hasOwn(n,t)?n[t]??null:null}function evaluateBinary(e,t,n){switch(e){case`+`:return add(t,n);case`-`:return numericBinary(t,n,(e,t)=>e-t);case`*`:return numericBinary(t,n,(e,t)=>e*t);case`/`:return numericBinary(t,n,(e,t)=>e/t);case`>`:return compareWith(t,n,e=>e>0);case`<`:return compareWith(t,n,e=>e<0);case`>=`:return compareWith(t,n,e=>e>=0);case`<=`:return compareWith(t,n,e=>e<=0);case`==`:return equalScalar(t,n);case`!=`:{let e=equalScalar(t,n);return e===null?null:!e}default:return unreachable(e)}}function add(e,t){return typeof e==`string`||typeof t==`string`?`${e??``}${t??``}`:numericBinary(e,t,(e,t)=>e+t)}function compareWith(e,t,n){let r=compare(e,t);return r===null?null:n(r)}function compare(e,t){if(!areCommensurable([e,t]))return null;let n=toFiniteNumber(e),r=toFiniteNumber(t);if(n!==null&&r!==null)return n-r;let i=toDate(e),a=toDate(t);return i&&a?i.getTime()-a.getTime():null}function equalScalar(e,t){return e===t?!0:e==null||t==null?!1:areCommensurable([e,t])?compare(e,t)===0:null}function assertComputedFunctionName(e){if(!isComputedFunctionName(e))throw Error(`Unknown computed function "${e}"`)}function validateArity(e,t){let{minArgs:n,maxArgs:r}=x[e];if(t>=n&&t<=(r??1/0))return;let i=r===void 0?`at least ${n}`:`between ${n} and ${r}`;throw Error(`Function "${e}" expects ${i} arguments, received ${t}`)}function evaluateCall(e,t){switch(e){case`concat`:return t.filter(e=>e!=null).map(String).join(``);case`sum`:return areCommensurable(t)?numericValues(t).reduce((e,t)=>e+t,0):null;case`avg`:{if(!areCommensurable(t))return null;let e=numericValues(t);return e.length>0?e.reduce((e,t)=>e+t,0)/e.length:null}case`count`:return collectionItems(t[0]).length;case`min`:return minMax(t,`min`);case`max`:return minMax(t,`max`);case`earliest`:return dateMinMax(t,`min`);case`latest`:return dateMinMax(t,`max`);case`unique`:return uniqueNonEmpty(collectionItems(t[0]));case`first`:return collectionItems(t[0]).find(e=>e!=null)??null;case`percent_empty`:return percentByEmptyState(t[0],!0);case`percent_not_empty`:return percentByEmptyState(t[0],!1);case`count_empty`:return collectionItems(t[0]).filter(s.t).length;case`count_not_empty`:return collectionItems(t[0]).filter(e=>!s.t(e)).length;case`count_unique`:return uniqueNonEmpty(collectionItems(t[0])).length;default:return unreachable(e)}}function unreachable(e){return e}function numericValues(e){return flatten(e).map(toFiniteNumber).filter(e=>e!==null)}function areCommensurable(e){let t=new Set;for(let n of flatten(e))isCurrencyValue(n)&&t.add(currencyCode(n));return t.size<=1}function currencyCode(e){return e.code.toUpperCase()}function numericBinary(e,t,n){if(!areCommensurable([e,t]))return null;let r=toFiniteNumber(e),i=toFiniteNumber(t);if(r===null||i===null)return null;let a=n(r,i);return Number.isFinite(a)?a:null}function minMax(e,t){if(!areCommensurable(e))return null;let n=numericValues(e);return n.length>0?t===`min`?Math.min(...n):Math.max(...n):dateMinMax(e,t)}function dateMinMax(e,t){let n=flatten(e).map(toDate).filter(e=>e!==null);if(n.length===0)return null;let r=n.map(e=>e.getTime()),i=t===`min`?Math.min(...r):Math.max(...r);return new Date(i).toISOString()}function percentByEmptyState(e,t){let n=collectionItems(e);return n.length===0?0:n.filter(e=>s.t(e)===t).length/n.length}function uniqueNonEmpty(e){let t=new Set,n=[];for(let r of e){if(s.t(r))continue;let e=uniqueKey(r);t.has(e)||(t.add(e),n.push(r))}return n}function collectionItems(e){return e==null?[]:Array.isArray(e)?flatten(e):[e]}function flatten(e){return e.flat(1/0)}function toFiniteNumber(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return isCurrencyValue(e)&&Number.isFinite(e.value)?e.value:null}function isCurrencyValue(e){return typeof e==`object`&&!!e&&typeof e.value==`number`&&typeof e.code==`string`}function toDate(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e!=`string`){let t=dateValueStart(e);if(t===null)return null;let n=new Date(t);return Number.isNaN(n.getTime())?null:n}let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function uniqueKey(e){if(isCurrencyValue(e))return`currency:${currencyCode(e)}:${e.value}`;let t=toFiniteNumber(e);return t===null?e instanceof Date?`date:${e.toISOString()}`:`${typeof e}:${JSON.stringify(e)}`:`number:${t}`}function isPlainRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function formatComputedResult(e,t,n){if(e==null)return null;let stringifyScalar=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Date?String(e):null;switch(t){case`number`:{let t=typeof e==`number`?e:Number(e);return Number.isNaN(t)?null:n===void 0?t:Number(t.toFixed(n))}case`boolean`:return!!e;case`date`:return e instanceof Date?e.toISOString():typeof e==`string`?e:null;case`text`:return String(e);case`select`:if(Array.isArray(e)){for(let t of e){if(t==null)continue;let e=stringifyScalar(t);if(e!==null)return e}return null}return stringifyScalar(e);case`multiselect`:return Array.isArray(e)?e.flatMap(e=>{if(e==null)return[];let t=stringifyScalar(e);return t===null?[]:[t]}):stringifyScalar(e)===null?[]:[String(e)];default:throw Error(`Unsupported computed return type: ${t}`)}}function evaluateComputedAst(e,t){return evaluateAst(e,t)}function evaluateComputedFormula(e,t){return evaluateAst(parseComputedFormula(e),t)}function evaluateComputedFormulaWithResult(e,t,n,r){try{let i=evaluateAst(parseComputedFormula(e),t);return{value:n?formatComputedResult(i,n,r):i}}catch(e){return{value:null,error:e instanceof Error?e.message:String(e)}}}const S=c.z.object({placeholder:c.z.string().optional(),description:c.z.string().optional(),defaultValue:c.z.unknown().optional(),icon:c.z.string().optional(),order:c.z.number().int().optional(),hidden:c.z.boolean().optional(),archived:c.z.boolean().optional(),deprecated:c.z.boolean().optional(),metadata:c.z.record(c.z.string(),c.z.unknown()).optional()}),C=[`placeholder`,`description`,`defaultValue`,`icon`,`order`,`hidden`,`archived`,`deprecated`,`metadata`],w={relation:{icon:g.optional().describe(`Field icon from search_icons`)}};function wireOmittedConfigKeysFor(e){let t=w[e]??{};return C.filter(e=>!(e in t))}function refuseForeignKeys(e,t,n=[]){let r=new Set(n);return function refuse(n,i,a,o=[]){let s=e[n];if(s!==void 0&&i!==void 0)for(let e of Object.keys(i))s.has(e)||r.has(e)||a.addIssue({code:`custom`,path:[...o,e],message:`"${e}" is not a ${n} ${t}; keys of ${n}: ${[...s].join(`, `)}`})}}const T=c.z.object({value:c.z.string().min(1).describe(`Stored value`),label:c.z.string().min(1).describe(`Label people see`),description:c.z.string().describe(`Extra context`).optional(),inverse:c.z.string().describe(`Paired option's value (symmetric)`).optional(),archived:c.z.boolean().describe(`Hides without deleting`).optional()}),E=c.z.enum([`idle`,`in_progress`,`finished`]).describe(`Workflow stage`),D=T.extend({color:h}).strict(),O=D,k=T.extend({color:h,group:E}).strict(),A=T.extend({color:c.z.string().optional().describe(`A color id`),group:E.optional()}).strict(),j=new Set(A.keyof().options),se=[`options`,`targetAttributeOptions`];function withoutUnknownOptionKeys(e){let t=e;for(let n of se){let r=e[n];if(!Array.isArray(r))continue;let i=!1,a=r.map(e=>!isPlainRecord(e)||Object.keys(e).every(e=>j.has(e))?e:(i=!0,Object.fromEntries(Object.entries(e).filter(([e])=>j.has(e)))));i&&(t={...t,[n]:a})}let n=e.properties;if(isPlainRecord(n)&&Array.isArray(n.definitions)){let e=n.definitions,r=e.map(e=>isPlainRecord(e)?withoutUnknownOptionKeys(e):e);r.some((t,n)=>t!==e[n])&&(t={...t,properties:{...n,definitions:r}})}return t}const M=c.z.array(A).min(1).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`});function writeOptionsArraySchema(e){return c.z.array(e).min(1).max(m.optionsPerAttribute).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`})}const N=writeOptionsArraySchema(D),P=writeOptionsArraySchema(O),F=writeOptionsArraySchema(k),ce=c.z.object({object:c.z.string().min(1).describe(`Target object`),displayTemplate:c.z.string().optional().describe(`Linked record label template`),filter:c.z.record(c.z.string(),c.z.unknown()).optional().describe(`Restricts linkable records`)}),le=c.z.object({object:c.z.string().min(1).describe(`Other side's object`),attribute:c.z.string().min(1).describe(`Other side's attribute`),cardinality:c.z.enum([`one`,`many`]).optional().describe(`Other side's cardinality`),label:c.z.string().min(1).optional().describe(`Other side's label`),storageOwner:c.z.boolean().optional().describe(`Owns the join storage`)}),I=c.z.object({objectName:c.z.string().min(1).describe(`API name of the object whose options are mirrored`),attributeName:c.z.string().min(1).describe(`API name of the select/status attribute to mirror options from`),attributeId:c.z.string().optional().describe(`Id of the source attribute, resolved by the server`)}),L=S.extend({multiline:c.z.boolean().describe(`Renders as a multi-line textarea`).optional(),minLength:c.z.number().int().min(0).describe(`Minimum character count`).optional(),maxLength:c.z.number().int().min(1).describe(`Maximum character count`).optional(),pattern:c.z.string().describe(`Regular expression the value must match`).optional(),format:c.z.enum([`email`,`url`,`slug`]).describe(`Validates and renders as this format`).optional()}),ue=S,R=S.extend({renderAs:c.z.enum([`number`,`rating`]).describe(`Plain number or a star rating`).optional(),min:c.z.number().describe(`Minimum allowed value`).optional(),max:c.z.number().describe(`Maximum allowed value`).optional(),unit:c.z.enum([`integer`,`decimal`,`percentage`]).describe(`How the value is stored and rendered`).optional(),decimals:c.z.number().int().min(0).max(10).describe(`Decimal places shown`).optional()}),z=S,de=S.extend({dateFormat:c.z.enum([`short`,`long`,`full`,`relative`]).describe(`How the date is rendered`).optional(),minDate:c.z.string().describe(`Earliest allowed date (ISO)`).optional(),maxDate:c.z.string().describe(`Latest allowed date (ISO)`).optional(),includeTime:c.z.boolean().describe(`Also captures a time of day`).optional(),endDate:c.z.boolean().describe(`Paired with another date attribute as a range's end`).optional(),timeFormat:c.z.enum([`12h`,`24h`]).describe(`Clock format when a time is included`).optional()}),B=S.extend({defaultCountryCode:c.z.string().length(3).describe(`ISO country code preselected in the dialer`).optional()}),V=S.extend({defaultCurrency:c.z.string().length(3).describe(`ISO currency code preselected for new values`).optional(),allowedCurrencies:c.z.array(c.z.string().length(3)).describe(`ISO currency codes a value may use; any currency when omitted`).optional(),allowNegative:c.z.boolean().describe(`Whether a negative amount is accepted`).optional()}),H=S.extend({options:M.describe(`The workflow statuses, in order`)}),U=S.extend({granularity:c.z.enum([`full`,`address`,`city`,`state`,`country`,`coordinates`]).describe(`How precise a location must be captured`).optional(),defaultCountry:c.z.string().length(3).describe(`ISO country code preselected for new values`).optional(),allowedCountries:c.z.array(c.z.string().length(3)).describe(`ISO country codes a value may use; any country when omitted`).optional()}),W=S.extend({options:M.describe(`Options`),renderAs:c.z.literal(`badges`).optional().describe(`Renders the chosen option as a colored badge`)}),G=S.extend({options:M.describe(`Options`),renderAs:c.z.literal(`badges`).optional().describe(`Renders the chosen options as colored badges`)}),fe=S.extend({types:c.z.array(c.z.enum([`user`,`agent`])).min(1).optional().describe(`Which kinds of actor can be picked; both when omitted`),multiple:c.z.boolean().optional().describe(`Whether more than one actor can be picked`)}),K={name:b.describe(`Property API name`),label:c.z.string().min(1).describe(`Label people see`),required:c.z.boolean().describe(`Required on every edge`).optional()},pe={id:c.z.string().optional(),objectId:c.z.string().optional(),system:c.z.boolean().optional(),unique:c.z.boolean().optional()},me=Object.fromEntries(C.map(e=>[e,!0])),q=[`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`location`],J=[...q,`select`,`multiselect`,`status`],Y={text:L,number:R,checkbox:z,date:de,phone:B,currency:V,location:U,select:W,multiselect:G,status:H},he={...Y,select:W.extend({options:N.describe(`Options`)}),multiselect:G.extend({options:P.describe(`Options`)}),status:H.extend({options:F.describe(`Statuses`)})},propertyWireConfigShapeFor=e=>he[e].omit(me).shape,storedPropertyMember=e=>c.z.object({...K,...pe,type:c.z.literal(e).describe(`Property type`),...Y[e].shape}).strip(),X=c.z.discriminatedUnion(`type`,J.map(storedPropertyMember)),Z=c.z.object({definitions:c.z.array(X).min(1).max(m.optionsPerAttribute).describe(`Edge properties`)}).strip().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),ge=refuseForeignKeys(Object.fromEntries(J.map(e=>[e,new Set(Object.keys(propertyWireConfigShapeFor(e)))])),`property key`,[...Object.keys(K),`type`]);function refuseForeignPropertyKeys(e,t){ge(e.type,e,t)}const _e=q.reduce((e,t)=>(Object.assign(e,propertyWireConfigShapeFor(t)),e),{}),optionPropertyWireMember=e=>c.z.object({...K,type:e.length===1?c.z.literal(e[0]).describe(`Property type`):c.z.enum(e).describe(`Property type`),...propertyWireConfigShapeFor(e[0])}).strict(),Q=c.z.discriminatedUnion(`type`,[optionPropertyWireMember([`select`,`multiselect`]),optionPropertyWireMember([`status`]),c.z.object({...K,type:c.z.enum(q).describe(`Property type`),..._e}).strict().superRefine(refuseForeignPropertyKeys)]),ve=c.z.object({definitions:c.z.array(Q).min(1).max(m.optionsPerAttribute).describe(`Edge properties`)}).strict().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),ye=S.extend({targets:c.z.array(ce).min(1).describe(`Target object(s)`),cardinality:c.z.enum([`one`,`many`]).describe(`one or many`),maxItems:c.z.number().int().min(1).optional().describe(`Max linked records`),bilateral:le.optional().describe(`Syncs the other side's attribute`),properties:Z.optional()}),be=S.extend({expression:c.z.string().min(1).superRefine((e,t)=>{try{parseComputedFormula(e)}catch(e){t.addIssue({code:c.z.ZodIssueCode.custom,message:e instanceof Error?e.message:`Invalid formula expression`})}}).describe(`The formula expression, compiled against this object's attributes`),returnType:c.z.enum([`text`,`number`,`boolean`,`date`,`select`,`multiselect`]).describe(`The formula's result type`),decimals:c.z.number().int().min(0).max(10).optional().describe(`Decimal places shown for a number result`),currencyCode:c.z.string().length(3).optional().describe(`ISO 4217 code a number result renders with; presentation only`),allowRelations:c.z.boolean().optional().describe(`Whether the expression may read across a relation`),optionsSource:I.optional().describe(`Mirrors an option set`)}),xe=S.extend({relationAttribute:c.z.string().min(1).optional().describe(`API name of the relation this rollup aggregates through`),relationPath:c.z.string().optional().describe(`Not supported yet — single-hop only`),targetAttribute:c.z.string().min(1).optional().describe(`API name of the attribute aggregated on the relation's target object; not read by count`),function:c.z.enum([`sum`,`avg`,`earliest`,`latest`,`count`,`countValues`,`countUniqueValues`,`countEmpty`,`percentEmpty`,`percentNotEmpty`,`original`]).describe(`The aggregation applied across the linked records`),decimals:c.z.number().int().min(0).max(10).optional().describe(`Decimal places shown for a numeric result`),targetAttributeType:c.z.string().optional().describe(`Server-set`),targetAttributeOptions:c.z.array(A).optional().describe(`Server-set`),targetCurrencyCode:c.z.string().length(3).optional().describe(`Server-set`),optionsSource:I.optional().describe(`Mirrors an option set`)});function rollupTargetIssue(e,t){if(e===`rollup`&&t.function!==`count`&&t.targetAttribute===void 0)return{path:[`targetAttribute`],message:`targetAttribute is required for a "${String(t.function)}" rollup`}}const $={text:L,richtext:ue,number:R,checkbox:z,date:de,phone:B,currency:V,status:H,location:U,select:W,multiselect:G,user:fe,relation:ye,formula:be,rollup:xe,document:S.extend({properties:Z.optional(),accepts:c.z.array(c.z.string().min(1)).optional().describe("MIME prefixes or globs a file must match (e.g. `image/*`, `*.pdf`)"),maxFileSize:c.z.number().int().min(1).optional().describe(`Maximum file size in bytes`)})};function getAttributeConfigSchema(e){let t=$[e];if(!t)throw new o.ValidationError(`Unsupported attribute type: ${e}`,[]);return t}function parseAttributeConfig(e,t){let n=getAttributeConfigSchema(e).strip().parse(t),r=rollupTargetIssue(e,n);if(r)throw validationErrorFromIssues([r]);return n}function getAttributeConfigWriteSchema(e){let t=getAttributeConfigSchema(e).extend({icon:g.optional()});switch(e){case`select`:return t.extend({options:N.describe(`Options`)});case`multiselect`:return t.extend({options:P.describe(`Options`)});case`status`:return t.extend({options:F.describe(`Statuses`)});default:return t}}function validationErrorFromIssues(e){return o.ValidationError.fromZodErrors(e.map(e=>({path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message})))}function parseWriteSchema(e,t){let n=getAttributeConfigWriteSchema(e).strip().safeParse(t);if(!n.success)throw validationErrorFromIssues(n.error.issues);let r=rollupTargetIssue(e,n.data);if(r)throw validationErrorFromIssues([r]);return n.data}function parseAttributeConfigForCreate(e,t){return parseWriteSchema(e,t)}function validatePatchedIcon(e){if(!Object.prototype.hasOwnProperty.call(e,`icon`))return;let t=g.optional().safeParse(e.icon);if(!t.success)throw o.ValidationError.fromZodErrors(t.error.issues.map(e=>({path:[`icon`,...e.path.map(e=>typeof e==`symbol`?String(e):e)],message:e.message})))}function isSelectLike(e){return e===`select`||e===`multiselect`||e===`status`}function parseAttributeConfigForUpdate(e,t){let n=Object.prototype.hasOwnProperty.call(t,`options`),r=Object.prototype.hasOwnProperty.call(t,`icon`),i={...e,...t};if(validatePatchedIcon(t),n){let{icon:t,...n}=i,a=parseWriteSchema(e.type,r?i:n);return!r&&t!==void 0&&(a.icon=t),a}let a=e.options;isSelectLike(e.type)&&(i.options=[{value:`__legacy__`,label:`__legacy__`}]);let o=getAttributeConfigSchema(e.type).strip().safeParse(i);if(!o.success)throw validationErrorFromIssues(o.error.issues);let s=o.data;return isSelectLike(e.type)&&(s.options=a),s}Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return isNativeObjectName}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return isComputedFunctionName}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return dateValueStart}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return evaluateComputedFormulaWithResult}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return parseComputedFormula}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return ComputedFormulaParseError}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return validateIconName}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return normalizeDateValue}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return validateLabel}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return validateObjectName}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return assertUniqueBy}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return validateAttributeName}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return validateOptions}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return evaluateComputedFormula}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return isPlainRecord}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return isDateRangeValue}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return parseResourceVisibility}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return getAttributeConfigSchema}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return withoutUnknownOptionKeys}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return parseAttributeConfig}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return refuseForeignKeys}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return parseAttributeConfigForCreate}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return getAttributeConfigWriteSchema}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return parseAttributeConfigForUpdate}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return formatComputedResult}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return evaluateComputedAst}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return wireOmittedConfigKeysFor}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return validateViewName}});
@@ -1,6 +1,6 @@
1
1
 
2
- import { u as DateAttribute } from "./attributes-BrWmES5w.mjs";
3
- import { r as ValidationMessages } from "./index-DggAjGTr.mjs";
2
+ import { u as DateAttribute } from "./attributes-0MFN3D1T.mjs";
3
+ import { r as ValidationMessages } from "./index-D9Zkc3Zp.mjs";
4
4
  import { z as z$1 } from "zod";
5
5
  //#region src/validation/primitives/date.d.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
1
 
2
- import { u as DateAttribute } from "./attributes-DF899HOt.js";
3
- import { r as ValidationMessages } from "./index-OvRk1isl.js";
2
+ import { u as DateAttribute } from "./attributes-D3wn8qoZ.js";
3
+ import { r as ValidationMessages } from "./index-BxM_oMmi.js";
4
4
  import { z as z$1 } from "zod";
5
5
  //#region src/validation/primitives/date.d.ts
6
6
  /**