simpler-forms 0.1.0-alpha.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 (76) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +111 -0
  3. package/dist/src/decorators/index.d.ts +4 -0
  4. package/dist/src/decorators/index.js +7 -0
  5. package/dist/src/decorators/index.js.map +1 -0
  6. package/dist/src/decorators/meta.d.ts +22 -0
  7. package/dist/src/decorators/meta.js +35 -0
  8. package/dist/src/decorators/meta.js.map +1 -0
  9. package/dist/src/decorators/shared.d.ts +49 -0
  10. package/dist/src/decorators/shared.js +149 -0
  11. package/dist/src/decorators/shared.js.map +1 -0
  12. package/dist/src/decorators/ui.d.ts +41 -0
  13. package/dist/src/decorators/ui.js +106 -0
  14. package/dist/src/decorators/ui.js.map +1 -0
  15. package/dist/src/decorators/validation.d.ts +25 -0
  16. package/dist/src/decorators/validation.js +91 -0
  17. package/dist/src/decorators/validation.js.map +1 -0
  18. package/dist/src/emitter.d.ts +15 -0
  19. package/dist/src/emitter.js +224 -0
  20. package/dist/src/emitter.js.map +1 -0
  21. package/dist/src/emitters/block-index.d.ts +4 -0
  22. package/dist/src/emitters/block-index.js +19 -0
  23. package/dist/src/emitters/block-index.js.map +1 -0
  24. package/dist/src/emitters/block-ui.d.ts +18 -0
  25. package/dist/src/emitters/block-ui.js +203 -0
  26. package/dist/src/emitters/block-ui.js.map +1 -0
  27. package/dist/src/emitters/field-occurrences.d.ts +18 -0
  28. package/dist/src/emitters/field-occurrences.js +237 -0
  29. package/dist/src/emitters/field-occurrences.js.map +1 -0
  30. package/dist/src/emitters/overlay.d.ts +16 -0
  31. package/dist/src/emitters/overlay.js +449 -0
  32. package/dist/src/emitters/overlay.js.map +1 -0
  33. package/dist/src/emitters/override-condition.d.ts +12 -0
  34. package/dist/src/emitters/override-condition.js +25 -0
  35. package/dist/src/emitters/override-condition.js.map +1 -0
  36. package/dist/src/index.d.ts +51 -0
  37. package/dist/src/index.js +55 -0
  38. package/dist/src/index.js.map +1 -0
  39. package/dist/src/lib.d.ts +361 -0
  40. package/dist/src/lib.js +194 -0
  41. package/dist/src/lib.js.map +1 -0
  42. package/dist/src/linter.d.ts +1 -0
  43. package/dist/src/linter.js +337 -0
  44. package/dist/src/linter.js.map +1 -0
  45. package/dist/src/model.d.ts +134 -0
  46. package/dist/src/model.js +203 -0
  47. package/dist/src/model.js.map +1 -0
  48. package/dist/src/public.d.ts +33 -0
  49. package/dist/src/public.js +40 -0
  50. package/dist/src/public.js.map +1 -0
  51. package/dist/src/validate.d.ts +15 -0
  52. package/dist/src/validate.js +737 -0
  53. package/dist/src/validate.js.map +1 -0
  54. package/lib/main.tsp +4 -0
  55. package/lib/meta.tsp +33 -0
  56. package/lib/types.tsp +134 -0
  57. package/lib/ui.tsp +78 -0
  58. package/lib/validation.tsp +134 -0
  59. package/package.json +54 -0
  60. package/src/decorators/index.ts +6 -0
  61. package/src/decorators/meta.ts +52 -0
  62. package/src/decorators/shared.ts +187 -0
  63. package/src/decorators/ui.ts +192 -0
  64. package/src/decorators/validation.ts +220 -0
  65. package/src/emitter.ts +272 -0
  66. package/src/emitters/block-index.ts +24 -0
  67. package/src/emitters/block-ui.ts +254 -0
  68. package/src/emitters/field-occurrences.ts +345 -0
  69. package/src/emitters/overlay.ts +596 -0
  70. package/src/emitters/override-condition.ts +37 -0
  71. package/src/index.ts +59 -0
  72. package/src/lib.ts +195 -0
  73. package/src/linter.ts +380 -0
  74. package/src/model.ts +400 -0
  75. package/src/public.ts +94 -0
  76. package/src/validate.ts +887 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Agile Six Applications, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # simpler-forms
2
+
3
+ A [TypeSpec](https://typespec.io) library for specifying grant application forms once and
4
+ emitting portable form artifacts — a JSON Schema for the data, a UI schema for the layout,
5
+ and an index describing how the two relate.
6
+
7
+ The library holds no form content and no vocabulary specific to any consuming application.
8
+ Form definitions, a shared question bank, and target-specific emitters live in the
9
+ repositories that consume this package.
10
+
11
+ ## Status
12
+
13
+ Pre-release, published from `main` as `simpler-forms`, unscoped.
14
+
15
+ Versions stay below 1.0 for now. release-please is configured with `bump-minor-pre-major`,
16
+ so a breaking change moves the minor — 0.1.0 to 0.2.0 — instead of jumping to 1.0.0. Read any
17
+ minor bump as potentially breaking until this section says otherwise.
18
+
19
+ The library name is passed to `createTypeSpecLibrary` as both `name` and `alias`, and it is
20
+ the alias that prefixes every diagnostic code and lint rule id. So a suppression in a form
21
+ specification reads:
22
+
23
+ ```tsp
24
+ #suppress "simpler-forms/no-orphan-question"
25
+ ```
26
+
27
+ Because that prefix comes from the alias and not from the package name, moving the package
28
+ into an npm scope later — `@agilesix/simpler-forms`, say — leaves every suppression already
29
+ written in a specification working. What such a move does change is the import specifier in a
30
+ consumer's specs and its dependency entry, one line each.
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ pnpm add -D simpler-forms @typespec/compiler @typespec/json-schema
36
+ ```
37
+
38
+ `@typespec/compiler` and `@typespec/json-schema` are peer dependencies, so a consumer
39
+ controls its own compiler version.
40
+
41
+ ## Develop
42
+
43
+ ```bash
44
+ pnpm install
45
+ pnpm build # required before anything else — see below
46
+ pnpm test
47
+ pnpm checks # format, lint, types, tests
48
+ ```
49
+
50
+ **Build before you type-check.** Each `lib/*.tsp` file imports `dist/src/index.js` to resolve
51
+ the `extern dec` declarations it makes, so the TypeSpec sources do not type-check until the
52
+ compiled JavaScript exists. This is why CI runs `pnpm build` ahead of `pnpm checks`, and why
53
+ a fresh clone reports unimplemented decorators until the first build.
54
+
55
+ ## Release
56
+
57
+ `main` is released by [release-please](https://github.com/googleapis/release-please). Pushing a
58
+ conventional commit opens or updates a release pull request; merging that pull request tags the
59
+ release and publishes the tarball to npm.
60
+
61
+ Publication authenticates through npm trusted publishing, so this repository holds no npm
62
+ token. The workflow exchanges a GitHub OIDC token for a short-lived credential, and npm
63
+ attaches a provenance attestation to the version it accepts. The trusted publisher is
64
+ configured against `.github/workflows/release.yml` by path, so renaming or moving that file
65
+ stops publication until the publisher is updated to match.
66
+
67
+ ## Layout
68
+
69
+ ```
70
+ lib/ TypeSpec declarations — the decorator vocabulary
71
+ main.tsp the entry point a consumer imports
72
+ meta.tsp @Meta.* — question, form, tag, role
73
+ ui.tsp @UI.* — labels, sections, widgets, overrides
74
+ validation.tsp @Validation.*
75
+ types.tsp shared scalars and enums
76
+ src/ the library implementation
77
+ public.ts the API a target emitter reads — the only semver-governed surface
78
+ decorators/ decorator entry points, one module per namespace
79
+ model.ts typed accessors over decorator state
80
+ validate.ts $onValidate — cross-cutting checks reported as diagnostics
81
+ linter.ts lint rules
82
+ emitter.ts $onEmit — writes the canonical artifacts
83
+ emitters/ one module per emitted artifact
84
+ lib.ts createTypeSpecLibrary — diagnostics, lint rules, emitter options
85
+ test/ vitest suites, driven by the compiler's createTester
86
+ ```
87
+
88
+ Only `src/public.ts` is public API. The decorator implementations, emitters and validators
89
+ are internal, and a target emitter reaching past that module depends on something that can
90
+ change in a patch.
91
+
92
+ ## Design notes
93
+
94
+ **Diagnostics are live in the editor.** `$onValidate` runs in the standard compile pipeline
95
+ before the linter and is not gated by `noEmit`, and the language server routes through that
96
+ same pipeline. A custom diagnostic therefore appears as a squiggle while an author types,
97
+ not only in CI.
98
+
99
+ **Where artifacts land is the consumer's decision.** The emitter writes to
100
+ `emitter-output-dir` in a stable layout of its own. It deliberately knows nothing about any
101
+ consuming application's directory conventions; installing artifacts into a particular tree is
102
+ a separate step owned by the consumer, so that a downstream layout change is not a breaking
103
+ change here.
104
+
105
+ **Target vocabulary belongs downstream.** A consuming application's own decorators, state,
106
+ validation and emitted files are contributed by its own TypeSpec library listed alongside
107
+ this one in `tspconfig.yaml`, rather than by a plugin interface here.
108
+
109
+ ## License
110
+
111
+ [MIT](./LICENSE.md). Copyright (c) 2026 Agile Six Applications, Inc.
@@ -0,0 +1,4 @@
1
+ export { blockSchemaRef } from "./shared.js";
2
+ export * from "./meta.js";
3
+ export * from "./ui.js";
4
+ export * from "./validation.js";
@@ -0,0 +1,7 @@
1
+ // One module per TypeSpec namespace, mirroring lib/<name>.tsp. Marshalling helpers
2
+ // shared by more than one namespace live in ./shared.ts.
3
+ export { blockSchemaRef } from "./shared.js";
4
+ export * from "./meta.js";
5
+ export * from "./ui.js";
6
+ export * from "./validation.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,yDAAyD;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { Model, ModelProperty, Scalar } from "@typespec/compiler";
2
+ import { type Ctx } from "./shared.js";
3
+ /**
4
+ * `@Meta.question`: the question's stable identity, the entity it is asked about, and
5
+ * its classification. Also establishes the JSON Schema `$id`, so this is what makes a
6
+ * model a question rather than an ordinary model.
7
+ */
8
+ export declare const $question: (ctx: Ctx, target: Model | Scalar, meta: unknown) => void;
9
+ /** `@Meta.form`: the form's identity and the provenance of the paper form it mirrors. */
10
+ export declare const $form: (ctx: Ctx, target: Model, meta: unknown) => void;
11
+ /**
12
+ * `@Meta.tag`: catalogue markers. Unlike the entity, a tag also applies to a bare
13
+ * constrained scalar with no question identity, so it stays a decorator of its own
14
+ * rather than a field of the question meta.
15
+ */
16
+ export declare const $tag: (ctx: Ctx, target: Model | Scalar, ...tags: unknown[]) => void;
17
+ /**
18
+ * `@Meta.role`: why a field exists in a response -- applicant input, calculated output,
19
+ * a value a platform supplies, a technical field, an attestation, or static content.
20
+ * Resolved by inheritance at emission, so a form can override a shared question's role.
21
+ */
22
+ export declare const $role: (ctx: Ctx, target: Model | Scalar | ModelProperty, role: unknown) => void;
@@ -0,0 +1,35 @@
1
+ import { stateKeys } from "../lib.js";
2
+ import { enumName, plain, publishAs, set } from "./shared.js";
3
+ /**
4
+ * `@Meta.question`: the question's stable identity, the entity it is asked about, and
5
+ * its classification. Also establishes the JSON Schema `$id`, so this is what makes a
6
+ * model a question rather than an ordinary model.
7
+ */
8
+ export const $question = (ctx, target, meta) => {
9
+ const m = plain(ctx, meta);
10
+ if (m.entity !== undefined)
11
+ m.entity = enumName(m.entity);
12
+ if (m.classification !== undefined)
13
+ m.classification = enumName(m.classification);
14
+ set(ctx, stateKeys.questionMeta, target, m);
15
+ publishAs(ctx, target, m.id);
16
+ };
17
+ /** `@Meta.form`: the form's identity and the provenance of the paper form it mirrors. */
18
+ export const $form = (ctx, target, meta) => {
19
+ const m = plain(ctx, meta);
20
+ set(ctx, stateKeys.formMeta, target, m);
21
+ publishAs(ctx, target, m.id);
22
+ };
23
+ /**
24
+ * `@Meta.tag`: catalogue markers. Unlike the entity, a tag also applies to a bare
25
+ * constrained scalar with no question identity, so it stays a decorator of its own
26
+ * rather than a field of the question meta.
27
+ */
28
+ export const $tag = (ctx, target, ...tags) => set(ctx, stateKeys.tags, target, tags.map((t) => enumName(t)));
29
+ /**
30
+ * `@Meta.role`: why a field exists in a response -- applicant input, calculated output,
31
+ * a value a platform supplies, a technical field, an attestation, or static content.
32
+ * Resolved by inheritance at emission, so a form can override a shared question's role.
33
+ */
34
+ export const $role = (ctx, target, role) => set(ctx, stateKeys.responseRole, target, enumName(role));
35
+ //# sourceMappingURL=meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/decorators/meta.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAY,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAQ,EAAE,MAAsB,EAAE,IAAa,EAAE,EAAE;IAC3E,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,CAIxB,CAAC;IACF,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS;QAAE,CAAC,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC1D,IAAI,CAAC,CAAC,cAAc,KAAK,SAAS;QAChC,CAAC,CAAC,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IAChD,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC5C,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,yFAAyF;AACzF,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAQ,EAAE,MAAa,EAAE,IAAa,EAAE,EAAE;IAC9D,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,CAAmB,CAAC;IAC7C,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACxC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAQ,EAAE,MAAsB,EAAE,GAAG,IAAe,EAAE,EAAE,CAC3E,GAAG,CACD,GAAG,EACH,SAAS,CAAC,IAAI,EACd,MAAM,EACN,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAC7B,CAAC;AAEJ;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,GAAQ,EACR,MAAsC,EACtC,IAAa,EACb,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { DecoratorContext, Model, ModelProperty, Scalar, Type } from "@typespec/compiler";
2
+ export type Ctx = DecoratorContext;
3
+ /**
4
+ * `valueof <Model>` arrives as a TypeSpec ObjectValue with parent back-references,
5
+ * so it cannot be serialized directly. Convert to plain JS at the boundary.
6
+ */
7
+ export declare function plain(ctx: DecoratorContext, value: unknown): unknown;
8
+ export declare function resolvedArgumentProperty(ctx: Ctx, index: number): ModelProperty | undefined;
9
+ /** Store a single value keyed by target. */
10
+ export declare function set(ctx: Ctx, key: symbol, target: Type, value: unknown): void;
11
+ /** Append to a list keyed by target. */
12
+ export declare function push(ctx: Ctx, key: symbol, target: Type, value: unknown): void;
13
+ /**
14
+ * A block's `$id`, relative to the bank's base URI. The base is declared once with
15
+ * `@jsonSchema("<base>")` on the bank namespace, so it is a publishing decision in
16
+ * the specs rather than a constant in this library.
17
+ */
18
+ export declare const blockSchemaRef: (id: string) => string;
19
+ /**
20
+ * Delegate to the stock JSON Schema library, which resolves this relative id
21
+ * against the namespace base and uses it for both `$id` and every `$ref` target.
22
+ */
23
+ export declare function publishAs(ctx: Ctx, target: Model | Scalar, id: string): void;
24
+ /** Peel one layer of TypeSpec value wrapping. */
25
+ export declare function unwrap(v: unknown): unknown;
26
+ /** An enum member argument arrives as the member; take its name. */
27
+ export declare function enumName(v: unknown): string;
28
+ /**
29
+ * Resolve a decorator argument to a plain JSON literal. Enum members yield their
30
+ * wire value, so a comparison in an emitted schema is a string rather than a
31
+ * compiler object with parent back-references.
32
+ */
33
+ export declare function literal(v: unknown): string | number | boolean | null;
34
+ /**
35
+ * `source` is a ModelProperty passed as `Model.prop` at the call site. It is reduced
36
+ * to plain data here so no emitter ever handles a compiler object.
37
+ */
38
+ export declare function condition(source: ModelProperty, equals: unknown): {
39
+ operator: "equals";
40
+ sourcePath: string[];
41
+ sourceIsArray: boolean;
42
+ value: string | number | boolean | null;
43
+ };
44
+ export declare function countCondition(ctx: Ctx, target: ModelProperty, source: ModelProperty, minimum: number): {
45
+ operator: "countAtLeast";
46
+ sourcePath: string[];
47
+ sourceIsArray: boolean;
48
+ minimum: number;
49
+ } | undefined;
@@ -0,0 +1,149 @@
1
+ import { isArrayModelType, serializeValueAsJson } from "@typespec/compiler";
2
+ import { $id as $jsonSchemaId } from "@typespec/json-schema";
3
+ import { reportDiagnostic } from "../lib.js";
4
+ import { rememberConditionSourceModel } from "../model.js";
5
+ /**
6
+ * `valueof <Model>` arrives as a TypeSpec ObjectValue with parent back-references,
7
+ * so it cannot be serialized directly. Convert to plain JS at the boundary.
8
+ */
9
+ export function plain(ctx, value) {
10
+ const v = value;
11
+ if (v &&
12
+ typeof v === "object" &&
13
+ "entityKind" in v &&
14
+ v.entityKind === "Value") {
15
+ return serializeValueAsJson(ctx.program, v, v.type);
16
+ }
17
+ return value;
18
+ }
19
+ export function resolvedArgumentProperty(ctx, index) {
20
+ const target = ctx.getArgumentTarget(index);
21
+ if (!target || target.entityKind)
22
+ return undefined;
23
+ const node = target;
24
+ const resolved = ctx.program.checker.getTypeForNode(node);
25
+ return resolved.kind === "ModelProperty" ? resolved : undefined;
26
+ }
27
+ /** Store a single value keyed by target. */
28
+ export function set(ctx, key, target, value) {
29
+ ctx.program.stateMap(key).set(target, value);
30
+ }
31
+ /** Append to a list keyed by target. */
32
+ export function push(ctx, key, target, value) {
33
+ const map = ctx.program.stateMap(key);
34
+ const existing = map.get(target) ?? [];
35
+ existing.push(value);
36
+ map.set(target, existing);
37
+ }
38
+ // --- identity -------------------------------------------------------------
39
+ /**
40
+ * A block's `$id`, relative to the bank's base URI. The base is declared once with
41
+ * `@jsonSchema("<base>")` on the bank namespace, so it is a publishing decision in
42
+ * the specs rather than a constant in this library.
43
+ */
44
+ export const blockSchemaRef = (id) => `${id}/schema.json`;
45
+ /**
46
+ * Delegate to the stock JSON Schema library, which resolves this relative id
47
+ * against the namespace base and uses it for both `$id` and every `$ref` target.
48
+ */
49
+ export function publishAs(ctx, target, id) {
50
+ $jsonSchemaId(ctx, target, blockSchemaRef(id));
51
+ }
52
+ // --- value marshalling ----------------------------------------------------
53
+ /** Peel one layer of TypeSpec value wrapping. */
54
+ export function unwrap(v) {
55
+ const o = v;
56
+ if (o &&
57
+ typeof o === "object" &&
58
+ "entityKind" in o &&
59
+ o.entityKind === "Value" &&
60
+ "value" in o) {
61
+ return o.value;
62
+ }
63
+ return v;
64
+ }
65
+ /** An enum member argument arrives as the member; take its name. */
66
+ export function enumName(v) {
67
+ const m = unwrap(v);
68
+ if (m && typeof m === "object" && "name" in m)
69
+ return String(m.name);
70
+ return String(m);
71
+ }
72
+ /**
73
+ * Resolve a decorator argument to a plain JSON literal. Enum members yield their
74
+ * wire value, so a comparison in an emitted schema is a string rather than a
75
+ * compiler object with parent back-references.
76
+ */
77
+ export function literal(v) {
78
+ const u = unwrap(v);
79
+ if (u === null || u === undefined)
80
+ return null;
81
+ if (typeof u !== "object")
82
+ return u;
83
+ if (u.kind === "EnumMember" || ("name" in u && "enum" in u)) {
84
+ return (u.value ?? u.name);
85
+ }
86
+ if ("value" in u)
87
+ return literal(u.value);
88
+ if ("name" in u)
89
+ return String(u.name);
90
+ return String(u);
91
+ }
92
+ // --- conditions -----------------------------------------------------------
93
+ // Shared by UI (visibleWhen, enabledWhen, readOnlyWhen) and Validation
94
+ // (requiredWhen, constraintsWhen), so neither namespace owns them.
95
+ /**
96
+ * `source` is a ModelProperty passed as `Model.prop` at the call site. It is reduced
97
+ * to plain data here so no emitter ever handles a compiler object.
98
+ */
99
+ export function condition(source, equals) {
100
+ const t = source.type;
101
+ return {
102
+ operator: "equals",
103
+ sourcePath: [source.name],
104
+ sourceIsArray: t?.kind === "Model" && !!t.indexer,
105
+ value: literal(equals),
106
+ };
107
+ }
108
+ export function countCondition(ctx, target, source, minimum) {
109
+ let valid = true;
110
+ const resolvedSource = resolvedArgumentProperty(ctx, 0) ?? source;
111
+ if (resolvedSource.model &&
112
+ target.model &&
113
+ resolvedSource.model !== target.model) {
114
+ reportDiagnostic(ctx.program, {
115
+ code: "condition-source-not-sibling",
116
+ target,
117
+ format: { source: resolvedSource.name, target: target.name },
118
+ });
119
+ valid = false;
120
+ }
121
+ if (source.type.kind !== "Model" || !isArrayModelType(source.type)) {
122
+ reportDiagnostic(ctx.program, {
123
+ code: "condition-count-source-not-array",
124
+ target,
125
+ format: { source: source.name },
126
+ });
127
+ valid = false;
128
+ }
129
+ const normalizedMinimum = Number(literal(minimum));
130
+ if (!Number.isInteger(normalizedMinimum) || normalizedMinimum <= 0) {
131
+ reportDiagnostic(ctx.program, {
132
+ code: "condition-count-minimum-invalid",
133
+ target,
134
+ format: { minimum: String(normalizedMinimum) },
135
+ });
136
+ valid = false;
137
+ }
138
+ if (!valid)
139
+ return undefined;
140
+ const result = {
141
+ operator: "countAtLeast",
142
+ sourcePath: [source.name],
143
+ sourceIsArray: true,
144
+ minimum: normalizedMinimum,
145
+ };
146
+ rememberConditionSourceModel(result, resolvedSource.model);
147
+ return result;
148
+ }
149
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/decorators/shared.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,GAAG,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAI3D;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,GAAqB,EAAE,KAAc;IACzD,MAAM,CAAC,GAAG,KAAc,CAAC;IACzB,IACE,CAAC;QACD,OAAO,CAAC,KAAK,QAAQ;QACrB,YAAY,IAAI,CAAC;QAChB,CAAS,CAAC,UAAU,KAAK,OAAO,EACjC,CAAC;QACD,OAAO,oBAAoB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,EAAG,CAAS,CAAC,IAAI,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,GAAQ,EACR,KAAa;IAEb,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC5C,IAAI,CAAC,MAAM,IAAK,MAAc,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAC5D,MAAM,IAAI,GAAG,MAET,CAAC;IACL,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC1D,OAAO,QAAQ,CAAC,IAAI,KAAK,e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EAAE,iCAAiC;YACvC,MAAM;YACN,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,iBAAiB,CAAC,EAAE;SAC/C,CAAC,CAAC;QACH,KAAK,GAAG,KAAK,CAAC;IAChB,CAAC;IACD,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,MAAM,GAAG;QACb,QAAQ,EAAE,cAAuB;QACjC,UAAU,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;QACzB,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE,iBAAiB;KAC3B,CAAC;IACF,4BAA4B,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3D,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { Enum, Model, ModelProperty, Scalar } from "@typespec/compiler";
2
+ import { type Ctx } from "./shared.js";
3
+ export declare const $sections: (ctx: Ctx, target: Model, sections: Enum) => void;
4
+ /**
5
+ * `valueof EnumMember` arrives as a value, not the member type, so resolve the
6
+ * member's name and label here rather than in the emitters.
7
+ */
8
+ export declare const $section: (ctx: Ctx, target: ModelProperty, section: unknown) => void;
9
+ export declare function sectionRef(v: unknown): {
10
+ name: string;
11
+ label?: string;
12
+ };
13
+ export declare const $overrides: (ctx: Ctx, target: Model | ModelProperty, patch: unknown) => void;
14
+ /**
15
+ * A field label. Also delegated to `@summary`, which the JSON Schema emitter maps to
16
+ * `title` -- so the canonical schema carries the label without this library emitting
17
+ * any schema keyword itself.
18
+ */
19
+ export declare const $label: (ctx: Ctx, target: Model | Scalar | ModelProperty, text: string) => void;
20
+ /**
21
+ * Secondary guidance shown with the field. Distinct from the doc comment, which is the
22
+ * question's own description: help text is what a form says *about asking it here*.
23
+ */
24
+ export declare const $helpText: (ctx: Ctx, target: ModelProperty, text: string) => void;
25
+ export declare const $widget: (ctx: Ctx, target: ModelProperty, widget: unknown) => void;
26
+ export declare const $encodedCheckboxGroup: (ctx: Ctx, target: ModelProperty, contract: unknown) => void;
27
+ export declare const $order: (ctx: Ctx, target: Model, ...props: ModelProperty[]) => void;
28
+ export declare const $omit: (ctx: Ctx, target: ModelProperty) => void;
29
+ export declare const $readOnly: (ctx: Ctx, target: ModelProperty) => void;
30
+ export declare const $visibleWhen: (ctx: Ctx, target: ModelProperty, source: ModelProperty, equals: unknown) => void;
31
+ export declare const $enabledWhen: (ctx: Ctx, target: ModelProperty, source: ModelProperty, equals: unknown) => void;
32
+ export declare const $enabledWhenAny: (ctx: Ctx, target: ModelProperty, source: ModelProperty, ...equals: unknown[]) => void;
33
+ export declare const $enabledWhenCount: (ctx: Ctx, target: ModelProperty, source: ModelProperty, minimum: number) => void;
34
+ /**
35
+ * Enable a field once a sibling list reaches capacity, while keeping an already-saved
36
+ * value operable if the list later falls below that threshold. This is the narrow
37
+ * disjunction needed by overflow attachment controls; it deliberately does not expose
38
+ * an arbitrary expression AST.
39
+ */
40
+ export declare const $enabledWhenCountOrPresent: (ctx: Ctx, target: ModelProperty, source: ModelProperty, minimum: number) => void;
41
+ export declare const $readOnlyWhen: (ctx: Ctx, target: ModelProperty, source: ModelProperty, equals: unknown) => void;
@@ -0,0 +1,106 @@
1
+ import { $summary } from "@typespec/compiler";
2
+ import { stateKeys } from "../lib.js";
3
+ import { condition, countCondition, enumName, literal, plain, push, set, } from "./shared.js";
4
+ // --- sections -------------------------------------------------------------
5
+ export const $sections = (ctx, target, sections) => set(ctx, stateKeys.sections, target, sections);
6
+ /**
7
+ * `valueof EnumMember` arrives as a value, not the member type, so resolve the
8
+ * member's name and label here rather than in the emitters.
9
+ */
10
+ export const $section = (ctx, target, section) => set(ctx, stateKeys.section, target, sectionRef(section));
11
+ export function sectionRef(v) {
12
+ const m = v;
13
+ if (m && typeof m === "object") {
14
+ if (m.name)
15
+ return {
16
+ name: String(m.name),
17
+ label: m.value ? String(m.value) : undefined,
18
+ };
19
+ if (m.value?.name) {
20
+ return {
21
+ name: String(m.value.name),
22
+ label: m.value.value ? String(m.value.value) : undefined,
23
+ };
24
+ }
25
+ }
26
+ return { name: String(v) };
27
+ }
28
+ // --- form-scoped overrides ------------------------------------------------
29
+ function overridePlain(value) {
30
+ const candidate = value;
31
+ if (candidate &&
32
+ typeof candidate === "object" &&
33
+ candidate.entityKind === "Value") {
34
+ return literal(candidate);
35
+ }
36
+ if (Array.isArray(value))
37
+ return value.map(overridePlain);
38
+ if (value && typeof value === "object") {
39
+ return Object.fromEntries(Object.entries(value).map(([key, nested]) => [
40
+ key,
41
+ overridePlain(nested),
42
+ ]));
43
+ }
44
+ return value;
45
+ }
46
+ export const $overrides = (ctx, target, patch) => set(ctx, stateKeys.overrides, target, overridePlain(plain(ctx, patch)));
47
+ // --- presentation ---------------------------------------------------------
48
+ /**
49
+ * A field label. Also delegated to `@summary`, which the JSON Schema emitter maps to
50
+ * `title` -- so the canonical schema carries the label without this library emitting
51
+ * any schema keyword itself.
52
+ */
53
+ export const $label = (ctx, target, text) => {
54
+ set(ctx, stateKeys.label, target, text);
55
+ $summary(ctx, target, text);
56
+ };
57
+ /**
58
+ * Secondary guidance shown with the field. Distinct from the doc comment, which is the
59
+ * question's own description: help text is what a form says *about asking it here*.
60
+ */
61
+ export const $helpText = (ctx, target, text) => set(ctx, stateKeys.helpText, target, text);
62
+ export const $widget = (ctx, target, widget) => set(ctx, stateKeys.widget, target, enumName(widget));
63
+ export const $encodedCheckboxGroup = (ctx, target, contract) => {
64
+ set(ctx, stateKeys.widget, target, "EncodedCheckboxGroup");
65
+ set(ctx, stateKeys.encodedCheckboxGroup, target, plain(ctx, contract));
66
+ };
67
+ export const $order = (ctx, target, ...props) => set(ctx, stateKeys.order, target, props.map((p) => p.name));
68
+ export const $omit = (ctx, target) => set(ctx, stateKeys.omit, target, true);
69
+ export const $readOnly = (ctx, target) => set(ctx, stateKeys.readOnly, target, true);
70
+ // --- conditional behavior -------------------------------------------------
71
+ export const $visibleWhen = (ctx, target, source, equals) => push(ctx, stateKeys.visibleWhen, target, condition(source, equals));
72
+ export const $enabledWhen = (ctx, target, source, equals) => push(ctx, stateKeys.enabledWhen, target, condition(source, equals));
73
+ export const $enabledWhenAny = (ctx, target, source, ...equals) => {
74
+ const base = condition(source, null);
75
+ push(ctx, stateKeys.enabledWhen, target, {
76
+ operator: "in",
77
+ sourcePath: base.sourcePath,
78
+ sourceIsArray: base.sourceIsArray,
79
+ values: equals.map(literal),
80
+ });
81
+ };
82
+ export const $enabledWhenCount = (ctx, target, source, minimum) => {
83
+ const count = countCondition(ctx, target, source, minimum);
84
+ if (count)
85
+ push(ctx, stateKeys.enabledWhen, target, count);
86
+ };
87
+ /**
88
+ * Enable a field once a sibling list reaches capacity, while keeping an already-saved
89
+ * value operable if the list later falls below that threshold. This is the narrow
90
+ * disjunction needed by overflow attachment controls; it deliberately does not expose
91
+ * an arbitrary expression AST.
92
+ */
93
+ export const $enabledWhenCountOrPresent = (ctx, target, source, minimum) => {
94
+ const count = countCondition(ctx, target, source, minimum);
95
+ if (!count)
96
+ return;
97
+ push(ctx, stateKeys.enabledWhen, target, {
98
+ operator: "any",
99
+ predicates: [
100
+ count,
101
+ { operator: "present", sourcePath: [target.name], sourceIsArray: false },
102
+ ],
103
+ });
104
+ };
105
+ export const $readOnlyWhen = (ctx, target, source, equals) => push(ctx, stateKeys.readOnlyWhen, target, condition(source, equals));
106
+ //# sourceMappingURL=ui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/decorators/ui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAEL,SAAS,EACT,cAAc,EACd,QAAQ,EACR,OAAO,EACP,KAAK,EACL,IAAI,EACJ,GAAG,GACJ,MAAM,aAAa,CAAC;AAErB,6EAA6E;AAE7E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAQ,EAAE,MAAa,EAA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,CAAC,WAAW,EAAE,MAAM,EAAE;QACvC,QAAQ,EAAE,KAAK;QACf,UAAU,EAAE;YACV,KAAK;YACL,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE;SACzE;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,GAAQ,EACR,MAAqB,EACrB,MAAqB,EACrB,MAAe,EACf,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { Model, ModelProperty } from "@typespec/compiler";
2
+ import { type Ctx } from "./shared.js";
3
+ export declare const $validationConstraints: (ctx: Ctx, target: ModelProperty, patch: unknown) => void;
4
+ export declare const $exclusiveValues: (ctx: Ctx, target: ModelProperty, ...values: unknown[]) => void;
5
+ export declare const $validationConstraintsWhen: (ctx: Ctx, target: ModelProperty, source: ModelProperty, equals: unknown, patch: unknown) => void;
6
+ export declare const $requiredWhen: (ctx: Ctx, target: ModelProperty, source: ModelProperty, equals: unknown) => void;
7
+ export declare const $requiredWhenPath: (ctx: Ctx, target: ModelProperty, sourcePath: unknown, equals: unknown) => void;
8
+ export declare const $requiredPaths: (ctx: Ctx, target: Model | ModelProperty, ...paths: unknown[]) => void;
9
+ export declare const $requiredPathWhen: (ctx: Ctx, target: Model | ModelProperty, targetPath: unknown, sourcePath: unknown, equals: unknown) => void;
10
+ /** Record a bounded conditional choice over descendant paths. */
11
+ export declare const $atLeastOnePathWhenPresent: (ctx: Ctx, target: Model | ModelProperty, sourcePath: unknown, ...targetPaths: unknown[]) => void;
12
+ /** Record a portable JSON Schema any-of-required constraint on sibling properties. */
13
+ export declare const $atLeastOneOf: (ctx: Ctx, target: Model, ...properties: ModelProperty[]) => void;
14
+ export declare const $notBefore: (ctx: Ctx, target: ModelProperty, source: ModelProperty) => void;
15
+ export declare const $requiredPathWhenPositiveDecimalString: (ctx: Ctx, target: Model | ModelProperty, targetPath: unknown, sourcePath: unknown) => void;
16
+ export declare const $positiveDecimalStringWhenPathPresent: (ctx: Ctx, target: Model | ModelProperty, targetPath: unknown, sourcePath: unknown) => void;
17
+ export declare const $computed: (ctx: Ctx, target: ModelProperty, operator: unknown, ...refs: ModelProperty[]) => void;
18
+ export declare const $computedFrom: (ctx: Ctx, target: ModelProperty, operator: unknown, ...paths: unknown[]) => void;
19
+ export declare const $materializeWhenAnySourcePresent: (ctx: Ctx, target: ModelProperty) => void;
20
+ export declare const $evaluationOrder: (ctx: Ctx, target: ModelProperty, order: number) => void;
21
+ /**
22
+ * Field-by-field totalling. Only the source properties are recorded; which field of the
23
+ * block pairs with which is worked out at emission, where the type graph is in view.
24
+ */
25
+ export declare const $totals: (ctx: Ctx, target: ModelProperty, ...sources: ModelProperty[]) => void;