@atscript/typescript 0.1.27 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.cjs CHANGED
@@ -901,6 +901,17 @@ function mergeJsonSchemas(types) {
901
901
  if (prop.validator({ unknownProps: "ignore" }).validate(raw, true)) return { value: raw };
902
902
  return undefined;
903
903
  }
904
+ if (mode === "db") {
905
+ const dbValue = prop.metadata.get("db.default.value");
906
+ if (dbValue !== undefined) {
907
+ const parsed$1 = parseRawValue(dbValue, prop);
908
+ if (parsed$1 !== undefined && prop.validator({ unknownProps: "ignore" }).validate(parsed$1, true)) return { value: parsed$1 };
909
+ return undefined;
910
+ }
911
+ const dbFn = prop.metadata.get("db.default.fn");
912
+ if (dbFn !== undefined) return { value: dbFn };
913
+ return undefined;
914
+ }
904
915
  const metaKey = mode === "default" ? "meta.default" : "meta.example";
905
916
  const rawStr = prop.metadata.get(metaKey);
906
917
  if (rawStr === undefined) return undefined;
package/dist/utils.d.ts CHANGED
@@ -354,19 +354,21 @@ interface TCreateDataOptions {
354
354
  * - `'empty'` — structural defaults only (`''`, `0`, `false`, `[]`, `{}`); optional props skipped
355
355
  * - `'default'` — use `@meta.default` annotations; optional props skipped unless annotated
356
356
  * - `'example'` — use `@meta.example` annotations; optional props always included; arrays get one sample item
357
+ * - `'db'` — use `@db.default.value` (parsed) or `@db.default.fn` (returns fn name string); optional props skipped unless annotated
357
358
  * - `function` — custom resolver per field; optional props skipped unless resolver returns a value
358
359
  *
359
360
  * @default 'empty'
360
361
  */
361
- mode?: 'empty' | 'default' | 'example' | TValueResolver;
362
+ mode?: 'empty' | 'default' | 'example' | 'db' | TValueResolver;
362
363
  }
363
364
  /**
364
365
  * Creates a data object from an ATScript annotated type definition.
365
366
  *
366
- * Supports four modes:
367
+ * Supports five modes:
367
368
  * - `'empty'` — structural defaults only; optional props omitted
368
369
  * - `'default'` — uses `@meta.default` annotations; optional props omitted unless annotated
369
370
  * - `'example'` — uses `@meta.example` annotations; optional props always included; arrays get one sample item
371
+ * - `'db'` — uses `@db.default.value` (parsed) or `@db.default.fn` (fn name string); optional props omitted unless annotated
370
372
  * - `function` — custom resolver; optional props omitted unless resolver returns a value
371
373
  *
372
374
  * When a `@meta.default` / `@meta.example` value is set on a complex type (object, array)
package/dist/utils.mjs CHANGED
@@ -900,6 +900,17 @@ function mergeJsonSchemas(types) {
900
900
  if (prop.validator({ unknownProps: "ignore" }).validate(raw, true)) return { value: raw };
901
901
  return undefined;
902
902
  }
903
+ if (mode === "db") {
904
+ const dbValue = prop.metadata.get("db.default.value");
905
+ if (dbValue !== undefined) {
906
+ const parsed$1 = parseRawValue(dbValue, prop);
907
+ if (parsed$1 !== undefined && prop.validator({ unknownProps: "ignore" }).validate(parsed$1, true)) return { value: parsed$1 };
908
+ return undefined;
909
+ }
910
+ const dbFn = prop.metadata.get("db.default.fn");
911
+ if (dbFn !== undefined) return { value: dbFn };
912
+ return undefined;
913
+ }
903
914
  const metaKey = mode === "default" ? "meta.default" : "meta.example";
904
915
  const rawStr = prop.metadata.get(metaKey);
905
916
  if (rawStr === undefined) return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/typescript",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Atscript: typescript-gen support.",
5
5
  "keywords": [
6
6
  "annotations",
@@ -57,14 +57,14 @@
57
57
  "./package.json": "./package.json"
58
58
  },
59
59
  "dependencies": {
60
- "@moostjs/event-cli": "^0.6.0",
61
- "moost": "^0.6.0"
60
+ "@moostjs/event-cli": "^0.6.2",
61
+ "moost": "^0.6.2"
62
62
  },
63
63
  "devDependencies": {
64
64
  "vitest": "3.2.4"
65
65
  },
66
66
  "peerDependencies": {
67
- "@atscript/core": "^0.1.27"
67
+ "@atscript/core": "^0.1.29"
68
68
  },
69
69
  "build": [
70
70
  {},
@@ -15,7 +15,7 @@ Read the domain file that matches the task. Do not load all files — only what
15
15
  | ------------------------ | -------------------------------- | ------------------------------------------------------------------------------------------- |
16
16
  | Setup & configuration | [core.md](core.md) | Installing, configuring `atscript.config.ts`, using the `tsPlugin`, running the CLI |
17
17
  | `.as` file syntax | [syntax.md](syntax.md) | Writing `.as` files — interfaces, types, imports/exports, property syntax |
18
- | Annotations & primitives | [annotations.md](annotations.md) | Using built-in `@meta.*`/`@expect.*` annotations, defining custom annotations or primitives |
18
+ | Annotations & primitives | [annotations.md](annotations.md) | Using built-in `@meta.*`/`@expect.*`/`@ui.*`/`@db.*` annotations, defining custom annotations or primitives |
19
19
  | Code generation | [codegen.md](codegen.md) | Understanding what `.d.ts` and `.js` files are generated, `atscript.d.ts` global types |
20
20
  | Runtime type system | [runtime.md](runtime.md) | Reading/writing metadata, walking type definitions, understanding `TAtscriptAnnotatedType` |
21
21
  | Validation | [validation.md](validation.md) | Validating data, type guards, error handling, custom validator plugins |
@@ -9,16 +9,15 @@
9
9
  | Annotation | Arguments | Description |
10
10
  | --------------------- | -------------------------- | ------------------------------------------------------------------ |
11
11
  | `@meta.label` | `text: string` | Human-readable label for UI, logs, documentation |
12
- | `@meta.id` | `name?: string` (optional) | Mark field as unique identifier; optional custom name |
12
+ | `@meta.id` | _(none)_ | Mark field as unique identifier; multiple fields form composite PK |
13
13
  | `@meta.description` | `text: string` | Detailed description of a field or entity |
14
14
  | `@meta.documentation` | `text: string` | Multi-line docs (Markdown). Multiple allowed — each appends |
15
- | `@meta.placeholder` | `text: string` | Placeholder for UI input fields (props/types only) |
16
15
  | `@meta.sensitive` | _(none)_ | Mark as sensitive (passwords, API keys). Strips from serialization |
17
16
  | `@meta.readonly` | _(none)_ | Mark as read-only |
18
17
  | `@meta.required` | `message?: string` | Required field. Strings: non-whitespace. Booleans: must be `true` |
19
18
  | `@meta.default` | `value: string` | Default value (strings as-is, others parsed as JSON) |
20
19
  | `@meta.example` | `value: string` | Example value (strings as-is, others parsed as JSON) |
21
- | `@meta.isKey` | _(none)_ | Mark field as key inside array (string/number types only) |
20
+ | `@expect.array.key` | _(none)_ | Mark field as key inside array (string/number types only) |
22
21
 
23
22
  ### `@expect.*` — Validation Constraints
24
23
 
@@ -31,6 +30,24 @@
31
30
  | `@expect.int` | _(none)_ | number | Must be integer |
32
31
  | `@expect.pattern` | `pattern: string`, `flags?: string`, `message?: string` | string | Regex validation. **Multiple allowed** (all must pass) |
33
32
 
33
+ ### `@ui.*` — UI / Presentation Hints
34
+
35
+ | Annotation | Arguments | Description |
36
+ | ----------------- | ------------------------------ | ---------------------------------------------- |
37
+ | `@ui.placeholder` | `text: string` | Input placeholder text |
38
+ | `@ui.component` | `name: string` | UI component hint (`"select"`, `"datepicker"`) |
39
+ | `@ui.hidden` | _(none)_ | Hide from UI forms/tables |
40
+ | `@ui.group` | `name: string` | Group fields into form sections |
41
+ | `@ui.order` | `order: number` | Display order (lower = first) |
42
+ | `@ui.width` | `width: string` | Layout hint (`"half"`, `"full"`, `"third"`) |
43
+ | `@ui.icon` | `name: string` | Icon hint |
44
+ | `@ui.hint` | `text: string` | Help text / tooltip |
45
+ | `@ui.disabled` | _(none)_ | Non-interactive field |
46
+ | `@ui.type` | `type: string` | Input type (`"textarea"`, `"password"`, etc.) |
47
+ | `@ui.attr` | `key: string`, `value: string` | Arbitrary attribute (**multiple**, append) |
48
+ | `@ui.class` | `names: string` | CSS class names (**multiple**, append) |
49
+ | `@ui.style` | `css: string` | Inline CSS styles (**multiple**, append) |
50
+
34
51
  ### `@emit.*` — Build-time Directives
35
52
 
36
53
  | Annotation | Applies To | Description |
@@ -49,21 +66,21 @@ export default defineConfig({
49
66
  plugins: [tsPlugin()],
50
67
  annotations: {
51
68
  // Namespaced annotations use nested objects
52
- ui: {
53
- // @ui.component "DatePicker"
54
- component: new AnnotationSpec({
55
- argument: { name: 'name', type: 'string' },
56
- description: 'UI component to render this field',
69
+ grid: {
70
+ // @grid.column 200
71
+ column: new AnnotationSpec({
72
+ argument: { name: 'width', type: 'number' },
73
+ description: 'Table column width in data grid',
57
74
  }),
58
75
 
59
- // @ui.hidden (no arguments — boolean flag)
76
+ // @grid.hidden (no arguments — boolean flag)
60
77
  hidden: new AnnotationSpec({
61
- description: 'Hide this field in the UI',
78
+ description: 'Hide column in data grid',
62
79
  }),
63
80
 
64
- // @ui.order 5
65
- order: new AnnotationSpec({
66
- argument: { name: 'position', type: 'number' },
81
+ // @grid.sortable
82
+ sortable: new AnnotationSpec({
83
+ description: 'Allow sorting by this column',
67
84
  }),
68
85
  },
69
86