@stonecrop/schema 0.13.14 → 0.15.0

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 (141) hide show
  1. package/README.md +38 -92
  2. package/dist/cli.js +6 -6
  3. package/dist/index-rozX0Luh.js +458 -0
  4. package/dist/index-rozX0Luh.js.map +1 -0
  5. package/dist/index.js +70 -31
  6. package/dist/index.js.map +1 -1
  7. package/dist/schema.d.ts +324 -88
  8. package/dist/src/column-schema.d.ts +17 -8
  9. package/dist/src/column-schema.d.ts.map +1 -1
  10. package/dist/src/component-meta.d.ts +96 -0
  11. package/dist/src/component-meta.d.ts.map +1 -0
  12. package/dist/src/component-meta.js +85 -0
  13. package/dist/src/converter/heuristics.d.ts.map +1 -1
  14. package/dist/src/converter/heuristics.js +6 -13
  15. package/dist/src/converter/index.d.ts +1 -1
  16. package/dist/src/converter/index.d.ts.map +1 -1
  17. package/dist/src/converter/index.js +9 -8
  18. package/dist/src/converter/scalars.d.ts +1 -1
  19. package/dist/src/converter/scalars.d.ts.map +1 -1
  20. package/dist/src/converter/scalars.js +23 -26
  21. package/dist/src/converter/types.d.ts +17 -8
  22. package/dist/src/converter/types.d.ts.map +1 -1
  23. package/dist/src/doctype.d.ts +127 -9
  24. package/dist/src/doctype.d.ts.map +1 -1
  25. package/dist/src/doctype.js +80 -7
  26. package/dist/src/field.d.ts +69 -12
  27. package/dist/src/field.d.ts.map +1 -1
  28. package/dist/src/field.js +45 -7
  29. package/dist/src/index.d.ts +4 -3
  30. package/dist/src/index.d.ts.map +1 -1
  31. package/dist/src/index.js +7 -3
  32. package/package.json +14 -9
  33. package/dist/cli.cjs +0 -41
  34. package/dist/cli.cjs.map +0 -1
  35. package/dist/converter/heuristics.js +0 -258
  36. package/dist/converter/index.js +0 -181
  37. package/dist/converter/scalars.js +0 -86
  38. package/dist/converter/types.js +0 -5
  39. package/dist/converter-CYNFRwPg.js +0 -512
  40. package/dist/converter-CYNFRwPg.js.map +0 -1
  41. package/dist/converter-DNwpowpq.js +0 -459
  42. package/dist/converter-DNwpowpq.js.map +0 -1
  43. package/dist/doctype.js +0 -152
  44. package/dist/field.js +0 -110
  45. package/dist/fieldtype.js +0 -97
  46. package/dist/index--rNo7Kel.js +0 -494
  47. package/dist/index--rNo7Kel.js.map +0 -1
  48. package/dist/index-0qWNlDQ5.js +0 -450
  49. package/dist/index-0qWNlDQ5.js.map +0 -1
  50. package/dist/index-2UVTfbcY.js +0 -448
  51. package/dist/index-2UVTfbcY.js.map +0 -1
  52. package/dist/index-9QjWZ_PC.js +0 -449
  53. package/dist/index-9QjWZ_PC.js.map +0 -1
  54. package/dist/index-BCADNO5M.js +0 -449
  55. package/dist/index-BCADNO5M.js.map +0 -1
  56. package/dist/index-BJjSlCSo.js +0 -496
  57. package/dist/index-BJjSlCSo.js.map +0 -1
  58. package/dist/index-BRQJGVFR.js +0 -453
  59. package/dist/index-BRQJGVFR.js.map +0 -1
  60. package/dist/index-BatnoC-J.js +0 -429
  61. package/dist/index-BatnoC-J.js.map +0 -1
  62. package/dist/index-BbG7Mzvg.js +0 -495
  63. package/dist/index-BbG7Mzvg.js.map +0 -1
  64. package/dist/index-BdCmYHg0.js +0 -493
  65. package/dist/index-BdCmYHg0.js.map +0 -1
  66. package/dist/index-BhMd2_xl.js +0 -454
  67. package/dist/index-BhMd2_xl.js.map +0 -1
  68. package/dist/index-C5ANE_rn.js +0 -501
  69. package/dist/index-C5ANE_rn.js.map +0 -1
  70. package/dist/index-CLc5mUMQ.js +0 -478
  71. package/dist/index-CLc5mUMQ.js.map +0 -1
  72. package/dist/index-COrltkHl.js +0 -401
  73. package/dist/index-COrltkHl.js.map +0 -1
  74. package/dist/index-Cu-6609R.js +0 -493
  75. package/dist/index-Cu-6609R.js.map +0 -1
  76. package/dist/index-CvN9xK1B.js +0 -453
  77. package/dist/index-CvN9xK1B.js.map +0 -1
  78. package/dist/index-CzoRIy1-.js +0 -408
  79. package/dist/index-CzoRIy1-.js.map +0 -1
  80. package/dist/index-D66L9JNw.js +0 -506
  81. package/dist/index-D66L9JNw.js.map +0 -1
  82. package/dist/index-D68mWfHm.js +0 -510
  83. package/dist/index-D68mWfHm.js.map +0 -1
  84. package/dist/index-D6Up-BP5.js +0 -435
  85. package/dist/index-D6Up-BP5.js.map +0 -1
  86. package/dist/index-D9qPYlSk.js +0 -491
  87. package/dist/index-D9qPYlSk.js.map +0 -1
  88. package/dist/index-DEkR-1RC.js +0 -496
  89. package/dist/index-DEkR-1RC.js.map +0 -1
  90. package/dist/index-DIY_FLR2.js +0 -516
  91. package/dist/index-DIY_FLR2.js.map +0 -1
  92. package/dist/index-DIb_Z0wI.js +0 -476
  93. package/dist/index-DIb_Z0wI.js.map +0 -1
  94. package/dist/index-DNROIEMe.js +0 -449
  95. package/dist/index-DNROIEMe.js.map +0 -1
  96. package/dist/index-DT-NJBvW.js +0 -510
  97. package/dist/index-DT-NJBvW.js.map +0 -1
  98. package/dist/index-DUFcQC-H.js +0 -449
  99. package/dist/index-DUFcQC-H.js.map +0 -1
  100. package/dist/index-DVVTsJNb.js +0 -495
  101. package/dist/index-DVVTsJNb.js.map +0 -1
  102. package/dist/index-DYy5E1cU.js +0 -508
  103. package/dist/index-DYy5E1cU.js.map +0 -1
  104. package/dist/index-DdC5tpt-.js +0 -488
  105. package/dist/index-DdC5tpt-.js.map +0 -1
  106. package/dist/index-Dk593rMz.js +0 -512
  107. package/dist/index-Dk593rMz.js.map +0 -1
  108. package/dist/index-DmD8vmuB.js +0 -449
  109. package/dist/index-DmD8vmuB.js.map +0 -1
  110. package/dist/index-DpCFgELB.js +0 -514
  111. package/dist/index-DpCFgELB.js.map +0 -1
  112. package/dist/index-DqxTn6jG.js +0 -488
  113. package/dist/index-DqxTn6jG.js.map +0 -1
  114. package/dist/index-DyK5-0kh.js +0 -514
  115. package/dist/index-DyK5-0kh.js.map +0 -1
  116. package/dist/index-XSSAHj8g.js +0 -495
  117. package/dist/index-XSSAHj8g.js.map +0 -1
  118. package/dist/index-XZZbfFxT.js +0 -434
  119. package/dist/index-XZZbfFxT.js.map +0 -1
  120. package/dist/index-_3q9Bzka.js +0 -512
  121. package/dist/index-_3q9Bzka.js.map +0 -1
  122. package/dist/index-aeXXzPET.cjs +0 -2
  123. package/dist/index-aeXXzPET.cjs.map +0 -1
  124. package/dist/index-neVkjlgB.js +0 -446
  125. package/dist/index-neVkjlgB.js.map +0 -1
  126. package/dist/index-xdlVWldg.js +0 -408
  127. package/dist/index-xdlVWldg.js.map +0 -1
  128. package/dist/index.cjs +0 -2
  129. package/dist/index.cjs.map +0 -1
  130. package/dist/jsonschema.js +0 -225
  131. package/dist/naming.js +0 -106
  132. package/dist/src/fieldtype.d.ts +0 -63
  133. package/dist/src/fieldtype.d.ts.map +0 -1
  134. package/dist/src/fieldtype.js +0 -105
  135. package/dist/src/jsonschema.d.ts +0 -95
  136. package/dist/src/jsonschema.d.ts.map +0 -1
  137. package/dist/src/schema-field.d.ts +0 -66
  138. package/dist/src/schema-field.d.ts.map +0 -1
  139. package/dist/src/schema-field.js +0 -0
  140. package/dist/src/tsdoc-metadata.json +0 -11
  141. package/dist/validation.js +0 -60
package/dist/index.js CHANGED
@@ -1,34 +1,73 @@
1
- import { B as s, D as l, F as i, G as t, I as o, S as c, T as d, a as p, b as S, V as T, W as n, c as F, d as m, e as L, f as r, g as y, h as A, i as C, j as _, k as f, p as h, l as u, m as E, r as I, s as b, n as D, t as k, o as v, v as N, q as P } from "./index-D66L9JNw.js";
1
+ import { A as d, D as A, F as p, G as S, I as T, T as m, a as u, b as L, V as N, W as y, c as C, d as F, e as f, f as k, g as O, h as b, i as D, j as x, k as E, l as h, n as I, p as _, m as M, o as g, s as v, q as P, t as R, r as w, v as W, u as G } from "./index-rozX0Luh.js";
2
+ const a = {
3
+ ATextInput: "text",
4
+ ATextarea: "text",
5
+ ANumericInput: "number",
6
+ ACheckbox: "boolean",
7
+ ADate: "date",
8
+ ADatePicker: "date",
9
+ ADateSelection: "date",
10
+ ADateTime: "datetime",
11
+ ADuration: "text",
12
+ ADateRange: "date",
13
+ ADropdown: "select",
14
+ ACodeEditor: "code",
15
+ AFormLink: "link",
16
+ AFileAttach: "attach"
17
+ };
18
+ function o(e) {
19
+ return e ? a[e] : void 0;
20
+ }
21
+ const t = {
22
+ AFormLink: "inline",
23
+ AForm: "expand",
24
+ ATable: "expand"
25
+ };
26
+ function i(e) {
27
+ return e ? t[e] : void 0;
28
+ }
29
+ function s(e, n) {
30
+ return i(e.component ?? n) === "inline" ? "inline" : e.cardinality === "noneOrMany" || e.cardinality === "atLeastOne" ? "table" : "record";
31
+ }
32
+ const l = [
33
+ .../* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(t)])
34
+ ].toSorted();
2
35
  export {
3
- s as BUILTIN_FIELD_TYPES,
4
- l as DoctypeFieldSchema,
5
- i as FieldsetFieldSchema,
6
- t as GQL_SCALAR_MAP,
7
- o as INTERNAL_SCALARS,
8
- c as StonecropFieldType,
9
- d as TYPE_MAP,
10
- p as TableFieldSchema,
11
- S as TableViewConfig,
12
- T as ValueFieldSchema,
13
- n as WELL_KNOWN_SCALARS,
14
- F as buildScalarMap,
15
- m as camelToLabel,
16
- L as camelToSnake,
17
- r as classifyFieldType,
18
- y as convertGraphQLSchema,
19
- A as defaultIsEntityField,
20
- C as defaultIsEntityType,
21
- _ as getDefaultComponent,
22
- f as isBuiltinFieldType,
23
- h as parseDoctype,
24
- u as parseField,
25
- E as pascalToSnake,
26
- I as resolveComponent,
27
- b as snakeToCamel,
28
- D as snakeToLabel,
29
- k as toPascalCase,
30
- v as toSlug,
31
- N as validateDoctype,
32
- P as validateField
36
+ d as ActionDefinition,
37
+ l as CANONICAL_COMPONENTS,
38
+ a as COMPONENT_CATEGORY,
39
+ t as COMPONENT_LINK_EXPANSION,
40
+ A as DoctypeFieldSchema,
41
+ p as FieldsetFieldSchema,
42
+ S as GQL_SCALAR_MAP,
43
+ T as INTERNAL_SCALARS,
44
+ m as TableFieldSchema,
45
+ u as TableViewConfig,
46
+ L as TriggerDefinition,
47
+ N as ValueFieldSchema,
48
+ y as WELL_KNOWN_SCALARS,
49
+ C as WorkflowLayout,
50
+ F as WorkflowMeta,
51
+ f as buildScalarMap,
52
+ k as camelToLabel,
53
+ O as camelToSnake,
54
+ b as classifyFieldType,
55
+ o as componentCategory,
56
+ i as componentLinkExpansion,
57
+ D as convertGraphQLSchema,
58
+ x as defaultIsEntityField,
59
+ E as defaultIsEntityType,
60
+ h as isActionAllowedInState,
61
+ I as normalizeFieldKind,
62
+ _ as parseDoctype,
63
+ M as parseField,
64
+ g as pascalToSnake,
65
+ s as resolveLinkRenderMode,
66
+ v as snakeToCamel,
67
+ P as snakeToLabel,
68
+ R as toPascalCase,
69
+ w as toSlug,
70
+ W as validateDoctype,
71
+ G as validateField
33
72
  };
34
73
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.js","sources":["../src/component-meta.ts"],"sourcesContent":["/**\n * Semantic category for a rendering component.\n *\n * `component` is the primary field axis, so the runtime consumers that need to know what a field\n * *means* (atable cell formatting / filter widgets, record-default init) derive it from here. This\n * is the single source of \"what kind of value does this component render\", keyed by the canonical\n * registered component names — each consumer maps the category to its own concern (filter widget,\n * default value, …).\n *\n * @public\n */\nexport type ComponentCategory =\n\t'text' | 'number' | 'boolean' | 'date' | 'datetime' | 'select' | 'code' | 'link' | 'attach'\n\n/**\n * Canonical component → semantic category. Only the components Stonecrop ships with appear here;\n * custom/unknown component names have no category and consumers fall back to their default.\n * @public\n */\nexport const COMPONENT_CATEGORY: Record<string, ComponentCategory> = {\n\tATextInput: 'text',\n\tATextarea: 'text',\n\tANumericInput: 'number',\n\tACheckbox: 'boolean',\n\tADate: 'date',\n\tADatePicker: 'date',\n\tADateSelection: 'date',\n\tADateTime: 'datetime',\n\tADuration: 'text',\n\tADateRange: 'date',\n\tADropdown: 'select',\n\tACodeEditor: 'code',\n\tAFormLink: 'link',\n\tAFileAttach: 'attach',\n}\n\n/**\n * Resolve a component's semantic category, or `undefined` for an unknown (custom) component —\n * callers treat that as \"no opinion\" and use their own default.\n * @public\n */\nexport function componentCategory(component?: string): ComponentCategory | undefined {\n\treturn component ? COMPONENT_CATEGORY[component] : undefined\n}\n\n/**\n * Whether a link component expands its target doctype, or renders the link inline.\n *\n * This is the *only* axis the component decides. It deliberately does not choose between an\n * embedded record and an embedded table: `cardinality` states whether the value is a scalar or\n * an array, which is a fact about the data rather than a rendering preference, so a component\n * must not be able to override it (an `AForm` over a `noneOrMany` link would be handed an array\n * it cannot render). Component names encode both axes — `AFormLink`/`ATableLink` are the inline\n * pair, `AForm`/`ATable` the expanding pair — but only the inline/expand half is authoritative.\n *\n * @public\n */\nexport type LinkExpansion = 'inline' | 'expand'\n\n/**\n * Canonical link component → expansion. Only components Stonecrop ships with appear here; an\n * unmapped (custom) component has none, and callers treat that as `expand` — the behaviour that\n * predates this map, so a custom component can never silently collapse a link to a picker.\n * @public\n */\nexport const COMPONENT_LINK_EXPANSION: Record<string, LinkExpansion> = {\n\tAFormLink: 'inline',\n\tAForm: 'expand',\n\tATable: 'expand',\n}\n\n/**\n * Resolve a component's link expansion, or `undefined` for an absent/unmapped component.\n * @public\n */\nexport function componentLinkExpansion(component?: string): LinkExpansion | undefined {\n\treturn component ? COMPONENT_LINK_EXPANSION[component] : undefined\n}\n\n/**\n * How a link field renders.\n *\n * - `inline` — a scalar id-picker; the target is *not* expanded (the field keeps its own value\n * and carries a `doctype` prop for async display-text resolution and navigation).\n * - `record` — the target doctype is resolved and embedded as a nested form.\n * - `table` — the target doctype is resolved and embedded as a child table.\n *\n * @public\n */\nexport type LinkRenderMode = 'inline' | 'record' | 'table'\n\n/**\n * Decide how a *declared* link (one with a `LinkDeclaration`) renders.\n *\n * Two independent axes: the **component** picks inline vs expand, and when expanding the\n * **cardinality** picks record vs table (many → table). The declaration's component wins over the\n * field's, matching the precedence the resolver already uses for the rendered component.\n *\n * This is the single definition of \"does this link expand\" — it is consumed by both the client\n * resolver (which builds the nested schema) and the server column builder (which must still\n * SELECT an `inline` link's FK column). Call it; never re-derive the rule at the call site, or\n * the two will drift and the client will render a table for a column the server never selected.\n *\n * @param link - the link declaration (only `component` and `cardinality` are consulted)\n * @param fieldComponent - the linked field's own `component`, used when the declaration names none\n * @public\n */\nexport function resolveLinkRenderMode(\n\tlink: { component?: string; cardinality?: string },\n\tfieldComponent?: string\n): LinkRenderMode {\n\tif (componentLinkExpansion(link.component ?? fieldComponent) === 'inline') return 'inline'\n\treturn link.cardinality === 'noneOrMany' || link.cardinality === 'atLeastOne' ? 'table' : 'record'\n}\n\n/**\n * Every component Stonecrop ships with that can render a value field, sorted by name.\n *\n * The union of the two maps above is the definition, not a copy of it: a shipped component either\n * categorises a value ({@link COMPONENT_CATEGORY}) or is one of the link containers that has no\n * value of its own ({@link COMPONENT_LINK_EXPANSION}'s `AForm`/`ATable`). `AFieldset` is absent by\n * the same rule — it is a `kind: 'fieldset'` container, so it is never a value field's component.\n *\n * `component` is an **open** axis: any string is valid, and naming a custom component is how an app\n * renders a field Stonecrop ships no widget for. This list is therefore the set to *suggest* to an\n * author, and to check first-party data against — never a set to validate arbitrary input against.\n *\n * @public\n */\nexport const CANONICAL_COMPONENTS: readonly string[] = [\n\t...new Set([...Object.keys(COMPONENT_CATEGORY), ...Object.keys(COMPONENT_LINK_EXPANSION)]),\n].toSorted()\n"],"names":["COMPONENT_CATEGORY","componentCategory","component","COMPONENT_LINK_EXPANSION","componentLinkExpansion","resolveLinkRenderMode","link","fieldComponent","CANONICAL_COMPONENTS"],"mappings":";AAmBO,MAAMA,IAAwD;AAAA,EACpE,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,eAAe;AAAA,EACf,WAAW;AAAA,EACX,OAAO;AAAA,EACP,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,aAAa;AAAA,EACb,WAAW;AAAA,EACX,aAAa;AACd;AAOO,SAASC,EAAkBC,GAAmD;AACpF,SAAOA,IAAYF,EAAmBE,CAAS,IAAI;AACpD;AAsBO,MAAMC,IAA0D;AAAA,EACtE,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ;AACT;AAMO,SAASC,EAAuBF,GAA+C;AACrF,SAAOA,IAAYC,EAAyBD,CAAS,IAAI;AAC1D;AA8BO,SAASG,EACfC,GACAC,GACiB;AACjB,SAAIH,EAAuBE,EAAK,aAAaC,CAAc,MAAM,WAAiB,WAC3ED,EAAK,gBAAgB,gBAAgBA,EAAK,gBAAgB,eAAe,UAAU;AAC3F;AAgBO,MAAME,IAA0C;AAAA,EACtD,GAAG,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAKR,CAAkB,GAAG,GAAG,OAAO,KAAKG,CAAwB,CAAC,CAAC;AAC1F,EAAE,SAAA;"}