{"id":20600984,"url":"https://github.com/momsfriendlydevco/supabase-reactive","last_synced_at":"2025-04-15T01:37:44.846Z","repository":{"id":207272043,"uuid":"718849195","full_name":"MomsFriendlyDevCo/supabase-reactive","owner":"MomsFriendlyDevCo","description":"Supabase plugin for reactive read/write against local objects","archived":false,"fork":false,"pushed_at":"2024-11-10T23:17:41.000Z","size":382,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T03:56:39.744Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MomsFriendlyDevCo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-14T23:10:21.000Z","updated_at":"2024-11-10T23:17:44.000Z","dependencies_parsed_at":"2023-11-15T00:26:44.841Z","dependency_job_id":"1a3dd097-334d-4fd3-802d-e75eb1ddbd12","html_url":"https://github.com/MomsFriendlyDevCo/supabase-reactive","commit_stats":null,"previous_names":["momsfriendlydevco/supabase-reactive"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fsupabase-reactive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fsupabase-reactive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fsupabase-reactive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fsupabase-reactive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MomsFriendlyDevCo","download_url":"https://codeload.github.com/MomsFriendlyDevCo/supabase-reactive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248990470,"owners_count":21194761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T09:07:55.009Z","updated_at":"2025-04-15T01:37:44.830Z","avatar_url":"https://github.com/MomsFriendlyDevCo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"@MomsFriendlyDevCo/Supabase-Reactive\n====================================\nSupabase plugin for reactive read/write against local objects.\n\nExtends the existing [Supabase](https://supabase.com) JavaScript functionality by adding a bi-directional, bound object which syncs with the server when its state changes. Changes on the server (or from another client) similarly update local state across all clients.\n\n```javascript\nimport Reactive from '@momsfriendlydevco/supabase-reactive';\nimport {createClient} from '@supabase/supabase-js'\n\n// Create a Supabase client\nlet supabase = creatClient('https://MY-SUPABASE-DOMAIN.supabase.co', 'big-long-key');\n\n// Create a reactive\nlet state = Reactive('my-table/id-to-sync', {supabase});\n\n// Changes to state are now synced bi-directionally\nstate.foo = 1;\nstate.bar = [1, 2, 3];\nstate.baz = {key1: {subkey1: [4, 5, 6]}};\ndelete state.bar;\n```\n\n\nAPI\n===\n\nSupabase Table Structure\n------------------------\nIdeally the data structure within Supabase should be made up of these columns:\n\n* `id` - a UUID is recommended\n* `created_at` - optional timestamp to indicate when the row was created\n* `edited_at` - timestamp to track changes\n* `version` - optional numeric to indicate the version offset of the row\n* `data` - the main JSONB data entity storage\n\nAn example Postgres data command is:\n\n```sql\ncreate table\n  public.test (\n    id uuid not null default gen_random_uuid (),\n    created_at timestamp with time zone not null default now(),\n    edited_at timestamp with time zone null,\n    data jsonb null,\n    version bigint null,\n    constraint test_pkey primary key (id),\n    constraint test_id_key unique (id)\n  ) tablespace pg_default;\n```\n\n\nSupabaseReactive(path, options)\n------------------------------\nThe main exported function which returns a Reactive object.\n\nThe resulting reactive object also has a series of non-enumerable utility functions which all start with a single dollar sign. See below for their purpose and documentation.\n\nThis can take an optional shorthand path and/or an options structure.\n\nValid options are:\n\n| Option            | Type                   | Default       | Description                                                                                                                                     |\n|-------------------|------------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| `supbase`         | `Supabase`             |               | Supabase instance to use                                                                                                                        |\n| `table`           | `String`               |               | Supabase table to store data within if `path` is not specified                                                                                  |\n| `id`              | `String`               |               | ID of the table row to sync data with                                                                                                           |\n| `isArray`         | `Boolean`              | `false`       | Specifies if the data entity is an Array rather than an object                                                                                  |\n| `read=true`       | `Boolean`              | `true`        | Allow reading from the remote Supabase server, disabling this makes the data transfer transmit only                                             |\n| `watch=true`      | `Boolean`              | `true`        | Allow watching for local changes and write them to the remote server if enabled                                                                 |\n| `write=true`      | `Boolean`              | `true`        | Allow writing back local changes to the Supabase server                                                                                         |\n| `attachReactives` | `Boolean`              | `true`        | Expose all utility functions as '$' prefixed functions to control the local state                                                               |\n| `throttle`        | `Object`               |               | Lodash debounce options + `wait` key used to throttle all writes, set to falsy to disable                                                       |\n| `idColumn='id'`   | `String`               | `'id'`        | Row ID column to sync with                                                                                                                      |\n| `filter`          | `Object`               |               | Query filter to use when accessing multiple rows                                                                                                |\n| `dataColumn`      | `String`               | `'data'`      | Data / JSONB column to sync data with                                                                                                           |\n| `timestampColumn` | `String`               | `'edited_at'` | Timezone+TZ column to use when syncing data                                                                                                     |\n| `versionColumn`   | `String`               |               | Optional version column, this increments on each write and is only really useful for debugging purposes                                         |\n| `reactiveCreate`  | `Function`             |               | Async function used to create an observable / reactive data entity from its input. Defaults to Vue's reactive function                          |\n| `reactiveWatch`   | `Function`             |               | Async function used to create a watch on the created reactive. Defaults to Vue's watch function                                                 |\n| `onInit`          | `Function`             |               | Async function when first populating data from the remote. Called as `(data)`                                                                   |\n| `onRead`          | `Function`             |               | Async function called on subsequent reads when populating data from the remote. Called as `(data)`                                              |\n| `onChange`        | `Function`             |               | Async function called when a detected local write is about to be sent to the remote. Called as `(dataPayload)`                                  |\n| `onDestroy`       | `Function`             |               | Async function called when destroying state. Called as `(data:Reactive)`                                                                        |\n| `debug`           | `Function` / `Boolean` |               | Optional debugging function callback. Called as `(...msg:Any)`                                                                                  |\n| `splitPath`       | `Function`             |               | Path parser, expected to decorate the `settings` object. Called as `(path: String, settings: Object)` and expected to mutate the settings state |\n\n\ndefaults\n--------\nStorage object for all defaults used by `SupabaseReactive`.\n\n\nReactive.$meta\n--------------\nMeta information about the current row.\nThis only really exists because we can't assign scalars in Javascript without it resetting the pointer later.\n\nThis object is made up of:\n\n| Key         | Type              | Description                                                                                                   |\n|-------------|-------------------|---------------------------------------------------------------------------------------------------------------|\n| `id`        | `String`          | The ID of the current row                                                                                     |\n| `table`     | `String`          | The active table for the current row                                                                          |\n| `timestamp` | `Null` / `Date`   | The last known timestamp of data from the server (or NULL if no data has been pulled yet)                     |\n| `If`        | `Null` / `Number` | a versioning column is enabled this represents the last known version of the data, similar to $meta.timestamp |\n| `Whether`   | `Boolean`         | the state is being updated locally - indicates that local watchers should ignore incoming change detection    |\n\n\nReactive.$set(state, options)\n-----------------------------\nSets the content of the current reactive.\n\nValid options are:\n\n| Option         | Type      | Default | Description                                                                        |\n|----------------|-----------|---------|------------------------------------------------------------------------------------|\n| `markUpdating` | `Boolean` | `true`  | Mark the object as within an update to prevent recursion + disable local observers |\n| `removeKeys`   | `Boolean` | `true`  | Clean out dead reactive keys if the new state doesn't also contain them            |\n| `timestamp`    | `Date`    |         | Set the reactive timestamp if provided                                             |\n| `version`      | `Number`  |         | Set the reactive version if provided                                               |\n\n\nReactive.$toObject()\n--------------------\nTidy JSON field data so that is safe from private methods (anything starting with '$' or '_', proxies or other non POJO slush.\nReturns a POJO.\n\n\nReactive.$refresh()\n-------------------\nAlias of `Reactive.$read()`.\n\n\nReactive.$getQuery()\n--------------------\nGenerate a Supabase object representing a query for the current configuration.\nReturns a Supabase promise which resolves when the operation has completed\n\n\nReactive.$init()\n----------------\nInitial operaton to wait on data from service + return reactable\nThis function is the default response when calling the outer `SupabaseReactive()` function.\n\n\nReactive.$read()\n----------------\nFetch the current data state from the server and update the reactive.\nReturns a promise.\n\n\nReactive.$fetch()\n-----------------\nFetch the current data state from the server but don't update the local state.\nThis function is only really useful for snapshotting server state.\nReturns a promise which resolves with the snapshot data.\n\n\nReactive.$watch(isWatching=true)\n--------------------------------\nWatch local data for changes and push to the server as needed.\nReturns a promise.\n\n\nReactive.$flush()\n-----------------\nWait for all local writes to complete.\nNOTE: This only promises that local writes complete, not that a subsequent read is required.\nReturns a promise.\n\n\nReactive.$subscribe(isSubscribed=true)\n--------------------------------------\nToggle subscription to the realtime datafeed.\nReturns a promise.\n\n\nReactive.$destroy()\n-------------------\nRelease all watchers and subscriptions, local and remote.\nReturns a promise.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fsupabase-reactive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmomsfriendlydevco%2Fsupabase-reactive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fsupabase-reactive/lists"}