@c15t/node-sdk 1.2.0-canary.12 → 1.2.0-canary.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.
@@ -1,22 +1,22 @@
1
1
 
2
2
  
3
- > @c15t/node-sdk@1.2.0-canary.12 build /Users/christopherburns/glados/k/c15t/packages/node-sdk
3
+ > @c15t/node-sdk@1.2.0-canary.13 build /Users/christopherburns/glados/k/c15t/packages/node-sdk
4
4
  > rslib build
5
5
 
6
6
    Rslib v0.6.2
7
7
  
8
- ready  built in 0.04 s (esm)
9
- ready  built in 0.04 s (cjs)
8
+ ready  built in 0.05 s (esm)
9
+ ready  built in 0.05 s (cjs)
10
10
  start  generating declaration files... (esm)
11
11
  start  generating declaration files... (cjs)
12
- ready  declaration files generated in 0.63 s (esm)
13
- ready  declaration files generated in 0.63 s (cjs)
12
+ ready  declaration files generated in 1.65 s (esm)
13
+ ready  declaration files generated in 1.76 s (cjs)
14
14
 
15
15
   File (esm) Size 
16
- dist/index.js 0.78 kB
16
+ dist/index.js 0.95 kB
17
17
 
18
18
   -----
19
19
 
20
20
   File (cjs) Size 
21
- dist/index.cjs 1.8 kB
21
+ dist/index.cjs 1.9 kB
22
22
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  
3
- > @c15t/node-sdk@1.2.0-canary.9 fmt /Users/christopherburns/glados/k/c15t/packages/node-sdk
4
- > pnpm biome format --write . && biome check --formatter-enabled=false --linter-enabled=false --organize-imports-enabled=true --write
3
+ > @c15t/node-sdk@1.2.0-canary.12 fmt /Users/christopherburns/glados/k/c15t/packages/node-sdk
4
+ > pnpm biome format --write . && pnpm biome check --formatter-enabled=false --linter-enabled=false --organize-imports-enabled=true --write
5
5
 
6
- Formatted 5 files in 68ms. No fixes applied.
7
- Checked 5 files in 4ms. No fixes applied.
6
+ Formatted 6 files in 9ms. No fixes applied.
7
+ Checked 6 files in 4ms. No fixes applied.
@@ -1,2 +1,2 @@
1
- {"/Users/christopherburns/glados/k/c15t/packages/node-sdk/src/index.ts": {"path":"/Users/christopherburns/glados/k/c15t/packages/node-sdk/src/index.ts","statementMap":{"0":{"start":{"line":54,"column":45},"end":{"line":56,"column":null}},"1":{"start":{"line":59,"column":17},"end":{"line":59,"column":null}},"2":{"start":{"line":62,"column":1},"end":{"line":64,"column":null}},"3":{"start":{"line":63,"column":2},"end":{"line":63,"column":null}},"4":{"start":{"line":67,"column":14},"end":{"line":73,"column":null}},"5":{"start":{"line":78,"column":16},"end":{"line":78,"column":null}},"6":{"start":{"line":80,"column":1},"end":{"line":80,"column":null}}},"fnMap":{"0":{"name":"c15tClient","decl":{"start":{"line":52,"column":16},"end":{"line":52,"column":27}},"loc":{"start":{"line":52,"column":55},"end":{"line":81,"column":null}}}},"branchMap":{"0":{"loc":{"start":{"line":54,"column":45},"end":{"line":56,"column":null}},"type":"cond-expr","locations":[{"start":{"line":55,"column":4},"end":{"line":55,"column":null}},{"start":{"line":56,"column":4},"end":{"line":56,"column":null}}]},"1":{"loc":{"start":{"line":62,"column":1},"end":{"line":64,"column":null}},"type":"if","locations":[{"start":{"line":62,"column":1},"end":{"line":64,"column":null}},{"start":{},"end":{}}]}},"s":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0},"f":{"0":0},"b":{"0":[0,0],"1":[0,0]}}
1
+ {"/Users/christopherburns/glados/k/c15t/packages/node-sdk/src/index.ts": {"path":"/Users/christopherburns/glados/k/c15t/packages/node-sdk/src/index.ts","statementMap":{"0":{"start":{"line":55,"column":45},"end":{"line":57,"column":null}},"1":{"start":{"line":60,"column":17},"end":{"line":60,"column":null}},"2":{"start":{"line":63,"column":1},"end":{"line":65,"column":null}},"3":{"start":{"line":64,"column":2},"end":{"line":64,"column":null}},"4":{"start":{"line":67,"column":14},"end":{"line":73,"column":null}},"5":{"start":{"line":79,"column":1},"end":{"line":79,"column":null}}},"fnMap":{"0":{"name":"c15tClient","decl":{"start":{"line":53,"column":16},"end":{"line":53,"column":27}},"loc":{"start":{"line":53,"column":55},"end":{"line":80,"column":null}}}},"branchMap":{"0":{"loc":{"start":{"line":55,"column":45},"end":{"line":57,"column":null}},"type":"cond-expr","locations":[{"start":{"line":56,"column":4},"end":{"line":56,"column":null}},{"start":{"line":57,"column":4},"end":{"line":57,"column":null}}]},"1":{"loc":{"start":{"line":63,"column":1},"end":{"line":65,"column":null}},"type":"if","locations":[{"start":{"line":63,"column":1},"end":{"line":65,"column":null}},{"start":{},"end":{}}]}},"s":{"0":8,"1":8,"2":6,"3":3,"4":6,"5":6},"f":{"0":8},"b":{"0":[1,7],"1":[3,3]}}
2
2
  }
@@ -1,3 +1,3 @@
1
- {"total": {"lines":{"total":7,"covered":0,"skipped":0,"pct":0},"statements":{"total":7,"covered":0,"skipped":0,"pct":0},"functions":{"total":1,"covered":0,"skipped":0,"pct":0},"branches":{"total":4,"covered":0,"skipped":0,"pct":0},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}}
2
- ,"/Users/christopherburns/glados/k/c15t/packages/node-sdk/src/index.ts": {"lines":{"total":7,"covered":0,"skipped":0,"pct":0},"functions":{"total":1,"covered":0,"skipped":0,"pct":0},"statements":{"total":7,"covered":0,"skipped":0,"pct":0},"branches":{"total":4,"covered":0,"skipped":0,"pct":0}}
1
+ {"total": {"lines":{"total":6,"covered":6,"skipped":0,"pct":100},"statements":{"total":6,"covered":6,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"branches":{"total":4,"covered":4,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}}
2
+ ,"/Users/christopherburns/glados/k/c15t/packages/node-sdk/src/index.ts": {"lines":{"total":6,"covered":6,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":6,"covered":6,"skipped":0,"pct":100},"branches":{"total":4,"covered":4,"skipped":0,"pct":100}}
3
3
  }
@@ -23,30 +23,30 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">0% </span>
26
+ <span class="strong">100% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>0/7</span>
28
+ <span class='fraction'>6/6</span>
29
29
  </div>
30
30
 
31
31
 
32
32
  <div class='fl pad1y space-right2'>
33
- <span class="strong">0% </span>
33
+ <span class="strong">100% </span>
34
34
  <span class="quiet">Branches</span>
35
- <span class='fraction'>0/4</span>
35
+ <span class='fraction'>4/4</span>
36
36
  </div>
37
37
 
38
38
 
39
39
  <div class='fl pad1y space-right2'>
40
- <span class="strong">0% </span>
40
+ <span class="strong">100% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>0/1</span>
42
+ <span class='fraction'>1/1</span>
43
43
  </div>
44
44
 
45
45
 
46
46
  <div class='fl pad1y space-right2'>
47
- <span class="strong">0% </span>
47
+ <span class="strong">100% </span>
48
48
  <span class="quiet">Lines</span>
49
- <span class='fraction'>0/7</span>
49
+ <span class='fraction'>6/6</span>
50
50
  </div>
51
51
 
52
52
 
@@ -61,7 +61,7 @@
61
61
  </div>
62
62
  </template>
63
63
  </div>
64
- <div class='status-line low'></div>
64
+ <div class='status-line high'></div>
65
65
  <div class="pad1">
66
66
  <table class="coverage-summary">
67
67
  <thead>
@@ -79,18 +79,18 @@
79
79
  </tr>
80
80
  </thead>
81
81
  <tbody><tr>
82
- <td class="file low" data-value="index.ts"><a href="index.ts.html">index.ts</a></td>
83
- <td data-value="0" class="pic low">
84
- <div class="chart"><div class="cover-fill" style="width: 0%"></div><div class="cover-empty" style="width: 100%"></div></div>
82
+ <td class="file high" data-value="index.ts"><a href="index.ts.html">index.ts</a></td>
83
+ <td data-value="100" class="pic high">
84
+ <div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
85
85
  </td>
86
- <td data-value="0" class="pct low">0%</td>
87
- <td data-value="7" class="abs low">0/7</td>
88
- <td data-value="0" class="pct low">0%</td>
89
- <td data-value="4" class="abs low">0/4</td>
90
- <td data-value="0" class="pct low">0%</td>
91
- <td data-value="1" class="abs low">0/1</td>
92
- <td data-value="0" class="pct low">0%</td>
93
- <td data-value="7" class="abs low">0/7</td>
86
+ <td data-value="100" class="pct high">100%</td>
87
+ <td data-value="6" class="abs high">6/6</td>
88
+ <td data-value="100" class="pct high">100%</td>
89
+ <td data-value="4" class="abs high">4/4</td>
90
+ <td data-value="100" class="pct high">100%</td>
91
+ <td data-value="1" class="abs high">1/1</td>
92
+ <td data-value="100" class="pct high">100%</td>
93
+ <td data-value="6" class="abs high">6/6</td>
94
94
  </tr>
95
95
 
96
96
  </tbody>
@@ -101,7 +101,7 @@
101
101
  <div class='footer quiet pad2 space-top1 center small'>
102
102
  Code coverage generated by
103
103
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
104
- at 2025-05-08T23:05:30.707Z
104
+ at 2025-05-09T21:48:42.619Z
105
105
  </div>
106
106
  <script src="prettify.js"></script>
107
107
  <script>
@@ -23,30 +23,30 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">0% </span>
26
+ <span class="strong">100% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>0/7</span>
28
+ <span class='fraction'>6/6</span>
29
29
  </div>
30
30
 
31
31
 
32
32
  <div class='fl pad1y space-right2'>
33
- <span class="strong">0% </span>
33
+ <span class="strong">100% </span>
34
34
  <span class="quiet">Branches</span>
35
- <span class='fraction'>0/4</span>
35
+ <span class='fraction'>4/4</span>
36
36
  </div>
37
37
 
38
38
 
39
39
  <div class='fl pad1y space-right2'>
40
- <span class="strong">0% </span>
40
+ <span class="strong">100% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>0/1</span>
42
+ <span class='fraction'>1/1</span>
43
43
  </div>
44
44
 
45
45
 
46
46
  <div class='fl pad1y space-right2'>
47
- <span class="strong">0% </span>
47
+ <span class="strong">100% </span>
48
48
  <span class="quiet">Lines</span>
49
- <span class='fraction'>0/7</span>
49
+ <span class='fraction'>6/6</span>
50
50
  </div>
51
51
 
52
52
 
@@ -61,7 +61,7 @@
61
61
  </div>
62
62
  </template>
63
63
  </div>
64
- <div class='status-line low'></div>
64
+ <div class='status-line high'></div>
65
65
  <pre><table class="coverage">
66
66
  <tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
67
67
  <a name='L2'></a><a href='#L2'>2</a>
@@ -142,9 +142,7 @@
142
142
  <a name='L77'></a><a href='#L77'>77</a>
143
143
  <a name='L78'></a><a href='#L78'>78</a>
144
144
  <a name='L79'></a><a href='#L79'>79</a>
145
- <a name='L80'></a><a href='#L80'>80</a>
146
- <a name='L81'></a><a href='#L81'>81</a>
147
- <a name='L82'></a><a href='#L82'>82</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
145
+ <a name='L80'></a><a href='#L80'>80</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
148
146
  <span class="cline-any cline-neutral">&nbsp;</span>
149
147
  <span class="cline-any cline-neutral">&nbsp;</span>
150
148
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -197,20 +195,20 @@
197
195
  <span class="cline-any cline-neutral">&nbsp;</span>
198
196
  <span class="cline-any cline-neutral">&nbsp;</span>
199
197
  <span class="cline-any cline-neutral">&nbsp;</span>
200
- <span class="cline-any cline-no">&nbsp;</span>
201
198
  <span class="cline-any cline-neutral">&nbsp;</span>
199
+ <span class="cline-any cline-yes">8x</span>
202
200
  <span class="cline-any cline-neutral">&nbsp;</span>
203
201
  <span class="cline-any cline-neutral">&nbsp;</span>
204
202
  <span class="cline-any cline-neutral">&nbsp;</span>
205
- <span class="cline-any cline-no">&nbsp;</span>
206
203
  <span class="cline-any cline-neutral">&nbsp;</span>
204
+ <span class="cline-any cline-yes">8x</span>
207
205
  <span class="cline-any cline-neutral">&nbsp;</span>
208
- <span class="cline-any cline-no">&nbsp;</span>
209
- <span class="cline-any cline-no">&nbsp;</span>
210
206
  <span class="cline-any cline-neutral">&nbsp;</span>
207
+ <span class="cline-any cline-yes">6x</span>
208
+ <span class="cline-any cline-yes">3x</span>
211
209
  <span class="cline-any cline-neutral">&nbsp;</span>
212
210
  <span class="cline-any cline-neutral">&nbsp;</span>
213
- <span class="cline-any cline-no">&nbsp;</span>
211
+ <span class="cline-any cline-yes">6x</span>
214
212
  <span class="cline-any cline-neutral">&nbsp;</span>
215
213
  <span class="cline-any cline-neutral">&nbsp;</span>
216
214
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -221,14 +219,13 @@
221
219
  <span class="cline-any cline-neutral">&nbsp;</span>
222
220
  <span class="cline-any cline-neutral">&nbsp;</span>
223
221
  <span class="cline-any cline-neutral">&nbsp;</span>
224
- <span class="cline-any cline-no">&nbsp;</span>
225
222
  <span class="cline-any cline-neutral">&nbsp;</span>
226
- <span class="cline-any cline-no">&nbsp;</span>
227
- <span class="cline-any cline-neutral">&nbsp;</span>
228
- <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import type { router } from '@c15t/backend/router';
223
+ <span class="cline-any cline-yes">6x</span>
224
+ <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import { contracts } from '@c15t/backend/contracts';
229
225
  import { createORPCClient } from '@orpc/client';
230
- import { RPCLink } from '@orpc/client/fetch';
231
- import type { RouterClient } from '@orpc/server';
226
+ import { OpenAPILink } from '@orpc/openapi-client/fetch';
227
+ import type { JsonifiedClient } from '@orpc/openapi-client';
228
+ import type { ContractRouterClient } from '@orpc/contract';
232
229
  &nbsp;
233
230
  /**
234
231
  * Configuration options for the C15T SDK client
@@ -276,22 +273,21 @@ export interface C15TClientOptions {
276
273
  * const response = await client.users.getProfile({ userId: "123" });
277
274
  * ```
278
275
  */
279
- export function <span class="fstat-no" title="function not covered" >c15tClient(o</span>ptions: C15TClientOptions) {
276
+ export function c15tClient(options: C15TClientOptions) {
280
277
  // Prepare authorization header if token is provided
281
- const authHeaders: Record&lt;string, string&gt; = <span class="cstat-no" title="statement not covered" >options.token</span>
278
+ const authHeaders: Record&lt;string, string&gt; = options.token
282
279
  ? { Authorization: `Bearer ${options.token}` }
283
280
  : {};
284
281
  &nbsp;
285
282
  // Prepare the base URL, potentially with prefix
286
- const baseUrl = <span class="cstat-no" title="statement not covered" >new URL(options.baseUrl);</span>
283
+ const baseUrl = new URL(options.baseUrl);
287
284
  &nbsp;
288
285
  // If prefix is provided, apply it to the base URL path
289
- <span class="cstat-no" title="statement not covered" > if (options.prefix) {</span>
290
- <span class="cstat-no" title="statement not covered" > baseUrl.pathname = options.prefix;</span>
286
+ if (options.prefix) {
287
+ baseUrl.pathname = options.prefix;
291
288
  }
292
289
  &nbsp;
293
- // Create the RPC link with the configured options
294
- const link = <span class="cstat-no" title="statement not covered" >new RPCLink({</span>
290
+ const link = new OpenAPILink(contracts, {
295
291
  url: baseUrl.toString(),
296
292
  headers: {
297
293
  ...authHeaders,
@@ -302,18 +298,16 @@ export function <span class="fstat-no" title="function not covered" >c15tClient(
302
298
  // Create and return the client with a type assertion
303
299
  // This approach avoids complex type issues while providing
304
300
  // the same runtime functionality
305
- const client = <span class="cstat-no" title="statement not covered" >createORPCClient(link);</span>
306
301
  &nbsp;
307
- <span class="cstat-no" title="statement not covered" > return client as RouterClient&lt;typeof router&gt;;</span>
308
- }
309
- &nbsp;</pre></td></tr></table></pre>
302
+ return createORPCClient(link) as JsonifiedClient&lt;ContractRouterClient&lt;typeof contracts&gt;&gt;;
303
+ }</pre></td></tr></table></pre>
310
304
 
311
305
  <div class='push'></div><!-- for sticky footer -->
312
306
  </div><!-- /wrapper -->
313
307
  <div class='footer quiet pad2 space-top1 center small'>
314
308
  Code coverage generated by
315
309
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
316
- at 2025-05-08T23:05:30.707Z
310
+ at 2025-05-09T21:48:42.619Z
317
311
  </div>
318
312
  <script src="prettify.js"></script>
319
313
  <script>
package/dist/index.cjs CHANGED
@@ -26,23 +26,23 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  c15tClient: ()=>c15tClient
28
28
  });
29
+ const contracts_namespaceObject = require("@c15t/backend/contracts");
29
30
  const client_namespaceObject = require("@orpc/client");
30
- const fetch_namespaceObject = require("@orpc/client/fetch");
31
+ const fetch_namespaceObject = require("@orpc/openapi-client/fetch");
31
32
  function c15tClient(options) {
32
33
  const authHeaders = options.token ? {
33
34
  Authorization: `Bearer ${options.token}`
34
35
  } : {};
35
36
  const baseUrl = new URL(options.baseUrl);
36
37
  if (options.prefix) baseUrl.pathname = options.prefix;
37
- const link = new fetch_namespaceObject.RPCLink({
38
+ const link = new fetch_namespaceObject.OpenAPILink(contracts_namespaceObject.contracts, {
38
39
  url: baseUrl.toString(),
39
40
  headers: {
40
41
  ...authHeaders,
41
42
  ...options.headers
42
43
  }
43
44
  });
44
- const client = (0, client_namespaceObject.createORPCClient)(link);
45
- return client;
45
+ return (0, client_namespaceObject.createORPCClient)(link);
46
46
  }
47
47
  exports.c15tClient = __webpack_exports__.c15tClient;
48
48
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import type { router } from '@c15t/backend/router';
2
- import type { RouterClient } from '@orpc/server';
1
+ import { contracts } from '@c15t/backend/contracts';
2
+ import type { ContractRouterClient } from '@orpc/contract';
3
+ import type { JsonifiedClient } from '@orpc/openapi-client';
3
4
  /**
4
5
  * Configuration options for the C15T SDK client
5
6
  */
@@ -42,5 +43,5 @@ export interface C15TClientOptions {
42
43
  * const response = await client.users.getProfile({ userId: "123" });
43
44
  * ```
44
45
  */
45
- export declare function c15tClient(options: C15TClientOptions): RouterClient<typeof router>;
46
+ export declare function c15tClient(options: C15TClientOptions): JsonifiedClient<ContractRouterClient<typeof contracts>>;
46
47
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GA4BnC,YAAY,CAAC,OAAO,MAAM,CAAC,CAC5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GA0BnB,eAAe,CAC/C,oBAAoB,CAAC,OAAO,SAAS,CAAC,CACtC,CACD"}
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE__c15t_backend_contracts_743894b8__ from "@c15t/backend/contracts";
1
2
  import * as __WEBPACK_EXTERNAL_MODULE__orpc_client_e16cd7f2__ from "@orpc/client";
2
- import * as __WEBPACK_EXTERNAL_MODULE__orpc_client_fetch_45535244__ from "@orpc/client/fetch";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__orpc_openapi_client_fetch_375f7e70__ from "@orpc/openapi-client/fetch";
3
4
  function c15tClient(options) {
4
5
  const authHeaders = options.token ? {
5
6
  Authorization: `Bearer ${options.token}`
6
7
  } : {};
7
8
  const baseUrl = new URL(options.baseUrl);
8
9
  if (options.prefix) baseUrl.pathname = options.prefix;
9
- const link = new __WEBPACK_EXTERNAL_MODULE__orpc_client_fetch_45535244__.RPCLink({
10
+ const link = new __WEBPACK_EXTERNAL_MODULE__orpc_openapi_client_fetch_375f7e70__.OpenAPILink(__WEBPACK_EXTERNAL_MODULE__c15t_backend_contracts_743894b8__.contracts, {
10
11
  url: baseUrl.toString(),
11
12
  headers: {
12
13
  ...authHeaders,
13
14
  ...options.headers
14
15
  }
15
16
  });
16
- const client = (0, __WEBPACK_EXTERNAL_MODULE__orpc_client_e16cd7f2__.createORPCClient)(link);
17
- return client;
17
+ return (0, __WEBPACK_EXTERNAL_MODULE__orpc_client_e16cd7f2__.createORPCClient)(link);
18
18
  }
19
19
  export { c15tClient };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c15t/node-sdk",
3
- "version": "1.2.0-canary.12",
3
+ "version": "1.2.0-canary.13",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -11,8 +11,10 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@orpc/client": "1.2.0",
14
+ "@orpc/contract": "1.2.0",
15
+ "@orpc/openapi-client": "^1.2.0",
14
16
  "@orpc/server": "1.2.0",
15
- "@c15t/backend": "1.2.0-canary.12"
17
+ "@c15t/backend": "1.2.0-canary.13"
16
18
  },
17
19
  "devDependencies": {
18
20
  "@electric-sql/pglite": "0.2.17",
@@ -22,6 +24,7 @@
22
24
  "@types/node": "20.14.13",
23
25
  "@types/pg": "8.11.6",
24
26
  "kysely-pglite": "^0.6.1",
27
+ "msw": "^2.7.6",
25
28
  "typescript": "^5.8.3",
26
29
  "vitest": "^3.1.1",
27
30
  "@c15t/typescript-config": "0.0.1-beta.1",
@@ -32,7 +35,7 @@
32
35
  "check-types": "tsc --noEmit",
33
36
  "check-types:test": "tsc -p tsconfig.test.json",
34
37
  "dev": "rslib build --watch",
35
- "fmt": "pnpm biome format --write . && biome check --formatter-enabled=false --linter-enabled=false --organize-imports-enabled=true --write",
38
+ "fmt": "pnpm biome format --write . && pnpm biome check --formatter-enabled=false --linter-enabled=false --organize-imports-enabled=true --write",
36
39
  "lint": "pnpm biome lint ./src",
37
40
  "test": "vitest run",
38
41
  "test:watch": "vitest"
@@ -0,0 +1,218 @@
1
+ import { createServer } from 'node:http';
2
+ import { c15tInstance } from '@c15t/backend';
3
+ import type { C15TOptions } from '@c15t/backend';
4
+ import {
5
+ afterAll,
6
+ beforeAll,
7
+ beforeEach,
8
+ describe,
9
+ expect,
10
+ it,
11
+ vi,
12
+ } from 'vitest';
13
+ import { c15tClient } from './index';
14
+
15
+ // Server configuration for integration tests
16
+ const mockOptions: C15TOptions = {
17
+ appName: 'C15T Test Server',
18
+ basePath: '/',
19
+ trustedOrigins: ['localhost', 'test.example.com'],
20
+ cors: true,
21
+ advanced: {
22
+ cors: {
23
+ allowHeaders: ['content-type', 'x-request-id'],
24
+ },
25
+ },
26
+ // logger: {
27
+ // level: 'debug',
28
+ // },
29
+ };
30
+
31
+ describe('C15T Node SDK', () => {
32
+ const PORT = 8787;
33
+ const mockBaseUrl = `http://localhost:${PORT}`;
34
+ let server: ReturnType<typeof c15tInstance>;
35
+ let httpServer: ReturnType<typeof createServer>;
36
+ let client: ReturnType<typeof c15tClient>;
37
+
38
+ beforeAll(async () => {
39
+ // Initialize the server for integration tests
40
+ server = c15tInstance(mockOptions);
41
+
42
+ // Create and start HTTP server
43
+ httpServer = createServer(async (req, res) => {
44
+ try {
45
+ // Read request body if present
46
+ let body: string | undefined;
47
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
48
+ const chunks: Uint8Array[] = [];
49
+ for await (const chunk of req) {
50
+ chunks.push(chunk);
51
+ }
52
+ body = Buffer.concat(chunks).toString();
53
+ }
54
+
55
+ // Convert Node.js request to web standard Request
56
+ const request = new Request(`http://localhost:${PORT}${req.url}`, {
57
+ method: req.method,
58
+ headers: req.headers as Record<string, string>,
59
+ body: body,
60
+ duplex: 'half',
61
+ });
62
+
63
+ // Handle the request with c15tInstance
64
+ const response = await server.handler(request);
65
+
66
+ // Set response status and headers
67
+ res.statusCode = response.status;
68
+ for (const [key, value] of response.headers.entries()) {
69
+ res.setHeader(key, value);
70
+ }
71
+
72
+ // Ensure content-type is set for JSON responses
73
+ if (!response.headers.get('content-type')) {
74
+ res.setHeader('content-type', 'application/json');
75
+ }
76
+
77
+ // Get response body
78
+ const responseBody = await response.text();
79
+
80
+ // Send response
81
+ res.end(responseBody);
82
+ } catch (error) {
83
+ // biome-ignore lint/suspicious/noConsoleLog: its a test
84
+ // biome-ignore lint/suspicious/noConsole: its a test
85
+ console.error('Server error:', error);
86
+ res.statusCode = 500;
87
+ res.setHeader('content-type', 'application/json');
88
+ res.end(
89
+ JSON.stringify({
90
+ error: 'Internal Server Error',
91
+ message: error instanceof Error ? error.message : String(error),
92
+ })
93
+ );
94
+ }
95
+ });
96
+
97
+ await new Promise<void>((resolve) => {
98
+ httpServer.listen(PORT, () => {
99
+ // biome-ignore lint/suspicious/noConsoleLog: its a test
100
+ // biome-ignore lint/suspicious/noConsole: its a test
101
+ console.log(`Test server listening on port ${PORT}`);
102
+ resolve();
103
+ });
104
+ });
105
+
106
+ // Initialize the client for testing
107
+ client = c15tClient({
108
+ baseUrl: mockBaseUrl,
109
+ prefix: '/',
110
+ });
111
+ });
112
+
113
+ afterAll(async () => {
114
+ // Clean up server
115
+ await new Promise<void>((resolve) => {
116
+ httpServer.close(() => {
117
+ // biome-ignore lint/suspicious/noConsoleLog: its a test
118
+ // biome-ignore lint/suspicious/noConsole: its a test
119
+ console.log('Test server closed');
120
+ resolve();
121
+ });
122
+ });
123
+ });
124
+
125
+ beforeEach(() => {
126
+ vi.clearAllMocks();
127
+ });
128
+
129
+ describe('Unit Tests', () => {
130
+ describe('Client Creation', () => {
131
+ it('should create a client with basic configuration', () => {
132
+ const client = c15tClient({ baseUrl: mockBaseUrl });
133
+
134
+ expect(client).toBeDefined();
135
+ expect(client.consent).toBeDefined();
136
+ expect(client.meta).toBeDefined();
137
+ });
138
+
139
+ it('should include authorization header when token is provided', () => {
140
+ const client = c15tClient({
141
+ baseUrl: mockBaseUrl,
142
+ token: 'test-token',
143
+ });
144
+
145
+ expect(client).toBeDefined();
146
+ });
147
+
148
+ it('should include custom headers when provided', () => {
149
+ const client = c15tClient({
150
+ baseUrl: mockBaseUrl,
151
+ headers: { 'X-Custom-Header': 'test-value' },
152
+ });
153
+
154
+ expect(client).toBeDefined();
155
+ });
156
+
157
+ it('should apply prefix to base URL when provided', () => {
158
+ const prefix = '/api/v1';
159
+ const client = c15tClient({
160
+ baseUrl: mockBaseUrl,
161
+ prefix,
162
+ });
163
+
164
+ expect(client).toBeDefined();
165
+ });
166
+
167
+ it('should handle URL with existing path', () => {
168
+ const baseUrl = 'http://localhost:8787/existing';
169
+ const prefix = '/api/v1';
170
+ const client = c15tClient({
171
+ baseUrl,
172
+ prefix,
173
+ });
174
+
175
+ expect(client).toBeDefined();
176
+ });
177
+ });
178
+
179
+ describe('Error Handling', () => {
180
+ it('should handle invalid base URL', () => {
181
+ expect(() => {
182
+ c15tClient({ baseUrl: 'invalid-url' });
183
+ }).toThrow();
184
+ });
185
+
186
+ it('should handle empty base URL', () => {
187
+ expect(() => {
188
+ c15tClient({ baseUrl: '' });
189
+ }).toThrow();
190
+ });
191
+ });
192
+ });
193
+
194
+ describe('Integration Tests', () => {
195
+ it('should connect to status endpoint', async () => {
196
+ const response = await client.meta.status();
197
+
198
+ // Test exact structure based on actual response
199
+ expect(response).toEqual({
200
+ status: 'ok',
201
+ version: expect.any(String),
202
+ timestamp: expect.any(String),
203
+ storage: {
204
+ type: 'memory',
205
+ available: true,
206
+ },
207
+ client: {
208
+ ip: expect.any(String),
209
+ userAgent: expect.any(String),
210
+ region: {
211
+ countryCode: null,
212
+ regionCode: null,
213
+ },
214
+ },
215
+ });
216
+ });
217
+ });
218
+ });
package/src/index.ts CHANGED
@@ -1,7 +1,8 @@
1
- import type { router } from '@c15t/backend/router';
1
+ import { contracts } from '@c15t/backend/contracts';
2
2
  import { createORPCClient } from '@orpc/client';
3
- import { RPCLink } from '@orpc/client/fetch';
4
- import type { RouterClient } from '@orpc/server';
3
+ import type { ContractRouterClient } from '@orpc/contract';
4
+ import type { JsonifiedClient } from '@orpc/openapi-client';
5
+ import { OpenAPILink } from '@orpc/openapi-client/fetch';
5
6
 
6
7
  /**
7
8
  * Configuration options for the C15T SDK client
@@ -63,8 +64,7 @@ export function c15tClient(options: C15TClientOptions) {
63
64
  baseUrl.pathname = options.prefix;
64
65
  }
65
66
 
66
- // Create the RPC link with the configured options
67
- const link = new RPCLink({
67
+ const link = new OpenAPILink(contracts, {
68
68
  url: baseUrl.toString(),
69
69
  headers: {
70
70
  ...authHeaders,
@@ -75,7 +75,8 @@ export function c15tClient(options: C15TClientOptions) {
75
75
  // Create and return the client with a type assertion
76
76
  // This approach avoids complex type issues while providing
77
77
  // the same runtime functionality
78
- const client = createORPCClient(link);
79
78
 
80
- return client as RouterClient<typeof router>;
79
+ return createORPCClient(link) as JsonifiedClient<
80
+ ContractRouterClient<typeof contracts>
81
+ >;
81
82
  }
@@ -1,22 +0,0 @@
1
-
2
- 
3
- > @c15t/node-sdk@1.2.0-canary.10 test /Users/christopherburns/glados/k/c15t/packages/node-sdk
4
- > vitest run
5
-
6
- [?25l
7
-  RUN  v3.1.1 /Users/christopherburns/glados/k/c15t/packages/node-sdk
8
- Coverage enabled with istanbul
9
-
10
- No test files found, exiting with code 1
11
- 
12
- include: **/*.{test,spec}.?(c|m)[jt]s?(x)
13
- exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
14
-
15
-  % Coverage report from istanbul
16
- ----------|---------|----------|---------|---------|-------------------
17
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
18
- ----------|---------|----------|---------|---------|-------------------
19
- All files |  0 |  0 |  0 |  0 |  
20
-  index.ts |  0 |  0 |  0 |  0 | 54-80 
21
- ----------|---------|----------|---------|---------|-------------------
22
- [?25h ELIFECYCLE  Test failed. See above for more details.