Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Jul 21, 2025

  • Update storage.ts to call sync directly when not running in a shim environment.
  • Allow either EntityId or URIs on sync call (eventually we'll deprecate the former)

Summary by cubic

Updated storage to call sync directly when not running in a shim and added support for URIs in sync calls.

  • Refactors
    • Calls sync on the storage provider directly if not in a shim environment.
    • Allows both EntityId and URI formats in sync methods.

…c calls

- Update storage.ts to call sync directly when not running in a shim environment.
- Allow either EntityId or URIs on sync call (eventually we'll deprecate the former)
@seefeldb seefeldb requested review from Copilot and ubik2 July 21, 2025 21:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the storage sync functionality by allowing direct sync calls when not in a shim environment and expanding the sync method to accept URIs in addition to EntityIds. The changes prepare for future deprecation of EntityId in favor of URI-based identifiers.

  • Direct sync calls when not running in shim environment to improve performance
  • Updated sync method signatures to accept both EntityId and URI types
  • Added URI validation logic in the BaseStorageProvider's toEntity method

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/runner/src/storage/interface.ts Updated sync method signature to accept EntityId or URI
packages/runner/src/storage/cache.ts Updated sync method signatures in ProviderConnection and Provider classes
packages/runner/src/storage/base.ts Enhanced toEntity method to handle string URIs with validation
packages/runner/src/storage.ts Added direct sync call path when not in shim environment
Comments suppressed due to low confidence (1)

packages/runner/src/storage/base.ts:87

  • [nitpick] The error message uses an emoji which may not display properly in all environments and could make logs harder to parse programmatically. Consider using a standard error prefix.
          `💣 Got entity ID that is a string, but not a URI: ${source}`,

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic analysis

No issues found across 4 files. Review in cubic

if (!this.shim) {
const { space, id } = cell.getAsNormalizedFullLink();
const storageProvider = this._getStorageProviderForSpace(space);
return storageProvider.sync(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is in an async function, I'd rather have:

      await storageProvider.sync(id, false, schemaContext);
      return cell;


sync(
entityId: EntityId,
entityId: EntityId | Entity,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be URI instead of Entity for clarity, and we should do the same below (line 1445)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URI is an alias to Entity in the other file, but not here, not sure why.

Copy link
Contributor

@ubik2 ubik2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but i did have some minor suggestions

@ubik2
Copy link
Contributor

ubik2 commented Jul 22, 2025

I ended up folding my suggestions, as well as the more substantial move away from EntityId into #1464, so this should probably just land as-is.

@seefeldb
Copy link
Contributor Author

Ah, I think your change now includes all relevant bits of this one. Closing.

* Minor tweaks
- Use await instead of a promise chain in Storage.syncCell.
- Use URI isntead of Entity, since we also define this in memory/interface.ts.

* Change IStorageProvider API to be URI based instead of EntityId as well as the BaseStorageProvider implementation and the Storage class.
Moved BaseStorageProvider.toEntity into Storage.toURI, since this is the only place it's needed.
Changed IStorageProvider to use URI instead of EntityId, as well as the ProviderConnection and Provider classes.
Updated tests to use cell.getAsNormalizedFullLink to get the URI instead of EntityId.
@ubik2 ubik2 reopened this Jul 22, 2025
@ubik2 ubik2 merged commit 2e15fc8 into main Jul 22, 2025
7 checks passed
@ubik2 ubik2 deleted the call-sync-directly-when-not-in-shim branch July 22, 2025 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants