@tinycloud/sdk-services 2.10.0-beta.0 → 2.10.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.
package/dist/index.cjs CHANGED
@@ -514,7 +514,9 @@ function createKVResponseSchema(dataSchema) {
514
514
  var GenericKVResponseSchema = createKVResponseSchema(import_zod.z.unknown());
515
515
  var KVListResponseSchema = import_zod.z.object({
516
516
  /** Array of keys matching the list criteria */
517
- keys: import_zod.z.array(import_zod.z.string())
517
+ keys: import_zod.z.array(import_zod.z.string()),
518
+ truncated: import_zod.z.boolean().optional(),
519
+ nextCursor: import_zod.z.string().optional()
518
520
  });
519
521
  var KVListResultSchema = createResultSchema(KVListResponseSchema);
520
522
  var ServiceRequestEventSchema = import_zod.z.object({
@@ -2280,7 +2282,10 @@ var KVService = class extends BaseService {
2280
2282
  KVAction.LIST,
2281
2283
  void 0,
2282
2284
  options?.signal,
2283
- options?.limit === void 0 ? void 0 : { "x-tinycloud-limit": String(options.limit) }
2285
+ options?.limit === void 0 && options?.cursor === void 0 ? void 0 : {
2286
+ ...options?.limit === void 0 ? {} : { "x-tinycloud-limit": String(options.limit) },
2287
+ ...options?.cursor === void 0 ? {} : { "x-tinycloud-cursor": options.cursor }
2288
+ }
2284
2289
  );
2285
2290
  if (!response.ok) {
2286
2291
  if (response.status === 401) {
@@ -2312,7 +2317,8 @@ var KVService = class extends BaseService {
2312
2317
  }
2313
2318
  return ok({
2314
2319
  keys,
2315
- ...response.headers.get("x-tinycloud-truncated") === null ? {} : { truncated: response.headers.get("x-tinycloud-truncated") === "true" }
2320
+ ...response.headers.get("x-tinycloud-truncated") === null ? {} : { truncated: response.headers.get("x-tinycloud-truncated") === "true" },
2321
+ ...response.headers.get("x-tinycloud-next-cursor") === null ? {} : { nextCursor: response.headers.get("x-tinycloud-next-cursor") ?? void 0 }
2316
2322
  });
2317
2323
  } catch (error) {
2318
2324
  return err(wrapError("kv", error));
@@ -5037,6 +5043,10 @@ var DataVaultService = class extends BaseService {
5037
5043
  * @returns Result with array of key names (vault/ prefix stripped)
5038
5044
  */
5039
5045
  async list(options) {
5046
+ const page = await this.listPage(options);
5047
+ return page.ok ? { ok: true, data: page.data.keys } : page;
5048
+ }
5049
+ async listPage(options) {
5040
5050
  return this.withTelemetry("list", options?.prefix, async () => {
5041
5051
  if (!this.isUnlocked) {
5042
5052
  return vaultError({
@@ -5054,7 +5064,9 @@ var DataVaultService = class extends BaseService {
5054
5064
  const listPrefix = options?.prefix ? `vault/${options.prefix}` : "vault/";
5055
5065
  const listResult = await this.tc.kv.list({
5056
5066
  prefix: listPrefix,
5057
- removePrefix: true
5067
+ removePrefix: true,
5068
+ ...options?.limit === void 0 ? {} : { limit: options.limit },
5069
+ ...options?.cursor === void 0 ? {} : { cursor: options.cursor }
5058
5070
  });
5059
5071
  if (!listResult.ok) {
5060
5072
  return vaultError({
@@ -5071,7 +5083,11 @@ var DataVaultService = class extends BaseService {
5071
5083
  (k) => k.startsWith(userPrefix) ? k.slice(userPrefix.length) : k
5072
5084
  );
5073
5085
  }
5074
- return ok(keys);
5086
+ return ok({
5087
+ keys,
5088
+ truncated: listResult.data.truncated === true,
5089
+ ...listResult.data.nextCursor === void 0 ? {} : { nextCursor: listResult.data.nextCursor }
5090
+ });
5075
5091
  } catch (error) {
5076
5092
  return vaultError({
5077
5093
  code: "STORAGE_ERROR",