@geekmidas/client 10.0.0-alpha.9 → 10.0.0-alpha.91

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 (113) hide show
  1. package/README.md +40 -57
  2. package/dist/auth-fetcher.cjs +78 -3
  3. package/dist/auth-fetcher.cjs.map +1 -0
  4. package/dist/auth-fetcher.d.cts +156 -3
  5. package/dist/auth-fetcher.d.cts.map +1 -0
  6. package/dist/auth-fetcher.d.mts +156 -3
  7. package/dist/auth-fetcher.d.mts.map +1 -0
  8. package/dist/auth-fetcher.mjs +77 -3
  9. package/dist/auth-fetcher.mjs.map +1 -0
  10. package/dist/endpoint-hooks.cjs +11 -15
  11. package/dist/endpoint-hooks.cjs.map +1 -1
  12. package/dist/endpoint-hooks.d.cts +4 -7
  13. package/dist/endpoint-hooks.d.cts.map +1 -1
  14. package/dist/endpoint-hooks.d.mts +4 -7
  15. package/dist/endpoint-hooks.d.mts.map +1 -1
  16. package/dist/endpoint-hooks.mjs +5 -9
  17. package/dist/endpoint-hooks.mjs.map +1 -1
  18. package/dist/fetcher.cjs +115 -3
  19. package/dist/fetcher.cjs.map +1 -0
  20. package/dist/fetcher.d.cts +24 -3
  21. package/dist/fetcher.d.cts.map +1 -0
  22. package/dist/fetcher.d.mts +24 -3
  23. package/dist/fetcher.d.mts.map +1 -0
  24. package/dist/fetcher.mjs +90 -2
  25. package/dist/fetcher.mjs.map +1 -0
  26. package/dist/index.cjs +13 -6
  27. package/dist/index.d.cts +7 -5
  28. package/dist/index.d.mts +7 -5
  29. package/dist/index.mjs +7 -6
  30. package/dist/infer.cjs +0 -1
  31. package/dist/infer.d.cts +130 -2
  32. package/dist/infer.d.cts.map +1 -0
  33. package/dist/infer.d.mts +130 -2
  34. package/dist/infer.d.mts.map +1 -0
  35. package/dist/infer.mjs +1 -1
  36. package/dist/methods.cjs +21 -0
  37. package/dist/methods.cjs.map +1 -0
  38. package/dist/methods.d.cts +23 -0
  39. package/dist/methods.d.cts.map +1 -0
  40. package/dist/methods.d.mts +23 -0
  41. package/dist/methods.d.mts.map +1 -0
  42. package/dist/methods.mjs +19 -0
  43. package/dist/methods.mjs.map +1 -0
  44. package/dist/openapi-hooks.cjs +13 -16
  45. package/dist/openapi-hooks.cjs.map +1 -1
  46. package/dist/openapi-hooks.d.cts +8 -11
  47. package/dist/openapi-hooks.d.cts.map +1 -1
  48. package/dist/openapi-hooks.d.mts +8 -11
  49. package/dist/openapi-hooks.d.mts.map +1 -1
  50. package/dist/openapi-hooks.mjs +9 -12
  51. package/dist/openapi-hooks.mjs.map +1 -1
  52. package/dist/openapi-types.d.cts +5 -6
  53. package/dist/openapi-types.d.cts.map +1 -1
  54. package/dist/openapi-types.d.mts +5 -6
  55. package/dist/openapi-types.d.mts.map +1 -1
  56. package/dist/react-query.cjs +17 -16
  57. package/dist/react-query.cjs.map +1 -1
  58. package/dist/react-query.d.cts +12 -17
  59. package/dist/react-query.d.cts.map +1 -1
  60. package/dist/react-query.d.mts +12 -17
  61. package/dist/react-query.d.mts.map +1 -1
  62. package/dist/react-query.mjs +10 -9
  63. package/dist/react-query.mjs.map +1 -1
  64. package/dist/telemetry-g3BE86Wd.d.cts +68 -0
  65. package/dist/telemetry-g3BE86Wd.d.cts.map +1 -0
  66. package/dist/telemetry-g3BE86Wd.d.mts +68 -0
  67. package/dist/telemetry-g3BE86Wd.d.mts.map +1 -0
  68. package/dist/telemetry.cjs +128 -0
  69. package/dist/telemetry.cjs.map +1 -0
  70. package/dist/telemetry.d.cts +2 -0
  71. package/dist/telemetry.d.mts +2 -0
  72. package/dist/telemetry.mjs +125 -0
  73. package/dist/telemetry.mjs.map +1 -0
  74. package/dist/types.cjs +0 -1
  75. package/dist/types.d.cts +122 -2
  76. package/dist/types.d.cts.map +1 -0
  77. package/dist/types.d.mts +122 -2
  78. package/dist/types.d.mts.map +1 -0
  79. package/dist/types.mjs +1 -1
  80. package/package.json +22 -9
  81. package/dist/auth-fetcher-CBYuL6rx.d.cts +0 -158
  82. package/dist/auth-fetcher-CBYuL6rx.d.cts.map +0 -1
  83. package/dist/auth-fetcher-DOj0iz21.mjs +0 -77
  84. package/dist/auth-fetcher-DOj0iz21.mjs.map +0 -1
  85. package/dist/auth-fetcher-DxS8zOLc.d.mts +0 -158
  86. package/dist/auth-fetcher-DxS8zOLc.d.mts.map +0 -1
  87. package/dist/auth-fetcher-HILABmws.cjs +0 -82
  88. package/dist/auth-fetcher-HILABmws.cjs.map +0 -1
  89. package/dist/chunk-CUT6urMc.cjs +0 -30
  90. package/dist/fetcher-C1xtCKpT.d.mts +0 -25
  91. package/dist/fetcher-C1xtCKpT.d.mts.map +0 -1
  92. package/dist/fetcher-CakjC9C7.mjs +0 -88
  93. package/dist/fetcher-CakjC9C7.mjs.map +0 -1
  94. package/dist/fetcher-CwnSqc4D.cjs +0 -100
  95. package/dist/fetcher-CwnSqc4D.cjs.map +0 -1
  96. package/dist/fetcher-cDrfwN-Y.d.cts +0 -25
  97. package/dist/fetcher-cDrfwN-Y.d.cts.map +0 -1
  98. package/dist/infer-6KKCgmg1.cjs +0 -0
  99. package/dist/infer-CPRqfabW.d.cts +0 -133
  100. package/dist/infer-CPRqfabW.d.cts.map +0 -1
  101. package/dist/infer-D9CgpOuc.d.mts +0 -133
  102. package/dist/infer-D9CgpOuc.d.mts.map +0 -1
  103. package/dist/infer-uCUq1whM.mjs +0 -0
  104. package/dist/openapi.cjs +0 -526
  105. package/dist/openapi.cjs.map +0 -1
  106. package/dist/openapi.mjs +0 -501
  107. package/dist/openapi.mjs.map +0 -1
  108. package/dist/types-BH8WgGrm.mjs +0 -0
  109. package/dist/types-BMGM6sZc.d.mts +0 -110
  110. package/dist/types-BMGM6sZc.d.mts.map +0 -1
  111. package/dist/types-DMQMHePI.d.cts +0 -110
  112. package/dist/types-DMQMHePI.d.cts.map +0 -1
  113. package/dist/types-a8gm_IaQ.cjs +0 -0
@@ -0,0 +1,128 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/telemetry.ts
3
+ /** A `sampleRate` outside 0–1, which no sampler can honour. */
4
+ var InvalidClientSampleRate = class extends Error {
5
+ sampleRate;
6
+ constructor(sampleRate) {
7
+ super(`telemetry.sampleRate must be a number from 0 (no page views) to 1 (every page view), got ${sampleRate}. Pass the stage's sample rate, such as 0.1.`);
8
+ this.sampleRate = sampleRate;
9
+ this.name = "InvalidClientSampleRate";
10
+ }
11
+ };
12
+ const OTEL_GLOBAL = Symbol.for("opentelemetry.js.api.1");
13
+ const setter = { set(carrier, key, value) {
14
+ carrier[key] = value;
15
+ } };
16
+ /**
17
+ * The headers the registered propagator writes for the active context, or
18
+ * undefined when there is no SDK or no span to continue.
19
+ */
20
+ function fromActiveContext() {
21
+ const api = globalThis[OTEL_GLOBAL];
22
+ if (!api?.propagation || !api.context) return void 0;
23
+ const carrier = {};
24
+ try {
25
+ api.propagation.inject(api.context.active(), carrier, setter);
26
+ } catch {
27
+ return;
28
+ }
29
+ return carrier.traceparent ? carrier : void 0;
30
+ }
31
+ /** `bytes` crypto-random bytes as lowercase hex, never all zeros. */
32
+ function randomHex(bytes) {
33
+ const buffer = new Uint8Array(bytes);
34
+ do
35
+ globalThis.crypto.getRandomValues(buffer);
36
+ while (buffer.every((byte) => byte === 0));
37
+ let hex = "";
38
+ for (const byte of buffer) hex += byte.toString(16).padStart(2, "0");
39
+ return hex;
40
+ }
41
+ /**
42
+ * Whether a trace is sampled at `rate`, from its id.
43
+ *
44
+ * The same rule as OpenTelemetry's `TraceIdRatioBasedSampler`: the id's four
45
+ * 32-bit words XORed together, under `rate` of the 32-bit range. The trace id
46
+ * is random, so this samples `rate` of page views — and the API, applying the
47
+ * same rule to the same id at the same rate, keeps exactly the page views kept
48
+ * here rather than a random `rate` of them.
49
+ */
50
+ function sampledAt(traceId, rate) {
51
+ if (rate >= 1) return true;
52
+ if (rate <= 0) return false;
53
+ let accumulation = 0;
54
+ for (let i = 0; i < traceId.length; i += 8) accumulation = (accumulation ^ parseInt(traceId.slice(i, i + 8), 16)) >>> 0;
55
+ return accumulation < Math.floor(rate * 4294967295);
56
+ }
57
+ let browserPageView;
58
+ /**
59
+ * The page view a request belongs to: the page load's in a browser, shared by
60
+ * every client on the page, or this client's own elsewhere — a server process
61
+ * outlives any one user action, so one trace for all of it would mean nothing.
62
+ */
63
+ function pageViewFor(own) {
64
+ if (!(typeof window !== "undefined" && typeof document !== "undefined")) return own();
65
+ browserPageView ??= { traceId: randomHex(16) };
66
+ return browserPageView;
67
+ }
68
+ /** The origin of `url`, resolved the way `fetch` would, or undefined. */
69
+ function originOf(url) {
70
+ try {
71
+ const base = globalThis.location?.href;
72
+ return new URL(url, base).origin;
73
+ } catch {
74
+ return;
75
+ }
76
+ }
77
+ let fetchRequests;
78
+ /**
79
+ * Whether something instruments `fetch` in this process: OpenTelemetry's
80
+ * undici instrumentation, or an APM built on it, listening on undici's
81
+ * diagnostics channel. It opens each request's CLIENT span and appends that
82
+ * span's `traceparent` itself, so one written here as well would reach the API
83
+ * as two values joined — `a, b` — which no propagator reads.
84
+ *
85
+ * Asked through `process.getBuiltinModule`, so a browser bundle imports no
86
+ * Node module; anywhere without it, nothing is listening.
87
+ */
88
+ function fetchIsInstrumented() {
89
+ if (fetchRequests === void 0) {
90
+ const getBuiltinModule = globalThis.process?.getBuiltinModule;
91
+ fetchRequests = (getBuiltinModule?.("node:diagnostics_channel"))?.channel("undici:request:create") ?? null;
92
+ }
93
+ return fetchRequests?.hasSubscribers === true;
94
+ }
95
+ /**
96
+ * An injector for a client whose API is at `baseURL`, or undefined when
97
+ * telemetry is off.
98
+ */
99
+ function traceContextInjector(baseURL, telemetry) {
100
+ if (!telemetry) return void 0;
101
+ const sampleRate = telemetry === true ? 1 : telemetry.sampleRate ?? 1;
102
+ if (!Number.isFinite(sampleRate) || sampleRate < 0 || sampleRate > 1) throw new InvalidClientSampleRate(sampleRate);
103
+ const apiOrigin = originOf(baseURL || "/");
104
+ let own;
105
+ const ownPageView = () => {
106
+ own ??= { traceId: randomHex(16) };
107
+ return own;
108
+ };
109
+ return (url, headers) => {
110
+ if (!apiOrigin || originOf(url) !== apiOrigin) return;
111
+ if (Object.keys(headers).some((h) => h.toLowerCase() === "traceparent")) return;
112
+ if (fetchIsInstrumented()) return;
113
+ const active = fromActiveContext();
114
+ if (active) {
115
+ Object.assign(headers, active);
116
+ return;
117
+ }
118
+ const { traceId } = pageViewFor(ownPageView);
119
+ const flags = sampledAt(traceId, sampleRate) ? "01" : "00";
120
+ headers.traceparent = `00-${traceId}-${randomHex(8)}-${flags}`;
121
+ };
122
+ }
123
+ //#endregion
124
+ exports.InvalidClientSampleRate = InvalidClientSampleRate;
125
+ exports.sampledAt = sampledAt;
126
+ exports.traceContextInjector = traceContextInjector;
127
+
128
+ //# sourceMappingURL=telemetry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.cjs","names":[],"sources":["../src/telemetry.ts"],"sourcesContent":["/**\n * W3C trace context on the requests a client makes to its own API, so a user\n * action in the browser and the API request it causes are one trace.\n *\n * Two levels, chosen per request:\n *\n * - **An OpenTelemetry context is active** — a browser SDK has a span open, or\n * this runs on a server (a Next.js server component, an API calling another\n * API) inside a request span. The globally registered propagator writes the\n * headers, so the current span is the parent: `traceparent`, `tracestate`,\n * and whatever else that propagator carries.\n * - **Otherwise** (level 1): one trace id per page view — per page load in a\n * browser, per client in Node — a fresh span id per request, and a sampled\n * flag decided once per page view from {@link ClientTelemetryOptions.sampleRate}.\n *\n * Nothing is sent to any origin but the API's own: a trace id is an identifier,\n * and a third party has no business correlating a user's requests by it. And\n * nothing at all where a `fetch` instrumentation is listening (a server with\n * OpenTelemetry's undici instrumentation): it writes the request's own\n * context, and two `traceparent` headers would be read as none.\n *\n * `@opentelemetry/api` is not imported. Every copy of it — whichever version\n * an app bundles — registers its globals on `globalThis` under\n * `Symbol.for('opentelemetry.js.api.1')`, which is how two copies in one page\n * already share a provider. Reading the propagator and context manager from\n * there costs a browser bundle nothing when no SDK is loaded, and still finds\n * the SDK when one is.\n */\n\n/** Telemetry on a client: `true` for the defaults, or these options. */\nexport interface ClientTelemetryOptions {\n\t/**\n\t * The fraction of page views whose requests are sampled, from 0 to 1, when\n\t * no OpenTelemetry context is active. Decided once per page view, so a\n\t * page's requests are all kept or all dropped together.\n\t *\n\t * Use the stage's rate. The API caps an incoming sampled flag at its own\n\t * rate anyway, and decides from the trace id the same way this does, so a\n\t * page view sampled here at the API's rate is sampled there too.\n\t * @default 1\n\t */\n\tsampleRate?: number;\n}\n\n/** A `sampleRate` outside 0–1, which no sampler can honour. */\nexport class InvalidClientSampleRate extends Error {\n\tconstructor(readonly sampleRate: number) {\n\t\tsuper(\n\t\t\t`telemetry.sampleRate must be a number from 0 (no page views) to 1 (every page view), got ${sampleRate}. Pass the stage's sample rate, such as 0.1.`,\n\t\t);\n\t\tthis.name = 'InvalidClientSampleRate';\n\t}\n}\n\n/** Adds trace headers to a request to `url`, when it is the API's own. */\nexport type TraceContextInjector = (\n\turl: string,\n\theaders: Record<string, string>,\n) => void;\n\n/** The slice of `@opentelemetry/api`'s global registry this reads. */\ninterface OtelGlobal {\n\tcontext?: { active(): unknown };\n\tpropagation?: {\n\t\tinject(\n\t\t\tcontext: unknown,\n\t\t\tcarrier: Record<string, string>,\n\t\t\tsetter: {\n\t\t\t\tset(carrier: Record<string, string>, key: string, value: string): void;\n\t\t\t},\n\t\t): void;\n\t};\n}\n\nconst OTEL_GLOBAL = Symbol.for('opentelemetry.js.api.1');\n\nconst setter = {\n\tset(carrier: Record<string, string>, key: string, value: string) {\n\t\tcarrier[key] = value;\n\t},\n};\n\n/**\n * The headers the registered propagator writes for the active context, or\n * undefined when there is no SDK or no span to continue.\n */\nfunction fromActiveContext(): Record<string, string> | undefined {\n\tconst api = (globalThis as Record<symbol, OtelGlobal | undefined>)[\n\t\tOTEL_GLOBAL\n\t];\n\tif (!api?.propagation || !api.context) return undefined;\n\n\tconst carrier: Record<string, string> = {};\n\ttry {\n\t\tapi.propagation.inject(api.context.active(), carrier, setter);\n\t} catch {\n\t\treturn undefined;\n\t}\n\t// The W3C propagator writes nothing without a valid, unsuppressed span.\n\treturn carrier.traceparent ? carrier : undefined;\n}\n\n/** `bytes` crypto-random bytes as lowercase hex, never all zeros. */\nfunction randomHex(bytes: number): string {\n\tconst buffer = new Uint8Array(bytes);\n\tdo {\n\t\tglobalThis.crypto.getRandomValues(buffer);\n\t} while (buffer.every((byte) => byte === 0));\n\tlet hex = '';\n\tfor (const byte of buffer) hex += byte.toString(16).padStart(2, '0');\n\treturn hex;\n}\n\n/**\n * Whether a trace is sampled at `rate`, from its id.\n *\n * The same rule as OpenTelemetry's `TraceIdRatioBasedSampler`: the id's four\n * 32-bit words XORed together, under `rate` of the 32-bit range. The trace id\n * is random, so this samples `rate` of page views — and the API, applying the\n * same rule to the same id at the same rate, keeps exactly the page views kept\n * here rather than a random `rate` of them.\n */\nexport function sampledAt(traceId: string, rate: number): boolean {\n\tif (rate >= 1) return true;\n\tif (rate <= 0) return false;\n\tlet accumulation = 0;\n\tfor (let i = 0; i < traceId.length; i += 8) {\n\t\taccumulation = (accumulation ^ parseInt(traceId.slice(i, i + 8), 16)) >>> 0;\n\t}\n\treturn accumulation < Math.floor(rate * 0xffffffff);\n}\n\n/** A page view: one trace id for every request made during it. */\ninterface PageView {\n\ttraceId: string;\n}\n\nlet browserPageView: PageView | undefined;\n\n/**\n * The page view a request belongs to: the page load's in a browser, shared by\n * every client on the page, or this client's own elsewhere — a server process\n * outlives any one user action, so one trace for all of it would mean nothing.\n */\nfunction pageViewFor(own: () => PageView): PageView {\n\tconst browser =\n\t\ttypeof window !== 'undefined' && typeof document !== 'undefined';\n\tif (!browser) return own();\n\tbrowserPageView ??= { traceId: randomHex(16) };\n\treturn browserPageView;\n}\n\n/** The origin of `url`, resolved the way `fetch` would, or undefined. */\nfunction originOf(url: string): string | undefined {\n\ttry {\n\t\tconst base = (globalThis as { location?: { href?: string } }).location\n\t\t\t?.href;\n\t\treturn new URL(url, base).origin;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The slice of `node:diagnostics_channel` this reads. */\ninterface DiagnosticsChannels {\n\tchannel(name: string): { hasSubscribers: boolean };\n}\n\nlet fetchRequests: { hasSubscribers: boolean } | null | undefined;\n\n/**\n * Whether something instruments `fetch` in this process: OpenTelemetry's\n * undici instrumentation, or an APM built on it, listening on undici's\n * diagnostics channel. It opens each request's CLIENT span and appends that\n * span's `traceparent` itself, so one written here as well would reach the API\n * as two values joined — `a, b` — which no propagator reads.\n *\n * Asked through `process.getBuiltinModule`, so a browser bundle imports no\n * Node module; anywhere without it, nothing is listening.\n */\nfunction fetchIsInstrumented(): boolean {\n\tif (fetchRequests === undefined) {\n\t\tconst getBuiltinModule = (\n\t\t\tglobalThis as {\n\t\t\t\tprocess?: { getBuiltinModule?: (id: string) => unknown };\n\t\t\t}\n\t\t).process?.getBuiltinModule;\n\t\tconst channels = getBuiltinModule?.('node:diagnostics_channel') as\n\t\t\t| DiagnosticsChannels\n\t\t\t| undefined;\n\t\tfetchRequests = channels?.channel('undici:request:create') ?? null;\n\t}\n\treturn fetchRequests?.hasSubscribers === true;\n}\n\n/**\n * An injector for a client whose API is at `baseURL`, or undefined when\n * telemetry is off.\n */\nexport function traceContextInjector(\n\tbaseURL: string,\n\ttelemetry: boolean | ClientTelemetryOptions | undefined,\n): TraceContextInjector | undefined {\n\tif (!telemetry) return undefined;\n\n\tconst sampleRate = telemetry === true ? 1 : (telemetry.sampleRate ?? 1);\n\tif (!Number.isFinite(sampleRate) || sampleRate < 0 || sampleRate > 1) {\n\t\tthrow new InvalidClientSampleRate(sampleRate);\n\t}\n\n\tconst apiOrigin = originOf(baseURL || '/');\n\tlet own: PageView | undefined;\n\tconst ownPageView = () => {\n\t\town ??= { traceId: randomHex(16) };\n\t\treturn own;\n\t};\n\n\treturn (url, headers) => {\n\t\t// Only the API's own origin: never a third party, and never anything\n\t\t// whose origin cannot be told.\n\t\tif (!apiOrigin || originOf(url) !== apiOrigin) return;\n\t\t// A caller that set its own context keeps it.\n\t\tif (Object.keys(headers).some((h) => h.toLowerCase() === 'traceparent'))\n\t\t\treturn;\n\t\t// A fetch instrumentation writes the request's own context.\n\t\tif (fetchIsInstrumented()) return;\n\n\t\tconst active = fromActiveContext();\n\t\tif (active) {\n\t\t\tObject.assign(headers, active);\n\t\t\treturn;\n\t\t}\n\n\t\tconst { traceId } = pageViewFor(ownPageView);\n\t\tconst flags = sampledAt(traceId, sampleRate) ? '01' : '00';\n\t\theaders.traceparent = `00-${traceId}-${randomHex(8)}-${flags}`;\n\t};\n}\n"],"mappings":";;;AA6CA,IAAa,0BAAb,cAA6C,MAAM;CAC7B;CAArB,YAAY,YAA6B;EACxC,MACC,4FAA4F,WAAW,6CACxG;EAHoB,KAAA,aAAA;EAIpB,KAAK,OAAO;CACb;AACD;AAsBA,MAAM,cAAc,OAAO,IAAI,wBAAwB;AAEvD,MAAM,SAAS,EACd,IAAI,SAAiC,KAAa,OAAe;CAChE,QAAQ,OAAO;AAChB,EACD;;;;;AAMA,SAAS,oBAAwD;CAChE,MAAM,MAAO,WACZ;CAED,IAAI,CAAC,KAAK,eAAe,CAAC,IAAI,SAAS,OAAO,KAAA;CAE9C,MAAM,UAAkC,CAAC;CACzC,IAAI;EACH,IAAI,YAAY,OAAO,IAAI,QAAQ,OAAO,GAAG,SAAS,MAAM;CAC7D,QAAQ;EACP;CACD;CAEA,OAAO,QAAQ,cAAc,UAAU,KAAA;AACxC;;AAGA,SAAS,UAAU,OAAuB;CACzC,MAAM,SAAS,IAAI,WAAW,KAAK;CACnC;EACC,WAAW,OAAO,gBAAgB,MAAM;QAChC,OAAO,OAAO,SAAS,SAAS,CAAC;CAC1C,IAAI,MAAM;CACV,KAAK,MAAM,QAAQ,QAAQ,OAAO,KAAK,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;CACnE,OAAO;AACR;;;;;;;;;;AAWA,SAAgB,UAAU,SAAiB,MAAuB;CAC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AAK,OAAO,CAAC,CAAC,MAAM,MAAM,EAAE,YAAY,MAAM,aAAa,GACrE;EAED,IAAI,oBAAoB,GAAG;EAE3B,MAAM,SAAS,kBAAkB;EACjC,IAAI,QAAQ;GACX,OAAO,OAAO,SAAS,MAAM;GAC7B;EACD;EAEA,MAAM,EAAE,YAAY,YAAY,WAAW;EAC3C,MAAM,QAAQ,UAAU,SAAS,UAAU,IAAI,OAAO;EACtD,QAAQ,cAAc,MAAM,QAAQ,GAAG,UAAU,CAAC,EAAE,GAAG;CACxD;AACD"}
@@ -0,0 +1,2 @@
1
+ import { a as traceContextInjector, i as sampledAt, n as InvalidClientSampleRate, r as TraceContextInjector, t as ClientTelemetryOptions } from "./telemetry-g3BE86Wd.cjs";
2
+ export { ClientTelemetryOptions, InvalidClientSampleRate, TraceContextInjector, sampledAt, traceContextInjector };
@@ -0,0 +1,2 @@
1
+ import { a as traceContextInjector, i as sampledAt, n as InvalidClientSampleRate, r as TraceContextInjector, t as ClientTelemetryOptions } from "./telemetry-g3BE86Wd.mjs";
2
+ export { ClientTelemetryOptions, InvalidClientSampleRate, TraceContextInjector, sampledAt, traceContextInjector };
@@ -0,0 +1,125 @@
1
+ //#region src/telemetry.ts
2
+ /** A `sampleRate` outside 0–1, which no sampler can honour. */
3
+ var InvalidClientSampleRate = class extends Error {
4
+ sampleRate;
5
+ constructor(sampleRate) {
6
+ super(`telemetry.sampleRate must be a number from 0 (no page views) to 1 (every page view), got ${sampleRate}. Pass the stage's sample rate, such as 0.1.`);
7
+ this.sampleRate = sampleRate;
8
+ this.name = "InvalidClientSampleRate";
9
+ }
10
+ };
11
+ const OTEL_GLOBAL = Symbol.for("opentelemetry.js.api.1");
12
+ const setter = { set(carrier, key, value) {
13
+ carrier[key] = value;
14
+ } };
15
+ /**
16
+ * The headers the registered propagator writes for the active context, or
17
+ * undefined when there is no SDK or no span to continue.
18
+ */
19
+ function fromActiveContext() {
20
+ const api = globalThis[OTEL_GLOBAL];
21
+ if (!api?.propagation || !api.context) return void 0;
22
+ const carrier = {};
23
+ try {
24
+ api.propagation.inject(api.context.active(), carrier, setter);
25
+ } catch {
26
+ return;
27
+ }
28
+ return carrier.traceparent ? carrier : void 0;
29
+ }
30
+ /** `bytes` crypto-random bytes as lowercase hex, never all zeros. */
31
+ function randomHex(bytes) {
32
+ const buffer = new Uint8Array(bytes);
33
+ do
34
+ globalThis.crypto.getRandomValues(buffer);
35
+ while (buffer.every((byte) => byte === 0));
36
+ let hex = "";
37
+ for (const byte of buffer) hex += byte.toString(16).padStart(2, "0");
38
+ return hex;
39
+ }
40
+ /**
41
+ * Whether a trace is sampled at `rate`, from its id.
42
+ *
43
+ * The same rule as OpenTelemetry's `TraceIdRatioBasedSampler`: the id's four
44
+ * 32-bit words XORed together, under `rate` of the 32-bit range. The trace id
45
+ * is random, so this samples `rate` of page views — and the API, applying the
46
+ * same rule to the same id at the same rate, keeps exactly the page views kept
47
+ * here rather than a random `rate` of them.
48
+ */
49
+ function sampledAt(traceId, rate) {
50
+ if (rate >= 1) return true;
51
+ if (rate <= 0) return false;
52
+ let accumulation = 0;
53
+ for (let i = 0; i < traceId.length; i += 8) accumulation = (accumulation ^ parseInt(traceId.slice(i, i + 8), 16)) >>> 0;
54
+ return accumulation < Math.floor(rate * 4294967295);
55
+ }
56
+ let browserPageView;
57
+ /**
58
+ * The page view a request belongs to: the page load's in a browser, shared by
59
+ * every client on the page, or this client's own elsewhere — a server process
60
+ * outlives any one user action, so one trace for all of it would mean nothing.
61
+ */
62
+ function pageViewFor(own) {
63
+ if (!(typeof window !== "undefined" && typeof document !== "undefined")) return own();
64
+ browserPageView ??= { traceId: randomHex(16) };
65
+ return browserPageView;
66
+ }
67
+ /** The origin of `url`, resolved the way `fetch` would, or undefined. */
68
+ function originOf(url) {
69
+ try {
70
+ const base = globalThis.location?.href;
71
+ return new URL(url, base).origin;
72
+ } catch {
73
+ return;
74
+ }
75
+ }
76
+ let fetchRequests;
77
+ /**
78
+ * Whether something instruments `fetch` in this process: OpenTelemetry's
79
+ * undici instrumentation, or an APM built on it, listening on undici's
80
+ * diagnostics channel. It opens each request's CLIENT span and appends that
81
+ * span's `traceparent` itself, so one written here as well would reach the API
82
+ * as two values joined — `a, b` — which no propagator reads.
83
+ *
84
+ * Asked through `process.getBuiltinModule`, so a browser bundle imports no
85
+ * Node module; anywhere without it, nothing is listening.
86
+ */
87
+ function fetchIsInstrumented() {
88
+ if (fetchRequests === void 0) {
89
+ const getBuiltinModule = globalThis.process?.getBuiltinModule;
90
+ fetchRequests = (getBuiltinModule?.("node:diagnostics_channel"))?.channel("undici:request:create") ?? null;
91
+ }
92
+ return fetchRequests?.hasSubscribers === true;
93
+ }
94
+ /**
95
+ * An injector for a client whose API is at `baseURL`, or undefined when
96
+ * telemetry is off.
97
+ */
98
+ function traceContextInjector(baseURL, telemetry) {
99
+ if (!telemetry) return void 0;
100
+ const sampleRate = telemetry === true ? 1 : telemetry.sampleRate ?? 1;
101
+ if (!Number.isFinite(sampleRate) || sampleRate < 0 || sampleRate > 1) throw new InvalidClientSampleRate(sampleRate);
102
+ const apiOrigin = originOf(baseURL || "/");
103
+ let own;
104
+ const ownPageView = () => {
105
+ own ??= { traceId: randomHex(16) };
106
+ return own;
107
+ };
108
+ return (url, headers) => {
109
+ if (!apiOrigin || originOf(url) !== apiOrigin) return;
110
+ if (Object.keys(headers).some((h) => h.toLowerCase() === "traceparent")) return;
111
+ if (fetchIsInstrumented()) return;
112
+ const active = fromActiveContext();
113
+ if (active) {
114
+ Object.assign(headers, active);
115
+ return;
116
+ }
117
+ const { traceId } = pageViewFor(ownPageView);
118
+ const flags = sampledAt(traceId, sampleRate) ? "01" : "00";
119
+ headers.traceparent = `00-${traceId}-${randomHex(8)}-${flags}`;
120
+ };
121
+ }
122
+ //#endregion
123
+ export { InvalidClientSampleRate, sampledAt, traceContextInjector };
124
+
125
+ //# sourceMappingURL=telemetry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.mjs","names":[],"sources":["../src/telemetry.ts"],"sourcesContent":["/**\n * W3C trace context on the requests a client makes to its own API, so a user\n * action in the browser and the API request it causes are one trace.\n *\n * Two levels, chosen per request:\n *\n * - **An OpenTelemetry context is active** — a browser SDK has a span open, or\n * this runs on a server (a Next.js server component, an API calling another\n * API) inside a request span. The globally registered propagator writes the\n * headers, so the current span is the parent: `traceparent`, `tracestate`,\n * and whatever else that propagator carries.\n * - **Otherwise** (level 1): one trace id per page view — per page load in a\n * browser, per client in Node — a fresh span id per request, and a sampled\n * flag decided once per page view from {@link ClientTelemetryOptions.sampleRate}.\n *\n * Nothing is sent to any origin but the API's own: a trace id is an identifier,\n * and a third party has no business correlating a user's requests by it. And\n * nothing at all where a `fetch` instrumentation is listening (a server with\n * OpenTelemetry's undici instrumentation): it writes the request's own\n * context, and two `traceparent` headers would be read as none.\n *\n * `@opentelemetry/api` is not imported. Every copy of it — whichever version\n * an app bundles — registers its globals on `globalThis` under\n * `Symbol.for('opentelemetry.js.api.1')`, which is how two copies in one page\n * already share a provider. Reading the propagator and context manager from\n * there costs a browser bundle nothing when no SDK is loaded, and still finds\n * the SDK when one is.\n */\n\n/** Telemetry on a client: `true` for the defaults, or these options. */\nexport interface ClientTelemetryOptions {\n\t/**\n\t * The fraction of page views whose requests are sampled, from 0 to 1, when\n\t * no OpenTelemetry context is active. Decided once per page view, so a\n\t * page's requests are all kept or all dropped together.\n\t *\n\t * Use the stage's rate. The API caps an incoming sampled flag at its own\n\t * rate anyway, and decides from the trace id the same way this does, so a\n\t * page view sampled here at the API's rate is sampled there too.\n\t * @default 1\n\t */\n\tsampleRate?: number;\n}\n\n/** A `sampleRate` outside 0–1, which no sampler can honour. */\nexport class InvalidClientSampleRate extends Error {\n\tconstructor(readonly sampleRate: number) {\n\t\tsuper(\n\t\t\t`telemetry.sampleRate must be a number from 0 (no page views) to 1 (every page view), got ${sampleRate}. Pass the stage's sample rate, such as 0.1.`,\n\t\t);\n\t\tthis.name = 'InvalidClientSampleRate';\n\t}\n}\n\n/** Adds trace headers to a request to `url`, when it is the API's own. */\nexport type TraceContextInjector = (\n\turl: string,\n\theaders: Record<string, string>,\n) => void;\n\n/** The slice of `@opentelemetry/api`'s global registry this reads. */\ninterface OtelGlobal {\n\tcontext?: { active(): unknown };\n\tpropagation?: {\n\t\tinject(\n\t\t\tcontext: unknown,\n\t\t\tcarrier: Record<string, string>,\n\t\t\tsetter: {\n\t\t\t\tset(carrier: Record<string, string>, key: string, value: string): void;\n\t\t\t},\n\t\t): void;\n\t};\n}\n\nconst OTEL_GLOBAL = Symbol.for('opentelemetry.js.api.1');\n\nconst setter = {\n\tset(carrier: Record<string, string>, key: string, value: string) {\n\t\tcarrier[key] = value;\n\t},\n};\n\n/**\n * The headers the registered propagator writes for the active context, or\n * undefined when there is no SDK or no span to continue.\n */\nfunction fromActiveContext(): Record<string, string> | undefined {\n\tconst api = (globalThis as Record<symbol, OtelGlobal | undefined>)[\n\t\tOTEL_GLOBAL\n\t];\n\tif (!api?.propagation || !api.context) return undefined;\n\n\tconst carrier: Record<string, string> = {};\n\ttry {\n\t\tapi.propagation.inject(api.context.active(), carrier, setter);\n\t} catch {\n\t\treturn undefined;\n\t}\n\t// The W3C propagator writes nothing without a valid, unsuppressed span.\n\treturn carrier.traceparent ? carrier : undefined;\n}\n\n/** `bytes` crypto-random bytes as lowercase hex, never all zeros. */\nfunction randomHex(bytes: number): string {\n\tconst buffer = new Uint8Array(bytes);\n\tdo {\n\t\tglobalThis.crypto.getRandomValues(buffer);\n\t} while (buffer.every((byte) => byte === 0));\n\tlet hex = '';\n\tfor (const byte of buffer) hex += byte.toString(16).padStart(2, '0');\n\treturn hex;\n}\n\n/**\n * Whether a trace is sampled at `rate`, from its id.\n *\n * The same rule as OpenTelemetry's `TraceIdRatioBasedSampler`: the id's four\n * 32-bit words XORed together, under `rate` of the 32-bit range. The trace id\n * is random, so this samples `rate` of page views — and the API, applying the\n * same rule to the same id at the same rate, keeps exactly the page views kept\n * here rather than a random `rate` of them.\n */\nexport function sampledAt(traceId: string, rate: number): boolean {\n\tif (rate >= 1) return true;\n\tif (rate <= 0) return false;\n\tlet accumulation = 0;\n\tfor (let i = 0; i < traceId.length; i += 8) {\n\t\taccumulation = (accumulation ^ parseInt(traceId.slice(i, i + 8), 16)) >>> 0;\n\t}\n\treturn accumulation < Math.floor(rate * 0xffffffff);\n}\n\n/** A page view: one trace id for every request made during it. */\ninterface PageView {\n\ttraceId: string;\n}\n\nlet browserPageView: PageView | undefined;\n\n/**\n * The page view a request belongs to: the page load's in a browser, shared by\n * every client on the page, or this client's own elsewhere — a server process\n * outlives any one user action, so one trace for all of it would mean nothing.\n */\nfunction pageViewFor(own: () => PageView): PageView {\n\tconst browser =\n\t\ttypeof window !== 'undefined' && typeof document !== 'undefined';\n\tif (!browser) return own();\n\tbrowserPageView ??= { traceId: randomHex(16) };\n\treturn browserPageView;\n}\n\n/** The origin of `url`, resolved the way `fetch` would, or undefined. */\nfunction originOf(url: string): string | undefined {\n\ttry {\n\t\tconst base = (globalThis as { location?: { href?: string } }).location\n\t\t\t?.href;\n\t\treturn new URL(url, base).origin;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The slice of `node:diagnostics_channel` this reads. */\ninterface DiagnosticsChannels {\n\tchannel(name: string): { hasSubscribers: boolean };\n}\n\nlet fetchRequests: { hasSubscribers: boolean } | null | undefined;\n\n/**\n * Whether something instruments `fetch` in this process: OpenTelemetry's\n * undici instrumentation, or an APM built on it, listening on undici's\n * diagnostics channel. It opens each request's CLIENT span and appends that\n * span's `traceparent` itself, so one written here as well would reach the API\n * as two values joined — `a, b` — which no propagator reads.\n *\n * Asked through `process.getBuiltinModule`, so a browser bundle imports no\n * Node module; anywhere without it, nothing is listening.\n */\nfunction fetchIsInstrumented(): boolean {\n\tif (fetchRequests === undefined) {\n\t\tconst getBuiltinModule = (\n\t\t\tglobalThis as {\n\t\t\t\tprocess?: { getBuiltinModule?: (id: string) => unknown };\n\t\t\t}\n\t\t).process?.getBuiltinModule;\n\t\tconst channels = getBuiltinModule?.('node:diagnostics_channel') as\n\t\t\t| DiagnosticsChannels\n\t\t\t| undefined;\n\t\tfetchRequests = channels?.channel('undici:request:create') ?? null;\n\t}\n\treturn fetchRequests?.hasSubscribers === true;\n}\n\n/**\n * An injector for a client whose API is at `baseURL`, or undefined when\n * telemetry is off.\n */\nexport function traceContextInjector(\n\tbaseURL: string,\n\ttelemetry: boolean | ClientTelemetryOptions | undefined,\n): TraceContextInjector | undefined {\n\tif (!telemetry) return undefined;\n\n\tconst sampleRate = telemetry === true ? 1 : (telemetry.sampleRate ?? 1);\n\tif (!Number.isFinite(sampleRate) || sampleRate < 0 || sampleRate > 1) {\n\t\tthrow new InvalidClientSampleRate(sampleRate);\n\t}\n\n\tconst apiOrigin = originOf(baseURL || '/');\n\tlet own: PageView | undefined;\n\tconst ownPageView = () => {\n\t\town ??= { traceId: randomHex(16) };\n\t\treturn own;\n\t};\n\n\treturn (url, headers) => {\n\t\t// Only the API's own origin: never a third party, and never anything\n\t\t// whose origin cannot be told.\n\t\tif (!apiOrigin || originOf(url) !== apiOrigin) return;\n\t\t// A caller that set its own context keeps it.\n\t\tif (Object.keys(headers).some((h) => h.toLowerCase() === 'traceparent'))\n\t\t\treturn;\n\t\t// A fetch instrumentation writes the request's own context.\n\t\tif (fetchIsInstrumented()) return;\n\n\t\tconst active = fromActiveContext();\n\t\tif (active) {\n\t\t\tObject.assign(headers, active);\n\t\t\treturn;\n\t\t}\n\n\t\tconst { traceId } = pageViewFor(ownPageView);\n\t\tconst flags = sampledAt(traceId, sampleRate) ? '01' : '00';\n\t\theaders.traceparent = `00-${traceId}-${randomHex(8)}-${flags}`;\n\t};\n}\n"],"mappings":";;AA6CA,IAAa,0BAAb,cAA6C,MAAM;CAC7B;CAArB,YAAY,YAA6B;EACxC,MACC,4FAA4F,WAAW,6CACxG;EAHoB,KAAA,aAAA;EAIpB,KAAK,OAAO;CACb;AACD;AAsBA,MAAM,cAAc,OAAO,IAAI,w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ACP;CACD;AACD;AAOA,IAAI;;;;;;;;;;;AAYJ,SAAS,sBAA+B;CACvC,IAAI,kBAAkB,KAAA,GAAW;EAChC,MAAM,mBACL,WAGC,SAAS;EAIX,iBAHiB,mBAAmB,0BAA0B,EAAA,EAGpC,QAAQ,uBAAuB,KAAK;CAC/D;CACA,OAAO,eAAe,mBAAmB;AAC1C;;;;;AAMA,SAAgB,qBACf,SACA,WACmC;CACnC,IAAI,CAAC,WAAW,OAAO,KAAA;CAEvB,MAAM,aAAa,cAAc,OAAO,IAAK,UAAU,cAAc;CACrE,IAAI,CAAC,OAAO,SAAS,UAAU,KAAK,aAAa,KAAK,aAAa,GAClE,MAAM,IAAI,wBAAwB,UAAU;CAG7C,MAAM,YAAY,SAAS,WAAW,GAAG;CACzC,IAAI;CACJ,MAAM,oBAAoB;EACzB,QAAQ,EAAE,SAAS,UAAU,EAAE,EAAE;EACjC,OAAO;CACR;CAEA,QAAQ,KAAK,YAAY;EAGxB,IAAI,CAAC,aAAa,SAAS,GAAG,MAAM,WAAW;EAE/C,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,MAAM,MAAM,EAAE,YAAY,MAAM,aAAa,GACrE;EAED,IAAI,oBAAoB,GAAG;EAE3B,MAAM,SAAS,kBAAkB;EACjC,IAAI,QAAQ;GACX,OAAO,OAAO,SAAS,MAAM;GAC7B;EACD;EAEA,MAAM,EAAE,YAAY,YAAY,WAAW;EAC3C,MAAM,QAAQ,UAAU,SAAS,UAAU,IAAI,OAAO;EACtD,QAAQ,cAAc,MAAM,QAAQ,GAAG,UAAU,CAAC,EAAE,GAAG;CACxD;AACD"}
package/dist/types.cjs CHANGED
@@ -1 +0,0 @@
1
- require('./types-a8gm_IaQ.cjs');
package/dist/types.d.cts CHANGED
@@ -1,2 +1,122 @@
1
- import { EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint, WrappedApiFunction, WrappedResult } from "./types-DMQMHePI.cjs";
2
- export { EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint, WrappedApiFunction, WrappedResult };
1
+ import { t as ClientTelemetryOptions } from "./telemetry-g3BE86Wd.cjs";
2
+ //#region src/types.d.ts
3
+ export type OpenAPIRoutes<Paths> = keyof Paths;
4
+ type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head' | 'options';
5
+ export type ExtractMethod<Paths, Route extends OpenAPIRoutes<Paths>> = Extract<keyof Paths[Route], HttpMethod>;
6
+ export type ExtractPathParams<Paths, Route extends OpenAPIRoutes<Paths>> = Paths[Route] extends {
7
+ parameters?: {
8
+ path?: infer P;
9
+ };
10
+ } ? P : never;
11
+ export type ExtractQueryParams<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = Paths[Route][Method] extends {
12
+ parameters?: {
13
+ query?: infer Q;
14
+ };
15
+ } ? Q : never;
16
+ export type ExtractRequestBody<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = Paths[Route][Method] extends {
17
+ requestBody?: infer RB;
18
+ } ? [NonNullable<RB>] extends [never] ? never : NonNullable<RB> extends {
19
+ content?: {
20
+ 'application/json'?: infer B;
21
+ };
22
+ } ? B : never : never;
23
+ export type ExtractResponse<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = Paths[Route][Method] extends {
24
+ responses?: {
25
+ 200?: {
26
+ content?: {
27
+ 'application/json'?: infer R;
28
+ };
29
+ };
30
+ };
31
+ } ? R : Paths[Route][Method] extends {
32
+ responses?: {
33
+ 201?: {
34
+ content?: {
35
+ 'application/json'?: infer R;
36
+ };
37
+ };
38
+ };
39
+ } ? R : never;
40
+ export type RequestConfig<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = {
41
+ params?: ExtractPathParams<Paths, Route>;
42
+ query?: ExtractQueryParams<Paths, Route, Method>;
43
+ body?: ExtractRequestBody<Paths, Route, Method>;
44
+ headers?: Record<string, string>;
45
+ };
46
+ export type EndpointString = `${Uppercase<string>} ${string}`;
47
+ export type ValidEndpoint<Paths> = { [Route in keyof Paths]: { [Method in Extract<keyof Paths[Route], HttpMethod>]: `${Uppercase<string & Method>} ${string & Route}`; }[Extract<keyof Paths[Route], HttpMethod>]; }[keyof Paths];
48
+ export type TypedEndpoint<Paths> = ValidEndpoint<Paths> extends (infer E) ? (E extends string ? E : never) : never;
49
+ export type FilterEndpointByMethod<Paths, Method extends string> = ValidEndpoint<Paths> extends (infer E) ? E extends `${Method} ${string}` ? E : never : never;
50
+ export type QueryEndpoint<Paths> = FilterEndpointByMethod<Paths, 'GET'>;
51
+ export type MutationEndpoint<Paths> = FilterEndpointByMethod<Paths, 'POST'> | FilterEndpointByMethod<Paths, 'PATCH'> | FilterEndpointByMethod<Paths, 'PUT'> | FilterEndpointByMethod<Paths, 'DELETE'>;
52
+ export type ParseEndpoint<T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? {
53
+ method: Lowercase<Method>;
54
+ route: Route;
55
+ } : never;
56
+ export type ExtractEndpointResponse<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? ExtractResponse<Paths, Route, Lowercase<Method>> : never : never : never;
57
+ export type ExtractEndpointConfig<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? RequestConfig<Paths, Route, Lowercase<Method>> : never : never : never;
58
+ /**
59
+ * Build a request config type where:
60
+ * - `params` is required if the endpoint has path parameters
61
+ * - `body` is required if the endpoint has a request body
62
+ * - `query` is required if it has a required key, optional otherwise
63
+ * - `headers` is always optional
64
+ */
65
+ export type FilteredRequestConfig<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? BuildRequestConfig<ExtractPathParams<Paths, Route>, ExtractQueryParams<Paths, Route, Lowercase<Method>>, ExtractRequestBody<Paths, Route, Lowercase<Method>>> : never : never : never;
66
+ /**
67
+ * Helper to build request config with correct required/optional fields.
68
+ * Uses [T] extends [never] pattern to prevent distribution over union types,
69
+ * which would cause the entire type to become `never`.
70
+ */
71
+ type BuildRequestConfig<TParams, TQuery, TBody> = SimplifyIntersection<([TParams] extends [never] ? {} : {
72
+ params: TParams;
73
+ }) & ([TBody] extends [never] ? {} : {
74
+ body: TBody;
75
+ }) & ([TQuery] extends [never] ? {} : {} extends TQuery ? {
76
+ query?: TQuery;
77
+ } : {
78
+ query: TQuery;
79
+ }) & {
80
+ headers?: Record<string, string>;
81
+ }>;
82
+ /**
83
+ * Simplify intersection types for better IDE display
84
+ */
85
+ type SimplifyIntersection<T> = { [K in keyof T]: T[K]; };
86
+ /** Whether a query has a key the caller must supply. */
87
+ type HasRequiredQuery<TQuery> = [TQuery] extends [never] ? false : {} extends TQuery ? false : true;
88
+ /**
89
+ * Check if the config object is required (has any required fields)
90
+ */
91
+ export type IsConfigRequired<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? ExtractPathParams<Paths, Route> extends never ? ExtractRequestBody<Paths, Route, Lowercase<Method>> extends never ? HasRequiredQuery<ExtractQueryParams<Paths, Route, Lowercase<Method>>> : true : true : false : false : false;
92
+ /**
93
+ * Typed function signature for the API client.
94
+ * Config is required when endpoint has path params or body.
95
+ */
96
+ export type TypedApiFunction<Paths> = <T extends TypedEndpoint<Paths>>(endpoint: T, ...args: IsConfigRequired<Paths, T> extends true ? [config: FilteredRequestConfig<Paths, T>] : [config?: FilteredRequestConfig<Paths, T>]) => Promise<ExtractEndpointResponse<Paths, T>>;
97
+ export interface FetcherOptions {
98
+ baseURL?: string;
99
+ headers?: Record<string, string>;
100
+ onRequest?: (config: RequestInit) => RequestInit | Promise<RequestInit>;
101
+ onResponse?: (response: Response) => Response | Promise<Response>;
102
+ onError?: (error: Error) => void | Promise<void>;
103
+ fetch?: typeof fetch;
104
+ /**
105
+ * W3C trace context (`traceparent`, `tracestate`) on every request to
106
+ * `baseURL`'s origin — never another. Continues the active OpenTelemetry
107
+ * span when there is one; otherwise a trace per page view, sampled at
108
+ * `sampleRate`. Off unless set.
109
+ */
110
+ telemetry?: boolean | ClientTelemetryOptions;
111
+ }
112
+ export type WrappedResult<T, E = unknown> = {
113
+ ok: true;
114
+ data: T;
115
+ } | {
116
+ ok: false;
117
+ error: E;
118
+ };
119
+ export type ErrorTransformer<E> = (error: unknown) => E | Promise<E>;
120
+ export type WrappedApiFunction<Paths, E = unknown> = <T extends TypedEndpoint<Paths>>(endpoint: T, ...args: IsConfigRequired<Paths, T> extends true ? [config: FilteredRequestConfig<Paths, T>] : [config?: FilteredRequestConfig<Paths, T>]) => Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>>;
121
+ //#endregion
122
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";;YAEY,cAAc,eAAe;KAEpC;YASO,cAAc,OAAO,cAAc,cAAc,UAAU,cAChE,MAAM,QACZ;YAGW,kBACX,OACA,cAAc,cAAc,UACzB,MAAM;EACT;IAAe,aAAa;;IAE1B;YAG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/dist/types.d.mts CHANGED
@@ -1,2 +1,122 @@
1
- import { EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint, WrappedApiFunction, WrappedResult } from "./types-BMGM6sZc.mjs";
2
- export { EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint, WrappedApiFunction, WrappedResult };
1
+ import { t as ClientTelemetryOptions } from "./telemetry-g3BE86Wd.mjs";
2
+ //#region src/types.d.ts
3
+ export type OpenAPIRoutes<Paths> = keyof Paths;
4
+ type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head' | 'options';
5
+ export type ExtractMethod<Paths, Route extends OpenAPIRoutes<Paths>> = Extract<keyof Paths[Route], HttpMethod>;
6
+ export type ExtractPathParams<Paths, Route extends OpenAPIRoutes<Paths>> = Paths[Route] extends {
7
+ parameters?: {
8
+ path?: infer P;
9
+ };
10
+ } ? P : never;
11
+ export type ExtractQueryParams<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = Paths[Route][Method] extends {
12
+ parameters?: {
13
+ query?: infer Q;
14
+ };
15
+ } ? Q : never;
16
+ export type ExtractRequestBody<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = Paths[Route][Method] extends {
17
+ requestBody?: infer RB;
18
+ } ? [NonNullable<RB>] extends [never] ? never : NonNullable<RB> extends {
19
+ content?: {
20
+ 'application/json'?: infer B;
21
+ };
22
+ } ? B : never : never;
23
+ export type ExtractResponse<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = Paths[Route][Method] extends {
24
+ responses?: {
25
+ 200?: {
26
+ content?: {
27
+ 'application/json'?: infer R;
28
+ };
29
+ };
30
+ };
31
+ } ? R : Paths[Route][Method] extends {
32
+ responses?: {
33
+ 201?: {
34
+ content?: {
35
+ 'application/json'?: infer R;
36
+ };
37
+ };
38
+ };
39
+ } ? R : never;
40
+ export type RequestConfig<Paths, Route extends OpenAPIRoutes<Paths>, Method extends ExtractMethod<Paths, Route>> = {
41
+ params?: ExtractPathParams<Paths, Route>;
42
+ query?: ExtractQueryParams<Paths, Route, Method>;
43
+ body?: ExtractRequestBody<Paths, Route, Method>;
44
+ headers?: Record<string, string>;
45
+ };
46
+ export type EndpointString = `${Uppercase<string>} ${string}`;
47
+ export type ValidEndpoint<Paths> = { [Route in keyof Paths]: { [Method in Extract<keyof Paths[Route], HttpMethod>]: `${Uppercase<string & Method>} ${string & Route}`; }[Extract<keyof Paths[Route], HttpMethod>]; }[keyof Paths];
48
+ export type TypedEndpoint<Paths> = ValidEndpoint<Paths> extends (infer E) ? (E extends string ? E : never) : never;
49
+ export type FilterEndpointByMethod<Paths, Method extends string> = ValidEndpoint<Paths> extends (infer E) ? E extends `${Method} ${string}` ? E : never : never;
50
+ export type QueryEndpoint<Paths> = FilterEndpointByMethod<Paths, 'GET'>;
51
+ export type MutationEndpoint<Paths> = FilterEndpointByMethod<Paths, 'POST'> | FilterEndpointByMethod<Paths, 'PATCH'> | FilterEndpointByMethod<Paths, 'PUT'> | FilterEndpointByMethod<Paths, 'DELETE'>;
52
+ export type ParseEndpoint<T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? {
53
+ method: Lowercase<Method>;
54
+ route: Route;
55
+ } : never;
56
+ export type ExtractEndpointResponse<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? ExtractResponse<Paths, Route, Lowercase<Method>> : never : never : never;
57
+ export type ExtractEndpointConfig<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? RequestConfig<Paths, Route, Lowercase<Method>> : never : never : never;
58
+ /**
59
+ * Build a request config type where:
60
+ * - `params` is required if the endpoint has path parameters
61
+ * - `body` is required if the endpoint has a request body
62
+ * - `query` is required if it has a required key, optional otherwise
63
+ * - `headers` is always optional
64
+ */
65
+ export type FilteredRequestConfig<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? BuildRequestConfig<ExtractPathParams<Paths, Route>, ExtractQueryParams<Paths, Route, Lowercase<Method>>, ExtractRequestBody<Paths, Route, Lowercase<Method>>> : never : never : never;
66
+ /**
67
+ * Helper to build request config with correct required/optional fields.
68
+ * Uses [T] extends [never] pattern to prevent distribution over union types,
69
+ * which would cause the entire type to become `never`.
70
+ */
71
+ type BuildRequestConfig<TParams, TQuery, TBody> = SimplifyIntersection<([TParams] extends [never] ? {} : {
72
+ params: TParams;
73
+ }) & ([TBody] extends [never] ? {} : {
74
+ body: TBody;
75
+ }) & ([TQuery] extends [never] ? {} : {} extends TQuery ? {
76
+ query?: TQuery;
77
+ } : {
78
+ query: TQuery;
79
+ }) & {
80
+ headers?: Record<string, string>;
81
+ }>;
82
+ /**
83
+ * Simplify intersection types for better IDE display
84
+ */
85
+ type SimplifyIntersection<T> = { [K in keyof T]: T[K]; };
86
+ /** Whether a query has a key the caller must supply. */
87
+ type HasRequiredQuery<TQuery> = [TQuery] extends [never] ? false : {} extends TQuery ? false : true;
88
+ /**
89
+ * Check if the config object is required (has any required fields)
90
+ */
91
+ export type IsConfigRequired<Paths, T extends EndpointString> = T extends `${infer Method} ${infer Route}` ? Route extends OpenAPIRoutes<Paths> ? Lowercase<Method> extends ExtractMethod<Paths, Route> ? ExtractPathParams<Paths, Route> extends never ? ExtractRequestBody<Paths, Route, Lowercase<Method>> extends never ? HasRequiredQuery<ExtractQueryParams<Paths, Route, Lowercase<Method>>> : true : true : false : false : false;
92
+ /**
93
+ * Typed function signature for the API client.
94
+ * Config is required when endpoint has path params or body.
95
+ */
96
+ export type TypedApiFunction<Paths> = <T extends TypedEndpoint<Paths>>(endpoint: T, ...args: IsConfigRequired<Paths, T> extends true ? [config: FilteredRequestConfig<Paths, T>] : [config?: FilteredRequestConfig<Paths, T>]) => Promise<ExtractEndpointResponse<Paths, T>>;
97
+ export interface FetcherOptions {
98
+ baseURL?: string;
99
+ headers?: Record<string, string>;
100
+ onRequest?: (config: RequestInit) => RequestInit | Promise<RequestInit>;
101
+ onResponse?: (response: Response) => Response | Promise<Response>;
102
+ onError?: (error: Error) => void | Promise<void>;
103
+ fetch?: typeof fetch;
104
+ /**
105
+ * W3C trace context (`traceparent`, `tracestate`) on every request to
106
+ * `baseURL`'s origin — never another. Continues the active OpenTelemetry
107
+ * span when there is one; otherwise a trace per page view, sampled at
108
+ * `sampleRate`. Off unless set.
109
+ */
110
+ telemetry?: boolean | ClientTelemetryOptions;
111
+ }
112
+ export type WrappedResult<T, E = unknown> = {
113
+ ok: true;
114
+ data: T;
115
+ } | {
116
+ ok: false;
117
+ error: E;
118
+ };
119
+ export type ErrorTransformer<E> = (error: unknown) => E | Promise<E>;
120
+ export type WrappedApiFunction<Paths, E = unknown> = <T extends TypedEndpoint<Paths>>(endpoint: T, ...args: IsConfigRequired<Paths, T> extends true ? [config: FilteredRequestConfig<Paths, T>] : [config?: FilteredRequestConfig<Paths, T>]) => Promise<WrappedResult<ExtractEndpointResponse<Paths, T>, E>>;
121
+ //#endregion
122
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types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