@tinycloud/sdk-services 3.8.0-beta.2 → 3.8.0-beta.22

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 (59) hide show
  1. package/dist/{BaseService-DO7vZ67k.d.ts → BaseService-Ma2MwJAd.d.ts} +1 -1
  2. package/dist/{BaseService-D-29xShG.d.cts → BaseService-O0iyuFLk.d.cts} +1 -1
  3. package/dist/IHooksService-4QNODVy6.d.cts +120 -0
  4. package/dist/IHooksService-CvTpJbQD.d.ts +120 -0
  5. package/dist/ISQLService-Aly1CBsW.d.ts +242 -0
  6. package/dist/ISQLService-BOgWzHLT.d.cts +242 -0
  7. package/dist/context.d.cts +1 -1
  8. package/dist/context.d.ts +1 -1
  9. package/dist/encryption/index.cjs +80 -7
  10. package/dist/encryption/index.cjs.map +1 -1
  11. package/dist/encryption/index.d.cts +23 -11
  12. package/dist/encryption/index.d.ts +23 -11
  13. package/dist/encryption/index.js +79 -7
  14. package/dist/encryption/index.js.map +1 -1
  15. package/dist/encryption/named-keys.cjs.map +1 -1
  16. package/dist/encryption/named-keys.d.cts +2 -2
  17. package/dist/encryption/named-keys.d.ts +2 -2
  18. package/dist/encryption/named-keys.js.map +1 -1
  19. package/dist/encryption/resource.cjs.map +1 -1
  20. package/dist/encryption/resource.js.map +1 -1
  21. package/dist/feed/index.cjs +1309 -0
  22. package/dist/feed/index.cjs.map +1 -0
  23. package/dist/feed/index.d.cts +238 -0
  24. package/dist/feed/index.d.ts +238 -0
  25. package/dist/feed/index.js +1258 -0
  26. package/dist/feed/index.js.map +1 -0
  27. package/dist/index.cjs +131 -15
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +16 -116
  30. package/dist/index.d.ts +16 -116
  31. package/dist/index.js +130 -15
  32. package/dist/index.js.map +1 -1
  33. package/dist/internal/decrypt-transport-response-error.d.cts +1 -1
  34. package/dist/internal/decrypt-transport-response-error.d.ts +1 -1
  35. package/dist/kv/index.cjs.map +1 -1
  36. package/dist/kv/index.d.cts +4 -4
  37. package/dist/kv/index.d.ts +4 -4
  38. package/dist/kv/index.js.map +1 -1
  39. package/dist/kv/replication/index.cjs +1 -0
  40. package/dist/kv/replication/index.cjs.map +1 -1
  41. package/dist/kv/replication/index.d.cts +3 -3
  42. package/dist/kv/replication/index.d.ts +3 -3
  43. package/dist/kv/replication/index.js +1 -0
  44. package/dist/kv/replication/index.js.map +1 -1
  45. package/dist/{scope-_HAUxOPl.d.ts → scope-BZr0QwxX.d.ts} +8 -1
  46. package/dist/{scope-D7bzmU6F.d.cts → scope-DEgc9f-W.d.cts} +8 -1
  47. package/dist/sql/index.cjs +21 -6
  48. package/dist/sql/index.cjs.map +1 -1
  49. package/dist/sql/index.d.cts +6 -236
  50. package/dist/sql/index.d.ts +6 -236
  51. package/dist/sql/index.js +21 -6
  52. package/dist/sql/index.js.map +1 -1
  53. package/dist/telemetry/requestLog.d.cts +1 -1
  54. package/dist/telemetry/requestLog.d.ts +1 -1
  55. package/dist/{types-BGRzS1ob.d.ts → types-Bf91gup6.d.ts} +7 -2
  56. package/dist/{types-DAOyIbXu.d.cts → types-CSd0RYir.d.cts} +1 -1
  57. package/dist/{types-DAOyIbXu.d.ts → types-CSd0RYir.d.ts} +1 -1
  58. package/dist/{types-B_rbS4XE.d.cts → types-D4XbIfFJ.d.cts} +7 -2
  59. package/package.json +6 -1
@@ -1,4 +1,4 @@
1
- import { i as RetryStats, h as Result, F as FetchFunction } from './types-DAOyIbXu.js';
1
+ import { i as RetryStats, f as Result, F as FetchFunction } from './types-CSd0RYir.js';
2
2
  import { REPLICA_KV_STORES } from './kv/replication/contractConstants.js';
3
3
  import { ReplicaConsentAnchor, ReplicaGrantPolicy } from './kv/replication/grantPolicyTypes.js';
4
4
 
@@ -1460,6 +1460,8 @@ interface KVReplicaSpec {
1460
1460
  grantPolicy?: ReplicaGrantPolicy;
1461
1461
  /** Quota settings; absent means unbounded. */
1462
1462
  quota?: ReplicaQuotaSpec;
1463
+ /** Value download policy for syncs of this handle; absent means `"eager"`. See `ReplicationOptions.contentFetch`. */
1464
+ contentFetch?: "eager" | "lazy";
1463
1465
  /**
1464
1466
  * Called when another tab/process commits a sync for this partition (browser: the worker's
1465
1467
  * `committed` BroadcastChannel message). The controller emits `replication.sync` with
@@ -1842,6 +1844,11 @@ interface ReplicationOptions {
1842
1844
  allowSecrets?: boolean;
1843
1845
  /** Sign-in asks for kv/sync on each declared prefix only and never widens to a root entry that covers them. */
1844
1846
  syncScope?: "prefixes";
1847
+ /**
1848
+ * `"eager"` (default) downloads each changed value while syncing. `"lazy"` syncs entry names
1849
+ * without downloading values; a read of a value the replica does not hold goes to the network.
1850
+ */
1851
+ contentFetch?: "eager" | "lazy";
1845
1852
  /** Background interval; default 60 seconds. */
1846
1853
  syncIntervalMs?: number;
1847
1854
  maxStalenessMs?: number;
@@ -1,4 +1,4 @@
1
- import { i as RetryStats, h as Result, F as FetchFunction } from './types-DAOyIbXu.cjs';
1
+ import { i as RetryStats, f as Result, F as FetchFunction } from './types-CSd0RYir.cjs';
2
2
  import { REPLICA_KV_STORES } from './kv/replication/contractConstants.cjs';
3
3
  import { ReplicaConsentAnchor, ReplicaGrantPolicy } from './kv/replication/grantPolicyTypes.cjs';
4
4
 
@@ -1460,6 +1460,8 @@ interface KVReplicaSpec {
1460
1460
  grantPolicy?: ReplicaGrantPolicy;
1461
1461
  /** Quota settings; absent means unbounded. */
1462
1462
  quota?: ReplicaQuotaSpec;
1463
+ /** Value download policy for syncs of this handle; absent means `"eager"`. See `ReplicationOptions.contentFetch`. */
1464
+ contentFetch?: "eager" | "lazy";
1463
1465
  /**
1464
1466
  * Called when another tab/process commits a sync for this partition (browser: the worker's
1465
1467
  * `committed` BroadcastChannel message). The controller emits `replication.sync` with
@@ -1842,6 +1844,11 @@ interface ReplicationOptions {
1842
1844
  allowSecrets?: boolean;
1843
1845
  /** Sign-in asks for kv/sync on each declared prefix only and never widens to a root entry that covers them. */
1844
1846
  syncScope?: "prefixes";
1847
+ /**
1848
+ * `"eager"` (default) downloads each changed value while syncing. `"lazy"` syncs entry names
1849
+ * without downloading values; a read of a value the replica does not hold goes to the network.
1850
+ */
1851
+ contentFetch?: "eager" | "lazy";
1845
1852
  /** Background interval; default 60 seconds. */
1846
1853
  syncIntervalMs?: number;
1847
1854
  maxStalenessMs?: number;
@@ -770,12 +770,13 @@ var SQLService = class extends BaseService {
770
770
  request.signal
771
771
  );
772
772
  if (!response.ok) {
773
- return await this.handleErrorResponse(response, "query", dbName, [action]);
773
+ const failure = await this.handleErrorResponse(response, "query", dbName, [action]);
774
+ return this.redactFailure(failure, options?.redactErrors, response.status);
774
775
  }
775
776
  const data = await response.json();
776
777
  return ok(data);
777
778
  } catch (error) {
778
- return err(wrapError("sql", error));
779
+ return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
779
780
  } finally {
780
781
  request.dispose();
781
782
  }
@@ -810,12 +811,13 @@ var SQLService = class extends BaseService {
810
811
  request.signal
811
812
  );
812
813
  if (!response.ok) {
813
- return await this.handleErrorResponse(response, "execute", dbName, requestedActions);
814
+ const failure = await this.handleErrorResponse(response, "execute", dbName, requestedActions);
815
+ return this.redactFailure(failure, options?.redactErrors, response.status);
814
816
  }
815
817
  const data = await response.json();
816
818
  return ok(data);
817
819
  } catch (error) {
818
- return err(wrapError("sql", error));
820
+ return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
819
821
  } finally {
820
822
  request.dispose();
821
823
  }
@@ -836,12 +838,13 @@ var SQLService = class extends BaseService {
836
838
  request.signal
837
839
  );
838
840
  if (!response.ok) {
839
- return await this.handleErrorResponse(response, "batch", dbName, requestedActions);
841
+ const failure = await this.handleErrorResponse(response, "batch", dbName, requestedActions);
842
+ return this.redactFailure(failure, options?.redactErrors, response.status);
840
843
  }
841
844
  const data = await response.json();
842
845
  return ok(data);
843
846
  } catch (error) {
844
- return err(wrapError("sql", error));
847
+ return this.redactFailure(err(wrapError("sql", error)), options?.redactErrors);
845
848
  } finally {
846
849
  request.dispose();
847
850
  }
@@ -1037,6 +1040,18 @@ var SQLService = class extends BaseService {
1037
1040
  }))
1038
1041
  );
1039
1042
  }
1043
+ redactFailure(result, redactErrors, status) {
1044
+ if (!redactErrors || result.ok) return result;
1045
+ const candidate = result.error.code;
1046
+ const code = typeof candidate === "string" && Object.prototype.hasOwnProperty.call(ErrorCodes, candidate) ? candidate : ErrorCodes.SQL_ERROR;
1047
+ const safeStatus = typeof status === "number" && Number.isInteger(status) && status >= 400 && status <= 599 ? status : void 0;
1048
+ return err(serviceError(
1049
+ code,
1050
+ "SQL operation failed",
1051
+ "sql",
1052
+ safeStatus === void 0 ? void 0 : { meta: { status: safeStatus } }
1053
+ ));
1054
+ }
1040
1055
  async handleErrorResponse(response, operation, dbName, requestedActions) {
1041
1056
  const errorText = await response.text();
1042
1057
  const meta = responseErrorMeta(response.status, response.statusText, errorText);