@tinycloud/sdk-core 3.1.0-beta.1 → 3.1.0-beta.2
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 +42 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +47 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -185,6 +185,8 @@ __export(index_exports, {
|
|
|
185
185
|
SQL: () => import_bootstrap4.SQL,
|
|
186
186
|
SQLAction: () => import_sdk_services8.SQLAction,
|
|
187
187
|
SQLService: () => import_sdk_services8.SQLService,
|
|
188
|
+
STORAGE_FULL_MESSAGE: () => import_sdk_services8.STORAGE_FULL_MESSAGE,
|
|
189
|
+
STORAGE_WRITE_TOO_LARGE_MESSAGE: () => import_sdk_services8.STORAGE_WRITE_TOO_LARGE_MESSAGE,
|
|
188
190
|
SecretsService: () => import_sdk_services8.SecretsService,
|
|
189
191
|
SenderShareStore: () => SenderShareStore,
|
|
190
192
|
ServiceContext: () => import_sdk_services8.ServiceContext,
|
|
@@ -358,6 +360,7 @@ __export(index_exports, {
|
|
|
358
360
|
isEvmAddress: () => isEvmAddress,
|
|
359
361
|
isNetworkId: () => import_sdk_services8.isNetworkId,
|
|
360
362
|
isPlausibleOpenKeyActionId: () => isPlausibleOpenKeyActionId,
|
|
363
|
+
isStorageFullError: () => import_sdk_services8.isStorageFullError,
|
|
361
364
|
isV2ShareLink: () => isV2ShareLink,
|
|
362
365
|
issuedCredentialEnvelopeFromVerified: () => issuedCredentialEnvelopeFromVerified,
|
|
363
366
|
jcsCanonicalize: () => jcsCanonicalize,
|
|
@@ -14185,10 +14188,10 @@ var AccountService = class {
|
|
|
14185
14188
|
* Per-account-space memo for {@link ensureAccountIndex}.
|
|
14186
14189
|
*
|
|
14187
14190
|
* Applying the index migration is a no-op once the schema exists, but the
|
|
14188
|
-
* SQL service still spends
|
|
14189
|
-
*
|
|
14190
|
-
*
|
|
14191
|
-
*
|
|
14191
|
+
* SQL service still spends a round trip discovering that (reading the
|
|
14192
|
+
* applied-migration rows). Account bootstrap touches the index eight times,
|
|
14193
|
+
* so without a memo that is ~7 wasted requests on the cold sign-in path.
|
|
14194
|
+
* The in-flight dedupe inside SQLService
|
|
14192
14195
|
* never helps here: the node SDK builds a fresh SQLService per
|
|
14193
14196
|
* `getAccountDb()` call, so its lock map is always empty.
|
|
14194
14197
|
*
|
|
@@ -14286,11 +14289,12 @@ var AccountService = class {
|
|
|
14286
14289
|
const indexed = await this.index.spaces.list();
|
|
14287
14290
|
if (indexed.ok && indexed.data.length > 0) return indexed;
|
|
14288
14291
|
if (!indexed.ok && !isMissingIndexError(indexed.error)) return indexed;
|
|
14289
|
-
const canonical = await this.
|
|
14290
|
-
if (canonical.ok
|
|
14291
|
-
|
|
14292
|
+
const canonical = await this.syncAccessibleSpaces({ tolerateStorageFull: true });
|
|
14293
|
+
if (!canonical.ok) return canonical;
|
|
14294
|
+
if (canonical.data.allRegistered && options2.refreshIndex !== false) {
|
|
14295
|
+
await this.replaceSpacesIndexQuietly(canonical.data.spaces);
|
|
14292
14296
|
}
|
|
14293
|
-
return canonical;
|
|
14297
|
+
return (0, import_sdk_services6.ok)(canonical.data.spaces);
|
|
14294
14298
|
}
|
|
14295
14299
|
const kvResult = this.accountKV();
|
|
14296
14300
|
if (!kvResult.ok) return kvResult;
|
|
@@ -14378,15 +14382,8 @@ var AccountService = class {
|
|
|
14378
14382
|
return (0, import_sdk_services6.ok)({ spaces: registered, recoveredFromBatchError: batchResult.error });
|
|
14379
14383
|
},
|
|
14380
14384
|
syncAccessible: async () => {
|
|
14381
|
-
const
|
|
14382
|
-
|
|
14383
|
-
const registered = [];
|
|
14384
|
-
for (const space of listed.data) {
|
|
14385
|
-
const result = await this.spaces.register(space);
|
|
14386
|
-
if (!result.ok) return result;
|
|
14387
|
-
registered.push(result.data);
|
|
14388
|
-
}
|
|
14389
|
-
return (0, import_sdk_services6.ok)(registered);
|
|
14385
|
+
const synced = await this.syncAccessibleSpaces({ tolerateStorageFull: false });
|
|
14386
|
+
return synced.ok ? (0, import_sdk_services6.ok)(synced.data.spaces) : synced;
|
|
14390
14387
|
},
|
|
14391
14388
|
remove: async (spaceId) => {
|
|
14392
14389
|
const kvResult = this.accountKV();
|
|
@@ -14818,6 +14815,34 @@ var AccountService = class {
|
|
|
14818
14815
|
if (!deleted.ok) return accountErr(deleted.error);
|
|
14819
14816
|
return (0, import_sdk_services6.ok)(void 0);
|
|
14820
14817
|
}
|
|
14818
|
+
/**
|
|
14819
|
+
* Register every space the session can reach and return them. With
|
|
14820
|
+
* `tolerateStorageFull`, a full account space stops the registration
|
|
14821
|
+
* writes but not the listing: the remaining spaces are returned as they
|
|
14822
|
+
* would have been registered, and `allRegistered` is false.
|
|
14823
|
+
*/
|
|
14824
|
+
async syncAccessibleSpaces(options2) {
|
|
14825
|
+
const listed = await this.config.getSpaces().list();
|
|
14826
|
+
if (!listed.ok) return accountErr(listed.error);
|
|
14827
|
+
const spaces = [];
|
|
14828
|
+
let allRegistered = true;
|
|
14829
|
+
for (const space of listed.data) {
|
|
14830
|
+
if (allRegistered) {
|
|
14831
|
+
const result = await this.spaces.register(space);
|
|
14832
|
+
if (result.ok) {
|
|
14833
|
+
spaces.push(result.data);
|
|
14834
|
+
continue;
|
|
14835
|
+
}
|
|
14836
|
+
if (!options2.tolerateStorageFull || !(0, import_sdk_services6.isStorageFullError)(result.error)) {
|
|
14837
|
+
return result;
|
|
14838
|
+
}
|
|
14839
|
+
allRegistered = false;
|
|
14840
|
+
}
|
|
14841
|
+
const record2 = spaceRecordFromInput(space);
|
|
14842
|
+
spaces.push(spaceFromRecord(spaceKey(record2.space_id), record2));
|
|
14843
|
+
}
|
|
14844
|
+
return (0, import_sdk_services6.ok)({ spaces, allRegistered });
|
|
14845
|
+
}
|
|
14821
14846
|
async resolveSpace(space) {
|
|
14822
14847
|
const listed = await this.config.getSpaces().list();
|
|
14823
14848
|
if (!listed.ok) return accountErr(listed.error);
|