@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.
- package/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-fmt.log +4 -4
- package/coverage/coverage-final.json +1 -1
- package/coverage/coverage-summary.json +2 -2
- package/coverage/html/index.html +21 -21
- package/coverage/html/index.ts.html +29 -35
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/package.json +6 -3
- package/src/index.test.ts +218 -0
- package/src/index.ts +8 -7
- package/.turbo/turbo-test.log +0 -22
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @c15t/node-sdk@1.2.0-canary.
|
|
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
|
[1m[38;2;189;255;243m [39m[38;2;189;255;243m [39m[38;2;179;249;235mR[39m[38;2;168;244;227ms[39m[38;2;158;238;219ml[39m[38;2;147;233;211mi[39m[38;2;137;227;203mb[39m[38;2;137;227;203m [39m[38;2;126;222;194mv[39m[38;2;116;216;186m0[39m[38;2;105;211;178m.[39m[38;2;95;205;170m6[39m[38;2;84;200;162m.[39m[38;2;74;194;154m2[39m[38;2;74;194;154m
|
|
7
7
|
[39m[22m
|
|
8
|
-
[1m[32mready [39m[22m built in [1m0.
|
|
9
|
-
[1m[32mready [39m[22m built in [1m0.
|
|
8
|
+
[1m[32mready [39m[22m built in [1m0.05[22m s[90m (esm)[39m
|
|
9
|
+
[1m[32mready [39m[22m built in [1m0.05[22m s[90m (cjs)[39m
|
|
10
10
|
[1m[36mstart [39m[22m generating declaration files... [90m(esm)[39m
|
|
11
11
|
[1m[36mstart [39m[22m generating declaration files... [90m(cjs)[39m
|
|
12
|
-
[1m[32mready [39m[22m declaration files generated in [
|
|
13
|
-
[1m[32mready [39m[22m declaration files generated in [
|
|
12
|
+
[1m[32mready [39m[22m declaration files generated in [1m1.65[22m s [90m(esm)[39m
|
|
13
|
+
[1m[32mready [39m[22m declaration files generated in [1m1.76[22m s [90m(cjs)[39m
|
|
14
14
|
|
|
15
15
|
[34m File (esm) Size [39m
|
|
16
|
-
[2mdist/[22m[36mindex.js[39m 0.
|
|
16
|
+
[2mdist/[22m[36mindex.js[39m 0.95 kB
|
|
17
17
|
|
|
18
18
|
[2m -----[22m
|
|
19
19
|
|
|
20
20
|
[34m File (cjs) Size [39m
|
|
21
|
-
[2mdist/[22m[36mindex.cjs[39m 1.
|
|
21
|
+
[2mdist/[22m[36mindex.cjs[39m 1.9 kB
|
|
22
22
|
|
package/.turbo/turbo-fmt.log
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @c15t/node-sdk@1.2.0-canary.
|
|
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
|
-
[0m[34mFormatted [0m[0m[
|
|
7
|
-
[0m[34mChecked [0m[0m[
|
|
6
|
+
[0m[34mFormatted [0m[0m[34m6[0m[0m[34m [0m[0m[34mfiles[0m[0m[34m in [0m[0m[34m9[0m[0m[2m[34mms[0m[0m[34m.[0m[0m[34m No fixes applied.[0m
|
|
7
|
+
[0m[34mChecked [0m[0m[34m6[0m[0m[34m [0m[0m[34mfiles[0m[0m[34m in [0m[0m[34m4[0m[0m[2m[34mms[0m[0m[34m.[0m[0m[34m No fixes applied.[0m
|
|
@@ -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":
|
|
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":
|
|
2
|
-
,"/Users/christopherburns/glados/k/c15t/packages/node-sdk/src/index.ts": {"lines":{"total":
|
|
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
|
}
|
package/coverage/html/index.html
CHANGED
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">100% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
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">
|
|
33
|
+
<span class="strong">100% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
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">
|
|
40
|
+
<span class="strong">100% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
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">
|
|
47
|
+
<span class="strong">100% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
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
|
|
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
|
|
83
|
-
<td data-value="
|
|
84
|
-
<div class="chart"><div class="cover-fill" style="width:
|
|
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="
|
|
87
|
-
<td data-value="
|
|
88
|
-
<td data-value="
|
|
89
|
-
<td data-value="4" class="abs
|
|
90
|
-
<td data-value="
|
|
91
|
-
<td data-value="1" class="abs
|
|
92
|
-
<td data-value="
|
|
93
|
-
<td data-value="
|
|
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-
|
|
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">
|
|
26
|
+
<span class="strong">100% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
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">
|
|
33
|
+
<span class="strong">100% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
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">
|
|
40
|
+
<span class="strong">100% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
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">
|
|
47
|
+
<span class="strong">100% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
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
|
|
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"> </span>
|
|
145
|
+
<a name='L80'></a><a href='#L80'>80</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
148
146
|
<span class="cline-any cline-neutral"> </span>
|
|
149
147
|
<span class="cline-any cline-neutral"> </span>
|
|
150
148
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -197,20 +195,20 @@
|
|
|
197
195
|
<span class="cline-any cline-neutral"> </span>
|
|
198
196
|
<span class="cline-any cline-neutral"> </span>
|
|
199
197
|
<span class="cline-any cline-neutral"> </span>
|
|
200
|
-
<span class="cline-any cline-no"> </span>
|
|
201
198
|
<span class="cline-any cline-neutral"> </span>
|
|
199
|
+
<span class="cline-any cline-yes">8x</span>
|
|
202
200
|
<span class="cline-any cline-neutral"> </span>
|
|
203
201
|
<span class="cline-any cline-neutral"> </span>
|
|
204
202
|
<span class="cline-any cline-neutral"> </span>
|
|
205
|
-
<span class="cline-any cline-no"> </span>
|
|
206
203
|
<span class="cline-any cline-neutral"> </span>
|
|
204
|
+
<span class="cline-any cline-yes">8x</span>
|
|
207
205
|
<span class="cline-any cline-neutral"> </span>
|
|
208
|
-
<span class="cline-any cline-no"> </span>
|
|
209
|
-
<span class="cline-any cline-no"> </span>
|
|
210
206
|
<span class="cline-any cline-neutral"> </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"> </span>
|
|
212
210
|
<span class="cline-any cline-neutral"> </span>
|
|
213
|
-
<span class="cline-any cline-
|
|
211
|
+
<span class="cline-any cline-yes">6x</span>
|
|
214
212
|
<span class="cline-any cline-neutral"> </span>
|
|
215
213
|
<span class="cline-any cline-neutral"> </span>
|
|
216
214
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -221,14 +219,13 @@
|
|
|
221
219
|
<span class="cline-any cline-neutral"> </span>
|
|
222
220
|
<span class="cline-any cline-neutral"> </span>
|
|
223
221
|
<span class="cline-any cline-neutral"> </span>
|
|
224
|
-
<span class="cline-any cline-no"> </span>
|
|
225
222
|
<span class="cline-any cline-neutral"> </span>
|
|
226
|
-
<span class="cline-any cline-
|
|
227
|
-
<span class="cline-any cline-neutral"> </span>
|
|
228
|
-
<span class="cline-any cline-neutral"> </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"> </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 {
|
|
231
|
-
import type {
|
|
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
|
|
|
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
|
|
276
|
+
export function c15tClient(options: C15TClientOptions) {
|
|
280
277
|
// Prepare authorization header if token is provided
|
|
281
|
-
const authHeaders: Record<string, string> =
|
|
278
|
+
const authHeaders: Record<string, string> = options.token
|
|
282
279
|
? { Authorization: `Bearer ${options.token}` }
|
|
283
280
|
: {};
|
|
284
281
|
|
|
285
282
|
// Prepare the base URL, potentially with prefix
|
|
286
|
-
const baseUrl =
|
|
283
|
+
const baseUrl = new URL(options.baseUrl);
|
|
287
284
|
|
|
288
285
|
// If prefix is provided, apply it to the base URL path
|
|
289
|
-
|
|
290
|
-
|
|
286
|
+
if (options.prefix) {
|
|
287
|
+
baseUrl.pathname = options.prefix;
|
|
291
288
|
}
|
|
292
289
|
|
|
293
|
-
|
|
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
|
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
</pre></td></tr></table></pre>
|
|
302
|
+
return createORPCClient(link) as JsonifiedClient<ContractRouterClient<typeof contracts>>;
|
|
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-
|
|
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.
|
|
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
|
-
|
|
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
|
|
2
|
-
import type {
|
|
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):
|
|
46
|
+
export declare function c15tClient(options: C15TClientOptions): JsonifiedClient<ContractRouterClient<typeof contracts>>;
|
|
46
47
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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
|
|
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
|
|
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
|
-
|
|
17
|
-
return client;
|
|
17
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__orpc_client_e16cd7f2__.createORPCClient)(link);
|
|
18
18
|
}
|
|
19
19
|
export { c15tClient };
|
|
@@ -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.
|
|
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.
|
|
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
|
|
1
|
+
import { contracts } from '@c15t/backend/contracts';
|
|
2
2
|
import { createORPCClient } from '@orpc/client';
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
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
|
-
|
|
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
|
|
79
|
+
return createORPCClient(link) as JsonifiedClient<
|
|
80
|
+
ContractRouterClient<typeof contracts>
|
|
81
|
+
>;
|
|
81
82
|
}
|
package/.turbo/turbo-test.log
DELETED
|
@@ -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
|
-
[1m[7m[36m RUN [39m[27m[22m [36mv3.1.1 [39m[90m/Users/christopherburns/glados/k/c15t/packages/node-sdk[39m
|
|
8
|
-
[2mCoverage enabled with [22m[33mistanbul[39m
|
|
9
|
-
|
|
10
|
-
[31mNo test files found, exiting with code 1
|
|
11
|
-
[39m
|
|
12
|
-
[2minclude: [22m[33m**/*.{test,spec}.?(c|m)[jt]s?(x)[39m
|
|
13
|
-
[2mexclude: [22m[33m**/node_modules/**[2m, [22m**/dist/**[2m, [22m**/cypress/**[2m, [22m**/.{idea,git,cache,output,temp}/**[2m, [22m**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*[39m
|
|
14
|
-
|
|
15
|
-
[34m % [39m[2mCoverage report from [22m[33mistanbul[39m
|
|
16
|
-
----------|---------|----------|---------|---------|-------------------
|
|
17
|
-
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
18
|
-
----------|---------|----------|---------|---------|-------------------
|
|
19
|
-
[31;1mAll files[0m | [31;1m 0[0m | [31;1m 0[0m | [31;1m 0[0m | [31;1m 0[0m | [31;1m [0m
|
|
20
|
-
[31;1m index.ts[0m | [31;1m 0[0m | [31;1m 0[0m | [31;1m 0[0m | [31;1m 0[0m | [31;1m54-80 [0m
|
|
21
|
-
----------|---------|----------|---------|---------|-------------------
|
|
22
|
-
[?25h[41m[30m ELIFECYCLE [39m[49m [31mTest failed. See above for more details.[39m
|