ts-procedures 8.1.1 → 8.2.1
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/agent_config/bin/setup.mjs +2 -2
- package/agent_config/claude-code/.claude-plugin/plugin.json +1 -1
- package/agent_config/claude-code/agents/ts-procedures-architect.md +1 -1
- package/agent_config/claude-code/skills/ts-procedures/SKILL.md +348 -5
- package/agent_config/claude-code/skills/ts-procedures/api-reference.md +2 -2
- package/agent_config/claude-code/skills/ts-procedures/patterns.md +3 -3
- package/agent_config/claude-code/skills/{ts-procedures-scaffold → ts-procedures}/templates/client.md +4 -2
- package/agent_config/copilot/copilot-instructions.md +3 -3
- package/agent_config/cursor/cursorrules +3 -3
- package/agent_config/lib/install-claude.mjs +4 -4
- package/build/codegen/bin/cli.js +1 -1
- package/build/codegen/bin/cli.js.map +1 -1
- package/build/codegen/bin/cli.test.js +2 -2
- package/build/codegen/bin/cli.test.js.map +1 -1
- package/build/codegen/constants.d.ts +8 -1
- package/build/codegen/constants.js +9 -1
- package/build/codegen/constants.js.map +1 -1
- package/build/codegen/e2e.test.js +1 -1
- package/build/codegen/e2e.test.js.map +1 -1
- package/build/codegen/emit-errors.test.js +1 -1
- package/build/codegen/emit-errors.test.js.map +1 -1
- package/build/codegen/emit-index.test.js +1 -1
- package/build/codegen/emit-index.test.js.map +1 -1
- package/build/codegen/emit-scope.test.js +1 -1
- package/build/codegen/emit-scope.test.js.map +1 -1
- package/build/codegen/pipeline.js +1 -1
- package/build/codegen/pipeline.js.map +1 -1
- package/build/codegen/pipeline.test.js +33 -10
- package/build/codegen/pipeline.test.js.map +1 -1
- package/build/codegen/targets/_shared/write-files.d.ts +11 -5
- package/build/codegen/targets/_shared/write-files.js +49 -7
- package/build/codegen/targets/_shared/write-files.js.map +1 -1
- package/build/codegen/targets/_shared/write-files.test.js +87 -21
- package/build/codegen/targets/_shared/write-files.test.js.map +1 -1
- package/build/codegen/targets/kotlin/emit-scope-kotlin.js +3 -2
- package/build/codegen/targets/kotlin/emit-scope-kotlin.js.map +1 -1
- package/build/codegen/targets/kotlin/format-kotlin.d.ts +6 -0
- package/build/codegen/targets/kotlin/format-kotlin.js +9 -0
- package/build/codegen/targets/kotlin/format-kotlin.js.map +1 -1
- package/build/codegen/targets/kotlin/format-kotlin.test.js +8 -1
- package/build/codegen/targets/kotlin/format-kotlin.test.js.map +1 -1
- package/build/codegen/targets/swift/format-swift.js +4 -1
- package/build/codegen/targets/swift/format-swift.js.map +1 -1
- package/docs/ai-agent-setup.md +5 -6
- package/docs/client-and-codegen.md +2 -2
- package/package.json +1 -1
- package/src/codegen/bin/cli.test.ts +2 -2
- package/src/codegen/bin/cli.ts +1 -1
- package/src/codegen/constants.ts +10 -1
- package/src/codegen/e2e.test.ts +1 -1
- package/src/codegen/emit-errors.test.ts +1 -1
- package/src/codegen/emit-index.test.ts +1 -1
- package/src/codegen/emit-scope.test.ts +1 -1
- package/src/codegen/pipeline.test.ts +39 -10
- package/src/codegen/pipeline.ts +1 -1
- package/src/codegen/targets/_shared/write-files.test.ts +143 -32
- package/src/codegen/targets/_shared/write-files.ts +53 -8
- package/src/codegen/targets/kotlin/__fixtures__/users-golden.kt +1 -0
- package/src/codegen/targets/kotlin/emit-scope-kotlin.ts +3 -2
- package/src/codegen/targets/kotlin/format-kotlin.test.ts +9 -0
- package/src/codegen/targets/kotlin/format-kotlin.ts +11 -0
- package/src/codegen/targets/swift/format-swift.ts +5 -1
- package/agent_config/claude-code/skills/ts-procedures-kotlin/SKILL.md +0 -106
- package/agent_config/claude-code/skills/ts-procedures-review/SKILL.md +0 -48
- package/agent_config/claude-code/skills/ts-procedures-scaffold/SKILL.md +0 -50
- package/agent_config/claude-code/skills/ts-procedures-swift/SKILL.md +0 -119
- /package/agent_config/claude-code/skills/{ts-procedures-review → ts-procedures}/checklist.md +0 -0
- /package/agent_config/claude-code/skills/{ts-procedures-scaffold → ts-procedures}/templates/astro-catchall.md +0 -0
- /package/agent_config/claude-code/skills/{ts-procedures-scaffold → ts-procedures}/templates/hono.md +0 -0
- /package/agent_config/claude-code/skills/{ts-procedures-scaffold → ts-procedures}/templates/procedure.md +0 -0
- /package/agent_config/claude-code/skills/{ts-procedures-scaffold → ts-procedures}/templates/stream-procedure.md +0 -0
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: ts-procedures-swift
|
|
3
|
-
description: "Swift client codegen for ts-procedures — generate types-only Swift source from a ts-procedures DocEnvelope for iOS/macOS/Apple-platform consumers. Use when the user mentions Swift, iOS, macOS, Apple platforms, Codable, or asks how to generate non-TypeScript types from a ts-procedures server."
|
|
4
|
-
user-invocable: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# ts-procedures — Swift Client Codegen
|
|
8
|
-
|
|
9
|
-
You are assisting a developer who needs to generate Swift types from a `ts-procedures` server's `DocEnvelope`. The Swift target is **types-only** — no runtime, no adapter, no error registry. iOS / macOS / Apple-platform consumers own the HTTP layer.
|
|
10
|
-
|
|
11
|
-
## When this skill applies
|
|
12
|
-
|
|
13
|
-
- The user mentions Swift, iOS, macOS, watchOS, tvOS, visionOS, Apple platforms, `Codable`, `URLSession`, or `--target swift`.
|
|
14
|
-
- The user wants to share API types between a `ts-procedures` server and a Swift consumer.
|
|
15
|
-
- The user is debugging Swift codegen output, SPM/Xcode integration, `JSONDecoder` configuration, or `Codable` conformance issues.
|
|
16
|
-
|
|
17
|
-
If the user is generating a **TypeScript** client, redirect them to the main `ts-procedures` skill. For **Kotlin/Android** consumers, redirect to `ts-procedures-kotlin`.
|
|
18
|
-
|
|
19
|
-
## Quickstart
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npx ts-procedures-codegen \
|
|
23
|
-
--target swift \
|
|
24
|
-
--url https://api.example.com/_ts-procedures.json \
|
|
25
|
-
--out ./Sources/MyApp/Generated
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
One `.swift` file per scope. Types accessed as `Users.GetUser.Response`, `Users.GetUser.PathParams`, `Users.GetUser.Response.Address` (nested structs via `inlineTypes: true`), `Users.GetUser.Errors.NotFound`.
|
|
29
|
-
|
|
30
|
-
**Note:** unlike the Kotlin target, no `--swift-package` flag exists or is required. Swift modules are defined by Xcode/SPM targets.
|
|
31
|
-
|
|
32
|
-
## CLI flags (Swift-specific)
|
|
33
|
-
|
|
34
|
-
| Flag | Default | Purpose |
|
|
35
|
-
|---|---|---|
|
|
36
|
-
| `--target swift` | `ts` | Switch to the Swift codegen path |
|
|
37
|
-
| `--swift-serializer <codable\|none>` | `codable` | `codable` emits `: Codable` + `CodingKeys`; `none` emits plain structs (consumer handles serialization) |
|
|
38
|
-
| `--swift-access-level <public\|internal>` | `public` | Threads through to ajsc's `accessLevel`; use `internal` when generated types shouldn't appear in module ABI |
|
|
39
|
-
| `--unsupported-unions <throw\|fallback>` | `throw` | **Functional for Swift** (unlike Kotlin where it's a no-op) — `fallback` emits a self-contained `AnyCodable` helper for untagged `anyOf`/`oneOf` |
|
|
40
|
-
|
|
41
|
-
`--array-item-naming`, `--depluralize`, `--uncountable-words` also apply to the Swift target.
|
|
42
|
-
|
|
43
|
-
## Output shape (what consumers see)
|
|
44
|
-
|
|
45
|
-
```swift
|
|
46
|
-
import Foundation
|
|
47
|
-
|
|
48
|
-
public enum Users {
|
|
49
|
-
public enum GetUser {
|
|
50
|
-
public static let method = "GET"
|
|
51
|
-
public static let pathTemplate = "/users/{id}"
|
|
52
|
-
public static func path(_ p: PathParams) -> String { return "/users/\(p.id)" }
|
|
53
|
-
|
|
54
|
-
public struct PathParams: Codable {
|
|
55
|
-
public let id: String
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public struct Response: Codable {
|
|
59
|
-
public let id: String
|
|
60
|
-
public let createdAt: Date
|
|
61
|
-
public let address: Address
|
|
62
|
-
|
|
63
|
-
enum CodingKeys: String, CodingKey {
|
|
64
|
-
case id
|
|
65
|
-
case createdAt = "created-at"
|
|
66
|
-
case address
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public struct Address: Codable {
|
|
70
|
-
public let street: String
|
|
71
|
-
public let city: String
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public enum Errors {
|
|
76
|
-
public struct NotFound: Codable {
|
|
77
|
-
public let name: String
|
|
78
|
-
public let message: String
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
For routes without path params, `path` is a `static let`, not a function. Namespaces are caseless `enum`s (the standard Swift idiom — uninstantiable, zero runtime cost).
|
|
86
|
-
|
|
87
|
-
## Consumer-side setup the dev MUST do
|
|
88
|
-
|
|
89
|
-
The generated code requires these on the Apple-platform side. **Don't let the user assume the codegen handles them.**
|
|
90
|
-
|
|
91
|
-
1. **Drop generated files into your SPM target or Xcode source group.** Any target containing the generated dir picks them up — no special build config. SPM globs sources recursively; for Xcode, use **File → Add Files to "<TargetName>"…** and ensure target membership is checked.
|
|
92
|
-
|
|
93
|
-
2. **Configure `JSONDecoder.dateDecodingStrategy = .iso8601`.** **Required** if the schema uses any `format: date-time` field (which become `Foundation.Date`). Without this, decoding fails with `DecodingError.typeMismatch`. Symmetric: set `JSONEncoder.dateEncodingStrategy = .iso8601` for request bodies.
|
|
94
|
-
|
|
95
|
-
3. **HTTP transport is the consumer's choice.** `URLSession` (with `async/await`) is the default recommendation — it's built-in and works on all Apple platforms with no dependencies. Alamofire / other libraries are fine but never required.
|
|
96
|
-
|
|
97
|
-
4. **No runtime dispatch.** Error types are emitted as nested structs (`Users.GetUser.Errors.NotFound`), but there's no registry, no `instanceof`-style lookup, no `dispatchTypedError`. Consumers catch HTTP failures themselves and dispatch on status code or `body.name` (a regular `String` field, not a type-system discriminator) to decide which error struct to decode against. To make error structs throwable, declare a one-line `extension X.Errors.NotFound: Error {}` in user code (keep it out of the generated file so re-runs don't clobber it). This is by design; don't suggest implementing a registry.
|
|
98
|
-
|
|
99
|
-
The full setup guide lives at `docs/codegen-swift.md` in the `ts-procedures` repo.
|
|
100
|
-
|
|
101
|
-
## Documented limitations to flag during reviews
|
|
102
|
-
|
|
103
|
-
- **`format: date` and `format: time` map to `String`.** Foundation has no native date-only or time-only type. Parse with `DateFormatter` if a typed value is needed.
|
|
104
|
-
- **`type: integer` maps to `Int64`** (not `Int`). 32-bit Apple platforms exist; `Int64` guarantees range parity.
|
|
105
|
-
- **`type: number` maps to `Double`.** For monetary values, convert to `Decimal` at the parse boundary.
|
|
106
|
-
- **Heterogeneous tuples throw under `Codable`.** Swift tuples aren't `Codable`. Schemas with positional-tuple `items: [...]` arrays throw at codegen time. Refactor to a struct schema upstream.
|
|
107
|
-
- **`additionalProperties: { type: T }` is silently dropped** with a doc-comment. Add a sibling `[String: T]` field by hand if your contract uses extra keys.
|
|
108
|
-
- **`not` and `patternProperties` throw at codegen time.** Simplify the schema upstream.
|
|
109
|
-
- **Untagged `oneOf` throws by default.** Add a discriminator, or pass `--unsupported-unions fallback` to emit `AnyCodable`-typed values (loses static typing).
|
|
110
|
-
|
|
111
|
-
## Anti-patterns
|
|
112
|
-
|
|
113
|
-
- **Suggesting the Swift target ships a networking layer or HTTP adapter.** It does not — consumers own `URLSession`/etc. entirely.
|
|
114
|
-
- **Recommending Alamofire as required.** `URLSession` + `async/await` is fine and ships with the OS. Alamofire is a personal-preference choice, not a dependency of the generated code.
|
|
115
|
-
- **Conflating `--swift-serializer none` with "no setup needed".** `none` removes `Codable` conformance and `CodingKeys` — the consumer then needs their own serialization plan (hand-rolled, SwiftyJSON, etc.). It's strictly *more* setup, not less.
|
|
116
|
-
- **Treating `--unsupported-unions fallback` as a no-op for Swift.** Unlike Kotlin (where it's silently dropped), the Swift target actually emits an `AnyCodable` helper that round-trips correctly. Use it when needed.
|
|
117
|
-
- **Suggesting backwards compatibility with Swift 4 / pre-async-await.** Assume Swift 5.5+ (the async/await era). Sample dispatch code in docs uses `async throws`.
|
|
118
|
-
- **Suggesting the codegen emits `: Error` conformance on error structs.** It doesn't (`Codable` only) — consumers add a one-line extension. Don't ask for this to be added to the codegen; it would force users into a particular error model.
|
|
119
|
-
- **Mixing `--target swift` flags into a TypeScript-target invocation.** The flags are silently ignored; no harm, but the user is probably running the wrong target.
|
/package/agent_config/claude-code/skills/{ts-procedures-review → ts-procedures}/checklist.md
RENAMED
|
File without changes
|
|
File without changes
|
/package/agent_config/claude-code/skills/{ts-procedures-scaffold → ts-procedures}/templates/hono.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|