@fink-andreas/pi-linear-tools 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Linear SDK client factory
3
+ *
4
+ * Creates a configured LinearClient instance for interacting with Linear API.
5
+ */
6
+
7
+ import { LinearClient } from '@linear/sdk';
8
+
9
+ /** @type {Function|null} Test-only client factory override */
10
+ let _testClientFactory = null;
11
+
12
+ /**
13
+ * Create a Linear SDK client
14
+ * @param {string} apiKey - Linear API key
15
+ * @returns {LinearClient} Configured Linear client
16
+ */
17
+ export function createLinearClient(apiKey) {
18
+ // Allow test override
19
+ if (_testClientFactory) {
20
+ return _testClientFactory(apiKey);
21
+ }
22
+
23
+ if (!apiKey || typeof apiKey !== 'string') {
24
+ throw new Error('Linear API key is required');
25
+ }
26
+
27
+ return new LinearClient({ apiKey });
28
+ }
29
+
30
+ /**
31
+ * Set a mock client factory for testing (TEST ONLY)
32
+ * @param {Function|null} factory - Factory function that returns a mock client
33
+ */
34
+ export function setTestClientFactory(factory) {
35
+ _testClientFactory = factory;
36
+ }
37
+
38
+ /**
39
+ * Reset test client factory
40
+ */
41
+ export function resetTestClientFactory() {
42
+ _testClientFactory = null;
43
+ }