@auto-engineer/id 1.147.0 → 1.149.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.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +3 -3
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +45 -0
- package/README.md +44 -41
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @auto-engineer/id@1.
|
|
2
|
+
> @auto-engineer/id@1.148.0 test /home/runner/work/auto-engineer/auto-engineer/packages/id
|
|
3
3
|
> vitest run --reporter=dot
|
|
4
4
|
|
|
5
5
|
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
11
11
|
[2m Tests [22m [1m[32m2 passed[39m[22m[90m (2)[39m
|
|
12
|
-
[2m Start at [22m
|
|
13
|
-
[2m Duration [22m
|
|
12
|
+
[2m Start at [22m 07:22:24
|
|
13
|
+
[2m Duration [22m 2.06s[2m (transform 371ms, setup 0ms, collect 362ms, tests 26ms, environment 0ms, prepare 600ms)[22m
|
|
14
14
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @auto-engineer/id
|
|
2
2
|
|
|
3
|
+
## 1.149.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`e1eebbd`](https://github.com/BeOnAuto/auto-engineer/commit/e1eebbdf4f209780e790094d2e6887c4fa809f98) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: add Given state ref hints to state.ts.ejs
|
|
8
|
+
- **server-generator-apollo-emmett**: context-aware nonCommandField instructions
|
|
9
|
+
- **server-generator-apollo-emmett**: add state context instruction
|
|
10
|
+
- **server-generator-apollo-emmett**: extract shared template helpers
|
|
11
|
+
- **server-generator-apollo-emmett**: filter state refs from hasGivenEvents in decide.ts.ejs
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`d38c81e`](https://github.com/BeOnAuto/auto-engineer/commit/d38c81e7bb442a39626564cf4f6d8d55b60d0a38) Thanks [@SamHatoum](https://github.com/SamHatoum)! -
|
|
16
|
+
|
|
17
|
+
## 1.148.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- [`d5ba3a0`](https://github.com/BeOnAuto/auto-engineer/commit/d5ba3a0e3fb0f6a9ad7a3a8b1815590ea77a5b42) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added state context instruction to generated decide handlers, preventing unnecessary narrowing when Given steps contain only state references
|
|
22
|
+
|
|
23
|
+
- [`e0cdc4e`](https://github.com/BeOnAuto/auto-engineer/commit/e0cdc4e3363ad84d4bc49996a600ac75c97ccc38) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added context-aware classification of non-command fields in generated decide.ts scaffolds, distinguishing between date-derived, state-derived, and not-yet-tested fields
|
|
24
|
+
|
|
25
|
+
- [`9195db7`](https://github.com/BeOnAuto/auto-engineer/commit/9195db78cb707d658866cee99a1c73d34fb4efde) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Extracted shared template helpers into a dedicated module for cleaner code generation
|
|
26
|
+
|
|
27
|
+
- [`abb6540`](https://github.com/BeOnAuto/auto-engineer/commit/abb6540db7196ed7935c8a8610695828f9035fc3) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added status variant hints from Given state references to the state template, helping implementers create matching discriminated union variants
|
|
28
|
+
|
|
29
|
+
- [`9195db7`](https://github.com/BeOnAuto/auto-engineer/commit/9195db78cb707d658866cee99a1c73d34fb4efde) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Extracted shared template helper functions into a dedicated module for better code reuse across generators
|
|
30
|
+
- Simplified template specs by removing inline duplicate definitions in favor of the shared helpers
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [`88fb1da`](https://github.com/BeOnAuto/auto-engineer/commit/88fb1da2b222de04dd4959d87657395ee960a6ce) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: skip empty file plans in scaffold output
|
|
35
|
+
- **server-generator-apollo-emmett**: filter state refs from given() in decide.specs.ts.ejs
|
|
36
|
+
- **server-generator-apollo-emmett**: move CS Given states from events to states array
|
|
37
|
+
- **global**: version packages
|
|
38
|
+
- **server-generator-apollo-emmett**: mark G1+G2 ketchup plan complete
|
|
39
|
+
|
|
40
|
+
- [`4255f6d`](https://github.com/BeOnAuto/auto-engineer/commit/4255f6db0d128979e573244a615886482ce799b0) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Updated ketchup plan for state reference fix in decide template generator
|
|
41
|
+
- Marked generator bug fix milestones G1 and G2 as complete
|
|
42
|
+
|
|
43
|
+
- [`62f1ea3`](https://github.com/BeOnAuto/auto-engineer/commit/62f1ea3dd1b4275211574e3df9d9a6571ae9b27a) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Fixed scaffold generation to correctly distinguish between event and state references in decision handlers
|
|
44
|
+
- Prevented contradictory instructions from appearing in generated code when Given clauses contain only state references
|
|
45
|
+
|
|
46
|
+
- [`ba4f5c9`](https://github.com/BeOnAuto/auto-engineer/commit/ba4f5c9749fb1c15d444e78ca9a2689817f039cb) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added implementation plan for decide.ts code generation fixes in the Apollo Emmett server generator
|
|
47
|
+
|
|
3
48
|
## 1.147.0
|
|
4
49
|
|
|
5
50
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -8,7 +8,14 @@ Generate cryptographically secure, URL-safe, unbiased base-62 identifiers.
|
|
|
8
8
|
|
|
9
9
|
Without `@auto-engineer/id`, you would have to implement your own ID generation with proper cryptographic security, handle modulo bias in random number generation, and ensure URL-safe character encoding.
|
|
10
10
|
|
|
11
|
-
This package provides compact, URL-safe identifiers using base-62 encoding with cryptographically secure random values. The implementation uses rejection sampling to
|
|
11
|
+
This package provides compact, URL-safe identifiers using base-62 encoding (`A-Za-z0-9`) with cryptographically secure random values. The implementation uses rejection sampling to eliminate modulo bias, ensuring uniform distribution across all 62 characters.
|
|
12
|
+
|
|
13
|
+
## Key Concepts
|
|
14
|
+
|
|
15
|
+
- **Base-62 Encoding** -- Uses `A-Z`, `a-z`, `0-9` (62 characters) to produce identifiers that are safe in URLs, filenames, and HTML attributes without escaping.
|
|
16
|
+
- **Rejection Sampling** -- Random bytes outside an evenly divisible range are discarded, preventing modulo bias that would make some characters more likely than others.
|
|
17
|
+
- **Cryptographic Security** -- Built on `crypto.getRandomValues()` (Web Crypto API), not `Math.random()`.
|
|
18
|
+
- **Entropy** -- A default 9-character token yields 62^9 (~13.5 quadrillion) combinations, approximately 53.6 bits of entropy.
|
|
12
19
|
|
|
13
20
|
---
|
|
14
21
|
|
|
@@ -24,8 +31,7 @@ pnpm add @auto-engineer/id
|
|
|
24
31
|
import { generateId } from '@auto-engineer/id';
|
|
25
32
|
|
|
26
33
|
const id = generateId();
|
|
27
|
-
|
|
28
|
-
// → "aP9ZfWcLQ"
|
|
34
|
+
// → "aP9ZfWcLQ" (9-character base-62 token)
|
|
29
35
|
```
|
|
30
36
|
|
|
31
37
|
---
|
|
@@ -38,10 +44,12 @@ console.log(id);
|
|
|
38
44
|
import { generateId } from '@auto-engineer/id';
|
|
39
45
|
|
|
40
46
|
const id = generateId();
|
|
41
|
-
// 9-character base-62 token
|
|
47
|
+
// 9-character base-62 token, no prefix
|
|
42
48
|
```
|
|
43
49
|
|
|
44
|
-
### Generate with Prefix
|
|
50
|
+
### Generate with a Prefix
|
|
51
|
+
|
|
52
|
+
Prefixes must be URL-safe (`A-Za-z0-9_-`). A trailing `-` is allowed as a separator.
|
|
45
53
|
|
|
46
54
|
```typescript
|
|
47
55
|
import { generateId } from '@auto-engineer/id';
|
|
@@ -50,16 +58,16 @@ const userId = generateId({ prefix: 'user-' });
|
|
|
50
58
|
// → "user-xYz7GhtR2"
|
|
51
59
|
```
|
|
52
60
|
|
|
53
|
-
### Generate with Custom Length
|
|
61
|
+
### Generate with a Custom Length
|
|
54
62
|
|
|
55
63
|
```typescript
|
|
56
64
|
import { generateId } from '@auto-engineer/id';
|
|
57
65
|
|
|
58
|
-
const
|
|
59
|
-
// → "
|
|
66
|
+
const shortId = generateId({ length: 6 });
|
|
67
|
+
// → "Ab3Xyz"
|
|
60
68
|
```
|
|
61
69
|
|
|
62
|
-
### Combine
|
|
70
|
+
### Combine Prefix and Length
|
|
63
71
|
|
|
64
72
|
```typescript
|
|
65
73
|
import { generateId } from '@auto-engineer/id';
|
|
@@ -76,63 +84,58 @@ const orderId = generateId({ prefix: 'ord-', length: 6 });
|
|
|
76
84
|
|
|
77
85
|
```typescript
|
|
78
86
|
import { generateId, type GenerateIdOptions } from '@auto-engineer/id';
|
|
79
|
-
|
|
80
|
-
import { BASE62_ALPHABET, BASE62_TOKEN_REGEX, SAFE_PREFIX_REGEX } from '@auto-engineer/id/constants';
|
|
81
|
-
|
|
82
|
-
import { generateBase62Token, assertSafePrefix } from '@auto-engineer/id/core';
|
|
83
87
|
```
|
|
84
88
|
|
|
85
89
|
### Functions
|
|
86
90
|
|
|
87
91
|
#### `generateId(options?: GenerateIdOptions): string`
|
|
88
92
|
|
|
89
|
-
Generate a unique identifier with optional prefix and length.
|
|
93
|
+
Generate a unique identifier with an optional prefix and configurable token length.
|
|
94
|
+
|
|
95
|
+
| Parameter | Type | Default | Description |
|
|
96
|
+
|-----------|----------|---------|----------------------------------------------------|
|
|
97
|
+
| `prefix` | `string` | `''` | String prepended to the token (must be URL-safe) |
|
|
98
|
+
| `length` | `number` | `9` | Length of the random base-62 token portion |
|
|
90
99
|
|
|
91
|
-
|
|
92
|
-
|-----------|------|---------|-------------|
|
|
93
|
-
| `prefix` | `string` | - | String to prepend (must be URL-safe) |
|
|
94
|
-
| `length` | `number` | 9 | Token length |
|
|
100
|
+
**Returns:** `string` -- the concatenation of `prefix` and the generated token.
|
|
95
101
|
|
|
96
|
-
|
|
102
|
+
**Throws:** `Error` if `prefix` contains characters outside `A-Za-z0-9_-`.
|
|
103
|
+
|
|
104
|
+
### Interfaces
|
|
105
|
+
|
|
106
|
+
#### `GenerateIdOptions`
|
|
97
107
|
|
|
98
108
|
```typescript
|
|
99
109
|
type GenerateIdOptions = {
|
|
110
|
+
/** Optional string to prepend before the token. (URL-safe; trailing '-' ok) */
|
|
100
111
|
prefix?: string;
|
|
112
|
+
/** Token length; default 9 (base-62). */
|
|
101
113
|
length?: number;
|
|
102
114
|
};
|
|
103
115
|
```
|
|
104
116
|
|
|
105
|
-
### Constants
|
|
106
|
-
|
|
107
|
-
| Constant | Value | Description |
|
|
108
|
-
|----------|-------|-------------|
|
|
109
|
-
| `BASE62_ALPHABET` | A-Za-z0-9 | 62-character alphabet |
|
|
110
|
-
| `BASE62_TOKEN_REGEX` | `/^[A-Za-z0-9]+$/` | Token validation |
|
|
111
|
-
| `SAFE_PREFIX_REGEX` | `/^[A-Za-z0-9_-]+$/` | Prefix validation |
|
|
112
|
-
|
|
113
117
|
---
|
|
114
118
|
|
|
115
119
|
## Architecture
|
|
116
120
|
|
|
117
121
|
```
|
|
118
122
|
src/
|
|
119
|
-
├── index.ts
|
|
120
|
-
├── core.ts
|
|
121
|
-
└── constants.ts
|
|
123
|
+
├── index.ts # Public API: generateId, GenerateIdOptions
|
|
124
|
+
├── core.ts # assertSafePrefix, generateBase62Token (rejection sampling)
|
|
125
|
+
└── constants.ts # BASE62_ALPHABET, regex patterns
|
|
122
126
|
```
|
|
123
127
|
|
|
124
|
-
###
|
|
125
|
-
|
|
126
|
-
- **Base-62 Encoding**: Uses A-Z, a-z, 0-9 for URL-safe identifiers
|
|
127
|
-
- **Rejection Sampling**: Ensures unbiased character distribution
|
|
128
|
-
- **Cryptographic Security**: Uses `crypto.getRandomValues()`
|
|
129
|
-
|
|
130
|
-
### Entropy Analysis
|
|
128
|
+
### Internal Modules
|
|
131
129
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
-
|
|
130
|
+
| File | Responsibility |
|
|
131
|
+
|----------------|-------------------------------------------------------------|
|
|
132
|
+
| `constants.ts` | Defines the 62-char alphabet and validation regexes |
|
|
133
|
+
| `core.ts` | Prefix validation and unbiased token generation |
|
|
134
|
+
| `index.ts` | Composes `core` functions into the public `generateId` API |
|
|
135
135
|
|
|
136
136
|
### Dependencies
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
| Dependency | Kind | Purpose |
|
|
139
|
+
|------------|----------|--------------------------------|
|
|
140
|
+
| `nanoid` | Runtime | Listed in `dependencies` (unused in current source; reserved) |
|
|
141
|
+
| `vitest` | Dev-only | Test runner |
|