@tinycloud/sdk-services 2.7.0-beta.3 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/BaseService-BwBU5CQ4.d.cts +158 -0
  2. package/dist/BaseService-CnPTKR5G.d.ts +158 -0
  3. package/dist/encryption/index.cjs +46 -6
  4. package/dist/encryption/index.cjs.map +1 -1
  5. package/dist/encryption/index.d.cts +9 -1
  6. package/dist/encryption/index.d.ts +9 -1
  7. package/dist/encryption/index.js +45 -6
  8. package/dist/encryption/index.js.map +1 -1
  9. package/dist/index.cjs +299 -21
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +58 -9
  12. package/dist/index.d.ts +58 -9
  13. package/dist/index.js +293 -18
  14. package/dist/index.js.map +1 -1
  15. package/dist/internal/decrypt-transport-response-error.cjs +38 -0
  16. package/dist/internal/decrypt-transport-response-error.cjs.map +1 -0
  17. package/dist/internal/decrypt-transport-response-error.d.cts +10 -0
  18. package/dist/internal/decrypt-transport-response-error.d.ts +10 -0
  19. package/dist/internal/decrypt-transport-response-error.js +13 -0
  20. package/dist/internal/decrypt-transport-response-error.js.map +1 -0
  21. package/dist/kv/index.cjs +46 -4
  22. package/dist/kv/index.cjs.map +1 -1
  23. package/dist/kv/index.d.cts +2 -1
  24. package/dist/kv/index.d.ts +2 -1
  25. package/dist/kv/index.js +46 -4
  26. package/dist/kv/index.js.map +1 -1
  27. package/dist/sql/index.cjs +6 -2
  28. package/dist/sql/index.cjs.map +1 -1
  29. package/dist/sql/index.d.cts +2 -1
  30. package/dist/sql/index.d.ts +2 -1
  31. package/dist/sql/index.js +6 -2
  32. package/dist/sql/index.js.map +1 -1
  33. package/dist/{BaseService-C-EsEeGo.d.cts → types-DAY1O1kW.d.cts} +12 -156
  34. package/dist/{BaseService-C-EsEeGo.d.ts → types-DAY1O1kW.d.ts} +12 -156
  35. package/package.json +11 -3
@@ -43,6 +43,17 @@ interface ServiceError {
43
43
  /** Additional metadata about the error */
44
44
  meta?: Record<string, unknown>;
45
45
  }
46
+ /**
47
+ * A node-supplied permission hint after strict SDK validation. This is
48
+ * deliberately narrower than a general capability: no wildcards, caveats,
49
+ * descriptions, or transport metadata can cross the service boundary.
50
+ */
51
+ interface PermissionHint {
52
+ readonly service: "tinycloud.kv" | "tinycloud.encryption";
53
+ readonly space?: string;
54
+ readonly path: string;
55
+ readonly actions: readonly string[];
56
+ }
46
57
  /**
47
58
  * Storage quota information returned with quota-related errors.
48
59
  */
@@ -338,159 +349,4 @@ declare function serviceError(code: string, message: string, service: string, op
338
349
  meta?: Record<string, unknown>;
339
350
  }): ServiceError;
340
351
 
341
- /**
342
- * BaseService - Abstract base class for all TinyCloud services.
343
- *
344
- * Provides common functionality:
345
- * - Context management
346
- * - Session lifecycle hooks
347
- * - Abort signal handling
348
- * - Telemetry emission
349
- */
350
-
351
- /**
352
- * Abstract base class for TinyCloud services.
353
- *
354
- * Services extend this class to get common functionality like
355
- * context management, session lifecycle, and abort handling.
356
- *
357
- * @example
358
- * ```typescript
359
- * class MyService extends BaseService implements IMyService {
360
- * static readonly serviceName = 'myservice';
361
- *
362
- * constructor(config: MyServiceConfig = {}) {
363
- * super();
364
- * this._config = config;
365
- * }
366
- *
367
- * async doSomething(): Promise<Result<Data>> {
368
- * if (!this.requireAuth()) {
369
- * return err(authRequiredError('myservice'));
370
- * }
371
- * // ... implementation
372
- * }
373
- * }
374
- * ```
375
- */
376
- declare abstract class BaseService implements IService {
377
- /**
378
- * Service identifier used for registration.
379
- * Must be overridden by subclasses.
380
- */
381
- static readonly serviceName: string;
382
- /**
383
- * Service context providing access to platform dependencies.
384
- * Set during initialize().
385
- */
386
- protected context: IServiceContext;
387
- /**
388
- * Abort controller for this service's operations.
389
- * Reset on sign-out.
390
- */
391
- protected abortController: AbortController;
392
- /**
393
- * Service-specific configuration.
394
- */
395
- protected _config: Record<string, unknown>;
396
- /**
397
- * Get the service configuration.
398
- */
399
- get config(): Record<string, unknown>;
400
- /**
401
- * Initialize the service with context.
402
- * Called by the SDK after instantiation.
403
- *
404
- * @param context - The service context
405
- */
406
- initialize(context: IServiceContext): void;
407
- /**
408
- * Called when session changes (sign-in, sign-out, refresh).
409
- * Override in subclasses to handle session changes.
410
- *
411
- * @param session - The new session, or null if signed out
412
- */
413
- onSessionChange(session: ServiceSession | null): void;
414
- /**
415
- * Called when SDK signs out.
416
- * Aborts all pending operations.
417
- */
418
- onSignOut(): void;
419
- /**
420
- * Get the abort signal for this service.
421
- * Combines the service-level abort with context-level abort.
422
- */
423
- protected get abortSignal(): AbortSignal;
424
- /**
425
- * Check if the service is authenticated.
426
- */
427
- protected get isAuthenticated(): boolean;
428
- /**
429
- * Get the current session.
430
- * Throws if not authenticated.
431
- */
432
- protected get session(): ServiceSession;
433
- /**
434
- * Check authentication and return error result if not authenticated.
435
- * Use this at the start of methods that require authentication.
436
- *
437
- * @returns true if authenticated, false otherwise
438
- */
439
- protected requireAuth(): boolean;
440
- /**
441
- * Emit a telemetry event.
442
- *
443
- * @param event - Event name
444
- * @param data - Event data
445
- */
446
- protected emit(event: string, data: unknown): void;
447
- /**
448
- * Emit a service request event.
449
- *
450
- * @param action - The action being performed
451
- * @param key - Optional key/path being accessed
452
- */
453
- protected emitRequest(action: string, key?: string): void;
454
- /**
455
- * Emit a service response event.
456
- *
457
- * @param action - The action that was performed
458
- * @param ok - Whether the request was successful
459
- * @param startTime - Start time for duration calculation
460
- * @param status - Optional HTTP status code
461
- */
462
- protected emitResponse(action: string, ok: boolean, startTime: number, status?: number): void;
463
- /**
464
- * Emit a service error event.
465
- *
466
- * @param error - The service error
467
- */
468
- protected emitError(error: ServiceError, action?: string): void;
469
- /**
470
- * Get the service name from the static property.
471
- * Subclasses must define static serviceName.
472
- */
473
- protected getServiceName(): string;
474
- /**
475
- * Stable span name used by SDK telemetry sinks.
476
- */
477
- protected spanName(action: string): string;
478
- /**
479
- * Create a combined abort signal from multiple sources.
480
- *
481
- * @param signals - Additional abort signals to combine
482
- * @returns A combined abort signal
483
- */
484
- protected combineSignals(...signals: (AbortSignal | undefined)[]): AbortSignal;
485
- /**
486
- * Wrap an operation with error handling and telemetry.
487
- *
488
- * @param action - The action name for telemetry
489
- * @param key - Optional key for telemetry
490
- * @param operation - The operation to execute
491
- * @returns Result of the operation
492
- */
493
- protected withTelemetry<T>(action: string, key: string | undefined, operation: () => Promise<Result<T>>): Promise<Result<T>>;
494
- }
495
-
496
- export { BaseService as B, type EventHandler as E, type FetchFunction as F, type IServiceContext as I, type RetryPolicy as R, type ServiceSession as S, type TelemetryConfig as T, type InvokeFunction as a, type InvokeAnyFunction as b, type IService as c, type ServiceError as d, type Result as e, type StorageQuotaInfo as f, type ErrorCode as g, ErrorCodes as h, type FetchRequestInit as i, type FetchResponse as j, type InvocationFact as k, type InvocationFacts as l, type InvokeAnyEntry as m, type ServiceErrorEvent as n, type ServiceHeaders as o, type ServiceRequestEvent as p, type ServiceResponseEvent as q, type ServiceRetryEvent as r, type TelemetryEventHandler as s, TelemetryEvents as t, type TelemetrySpanEvent as u, defaultRetryPolicy as v, err as w, ok as x, serviceError as y };
352
+ export { type EventHandler as E, type FetchFunction as F, type IService as I, type PermissionHint as P, type Result as R, type ServiceSession as S, type TelemetryConfig as T, type IServiceContext as a, type ServiceError as b, type InvokeFunction as c, type InvokeAnyFunction as d, type RetryPolicy as e, type StorageQuotaInfo as f, type ErrorCode as g, ErrorCodes as h, type FetchRequestInit as i, type FetchResponse as j, type InvocationFact as k, type InvocationFacts as l, type InvokeAnyEntry as m, type ServiceErrorEvent as n, type ServiceHeaders as o, type ServiceRequestEvent as p, type ServiceResponseEvent as q, type ServiceRetryEvent as r, type TelemetryEventHandler as s, TelemetryEvents as t, type TelemetrySpanEvent as u, defaultRetryPolicy as v, err as w, ok as x, serviceError as y };
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@tinycloud/sdk-services",
3
- "version": "2.7.0-beta.3",
3
+ "version": "2.7.0",
4
4
  "description": "TinyCloud SDK Services - Platform-agnostic service implementations",
5
5
  "author": "TinyCloud, Inc.",
6
6
  "license": "EGPL",
7
+ "engines": {
8
+ "node": ">=20"
9
+ },
7
10
  "type": "module",
8
11
  "main": "dist/index.cjs",
9
12
  "module": "dist/index.js",
@@ -28,6 +31,11 @@
28
31
  "types": "./dist/encryption/index.d.ts",
29
32
  "import": "./dist/encryption/index.js",
30
33
  "require": "./dist/encryption/index.cjs"
34
+ },
35
+ "./internal/decrypt-transport-response-error": {
36
+ "types": "./dist/internal/decrypt-transport-response-error.d.cts",
37
+ "import": "./dist/internal/decrypt-transport-response-error.cjs",
38
+ "require": "./dist/internal/decrypt-transport-response-error.cjs"
31
39
  }
32
40
  },
33
41
  "files": [
@@ -39,12 +47,12 @@
39
47
  "test": "bun test"
40
48
  },
41
49
  "dependencies": {
42
- "@tinycloud/bootstrap": "2.6.0-beta.0",
50
+ "@tinycloud/bootstrap": "2.6.0",
43
51
  "zod": "^3.23.0"
44
52
  },
45
53
  "devDependencies": {
46
54
  "@types/node": "^20",
47
- "@tinycloud/node-sdk-wasm": "1.7.4",
55
+ "@tinycloud/node-sdk-wasm": "1.7.5",
48
56
  "tsup": "^8.0.0",
49
57
  "typescript": "^5.9.3"
50
58
  },