Skip to content

Commit 6b120f7

Browse files
authored
[codex] add auto increment sequence generator (#200)
* add auto increment sequence generator * reset generator state on spec import * avoid autoincrement key reuse after restore * correct autoincrement zero padding semantics * tighten autoincrement validation
1 parent 280ca67 commit 6b120f7

49 files changed

Lines changed: 1597 additions & 1375 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs-src/blog/2026-06-12-release-prep-combinatorial-grid-workflows.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,32 @@ Docs:
103103

104104
![Grid to enum schema in the app](/img/release-198/grid-to-enum-schema.png)
105105

106-
## 4. PICT-style inline enum definitions such as `Name: values`
106+
## 4. Constraint-aware auto-increment sequences for generated identifiers
107+
108+
Schemas can now generate sequential IDs through the domain model with `autoIncrement.sequence`.
109+
110+
Example:
111+
112+
```text
113+
Filename
114+
autoIncrement.sequence(start=1, step=5, prefix="filename", suffix=".txt", zeropadding=3)
115+
```
116+
117+
Generated values:
118+
119+
```text
120+
filename001.txt
121+
filename0006.txt
122+
filename011.txt
123+
```
124+
125+
This is especially useful for ticket IDs, filenames, and human-readable references because the sequence only advances when a row is accepted. If a generated row is rejected by constraints and retried, the skipped attempt does not consume the next number.
126+
127+
Docs:
128+
129+
- [Auto Increment Sequences](/docs/test-data/auto-increment-sequences)
130+
131+
## 5. PICT-style inline enum definitions such as `Name: values`
107132

108133
Schema text now fits more naturally with compact PICT-style authoring.
109134

@@ -128,7 +153,7 @@ Docs:
128153

129154
- [Schema Definition](/docs/test-data/Schema-Definition)
130155

131-
## 5. Import trimming controls for cleaner amend and import workflows
156+
## 6. Import trimming controls for cleaner amend and import workflows
132157

133158
Imported files and clipboard data can now be normalized during import.
134159

@@ -151,7 +176,7 @@ Docs:
151176

152177
![Import trim settings](/img/release-198/import-trim-settings.png)
153178

154-
## 6. File export settings for line endings and BOM
179+
## 7. File export settings for line endings and BOM
155180

156181
Downloads now support file transport settings without changing the preview text shown in the browser.
157182

@@ -168,7 +193,7 @@ Docs:
168193

169194
![Download encoding settings](/img/release-198/export-encoding-settings.png)
170195

171-
## 7. Right-click context menu in the main data grid
196+
## 8. Right-click context menu in the main data grid
172197

173198
The editable grid now has a right-click context menu for common grid actions.
174199

@@ -178,7 +203,7 @@ Docs:
178203

179204
- [Data Grid Editable](/docs/test-data/data-grid-editable)
180205

181-
## 8. Always-visible total row counts in the data grid
206+
## 9. Always-visible total row counts in the data grid
182207

183208
The main grid now shows total row counts, and filtered views also show how many rows remain visible.
184209

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
sidebar_position: 35
3+
title: "Auto Increment Sequences"
4+
description: "Generate sequential values that only advance when a row is accepted."
5+
---
6+
7+
# Auto Increment Sequences
8+
9+
`autoIncrement.sequence` generates a sequential value for each accepted row.
10+
11+
Unlike a plain counter that advances on every attempt, this sequence only advances when the row is kept. If a row is rejected by schema constraints and retried, the skipped attempt does not consume the next number.
12+
13+
## Basic Usage
14+
15+
```txt
16+
Id
17+
autoIncrement.sequence()
18+
```
19+
20+
Example output:
21+
22+
```txt
23+
1
24+
2
25+
3
26+
```
27+
28+
## Start and Step
29+
30+
```txt
31+
Build
32+
autoIncrement.sequence(start=10, step=5)
33+
```
34+
35+
Example output:
36+
37+
```txt
38+
10
39+
15
40+
20
41+
```
42+
43+
## Prefix, Suffix, and Zero Padding
44+
45+
```txt
46+
Filename
47+
autoIncrement.sequence(start=1, step=5, prefix="filename", suffix=".txt", zeropadding=3)
48+
```
49+
50+
Example output:
51+
52+
```txt
53+
filename001.txt
54+
filename006.txt
55+
filename011.txt
56+
```
57+
58+
`zeropadding=3` means the numeric portion is padded to a total width of three digits, so `1` becomes `001`, `100` stays `100`, and `1000` stays `1000`.
59+
60+
## Constraint-Aware Sequences
61+
62+
This command is especially useful when you generate rows under constraints.
63+
64+
```txt
65+
Ticket
66+
autoIncrement.sequence(prefix="T-", zeropadding=4)
67+
Priority
68+
enum(High,Low)
69+
Status
70+
enum(Open,Closed)
71+
72+
IF [Priority] = "High" THEN [Status] = "Open";
73+
```
74+
75+
If a generated row fails the constraint and is retried, the ticket sequence does not skip a value.
76+
77+
## Parameters
78+
79+
- `start`
80+
Starting integer. Defaults to `1`.
81+
- `step`
82+
Non-zero increment between accepted rows. Defaults to `1`.
83+
- `prefix`
84+
Optional text before the number.
85+
- `suffix`
86+
Optional text after the number.
87+
- `zeropadding`
88+
Optional integer padding amount. Defaults to `0`.
89+
90+
## See Also
91+
92+
- [Domain Test Data](/docs/test-data/domain/domain-test-data)
93+
- [Schema Definition](/docs/test-data/Schema-Definition)

docs-src/docs/040-test-data/domain/000-domain-test-data.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ For faker helper templates and utility functions, use faker helpers:
6464

6565
- [airline](/docs/test-data/domain/airline)
6666
- [animal](/docs/test-data/domain/animal)
67+
- [autoIncrement](/docs/test-data/domain/autoIncrement)
6768
- [book](/docs/test-data/domain/book)
6869
- [color](/docs/test-data/domain/color)
6970
- [commerce](/docs/test-data/domain/commerce)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
sidebar_position: 40
3+
title: "autoIncrement Domain"
4+
description: "Domain keyword reference for autoIncrement."
5+
---
6+
7+
# autoIncrement Domain
8+
9+
The `autoIncrement` domain provides stateful sequence helpers for accepted generated rows.
10+
11+
## Methods
12+
13+
### `autoIncrement.sequence`
14+
15+
Generates an incrementing sequence. Values only advance when a generated row is accepted, so constraint-filtered rows do not consume sequence numbers.
16+
17+
- Canonical: `awd.domain.autoIncrement.sequence`
18+
- Docs: [https://anywaydata.com/docs/test-data/auto-increment-sequences](https://anywaydata.com/docs/test-data/auto-increment-sequences)
19+
20+
| Arg | Type | Required | Description |
21+
| --- | --- | --- | --- |
22+
| `start` | `integer` | no | Starting integer in the sequence. Defaults to 1. |
23+
| `step` | `integer` | no | Amount added after each accepted row. Defaults to 1. |
24+
| `prefix` | `string` | no | Optional text added before the numeric portion. |
25+
| `suffix` | `string` | no | Optional text added after the numeric portion. |
26+
| `zeropadding` | `integer` | no | Total digit width for the numeric portion. A value of 3 renders 1 as 001, while 100 stays 100. Defaults to 0. |
27+
28+
Examples:
29+
30+
```txt
31+
autoIncrement.sequence()
32+
```
33+
34+
```txt
35+
autoIncrement.sequence(start=10, step=5)
36+
```
37+
38+
```txt
39+
autoIncrement.sequence(start=1, step=5, prefix="filename", suffix=".txt", zeropadding=3)
40+
```
41+
42+
Example return values:
43+
- `1`
44+
- `15`
45+
- `filename001.txt`

docs-src/docs/040-test-data/domain/040-book.md renamed to docs-src/docs/040-test-data/domain/050-book.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 40
2+
sidebar_position: 50
33
title: "book Domain"
44
description: "Domain keyword reference for book."
55
---

docs-src/docs/040-test-data/domain/050-color.md renamed to docs-src/docs/040-test-data/domain/060-color.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 50
2+
sidebar_position: 60
33
title: "color Domain"
44
description: "Domain keyword reference for color."
55
---

docs-src/docs/040-test-data/domain/060-commerce.md renamed to docs-src/docs/040-test-data/domain/070-commerce.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 60
2+
sidebar_position: 70
33
title: "commerce Domain"
44
description: "Domain keyword reference for commerce."
55
---

docs-src/docs/040-test-data/domain/070-company.md renamed to docs-src/docs/040-test-data/domain/080-company.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 70
2+
sidebar_position: 80
33
title: "company Domain"
44
description: "Domain keyword reference for company."
55
---

docs-src/docs/040-test-data/domain/080-database.md renamed to docs-src/docs/040-test-data/domain/090-database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 80
2+
sidebar_position: 90
33
title: "database Domain"
44
description: "Domain keyword reference for database."
55
---

docs-src/docs/040-test-data/domain/090-datatype.md renamed to docs-src/docs/040-test-data/domain/100-datatype.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 90
2+
sidebar_position: 100
33
title: "datatype Domain"
44
description: "Domain keyword reference for datatype."
55
---

0 commit comments

Comments
 (0)