@tinycloud/sdk-services 2.6.3 → 2.7.0-beta.4
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/BaseService-BwBU5CQ4.d.cts +158 -0
- package/dist/BaseService-CnPTKR5G.d.ts +158 -0
- package/dist/encryption/index.cjs +46 -6
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.d.cts +9 -1
- package/dist/encryption/index.d.ts +9 -1
- package/dist/encryption/index.js +45 -6
- package/dist/encryption/index.js.map +1 -1
- package/dist/index.cjs +299 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -9
- package/dist/index.d.ts +58 -9
- package/dist/index.js +293 -18
- package/dist/index.js.map +1 -1
- package/dist/internal/decrypt-transport-response-error.cjs +38 -0
- package/dist/internal/decrypt-transport-response-error.cjs.map +1 -0
- package/dist/internal/decrypt-transport-response-error.d.cts +10 -0
- package/dist/internal/decrypt-transport-response-error.d.ts +10 -0
- package/dist/internal/decrypt-transport-response-error.js +13 -0
- package/dist/internal/decrypt-transport-response-error.js.map +1 -0
- package/dist/kv/index.cjs +46 -4
- package/dist/kv/index.cjs.map +1 -1
- package/dist/kv/index.d.cts +2 -1
- package/dist/kv/index.d.ts +2 -1
- package/dist/kv/index.js +46 -4
- package/dist/kv/index.js.map +1 -1
- package/dist/sql/index.cjs +6 -2
- package/dist/sql/index.cjs.map +1 -1
- package/dist/sql/index.d.cts +2 -1
- package/dist/sql/index.d.ts +2 -1
- package/dist/sql/index.js +6 -2
- package/dist/sql/index.js.map +1 -1
- package/dist/{BaseService-BdRvNm2s.d.cts → types-DAY1O1kW.d.cts} +14 -156
- package/dist/{BaseService-BdRvNm2s.d.ts → types-DAY1O1kW.d.ts} +14 -156
- 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
|
*/
|
|
@@ -146,6 +157,8 @@ interface InvokeAnyEntry {
|
|
|
146
157
|
action: string;
|
|
147
158
|
/** Optional raw resource URI. When set, WASM signs this URI directly. */
|
|
148
159
|
resource?: string;
|
|
160
|
+
/** Capability caveats that must remain on this invocation attenuation. */
|
|
161
|
+
caveats?: Record<string, unknown>[];
|
|
149
162
|
}
|
|
150
163
|
/**
|
|
151
164
|
* Invoke function for minting a single authorization header that covers
|
|
@@ -336,159 +349,4 @@ declare function serviceError(code: string, message: string, service: string, op
|
|
|
336
349
|
meta?: Record<string, unknown>;
|
|
337
350
|
}): ServiceError;
|
|
338
351
|
|
|
339
|
-
|
|
340
|
-
* BaseService - Abstract base class for all TinyCloud services.
|
|
341
|
-
*
|
|
342
|
-
* Provides common functionality:
|
|
343
|
-
* - Context management
|
|
344
|
-
* - Session lifecycle hooks
|
|
345
|
-
* - Abort signal handling
|
|
346
|
-
* - Telemetry emission
|
|
347
|
-
*/
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Abstract base class for TinyCloud services.
|
|
351
|
-
*
|
|
352
|
-
* Services extend this class to get common functionality like
|
|
353
|
-
* context management, session lifecycle, and abort handling.
|
|
354
|
-
*
|
|
355
|
-
* @example
|
|
356
|
-
* ```typescript
|
|
357
|
-
* class MyService extends BaseService implements IMyService {
|
|
358
|
-
* static readonly serviceName = 'myservice';
|
|
359
|
-
*
|
|
360
|
-
* constructor(config: MyServiceConfig = {}) {
|
|
361
|
-
* super();
|
|
362
|
-
* this._config = config;
|
|
363
|
-
* }
|
|
364
|
-
*
|
|
365
|
-
* async doSomething(): Promise<Result<Data>> {
|
|
366
|
-
* if (!this.requireAuth()) {
|
|
367
|
-
* return err(authRequiredError('myservice'));
|
|
368
|
-
* }
|
|
369
|
-
* // ... implementation
|
|
370
|
-
* }
|
|
371
|
-
* }
|
|
372
|
-
* ```
|
|
373
|
-
*/
|
|
374
|
-
declare abstract class BaseService implements IService {
|
|
375
|
-
/**
|
|
376
|
-
* Service identifier used for registration.
|
|
377
|
-
* Must be overridden by subclasses.
|
|
378
|
-
*/
|
|
379
|
-
static readonly serviceName: string;
|
|
380
|
-
/**
|
|
381
|
-
* Service context providing access to platform dependencies.
|
|
382
|
-
* Set during initialize().
|
|
383
|
-
*/
|
|
384
|
-
protected context: IServiceContext;
|
|
385
|
-
/**
|
|
386
|
-
* Abort controller for this service's operations.
|
|
387
|
-
* Reset on sign-out.
|
|
388
|
-
*/
|
|
389
|
-
protected abortController: AbortController;
|
|
390
|
-
/**
|
|
391
|
-
* Service-specific configuration.
|
|
392
|
-
*/
|
|
393
|
-
protected _config: Record<string, unknown>;
|
|
394
|
-
/**
|
|
395
|
-
* Get the service configuration.
|
|
396
|
-
*/
|
|
397
|
-
get config(): Record<string, unknown>;
|
|
398
|
-
/**
|
|
399
|
-
* Initialize the service with context.
|
|
400
|
-
* Called by the SDK after instantiation.
|
|
401
|
-
*
|
|
402
|
-
* @param context - The service context
|
|
403
|
-
*/
|
|
404
|
-
initialize(context: IServiceContext): void;
|
|
405
|
-
/**
|
|
406
|
-
* Called when session changes (sign-in, sign-out, refresh).
|
|
407
|
-
* Override in subclasses to handle session changes.
|
|
408
|
-
*
|
|
409
|
-
* @param session - The new session, or null if signed out
|
|
410
|
-
*/
|
|
411
|
-
onSessionChange(session: ServiceSession | null): void;
|
|
412
|
-
/**
|
|
413
|
-
* Called when SDK signs out.
|
|
414
|
-
* Aborts all pending operations.
|
|
415
|
-
*/
|
|
416
|
-
onSignOut(): void;
|
|
417
|
-
/**
|
|
418
|
-
* Get the abort signal for this service.
|
|
419
|
-
* Combines the service-level abort with context-level abort.
|
|
420
|
-
*/
|
|
421
|
-
protected get abortSignal(): AbortSignal;
|
|
422
|
-
/**
|
|
423
|
-
* Check if the service is authenticated.
|
|
424
|
-
*/
|
|
425
|
-
protected get isAuthenticated(): boolean;
|
|
426
|
-
/**
|
|
427
|
-
* Get the current session.
|
|
428
|
-
* Throws if not authenticated.
|
|
429
|
-
*/
|
|
430
|
-
protected get session(): ServiceSession;
|
|
431
|
-
/**
|
|
432
|
-
* Check authentication and return error result if not authenticated.
|
|
433
|
-
* Use this at the start of methods that require authentication.
|
|
434
|
-
*
|
|
435
|
-
* @returns true if authenticated, false otherwise
|
|
436
|
-
*/
|
|
437
|
-
protected requireAuth(): boolean;
|
|
438
|
-
/**
|
|
439
|
-
* Emit a telemetry event.
|
|
440
|
-
*
|
|
441
|
-
* @param event - Event name
|
|
442
|
-
* @param data - Event data
|
|
443
|
-
*/
|
|
444
|
-
protected emit(event: string, data: unknown): void;
|
|
445
|
-
/**
|
|
446
|
-
* Emit a service request event.
|
|
447
|
-
*
|
|
448
|
-
* @param action - The action being performed
|
|
449
|
-
* @param key - Optional key/path being accessed
|
|
450
|
-
*/
|
|
451
|
-
protected emitRequest(action: string, key?: string): void;
|
|
452
|
-
/**
|
|
453
|
-
* Emit a service response event.
|
|
454
|
-
*
|
|
455
|
-
* @param action - The action that was performed
|
|
456
|
-
* @param ok - Whether the request was successful
|
|
457
|
-
* @param startTime - Start time for duration calculation
|
|
458
|
-
* @param status - Optional HTTP status code
|
|
459
|
-
*/
|
|
460
|
-
protected emitResponse(action: string, ok: boolean, startTime: number, status?: number): void;
|
|
461
|
-
/**
|
|
462
|
-
* Emit a service error event.
|
|
463
|
-
*
|
|
464
|
-
* @param error - The service error
|
|
465
|
-
*/
|
|
466
|
-
protected emitError(error: ServiceError, action?: string): void;
|
|
467
|
-
/**
|
|
468
|
-
* Get the service name from the static property.
|
|
469
|
-
* Subclasses must define static serviceName.
|
|
470
|
-
*/
|
|
471
|
-
protected getServiceName(): string;
|
|
472
|
-
/**
|
|
473
|
-
* Stable span name used by SDK telemetry sinks.
|
|
474
|
-
*/
|
|
475
|
-
protected spanName(action: string): string;
|
|
476
|
-
/**
|
|
477
|
-
* Create a combined abort signal from multiple sources.
|
|
478
|
-
*
|
|
479
|
-
* @param signals - Additional abort signals to combine
|
|
480
|
-
* @returns A combined abort signal
|
|
481
|
-
*/
|
|
482
|
-
protected combineSignals(...signals: (AbortSignal | undefined)[]): AbortSignal;
|
|
483
|
-
/**
|
|
484
|
-
* Wrap an operation with error handling and telemetry.
|
|
485
|
-
*
|
|
486
|
-
* @param action - The action name for telemetry
|
|
487
|
-
* @param key - Optional key for telemetry
|
|
488
|
-
* @param operation - The operation to execute
|
|
489
|
-
* @returns Result of the operation
|
|
490
|
-
*/
|
|
491
|
-
protected withTelemetry<T>(action: string, key: string | undefined, operation: () => Promise<Result<T>>): Promise<Result<T>>;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
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.
|
|
3
|
+
"version": "2.7.0-beta.4",
|
|
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.
|
|
50
|
+
"@tinycloud/bootstrap": "2.6.0-beta.1",
|
|
43
51
|
"zod": "^3.23.0"
|
|
44
52
|
},
|
|
45
53
|
"devDependencies": {
|
|
46
54
|
"@types/node": "^20",
|
|
47
|
-
"@tinycloud/node-sdk-wasm": "1.7.
|
|
55
|
+
"@tinycloud/node-sdk-wasm": "1.7.5-beta.0",
|
|
48
56
|
"tsup": "^8.0.0",
|
|
49
57
|
"typescript": "^5.9.3"
|
|
50
58
|
},
|