@pinta365/strava 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +390 -0
  3. package/esm/_dnt.shims.d.ts +2 -0
  4. package/esm/_dnt.shims.js +57 -0
  5. package/esm/deps/jsr.io/@cross/runtime/1.2.1/mod.d.ts +126 -0
  6. package/esm/deps/jsr.io/@cross/runtime/1.2.1/mod.js +480 -0
  7. package/esm/mod.d.ts +27 -0
  8. package/esm/mod.js +27 -0
  9. package/esm/package.json +3 -0
  10. package/esm/src/auth/oauth.d.ts +68 -0
  11. package/esm/src/auth/oauth.js +203 -0
  12. package/esm/src/auth/scopes.d.ts +52 -0
  13. package/esm/src/auth/scopes.js +71 -0
  14. package/esm/src/auth/token-store.d.ts +57 -0
  15. package/esm/src/auth/token-store.js +142 -0
  16. package/esm/src/client.d.ts +98 -0
  17. package/esm/src/client.js +235 -0
  18. package/esm/src/errors.d.ts +52 -0
  19. package/esm/src/errors.js +102 -0
  20. package/esm/src/http/deduplication.d.ts +33 -0
  21. package/esm/src/http/deduplication.js +96 -0
  22. package/esm/src/http/rate-limiter.d.ts +47 -0
  23. package/esm/src/http/rate-limiter.js +168 -0
  24. package/esm/src/http/request.d.ts +24 -0
  25. package/esm/src/http/request.js +158 -0
  26. package/esm/src/http/retry.d.ts +9 -0
  27. package/esm/src/http/retry.js +61 -0
  28. package/esm/src/resources/activities.d.ts +149 -0
  29. package/esm/src/resources/activities.js +189 -0
  30. package/esm/src/resources/athletes.d.ts +37 -0
  31. package/esm/src/resources/athletes.js +85 -0
  32. package/esm/src/resources/clubs.d.ts +45 -0
  33. package/esm/src/resources/clubs.js +71 -0
  34. package/esm/src/resources/gears.d.ts +17 -0
  35. package/esm/src/resources/gears.js +27 -0
  36. package/esm/src/resources/routes.d.ts +33 -0
  37. package/esm/src/resources/routes.js +71 -0
  38. package/esm/src/resources/segment-efforts.d.ts +38 -0
  39. package/esm/src/resources/segment-efforts.js +53 -0
  40. package/esm/src/resources/segments.d.ts +42 -0
  41. package/esm/src/resources/segments.js +67 -0
  42. package/esm/src/resources/streams.d.ts +44 -0
  43. package/esm/src/resources/streams.js +75 -0
  44. package/esm/src/resources/uploads.d.ts +41 -0
  45. package/esm/src/resources/uploads.js +79 -0
  46. package/esm/src/types/api.d.ts +9 -0
  47. package/esm/src/types/api.js +7 -0
  48. package/esm/src/types/common.d.ts +65 -0
  49. package/esm/src/types/common.js +4 -0
  50. package/esm/src/types/generated.d.ts +731 -0
  51. package/esm/src/types/generated.js +7 -0
  52. package/esm/src/utils/pagination.d.ts +45 -0
  53. package/esm/src/utils/pagination.js +112 -0
  54. package/esm/src/utils/transformers.d.ts +30 -0
  55. package/esm/src/utils/transformers.js +189 -0
  56. package/esm/src/utils/validators.d.ts +53 -0
  57. package/esm/src/utils/validators.js +84 -0
  58. package/package.json +40 -0
  59. package/script/_dnt.shims.d.ts +2 -0
  60. package/script/_dnt.shims.js +60 -0
  61. package/script/deps/jsr.io/@cross/runtime/1.2.1/mod.d.ts +126 -0
  62. package/script/deps/jsr.io/@cross/runtime/1.2.1/mod.js +526 -0
  63. package/script/mod.d.ts +27 -0
  64. package/script/mod.js +73 -0
  65. package/script/package.json +3 -0
  66. package/script/src/auth/oauth.d.ts +68 -0
  67. package/script/src/auth/oauth.js +211 -0
  68. package/script/src/auth/scopes.d.ts +52 -0
  69. package/script/src/auth/scopes.js +79 -0
  70. package/script/src/auth/token-store.d.ts +57 -0
  71. package/script/src/auth/token-store.js +182 -0
  72. package/script/src/client.d.ts +98 -0
  73. package/script/src/client.js +239 -0
  74. package/script/src/errors.d.ts +52 -0
  75. package/script/src/errors.js +111 -0
  76. package/script/src/http/deduplication.d.ts +33 -0
  77. package/script/src/http/deduplication.js +100 -0
  78. package/script/src/http/rate-limiter.d.ts +47 -0
  79. package/script/src/http/rate-limiter.js +172 -0
  80. package/script/src/http/request.d.ts +24 -0
  81. package/script/src/http/request.js +161 -0
  82. package/script/src/http/retry.d.ts +9 -0
  83. package/script/src/http/retry.js +64 -0
  84. package/script/src/resources/activities.d.ts +149 -0
  85. package/script/src/resources/activities.js +193 -0
  86. package/script/src/resources/athletes.d.ts +37 -0
  87. package/script/src/resources/athletes.js +89 -0
  88. package/script/src/resources/clubs.d.ts +45 -0
  89. package/script/src/resources/clubs.js +75 -0
  90. package/script/src/resources/gears.d.ts +17 -0
  91. package/script/src/resources/gears.js +31 -0
  92. package/script/src/resources/routes.d.ts +33 -0
  93. package/script/src/resources/routes.js +75 -0
  94. package/script/src/resources/segment-efforts.d.ts +38 -0
  95. package/script/src/resources/segment-efforts.js +57 -0
  96. package/script/src/resources/segments.d.ts +42 -0
  97. package/script/src/resources/segments.js +71 -0
  98. package/script/src/resources/streams.d.ts +44 -0
  99. package/script/src/resources/streams.js +79 -0
  100. package/script/src/resources/uploads.d.ts +41 -0
  101. package/script/src/resources/uploads.js +83 -0
  102. package/script/src/types/api.d.ts +9 -0
  103. package/script/src/types/api.js +23 -0
  104. package/script/src/types/common.d.ts +65 -0
  105. package/script/src/types/common.js +5 -0
  106. package/script/src/types/generated.d.ts +731 -0
  107. package/script/src/types/generated.js +8 -0
  108. package/script/src/utils/pagination.d.ts +45 -0
  109. package/script/src/utils/pagination.js +118 -0
  110. package/script/src/utils/transformers.d.ts +30 -0
  111. package/script/src/utils/transformers.js +196 -0
  112. package/script/src/utils/validators.d.ts +53 -0
  113. package/script/src/utils/validators.js +92 -0
@@ -0,0 +1,480 @@
1
+ // deno-lint-ignore-file no-process-global
2
+ /* Private functions */
3
+ import * as dntShim from "../../../../../_dnt.shims.js";
4
+ function getChromeVersion(userAgent) {
5
+ const match = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
6
+ return match ? match[2] : "Unknown";
7
+ }
8
+ function getFirefoxVersion(userAgent) {
9
+ const match = userAgent.match(/Firefox\/([0-9]+)\./);
10
+ return match ? match[1] : "Unknown";
11
+ }
12
+ function getEdgeVersion(userAgent) {
13
+ const match = userAgent.match(/Edg\/([0-9]+)\./);
14
+ return match ? match[1] : "Unknown";
15
+ }
16
+ function getSafariVersion(userAgent) {
17
+ const match = userAgent.match(/Version\/([0-9]+)\.([0-9]+)(\.[0-9]+)?/);
18
+ if (match)
19
+ return `${match[1]}.${match[2]}`;
20
+ return "Unknown";
21
+ }
22
+ function getOperaVersion(userAgent) {
23
+ // Look for either 'Opera/' or 'OPR/' followed by the version
24
+ const match = userAgent.match(/(Opera|OPR)\/([0-9]+)\./);
25
+ return match ? match[2] : "Unknown";
26
+ }
27
+ function getBraveVersion(userAgent) {
28
+ const match = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
29
+ return match ? match[2] : "Unknown";
30
+ }
31
+ /**
32
+ * Enum of supported Runtimes.
33
+ * @enum {string}
34
+ */
35
+ export var Runtime;
36
+ (function (Runtime) {
37
+ Runtime["Deno"] = "deno";
38
+ Runtime["Bun"] = "bun";
39
+ Runtime["Node"] = "node";
40
+ Runtime["Browser"] = "browser";
41
+ Runtime["Tauri"] = "tauri";
42
+ Runtime["Workerd"] = "workerd";
43
+ Runtime["Netlify"] = "netlify";
44
+ Runtime["EdgeLight"] = "edgelight";
45
+ Runtime["Fastly"] = "fastly";
46
+ Runtime["Unsupported"] = "unsupported";
47
+ })(Runtime || (Runtime = {}));
48
+ /**
49
+ * Enum of supported Operating Systems.
50
+ * @enum {string}
51
+ */
52
+ export var OperatingSystem;
53
+ (function (OperatingSystem) {
54
+ OperatingSystem["Windows"] = "windows";
55
+ OperatingSystem["macOS"] = "macos";
56
+ OperatingSystem["Linux"] = "linux";
57
+ OperatingSystem["Android"] = "android";
58
+ OperatingSystem["Unix"] = "unix";
59
+ OperatingSystem["iOS"] = "ios";
60
+ OperatingSystem["Unsupported"] = "unsupported";
61
+ })(OperatingSystem || (OperatingSystem = {}));
62
+ /**
63
+ * Enum of supported Products.
64
+ * @enum {string}
65
+ */
66
+ export var Product;
67
+ (function (Product) {
68
+ // All runtimes
69
+ Product["Deno"] = "deno";
70
+ Product["Bun"] = "bun";
71
+ Product["Node"] = "node";
72
+ Product["Tauri"] = "tauri";
73
+ Product["Workerd"] = "workerd";
74
+ Product["Netlify"] = "netlify";
75
+ Product["EdgeLight"] = "edgelight";
76
+ Product["Fastly"] = "fastly";
77
+ // All browsers
78
+ Product["Firefox"] = "firefox";
79
+ Product["Safari"] = "safari";
80
+ Product["Chrome"] = "chrome";
81
+ Product["Edge"] = "edge";
82
+ Product["Opera"] = "opera";
83
+ Product["Brave"] = "brave";
84
+ // And unsupported
85
+ Product["Unsupported"] = "unsupported";
86
+ })(Product || (Product = {}));
87
+ /**
88
+ * Enum of common CPU architectures.
89
+ * @enum {string}
90
+ */
91
+ export var Architecture;
92
+ (function (Architecture) {
93
+ Architecture["x86"] = "x86";
94
+ Architecture["x64"] = "x86_64";
95
+ Architecture["arm"] = "arm";
96
+ Architecture["arm64"] = "arm64";
97
+ Architecture["Unsupported"] = "unsupported";
98
+ })(Architecture || (Architecture = {}));
99
+ ///**
100
+ // * Interface for Tauri-specific information.
101
+ // */
102
+ //export interface TauriInfo {
103
+ // /** The application version, as defined in `tauri.conf.json`. */
104
+ // version?: string;
105
+ // /** The application name, as defined in `tauri.conf.json`. */
106
+ // name?: string;
107
+ // /** The application's bundle identifier, as defined in `tauri.conf.json`. */
108
+ // identifier?: string;
109
+ // /** The version of the underlying Tauri runtime. */
110
+ // tauriVersion?: string;
111
+ //}
112
+ /**
113
+ * Verifies if a property exists in the global namespace and optionally checks its type.
114
+ *
115
+ * @param {string} name - The name of the property to verify.
116
+ * @param {string} [typeString] - The expected type of the property (optional).
117
+ * @returns {boolean} True if the property exists and matches the type (if provided), False otherwise.
118
+ */
119
+ function verifyGlobal(name, typeString) {
120
+ return name in dntShim.dntGlobalThis && (!typeString || typeof dntShim.dntGlobalThis[name] === typeString);
121
+ }
122
+ // Disable getTauriInfo() while I figure some things out.
123
+ ///**
124
+ // * Gets Tauri-specific information asynchronously.
125
+ // * Only works when running in a Tauri application.
126
+ // * @returns {Promise<TauriInfo>} Tauri-specific data
127
+ // */
128
+ //export async function getTauriInfo(): Promise<TauriInfo> {
129
+ // if (getCurrentRuntime() !== Runtime.Tauri) {
130
+ // return {};
131
+ // }
132
+ //
133
+ // try {
134
+ // const { getVersion, getName, getIdentifier, getTauriVersion } = await import("@tauri-apps/api/app");
135
+ //
136
+ // const [version, name, identifier, tauriVersion] = await Promise.all([
137
+ // getVersion().catch(() => undefined),
138
+ // getName().catch(() => undefined),
139
+ // getIdentifier().catch(() => undefined),
140
+ // getTauriVersion().catch(() => undefined),
141
+ // ]);
142
+ //
143
+ // return { version, name, identifier, tauriVersion };
144
+ // } catch (_e) {
145
+ // return {};
146
+ // }
147
+ //}
148
+ /**
149
+ * Dynamically determines the current runtime environment.
150
+ */
151
+ export function getCurrentRuntime() {
152
+ if (verifyGlobal("Deno", "object"))
153
+ return Runtime.Deno;
154
+ if (verifyGlobal("Bun", "object"))
155
+ return Runtime.Bun;
156
+ if (verifyGlobal("Netlify", "object"))
157
+ return Runtime.Netlify;
158
+ if (verifyGlobal("EdgeRuntime", "string"))
159
+ return Runtime.EdgeLight;
160
+ if (globalThis.navigator?.userAgent === "Cloudflare-Workers")
161
+ return Runtime.Workerd;
162
+ if (verifyGlobal("fastly", "object"))
163
+ return Runtime.Fastly;
164
+ if (verifyGlobal("process", "object") &&
165
+ //@ts-ignore Runtime detection
166
+ typeof process.versions !== "undefined" &&
167
+ //@ts-ignore Runtime detection
168
+ typeof process.versions.node !== "undefined") {
169
+ return Runtime.Node;
170
+ }
171
+ if (verifyGlobal("window", "object")) { // Check for Browser or Tauri
172
+ // Check for Tauri first (Tauri runs in a webview, so it has window)
173
+ if (verifyGlobal("__TAURI__", "object"))
174
+ return Runtime.Tauri;
175
+ return Runtime.Browser;
176
+ }
177
+ return Runtime.Unsupported;
178
+ }
179
+ /**
180
+ * Dynamically determines the current operating system.
181
+ */
182
+ export function getCurrentOS() {
183
+ const runtime = getCurrentRuntime();
184
+ switch (runtime) {
185
+ case Runtime.Deno:
186
+ switch (Deno.build.os) {
187
+ case "darwin":
188
+ return OperatingSystem.macOS;
189
+ case "windows":
190
+ return OperatingSystem.Windows;
191
+ case "linux":
192
+ return OperatingSystem.Linux;
193
+ case "android":
194
+ return OperatingSystem.Android;
195
+ case "aix":
196
+ case "freebsd":
197
+ case "illumos":
198
+ case "netbsd":
199
+ case "solaris":
200
+ return OperatingSystem.Unix;
201
+ }
202
+ return OperatingSystem.Unsupported;
203
+ case Runtime.Node:
204
+ // @ts-ignore Cross Runtime
205
+ switch (process.platform) {
206
+ case "darwin":
207
+ return OperatingSystem.macOS;
208
+ case "win32":
209
+ return OperatingSystem.Windows;
210
+ case "linux":
211
+ return OperatingSystem.Linux;
212
+ case "android":
213
+ return OperatingSystem.Android;
214
+ case "aix":
215
+ case "freebsd":
216
+ case "openbsd":
217
+ case "sunos":
218
+ return OperatingSystem.Unix;
219
+ }
220
+ return OperatingSystem.Unsupported;
221
+ case Runtime.Bun:
222
+ // @ts-ignore Cross Runtime
223
+ switch (process.platform) {
224
+ case "darwin":
225
+ return OperatingSystem.macOS;
226
+ case "win32":
227
+ return OperatingSystem.Windows;
228
+ case "linux":
229
+ return OperatingSystem.Linux;
230
+ case "android":
231
+ return OperatingSystem.Android;
232
+ case "aix":
233
+ case "freebsd":
234
+ case "openbsd":
235
+ case "sunos":
236
+ return OperatingSystem.Unix;
237
+ }
238
+ return OperatingSystem.Unsupported;
239
+ case Runtime.Tauri:
240
+ case Runtime.Browser: {
241
+ if ("userAgent" in navigator) {
242
+ const userAgent = navigator.userAgent;
243
+ return getOSFromUserAgent(userAgent);
244
+ }
245
+ }
246
+ }
247
+ return OperatingSystem.Unsupported;
248
+ }
249
+ /**
250
+ * Determine operating system from user agent string, if possible
251
+ */
252
+ export function getOSFromUserAgent(userAgent) {
253
+ if (userAgent.indexOf("Win") !== -1)
254
+ return OperatingSystem.Windows;
255
+ if (userAgent.indexOf("like Mac") !== -1)
256
+ return OperatingSystem.iOS;
257
+ if (userAgent.indexOf("Mac") !== -1)
258
+ return OperatingSystem.macOS;
259
+ if (userAgent.indexOf("Android") !== -1)
260
+ return OperatingSystem.Android;
261
+ if (userAgent.indexOf("X11") !== -1 || userAgent.indexOf("Linux") !== -1)
262
+ return OperatingSystem.Linux;
263
+ return OperatingSystem.Unsupported;
264
+ }
265
+ /**
266
+ * Dynamically determines the current browser and its version (if applicable).
267
+ */
268
+ export function getCurrentProduct() {
269
+ const runtime = getCurrentRuntime();
270
+ switch (runtime) {
271
+ case Runtime.Deno:
272
+ return Product.Deno;
273
+ case Runtime.Node:
274
+ return Product.Node;
275
+ case Runtime.Bun:
276
+ return Product.Bun;
277
+ case Runtime.Tauri:
278
+ return Product.Tauri;
279
+ case Runtime.Workerd:
280
+ return Product.Workerd;
281
+ case Runtime.Netlify:
282
+ return Product.Netlify;
283
+ case Runtime.EdgeLight:
284
+ return Product.EdgeLight;
285
+ case Runtime.Fastly:
286
+ return Product.Fastly;
287
+ case Runtime.Browser: {
288
+ // Brave can not be detected from user agent string, handle separately
289
+ if (verifyGlobal("brave") && "brave" in navigator)
290
+ return Product.Brave;
291
+ // For browser, get the specific browser
292
+ const userAgent = navigator.userAgent;
293
+ return getProductFromUserAgent(userAgent);
294
+ }
295
+ default:
296
+ return Product.Unsupported;
297
+ }
298
+ }
299
+ /**
300
+ * Determines the product from a user agent string, if possible
301
+ */
302
+ export function getProductFromUserAgent(userAgent) {
303
+ if (userAgent.indexOf("Opera") !== -1 || userAgent.indexOf("OPR") !== -1)
304
+ return Product.Opera;
305
+ if (userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Chrome") === -1)
306
+ return Product.Safari;
307
+ if (userAgent.indexOf("Edg") !== -1)
308
+ return Product.Edge;
309
+ if (userAgent.indexOf("Chrome") !== -1)
310
+ return Product.Chrome;
311
+ if (userAgent.indexOf("Firefox") !== -1)
312
+ return Product.Firefox;
313
+ return Product.Unsupported;
314
+ }
315
+ /**
316
+ * Dynamically determines the version of the current product/runtime
317
+ * @returns {string} A string containing the detected version, or undefined if the product is not supported.
318
+ */
319
+ export function getCurrentVersion() {
320
+ const product = getCurrentProduct();
321
+ switch (product) {
322
+ case Product.Deno:
323
+ // @ts-ignore Runtime detection
324
+ return Deno.version.deno;
325
+ case Product.Node:
326
+ // @ts-ignore Runtime detection
327
+ return process.versions.node;
328
+ case Product.Bun:
329
+ // @ts-ignore Runtime detection
330
+ return process.versions.bun;
331
+ case Product.Tauri: //Fallthrough to default handling.
332
+ default: {
333
+ const userAgent = globalThis.navigator?.userAgent;
334
+ return getVersionFromUserAgent(userAgent);
335
+ }
336
+ }
337
+ }
338
+ /**
339
+ * Determines the product version from a user agent string, if possible
340
+ */
341
+ export function getVersionFromUserAgent(userAgent) {
342
+ const product = getProductFromUserAgent(userAgent);
343
+ switch (product) {
344
+ case Product.Chrome:
345
+ return getChromeVersion(userAgent);
346
+ case Product.Firefox:
347
+ return getFirefoxVersion(userAgent);
348
+ case Product.Edge:
349
+ return getEdgeVersion(userAgent);
350
+ case Product.Safari:
351
+ return getSafariVersion(userAgent);
352
+ case Product.Opera:
353
+ return getOperaVersion(userAgent);
354
+ case Product.Brave:
355
+ return getBraveVersion(userAgent);
356
+ default:
357
+ return undefined;
358
+ }
359
+ }
360
+ /**
361
+ * Attempts to determine the current CPU architecture of the runtime's environment.
362
+ */
363
+ export function getCurrentArchitecture() {
364
+ const runtime = getCurrentRuntime();
365
+ switch (runtime) {
366
+ case Runtime.Deno:
367
+ if (Deno.build.arch === "x86_64")
368
+ return Architecture.x64;
369
+ if (Deno.build.arch === "aarch64")
370
+ return Architecture.arm64;
371
+ if (Deno.build.os === "darwin")
372
+ return Architecture.x64;
373
+ return Architecture.x86;
374
+ case Runtime.Bun:
375
+ case Runtime.Node:
376
+ // @ts-ignore Cross Runtime
377
+ switch (process.arch) {
378
+ case "arm":
379
+ return Architecture.arm;
380
+ case "arm64":
381
+ return Architecture.arm64;
382
+ case "ia32":
383
+ return Architecture.x86;
384
+ case "x64":
385
+ return Architecture.x64;
386
+ case "loong64":
387
+ case "mips":
388
+ case "mipsel":
389
+ case "ppc":
390
+ case "ppc64":
391
+ case "riscv64":
392
+ case "s390":
393
+ case "s390x":
394
+ return Architecture.Unsupported;
395
+ }
396
+ return Architecture.Unsupported;
397
+ case Runtime.Tauri:
398
+ case Runtime.Browser: {
399
+ const userAgent = navigator.userAgent;
400
+ // @ts-ignore Cross Runtime
401
+ const platform = navigator.platform;
402
+ if (platform.indexOf("Win64") !== -1 || platform.indexOf("x64") !== -1 || platform.indexOf("x86_64") !== -1)
403
+ return Architecture.x64;
404
+ if (platform.indexOf("Win32") !== -1 || (platform.indexOf("x86") !== -1 && platform.indexOf("x86_64") === -1))
405
+ return Architecture.x86;
406
+ if (userAgent.indexOf("Win64") !== -1 || userAgent.indexOf("x64") !== -1 || userAgent.indexOf("x86_64") !== -1)
407
+ return Architecture.x64;
408
+ if (userAgent.indexOf("Win32") !== -1 || (userAgent.indexOf("x86") !== -1 && userAgent.indexOf("x86_64") === -1))
409
+ return Architecture.x86;
410
+ if (userAgent.indexOf("arm64") !== -1)
411
+ return Architecture.arm64;
412
+ if (userAgent.indexOf("arm") !== -1) {
413
+ return Architecture.arm;
414
+ }
415
+ // @ts-ignore Cross Runtime
416
+ if (platform.indexOf("iPhone") || platform.indexOf("iPad") || (userAgent.indexOf("Mac") !== -1 && "ontouchend" in document)) {
417
+ // Likely aarch64 on newer iOS devices and Apple Silicon Macs
418
+ return Architecture.arm64;
419
+ }
420
+ return Architecture.Unsupported;
421
+ }
422
+ }
423
+ return Architecture.Unsupported;
424
+ }
425
+ /**
426
+ * Retrieves the current system information.
427
+ * @returns {SystemInfo} An object containing the system information.
428
+ */
429
+ function getSystemInfoInternal() {
430
+ const systemInfo = {
431
+ runtime: CurrentRuntime,
432
+ product: CurrentProduct,
433
+ version: CurrentVersion,
434
+ os: CurrentOS,
435
+ architecture: CurrentArchitecture,
436
+ };
437
+ return systemInfo;
438
+ }
439
+ /**
440
+ * Logs current system information to the console.
441
+ *
442
+ * @param {boolean} [useTable=false] - If true, formats the output as a table.
443
+ */
444
+ export function dumpSystemInfo(useTable = false) {
445
+ const systemInfo = getSystemInfoInternal();
446
+ if (useTable) {
447
+ console.table(systemInfo);
448
+ }
449
+ else {
450
+ console.log(JSON.stringify(systemInfo, null, 2));
451
+ }
452
+ }
453
+ /**
454
+ * Gets the current system information as a formatted JSON string.
455
+ * @returns {string}
456
+ */
457
+ export function getSystemInfo() {
458
+ const systemInfo = getSystemInfoInternal();
459
+ return JSON.stringify(systemInfo);
460
+ }
461
+ /**
462
+ * Static variable containing the current runtime.
463
+ */
464
+ export const CurrentRuntime = getCurrentRuntime();
465
+ /**
466
+ * Static variable containing the current product.
467
+ */
468
+ export const CurrentProduct = getCurrentProduct();
469
+ /**
470
+ * Static variable containing the current product/runtime version.
471
+ */
472
+ export const CurrentVersion = getCurrentVersion();
473
+ /**
474
+ * Static variable containing the current operating system.
475
+ */
476
+ export const CurrentOS = getCurrentOS();
477
+ /**
478
+ * Static variable containing the current operating system.
479
+ */
480
+ export const CurrentArchitecture = getCurrentArchitecture();
package/esm/mod.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @pinta365/strava - TypeScript client for Strava API v3
3
+ *
4
+ * A cross-runtime (Deno, Node.js, Bun, Browser) library for interacting with the Strava API.
5
+ */
6
+ export { StravaClient } from "./src/client.js";
7
+ export type { AuthCredentials, ClientOptions } from "./src/client.js";
8
+ export { StravaAuthError, StravaError, StravaNotFoundError, StravaRateLimitError, StravaServerError, StravaValidationError } from "./src/errors.js";
9
+ export { exchangeCode, getAuthorizationUrl, OAuthManager, refreshAccessToken } from "./src/auth/oauth.js";
10
+ export { formatScopes, hasAllScopes, hasScope, parseScopes, StravaScope, validateScopes } from "./src/auth/scopes.js";
11
+ export type { TokenData, TokenStore } from "./src/auth/token-store.js";
12
+ export { FileSystemTokenStore, getDefaultTokenStore, LocalStorageTokenStore, MemoryTokenStore } from "./src/auth/token-store.js";
13
+ export type { PaginationOptions, RateLimitInfo, RateLimitStrategy, RequestConfig, RetryConfig } from "./src/types/common.js";
14
+ export type { Activity, ActivityStats, ActivityTotal, ActivityType, ActivityZone, Athlete, Club, Comment, DetailedActivity, DetailedAthlete, DetailedClub, DetailedGear, DetailedSegment, DetailedSegmentEffort, ExplorerResponse, ExplorerSegment, Gear, Lap, LatLng, PhotosSummary, PolylineMap, Route, Segment, SegmentEffort, Split, SportType, StreamSet, SummaryActivity, SummaryAthlete, SummaryClub, SummaryGear, SummaryPRSegmentEffort, SummarySegment, SummarySegmentEffort, UpdatableActivity, Upload, Waypoint, Zones, } from "./src/types/api.js";
15
+ export { AthletesResource } from "./src/resources/athletes.js";
16
+ export { ActivitiesResource } from "./src/resources/activities.js";
17
+ export { SegmentsResource } from "./src/resources/segments.js";
18
+ export { SegmentEffortsResource } from "./src/resources/segment-efforts.js";
19
+ export { ClubsResource } from "./src/resources/clubs.js";
20
+ export { GearsResource } from "./src/resources/gears.js";
21
+ export { RoutesResource } from "./src/resources/routes.js";
22
+ export { UploadsResource } from "./src/resources/uploads.js";
23
+ export { StreamsResource } from "./src/resources/streams.js";
24
+ export { buildPaginationQuery, listAll, PaginatedIterator } from "./src/utils/pagination.js";
25
+ export { addComputedFields, applyTransformations, flattenResponses, transformDates } from "./src/utils/transformers.js";
26
+ export { validateDate, validateNonEmptyString, validateNonNegativeInteger, validatePagination, validatePositiveInteger, validateRange, } from "./src/utils/validators.js";
27
+ //# sourceMappingURL=mod.d.ts.map
package/esm/mod.js ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @pinta365/strava - TypeScript client for Strava API v3
3
+ *
4
+ * A cross-runtime (Deno, Node.js, Bun, Browser) library for interacting with the Strava API.
5
+ */
6
+ // Main client
7
+ export { StravaClient } from "./src/client.js";
8
+ // Error classes
9
+ export { StravaAuthError, StravaError, StravaNotFoundError, StravaRateLimitError, StravaServerError, StravaValidationError } from "./src/errors.js";
10
+ // Auth
11
+ export { exchangeCode, getAuthorizationUrl, OAuthManager, refreshAccessToken } from "./src/auth/oauth.js";
12
+ export { formatScopes, hasAllScopes, hasScope, parseScopes, StravaScope, validateScopes } from "./src/auth/scopes.js";
13
+ export { FileSystemTokenStore, getDefaultTokenStore, LocalStorageTokenStore, MemoryTokenStore } from "./src/auth/token-store.js";
14
+ // Resources (for advanced usage)
15
+ export { AthletesResource } from "./src/resources/athletes.js";
16
+ export { ActivitiesResource } from "./src/resources/activities.js";
17
+ export { SegmentsResource } from "./src/resources/segments.js";
18
+ export { SegmentEffortsResource } from "./src/resources/segment-efforts.js";
19
+ export { ClubsResource } from "./src/resources/clubs.js";
20
+ export { GearsResource } from "./src/resources/gears.js";
21
+ export { RoutesResource } from "./src/resources/routes.js";
22
+ export { UploadsResource } from "./src/resources/uploads.js";
23
+ export { StreamsResource } from "./src/resources/streams.js";
24
+ // Utilities
25
+ export { buildPaginationQuery, listAll, PaginatedIterator } from "./src/utils/pagination.js";
26
+ export { addComputedFields, applyTransformations, flattenResponses, transformDates } from "./src/utils/transformers.js";
27
+ export { validateDate, validateNonEmptyString, validateNonNegativeInteger, validatePagination, validatePositiveInteger, validateRange, } from "./src/utils/validators.js";
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * OAuth 2.0 authentication flow for Strava API
3
+ */
4
+ import type { TokenData, TokenStore } from "./token-store.js";
5
+ import { type StravaScope } from "./scopes.js";
6
+ interface AuthorizationUrlOptions {
7
+ clientId: string;
8
+ redirectUri: string;
9
+ scope: StravaScope[];
10
+ state?: string;
11
+ approvalPrompt?: "force" | "auto";
12
+ }
13
+ /**
14
+ * Generate authorization URL
15
+ */
16
+ export declare function getAuthorizationUrl(options: AuthorizationUrlOptions): string;
17
+ /**
18
+ * Exchange authorization code for tokens
19
+ * @param code - Authorization code from OAuth callback
20
+ * @param clientId - Strava client ID
21
+ * @param clientSecret - Strava client secret
22
+ * @param redirectUri - Redirect URI used in authorization (optional)
23
+ * @returns Token data
24
+ */
25
+ export declare function exchangeCode(code: string, clientId: string, clientSecret: string, redirectUri?: string): Promise<TokenData>;
26
+ /**
27
+ * Refresh access token using refresh token
28
+ */
29
+ export declare function refreshAccessToken(refreshToken: string, clientId: string, clientSecret: string): Promise<TokenData>;
30
+ /**
31
+ * Check if token is expired or about to expire
32
+ */
33
+ export declare function isTokenExpired(token: TokenData, bufferSeconds?: number): boolean;
34
+ /**
35
+ * OAuth manager for handling authentication and token refresh
36
+ */
37
+ export declare class OAuthManager {
38
+ private tokenStore;
39
+ private clientId;
40
+ private clientSecret;
41
+ constructor(clientId: string, clientSecret: string, tokenStore: TokenStore);
42
+ /**
43
+ * Get authorization URL
44
+ */
45
+ getAuthorizationUrl(options: Omit<AuthorizationUrlOptions, "clientId">): string;
46
+ /**
47
+ * Exchange code and store tokens
48
+ */
49
+ authenticate(code: string, redirectUri?: string): Promise<TokenData>;
50
+ /**
51
+ * Get current token, refreshing if needed
52
+ */
53
+ getToken(): Promise<TokenData | null>;
54
+ /**
55
+ * Manually refresh token
56
+ */
57
+ refreshToken(): Promise<TokenData>;
58
+ /**
59
+ * Get current scopes
60
+ */
61
+ getScopes(): Promise<StravaScope[]>;
62
+ /**
63
+ * Clear stored tokens
64
+ */
65
+ clearTokens(): Promise<void>;
66
+ }
67
+ export {};
68
+ //# sourceMappingURL=oauth.d.ts.map