@redocly/client-generator 0.7.12 → 0.7.13

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 (60) hide show
  1. package/eject-assets/generators/cli/docs.ts +1 -1
  2. package/eject-assets/generators/cli/engine-source.ts +1 -1
  3. package/eject-assets/generators/cli/index.ts +2 -2
  4. package/eject-assets/generators/cli/render.ts +1 -1
  5. package/eject-assets/generators/go/client.ts +1 -1
  6. package/eject-assets/generators/go/descriptor.ts +1 -1
  7. package/eject-assets/generators/go/index.ts +2 -2
  8. package/eject-assets/generators/go/models.ts +1 -1
  9. package/eject-assets/generators/go/naming.ts +1 -1
  10. package/eject-assets/generators/go/operations.ts +1 -1
  11. package/eject-assets/generators/go/pagination.ts +1 -1
  12. package/eject-assets/generators/go/types.ts +1 -1
  13. package/eject-assets/generators/mock/faker.ts +1 -1
  14. package/eject-assets/generators/mock/index.ts +2 -2
  15. package/eject-assets/generators/mock/render.ts +1 -1
  16. package/eject-assets/generators/mock/sample.ts +1 -1
  17. package/eject-assets/generators/mock/values.ts +1 -1
  18. package/eject-assets/generators/php/client.ts +1 -1
  19. package/eject-assets/generators/php/descriptor.ts +1 -1
  20. package/eject-assets/generators/php/index.ts +2 -2
  21. package/eject-assets/generators/php/models.ts +1 -1
  22. package/eject-assets/generators/php/naming.ts +1 -1
  23. package/eject-assets/generators/php/operations.ts +1 -1
  24. package/eject-assets/generators/php/pagination.ts +1 -1
  25. package/eject-assets/generators/php/types.ts +1 -1
  26. package/eject-assets/generators/python/client.ts +1 -1
  27. package/eject-assets/generators/python/descriptor.ts +1 -1
  28. package/eject-assets/generators/python/index.ts +2 -2
  29. package/eject-assets/generators/python/models.ts +1 -1
  30. package/eject-assets/generators/python/naming.ts +1 -1
  31. package/eject-assets/generators/python/operations.ts +1 -1
  32. package/eject-assets/generators/python/pagination.ts +1 -1
  33. package/eject-assets/generators/python/types.ts +1 -1
  34. package/eject-assets/generators/swr/index.ts +2 -2
  35. package/eject-assets/generators/swr/render.ts +1 -1
  36. package/eject-assets/generators/tanstack-query/index.ts +2 -2
  37. package/eject-assets/generators/tanstack-query/render.ts +1 -1
  38. package/eject-assets/generators/transformers/index.ts +2 -2
  39. package/eject-assets/generators/transformers/render.ts +1 -1
  40. package/eject-assets/generators/typescript/banner.ts +1 -1
  41. package/eject-assets/generators/typescript/client.ts +1 -1
  42. package/eject-assets/generators/typescript/descriptor.ts +1 -1
  43. package/eject-assets/generators/typescript/index.ts +2 -2
  44. package/eject-assets/generators/typescript/inline-runtime.ts +1 -1
  45. package/eject-assets/generators/typescript/operation-signature.ts +1 -1
  46. package/eject-assets/generators/typescript/operation-types.ts +1 -1
  47. package/eject-assets/generators/typescript/operations.ts +1 -1
  48. package/eject-assets/generators/typescript/response-headers.ts +1 -1
  49. package/eject-assets/generators/typescript/type-guards.ts +1 -1
  50. package/eject-assets/generators/typescript/types.ts +1 -1
  51. package/eject-assets/generators/zod/index.ts +2 -2
  52. package/eject-assets/generators/zod/schemas.ts +1 -1
  53. package/lib/generators/typescript/telemetry/telemetry.d.ts.map +1 -1
  54. package/lib/generators/typescript/telemetry/telemetry.js +72 -11
  55. package/lib/generators/typescript/telemetry/telemetry.js.map +1 -1
  56. package/lib/runtime-sources/telemetry.d.ts +1 -1
  57. package/lib/runtime-sources/telemetry.d.ts.map +1 -1
  58. package/lib/runtime-sources/telemetry.js +1 -1
  59. package/lib/runtime-sources/telemetry.js.map +1 -1
  60. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "cli" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "cli" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator cli --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "cli" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "cli" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator cli --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "cli" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "cli" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator cli --update`.
@@ -86,5 +86,5 @@ export default {
86
86
  docs: cliDocs,
87
87
  requires: ["typescript","zod"],
88
88
  errorModes: ["throw"],
89
- requiresGenerator: '^0.7.12',
89
+ requiresGenerator: '^0.7.13',
90
90
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "cli" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "cli" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator cli --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -332,5 +332,5 @@ export default {
332
332
  "argsStyle": "inputs follow the target language's own idiom",
333
333
  "importExt": "the generated file has no relative imports"
334
334
  },
335
- requiresGenerator: '^0.7.12',
335
+ requiresGenerator: '^0.7.13',
336
336
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "mock" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "mock" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator mock --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "mock" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "mock" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator mock --update`.
@@ -32,5 +32,5 @@ export default {
32
32
  name: 'mock',
33
33
  run: mockGenerator,
34
34
  requires: ["typescript"],
35
- requiresGenerator: '^0.7.12',
35
+ requiresGenerator: '^0.7.13',
36
36
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "mock" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "mock" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator mock --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "mock" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "mock" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator mock --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "mock" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "mock" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator mock --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -234,5 +234,5 @@ export default {
234
234
  "argsStyle": "inputs follow the target language's own idiom",
235
235
  "importExt": "the generated file has no relative imports"
236
236
  },
237
- requiresGenerator: '^0.7.12',
237
+ requiresGenerator: '^0.7.13',
238
238
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -247,5 +247,5 @@ export default {
247
247
  "argsStyle": "inputs follow the target language's own idiom",
248
248
  "importExt": "the generated file has no relative imports"
249
249
  },
250
- requiresGenerator: '^0.7.12',
250
+ requiresGenerator: '^0.7.13',
251
251
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "swr" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "swr" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator swr --update`.
@@ -33,5 +33,5 @@ export default {
33
33
  run: swrGenerator,
34
34
  requires: ["typescript"],
35
35
  errorModes: ["throw"],
36
- requiresGenerator: '^0.7.12',
36
+ requiresGenerator: '^0.7.13',
37
37
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "swr" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "swr" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator swr --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "tanstack-query" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "tanstack-query" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator tanstack-query --update`.
@@ -44,5 +44,5 @@ export default {
44
44
  run: tanstackQueryGenerator('react'),
45
45
  requires: ["typescript"],
46
46
  errorModes: ["throw"],
47
- requiresGenerator: '^0.7.12',
47
+ requiresGenerator: '^0.7.13',
48
48
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "tanstack-query" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "tanstack-query" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator tanstack-query --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "transformers" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "transformers" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator transformers --update`.
@@ -42,5 +42,5 @@ export default {
42
42
  run: transformersGenerator,
43
43
  requires: ["typescript"],
44
44
  dateTypes: ["Date"],
45
- requiresGenerator: '^0.7.12',
45
+ requiresGenerator: '^0.7.13',
46
46
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "transformers" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "transformers" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator transformers --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -123,5 +123,5 @@ export default {
123
123
  run: typescriptGenerator,
124
124
  sample: typescriptSample,
125
125
  docs: typescriptDocs,
126
- requiresGenerator: '^0.7.12',
126
+ requiresGenerator: '^0.7.13',
127
127
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "zod" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "zod" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator zod --update`.
@@ -28,5 +28,5 @@ export const zodGenerator: Generator = ({ model, output, banner }) => {
28
28
  export default {
29
29
  name: 'zod',
30
30
  run: zodGenerator,
31
- requiresGenerator: '^0.7.12',
31
+ requiresGenerator: '^0.7.13',
32
32
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.7.12 — the built-in "zod" generator.
1
+ // Ejected from @redocly/client-generator@0.7.13 — the built-in "zod" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator zod --update`.
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../../src/generators/typescript/telemetry/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,8BAA8B,CAAC;AAI5E,QAAA,MAAM,UAAU,oCAAoC,CAAC;AAyBrD,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,UAAU,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;QACvC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAmCF,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAG3C;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,UAAU,CA8D/D"}
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../../src/generators/typescript/telemetry/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,8BAA8B,CAAC;AAI5E,QAAA,MAAM,UAAU,oCAAoC,CAAC;AAyBrD,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,UAAU,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;QACvC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAqCF,wBAAgB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAErC;AAOD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,UAAU,CAiF/D"}
@@ -40,9 +40,12 @@ function telemetryDisabled() {
40
40
  return true;
41
41
  return false;
42
42
  }
43
- export async function flush() {
43
+ export function flush() {
44
+ return flushWindows('keep');
45
+ }
46
+ async function flushWindows(onFailedSend) {
44
47
  for (const flushWindow of activeWindows)
45
- void flushWindow();
48
+ void flushWindow(onFailedSend);
46
49
  await Promise.all(pendingSends);
47
50
  }
48
51
  export function telemetry(options) {
@@ -74,7 +77,13 @@ export function telemetry(options) {
74
77
  let counts = new Map();
75
78
  let windowStart = 0;
76
79
  let timer;
77
- async function flushWindow() {
80
+ function openWindow() {
81
+ windowStart = Date.now();
82
+ timer = setTimeout(() => void flushWindow('keep'), intervalMs);
83
+ unrefTimer(timer);
84
+ activeWindows.add(flushWindow);
85
+ }
86
+ async function flushWindow(onFailedSend) {
78
87
  if (counts.size === 0)
79
88
  return;
80
89
  if (timer !== undefined)
@@ -82,25 +91,41 @@ export function telemetry(options) {
82
91
  timer = undefined;
83
92
  activeWindows.delete(flushWindow);
84
93
  const events = toEvents(counts, windowStart, Date.now() - windowStart, options.sdkName, sdk);
94
+ const sentCounts = counts;
95
+ const sentWindowStart = windowStart;
85
96
  counts = new Map();
86
97
  if (telemetryDisabled())
87
98
  return;
99
+ let action;
88
100
  const send = Promise.resolve()
89
101
  .then(() => sink(events))
90
- .catch(() => undefined);
102
+ .catch((error) => {
103
+ action = actionForFailedSend(error);
104
+ });
91
105
  pendingSends.add(send);
92
106
  await send;
93
107
  pendingSends.delete(send);
108
+ if (action !== 'keep' || onFailedSend === 'drop')
109
+ return;
110
+ if (counts.size === 0)
111
+ openWindow();
112
+ if (sentWindowStart < windowStart)
113
+ windowStart = sentWindowStart;
114
+ for (const [operationId, sentOperation] of sentCounts) {
115
+ const operation = counts.get(operationId);
116
+ if (operation === undefined) {
117
+ counts.set(operationId, sentOperation);
118
+ }
119
+ else {
120
+ addCounts(operation, sentOperation);
121
+ }
122
+ }
94
123
  }
95
124
  installExitHook();
96
125
  return {
97
126
  onSettled: (ctx, call) => {
98
- if (counts.size === 0) {
99
- windowStart = Date.now();
100
- timer = setTimeout(() => void flushWindow(), intervalMs);
101
- unrefTimer(timer);
102
- activeWindows.add(flushWindow);
103
- }
127
+ if (counts.size === 0)
128
+ openWindow();
104
129
  let operation = counts.get(ctx.operation.id);
105
130
  if (operation === undefined) {
106
131
  operation = emptyCounts();
@@ -114,7 +139,9 @@ function installExitHook() {
114
139
  if (exitHookInstalled)
115
140
  return;
116
141
  exitHookInstalled = true;
117
- nodeProcess()?.on?.('beforeExit', () => void flush());
142
+ // Node emits `beforeExit` again after each send at exit.
143
+ // Kept counts then cause one more send each time, so a failed send here drops its counts.
144
+ nodeProcess()?.on?.('beforeExit', () => void flushWindows('drop'));
118
145
  }
119
146
  function unrefTimer(timer) {
120
147
  if (timer instanceof Object && 'unref' in timer && typeof timer.unref === 'function') {
@@ -142,6 +169,17 @@ function record(operation, call) {
142
169
  }
143
170
  }
144
171
  }
172
+ function addCounts(target, source) {
173
+ target.calls += source.calls;
174
+ target.attempts += source.attempts;
175
+ target.durationSumMs += source.durationSumMs;
176
+ for (const statusClass of STATUS_CLASSES) {
177
+ target.status[statusClass] += source.status[statusClass];
178
+ }
179
+ for (const { bucket } of LATENCY_BUCKETS) {
180
+ target.latency[bucket] += source.latency[bucket];
181
+ }
182
+ }
145
183
  function statusClass(call) {
146
184
  if (call.response === undefined) {
147
185
  if (call.error instanceof Error && call.error.name === 'TimeoutError')
@@ -200,6 +238,29 @@ async function sendOtlp(endpoint, events) {
200
238
  signal: AbortSignal.timeout(SEND_TIMEOUT_MS),
201
239
  });
202
240
  await response.body?.cancel();
241
+ if (!response.ok) {
242
+ throw new RejectedSendError(response.status);
243
+ }
244
+ }
245
+ class RejectedSendError extends Error {
246
+ status;
247
+ constructor(status) {
248
+ super(`The telemetry endpoint answered ${status}.`);
249
+ this.name = 'RejectedSendError';
250
+ this.status = status;
251
+ }
252
+ }
253
+ function actionForFailedSend(error) {
254
+ // The endpoint can have stored the counts of a send that timed out.
255
+ if (error instanceof Error && error.name === 'TimeoutError')
256
+ return 'drop';
257
+ if (error instanceof RejectedSendError) {
258
+ if (error.status === 408 || error.status === 429 || error.status >= 500)
259
+ return 'keep';
260
+ // The endpoint refuses the same counts again.
261
+ return 'drop';
262
+ }
263
+ return 'keep';
203
264
  }
204
265
  function toOtlpRequest(events) {
205
266
  const spans = [];
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../../../src/generators/typescript/telemetry/telemetry.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAW,KAAK,CAAC;AACxC,MAAM,gBAAgB,GAAG,0CAA0C,CAAC;AACpE,MAAM,UAAU,GAAG,iCAAiC,CAAC;AACrD,MAA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AAE,KAAK,EAAE,EAAE,CAAC;IAC7E,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC;IACxE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,SAAS,CAAC,SAAiB;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IAChE,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACpE,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const TELEMETRY_RUNTIME_SOURCE = "import type { Middleware, SettledCall } from '../../../runtime-contract.js';\n\nconst GENERATOR_VERSION: string = 'dev';\nconst DEFAULT_ENDPOINT = 'https://otel.cloud.redocly.com/v1/traces';\nconst EVENT_TYPE = 'com.redocly.sdkUsage.aggregated';\nconst SEND_TIMEOUT_MS = 3000;\nconst SERVICE_NAME = 'redocly-sdk';\n\ntype StatusClass = '2xx' | '3xx' | '4xx' | '5xx' | 'network_error' | 'timeout' | 'aborted';\ntype LatencyBucket = 'lt_100ms' | 'lt_300ms' | 'lt_1s' | 'lt_3s' | 'lt_10s' | 'gte_10s';\n\nconst STATUS_CLASSES: StatusClass[] = [\n '2xx',\n '3xx',\n '4xx',\n '5xx',\n 'network_error',\n 'timeout',\n 'aborted',\n];\nconst LATENCY_BUCKETS: Array<{ bucket: LatencyBucket; belowMs: number }> = [\n { bucket: 'lt_100ms', belowMs: 100 },\n { bucket: 'lt_300ms', belowMs: 300 },\n { bucket: 'lt_1s', belowMs: 1000 },\n { bucket: 'lt_3s', belowMs: 3000 },\n { bucket: 'lt_10s', belowMs: 10000 },\n { bucket: 'gte_10s', belowMs: Infinity },\n];\n\nexport type SdkUsageEvent = {\n id: string;\n type: typeof EVENT_TYPE;\n source: string;\n time: string;\n data: {\n usage: Record<string, string | number>;\n sdk: Record<string, string>;\n };\n};\n\nexport type TelemetryOptions = {\n sdkName: string;\n sdkVersion: string;\n client: string;\n sink?: (events: SdkUsageEvent[]) => void | Promise<void>;\n endpoint?: string;\n flushIntervalMs?: number;\n};\n\ntype OperationCounts = {\n calls: number;\n attempts: number;\n durationSumMs: number;\n status: Record<StatusClass, number>;\n latency: Record<LatencyBucket, number>;\n};\n\ntype ProcessLike = {\n env?: Record<string, string | undefined>;\n versions?: { node?: string; bun?: string; deno?: string };\n on?: (event: 'beforeExit', listener: () => void) => void;\n};\n\nconst activeWindows = new Set<() => Promise<void>>();\nconst pendingSends = new Set<Promise<void>>();\nlet exitHookInstalled = false;\n\nfunction nodeProcess(): ProcessLike | undefined {\n return (globalThis as { process?: ProcessLike }).process;\n}\n\nfunction telemetryDisabled(): boolean {\n const runtimeProcess = nodeProcess();\n if (runtimeProcess === undefined) return true;\n // A browser bundle can add a `process` shim, so also check for `document`.\n if (typeof document !== 'undefined') return true;\n const env = runtimeProcess.env ?? {};\n if (env.REDOCLY_SDK_TELEMETRY === 'off') return true;\n if (env.DO_NOT_TRACK === '1') return true;\n return false;\n}\n\nexport async function flush(): Promise<void> {\n for (const flushWindow of activeWindows) void flushWindow();\n await Promise.all(pendingSends);\n}\n\nexport function telemetry(options: TelemetryOptions): Middleware {\n if (telemetryDisabled()) return {};\n const intervalMs = options.flushIntervalMs ?? 60_000;\n const endpoint = options.endpoint ?? DEFAULT_ENDPOINT;\n const sink = options.sink ?? ((events: SdkUsageEvent[]) => sendOtlp(endpoint, events));\n const versions = nodeProcess()?.versions ?? {};\n let runtime = 'node';\n let runtimeVersion = versions.node ?? '';\n if (versions.bun !== undefined) {\n runtime = 'bun';\n runtimeVersion = versions.bun;\n } else if (versions.deno !== undefined) {\n runtime = 'deno';\n runtimeVersion = versions.deno;\n }\n const sdk: Record<string, string> = {\n name: options.sdkName,\n version: options.sdkVersion,\n generator_version: GENERATOR_VERSION,\n language: 'typescript',\n runtime,\n runtime_version: runtimeVersion,\n client: options.client,\n };\n let counts = new Map<string, OperationCounts>();\n let windowStart = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n async function flushWindow(): Promise<void> {\n if (counts.size === 0) return;\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n activeWindows.delete(flushWindow);\n const events = toEvents(counts, windowStart, Date.now() - windowStart, options.sdkName, sdk);\n counts = new Map();\n if (telemetryDisabled()) return;\n const send = Promise.resolve()\n .then(() => sink(events))\n .catch(() => undefined);\n pendingSends.add(send);\n await send;\n pendingSends.delete(send);\n }\n\n installExitHook();\n\n return {\n onSettled: (ctx, call) => {\n if (counts.size === 0) {\n windowStart = Date.now();\n timer = setTimeout(() => void flushWindow(), intervalMs);\n unrefTimer(timer);\n activeWindows.add(flushWindow);\n }\n let operation = counts.get(ctx.operation.id);\n if (operation === undefined) {\n operation = emptyCounts();\n counts.set(ctx.operation.id, operation);\n }\n record(operation, call);\n },\n };\n}\n\nfunction installExitHook(): void {\n if (exitHookInstalled) return;\n exitHookInstalled = true;\n nodeProcess()?.on?.('beforeExit', () => void flush());\n}\n\nfunction unrefTimer(timer: unknown): void {\n if (timer instanceof Object && 'unref' in timer && typeof timer.unref === 'function') {\n timer.unref();\n }\n}\n\nfunction emptyCounts(): OperationCounts {\n return {\n calls: 0,\n attempts: 0,\n durationSumMs: 0,\n status: { '2xx': 0, '3xx': 0, '4xx': 0, '5xx': 0, network_error: 0, timeout: 0, aborted: 0 },\n latency: { lt_100ms: 0, lt_300ms: 0, lt_1s: 0, lt_3s: 0, lt_10s: 0, gte_10s: 0 },\n };\n}\n\nfunction record(operation: OperationCounts, call: SettledCall): void {\n operation.calls += 1;\n operation.attempts += call.attempts;\n operation.durationSumMs += call.durationMs;\n operation.status[statusClass(call)] += 1;\n for (const { bucket, belowMs } of LATENCY_BUCKETS) {\n if (call.durationMs < belowMs) {\n operation.latency[bucket] += 1;\n break;\n }\n }\n}\n\nfunction statusClass(call: SettledCall): StatusClass {\n if (call.response === undefined) {\n if (call.error instanceof Error && call.error.name === 'TimeoutError') return 'timeout';\n if (call.error instanceof Error && call.error.name === 'AbortError') return 'aborted';\n return 'network_error';\n }\n const status = call.response.status;\n if (status >= 500) return '5xx';\n if (status >= 400) return '4xx';\n if (status >= 300) return '3xx';\n return '2xx';\n}\n\nfunction toEvents(\n counts: Map<string, OperationCounts>,\n windowStart: number,\n windowMs: number,\n source: string,\n sdk: Record<string, string>\n): SdkUsageEvent[] {\n const events: SdkUsageEvent[] = [];\n for (const [operationId, operation] of counts) {\n const usage: Record<string, string | number> = {\n operation_id: operationId,\n window_ms: windowMs,\n calls: operation.calls,\n attempts: operation.attempts,\n duration_sum_ms: operation.durationSumMs,\n };\n for (const statusClass of STATUS_CLASSES) {\n const count = operation.status[statusClass];\n if (count > 0) {\n usage[`status_${statusClass}`] = count;\n }\n }\n for (const { bucket } of LATENCY_BUCKETS) {\n const count = operation.latency[bucket];\n if (count > 0) {\n usage[`latency_${bucket}`] = count;\n }\n }\n events.push({\n id: `evt_${randomHex(16)}`,\n type: EVENT_TYPE,\n source,\n time: new Date(windowStart).toISOString(),\n data: { usage, sdk },\n });\n }\n return events;\n}\n\nasync function sendOtlp(endpoint: string, events: SdkUsageEvent[]): Promise<void> {\n const response = await fetch(endpoint, {\n method: 'POST',\n // One send per window, so the socket is never reused: close it instead of keeping it idle.\n headers: { 'Content-Type': 'application/json', Connection: 'close' },\n body: JSON.stringify(toOtlpRequest(events)),\n signal: AbortSignal.timeout(SEND_TIMEOUT_MS),\n });\n await response.body?.cancel();\n}\n\ntype OtlpValue = { stringValue: string } | { intValue: number } | { doubleValue: number };\ntype OtlpAttribute = { key: string; value: OtlpValue };\n\nfunction toOtlpRequest(events: SdkUsageEvent[]) {\n const spans = [];\n for (const event of events) {\n const timeUnixNano = `${Date.parse(event.time)}000000`;\n const attributes: OtlpAttribute[] = [\n attribute('cloudevents.event_id', event.id),\n attribute('cloudevents.event_type', event.type),\n attribute('cloudevents.event_source', event.source),\n attribute('cloudevents.event_spec_version', '1.0'),\n attribute('cloudevents.event_data_content_type', 'application/json; charset=utf-8'),\n attribute('cloudevents.event_time', event.time),\n attribute('cloudevents.event_subject', ''),\n attribute('cloudevents.event_origin', SERVICE_NAME),\n attribute('cloudevents.event_object', 'event'),\n attribute('cloudevents.event_category', 'product'),\n attribute('cloudevents.event_signal', 'metric'),\n ];\n for (const [key, value] of Object.entries(event.data.usage)) {\n attributes.push(attribute(`cloudevents.event_data.usage.${key}`, value));\n }\n for (const [key, value] of Object.entries(event.data.sdk)) {\n attributes.push(attribute(`cloudevents.event_data.sdk.${key}`, value));\n }\n spans.push({\n traceId: randomHex(16),\n spanId: randomHex(8),\n name: `event.${event.type}`,\n kind: 1,\n startTimeUnixNano: timeUnixNano,\n endTimeUnixNano: timeUnixNano,\n attributes,\n });\n }\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n attribute('service.name', SERVICE_NAME),\n attribute('service.version', GENERATOR_VERSION),\n ],\n },\n scopeSpans: [{ scope: { name: 'redocly-sdk-telemetry' }, spans }],\n },\n ],\n };\n}\n\nfunction attribute(key: string, value: string | number): OtlpAttribute {\n if (typeof value === 'string') return { key, value: { stringValue: value } };\n if (Number.isInteger(value)) return { key, value: { intValue: value } };\n return { key, value: { doubleValue: value } };\n}\n\nfunction randomHex(byteCount: number): string {\n const bytes = crypto.getRandomValues(new Uint8Array(byteCount));\n let hex = '';\n for (const byte of bytes) hex += byte.toString(16).padStart(2, '0');\n return hex;\n}\n";
1
+ export declare const TELEMETRY_RUNTIME_SOURCE = "import type { Middleware, SettledCall } from '../../../runtime-contract.js';\n\nconst GENERATOR_VERSION: string = 'dev';\nconst DEFAULT_ENDPOINT = 'https://otel.cloud.redocly.com/v1/traces';\nconst EVENT_TYPE = 'com.redocly.sdkUsage.aggregated';\nconst SEND_TIMEOUT_MS = 3000;\nconst SERVICE_NAME = 'redocly-sdk';\n\ntype StatusClass = '2xx' | '3xx' | '4xx' | '5xx' | 'network_error' | 'timeout' | 'aborted';\ntype LatencyBucket = 'lt_100ms' | 'lt_300ms' | 'lt_1s' | 'lt_3s' | 'lt_10s' | 'gte_10s';\n\nconst STATUS_CLASSES: StatusClass[] = [\n '2xx',\n '3xx',\n '4xx',\n '5xx',\n 'network_error',\n 'timeout',\n 'aborted',\n];\nconst LATENCY_BUCKETS: Array<{ bucket: LatencyBucket; belowMs: number }> = [\n { bucket: 'lt_100ms', belowMs: 100 },\n { bucket: 'lt_300ms', belowMs: 300 },\n { bucket: 'lt_1s', belowMs: 1000 },\n { bucket: 'lt_3s', belowMs: 3000 },\n { bucket: 'lt_10s', belowMs: 10000 },\n { bucket: 'gte_10s', belowMs: Infinity },\n];\n\nexport type SdkUsageEvent = {\n id: string;\n type: typeof EVENT_TYPE;\n source: string;\n time: string;\n data: {\n usage: Record<string, string | number>;\n sdk: Record<string, string>;\n };\n};\n\nexport type TelemetryOptions = {\n sdkName: string;\n sdkVersion: string;\n client: string;\n sink?: (events: SdkUsageEvent[]) => void | Promise<void>;\n endpoint?: string;\n flushIntervalMs?: number;\n};\n\ntype OperationCounts = {\n calls: number;\n attempts: number;\n durationSumMs: number;\n status: Record<StatusClass, number>;\n latency: Record<LatencyBucket, number>;\n};\n\ntype ProcessLike = {\n env?: Record<string, string | undefined>;\n versions?: { node?: string; bun?: string; deno?: string };\n on?: (event: 'beforeExit', listener: () => void) => void;\n};\n\ntype OnFailedSend = 'keep' | 'drop';\n\nconst activeWindows = new Set<(onFailedSend: OnFailedSend) => Promise<void>>();\nconst pendingSends = new Set<Promise<void>>();\nlet exitHookInstalled = false;\n\nfunction nodeProcess(): ProcessLike | undefined {\n return (globalThis as { process?: ProcessLike }).process;\n}\n\nfunction telemetryDisabled(): boolean {\n const runtimeProcess = nodeProcess();\n if (runtimeProcess === undefined) return true;\n // A browser bundle can add a `process` shim, so also check for `document`.\n if (typeof document !== 'undefined') return true;\n const env = runtimeProcess.env ?? {};\n if (env.REDOCLY_SDK_TELEMETRY === 'off') return true;\n if (env.DO_NOT_TRACK === '1') return true;\n return false;\n}\n\nexport function flush(): Promise<void> {\n return flushWindows('keep');\n}\n\nasync function flushWindows(onFailedSend: OnFailedSend): Promise<void> {\n for (const flushWindow of activeWindows) void flushWindow(onFailedSend);\n await Promise.all(pendingSends);\n}\n\nexport function telemetry(options: TelemetryOptions): Middleware {\n if (telemetryDisabled()) return {};\n const intervalMs = options.flushIntervalMs ?? 60_000;\n const endpoint = options.endpoint ?? DEFAULT_ENDPOINT;\n const sink = options.sink ?? ((events: SdkUsageEvent[]) => sendOtlp(endpoint, events));\n const versions = nodeProcess()?.versions ?? {};\n let runtime = 'node';\n let runtimeVersion = versions.node ?? '';\n if (versions.bun !== undefined) {\n runtime = 'bun';\n runtimeVersion = versions.bun;\n } else if (versions.deno !== undefined) {\n runtime = 'deno';\n runtimeVersion = versions.deno;\n }\n const sdk: Record<string, string> = {\n name: options.sdkName,\n version: options.sdkVersion,\n generator_version: GENERATOR_VERSION,\n language: 'typescript',\n runtime,\n runtime_version: runtimeVersion,\n client: options.client,\n };\n let counts = new Map<string, OperationCounts>();\n let windowStart = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n function openWindow(): void {\n windowStart = Date.now();\n timer = setTimeout(() => void flushWindow('keep'), intervalMs);\n unrefTimer(timer);\n activeWindows.add(flushWindow);\n }\n\n async function flushWindow(onFailedSend: OnFailedSend): Promise<void> {\n if (counts.size === 0) return;\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n activeWindows.delete(flushWindow);\n const events = toEvents(counts, windowStart, Date.now() - windowStart, options.sdkName, sdk);\n const sentCounts = counts;\n const sentWindowStart = windowStart;\n counts = new Map();\n if (telemetryDisabled()) return;\n let action: OnFailedSend | undefined;\n const send = Promise.resolve()\n .then(() => sink(events))\n .catch((error: unknown) => {\n action = actionForFailedSend(error);\n });\n pendingSends.add(send);\n await send;\n pendingSends.delete(send);\n if (action !== 'keep' || onFailedSend === 'drop') return;\n\n if (counts.size === 0) openWindow();\n if (sentWindowStart < windowStart) windowStart = sentWindowStart;\n for (const [operationId, sentOperation] of sentCounts) {\n const operation = counts.get(operationId);\n if (operation === undefined) {\n counts.set(operationId, sentOperation);\n } else {\n addCounts(operation, sentOperation);\n }\n }\n }\n\n installExitHook();\n\n return {\n onSettled: (ctx, call) => {\n if (counts.size === 0) openWindow();\n let operation = counts.get(ctx.operation.id);\n if (operation === undefined) {\n operation = emptyCounts();\n counts.set(ctx.operation.id, operation);\n }\n record(operation, call);\n },\n };\n}\n\nfunction installExitHook(): void {\n if (exitHookInstalled) return;\n exitHookInstalled = true;\n // Node emits `beforeExit` again after each send at exit.\n // Kept counts then cause one more send each time, so a failed send here drops its counts.\n nodeProcess()?.on?.('beforeExit', () => void flushWindows('drop'));\n}\n\nfunction unrefTimer(timer: unknown): void {\n if (timer instanceof Object && 'unref' in timer && typeof timer.unref === 'function') {\n timer.unref();\n }\n}\n\nfunction emptyCounts(): OperationCounts {\n return {\n calls: 0,\n attempts: 0,\n durationSumMs: 0,\n status: { '2xx': 0, '3xx': 0, '4xx': 0, '5xx': 0, network_error: 0, timeout: 0, aborted: 0 },\n latency: { lt_100ms: 0, lt_300ms: 0, lt_1s: 0, lt_3s: 0, lt_10s: 0, gte_10s: 0 },\n };\n}\n\nfunction record(operation: OperationCounts, call: SettledCall): void {\n operation.calls += 1;\n operation.attempts += call.attempts;\n operation.durationSumMs += call.durationMs;\n operation.status[statusClass(call)] += 1;\n for (const { bucket, belowMs } of LATENCY_BUCKETS) {\n if (call.durationMs < belowMs) {\n operation.latency[bucket] += 1;\n break;\n }\n }\n}\n\nfunction addCounts(target: OperationCounts, source: OperationCounts): void {\n target.calls += source.calls;\n target.attempts += source.attempts;\n target.durationSumMs += source.durationSumMs;\n for (const statusClass of STATUS_CLASSES) {\n target.status[statusClass] += source.status[statusClass];\n }\n for (const { bucket } of LATENCY_BUCKETS) {\n target.latency[bucket] += source.latency[bucket];\n }\n}\n\nfunction statusClass(call: SettledCall): StatusClass {\n if (call.response === undefined) {\n if (call.error instanceof Error && call.error.name === 'TimeoutError') return 'timeout';\n if (call.error instanceof Error && call.error.name === 'AbortError') return 'aborted';\n return 'network_error';\n }\n const status = call.response.status;\n if (status >= 500) return '5xx';\n if (status >= 400) return '4xx';\n if (status >= 300) return '3xx';\n return '2xx';\n}\n\nfunction toEvents(\n counts: Map<string, OperationCounts>,\n windowStart: number,\n windowMs: number,\n source: string,\n sdk: Record<string, string>\n): SdkUsageEvent[] {\n const events: SdkUsageEvent[] = [];\n for (const [operationId, operation] of counts) {\n const usage: Record<string, string | number> = {\n operation_id: operationId,\n window_ms: windowMs,\n calls: operation.calls,\n attempts: operation.attempts,\n duration_sum_ms: operation.durationSumMs,\n };\n for (const statusClass of STATUS_CLASSES) {\n const count = operation.status[statusClass];\n if (count > 0) {\n usage[`status_${statusClass}`] = count;\n }\n }\n for (const { bucket } of LATENCY_BUCKETS) {\n const count = operation.latency[bucket];\n if (count > 0) {\n usage[`latency_${bucket}`] = count;\n }\n }\n events.push({\n id: `evt_${randomHex(16)}`,\n type: EVENT_TYPE,\n source,\n time: new Date(windowStart).toISOString(),\n data: { usage, sdk },\n });\n }\n return events;\n}\n\nasync function sendOtlp(endpoint: string, events: SdkUsageEvent[]): Promise<void> {\n const response = await fetch(endpoint, {\n method: 'POST',\n // One send per window, so the socket is never reused: close it instead of keeping it idle.\n headers: { 'Content-Type': 'application/json', Connection: 'close' },\n body: JSON.stringify(toOtlpRequest(events)),\n signal: AbortSignal.timeout(SEND_TIMEOUT_MS),\n });\n await response.body?.cancel();\n if (!response.ok) {\n throw new RejectedSendError(response.status);\n }\n}\n\nclass RejectedSendError extends Error {\n public readonly status: number;\n constructor(status: number) {\n super(`The telemetry endpoint answered ${status}.`);\n this.name = 'RejectedSendError';\n this.status = status;\n }\n}\n\nfunction actionForFailedSend(error: unknown): OnFailedSend {\n // The endpoint can have stored the counts of a send that timed out.\n if (error instanceof Error && error.name === 'TimeoutError') return 'drop';\n if (error instanceof RejectedSendError) {\n if (error.status === 408 || error.status === 429 || error.status >= 500) return 'keep';\n // The endpoint refuses the same counts again.\n return 'drop';\n }\n return 'keep';\n}\n\ntype OtlpValue = { stringValue: string } | { intValue: number } | { doubleValue: number };\ntype OtlpAttribute = { key: string; value: OtlpValue };\n\nfunction toOtlpRequest(events: SdkUsageEvent[]) {\n const spans = [];\n for (const event of events) {\n const timeUnixNano = `${Date.parse(event.time)}000000`;\n const attributes: OtlpAttribute[] = [\n attribute('cloudevents.event_id', event.id),\n attribute('cloudevents.event_type', event.type),\n attribute('cloudevents.event_source', event.source),\n attribute('cloudevents.event_spec_version', '1.0'),\n attribute('cloudevents.event_data_content_type', 'application/json; charset=utf-8'),\n attribute('cloudevents.event_time', event.time),\n attribute('cloudevents.event_subject', ''),\n attribute('cloudevents.event_origin', SERVICE_NAME),\n attribute('cloudevents.event_object', 'event'),\n attribute('cloudevents.event_category', 'product'),\n attribute('cloudevents.event_signal', 'metric'),\n ];\n for (const [key, value] of Object.entries(event.data.usage)) {\n attributes.push(attribute(`cloudevents.event_data.usage.${key}`, value));\n }\n for (const [key, value] of Object.entries(event.data.sdk)) {\n attributes.push(attribute(`cloudevents.event_data.sdk.${key}`, value));\n }\n spans.push({\n traceId: randomHex(16),\n spanId: randomHex(8),\n name: `event.${event.type}`,\n kind: 1,\n startTimeUnixNano: timeUnixNano,\n endTimeUnixNano: timeUnixNano,\n attributes,\n });\n }\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n attribute('service.name', SERVICE_NAME),\n attribute('service.version', GENERATOR_VERSION),\n ],\n },\n scopeSpans: [{ scope: { name: 'redocly-sdk-telemetry' }, spans }],\n },\n ],\n };\n}\n\nfunction attribute(key: string, value: string | number): OtlpAttribute {\n if (typeof value === 'string') return { key, value: { stringValue: value } };\n if (Number.isInteger(value)) return { key, value: { intValue: value } };\n return { key, value: { doubleValue: value } };\n}\n\nfunction randomHex(byteCount: number): string {\n const bytes = crypto.getRandomValues(new Uint8Array(byteCount));\n let hex = '';\n for (const byte of bytes) hex += byte.toString(16).padStart(2, '0');\n return hex;\n}\n";
2
2
  //# sourceMappingURL=telemetry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/runtime-sources/telemetry.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,wBAAwB,49TACs7T,CAAC"}
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/runtime-sources/telemetry.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,wBAAwB,6pYACunY,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // GENERATED by scripts/generate-runtime-sources.mjs — do not edit. Regenerated on install (`prepare`); manually: `npm run prepare -w @redocly/client-generator`.
2
- export const TELEMETRY_RUNTIME_SOURCE = "import type { Middleware, SettledCall } from '../../../runtime-contract.js';\n\nconst GENERATOR_VERSION: string = 'dev';\nconst DEFAULT_ENDPOINT = 'https://otel.cloud.redocly.com/v1/traces';\nconst EVENT_TYPE = 'com.redocly.sdkUsage.aggregated';\nconst SEND_TIMEOUT_MS = 3000;\nconst SERVICE_NAME = 'redocly-sdk';\n\ntype StatusClass = '2xx' | '3xx' | '4xx' | '5xx' | 'network_error' | 'timeout' | 'aborted';\ntype LatencyBucket = 'lt_100ms' | 'lt_300ms' | 'lt_1s' | 'lt_3s' | 'lt_10s' | 'gte_10s';\n\nconst STATUS_CLASSES: StatusClass[] = [\n '2xx',\n '3xx',\n '4xx',\n '5xx',\n 'network_error',\n 'timeout',\n 'aborted',\n];\nconst LATENCY_BUCKETS: Array<{ bucket: LatencyBucket; belowMs: number }> = [\n { bucket: 'lt_100ms', belowMs: 100 },\n { bucket: 'lt_300ms', belowMs: 300 },\n { bucket: 'lt_1s', belowMs: 1000 },\n { bucket: 'lt_3s', belowMs: 3000 },\n { bucket: 'lt_10s', belowMs: 10000 },\n { bucket: 'gte_10s', belowMs: Infinity },\n];\n\nexport type SdkUsageEvent = {\n id: string;\n type: typeof EVENT_TYPE;\n source: string;\n time: string;\n data: {\n usage: Record<string, string | number>;\n sdk: Record<string, string>;\n };\n};\n\nexport type TelemetryOptions = {\n sdkName: string;\n sdkVersion: string;\n client: string;\n sink?: (events: SdkUsageEvent[]) => void | Promise<void>;\n endpoint?: string;\n flushIntervalMs?: number;\n};\n\ntype OperationCounts = {\n calls: number;\n attempts: number;\n durationSumMs: number;\n status: Record<StatusClass, number>;\n latency: Record<LatencyBucket, number>;\n};\n\ntype ProcessLike = {\n env?: Record<string, string | undefined>;\n versions?: { node?: string; bun?: string; deno?: string };\n on?: (event: 'beforeExit', listener: () => void) => void;\n};\n\nconst activeWindows = new Set<() => Promise<void>>();\nconst pendingSends = new Set<Promise<void>>();\nlet exitHookInstalled = false;\n\nfunction nodeProcess(): ProcessLike | undefined {\n return (globalThis as { process?: ProcessLike }).process;\n}\n\nfunction telemetryDisabled(): boolean {\n const runtimeProcess = nodeProcess();\n if (runtimeProcess === undefined) return true;\n // A browser bundle can add a `process` shim, so also check for `document`.\n if (typeof document !== 'undefined') return true;\n const env = runtimeProcess.env ?? {};\n if (env.REDOCLY_SDK_TELEMETRY === 'off') return true;\n if (env.DO_NOT_TRACK === '1') return true;\n return false;\n}\n\nexport async function flush(): Promise<void> {\n for (const flushWindow of activeWindows) void flushWindow();\n await Promise.all(pendingSends);\n}\n\nexport function telemetry(options: TelemetryOptions): Middleware {\n if (telemetryDisabled()) return {};\n const intervalMs = options.flushIntervalMs ?? 60_000;\n const endpoint = options.endpoint ?? DEFAULT_ENDPOINT;\n const sink = options.sink ?? ((events: SdkUsageEvent[]) => sendOtlp(endpoint, events));\n const versions = nodeProcess()?.versions ?? {};\n let runtime = 'node';\n let runtimeVersion = versions.node ?? '';\n if (versions.bun !== undefined) {\n runtime = 'bun';\n runtimeVersion = versions.bun;\n } else if (versions.deno !== undefined) {\n runtime = 'deno';\n runtimeVersion = versions.deno;\n }\n const sdk: Record<string, string> = {\n name: options.sdkName,\n version: options.sdkVersion,\n generator_version: GENERATOR_VERSION,\n language: 'typescript',\n runtime,\n runtime_version: runtimeVersion,\n client: options.client,\n };\n let counts = new Map<string, OperationCounts>();\n let windowStart = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n async function flushWindow(): Promise<void> {\n if (counts.size === 0) return;\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n activeWindows.delete(flushWindow);\n const events = toEvents(counts, windowStart, Date.now() - windowStart, options.sdkName, sdk);\n counts = new Map();\n if (telemetryDisabled()) return;\n const send = Promise.resolve()\n .then(() => sink(events))\n .catch(() => undefined);\n pendingSends.add(send);\n await send;\n pendingSends.delete(send);\n }\n\n installExitHook();\n\n return {\n onSettled: (ctx, call) => {\n if (counts.size === 0) {\n windowStart = Date.now();\n timer = setTimeout(() => void flushWindow(), intervalMs);\n unrefTimer(timer);\n activeWindows.add(flushWindow);\n }\n let operation = counts.get(ctx.operation.id);\n if (operation === undefined) {\n operation = emptyCounts();\n counts.set(ctx.operation.id, operation);\n }\n record(operation, call);\n },\n };\n}\n\nfunction installExitHook(): void {\n if (exitHookInstalled) return;\n exitHookInstalled = true;\n nodeProcess()?.on?.('beforeExit', () => void flush());\n}\n\nfunction unrefTimer(timer: unknown): void {\n if (timer instanceof Object && 'unref' in timer && typeof timer.unref === 'function') {\n timer.unref();\n }\n}\n\nfunction emptyCounts(): OperationCounts {\n return {\n calls: 0,\n attempts: 0,\n durationSumMs: 0,\n status: { '2xx': 0, '3xx': 0, '4xx': 0, '5xx': 0, network_error: 0, timeout: 0, aborted: 0 },\n latency: { lt_100ms: 0, lt_300ms: 0, lt_1s: 0, lt_3s: 0, lt_10s: 0, gte_10s: 0 },\n };\n}\n\nfunction record(operation: OperationCounts, call: SettledCall): void {\n operation.calls += 1;\n operation.attempts += call.attempts;\n operation.durationSumMs += call.durationMs;\n operation.status[statusClass(call)] += 1;\n for (const { bucket, belowMs } of LATENCY_BUCKETS) {\n if (call.durationMs < belowMs) {\n operation.latency[bucket] += 1;\n break;\n }\n }\n}\n\nfunction statusClass(call: SettledCall): StatusClass {\n if (call.response === undefined) {\n if (call.error instanceof Error && call.error.name === 'TimeoutError') return 'timeout';\n if (call.error instanceof Error && call.error.name === 'AbortError') return 'aborted';\n return 'network_error';\n }\n const status = call.response.status;\n if (status >= 500) return '5xx';\n if (status >= 400) return '4xx';\n if (status >= 300) return '3xx';\n return '2xx';\n}\n\nfunction toEvents(\n counts: Map<string, OperationCounts>,\n windowStart: number,\n windowMs: number,\n source: string,\n sdk: Record<string, string>\n): SdkUsageEvent[] {\n const events: SdkUsageEvent[] = [];\n for (const [operationId, operation] of counts) {\n const usage: Record<string, string | number> = {\n operation_id: operationId,\n window_ms: windowMs,\n calls: operation.calls,\n attempts: operation.attempts,\n duration_sum_ms: operation.durationSumMs,\n };\n for (const statusClass of STATUS_CLASSES) {\n const count = operation.status[statusClass];\n if (count > 0) {\n usage[`status_${statusClass}`] = count;\n }\n }\n for (const { bucket } of LATENCY_BUCKETS) {\n const count = operation.latency[bucket];\n if (count > 0) {\n usage[`latency_${bucket}`] = count;\n }\n }\n events.push({\n id: `evt_${randomHex(16)}`,\n type: EVENT_TYPE,\n source,\n time: new Date(windowStart).toISOString(),\n data: { usage, sdk },\n });\n }\n return events;\n}\n\nasync function sendOtlp(endpoint: string, events: SdkUsageEvent[]): Promise<void> {\n const response = await fetch(endpoint, {\n method: 'POST',\n // One send per window, so the socket is never reused: close it instead of keeping it idle.\n headers: { 'Content-Type': 'application/json', Connection: 'close' },\n body: JSON.stringify(toOtlpRequest(events)),\n signal: AbortSignal.timeout(SEND_TIMEOUT_MS),\n });\n await response.body?.cancel();\n}\n\ntype OtlpValue = { stringValue: string } | { intValue: number } | { doubleValue: number };\ntype OtlpAttribute = { key: string; value: OtlpValue };\n\nfunction toOtlpRequest(events: SdkUsageEvent[]) {\n const spans = [];\n for (const event of events) {\n const timeUnixNano = `${Date.parse(event.time)}000000`;\n const attributes: OtlpAttribute[] = [\n attribute('cloudevents.event_id', event.id),\n attribute('cloudevents.event_type', event.type),\n attribute('cloudevents.event_source', event.source),\n attribute('cloudevents.event_spec_version', '1.0'),\n attribute('cloudevents.event_data_content_type', 'application/json; charset=utf-8'),\n attribute('cloudevents.event_time', event.time),\n attribute('cloudevents.event_subject', ''),\n attribute('cloudevents.event_origin', SERVICE_NAME),\n attribute('cloudevents.event_object', 'event'),\n attribute('cloudevents.event_category', 'product'),\n attribute('cloudevents.event_signal', 'metric'),\n ];\n for (const [key, value] of Object.entries(event.data.usage)) {\n attributes.push(attribute(`cloudevents.event_data.usage.${key}`, value));\n }\n for (const [key, value] of Object.entries(event.data.sdk)) {\n attributes.push(attribute(`cloudevents.event_data.sdk.${key}`, value));\n }\n spans.push({\n traceId: randomHex(16),\n spanId: randomHex(8),\n name: `event.${event.type}`,\n kind: 1,\n startTimeUnixNano: timeUnixNano,\n endTimeUnixNano: timeUnixNano,\n attributes,\n });\n }\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n attribute('service.name', SERVICE_NAME),\n attribute('service.version', GENERATOR_VERSION),\n ],\n },\n scopeSpans: [{ scope: { name: 'redocly-sdk-telemetry' }, spans }],\n },\n ],\n };\n}\n\nfunction attribute(key: string, value: string | number): OtlpAttribute {\n if (typeof value === 'string') return { key, value: { stringValue: value } };\n if (Number.isInteger(value)) return { key, value: { intValue: value } };\n return { key, value: { doubleValue: value } };\n}\n\nfunction randomHex(byteCount: number): string {\n const bytes = crypto.getRandomValues(new Uint8Array(byteCount));\n let hex = '';\n for (const byte of bytes) hex += byte.toString(16).padStart(2, '0');\n return hex;\n}\n";
2
+ export const TELEMETRY_RUNTIME_SOURCE = "import type { Middleware, SettledCall } from '../../../runtime-contract.js';\n\nconst GENERATOR_VERSION: string = 'dev';\nconst DEFAULT_ENDPOINT = 'https://otel.cloud.redocly.com/v1/traces';\nconst EVENT_TYPE = 'com.redocly.sdkUsage.aggregated';\nconst SEND_TIMEOUT_MS = 3000;\nconst SERVICE_NAME = 'redocly-sdk';\n\ntype StatusClass = '2xx' | '3xx' | '4xx' | '5xx' | 'network_error' | 'timeout' | 'aborted';\ntype LatencyBucket = 'lt_100ms' | 'lt_300ms' | 'lt_1s' | 'lt_3s' | 'lt_10s' | 'gte_10s';\n\nconst STATUS_CLASSES: StatusClass[] = [\n '2xx',\n '3xx',\n '4xx',\n '5xx',\n 'network_error',\n 'timeout',\n 'aborted',\n];\nconst LATENCY_BUCKETS: Array<{ bucket: LatencyBucket; belowMs: number }> = [\n { bucket: 'lt_100ms', belowMs: 100 },\n { bucket: 'lt_300ms', belowMs: 300 },\n { bucket: 'lt_1s', belowMs: 1000 },\n { bucket: 'lt_3s', belowMs: 3000 },\n { bucket: 'lt_10s', belowMs: 10000 },\n { bucket: 'gte_10s', belowMs: Infinity },\n];\n\nexport type SdkUsageEvent = {\n id: string;\n type: typeof EVENT_TYPE;\n source: string;\n time: string;\n data: {\n usage: Record<string, string | number>;\n sdk: Record<string, string>;\n };\n};\n\nexport type TelemetryOptions = {\n sdkName: string;\n sdkVersion: string;\n client: string;\n sink?: (events: SdkUsageEvent[]) => void | Promise<void>;\n endpoint?: string;\n flushIntervalMs?: number;\n};\n\ntype OperationCounts = {\n calls: number;\n attempts: number;\n durationSumMs: number;\n status: Record<StatusClass, number>;\n latency: Record<LatencyBucket, number>;\n};\n\ntype ProcessLike = {\n env?: Record<string, string | undefined>;\n versions?: { node?: string; bun?: string; deno?: string };\n on?: (event: 'beforeExit', listener: () => void) => void;\n};\n\ntype OnFailedSend = 'keep' | 'drop';\n\nconst activeWindows = new Set<(onFailedSend: OnFailedSend) => Promise<void>>();\nconst pendingSends = new Set<Promise<void>>();\nlet exitHookInstalled = false;\n\nfunction nodeProcess(): ProcessLike | undefined {\n return (globalThis as { process?: ProcessLike }).process;\n}\n\nfunction telemetryDisabled(): boolean {\n const runtimeProcess = nodeProcess();\n if (runtimeProcess === undefined) return true;\n // A browser bundle can add a `process` shim, so also check for `document`.\n if (typeof document !== 'undefined') return true;\n const env = runtimeProcess.env ?? {};\n if (env.REDOCLY_SDK_TELEMETRY === 'off') return true;\n if (env.DO_NOT_TRACK === '1') return true;\n return false;\n}\n\nexport function flush(): Promise<void> {\n return flushWindows('keep');\n}\n\nasync function flushWindows(onFailedSend: OnFailedSend): Promise<void> {\n for (const flushWindow of activeWindows) void flushWindow(onFailedSend);\n await Promise.all(pendingSends);\n}\n\nexport function telemetry(options: TelemetryOptions): Middleware {\n if (telemetryDisabled()) return {};\n const intervalMs = options.flushIntervalMs ?? 60_000;\n const endpoint = options.endpoint ?? DEFAULT_ENDPOINT;\n const sink = options.sink ?? ((events: SdkUsageEvent[]) => sendOtlp(endpoint, events));\n const versions = nodeProcess()?.versions ?? {};\n let runtime = 'node';\n let runtimeVersion = versions.node ?? '';\n if (versions.bun !== undefined) {\n runtime = 'bun';\n runtimeVersion = versions.bun;\n } else if (versions.deno !== undefined) {\n runtime = 'deno';\n runtimeVersion = versions.deno;\n }\n const sdk: Record<string, string> = {\n name: options.sdkName,\n version: options.sdkVersion,\n generator_version: GENERATOR_VERSION,\n language: 'typescript',\n runtime,\n runtime_version: runtimeVersion,\n client: options.client,\n };\n let counts = new Map<string, OperationCounts>();\n let windowStart = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n function openWindow(): void {\n windowStart = Date.now();\n timer = setTimeout(() => void flushWindow('keep'), intervalMs);\n unrefTimer(timer);\n activeWindows.add(flushWindow);\n }\n\n async function flushWindow(onFailedSend: OnFailedSend): Promise<void> {\n if (counts.size === 0) return;\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n activeWindows.delete(flushWindow);\n const events = toEvents(counts, windowStart, Date.now() - windowStart, options.sdkName, sdk);\n const sentCounts = counts;\n const sentWindowStart = windowStart;\n counts = new Map();\n if (telemetryDisabled()) return;\n let action: OnFailedSend | undefined;\n const send = Promise.resolve()\n .then(() => sink(events))\n .catch((error: unknown) => {\n action = actionForFailedSend(error);\n });\n pendingSends.add(send);\n await send;\n pendingSends.delete(send);\n if (action !== 'keep' || onFailedSend === 'drop') return;\n\n if (counts.size === 0) openWindow();\n if (sentWindowStart < windowStart) windowStart = sentWindowStart;\n for (const [operationId, sentOperation] of sentCounts) {\n const operation = counts.get(operationId);\n if (operation === undefined) {\n counts.set(operationId, sentOperation);\n } else {\n addCounts(operation, sentOperation);\n }\n }\n }\n\n installExitHook();\n\n return {\n onSettled: (ctx, call) => {\n if (counts.size === 0) openWindow();\n let operation = counts.get(ctx.operation.id);\n if (operation === undefined) {\n operation = emptyCounts();\n counts.set(ctx.operation.id, operation);\n }\n record(operation, call);\n },\n };\n}\n\nfunction installExitHook(): void {\n if (exitHookInstalled) return;\n exitHookInstalled = true;\n // Node emits `beforeExit` again after each send at exit.\n // Kept counts then cause one more send each time, so a failed send here drops its counts.\n nodeProcess()?.on?.('beforeExit', () => void flushWindows('drop'));\n}\n\nfunction unrefTimer(timer: unknown): void {\n if (timer instanceof Object && 'unref' in timer && typeof timer.unref === 'function') {\n timer.unref();\n }\n}\n\nfunction emptyCounts(): OperationCounts {\n return {\n calls: 0,\n attempts: 0,\n durationSumMs: 0,\n status: { '2xx': 0, '3xx': 0, '4xx': 0, '5xx': 0, network_error: 0, timeout: 0, aborted: 0 },\n latency: { lt_100ms: 0, lt_300ms: 0, lt_1s: 0, lt_3s: 0, lt_10s: 0, gte_10s: 0 },\n };\n}\n\nfunction record(operation: OperationCounts, call: SettledCall): void {\n operation.calls += 1;\n operation.attempts += call.attempts;\n operation.durationSumMs += call.durationMs;\n operation.status[statusClass(call)] += 1;\n for (const { bucket, belowMs } of LATENCY_BUCKETS) {\n if (call.durationMs < belowMs) {\n operation.latency[bucket] += 1;\n break;\n }\n }\n}\n\nfunction addCounts(target: OperationCounts, source: OperationCounts): void {\n target.calls += source.calls;\n target.attempts += source.attempts;\n target.durationSumMs += source.durationSumMs;\n for (const statusClass of STATUS_CLASSES) {\n target.status[statusClass] += source.status[statusClass];\n }\n for (const { bucket } of LATENCY_BUCKETS) {\n target.latency[bucket] += source.latency[bucket];\n }\n}\n\nfunction statusClass(call: SettledCall): StatusClass {\n if (call.response === undefined) {\n if (call.error instanceof Error && call.error.name === 'TimeoutError') return 'timeout';\n if (call.error instanceof Error && call.error.name === 'AbortError') return 'aborted';\n return 'network_error';\n }\n const status = call.response.status;\n if (status >= 500) return '5xx';\n if (status >= 400) return '4xx';\n if (status >= 300) return '3xx';\n return '2xx';\n}\n\nfunction toEvents(\n counts: Map<string, OperationCounts>,\n windowStart: number,\n windowMs: number,\n source: string,\n sdk: Record<string, string>\n): SdkUsageEvent[] {\n const events: SdkUsageEvent[] = [];\n for (const [operationId, operation] of counts) {\n const usage: Record<string, string | number> = {\n operation_id: operationId,\n window_ms: windowMs,\n calls: operation.calls,\n attempts: operation.attempts,\n duration_sum_ms: operation.durationSumMs,\n };\n for (const statusClass of STATUS_CLASSES) {\n const count = operation.status[statusClass];\n if (count > 0) {\n usage[`status_${statusClass}`] = count;\n }\n }\n for (const { bucket } of LATENCY_BUCKETS) {\n const count = operation.latency[bucket];\n if (count > 0) {\n usage[`latency_${bucket}`] = count;\n }\n }\n events.push({\n id: `evt_${randomHex(16)}`,\n type: EVENT_TYPE,\n source,\n time: new Date(windowStart).toISOString(),\n data: { usage, sdk },\n });\n }\n return events;\n}\n\nasync function sendOtlp(endpoint: string, events: SdkUsageEvent[]): Promise<void> {\n const response = await fetch(endpoint, {\n method: 'POST',\n // One send per window, so the socket is never reused: close it instead of keeping it idle.\n headers: { 'Content-Type': 'application/json', Connection: 'close' },\n body: JSON.stringify(toOtlpRequest(events)),\n signal: AbortSignal.timeout(SEND_TIMEOUT_MS),\n });\n await response.body?.cancel();\n if (!response.ok) {\n throw new RejectedSendError(response.status);\n }\n}\n\nclass RejectedSendError extends Error {\n public readonly status: number;\n constructor(status: number) {\n super(`The telemetry endpoint answered ${status}.`);\n this.name = 'RejectedSendError';\n this.status = status;\n }\n}\n\nfunction actionForFailedSend(error: unknown): OnFailedSend {\n // The endpoint can have stored the counts of a send that timed out.\n if (error instanceof Error && error.name === 'TimeoutError') return 'drop';\n if (error instanceof RejectedSendError) {\n if (error.status === 408 || error.status === 429 || error.status >= 500) return 'keep';\n // The endpoint refuses the same counts again.\n return 'drop';\n }\n return 'keep';\n}\n\ntype OtlpValue = { stringValue: string } | { intValue: number } | { doubleValue: number };\ntype OtlpAttribute = { key: string; value: OtlpValue };\n\nfunction toOtlpRequest(events: SdkUsageEvent[]) {\n const spans = [];\n for (const event of events) {\n const timeUnixNano = `${Date.parse(event.time)}000000`;\n const attributes: OtlpAttribute[] = [\n attribute('cloudevents.event_id', event.id),\n attribute('cloudevents.event_type', event.type),\n attribute('cloudevents.event_source', event.source),\n attribute('cloudevents.event_spec_version', '1.0'),\n attribute('cloudevents.event_data_content_type', 'application/json; charset=utf-8'),\n attribute('cloudevents.event_time', event.time),\n attribute('cloudevents.event_subject', ''),\n attribute('cloudevents.event_origin', SERVICE_NAME),\n attribute('cloudevents.event_object', 'event'),\n attribute('cloudevents.event_category', 'product'),\n attribute('cloudevents.event_signal', 'metric'),\n ];\n for (const [key, value] of Object.entries(event.data.usage)) {\n attributes.push(attribute(`cloudevents.event_data.usage.${key}`, value));\n }\n for (const [key, value] of Object.entries(event.data.sdk)) {\n attributes.push(attribute(`cloudevents.event_data.sdk.${key}`, value));\n }\n spans.push({\n traceId: randomHex(16),\n spanId: randomHex(8),\n name: `event.${event.type}`,\n kind: 1,\n startTimeUnixNano: timeUnixNano,\n endTimeUnixNano: timeUnixNano,\n attributes,\n });\n }\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n attribute('service.name', SERVICE_NAME),\n attribute('service.version', GENERATOR_VERSION),\n ],\n },\n scopeSpans: [{ scope: { name: 'redocly-sdk-telemetry' }, spans }],\n },\n ],\n };\n}\n\nfunction attribute(key: string, value: string | number): OtlpAttribute {\n if (typeof value === 'string') return { key, value: { stringValue: value } };\n if (Number.isInteger(value)) return { key, value: { intValue: value } };\n return { key, value: { doubleValue: value } };\n}\n\nfunction randomHex(byteCount: number): string {\n const bytes = crypto.getRandomValues(new Uint8Array(byteCount));\n let hex = '';\n for (const byte of bytes) hex += byte.toString(16).padStart(2, '0');\n return hex;\n}\n";
3
3
  //# sourceMappingURL=telemetry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/runtime-sources/telemetry.ts"],"names":[],"mappings":"AAAA,iKAAiK;AACjK,MAAM,CAAC,MAAM,wBAAwB,GACnC,y9TAAy9T,CAAC"}
1
+ {"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/runtime-sources/telemetry.ts"],"names":[],"mappings":"AAAA,iKAAiK;AACjK,MAAM,CAAC,MAAM,wBAAwB,GACnC,0pYAA0pY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/client-generator",
3
- "version": "0.7.12",
3
+ "version": "0.7.13",
4
4
  "description": "Generate typed, zero-dependency TypeScript clients (fetch, auth, retries, middleware, SSE) from OpenAPI descriptions.",
5
5
  "type": "module",
6
6
  "types": "lib/index.d.ts",
@@ -82,7 +82,7 @@
82
82
  "Roman Marshevskyi <roman.marshevskyy@redocly.com> (https://redocly.com/)"
83
83
  ],
84
84
  "dependencies": {
85
- "@redocly/openapi-core": "2.71.1"
85
+ "@redocly/openapi-core": "2.71.2"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "typescript": ">=5.5.0"