Add core TypeScript submodules: cron, retry, rate-limit, and crypto - #5903
bradleyshep wants to merge 6 commits into
Conversation
clockwork-tien
left a comment
There was a problem hiding this comment.
There are places where we are using snake_case instead of camelCase, worth checking thoroughly to ensure consistency. I have also left additional comments inline.
| "name": "@spacetimedb/crypto", | ||
| "description": "Deterministic hashing, encoding, and webhook-signature helpers for SpacetimeDB TypeScript modules.", | ||
| "version": "0.1.0", | ||
| "license": "BUSL-1.1", |
There was a problem hiding this comment.
Is BUSL-1.1 license intentional?
| : [] | ||
| ); | ||
|
|
||
| export const start_reactor = spacetimedb.procedure( |
There was a problem hiding this comment.
These should be lowerCamelCase
| export const start_reactor = spacetimedb.procedure( | |
| export const startReactor = spacetimedb.procedure( |
| } | ||
| ); | ||
|
|
||
| export const tap_reactor = spacetimedb.procedure( |
There was a problem hiding this comment.
These should be lowerCamelCase
| export const tap_reactor = spacetimedb.procedure( | |
| export const tapReactor = spacetimedb.procedure( |
| } | ||
| ); | ||
|
|
||
| export const buy_upgrade = spacetimedb.procedure( |
There was a problem hiding this comment.
| export const buy_upgrade = spacetimedb.procedure( | |
| export const buyUpgrade = spacetimedb.procedure( |
| } | ||
| ); | ||
|
|
||
| export const repair_reactor = spacetimedb.procedure( |
There was a problem hiding this comment.
| export const repair_reactor = spacetimedb.procedure( | |
| export const repairReactor = spacetimedb.procedure( |
| return isAdmin(ctx) ? takeRows(retryCtx.db.retryTask.iter()) : []; | ||
| } | ||
|
|
||
| function retryHistoryAdmin(ctx: unknown): RetryHistoryRow[] { |
There was a problem hiding this comment.
retryHistory is never pruned, and with takeRows(iter(), 1000) after 1000 attempts the admin view stops showing anything recent
| npm install @spacetimedb/retry spacetimedb@^2.8.3 | ||
| ``` | ||
|
|
||
| Requires SpacetimeDB 2.8.3 or later for submodule mounting. |
There was a problem hiding this comment.
Seems incorrect since nothing here mounts (no export default schema etc)
|
|
||
| ## Requirements | ||
|
|
||
| - SpacetimeDB CLI 2.8.3 |
There was a problem hiding this comment.
Is it expected to pin the requirement to 2.8.3? e.g. the peer dependency is workspace:^
| @@ -0,0 +1,340 @@ | |||
| // Verify the pure-TS implementations against published test vectors. | |||
There was a problem hiding this comment.
Worth adding here that hashing is @noble/hashes, not an implementation in this package
| ranAt: retryCtx.timestamp, | ||
| }); | ||
|
|
||
| const result = dispatchRetry( |
There was a problem hiding this comment.
Seems if a handler throws instead of returning retryFailed, the whole reducer aborts. Worth adding try/catch here
Description of Changes
Adds reusable scheduling, retry, rate-limit, and cryptographic helpers for SpacetimeDB TypeScript modules.
This is the prerequisite branch for the remaining submodule groups. It is based on master commit
3653d2ed4.Example screenshots
Existing example screenshots from #5823:
Cron
Rate Limit
API and ABI breaking changes
No existing SpacetimeDB API or ABI is changed. This adds new TypeScript package APIs that need review before merge.
Rollback safety impact
n/a. This adds opt-in TypeScript packages and examples; it does not change existing server storage formats.
Expected complexity level and risk
3/5
The packages are opt-in and do not change existing server behavior. Complexity is in scheduling, retry recovery, and cron's direct use of the internal
spacetime:sys@2.0host ABI. Review failure recovery and repeated execution for applications that use these packages.Testing
Verified locally on
bradley/submodules-core:Commands used for this group:
The TypeScript SDK was built first. Live deployment and provider tests were not run during split validation. Existing workspace peer-dependency warnings remain.