@workos/oagen-emitters 0.15.1 → 0.16.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/dist/index.mjs CHANGED
@@ -1,2 +1,852 @@
1
- import { _ as pythonEmitter, a as rustExtractor, c as pythonExtractor, d as rustEmitter, f as rubyEmitter, g as phpEmitter, h as goEmitter, i as kotlinExtractor, l as rubyExtractor, m as dotnetEmitter, n as elixirExtractor, o as goExtractor, p as kotlinEmitter, r as dotnetExtractor, s as phpExtractor, t as workosEmittersPlugin, u as nodeExtractor, v as nodeEmitter } from "./plugin-C2Hp2Vs2.mjs";
2
- export { dotnetEmitter, dotnetExtractor, elixirExtractor, goEmitter, goExtractor, kotlinEmitter, kotlinExtractor, nodeEmitter, nodeExtractor, phpEmitter, phpExtractor, pythonEmitter, pythonExtractor, rubyEmitter, rubyExtractor, rustEmitter, rustExtractor, workosEmittersPlugin };
1
+ import { A as fieldName$4, B as servicePropertyName, C as apiClassName, D as dotnetEmitter, E as propertyName, F as fieldName$3, H as fieldName$1, I as methodName, L as trimMountedResourceFromMethod, M as trimMountedResourceFromMethod$1, N as goEmitter, O as appendAsyncSuffix, P as className, R as phpEmitter, S as kotlinEmitter, T as packageSegment, U as safeParamName$1, V as pythonEmitter, W as nodeEmitter, _ as rubyEmitter, a as rustExtractor, b as resolveServiceTarget, c as pythonExtractor, d as rustEmitter, f as fieldName$5, g as typeName, h as resourceAccessorName, i as kotlinExtractor, j as methodName$1, k as className$1, l as rubyExtractor, m as moduleName, n as elixirExtractor, o as goExtractor, p as methodName$3, r as dotnetExtractor, s as phpExtractor, t as workosEmittersPlugin, u as nodeExtractor, v as buildExportedClassNameSet, w as methodName$2, x as safeParamName, y as fieldName, z as fieldName$2 } from "./plugin-DuB1UozS.mjs";
2
+ import { collectSnippetArgs, collectWrapperArgs, toSnakeCase } from "@workos/oagen";
3
+ //#region src/snippets/ruby.ts
4
+ const INDENT$6 = " ";
5
+ const rubySnippetEmitter = {
6
+ language: "ruby",
7
+ fileExtension: "rb",
8
+ renderOperation(resolved, ctx, examples) {
9
+ if (resolved.urlBuilder) return null;
10
+ const accessor = serviceAccessor(resolved.mountOn, ctx);
11
+ if (resolved.wrappers && resolved.wrappers.length > 0) {
12
+ const wrapper = resolved.wrappers[0];
13
+ const args = collectWrapperArgs(wrapper, ctx, examples);
14
+ return renderCall$6(accessor, wrapper.name, toRubyArgs(args, /* @__PURE__ */ new Set()));
15
+ }
16
+ const { args, collisionNames } = collectSnippetArgs(resolved, ctx, examples);
17
+ return renderCall$6(accessor, resolved.methodName, toRubyArgs(args, collisionNames));
18
+ }
19
+ };
20
+ function toRubyArgs(args, collisionNames) {
21
+ const seen = /* @__PURE__ */ new Set();
22
+ const out = [];
23
+ for (const a of args) {
24
+ const keyword = rubyKeyword(a, collisionNames);
25
+ if (seen.has(keyword)) continue;
26
+ seen.add(keyword);
27
+ out.push({
28
+ keyword,
29
+ value: renderValue$6(a.value)
30
+ });
31
+ }
32
+ return out;
33
+ }
34
+ function rubyKeyword(arg, collisions) {
35
+ if (arg.source === "body") {
36
+ const base = fieldName(arg.wireName);
37
+ return collisions.has(arg.wireName) ? `body_${base}` : base;
38
+ }
39
+ return safeParamName(arg.wireName);
40
+ }
41
+ function renderCall$6(accessor, method, args) {
42
+ const lines = [];
43
+ lines.push("require \"workos\"");
44
+ lines.push("");
45
+ lines.push("WorkOS.configure do |config|");
46
+ lines.push(`${INDENT$6}config.api_key = "sk_example_123456789"`);
47
+ lines.push("end");
48
+ lines.push("");
49
+ const target = `WorkOS.client.${accessor}.${method}`;
50
+ if (args.length === 0) {
51
+ lines.push(target);
52
+ return lines.join("\n");
53
+ }
54
+ if (args.length === 1 && !args[0].value.includes("\n")) {
55
+ const a = args[0];
56
+ lines.push(`${target}(${a.keyword}: ${a.value})`);
57
+ return lines.join("\n");
58
+ }
59
+ lines.push(`${target}(`);
60
+ for (let i = 0; i < args.length; i++) {
61
+ const a = args[i];
62
+ const trailing = i < args.length - 1 ? "," : "";
63
+ const valueIndented = indentContinuationLines$6(a.value, INDENT$6);
64
+ lines.push(`${INDENT$6}${a.keyword}: ${valueIndented}${trailing}`);
65
+ }
66
+ lines.push(")");
67
+ return lines.join("\n");
68
+ }
69
+ function serviceAccessor(mountOn, ctx) {
70
+ resolveServiceTarget(mountOn, buildExportedClassNameSet(ctx));
71
+ return toSnakeCase(mountOn);
72
+ }
73
+ function renderValue$6(value) {
74
+ if (value === null || value === void 0) return "nil";
75
+ if (typeof value === "boolean") return value ? "true" : "false";
76
+ if (typeof value === "number") return String(value);
77
+ if (typeof value === "string") return rubyString(value);
78
+ if (Array.isArray(value)) return renderArray$3(value);
79
+ if (typeof value === "object") return renderHash(value);
80
+ return "nil";
81
+ }
82
+ function rubyString(s) {
83
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
84
+ }
85
+ function renderArray$3(items) {
86
+ if (items.length === 0) return "[]";
87
+ const rendered = items.map((v) => renderValue$6(v));
88
+ const oneline = `[${rendered.join(", ")}]`;
89
+ if (oneline.length <= 80 && rendered.every((r) => !r.includes("\n"))) return oneline;
90
+ const lines = ["["];
91
+ for (let i = 0; i < rendered.length; i++) {
92
+ const trailing = i < rendered.length - 1 ? "," : "";
93
+ lines.push(`${INDENT$6}${indentContinuationLines$6(rendered[i], INDENT$6)}${trailing}`);
94
+ }
95
+ lines.push("]");
96
+ return lines.join("\n");
97
+ }
98
+ function renderHash(obj) {
99
+ const entries = Object.entries(obj);
100
+ if (entries.length === 0) return "{}";
101
+ const rendered = entries.map(([k, v]) => ({
102
+ key: k,
103
+ value: renderValue$6(v)
104
+ }));
105
+ const oneline = `{ ${rendered.map((e) => `${formatInlineKey(e.key)} ${e.value}`).join(", ")} }`;
106
+ if (oneline.length <= 80 && rendered.every((e) => !e.value.includes("\n"))) return oneline;
107
+ const lines = ["{"];
108
+ for (let i = 0; i < rendered.length; i++) {
109
+ const e = rendered[i];
110
+ const trailing = i < rendered.length - 1 ? "," : "";
111
+ lines.push(`${INDENT$6}${formatInlineKey(e.key)} ${indentContinuationLines$6(e.value, INDENT$6)}${trailing}`);
112
+ }
113
+ lines.push("}");
114
+ return lines.join("\n");
115
+ }
116
+ function formatInlineKey(name) {
117
+ if (/^[a-z_][a-zA-Z0-9_]*$/.test(name)) return `${name}:`;
118
+ return `"${name.replace(/"/g, "\\\"")}" =>`;
119
+ }
120
+ function indentContinuationLines$6(s, indent) {
121
+ if (!s.includes("\n")) return s;
122
+ return s.split("\n").map((line, i) => i === 0 ? line : `${indent}${line}`).join("\n");
123
+ }
124
+ //#endregion
125
+ //#region src/snippets/python.ts
126
+ const INDENT$5 = " ";
127
+ const pythonSnippetEmitter = {
128
+ language: "python",
129
+ fileExtension: "py",
130
+ renderOperation(resolved, ctx, examples) {
131
+ if (resolved.urlBuilder) return null;
132
+ const accessor = toSnakeCase(resolved.mountOn);
133
+ if (resolved.wrappers && resolved.wrappers.length > 0) {
134
+ const wrapper = resolved.wrappers[0];
135
+ const args = collectWrapperArgs(wrapper, ctx, examples);
136
+ return renderCall$5(accessor, wrapper.name, toPyArgs(args, /* @__PURE__ */ new Set()));
137
+ }
138
+ const { args, collisionNames } = collectSnippetArgs(resolved, ctx, examples);
139
+ return renderCall$5(accessor, resolved.methodName, toPyArgs(args, collisionNames));
140
+ }
141
+ };
142
+ function toPyArgs(args, collisionNames) {
143
+ const seen = /* @__PURE__ */ new Set();
144
+ const out = [];
145
+ for (const a of args) {
146
+ const keyword = pythonKeyword(a, collisionNames);
147
+ if (seen.has(keyword)) continue;
148
+ seen.add(keyword);
149
+ out.push({
150
+ keyword,
151
+ value: renderValue$5(a.value)
152
+ });
153
+ }
154
+ return out;
155
+ }
156
+ function pythonKeyword(arg, collisions) {
157
+ if (arg.source === "body") {
158
+ const base = fieldName$1(arg.wireName);
159
+ return collisions.has(arg.wireName) ? `body_${base}` : base;
160
+ }
161
+ return safeParamName$1(arg.wireName);
162
+ }
163
+ function renderCall$5(accessor, method, args) {
164
+ const lines = [];
165
+ lines.push("from workos import WorkOSClient");
166
+ lines.push("");
167
+ lines.push("client = WorkOSClient(api_key=\"sk_example_123456789\", client_id=\"client_123456789\")");
168
+ lines.push("");
169
+ const target = `client.${accessor}.${method}`;
170
+ if (args.length === 0) {
171
+ lines.push(`${target}()`);
172
+ return lines.join("\n");
173
+ }
174
+ if (args.length === 1 && !args[0].value.includes("\n")) {
175
+ const a = args[0];
176
+ lines.push(`${target}(${a.keyword}=${a.value})`);
177
+ return lines.join("\n");
178
+ }
179
+ lines.push(`${target}(`);
180
+ for (let i = 0; i < args.length; i++) {
181
+ const a = args[i];
182
+ const trailing = i < args.length - 1 ? "," : "";
183
+ const valueIndented = indentContinuationLines$5(a.value, INDENT$5);
184
+ lines.push(`${INDENT$5}${a.keyword}=${valueIndented}${trailing}`);
185
+ }
186
+ lines.push(")");
187
+ return lines.join("\n");
188
+ }
189
+ function renderValue$5(value) {
190
+ if (value === null || value === void 0) return "None";
191
+ if (typeof value === "boolean") return value ? "True" : "False";
192
+ if (typeof value === "number") return String(value);
193
+ if (typeof value === "string") return pythonString(value);
194
+ if (Array.isArray(value)) return renderArray$2(value);
195
+ if (typeof value === "object") return renderDict$1(value);
196
+ return "None";
197
+ }
198
+ function pythonString(s) {
199
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
200
+ }
201
+ function renderArray$2(items) {
202
+ if (items.length === 0) return "[]";
203
+ const rendered = items.map((v) => renderValue$5(v));
204
+ const oneline = `[${rendered.join(", ")}]`;
205
+ if (oneline.length <= 80 && rendered.every((r) => !r.includes("\n"))) return oneline;
206
+ const lines = ["["];
207
+ for (let i = 0; i < rendered.length; i++) {
208
+ const trailing = i < rendered.length - 1 ? "," : "";
209
+ lines.push(`${INDENT$5}${indentContinuationLines$5(rendered[i], INDENT$5)}${trailing}`);
210
+ }
211
+ lines.push("]");
212
+ return lines.join("\n");
213
+ }
214
+ function renderDict$1(obj) {
215
+ const entries = Object.entries(obj);
216
+ if (entries.length === 0) return "{}";
217
+ const rendered = entries.map(([k, v]) => ({
218
+ key: k,
219
+ value: renderValue$5(v)
220
+ }));
221
+ const oneline = `{${rendered.map((e) => `"${e.key}": ${e.value}`).join(", ")}}`;
222
+ if (oneline.length <= 80 && rendered.every((e) => !e.value.includes("\n"))) return oneline;
223
+ const lines = ["{"];
224
+ for (let i = 0; i < rendered.length; i++) {
225
+ const e = rendered[i];
226
+ const trailing = i < rendered.length - 1 ? "," : "";
227
+ lines.push(`${INDENT$5}"${e.key}": ${indentContinuationLines$5(e.value, INDENT$5)}${trailing}`);
228
+ }
229
+ lines.push("}");
230
+ return lines.join("\n");
231
+ }
232
+ function indentContinuationLines$5(s, indent) {
233
+ if (!s.includes("\n")) return s;
234
+ return s.split("\n").map((line, i) => i === 0 ? line : `${indent}${line}`).join("\n");
235
+ }
236
+ //#endregion
237
+ //#region src/snippets/php.ts
238
+ const INDENT$4 = " ";
239
+ const phpSnippetEmitter = {
240
+ language: "php",
241
+ fileExtension: "php",
242
+ renderOperation(resolved, ctx, examples) {
243
+ if (resolved.urlBuilder) return null;
244
+ const accessor = servicePropertyName(resolved.mountOn);
245
+ const method = fieldName$2(resolved.wrappers && resolved.wrappers.length > 0 ? resolved.wrappers[0].name : resolved.methodName);
246
+ let args;
247
+ let collisionNames;
248
+ if (resolved.wrappers && resolved.wrappers.length > 0) {
249
+ args = collectWrapperArgs(resolved.wrappers[0], ctx, examples);
250
+ collisionNames = /* @__PURE__ */ new Set();
251
+ } else {
252
+ const collected = collectSnippetArgs(resolved, ctx, examples);
253
+ args = collected.args;
254
+ collisionNames = collected.collisionNames;
255
+ }
256
+ return renderCall$4(accessor, method, toPhpArgs(args, collisionNames));
257
+ }
258
+ };
259
+ function toPhpArgs(args, collisions) {
260
+ const seen = /* @__PURE__ */ new Set();
261
+ const out = [];
262
+ for (const a of args) {
263
+ const keyword = phpKeyword(a, collisions);
264
+ if (seen.has(keyword)) continue;
265
+ seen.add(keyword);
266
+ out.push({
267
+ keyword,
268
+ value: renderValue$4(a.value)
269
+ });
270
+ }
271
+ return out;
272
+ }
273
+ function phpKeyword(arg, collisions) {
274
+ const base = fieldName$2(arg.wireName);
275
+ if (arg.source === "body" && collisions.has(arg.wireName)) return `body${capitalize(base)}`;
276
+ return base;
277
+ }
278
+ function capitalize(s) {
279
+ return s.length === 0 ? s : s[0].toUpperCase() + s.slice(1);
280
+ }
281
+ function renderCall$4(accessor, method, args) {
282
+ const lines = [];
283
+ lines.push("<?php");
284
+ lines.push("");
285
+ lines.push("use WorkOS\\WorkOS;");
286
+ lines.push("");
287
+ lines.push("$workos = new WorkOS(");
288
+ lines.push(`${INDENT$4}apiKey: 'sk_example_123456789',`);
289
+ lines.push(`${INDENT$4}clientId: 'client_123456789',`);
290
+ lines.push(");");
291
+ lines.push("");
292
+ const target = `$workos->${accessor}()->${method}`;
293
+ if (args.length === 0) {
294
+ lines.push(`${target}();`);
295
+ return lines.join("\n");
296
+ }
297
+ if (args.length === 1 && !args[0].value.includes("\n")) {
298
+ const a = args[0];
299
+ lines.push(`${target}(${a.keyword}: ${a.value});`);
300
+ return lines.join("\n");
301
+ }
302
+ lines.push(`${target}(`);
303
+ for (let i = 0; i < args.length; i++) {
304
+ const a = args[i];
305
+ const trailing = i < args.length - 1 ? "," : ",";
306
+ const valueIndented = indentContinuationLines$4(a.value, INDENT$4);
307
+ lines.push(`${INDENT$4}${a.keyword}: ${valueIndented}${trailing}`);
308
+ }
309
+ lines.push(");");
310
+ return lines.join("\n");
311
+ }
312
+ function renderValue$4(value) {
313
+ if (value === null || value === void 0) return "null";
314
+ if (typeof value === "boolean") return value ? "true" : "false";
315
+ if (typeof value === "number") return String(value);
316
+ if (typeof value === "string") return phpString(value);
317
+ if (Array.isArray(value)) return renderArray$1(value);
318
+ if (typeof value === "object") return renderAssoc(value);
319
+ return "null";
320
+ }
321
+ function phpString(s) {
322
+ return `'${s.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
323
+ }
324
+ function renderArray$1(items) {
325
+ if (items.length === 0) return "[]";
326
+ const rendered = items.map((v) => renderValue$4(v));
327
+ const oneline = `[${rendered.join(", ")}]`;
328
+ if (oneline.length <= 80 && rendered.every((r) => !r.includes("\n"))) return oneline;
329
+ const lines = ["["];
330
+ for (let i = 0; i < rendered.length; i++) {
331
+ const trailing = i < rendered.length - 1 ? "," : ",";
332
+ lines.push(`${INDENT$4}${indentContinuationLines$4(rendered[i], INDENT$4)}${trailing}`);
333
+ }
334
+ lines.push("]");
335
+ return lines.join("\n");
336
+ }
337
+ function renderAssoc(obj) {
338
+ const entries = Object.entries(obj);
339
+ if (entries.length === 0) return "[]";
340
+ const rendered = entries.map(([k, v]) => ({
341
+ key: k,
342
+ value: renderValue$4(v)
343
+ }));
344
+ const oneline = `[${rendered.map((e) => `'${e.key}' => ${e.value}`).join(", ")}]`;
345
+ if (oneline.length <= 80 && rendered.every((e) => !e.value.includes("\n"))) return oneline;
346
+ const lines = ["["];
347
+ for (let i = 0; i < rendered.length; i++) {
348
+ const e = rendered[i];
349
+ const trailing = i < rendered.length - 1 ? "," : ",";
350
+ lines.push(`${INDENT$4}'${e.key}' => ${indentContinuationLines$4(e.value, INDENT$4)}${trailing}`);
351
+ }
352
+ lines.push("]");
353
+ return lines.join("\n");
354
+ }
355
+ function indentContinuationLines$4(s, indent) {
356
+ if (!s.includes("\n")) return s;
357
+ return s.split("\n").map((line, i) => i === 0 ? line : `${indent}${line}`).join("\n");
358
+ }
359
+ //#endregion
360
+ //#region src/snippets/go.ts
361
+ const INDENT$3 = " ";
362
+ const goSnippetEmitter = {
363
+ language: "go",
364
+ fileExtension: "go",
365
+ renderOperation(resolved, ctx, examples) {
366
+ if (resolved.urlBuilder) return null;
367
+ return renderCall$3(resolved, ctx, examples, trimMountedResourceFromMethod(methodName(resolved.wrappers && resolved.wrappers.length > 0 ? resolved.wrappers[0].name : resolved.methodName), resolved.mountOn));
368
+ }
369
+ };
370
+ function renderCall$3(resolved, ctx, examples, method) {
371
+ const accessorMethod = className(resolved.mountOn);
372
+ const optsTypeName = `${accessorMethod}${method}Params`;
373
+ let args;
374
+ let pathArgs;
375
+ let bodyAndQueryArgs;
376
+ if (resolved.wrappers && resolved.wrappers.length > 0) {
377
+ args = collectWrapperArgs(resolved.wrappers[0], ctx, examples);
378
+ pathArgs = [];
379
+ bodyAndQueryArgs = args;
380
+ } else {
381
+ args = collectSnippetArgs(resolved, ctx, examples).args;
382
+ pathArgs = args.filter((a) => a.source === "path");
383
+ bodyAndQueryArgs = args.filter((a) => a.source !== "path");
384
+ }
385
+ const lines = [];
386
+ lines.push("package main");
387
+ lines.push("");
388
+ lines.push("import (");
389
+ lines.push(`${INDENT$3}"context"`);
390
+ lines.push("");
391
+ lines.push(`${INDENT$3}"github.com/workos/workos-go/v9"`);
392
+ lines.push(")");
393
+ lines.push("");
394
+ lines.push("func main() {");
395
+ lines.push(`${INDENT$3}client := workos.NewClient("sk_example_123456789")`);
396
+ lines.push("");
397
+ const callParts = ["context.Background()"];
398
+ for (const p of pathArgs) callParts.push(renderValue$3(p.value));
399
+ if (bodyAndQueryArgs.length === 0) lines.push(`${INDENT$3}_, err := client.${accessorMethod}().${method}(${callParts.join(", ")})`);
400
+ else {
401
+ const optsLines = buildOptsStruct(optsTypeName, bodyAndQueryArgs);
402
+ callParts.push(optsLines);
403
+ const joined = callParts.length === 2 ? callParts.join(", ") : callParts.join(", ");
404
+ lines.push(`${INDENT$3}_, err := client.${accessorMethod}().${method}(${joined})`);
405
+ }
406
+ lines.push(`${INDENT$3}if err != nil {`);
407
+ lines.push(`${INDENT$3}${INDENT$3}panic(err)`);
408
+ lines.push(`${INDENT$3}}`);
409
+ lines.push("}");
410
+ return lines.join("\n");
411
+ }
412
+ function buildOptsStruct(typeName, args) {
413
+ const lines = [`&workos.${typeName}{`];
414
+ for (const a of args) {
415
+ const field = fieldName$3(a.wireName);
416
+ const indentedValue = indentContinuationLines$3(renderValue$3(a.value), `${INDENT$3}${INDENT$3}`);
417
+ lines.push(`${INDENT$3}${INDENT$3}${field}: ${indentedValue},`);
418
+ }
419
+ lines.push(`${INDENT$3}}`);
420
+ return lines.join("\n");
421
+ }
422
+ function renderValue$3(value) {
423
+ if (value === null || value === void 0) return "nil";
424
+ if (typeof value === "boolean") return value ? "true" : "false";
425
+ if (typeof value === "number") return String(value);
426
+ if (typeof value === "string") return goString(value);
427
+ if (Array.isArray(value)) return renderSlice(value);
428
+ if (typeof value === "object") return renderStruct(value);
429
+ return "nil";
430
+ }
431
+ function goString(s) {
432
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
433
+ }
434
+ function renderSlice(items) {
435
+ if (items.length === 0) return "[]any{}";
436
+ const rendered = items.map((v) => renderValue$3(v));
437
+ const oneline = `[]any{${rendered.join(", ")}}`;
438
+ if (oneline.length <= 80 && rendered.every((r) => !r.includes("\n"))) return oneline;
439
+ const lines = ["[]any{"];
440
+ for (const r of rendered) lines.push(`${INDENT$3}${indentContinuationLines$3(r, INDENT$3)},`);
441
+ lines.push("}");
442
+ return lines.join("\n");
443
+ }
444
+ function renderStruct(obj) {
445
+ const entries = Object.entries(obj);
446
+ if (entries.length === 0) return "map[string]any{}";
447
+ const rendered = entries.map(([k, v]) => ({
448
+ key: k,
449
+ value: renderValue$3(v)
450
+ }));
451
+ const oneline = `map[string]any{${rendered.map((e) => `"${e.key}": ${e.value}`).join(", ")}}`;
452
+ if (oneline.length <= 80 && rendered.every((e) => !e.value.includes("\n"))) return oneline;
453
+ const lines = ["map[string]any{"];
454
+ for (const e of rendered) lines.push(`${INDENT$3}"${e.key}": ${indentContinuationLines$3(e.value, INDENT$3)},`);
455
+ lines.push("}");
456
+ return lines.join("\n");
457
+ }
458
+ function indentContinuationLines$3(s, indent) {
459
+ if (!s.includes("\n")) return s;
460
+ return s.split("\n").map((line, i) => i === 0 ? line : `${indent}${line}`).join("\n");
461
+ }
462
+ //#endregion
463
+ //#region src/snippets/dotnet.ts
464
+ const INDENT$2 = " ";
465
+ const dotnetSnippetEmitter = {
466
+ language: "dotnet",
467
+ fileExtension: "cs",
468
+ renderOperation(resolved, ctx, examples) {
469
+ if (resolved.urlBuilder) return null;
470
+ return renderCall$2(resolved, ctx, examples, appendAsyncSuffix(trimMountedResourceFromMethod$1(methodName$1(resolved.wrappers && resolved.wrappers.length > 0 ? resolved.wrappers[0].name : resolved.methodName), resolved.mountOn)));
471
+ }
472
+ };
473
+ function renderCall$2(resolved, ctx, examples, method) {
474
+ const accessor = className$1(resolved.mountOn);
475
+ const optsType = `${accessor}${method.replace(/Async$/, "")}Options`;
476
+ let args;
477
+ let pathArgs;
478
+ let optionsArgs;
479
+ if (resolved.wrappers && resolved.wrappers.length > 0) {
480
+ args = collectWrapperArgs(resolved.wrappers[0], ctx, examples);
481
+ pathArgs = [];
482
+ optionsArgs = args;
483
+ } else {
484
+ args = collectSnippetArgs(resolved, ctx, examples).args;
485
+ pathArgs = args.filter((a) => a.source === "path");
486
+ optionsArgs = args.filter((a) => a.source !== "path");
487
+ }
488
+ const lines = [];
489
+ lines.push("using WorkOS;");
490
+ lines.push("");
491
+ lines.push("var client = new WorkOSClient(new WorkOSOptions");
492
+ lines.push("{");
493
+ lines.push(`${INDENT$2}ApiKey = "sk_example_123456789",`);
494
+ lines.push(`${INDENT$2}ClientId = "client_123456789",`);
495
+ lines.push("});");
496
+ lines.push("");
497
+ const callParts = [];
498
+ for (const p of pathArgs) callParts.push(renderValue$2(p.value));
499
+ if (optionsArgs.length > 0) callParts.push(renderOptions(optsType, optionsArgs));
500
+ const lhs = `await client.${accessor}.${method}`;
501
+ if (callParts.length === 0) lines.push(`${lhs}();`);
502
+ else if (callParts.length === 1) lines.push(`${lhs}(${indentContinuationLines$2(callParts[0], INDENT$2)});`);
503
+ else {
504
+ lines.push(`${lhs}(`);
505
+ for (let i = 0; i < callParts.length; i++) {
506
+ const trailing = i < callParts.length - 1 ? "," : "";
507
+ lines.push(`${INDENT$2}${indentContinuationLines$2(callParts[i], INDENT$2)}${trailing}`);
508
+ }
509
+ lines.push(");");
510
+ }
511
+ return lines.join("\n");
512
+ }
513
+ function renderOptions(typeName, args) {
514
+ const lines = [`new ${typeName}`, "{"];
515
+ for (let i = 0; i < args.length; i++) {
516
+ const a = args[i];
517
+ const field = fieldName$4(a.wireName);
518
+ const value = renderValue$2(a.value);
519
+ const trailing = i < args.length - 1 ? "," : ",";
520
+ lines.push(`${INDENT$2}${field} = ${indentContinuationLines$2(value, INDENT$2)}${trailing}`);
521
+ }
522
+ lines.push("}");
523
+ return lines.join("\n");
524
+ }
525
+ function renderValue$2(value) {
526
+ if (value === null || value === void 0) return "null";
527
+ if (typeof value === "boolean") return value ? "true" : "false";
528
+ if (typeof value === "number") return String(value);
529
+ if (typeof value === "string") return csharpString(value);
530
+ if (Array.isArray(value)) return renderArray(value);
531
+ if (typeof value === "object") return renderDict(value);
532
+ return "null";
533
+ }
534
+ function csharpString(s) {
535
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
536
+ }
537
+ function renderArray(items) {
538
+ if (items.length === 0) return "new[] { }";
539
+ const rendered = items.map((v) => renderValue$2(v));
540
+ const oneline = `new[] { ${rendered.join(", ")} }`;
541
+ if (oneline.length <= 80 && rendered.every((r) => !r.includes("\n"))) return oneline;
542
+ const lines = ["new[]", "{"];
543
+ for (let i = 0; i < rendered.length; i++) {
544
+ const trailing = i < rendered.length - 1 ? "," : ",";
545
+ lines.push(`${INDENT$2}${indentContinuationLines$2(rendered[i], INDENT$2)}${trailing}`);
546
+ }
547
+ lines.push("}");
548
+ return lines.join("\n");
549
+ }
550
+ function renderDict(obj) {
551
+ const entries = Object.entries(obj);
552
+ if (entries.length === 0) return "new Dictionary<string, object>()";
553
+ const rendered = entries.map(([k, v]) => ({
554
+ key: k,
555
+ value: renderValue$2(v)
556
+ }));
557
+ const lines = ["new Dictionary<string, object>", "{"];
558
+ for (let i = 0; i < rendered.length; i++) {
559
+ const e = rendered[i];
560
+ const trailing = i < rendered.length - 1 ? "," : ",";
561
+ lines.push(`${INDENT$2}{ "${e.key}", ${indentContinuationLines$2(e.value, INDENT$2)} }${trailing}`);
562
+ }
563
+ lines.push("}");
564
+ return lines.join("\n");
565
+ }
566
+ function indentContinuationLines$2(s, indent) {
567
+ if (!s.includes("\n")) return s;
568
+ return s.split("\n").map((line, i) => i === 0 ? line : `${indent}${line}`).join("\n");
569
+ }
570
+ //#endregion
571
+ //#region src/snippets/kotlin.ts
572
+ const INDENT$1 = " ";
573
+ /**
574
+ * Emits Java-syntax snippets (rendered as `.java`) backed by the Kotlin SDK's
575
+ * naming so JVM callers see the same method and options names whether they
576
+ * write Kotlin or Java. The WorkOS docs render the `.java` extension because
577
+ * Java is the most common JVM consumer; Kotlin call sites would look almost
578
+ * identical apart from `var`/`val` and named-argument syntax.
579
+ */
580
+ const kotlinSnippetEmitter = {
581
+ language: "java",
582
+ fileExtension: "java",
583
+ renderOperation(resolved, ctx, examples) {
584
+ if (resolved.urlBuilder) return null;
585
+ return renderCall$1(resolved, ctx, examples, resolved.wrappers && resolved.wrappers.length > 0 ? methodName$2(resolved.wrappers[0].name) : methodName$2(resolved.methodName));
586
+ }
587
+ };
588
+ function renderCall$1(resolved, ctx, examples, method) {
589
+ const apiClass = apiClassName(resolved.mountOn);
590
+ const accessor = propertyName(resolved.mountOn);
591
+ const optionsType = `${methodName$2(resolved.wrappers && resolved.wrappers.length > 0 ? resolved.wrappers[0].name : resolved.methodName)}Options`;
592
+ const optionsTypeCapitalized = optionsType[0].toUpperCase() + optionsType.slice(1);
593
+ const apiSubPackage = packageSegment(resolved.mountOn);
594
+ let args;
595
+ let pathArgs;
596
+ let optionsArgs;
597
+ if (resolved.wrappers && resolved.wrappers.length > 0) {
598
+ args = collectWrapperArgs(resolved.wrappers[0], ctx, examples);
599
+ pathArgs = [];
600
+ optionsArgs = args;
601
+ } else {
602
+ args = collectSnippetArgs(resolved, ctx, examples).args;
603
+ pathArgs = args.filter((a) => a.source === "path");
604
+ optionsArgs = args.filter((a) => a.source !== "path");
605
+ }
606
+ const lines = [];
607
+ lines.push("import com.workos.WorkOS;");
608
+ if (optionsArgs.length > 0) lines.push(`import com.workos.${apiSubPackage}.${apiClass}Api.${optionsTypeCapitalized};`);
609
+ lines.push("");
610
+ lines.push("WorkOS workos = new WorkOS(\"sk_example_123456789\");");
611
+ lines.push("");
612
+ const callParts = pathArgs.map((p) => renderValue$1(p.value));
613
+ if (optionsArgs.length > 0) {
614
+ lines.push(`${optionsTypeCapitalized} options = ${optionsTypeCapitalized}.builder()`);
615
+ for (const a of optionsArgs) {
616
+ const prop = propertyName(a.wireName);
617
+ const indentedValue = indentContinuationLines$1(renderValue$1(a.value), INDENT$1);
618
+ lines.push(`${INDENT$1}.${prop}(${indentedValue})`);
619
+ }
620
+ lines.push(`${INDENT$1}.build();`);
621
+ lines.push("");
622
+ callParts.push("options");
623
+ }
624
+ if (callParts.length === 0) lines.push(`workos.${accessor}.${method}();`);
625
+ else lines.push(`workos.${accessor}.${method}(${callParts.join(", ")});`);
626
+ return lines.join("\n");
627
+ }
628
+ function renderValue$1(value) {
629
+ if (value === null || value === void 0) return "null";
630
+ if (typeof value === "boolean") return value ? "true" : "false";
631
+ if (typeof value === "number") return String(value);
632
+ if (typeof value === "string") return javaString(value);
633
+ if (Array.isArray(value)) return renderList(value);
634
+ if (typeof value === "object") return renderMap(value);
635
+ return "null";
636
+ }
637
+ function javaString(s) {
638
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
639
+ }
640
+ function renderList(items) {
641
+ if (items.length === 0) return "List.of()";
642
+ const rendered = items.map((v) => renderValue$1(v));
643
+ const oneline = `List.of(${rendered.join(", ")})`;
644
+ if (oneline.length <= 80 && rendered.every((r) => !r.includes("\n"))) return oneline;
645
+ const lines = ["List.of("];
646
+ for (let i = 0; i < rendered.length; i++) {
647
+ const trailing = i < rendered.length - 1 ? "," : "";
648
+ lines.push(`${INDENT$1}${indentContinuationLines$1(rendered[i], INDENT$1)}${trailing}`);
649
+ }
650
+ lines.push(")");
651
+ return lines.join("\n");
652
+ }
653
+ function renderMap(obj) {
654
+ const entries = Object.entries(obj);
655
+ if (entries.length === 0) return "Map.of()";
656
+ const rendered = entries.map(([k, v]) => ({
657
+ key: k,
658
+ value: renderValue$1(v)
659
+ }));
660
+ const oneline = `Map.of(${rendered.map((e) => `"${e.key}", ${e.value}`).join(", ")})`;
661
+ if (oneline.length <= 80 && rendered.every((e) => !e.value.includes("\n"))) return oneline;
662
+ const lines = ["Map.of("];
663
+ for (let i = 0; i < rendered.length; i++) {
664
+ const e = rendered[i];
665
+ const trailing = i < rendered.length - 1 ? "," : "";
666
+ lines.push(`${INDENT$1}"${e.key}", ${indentContinuationLines$1(e.value, INDENT$1)}${trailing}`);
667
+ }
668
+ lines.push(")");
669
+ return lines.join("\n");
670
+ }
671
+ function indentContinuationLines$1(s, indent) {
672
+ if (!s.includes("\n")) return s;
673
+ return s.split("\n").map((line, i) => i === 0 ? line : `${indent}${line}`).join("\n");
674
+ }
675
+ //#endregion
676
+ //#region src/snippets/rust.ts
677
+ const INDENT = " ";
678
+ const rustSnippetEmitter = {
679
+ language: "rust",
680
+ fileExtension: "rs",
681
+ renderOperation(resolved, ctx, examples) {
682
+ if (resolved.urlBuilder) return null;
683
+ return renderCall(resolved, ctx, examples, methodName$3(resolved.wrappers && resolved.wrappers.length > 0 ? resolved.wrappers[0].name : resolved.methodName));
684
+ }
685
+ };
686
+ function renderCall(resolved, ctx, examples, method) {
687
+ const accessor = resourceAccessorName(resolved.mountOn);
688
+ const modulePath = moduleName(resolved.mountOn);
689
+ const paramsStructName = `${typeName(resolved.wrappers && resolved.wrappers.length > 0 ? resolved.wrappers[0].name : resolved.methodName)}Params`;
690
+ let args;
691
+ let pathArgs;
692
+ let structArgs;
693
+ if (resolved.wrappers && resolved.wrappers.length > 0) {
694
+ args = collectWrapperArgs(resolved.wrappers[0], ctx, examples);
695
+ pathArgs = [];
696
+ structArgs = args;
697
+ } else {
698
+ args = collectSnippetArgs(resolved, ctx, examples).args;
699
+ pathArgs = args.filter((a) => a.source === "path");
700
+ structArgs = args.filter((a) => a.source !== "path");
701
+ }
702
+ const imports = ["use workos::Client;"];
703
+ if (structArgs.length > 0) imports.push(`use workos::${modulePath}::${paramsStructName};`);
704
+ const lines = [];
705
+ lines.push(...imports);
706
+ lines.push("");
707
+ lines.push("#[tokio::main]");
708
+ lines.push("async fn main() -> Result<(), workos::Error> {");
709
+ lines.push(`${INDENT}let client = Client::builder()`);
710
+ lines.push(`${INDENT}${INDENT}.api_key("sk_example_123456789")`);
711
+ lines.push(`${INDENT}${INDENT}.client_id("client_123456789")`);
712
+ lines.push(`${INDENT}${INDENT}.build();`);
713
+ lines.push("");
714
+ const callParts = [];
715
+ for (const p of pathArgs) {
716
+ const v = p.value;
717
+ if (typeof v === "string") callParts.push(rustString(v));
718
+ else callParts.push(renderValue(v));
719
+ }
720
+ if (structArgs.length > 0) callParts.push(renderStructLiteral(paramsStructName, structArgs));
721
+ const callLines = [`${INDENT}let _result = client`, `${INDENT}${INDENT}.${accessor}()`];
722
+ if (callParts.length === 0) callLines.push(`${INDENT}${INDENT}.${method}()`);
723
+ else if (callParts.length === 1 && !callParts[0].includes("\n")) callLines.push(`${INDENT}${INDENT}.${method}(${callParts[0]})`);
724
+ else {
725
+ callLines.push(`${INDENT}${INDENT}.${method}(`);
726
+ for (let i = 0; i < callParts.length; i++) {
727
+ const trailing = i < callParts.length - 1 ? "," : "";
728
+ const indented = indentContinuationLines(callParts[i], `${INDENT}${INDENT}${INDENT}`);
729
+ callLines.push(`${INDENT}${INDENT}${INDENT}${indented}${trailing}`);
730
+ }
731
+ callLines.push(`${INDENT}${INDENT})`);
732
+ }
733
+ callLines.push(`${INDENT}${INDENT}.await?;`);
734
+ lines.push(...callLines);
735
+ lines.push("");
736
+ lines.push(`${INDENT}Ok(())`);
737
+ lines.push("}");
738
+ return lines.join("\n");
739
+ }
740
+ function renderStructLiteral(structName, args) {
741
+ const lines = [`${structName} {`];
742
+ for (const a of args) {
743
+ const field = fieldName$5(a.wireName);
744
+ const value = renderStructValue(a.value);
745
+ lines.push(`${INDENT}${field}: ${indentContinuationLines(value, INDENT)},`);
746
+ }
747
+ lines.push(`${INDENT}..Default::default()`);
748
+ lines.push("}");
749
+ return lines.join("\n");
750
+ }
751
+ /** Top-level value rendering (no `.into()` wrap — used for path params etc.). */
752
+ function renderValue(value) {
753
+ if (value === null || value === void 0) return "None";
754
+ if (typeof value === "boolean") return value ? "true" : "false";
755
+ if (typeof value === "number") return String(value);
756
+ if (typeof value === "string") return rustString(value);
757
+ if (Array.isArray(value)) return renderVec(value);
758
+ if (typeof value === "object") return renderInlineObject(value);
759
+ return "None";
760
+ }
761
+ /** Struct-field rendering: wraps strings with `.into()` so `String` fields accept &str. */
762
+ function renderStructValue(value) {
763
+ if (typeof value === "string") return `${rustString(value)}.into()`;
764
+ if (Array.isArray(value)) return renderVecStructValues(value);
765
+ return renderValue(value);
766
+ }
767
+ function rustString(s) {
768
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
769
+ }
770
+ function renderVec(items) {
771
+ if (items.length === 0) return "vec![]";
772
+ const rendered = items.map((v) => renderValue(v));
773
+ const oneline = `vec![${rendered.join(", ")}]`;
774
+ if (oneline.length <= 80 && rendered.every((r) => !r.includes("\n"))) return oneline;
775
+ const lines = ["vec!["];
776
+ for (let i = 0; i < rendered.length; i++) {
777
+ const trailing = i < rendered.length - 1 ? "," : ",";
778
+ lines.push(`${INDENT}${indentContinuationLines(rendered[i], INDENT)}${trailing}`);
779
+ }
780
+ lines.push("]");
781
+ return lines.join("\n");
782
+ }
783
+ function renderVecStructValues(items) {
784
+ if (items.length === 0) return "vec![]";
785
+ const rendered = items.map((v) => renderStructValue(v));
786
+ const oneline = `vec![${rendered.join(", ")}]`;
787
+ if (oneline.length <= 80 && rendered.every((r) => !r.includes("\n"))) return oneline;
788
+ const lines = ["vec!["];
789
+ for (let i = 0; i < rendered.length; i++) {
790
+ const trailing = i < rendered.length - 1 ? "," : ",";
791
+ lines.push(`${INDENT}${indentContinuationLines(rendered[i], INDENT)}${trailing}`);
792
+ }
793
+ lines.push("]");
794
+ return lines.join("\n");
795
+ }
796
+ /** Render a plain object as a generic `serde_json::json!({...})` literal. The
797
+ * snippet doesn't know the exact Rust struct corresponding to each nested
798
+ * object, so we fall back to a serde-friendly literal a developer can swap
799
+ * for the concrete struct (e.g. `OrganizationDomainData { ... }`). */
800
+ function renderInlineObject(obj) {
801
+ const entries = Object.entries(obj);
802
+ if (entries.length === 0) return "serde_json::json!({})";
803
+ const rendered = entries.map(([k, v]) => ({
804
+ key: k,
805
+ value: renderValue(v)
806
+ }));
807
+ const oneline = `serde_json::json!({ ${rendered.map((e) => `"${e.key}": ${e.value}`).join(", ")} })`;
808
+ if (oneline.length <= 80 && rendered.every((e) => !e.value.includes("\n"))) return oneline;
809
+ const lines = ["serde_json::json!({"];
810
+ for (let i = 0; i < rendered.length; i++) {
811
+ const e = rendered[i];
812
+ const trailing = i < rendered.length - 1 ? "," : ",";
813
+ lines.push(`${INDENT}"${e.key}": ${indentContinuationLines(e.value, INDENT)}${trailing}`);
814
+ }
815
+ lines.push("})");
816
+ return lines.join("\n");
817
+ }
818
+ function indentContinuationLines(s, indent) {
819
+ if (!s.includes("\n")) return s;
820
+ return s.split("\n").map((line, i) => i === 0 ? line : `${indent}${line}`).join("\n");
821
+ }
822
+ //#endregion
823
+ //#region src/snippets/plugin.ts
824
+ /**
825
+ * Bundle of snippet emitters for every WorkOS SDK language we currently
826
+ * generate call-site samples for. Node is intentionally absent — the docs
827
+ * pipeline still owns hand-authored TypeScript samples there.
828
+ *
829
+ * ```ts
830
+ * import { runSnippetEmitters, workosSnippetsPlugin } from '@workos/oagen-emitters';
831
+ *
832
+ * const snippets = runSnippetEmitters(workosSnippetsPlugin.snippets, ctx);
833
+ * ```
834
+ *
835
+ * Each entry mirrors a published WorkOS SDK and reuses that emitter's naming
836
+ * helpers (`src/<lang>/naming.ts`), so generated samples stay in lockstep
837
+ * with the SDK they document — method names, mount-target casing, parameter
838
+ * names, and reserved-word handling all match what the real SDK exposes.
839
+ */
840
+ const workosSnippetsPlugin = { snippets: [
841
+ rubySnippetEmitter,
842
+ pythonSnippetEmitter,
843
+ phpSnippetEmitter,
844
+ goSnippetEmitter,
845
+ dotnetSnippetEmitter,
846
+ kotlinSnippetEmitter,
847
+ rustSnippetEmitter
848
+ ] };
849
+ //#endregion
850
+ export { dotnetEmitter, dotnetExtractor, dotnetSnippetEmitter, elixirExtractor, goEmitter, goExtractor, goSnippetEmitter, kotlinEmitter, kotlinExtractor, kotlinSnippetEmitter, nodeEmitter, nodeExtractor, phpEmitter, phpExtractor, phpSnippetEmitter, pythonEmitter, pythonExtractor, pythonSnippetEmitter, rubyEmitter, rubyExtractor, rubySnippetEmitter, rustEmitter, rustExtractor, rustSnippetEmitter, workosEmittersPlugin, workosSnippetsPlugin };
851
+
852
+ //# sourceMappingURL=index.mjs.map