@lessly/sdk-app 0.1.11

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/dist/index.js ADDED
@@ -0,0 +1,929 @@
1
+ // src/runtime/errors.ts
2
+ var LesslyApiError = class extends Error {
3
+ status;
4
+ code;
5
+ body;
6
+ constructor(status, code, message, body) {
7
+ super(message);
8
+ this.name = "LesslyApiError";
9
+ this.status = status;
10
+ this.code = code;
11
+ this.body = body;
12
+ }
13
+ };
14
+ function parseErrorBody(body, status) {
15
+ const b = typeof body === "object" && body !== null ? body : null;
16
+ const code = b?.error?.code ?? b?.code ?? null;
17
+ const message = b?.error?.message ?? b?.message ?? `Request failed with status ${status}`;
18
+ return new LesslyApiError(status, code, message, body);
19
+ }
20
+
21
+ // src/runtime/csrf.ts
22
+ var CSRF_COOKIE = "lessly_csrf";
23
+ function readCsrfCookie() {
24
+ if (typeof document === "undefined" || !document) return null;
25
+ const match = document.cookie.match(new RegExp(`(?:^|; )${CSRF_COOKIE}=([^;]*)`));
26
+ return match ? decodeURIComponent(match[1]) : null;
27
+ }
28
+
29
+ // src/runtime/request.ts
30
+ var MUTATING = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
31
+ function pathTokenNames(path) {
32
+ const names = /* @__PURE__ */ new Set();
33
+ const re = /:([A-Za-z0-9_]+)/g;
34
+ let m;
35
+ while ((m = re.exec(path)) !== null) names.add(m[1]);
36
+ return names;
37
+ }
38
+ function placementFor(key, binding, tokens) {
39
+ if (binding.params) {
40
+ const spec = binding.params.find((p) => p.name === key);
41
+ if (spec) return spec.in;
42
+ }
43
+ if (tokens.has(key)) return "path";
44
+ return binding.method === "GET" || binding.method === "DELETE" ? "query" : "body";
45
+ }
46
+ function resolveRequest(binding, input = {}) {
47
+ const tokens = pathTokenNames(binding.path);
48
+ const query = {};
49
+ const body = {};
50
+ const pathValues = {};
51
+ for (const [k, v] of Object.entries(input)) {
52
+ const where = placementFor(k, binding, tokens);
53
+ if (where === "path") pathValues[k] = v;
54
+ else if (where === "query") query[k] = v;
55
+ else body[k] = v;
56
+ }
57
+ let path = binding.path;
58
+ for (const token of tokens) {
59
+ const val = pathValues[token];
60
+ if (val === void 0) throw new Error(`Missing path parameter "${token}" for ${binding.path}`);
61
+ path = path.replace(`:${token}`, encodeURIComponent(String(val)));
62
+ }
63
+ return { path, query, body: Object.keys(body).length > 0 ? body : void 0 };
64
+ }
65
+ function buildUrl(baseUrl, path, query) {
66
+ const url = new URL(baseUrl.replace(/\/$/, "") + path);
67
+ for (const [k, v] of Object.entries(query)) {
68
+ if (v === void 0 || v === null) continue;
69
+ if (Array.isArray(v)) v.forEach((item) => url.searchParams.append(k, String(item)));
70
+ else url.searchParams.append(k, String(v));
71
+ }
72
+ return url.toString();
73
+ }
74
+ function safeJson(text) {
75
+ try {
76
+ return JSON.parse(text);
77
+ } catch {
78
+ return text;
79
+ }
80
+ }
81
+ async function executeRequest(opts, binding, input) {
82
+ const { path, query, body } = resolveRequest(binding, input);
83
+ const url = buildUrl(opts.baseUrl, path, query);
84
+ const doFetch = opts.fetch ?? globalThis.fetch;
85
+ const headers = new Headers();
86
+ headers.set("X-Product-Id", opts.productId);
87
+ if (body !== void 0) headers.set("Content-Type", "application/json");
88
+ if (MUTATING.has(binding.method)) {
89
+ const token = (opts.getCsrfToken ?? readCsrfCookie)();
90
+ if (token) headers.set("X-CSRF-Token", token);
91
+ }
92
+ const requestInit = { method: binding.method, headers, credentials: "include" };
93
+ if (body !== void 0) requestInit.body = JSON.stringify(body);
94
+ const res = await doFetch(url, requestInit);
95
+ const text = await res.text();
96
+ const parsed = text ? safeJson(text) : null;
97
+ if (!res.ok) throw parseErrorBody(parsed, res.status);
98
+ return parsed;
99
+ }
100
+
101
+ // src/gen/bindings.gen.ts
102
+ var bindings = {
103
+ "organization": {
104
+ "auth": {
105
+ "me": {
106
+ "method": "GET",
107
+ "path": "/governance/api/v1/auth/me",
108
+ "readOnly": true
109
+ }
110
+ },
111
+ "bindings": {
112
+ "list": {
113
+ "method": "GET",
114
+ "params": [
115
+ {
116
+ "in": "path",
117
+ "name": "productId"
118
+ },
119
+ {
120
+ "in": "path",
121
+ "name": "domainId"
122
+ }
123
+ ],
124
+ "path": "/governance/api/v1/products/:productId/domains/:domainId/bindings",
125
+ "readOnly": true
126
+ }
127
+ },
128
+ "clickup": {
129
+ "install": {
130
+ "method": "GET",
131
+ "path": "/governance/api/v1/connectors/clickup/install",
132
+ "readOnly": false
133
+ },
134
+ "list-installations": {
135
+ "method": "GET",
136
+ "path": "/governance/api/v1/connectors/clickup/installations",
137
+ "readOnly": true
138
+ }
139
+ },
140
+ "cloudflare": {
141
+ "install": {
142
+ "method": "GET",
143
+ "path": "/governance/api/v1/connectors/cloudflare/install",
144
+ "readOnly": false
145
+ }
146
+ },
147
+ "connectors": {
148
+ "attach": {
149
+ "method": "POST",
150
+ "params": [
151
+ {
152
+ "in": "body",
153
+ "name": "organizationId"
154
+ },
155
+ {
156
+ "in": "path",
157
+ "name": "id"
158
+ },
159
+ {
160
+ "in": "body",
161
+ "name": "productIds"
162
+ }
163
+ ],
164
+ "path": "/governance/api/v1/connectors/:id/attachments",
165
+ "readOnly": false
166
+ },
167
+ "delete": {
168
+ "method": "DELETE",
169
+ "params": [
170
+ {
171
+ "in": "path",
172
+ "name": "id"
173
+ }
174
+ ],
175
+ "path": "/governance/api/v1/connectors/:id/org",
176
+ "readOnly": false
177
+ },
178
+ "detach": {
179
+ "method": "DELETE",
180
+ "params": [
181
+ {
182
+ "in": "path",
183
+ "name": "id"
184
+ },
185
+ {
186
+ "in": "path",
187
+ "name": "productId"
188
+ }
189
+ ],
190
+ "path": "/governance/api/v1/connectors/:id/attachments/:productId",
191
+ "readOnly": false
192
+ },
193
+ "list": {
194
+ "method": "GET",
195
+ "params": [
196
+ {
197
+ "in": "query",
198
+ "name": "productId"
199
+ }
200
+ ],
201
+ "path": "/governance/api/v1/connectors/list",
202
+ "readOnly": true
203
+ },
204
+ "list-attachments": {
205
+ "method": "GET",
206
+ "params": [
207
+ {
208
+ "in": "path",
209
+ "name": "id"
210
+ }
211
+ ],
212
+ "path": "/governance/api/v1/connectors/:id/attachments",
213
+ "readOnly": true
214
+ },
215
+ "list-org": {
216
+ "method": "GET",
217
+ "params": [
218
+ {
219
+ "in": "path",
220
+ "name": "organizationId"
221
+ }
222
+ ],
223
+ "path": "/governance/api/v1/organizations/:organizationId/connectors",
224
+ "readOnly": true
225
+ },
226
+ "remove": {
227
+ "method": "DELETE",
228
+ "params": [
229
+ {
230
+ "in": "path",
231
+ "name": "id"
232
+ }
233
+ ],
234
+ "path": "/governance/api/v1/connectors/:id",
235
+ "readOnly": false
236
+ }
237
+ },
238
+ "domains": {
239
+ "add": {
240
+ "method": "POST",
241
+ "params": [
242
+ {
243
+ "in": "path",
244
+ "name": "productId"
245
+ },
246
+ {
247
+ "in": "body",
248
+ "name": "domain"
249
+ }
250
+ ],
251
+ "path": "/governance/api/v1/products/:productId/domains",
252
+ "readOnly": false
253
+ },
254
+ "get": {
255
+ "method": "GET",
256
+ "params": [
257
+ {
258
+ "in": "path",
259
+ "name": "productId"
260
+ },
261
+ {
262
+ "in": "path",
263
+ "name": "domainId"
264
+ }
265
+ ],
266
+ "path": "/governance/api/v1/products/:productId/domains/:domainId",
267
+ "readOnly": true
268
+ },
269
+ "list": {
270
+ "method": "GET",
271
+ "params": [
272
+ {
273
+ "in": "path",
274
+ "name": "productId"
275
+ }
276
+ ],
277
+ "path": "/governance/api/v1/products/:productId/domains",
278
+ "readOnly": true
279
+ },
280
+ "remove": {
281
+ "method": "DELETE",
282
+ "params": [
283
+ {
284
+ "in": "path",
285
+ "name": "productId"
286
+ },
287
+ {
288
+ "in": "path",
289
+ "name": "domainId"
290
+ }
291
+ ],
292
+ "path": "/governance/api/v1/products/:productId/domains/:domainId",
293
+ "readOnly": false
294
+ }
295
+ },
296
+ "extensions": {
297
+ "install": {
298
+ "method": "POST",
299
+ "params": [
300
+ {
301
+ "in": "path",
302
+ "name": "productId"
303
+ },
304
+ {
305
+ "in": "path",
306
+ "name": "extensionId"
307
+ }
308
+ ],
309
+ "path": "/governance/api/v1/products/:productId/extensions/:extensionId/install",
310
+ "readOnly": false
311
+ },
312
+ "list": {
313
+ "method": "GET",
314
+ "path": "/governance/api/v1/extensions",
315
+ "readOnly": true
316
+ },
317
+ "list-installed": {
318
+ "method": "GET",
319
+ "params": [
320
+ {
321
+ "in": "path",
322
+ "name": "productId"
323
+ }
324
+ ],
325
+ "path": "/governance/api/v1/products/:productId/extensions",
326
+ "readOnly": true
327
+ },
328
+ "uninstall": {
329
+ "method": "POST",
330
+ "params": [
331
+ {
332
+ "in": "path",
333
+ "name": "productId"
334
+ },
335
+ {
336
+ "in": "path",
337
+ "name": "extensionId"
338
+ }
339
+ ],
340
+ "path": "/governance/api/v1/products/:productId/extensions/:extensionId/uninstall",
341
+ "readOnly": false
342
+ }
343
+ },
344
+ "gdrive": {
345
+ "install": {
346
+ "method": "GET",
347
+ "path": "/governance/api/v1/connectors/gdrive/install",
348
+ "readOnly": false
349
+ }
350
+ },
351
+ "github": {
352
+ "install": {
353
+ "method": "GET",
354
+ "path": "/governance/api/v1/connectors/github/install",
355
+ "readOnly": false
356
+ },
357
+ "list-installations": {
358
+ "method": "GET",
359
+ "path": "/governance/api/v1/connectors/github/installations",
360
+ "readOnly": true
361
+ }
362
+ },
363
+ "googleads": {
364
+ "install": {
365
+ "method": "GET",
366
+ "params": [
367
+ {
368
+ "in": "query",
369
+ "name": "organizationId"
370
+ }
371
+ ],
372
+ "path": "/governance/api/v1/connectors/googleads/install",
373
+ "readOnly": false
374
+ }
375
+ },
376
+ "member": {
377
+ "accept-invite": {
378
+ "method": "POST",
379
+ "params": [
380
+ {
381
+ "in": "body",
382
+ "name": "token"
383
+ }
384
+ ],
385
+ "path": "/governance/api/v1/organizations/invitations/accept",
386
+ "readOnly": false
387
+ },
388
+ "invite": {
389
+ "method": "POST",
390
+ "params": [
391
+ {
392
+ "in": "path",
393
+ "name": "organizationId"
394
+ },
395
+ {
396
+ "in": "body",
397
+ "name": "email"
398
+ },
399
+ {
400
+ "in": "body",
401
+ "name": "role"
402
+ },
403
+ {
404
+ "in": "body",
405
+ "name": "productShares"
406
+ }
407
+ ],
408
+ "path": "/governance/api/v1/organizations/:organizationId/invitations",
409
+ "readOnly": false
410
+ },
411
+ "list": {
412
+ "method": "GET",
413
+ "params": [
414
+ {
415
+ "in": "path",
416
+ "name": "organizationId"
417
+ }
418
+ ],
419
+ "path": "/governance/api/v1/organizations/:organizationId/members",
420
+ "readOnly": true
421
+ },
422
+ "list-invitations": {
423
+ "method": "GET",
424
+ "params": [
425
+ {
426
+ "in": "path",
427
+ "name": "organizationId"
428
+ }
429
+ ],
430
+ "path": "/governance/api/v1/organizations/:organizationId/invitations",
431
+ "readOnly": true
432
+ },
433
+ "list-product-access": {
434
+ "method": "GET",
435
+ "params": [
436
+ {
437
+ "in": "path",
438
+ "name": "organizationId"
439
+ },
440
+ {
441
+ "in": "path",
442
+ "name": "userId"
443
+ }
444
+ ],
445
+ "path": "/governance/api/v1/organizations/:organizationId/members/:userId/products",
446
+ "readOnly": true
447
+ },
448
+ "remove": {
449
+ "method": "DELETE",
450
+ "params": [
451
+ {
452
+ "in": "path",
453
+ "name": "organizationId"
454
+ },
455
+ {
456
+ "in": "path",
457
+ "name": "userId"
458
+ }
459
+ ],
460
+ "path": "/governance/api/v1/organizations/:organizationId/members/:userId",
461
+ "readOnly": false
462
+ },
463
+ "revoke-invitation": {
464
+ "method": "DELETE",
465
+ "params": [
466
+ {
467
+ "in": "path",
468
+ "name": "organizationId"
469
+ },
470
+ {
471
+ "in": "path",
472
+ "name": "invitationId"
473
+ }
474
+ ],
475
+ "path": "/governance/api/v1/organizations/:organizationId/invitations/:invitationId",
476
+ "readOnly": false
477
+ },
478
+ "set-role": {
479
+ "method": "PATCH",
480
+ "params": [
481
+ {
482
+ "in": "path",
483
+ "name": "organizationId"
484
+ },
485
+ {
486
+ "in": "path",
487
+ "name": "userId"
488
+ },
489
+ {
490
+ "in": "body",
491
+ "name": "role"
492
+ }
493
+ ],
494
+ "path": "/governance/api/v1/organizations/:organizationId/members/:userId/role",
495
+ "readOnly": false
496
+ },
497
+ "share-product": {
498
+ "method": "POST",
499
+ "params": [
500
+ {
501
+ "in": "path",
502
+ "name": "organizationId"
503
+ },
504
+ {
505
+ "in": "path",
506
+ "name": "userId"
507
+ },
508
+ {
509
+ "in": "body",
510
+ "name": "productId"
511
+ },
512
+ {
513
+ "in": "body",
514
+ "name": "role"
515
+ },
516
+ {
517
+ "in": "body",
518
+ "name": "expiresAt"
519
+ },
520
+ {
521
+ "in": "body",
522
+ "name": "permissions"
523
+ },
524
+ {
525
+ "in": "body",
526
+ "name": "roleId"
527
+ }
528
+ ],
529
+ "path": "/governance/api/v1/organizations/:organizationId/members/:userId/products",
530
+ "readOnly": false
531
+ },
532
+ "unshare-product": {
533
+ "method": "DELETE",
534
+ "params": [
535
+ {
536
+ "in": "path",
537
+ "name": "organizationId"
538
+ },
539
+ {
540
+ "in": "path",
541
+ "name": "userId"
542
+ },
543
+ {
544
+ "in": "path",
545
+ "name": "productId"
546
+ }
547
+ ],
548
+ "path": "/governance/api/v1/organizations/:organizationId/members/:userId/products/:productId",
549
+ "readOnly": false
550
+ }
551
+ },
552
+ "members": {
553
+ "assign-role": {
554
+ "method": "PUT",
555
+ "params": [
556
+ {
557
+ "in": "path",
558
+ "name": "productId"
559
+ },
560
+ {
561
+ "in": "path",
562
+ "name": "memberId"
563
+ },
564
+ {
565
+ "in": "body",
566
+ "name": "roleId"
567
+ }
568
+ ],
569
+ "path": "/governance/api/v1/products/:productId/members/:memberId/role",
570
+ "readOnly": false
571
+ }
572
+ },
573
+ "permission": {
574
+ "catalog": {
575
+ "method": "GET",
576
+ "path": "/governance/api/v1/organizations/permission-catalog",
577
+ "readOnly": true
578
+ }
579
+ },
580
+ "product": {
581
+ "accept-invitation": {
582
+ "method": "POST",
583
+ "params": [
584
+ {
585
+ "in": "path",
586
+ "name": "token"
587
+ }
588
+ ],
589
+ "path": "/governance/api/v1/invitations/:token/accept",
590
+ "readOnly": false
591
+ },
592
+ "create": {
593
+ "method": "POST",
594
+ "params": [
595
+ {
596
+ "in": "body",
597
+ "name": "name"
598
+ },
599
+ {
600
+ "in": "body",
601
+ "name": "organizationName"
602
+ }
603
+ ],
604
+ "path": "/governance/api/v1/products",
605
+ "readOnly": false
606
+ },
607
+ "invite": {
608
+ "method": "POST",
609
+ "params": [
610
+ {
611
+ "in": "path",
612
+ "name": "productId"
613
+ },
614
+ {
615
+ "in": "body",
616
+ "name": "email"
617
+ }
618
+ ],
619
+ "path": "/governance/api/v1/products/:productId/invitations",
620
+ "readOnly": false
621
+ },
622
+ "list": {
623
+ "method": "GET",
624
+ "params": [
625
+ {
626
+ "in": "query",
627
+ "name": "organizationId"
628
+ }
629
+ ],
630
+ "path": "/governance/api/v1/products",
631
+ "readOnly": true
632
+ },
633
+ "list-invitations": {
634
+ "method": "GET",
635
+ "params": [
636
+ {
637
+ "in": "path",
638
+ "name": "productId"
639
+ }
640
+ ],
641
+ "path": "/governance/api/v1/products/:productId/invitations",
642
+ "readOnly": true
643
+ },
644
+ "list-members": {
645
+ "method": "GET",
646
+ "params": [
647
+ {
648
+ "in": "path",
649
+ "name": "productId"
650
+ }
651
+ ],
652
+ "path": "/governance/api/v1/products/:productId/members",
653
+ "readOnly": true
654
+ },
655
+ "revoke-invitation": {
656
+ "method": "POST",
657
+ "params": [
658
+ {
659
+ "in": "body",
660
+ "name": "productId"
661
+ },
662
+ {
663
+ "in": "body",
664
+ "name": "invitationId"
665
+ }
666
+ ],
667
+ "path": "/governance/api/v1/products/revoke-invitation",
668
+ "readOnly": false
669
+ },
670
+ "select": {
671
+ "method": "POST",
672
+ "params": [
673
+ {
674
+ "in": "body",
675
+ "name": "productId"
676
+ }
677
+ ],
678
+ "path": "/governance/api/v1/products/select",
679
+ "readOnly": false
680
+ }
681
+ },
682
+ "roles": {
683
+ "create": {
684
+ "method": "POST",
685
+ "params": [
686
+ {
687
+ "in": "path",
688
+ "name": "orgId"
689
+ },
690
+ {
691
+ "in": "body",
692
+ "name": "name"
693
+ },
694
+ {
695
+ "in": "body",
696
+ "name": "allow"
697
+ },
698
+ {
699
+ "in": "body",
700
+ "name": "deny"
701
+ }
702
+ ],
703
+ "path": "/governance/api/v1/organizations/:orgId/roles",
704
+ "readOnly": false
705
+ },
706
+ "delete": {
707
+ "method": "DELETE",
708
+ "params": [
709
+ {
710
+ "in": "path",
711
+ "name": "orgId"
712
+ },
713
+ {
714
+ "in": "path",
715
+ "name": "roleId"
716
+ }
717
+ ],
718
+ "path": "/governance/api/v1/organizations/:orgId/roles/:roleId",
719
+ "readOnly": false
720
+ },
721
+ "get": {
722
+ "method": "GET",
723
+ "params": [
724
+ {
725
+ "in": "path",
726
+ "name": "orgId"
727
+ },
728
+ {
729
+ "in": "path",
730
+ "name": "roleId"
731
+ }
732
+ ],
733
+ "path": "/governance/api/v1/organizations/:orgId/roles/:roleId",
734
+ "readOnly": true
735
+ },
736
+ "list": {
737
+ "method": "GET",
738
+ "params": [
739
+ {
740
+ "in": "path",
741
+ "name": "orgId"
742
+ }
743
+ ],
744
+ "path": "/governance/api/v1/organizations/:orgId/roles",
745
+ "readOnly": true
746
+ },
747
+ "update": {
748
+ "method": "PATCH",
749
+ "params": [
750
+ {
751
+ "in": "path",
752
+ "name": "orgId"
753
+ },
754
+ {
755
+ "in": "path",
756
+ "name": "roleId"
757
+ },
758
+ {
759
+ "in": "body",
760
+ "name": "name"
761
+ },
762
+ {
763
+ "in": "body",
764
+ "name": "allow"
765
+ },
766
+ {
767
+ "in": "body",
768
+ "name": "deny"
769
+ }
770
+ ],
771
+ "path": "/governance/api/v1/organizations/:orgId/roles/:roleId",
772
+ "readOnly": false
773
+ }
774
+ }
775
+ },
776
+ "playground": {
777
+ "analytics": {
778
+ "overview": {
779
+ "method": "POST",
780
+ "params": [
781
+ {
782
+ "in": "body",
783
+ "name": "limit"
784
+ }
785
+ ],
786
+ "path": "/governance/analytics/overview",
787
+ "readOnly": true
788
+ }
789
+ },
790
+ "billing": {
791
+ "entitlements": {
792
+ "method": "POST",
793
+ "path": "/governance/billing/entitlements",
794
+ "readOnly": true
795
+ },
796
+ "record-usage": {
797
+ "method": "POST",
798
+ "params": [
799
+ {
800
+ "in": "body",
801
+ "name": "value"
802
+ }
803
+ ],
804
+ "path": "/governance/billing/usage",
805
+ "readOnly": false
806
+ }
807
+ },
808
+ "clickup": {
809
+ "create-task": {
810
+ "method": "POST",
811
+ "params": [
812
+ {
813
+ "in": "body",
814
+ "name": "listId"
815
+ },
816
+ {
817
+ "in": "body",
818
+ "name": "name"
819
+ }
820
+ ],
821
+ "path": "/governance/clickup/tasks",
822
+ "readOnly": false
823
+ },
824
+ "get-last-webhook": {
825
+ "method": "GET",
826
+ "path": "/governance/clickup/webhooks/last",
827
+ "readOnly": true
828
+ },
829
+ "get-overview": {
830
+ "method": "GET",
831
+ "path": "/governance/clickup/overview",
832
+ "readOnly": true
833
+ }
834
+ },
835
+ "gdrive": {
836
+ "get-last-change": {
837
+ "method": "GET",
838
+ "path": "/governance/gdrive/changes/last",
839
+ "readOnly": true
840
+ },
841
+ "read-file": {
842
+ "method": "POST",
843
+ "params": [
844
+ {
845
+ "in": "body",
846
+ "name": "fileId"
847
+ }
848
+ ],
849
+ "path": "/governance/gdrive/file",
850
+ "readOnly": true
851
+ }
852
+ },
853
+ "googleads": {
854
+ "read-customer": {
855
+ "method": "POST",
856
+ "path": "/governance/googleads/customer",
857
+ "readOnly": true
858
+ }
859
+ },
860
+ "lifecycle": {
861
+ "get-state": {
862
+ "method": "GET",
863
+ "path": "/governance/lifecycle/state",
864
+ "readOnly": true
865
+ },
866
+ "list-events": {
867
+ "method": "GET",
868
+ "path": "/governance/lifecycle/events",
869
+ "readOnly": true
870
+ }
871
+ },
872
+ "webhook": {
873
+ "get-last": {
874
+ "method": "GET",
875
+ "path": "/governance/webhooks/last",
876
+ "readOnly": true
877
+ }
878
+ }
879
+ }
880
+ };
881
+
882
+ // src/runtime/createLesslyApp.ts
883
+ function actionFn(opts, binding) {
884
+ return (input) => executeRequest(opts, binding, input);
885
+ }
886
+ function resourceProxy(opts, actions) {
887
+ const cache = {};
888
+ return new Proxy(cache, {
889
+ get(_t, prop) {
890
+ if (typeof prop !== "string" || !Object.hasOwn(actions, prop)) return void 0;
891
+ return cache[prop] ??= actionFn(opts, actions[prop]);
892
+ }
893
+ });
894
+ }
895
+ function namespaceProxy(opts, resources) {
896
+ const cache = {};
897
+ return new Proxy(cache, {
898
+ get(_t, prop) {
899
+ if (typeof prop !== "string" || !Object.hasOwn(resources, prop)) return void 0;
900
+ return cache[prop] ??= resourceProxy(opts, resources[prop]);
901
+ }
902
+ });
903
+ }
904
+ function createLesslyApp(opts) {
905
+ const map = bindings;
906
+ const nsCache = {};
907
+ const base = {
908
+ call(toolName, input) {
909
+ const parts = toolName.split("_");
910
+ if (parts.length < 3) return Promise.reject(new Error(`Unknown tool: ${toolName}`));
911
+ const [ns] = parts;
912
+ const action = parts[parts.length - 1];
913
+ const resource = parts.slice(1, -1).join("-");
914
+ const binding = map[ns]?.[resource]?.[action];
915
+ if (!binding) return Promise.reject(new Error(`Unknown tool: ${toolName}`));
916
+ return executeRequest(opts, binding, input);
917
+ }
918
+ };
919
+ return new Proxy(base, {
920
+ get(target, prop) {
921
+ if (typeof prop === "string" && Object.hasOwn(map, prop)) return nsCache[prop] ??= namespaceProxy(opts, map[prop]);
922
+ return target[prop];
923
+ }
924
+ });
925
+ }
926
+
927
+ export { LesslyApiError, createLesslyApp };
928
+ //# sourceMappingURL=index.js.map
929
+ //# sourceMappingURL=index.js.map