@tinycloud/sdk-services 0.0.0-beta-20260401001229

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,748 @@
1
+ import { d as Result, b as IService, B as BaseService } from '../BaseService-D9BFm_rV.cjs';
2
+
3
+ /**
4
+ * KV Service Types
5
+ *
6
+ * Type definitions for the KV (Key-Value) service operations.
7
+ */
8
+ /**
9
+ * Configuration for KVService.
10
+ */
11
+ interface KVServiceConfig {
12
+ /**
13
+ * Default prefix for all keys.
14
+ * Useful for namespacing data within a space.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const kv = new KVService({ prefix: 'myapp/settings' });
19
+ * await kv.put('theme', 'dark'); // Stores at 'myapp/settings/theme'
20
+ * ```
21
+ */
22
+ prefix?: string;
23
+ /**
24
+ * Default timeout in milliseconds for KV operations.
25
+ * Overrides the context-level timeout if set.
26
+ */
27
+ timeout?: number;
28
+ /** Allow additional config properties */
29
+ [key: string]: unknown;
30
+ }
31
+ /**
32
+ * Options for KV get operations.
33
+ */
34
+ interface KVGetOptions {
35
+ /**
36
+ * Override the default prefix for this operation.
37
+ */
38
+ prefix?: string;
39
+ /**
40
+ * Return raw response instead of parsed JSON.
41
+ * When true, data will be the raw response text.
42
+ */
43
+ raw?: boolean;
44
+ /**
45
+ * Custom timeout for this operation in milliseconds.
46
+ */
47
+ timeout?: number;
48
+ /**
49
+ * Custom abort signal for this operation.
50
+ */
51
+ signal?: AbortSignal;
52
+ }
53
+ /**
54
+ * Options for KV put operations.
55
+ */
56
+ interface KVPutOptions {
57
+ /**
58
+ * Override the default prefix for this operation.
59
+ */
60
+ prefix?: string;
61
+ /**
62
+ * Content type for the value.
63
+ * Defaults to 'application/json' for objects.
64
+ */
65
+ contentType?: string;
66
+ /**
67
+ * Custom metadata headers to store with the value.
68
+ */
69
+ metadata?: Record<string, string>;
70
+ /**
71
+ * Custom timeout for this operation in milliseconds.
72
+ */
73
+ timeout?: number;
74
+ /**
75
+ * Custom abort signal for this operation.
76
+ */
77
+ signal?: AbortSignal;
78
+ }
79
+ /**
80
+ * Options for KV list operations.
81
+ */
82
+ interface KVListOptions {
83
+ /**
84
+ * Override the default prefix for this operation.
85
+ */
86
+ prefix?: string;
87
+ /**
88
+ * Additional path to append to the prefix.
89
+ */
90
+ path?: string;
91
+ /**
92
+ * Whether to remove the prefix from returned keys.
93
+ * When true, keys are returned relative to the prefix.
94
+ */
95
+ removePrefix?: boolean;
96
+ /**
97
+ * Return raw response instead of parsed JSON.
98
+ */
99
+ raw?: boolean;
100
+ /**
101
+ * Custom timeout for this operation in milliseconds.
102
+ */
103
+ timeout?: number;
104
+ /**
105
+ * Custom abort signal for this operation.
106
+ */
107
+ signal?: AbortSignal;
108
+ }
109
+ /**
110
+ * Options for KV delete operations.
111
+ */
112
+ interface KVDeleteOptions {
113
+ /**
114
+ * Override the default prefix for this operation.
115
+ */
116
+ prefix?: string;
117
+ /**
118
+ * Custom timeout for this operation in milliseconds.
119
+ */
120
+ timeout?: number;
121
+ /**
122
+ * Custom abort signal for this operation.
123
+ */
124
+ signal?: AbortSignal;
125
+ }
126
+ /**
127
+ * Options for KV head (metadata) operations.
128
+ */
129
+ interface KVHeadOptions {
130
+ /**
131
+ * Override the default prefix for this operation.
132
+ */
133
+ prefix?: string;
134
+ /**
135
+ * Custom timeout for this operation in milliseconds.
136
+ */
137
+ timeout?: number;
138
+ /**
139
+ * Custom abort signal for this operation.
140
+ */
141
+ signal?: AbortSignal;
142
+ }
143
+ /**
144
+ * Response headers from KV operations.
145
+ */
146
+ interface KVResponseHeaders {
147
+ /**
148
+ * ETag for conditional requests.
149
+ */
150
+ etag?: string;
151
+ /**
152
+ * Content type of the stored value.
153
+ */
154
+ contentType?: string;
155
+ /**
156
+ * Last modification timestamp.
157
+ */
158
+ lastModified?: string;
159
+ /**
160
+ * Content length in bytes.
161
+ */
162
+ contentLength?: number;
163
+ /**
164
+ * Get a header value by name.
165
+ * @param name - Header name (case-insensitive)
166
+ */
167
+ get(name: string): string | null;
168
+ }
169
+ /**
170
+ * Response from KV get/put operations.
171
+ *
172
+ * @template T - Type of the data payload
173
+ */
174
+ interface KVResponse<T = unknown> {
175
+ /**
176
+ * The data payload.
177
+ * For get: the stored value.
178
+ * For put: undefined.
179
+ */
180
+ data: T;
181
+ /**
182
+ * Response headers with metadata.
183
+ */
184
+ headers: KVResponseHeaders;
185
+ }
186
+ /**
187
+ * Response from KV list operations.
188
+ */
189
+ interface KVListResponse {
190
+ /**
191
+ * Array of keys matching the list criteria.
192
+ */
193
+ keys: string[];
194
+ }
195
+ /**
196
+ * KV service action types.
197
+ */
198
+ declare const KVAction: {
199
+ readonly GET: "tinycloud.kv/get";
200
+ readonly PUT: "tinycloud.kv/put";
201
+ readonly LIST: "tinycloud.kv/list";
202
+ readonly DELETE: "tinycloud.kv/del";
203
+ readonly HEAD: "tinycloud.kv/metadata";
204
+ };
205
+ type KVActionType = (typeof KVAction)[keyof typeof KVAction];
206
+
207
+ /**
208
+ * PrefixedKVService - A prefix-scoped view of KVService.
209
+ *
210
+ * Provides key-value operations scoped to a specific prefix.
211
+ * All operations automatically prefix keys, enabling app data isolation
212
+ * within a shared space.
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * const space = sdk.space('default');
217
+ *
218
+ * // Create prefix-scoped views
219
+ * const myApp = space.kv.withPrefix('/app.myapp.com');
220
+ * const sharedPhotos = space.kv.withPrefix('/photos');
221
+ *
222
+ * // Operations are automatically prefixed
223
+ * await myApp.put('settings.json', { theme: 'dark' });
224
+ * // -> Actually writes to: /app.myapp.com/settings.json
225
+ *
226
+ * await myApp.get('settings.json');
227
+ * // -> Actually reads from: /app.myapp.com/settings.json
228
+ *
229
+ * await sharedPhotos.list();
230
+ * // -> Lists: /photos/*
231
+ *
232
+ * // Nested prefixes
233
+ * const settings = myApp.withPrefix('/settings');
234
+ * await settings.get('theme.json'); // -> /app.myapp.com/settings/theme.json
235
+ * ```
236
+ */
237
+
238
+ /**
239
+ * Interface for prefixed KV operations.
240
+ *
241
+ * Provides the same operations as IKVService but scoped to a prefix.
242
+ * Supports nested prefixes via withPrefix().
243
+ */
244
+ interface IPrefixedKVService {
245
+ /**
246
+ * The current prefix for this scoped view.
247
+ */
248
+ readonly prefix: string;
249
+ /**
250
+ * Get a value by key.
251
+ *
252
+ * The key is automatically prefixed with this service's prefix.
253
+ *
254
+ * @param key - The key to retrieve (will be prefixed)
255
+ * @param options - Optional get configuration
256
+ * @returns Result with the stored value and headers
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * const myApp = kv.withPrefix('/app.myapp.com');
261
+ * const result = await myApp.get('settings.json');
262
+ * // -> Reads from: /app.myapp.com/settings.json
263
+ * ```
264
+ */
265
+ get<T = unknown>(key: string, options?: Omit<KVGetOptions, 'prefix'>): Promise<Result<KVResponse<T>>>;
266
+ /**
267
+ * Store a value at a key.
268
+ *
269
+ * The key is automatically prefixed with this service's prefix.
270
+ *
271
+ * @param key - The key to store under (will be prefixed)
272
+ * @param value - The value to store
273
+ * @param options - Optional put configuration
274
+ * @returns Result indicating success/failure
275
+ *
276
+ * @example
277
+ * ```typescript
278
+ * const myApp = kv.withPrefix('/app.myapp.com');
279
+ * await myApp.put('settings.json', { theme: 'dark' });
280
+ * // -> Stores at: /app.myapp.com/settings.json
281
+ * ```
282
+ */
283
+ put(key: string, value: unknown, options?: Omit<KVPutOptions, 'prefix'>): Promise<Result<KVResponse<void>>>;
284
+ /**
285
+ * List keys within this prefix.
286
+ *
287
+ * Returns keys that match the prefix, with keys returned relative
288
+ * to the prefix when removePrefix is true (default for prefixed service).
289
+ *
290
+ * @param options - Optional list configuration
291
+ * @returns Result with array of matching keys
292
+ *
293
+ * @example
294
+ * ```typescript
295
+ * const myApp = kv.withPrefix('/app.myapp.com');
296
+ * const result = await myApp.list();
297
+ * // -> Lists keys under: /app.myapp.com/*
298
+ * // Returns: ['settings.json', 'data/user.json', ...]
299
+ * ```
300
+ */
301
+ list(options?: Omit<KVListOptions, 'prefix'>): Promise<Result<KVListResponse>>;
302
+ /**
303
+ * Delete a key.
304
+ *
305
+ * The key is automatically prefixed with this service's prefix.
306
+ *
307
+ * @param key - The key to delete (will be prefixed)
308
+ * @param options - Optional delete configuration
309
+ * @returns Result indicating success/failure
310
+ *
311
+ * @example
312
+ * ```typescript
313
+ * const myApp = kv.withPrefix('/app.myapp.com');
314
+ * await myApp.delete('old-settings.json');
315
+ * // -> Deletes: /app.myapp.com/old-settings.json
316
+ * ```
317
+ */
318
+ delete(key: string, options?: Omit<KVDeleteOptions, 'prefix'>): Promise<Result<void>>;
319
+ /**
320
+ * Get metadata for a key without retrieving the value.
321
+ *
322
+ * The key is automatically prefixed with this service's prefix.
323
+ *
324
+ * @param key - The key to check (will be prefixed)
325
+ * @param options - Optional head configuration
326
+ * @returns Result with headers only
327
+ *
328
+ * @example
329
+ * ```typescript
330
+ * const myApp = kv.withPrefix('/app.myapp.com');
331
+ * const result = await myApp.head('large-file.bin');
332
+ * // -> Gets metadata for: /app.myapp.com/large-file.bin
333
+ * ```
334
+ */
335
+ head(key: string, options?: Omit<KVHeadOptions, 'prefix'>): Promise<Result<KVResponse<void>>>;
336
+ /**
337
+ * Create a nested prefix-scoped view.
338
+ *
339
+ * The subPrefix is appended to the current prefix.
340
+ *
341
+ * @param subPrefix - The sub-prefix to append
342
+ * @returns A new PrefixedKVService with the combined prefix
343
+ *
344
+ * @example
345
+ * ```typescript
346
+ * const myApp = kv.withPrefix('/app.myapp.com');
347
+ * const settings = myApp.withPrefix('/settings');
348
+ * await settings.get('theme.json');
349
+ * // -> Reads from: /app.myapp.com/settings/theme.json
350
+ * ```
351
+ */
352
+ withPrefix(subPrefix: string): IPrefixedKVService;
353
+ }
354
+ /**
355
+ * Interface for a KV service that supports prefix delegation.
356
+ *
357
+ * This is the subset of IKVService methods needed by PrefixedKVService.
358
+ */
359
+ interface IKVServiceLike {
360
+ get<T = unknown>(key: string, options?: KVGetOptions): Promise<Result<KVResponse<T>>>;
361
+ put(key: string, value: unknown, options?: KVPutOptions): Promise<Result<KVResponse<void>>>;
362
+ list(options?: KVListOptions): Promise<Result<KVListResponse>>;
363
+ delete(key: string, options?: KVDeleteOptions): Promise<Result<void>>;
364
+ head(key: string, options?: KVHeadOptions): Promise<Result<KVResponse<void>>>;
365
+ }
366
+ /**
367
+ * PrefixedKVService - Implementation of prefix-scoped KV operations.
368
+ *
369
+ * This class wraps a KVService (or another PrefixedKVService) and
370
+ * automatically prefixes all key operations with the configured prefix.
371
+ *
372
+ * ## Prefix Convention
373
+ *
374
+ * | Pattern | Use Case | Example |
375
+ * | -- | -- | -- |
376
+ * | `/app.{domain}/` | App-private data | `/app.photos.xyz/settings.json` |
377
+ * | `/{type}/` | Shared data type | `/photos/vacation.jpg` |
378
+ * | `/.{name}/` | Hidden/system data | `/.cache/thumbnails/` |
379
+ * | `/public/` | Explicitly shareable | `/public/profile.json` |
380
+ *
381
+ * @example
382
+ * ```typescript
383
+ * // Create from KVService
384
+ * const prefixed = new PrefixedKVService(kvService, '/app.myapp.com');
385
+ *
386
+ * // Or use the withPrefix factory method on KVService
387
+ * const prefixed = kvService.withPrefix('/app.myapp.com');
388
+ *
389
+ * // All operations are automatically prefixed
390
+ * await prefixed.put('settings.json', { theme: 'dark' });
391
+ * await prefixed.get('settings.json');
392
+ *
393
+ * // Nested prefixes
394
+ * const nested = prefixed.withPrefix('/settings');
395
+ * await nested.get('theme.json'); // -> /app.myapp.com/settings/theme.json
396
+ * ```
397
+ */
398
+ declare class PrefixedKVService implements IPrefixedKVService {
399
+ /**
400
+ * The underlying KV service.
401
+ */
402
+ private readonly _kv;
403
+ /**
404
+ * The prefix for this scoped view.
405
+ */
406
+ private readonly _prefix;
407
+ /**
408
+ * Create a new PrefixedKVService.
409
+ *
410
+ * @param kv - The underlying KV service to delegate to
411
+ * @param prefix - The prefix to apply to all operations
412
+ */
413
+ constructor(kv: IKVServiceLike, prefix: string);
414
+ /**
415
+ * The current prefix for this scoped view.
416
+ */
417
+ get prefix(): string;
418
+ /**
419
+ * Compute the full key path by combining prefix and key.
420
+ *
421
+ * @param key - The key to prefix
422
+ * @returns The full path including prefix
423
+ */
424
+ private getFullKey;
425
+ /**
426
+ * Get a value by key.
427
+ */
428
+ get<T = unknown>(key: string, options?: Omit<KVGetOptions, 'prefix'>): Promise<Result<KVResponse<T>>>;
429
+ /**
430
+ * Store a value at a key.
431
+ */
432
+ put(key: string, value: unknown, options?: Omit<KVPutOptions, 'prefix'>): Promise<Result<KVResponse<void>>>;
433
+ /**
434
+ * List keys within this prefix.
435
+ */
436
+ list(options?: Omit<KVListOptions, 'prefix'>): Promise<Result<KVListResponse>>;
437
+ /**
438
+ * Delete a key.
439
+ */
440
+ delete(key: string, options?: Omit<KVDeleteOptions, 'prefix'>): Promise<Result<void>>;
441
+ /**
442
+ * Get metadata for a key without retrieving the value.
443
+ */
444
+ head(key: string, options?: Omit<KVHeadOptions, 'prefix'>): Promise<Result<KVResponse<void>>>;
445
+ /**
446
+ * Create a nested prefix-scoped view.
447
+ */
448
+ withPrefix(subPrefix: string): IPrefixedKVService;
449
+ }
450
+
451
+ /**
452
+ * IKVService - Interface for KV (Key-Value) service.
453
+ *
454
+ * Platform-agnostic interface for key-value storage operations.
455
+ * Implementations use dependency injection via IServiceContext.
456
+ */
457
+
458
+ /**
459
+ * KV service interface.
460
+ *
461
+ * Provides key-value storage operations with:
462
+ * - Result type pattern (no throwing)
463
+ * - Optional prefix namespacing
464
+ * - Configurable timeouts
465
+ * - Abort signal support
466
+ *
467
+ * @example
468
+ * ```typescript
469
+ * const result = await kv.get('user/settings');
470
+ * if (result.ok) {
471
+ * console.log('Settings:', result.data.data);
472
+ * } else {
473
+ * console.error('Error:', result.error.code);
474
+ * }
475
+ * ```
476
+ */
477
+ interface IKVService extends IService {
478
+ /**
479
+ * Get a value by key.
480
+ *
481
+ * @param key - The key to retrieve
482
+ * @param options - Optional get configuration
483
+ * @returns Result with the stored value and headers
484
+ *
485
+ * @example
486
+ * ```typescript
487
+ * const result = await kv.get<UserSettings>('settings');
488
+ * if (result.ok) {
489
+ * const settings = result.data.data;
490
+ * const etag = result.data.headers.etag;
491
+ * }
492
+ * ```
493
+ */
494
+ get<T = unknown>(key: string, options?: KVGetOptions): Promise<Result<KVResponse<T>>>;
495
+ /**
496
+ * Store a value at a key.
497
+ *
498
+ * Objects are automatically JSON stringified.
499
+ * Strings are stored as-is.
500
+ *
501
+ * @param key - The key to store under
502
+ * @param value - The value to store
503
+ * @param options - Optional put configuration
504
+ * @returns Result indicating success/failure
505
+ *
506
+ * @example
507
+ * ```typescript
508
+ * // Store an object (auto-stringified)
509
+ * const result = await kv.put('settings', { theme: 'dark' });
510
+ *
511
+ * // Store a string
512
+ * const result = await kv.put('name', 'Alice');
513
+ * ```
514
+ */
515
+ put(key: string, value: unknown, options?: KVPutOptions): Promise<Result<KVResponse<void>>>;
516
+ /**
517
+ * List keys with optional prefix filtering.
518
+ *
519
+ * @param options - Optional list configuration
520
+ * @returns Result with array of matching keys
521
+ *
522
+ * @example
523
+ * ```typescript
524
+ * // List all keys
525
+ * const result = await kv.list();
526
+ *
527
+ * // List keys with a specific prefix
528
+ * const result = await kv.list({ prefix: 'users/' });
529
+ * ```
530
+ */
531
+ list(options?: KVListOptions): Promise<Result<KVListResponse>>;
532
+ /**
533
+ * Delete a key.
534
+ *
535
+ * @param key - The key to delete
536
+ * @param options - Optional delete configuration
537
+ * @returns Result indicating success/failure
538
+ *
539
+ * @example
540
+ * ```typescript
541
+ * const result = await kv.delete('old-key');
542
+ * if (!result.ok && result.error.code === 'KV_NOT_FOUND') {
543
+ * console.log('Key already deleted');
544
+ * }
545
+ * ```
546
+ */
547
+ delete(key: string, options?: KVDeleteOptions): Promise<Result<void>>;
548
+ /**
549
+ * Get metadata for a key without retrieving the value.
550
+ *
551
+ * Useful for checking if a key exists or getting headers
552
+ * without downloading the full value.
553
+ *
554
+ * @param key - The key to check
555
+ * @param options - Optional head configuration
556
+ * @returns Result with headers only
557
+ *
558
+ * @example
559
+ * ```typescript
560
+ * const result = await kv.head('large-file');
561
+ * if (result.ok) {
562
+ * console.log('Size:', result.data.headers.contentLength);
563
+ * }
564
+ * ```
565
+ */
566
+ head(key: string, options?: KVHeadOptions): Promise<Result<KVResponse<void>>>;
567
+ /**
568
+ * Create a prefix-scoped view of this KV service.
569
+ *
570
+ * Returns a PrefixedKVService that automatically prefixes all
571
+ * key operations with the specified prefix. This enables apps
572
+ * to isolate their data within a shared space.
573
+ *
574
+ * @param prefix - The prefix to apply to all operations
575
+ * @returns A PrefixedKVService scoped to the prefix
576
+ *
577
+ * @example
578
+ * ```typescript
579
+ * const myApp = kv.withPrefix('/app.myapp.com');
580
+ *
581
+ * // Operations are automatically prefixed
582
+ * await myApp.put('settings.json', { theme: 'dark' });
583
+ * // -> Actually writes to: /app.myapp.com/settings.json
584
+ *
585
+ * // Nested prefixes
586
+ * const settings = myApp.withPrefix('/settings');
587
+ * await settings.get('theme.json'); // -> /app.myapp.com/settings/theme.json
588
+ * ```
589
+ */
590
+ withPrefix(prefix: string): IPrefixedKVService;
591
+ /**
592
+ * Service configuration.
593
+ */
594
+ readonly config: KVServiceConfig;
595
+ }
596
+
597
+ /**
598
+ * KVService - Key-Value storage service implementation.
599
+ *
600
+ * Platform-agnostic KV service that works with both web-sdk and node-sdk.
601
+ * Uses dependency injection via IServiceContext for platform dependencies.
602
+ */
603
+
604
+ /**
605
+ * KV service implementation.
606
+ *
607
+ * Provides key-value storage operations using TinyCloud's KV API.
608
+ * Uses the Result type pattern for explicit error handling.
609
+ *
610
+ * @example
611
+ * ```typescript
612
+ * // Register with SDK
613
+ * const sdk = new TinyCloud({
614
+ * services: { kv: KVService },
615
+ * serviceConfigs: { kv: { prefix: 'myapp' } },
616
+ * });
617
+ *
618
+ * // Use the service
619
+ * const result = await sdk.kv.get('settings');
620
+ * if (result.ok) {
621
+ * console.log(result.data.data);
622
+ * }
623
+ * ```
624
+ */
625
+ declare class KVService extends BaseService implements IKVService {
626
+ /**
627
+ * Service identifier for registration.
628
+ */
629
+ static readonly serviceName = "kv";
630
+ /**
631
+ * Service configuration.
632
+ */
633
+ protected _config: KVServiceConfig;
634
+ /**
635
+ * Create a new KVService instance.
636
+ *
637
+ * @param config - Service configuration
638
+ */
639
+ constructor(config?: KVServiceConfig);
640
+ /**
641
+ * Get the service configuration.
642
+ */
643
+ get config(): KVServiceConfig;
644
+ private parseQuotaInfo;
645
+ private handleQuotaErrorResponse;
646
+ /**
647
+ * Get the full path with optional prefix.
648
+ *
649
+ * @param key - The key
650
+ * @param prefixOverride - Optional prefix override
651
+ * @returns The full path
652
+ */
653
+ private getFullPath;
654
+ /**
655
+ * Get the host URL.
656
+ */
657
+ private get host();
658
+ /**
659
+ * Execute an invoke operation.
660
+ *
661
+ * @param path - Resource path
662
+ * @param action - KV action
663
+ * @param body - Optional request body
664
+ * @param signal - Optional abort signal
665
+ * @returns Fetch response
666
+ */
667
+ private invokeOperation;
668
+ /**
669
+ * Create KVResponseHeaders from fetch response headers.
670
+ *
671
+ * @param headers - Fetch response headers
672
+ * @returns KVResponseHeaders object
673
+ */
674
+ private createResponseHeaders;
675
+ /**
676
+ * Parse response body based on content type.
677
+ *
678
+ * @param response - Fetch response
679
+ * @param raw - Whether to return raw text
680
+ * @returns Parsed data
681
+ */
682
+ private parseResponse;
683
+ /**
684
+ * Get a value by key.
685
+ */
686
+ get<T = unknown>(key: string, options?: KVGetOptions): Promise<Result<KVResponse<T>>>;
687
+ /**
688
+ * Store a value at a key.
689
+ */
690
+ put(key: string, value: unknown, options?: KVPutOptions): Promise<Result<KVResponse<void>>>;
691
+ /**
692
+ * List keys with optional prefix filtering.
693
+ */
694
+ list(options?: KVListOptions): Promise<Result<KVListResponse>>;
695
+ /**
696
+ * Delete a key.
697
+ */
698
+ delete(key: string, options?: KVDeleteOptions): Promise<Result<void>>;
699
+ /**
700
+ * Get metadata for a key without retrieving the value.
701
+ */
702
+ head(key: string, options?: KVHeadOptions): Promise<Result<KVResponse<void>>>;
703
+ /**
704
+ * Create a prefix-scoped view of this KV service.
705
+ *
706
+ * Returns a PrefixedKVService that automatically prefixes all
707
+ * key operations with the specified prefix. This enables apps
708
+ * to isolate their data within a shared space.
709
+ *
710
+ * @param prefix - The prefix to apply to all operations
711
+ * @returns A PrefixedKVService scoped to the prefix
712
+ *
713
+ * ## Prefix Conventions
714
+ *
715
+ * | Pattern | Use Case | Example |
716
+ * | -- | -- | -- |
717
+ * | `/app.{domain}/` | App-private data | `/app.photos.xyz/settings.json` |
718
+ * | `/{type}/` | Shared data type | `/photos/vacation.jpg` |
719
+ * | `/.{name}/` | Hidden/system data | `/.cache/thumbnails/` |
720
+ * | `/public/` | Explicitly shareable | `/public/profile.json` |
721
+ *
722
+ * @example
723
+ * ```typescript
724
+ * const space = sdk.space('default');
725
+ *
726
+ * // Create prefix-scoped views
727
+ * const myApp = space.kv.withPrefix('/app.myapp.com');
728
+ * const sharedPhotos = space.kv.withPrefix('/photos');
729
+ *
730
+ * // Operations are automatically prefixed
731
+ * await myApp.put('settings.json', { theme: 'dark' });
732
+ * // -> Actually writes to: /app.myapp.com/settings.json
733
+ *
734
+ * await myApp.get('settings.json');
735
+ * // -> Actually reads from: /app.myapp.com/settings.json
736
+ *
737
+ * await sharedPhotos.list();
738
+ * // -> Lists: /photos/*
739
+ *
740
+ * // Nested prefixes
741
+ * const settings = myApp.withPrefix('/settings');
742
+ * await settings.get('theme.json'); // -> /app.myapp.com/settings/theme.json
743
+ * ```
744
+ */
745
+ withPrefix(prefix: string): IPrefixedKVService;
746
+ }
747
+
748
+ export { type IKVService, type IPrefixedKVService, KVAction, type KVActionType, type KVDeleteOptions, type KVGetOptions, type KVHeadOptions, type KVListOptions, type KVListResponse, type KVPutOptions, type KVResponse, type KVResponseHeaders, KVService, type KVServiceConfig, PrefixedKVService };