@tinycloud/sdk-core 3.0.1-beta.0 → 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 +43 -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 +49 -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,
|
|
@@ -235,6 +237,7 @@ __export(index_exports, {
|
|
|
235
237
|
admitPolicyCredentialV3: () => admitPolicyCredentialV3,
|
|
236
238
|
admitPolicyCredentialV4: () => admitPolicyCredentialV4,
|
|
237
239
|
applyPrefix: () => applyPrefix,
|
|
240
|
+
authorizationVerdictOf: () => import_sdk_services8.authorizationVerdictOf,
|
|
238
241
|
bootstrapEncryptionNetworkId: () => import_bootstrap4.bootstrapEncryptionNetworkId,
|
|
239
242
|
bootstrapSpaceId: () => import_bootstrap4.bootstrapSpaceId,
|
|
240
243
|
bootstrapSteps: () => import_bootstrap4.bootstrapSteps,
|
|
@@ -357,6 +360,7 @@ __export(index_exports, {
|
|
|
357
360
|
isEvmAddress: () => isEvmAddress,
|
|
358
361
|
isNetworkId: () => import_sdk_services8.isNetworkId,
|
|
359
362
|
isPlausibleOpenKeyActionId: () => isPlausibleOpenKeyActionId,
|
|
363
|
+
isStorageFullError: () => import_sdk_services8.isStorageFullError,
|
|
360
364
|
isV2ShareLink: () => isV2ShareLink,
|
|
361
365
|
issuedCredentialEnvelopeFromVerified: () => issuedCredentialEnvelopeFromVerified,
|
|
362
366
|
jcsCanonicalize: () => jcsCanonicalize,
|
|
@@ -14184,10 +14188,10 @@ var AccountService = class {
|
|
|
14184
14188
|
* Per-account-space memo for {@link ensureAccountIndex}.
|
|
14185
14189
|
*
|
|
14186
14190
|
* Applying the index migration is a no-op once the schema exists, but the
|
|
14187
|
-
* SQL service still spends
|
|
14188
|
-
*
|
|
14189
|
-
*
|
|
14190
|
-
*
|
|
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
|
|
14191
14195
|
* never helps here: the node SDK builds a fresh SQLService per
|
|
14192
14196
|
* `getAccountDb()` call, so its lock map is always empty.
|
|
14193
14197
|
*
|
|
@@ -14285,11 +14289,12 @@ var AccountService = class {
|
|
|
14285
14289
|
const indexed = await this.index.spaces.list();
|
|
14286
14290
|
if (indexed.ok && indexed.data.length > 0) return indexed;
|
|
14287
14291
|
if (!indexed.ok && !isMissingIndexError(indexed.error)) return indexed;
|
|
14288
|
-
const canonical = await this.
|
|
14289
|
-
if (canonical.ok
|
|
14290
|
-
|
|
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);
|
|
14291
14296
|
}
|
|
14292
|
-
return canonical;
|
|
14297
|
+
return (0, import_sdk_services6.ok)(canonical.data.spaces);
|
|
14293
14298
|
}
|
|
14294
14299
|
const kvResult = this.accountKV();
|
|
14295
14300
|
if (!kvResult.ok) return kvResult;
|
|
@@ -14377,15 +14382,8 @@ var AccountService = class {
|
|
|
14377
14382
|
return (0, import_sdk_services6.ok)({ spaces: registered, recoveredFromBatchError: batchResult.error });
|
|
14378
14383
|
},
|
|
14379
14384
|
syncAccessible: async () => {
|
|
14380
|
-
const
|
|
14381
|
-
|
|
14382
|
-
const registered = [];
|
|
14383
|
-
for (const space of listed.data) {
|
|
14384
|
-
const result = await this.spaces.register(space);
|
|
14385
|
-
if (!result.ok) return result;
|
|
14386
|
-
registered.push(result.data);
|
|
14387
|
-
}
|
|
14388
|
-
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;
|
|
14389
14387
|
},
|
|
14390
14388
|
remove: async (spaceId) => {
|
|
14391
14389
|
const kvResult = this.accountKV();
|
|
@@ -14817,6 +14815,34 @@ var AccountService = class {
|
|
|
14817
14815
|
if (!deleted.ok) return accountErr(deleted.error);
|
|
14818
14816
|
return (0, import_sdk_services6.ok)(void 0);
|
|
14819
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
|
+
}
|
|
14820
14846
|
async resolveSpace(space) {
|
|
14821
14847
|
const listed = await this.config.getSpaces().list();
|
|
14822
14848
|
if (!listed.ok) return accountErr(listed.error);
|