@workos/oagen-emitters 0.3.0 → 0.5.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 (128) hide show
  1. package/.github/workflows/ci.yml +1 -1
  2. package/.github/workflows/lint.yml +1 -1
  3. package/.github/workflows/release-please.yml +2 -2
  4. package/.github/workflows/release.yml +1 -1
  5. package/.husky/pre-push +11 -0
  6. package/.node-version +1 -1
  7. package/.release-please-manifest.json +1 -1
  8. package/CHANGELOG.md +15 -0
  9. package/README.md +35 -224
  10. package/dist/index.d.mts +12 -1
  11. package/dist/index.d.mts.map +1 -1
  12. package/dist/index.mjs +2 -12737
  13. package/dist/plugin-BSop9f9z.mjs +21471 -0
  14. package/dist/plugin-BSop9f9z.mjs.map +1 -0
  15. package/dist/plugin.d.mts +7 -0
  16. package/dist/plugin.d.mts.map +1 -0
  17. package/dist/plugin.mjs +2 -0
  18. package/docs/sdk-architecture/dotnet.md +336 -0
  19. package/oagen.config.ts +5 -343
  20. package/package.json +10 -34
  21. package/smoke/sdk-dotnet.ts +45 -12
  22. package/src/dotnet/client.ts +89 -0
  23. package/src/dotnet/enums.ts +323 -0
  24. package/src/dotnet/fixtures.ts +236 -0
  25. package/src/dotnet/index.ts +248 -0
  26. package/src/dotnet/manifest.ts +36 -0
  27. package/src/dotnet/models.ts +320 -0
  28. package/src/dotnet/naming.ts +368 -0
  29. package/src/dotnet/resources.ts +943 -0
  30. package/src/dotnet/tests.ts +713 -0
  31. package/src/dotnet/type-map.ts +228 -0
  32. package/src/dotnet/wrappers.ts +197 -0
  33. package/src/go/client.ts +35 -3
  34. package/src/go/enums.ts +4 -0
  35. package/src/go/index.ts +15 -7
  36. package/src/go/models.ts +6 -1
  37. package/src/go/naming.ts +5 -17
  38. package/src/go/resources.ts +534 -73
  39. package/src/go/tests.ts +39 -3
  40. package/src/go/type-map.ts +8 -3
  41. package/src/go/wrappers.ts +79 -21
  42. package/src/index.ts +15 -0
  43. package/src/kotlin/client.ts +58 -0
  44. package/src/kotlin/enums.ts +189 -0
  45. package/src/kotlin/index.ts +92 -0
  46. package/src/kotlin/manifest.ts +55 -0
  47. package/src/kotlin/models.ts +486 -0
  48. package/src/kotlin/naming.ts +229 -0
  49. package/src/kotlin/overrides.ts +25 -0
  50. package/src/kotlin/resources.ts +998 -0
  51. package/src/kotlin/tests.ts +1133 -0
  52. package/src/kotlin/type-map.ts +123 -0
  53. package/src/kotlin/wrappers.ts +168 -0
  54. package/src/node/client.ts +84 -7
  55. package/src/node/field-plan.ts +12 -14
  56. package/src/node/fixtures.ts +39 -3
  57. package/src/node/index.ts +1 -0
  58. package/src/node/models.ts +281 -37
  59. package/src/node/resources.ts +319 -95
  60. package/src/node/tests.ts +108 -29
  61. package/src/node/type-map.ts +1 -31
  62. package/src/node/utils.ts +96 -6
  63. package/src/node/wrappers.ts +31 -1
  64. package/src/php/client.ts +11 -3
  65. package/src/php/models.ts +0 -33
  66. package/src/php/naming.ts +2 -21
  67. package/src/php/resources.ts +275 -19
  68. package/src/php/tests.ts +118 -18
  69. package/src/php/type-map.ts +16 -2
  70. package/src/php/wrappers.ts +7 -2
  71. package/src/plugin.ts +50 -0
  72. package/src/python/client.ts +50 -32
  73. package/src/python/enums.ts +35 -10
  74. package/src/python/index.ts +35 -27
  75. package/src/python/models.ts +139 -2
  76. package/src/python/naming.ts +2 -22
  77. package/src/python/resources.ts +234 -17
  78. package/src/python/tests.ts +260 -16
  79. package/src/python/type-map.ts +16 -2
  80. package/src/ruby/client.ts +238 -0
  81. package/src/ruby/enums.ts +149 -0
  82. package/src/ruby/index.ts +93 -0
  83. package/src/ruby/manifest.ts +35 -0
  84. package/src/ruby/models.ts +360 -0
  85. package/src/ruby/naming.ts +187 -0
  86. package/src/ruby/rbi.ts +313 -0
  87. package/src/ruby/resources.ts +799 -0
  88. package/src/ruby/tests.ts +459 -0
  89. package/src/ruby/type-map.ts +97 -0
  90. package/src/ruby/wrappers.ts +161 -0
  91. package/src/shared/model-utils.ts +357 -16
  92. package/src/shared/naming-utils.ts +83 -0
  93. package/src/shared/non-spec-services.ts +13 -0
  94. package/src/shared/resolved-ops.ts +75 -1
  95. package/src/shared/wrapper-utils.ts +12 -1
  96. package/test/dotnet/client.test.ts +121 -0
  97. package/test/dotnet/enums.test.ts +193 -0
  98. package/test/dotnet/errors.test.ts +9 -0
  99. package/test/dotnet/manifest.test.ts +82 -0
  100. package/test/dotnet/models.test.ts +258 -0
  101. package/test/dotnet/resources.test.ts +387 -0
  102. package/test/dotnet/tests.test.ts +202 -0
  103. package/test/entrypoint.test.ts +89 -0
  104. package/test/go/client.test.ts +6 -6
  105. package/test/go/resources.test.ts +156 -7
  106. package/test/kotlin/models.test.ts +135 -0
  107. package/test/kotlin/resources.test.ts +210 -0
  108. package/test/kotlin/tests.test.ts +176 -0
  109. package/test/node/client.test.ts +74 -0
  110. package/test/node/models.test.ts +134 -1
  111. package/test/node/resources.test.ts +343 -34
  112. package/test/node/utils.test.ts +140 -0
  113. package/test/php/client.test.ts +2 -1
  114. package/test/php/models.test.ts +5 -4
  115. package/test/php/resources.test.ts +103 -0
  116. package/test/php/tests.test.ts +67 -0
  117. package/test/plugin.test.ts +50 -0
  118. package/test/python/client.test.ts +56 -0
  119. package/test/python/models.test.ts +99 -0
  120. package/test/python/resources.test.ts +294 -0
  121. package/test/python/tests.test.ts +91 -0
  122. package/test/ruby/client.test.ts +81 -0
  123. package/test/ruby/resources.test.ts +386 -0
  124. package/test/shared/resolved-ops.test.ts +122 -0
  125. package/tsdown.config.ts +1 -1
  126. package/dist/index.mjs.map +0 -1
  127. package/scripts/generate-php.js +0 -13
  128. package/scripts/git-push-with-published-oagen.sh +0 -21
@@ -0,0 +1,7 @@
1
+ import { OagenConfig } from "@workos/oagen";
2
+
3
+ //#region src/plugin.d.ts
4
+ declare const workosEmittersPlugin: Pick<OagenConfig, 'emitters' | 'extractors' | 'smokeRunners'>;
5
+ //#endregion
6
+ export { workosEmittersPlugin };
7
+ //# sourceMappingURL=plugin.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;cAyBa,oBAAA,EAAsB,IAAA,CAAK,WAAA"}
@@ -0,0 +1,2 @@
1
+ import { t as workosEmittersPlugin } from "./plugin-BSop9f9z.mjs";
2
+ export { workosEmittersPlugin };
@@ -0,0 +1,336 @@
1
+ # C# / .NET SDK Architecture
2
+
3
+ Target: .NET 8.0 | Serialization: Newtonsoft.Json | Test: xUnit + Moq
4
+
5
+ ## Architecture Overview
6
+
7
+ The SDK follows a service-per-domain pattern. A static `WorkOS` entry point holds a singleton `WorkOSClient`. Each service (e.g., `OrganizationsService`) inherits from a shared `Service` base class that lazily resolves the client. All IO is async with `CancellationToken` support.
8
+
9
+ **Runtime files (hand-maintained, `@oagen-ignore-file`):**
10
+
11
+ - `WorkOS.cs` — static entry point
12
+ - `Client/WorkOSClient.cs` — HTTP execution, retry, error translation
13
+ - `Client/_interfaces/WorkOSOptions.cs` — client config
14
+ - `Client/_interfaces/WorkOSRequest.cs` — request DTO
15
+ - `Client/Utilities/RequestUtilities.cs` — JSON/query serialization
16
+ - `Services/Webhooks/WebhookService.cs` — webhook signature verification helper
17
+ - `Services/Webhooks/Entities/Webhook.cs` — webhook event envelope used by the helper
18
+ - `Services/Webhooks/Exceptions/WorkOSWebhookException.cs` — webhook verification exception
19
+ - `Services/_common/Service.cs` — base service class
20
+ - `Services/_common/_interfaces/BaseOptions.cs` — marker base for options
21
+ - `Services/_common/_interfaces/ListOptions.cs` — pagination base options
22
+ - `Services/_common/Entities/WorkOSList.cs` — pagination wrapper
23
+ - `Services/_common/Entities/ListMetadata.cs` — cursor metadata
24
+ - `Services/_common/Enums/PaginationOrder.cs` — asc/desc enum
25
+
26
+ **Generated files (emitter output):**
27
+
28
+ - `Services/{Mount}/Entities/*.cs` — model classes
29
+ - `Services/{Mount}/Enums/*.cs` — enum types
30
+ - `Services/{Mount}/{Mount}Service.cs` — service class with methods
31
+ - `Services/{Mount}/_interfaces/*Options.cs` — request option classes
32
+ - `test/WorkOSTests/Tests/*Test.cs` — generated service tests
33
+ - `test/WorkOSTests/testdata/*.json` — generated fixtures
34
+ - `test/WorkOSTests/xunit.runner.json` — generated xUnit runner config
35
+
36
+ ## Naming Conventions
37
+
38
+ | IR Concept | C# Convention | Example |
39
+ | -------------- | ---------------------------- | --------------------------- |
40
+ | Model name | PascalCase | `Organization` |
41
+ | Enum name | PascalCase | `ConnectionState` |
42
+ | Field/property | PascalCase | `EmailVerified` |
43
+ | Method | PascalCase (no Async suffix) | `GetOrganization` |
44
+ | File | PascalCase.cs | `Organization.cs` |
45
+ | Service class | `{Mount}Service` | `OrganizationsService` |
46
+ | Options class | `{Action}{Entity}Options` | `CreateOrganizationOptions` |
47
+ | Namespace | `WorkOS` | — |
48
+
49
+ ## Type Mapping
50
+
51
+ | IR TypeRef | C# Type |
52
+ | ------------------------------ | ----------------------- |
53
+ | `primitive:string` | `string` |
54
+ | `primitive:string` (date-time) | `string` |
55
+ | `primitive:string` (uuid) | `string` |
56
+ | `primitive:string` (binary) | `byte[]` |
57
+ | `primitive:integer` | `int` |
58
+ | `primitive:integer` (int64) | `long` |
59
+ | `primitive:number` | `double` |
60
+ | `primitive:boolean` | `bool` |
61
+ | `primitive:unknown` | `object` |
62
+ | `model:Foo` | `Foo` (reference type) |
63
+ | `enum:Foo` | `Foo` (value type) |
64
+ | `array` | `List<T>` |
65
+ | `map` | `Dictionary<string, T>` |
66
+ | `nullable` (value type) | `T?` |
67
+ | `nullable` (reference type) | `T` |
68
+ | `union` (single) | that type |
69
+ | `union` (multiple) | `object` |
70
+
71
+ ## Model Pattern
72
+
73
+ ```csharp
74
+ namespace WorkOS
75
+ {
76
+ using Newtonsoft.Json;
77
+
78
+ /// <summary>Represents an organization.</summary>
79
+ public class Organization
80
+ {
81
+ [JsonProperty("id")]
82
+ public string Id { get; set; }
83
+
84
+ [JsonProperty("name")]
85
+ public string Name { get; set; }
86
+
87
+ [JsonProperty("allow_profiles_outside_organization")]
88
+ public bool AllowProfilesOutsideOrganization { get; set; }
89
+
90
+ [JsonProperty("created_at")]
91
+ public string CreatedAt { get; set; }
92
+ }
93
+ }
94
+ ```
95
+
96
+ ## Enum Pattern
97
+
98
+ ```csharp
99
+ namespace WorkOS
100
+ {
101
+ using System.Runtime.Serialization;
102
+ using Newtonsoft.Json;
103
+ using Newtonsoft.Json.Converters;
104
+
105
+ [JsonConverter(typeof(StringEnumConverter))]
106
+ public enum OrganizationDomainState
107
+ {
108
+ [EnumMember(Value = "failed")]
109
+ Failed,
110
+
111
+ [EnumMember(Value = "pending")]
112
+ Pending,
113
+
114
+ [EnumMember(Value = "verified")]
115
+ Verified,
116
+ }
117
+ }
118
+ ```
119
+
120
+ ## Resource/Service Pattern
121
+
122
+ ```csharp
123
+ namespace WorkOS
124
+ {
125
+ using System.Net.Http;
126
+ using System.Threading;
127
+ using System.Threading.Tasks;
128
+
129
+ public class OrganizationsService : Service
130
+ {
131
+ public OrganizationsService() { }
132
+ public OrganizationsService(WorkOSClient client) : base(client) { }
133
+
134
+ public async Task<Organization> GetOrganization(
135
+ string id,
136
+ CancellationToken cancellationToken = default)
137
+ {
138
+ var request = new WorkOSRequest
139
+ {
140
+ Method = HttpMethod.Get,
141
+ Path = $"/organizations/{id}",
142
+ };
143
+ return await this.Client.MakeAPIRequest<Organization>(request, cancellationToken);
144
+ }
145
+
146
+ public async Task<WorkOSList<Organization>> ListOrganizations(
147
+ ListOrganizationsOptions options = null,
148
+ CancellationToken cancellationToken = default)
149
+ {
150
+ var request = new WorkOSRequest
151
+ {
152
+ Method = HttpMethod.Get,
153
+ Path = "/organizations",
154
+ Options = options,
155
+ };
156
+ return await this.Client.MakeAPIRequest<WorkOSList<Organization>>(request, cancellationToken);
157
+ }
158
+
159
+ public async Task<Organization> CreateOrganization(
160
+ CreateOrganizationOptions options,
161
+ CancellationToken cancellationToken = default)
162
+ {
163
+ var request = new WorkOSRequest
164
+ {
165
+ Method = HttpMethod.Post,
166
+ Path = "/organizations",
167
+ Options = options,
168
+ };
169
+ return await this.Client.MakeAPIRequest<Organization>(request, cancellationToken);
170
+ }
171
+
172
+ public async Task DeleteOrganization(
173
+ string id,
174
+ CancellationToken cancellationToken = default)
175
+ {
176
+ var request = new WorkOSRequest
177
+ {
178
+ Method = HttpMethod.Delete,
179
+ Path = $"/organizations/{id}",
180
+ };
181
+ await this.Client.MakeRawAPIRequest(request, cancellationToken);
182
+ }
183
+ }
184
+ }
185
+ ```
186
+
187
+ ## Options Pattern
188
+
189
+ ```csharp
190
+ namespace WorkOS
191
+ {
192
+ using Newtonsoft.Json;
193
+
194
+ public class CreateOrganizationOptions : BaseOptions
195
+ {
196
+ [JsonProperty("name")]
197
+ public string Name { get; set; }
198
+
199
+ [JsonProperty("domain_data")]
200
+ public List<OrganizationDomainDataOptions> DomainData { get; set; }
201
+ }
202
+
203
+ public class ListOrganizationsOptions : ListOptions
204
+ {
205
+ [JsonProperty("domains")]
206
+ public string[] Domains { get; set; }
207
+ }
208
+ }
209
+ ```
210
+
211
+ ## Pagination Pattern
212
+
213
+ ```csharp
214
+ // Returned by list methods — NOT an iterator
215
+ public class WorkOSList<T>
216
+ {
217
+ [JsonProperty("data")]
218
+ public List<T> Data { get; set; }
219
+
220
+ [JsonProperty("list_metadata")]
221
+ public ListMetadata ListMetadata { get; set; }
222
+ }
223
+ ```
224
+
225
+ ## Error Handling
226
+
227
+ The runtime translates HTTP status codes to SDK-native exceptions:
228
+
229
+ - `AuthenticationException` (401)
230
+ - `NotFoundException` (404)
231
+ - `UnprocessableEntityException` (422)
232
+ - `RateLimitExceededException` (429)
233
+ - `ServerException` (500+)
234
+
235
+ These are hand-maintained in the runtime. The emitter generates error-handling _tests_, not the error classes themselves.
236
+
237
+ ## Hidden Parameter Injection
238
+
239
+ For operations with defaults/inferFromClient, the service method sets properties on the options before making the request:
240
+
241
+ ```csharp
242
+ public async Task<AuthenticationResponse> AuthenticateWithPassword(
243
+ AuthenticateWithPasswordOptions options,
244
+ CancellationToken cancellationToken = default)
245
+ {
246
+ options.GrantType = "password";
247
+ options.ClientId = this.Client.ClientId;
248
+ options.ClientSecret = this.Client.ApiKey;
249
+ var request = new WorkOSRequest
250
+ {
251
+ Method = HttpMethod.Post,
252
+ Path = "/user_management/authenticate",
253
+ Options = options,
254
+ };
255
+ return await this.Client.MakeAPIRequest<AuthenticationResponse>(request, cancellationToken);
256
+ }
257
+ ```
258
+
259
+ ## Testing Pattern
260
+
261
+ xUnit + Moq with HttpMock utility:
262
+
263
+ ```csharp
264
+ public class OrganizationsServiceTest
265
+ {
266
+ private readonly HttpMock httpMock;
267
+ private readonly OrganizationsService service;
268
+
269
+ public OrganizationsServiceTest()
270
+ {
271
+ this.httpMock = new HttpMock();
272
+ var client = new WorkOSClient(new WorkOSOptions
273
+ {
274
+ ApiKey = "sk_test",
275
+ HttpClient = this.httpMock.HttpClient,
276
+ });
277
+ this.service = new OrganizationsService(client);
278
+ }
279
+
280
+ [Fact]
281
+ public async Task TestGetOrganization()
282
+ {
283
+ var fixture = File.ReadAllText("testdata/organization.json");
284
+ this.httpMock.MockResponse(HttpMethod.Get, "/organizations/org_01234", HttpStatusCode.OK, fixture);
285
+ var result = await this.service.GetOrganization("org_01234");
286
+ Assert.NotNull(result);
287
+ Assert.Equal("org_01234", result.Id);
288
+ this.httpMock.AssertRequestWasMade(HttpMethod.Get, "/organizations/org_01234");
289
+ }
290
+ }
291
+ ```
292
+
293
+ ## Structural Guidelines
294
+
295
+ | Category | Choice |
296
+ | ------------------ | --------------------------- |
297
+ | Target Framework | .NET 8.0 |
298
+ | HTTP Client | System.Net.Http.HttpClient |
299
+ | JSON Parsing | Newtonsoft.Json 13.x |
300
+ | Testing Framework | xUnit 2.x |
301
+ | HTTP Mocking | Moq 4.x (HttpClientHandler) |
302
+ | Linting/Formatting | StyleCop.Analyzers |
303
+ | Package Manager | NuGet |
304
+ | Build Tool | dotnet CLI / MSBuild |
305
+
306
+ ## Directory Structure
307
+
308
+ ```
309
+ src/WorkOS.net/
310
+ ├── WorkOS.cs # @oagen-ignore-file
311
+ ├── Client/ # @oagen-ignore-file (all)
312
+ │ ├── WorkOSClient.cs
313
+ │ ├── _interfaces/
314
+ │ └── Utilities/
315
+ ├── Services/
316
+ │ ├── _common/ # @oagen-ignore-file (all)
317
+ │ ├── Webhooks/ # Mixed hand-written + generated
318
+ │ │ ├── Entities/Webhook.cs # @oagen-ignore-file
319
+ │ │ ├── Exceptions/WorkOSWebhookException.cs
320
+ │ │ ├── WebhookService.cs # @oagen-ignore-file
321
+ │ │ └── WebhooksService.cs # Generated
322
+ │ └── {ServiceName}/ # Generated
323
+ │ ├── {ServiceName}Service.cs
324
+ │ ├── _interfaces/
325
+ │ │ └── {Action}{Entity}Options.cs
326
+ │ ├── Entities/
327
+ │ │ └── {Entity}.cs
328
+ │ └── Enums/
329
+ │ └── {EnumName}.cs
330
+ test/WorkOSTests/
331
+ ├── Utilities/HttpMock.cs # @oagen-ignore-file
332
+ ├── Client/ # @oagen-ignore-file
333
+ ├── Services/Webhooks/WebhookTests.cs # @oagen-ignore-file
334
+ ├── Tests/{ServiceName}Test.cs # Generated
335
+ └── xunit.runner.json # Generated
336
+ ```