Utils
The sdk.utils object provides a wide range of utility functions that help you build dynamic, user-friendly, and responsive views inside GridStudio. These include formatting, file uploading, timers, role checks, notifications, and more.
Categories
Formatting
formatDate(date)– Returns a formatted date string.formatDateTime(date)– Returns a full date-time string.formatDateTimeLocal(date)– Returns locale-aware date-time string.currency.priceString(isoCode, price, options)– Formats a price with currency.
HTML/Serialization
slugify(string)– Converts a string into a URL-safe slug.serialize(obj)– Serializes an object into a string.deserialize(string)– Converts a serialized string back into an object.
Loading State
loading.show()– Blocks the view with a loading spinner.loading.remove()– Removes the loading overlay.
Uploads
uploadAsync(dropzone)– Uploads files from a dropzone and returns their URLs.uploadFileAsync(file)– Uploads a single file.getSignedFileUrl()– Retrieves a secure file URL.
QR Codes
generateQrCodeAsync({ data })– Returns a QR code image in base64 for given input.
Drawer
drawer.show({...})– Opens a drawer with specified custom function.drawer.hide()– Hides the currently opened drawer.drawer.close()– Closes the drawer fully.
Notifications
notify.success(message)– Shows a success toast.notify.failure(message)– Shows a failure/error toast.
Confirmation Dialog
confirmation({ title, text }, onConfirm, onCancel)– Opens a confirm dialog.
Refresh Tokens
setRefreshToken(key)– Triggers a refresh for a key.listenRefreshToken(key)– Listens reactively for changes to a refresh key.
Reactive and Timer Helpers
autorun(fn)– Tracks reactive data sources and reruns the function.nonreactive(fn)– Executes a function without reactivity.setTimeout(fn, ms)– Delays execution.clearTimeout(timer)– Clears a timeout.setInterval(fn, ms)– Repeats execution at intervals.clearInterval(timer)– Clears an interval.
Role Check Utilities
roles.userIsInRole(roles)– Checks if user is in given roles (sync).roles.userIsInRoleAsync(roles)– Checks roles (async).roles.userIsInParentRole(roles)– Checks for parent tenant role.roles.userIsInRootRole(roles)– Checks for root-level role.roles.userIsInParentRoleAsync(roles)– Async parent role check.roles.userIsInRootRoleAsync(roles)– Async root role check.
Logging
logger.info(...args)– Console info.logger.warn(...args)– Console warning.logger.error(...args)– Console error.logger.debug(...args)– Console debug.
Other
translate('i18n.key')– Translates a string using i18n keys.absoluteUrl(path)– Returns absolute URL for a path.absolutePathString(name)– Converts a relative path to full path string.random.id()– Generates a random ID string.
Example: Upload + Notify
const files = await sdk.utils.uploadAsync(dropzone)
if (files.length > 0) {
sdk.utils.notify.success('Files uploaded successfully!')
}