The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Remove libraries & separate supabase/supabase-js
Angelicoe05d579f3195
diff --git a/libraries/README.md b/libraries/README.mddeleted file mode 100644index 854d4844b39..00000000000--- a/libraries/README.md+++ /dev/null@@ -1,5 +0,0 @@-# Supabase Libraries--We are building client libraries to make it even easier to get started with Supabase.--If you we haven't yet built a library for the language of your choice, feel free to show your interest in for new client library in [issue on GitHub](https://github.com/supabase/supabase/issues/5).\ No newline at end of filediff --git a/libraries/supabase-js/.babelrc b/libraries/supabase-js/.babelrcdeleted file mode 100644index 0ae1c324775..00000000000--- a/libraries/supabase-js/.babelrc+++ /dev/null@@ -1,3 +0,0 @@-{- "presets": [["@babel/preset-env"], ["minify", { "removeUndefined": false }]]-}\ No newline at end of filediff --git a/libraries/supabase-js/.gitignore b/libraries/supabase-js/.gitignoredeleted file mode 100644index 02c78233224..00000000000--- a/libraries/supabase-js/.gitignore+++ /dev/null@@ -1,44 +0,0 @@-# Logs-logs-*.log-npm-debug.log*--# Runtime data-pids-*.pid-*.seed--# Directory for instrumented libs generated by jscoverage/JSCover-lib-cov--# Coverage directory used by tools like istanbul-coverage--# nyc test coverage-.nyc_output--# Compiled binary addons (http://nodejs.org/api/addons.html)-build/Release--# Dependency directories-node_modules-jspm_packages--# Optional npm cache directory-.npm--# Optional REPL history-.node_repl_history--# Editors-.idea--# Lib-lib--# npm package lock-package-lock.json-yarn.lock--others-.DS_Store\ No newline at end of filediff --git a/libraries/supabase-js/.npmignore b/libraries/supabase-js/.npmignoredeleted file mode 100644index 45c2f4af977..00000000000--- a/libraries/supabase-js/.npmignore+++ /dev/null@@ -1,25 +0,0 @@-*.log-npm-debug.log*--# Coverage directory used by tools like istanbul-coverage-.nyc_output--# Dependency directories-node_modules--# npm package lock-package-lock.json-yarn.lock--# project files-src-test-examples-CHANGELOG.md-.travis.yml-.editorconfig-.eslintignore-.eslintrc-.babelrc-.gitignorediff --git a/libraries/supabase-js/README.md b/libraries/supabase-js/README.mddeleted file mode 100644index 675a04dcdde..00000000000--- a/libraries/supabase-js/README.md+++ /dev/null@@ -1,23 +0,0 @@-# Supabase JS--## Commands-- `npm run clean` - Remove `lib/` directory-- `npm test` - Run tests with linting and coverage results.-- `npm run test:integration` - Run the integration tests (requires docker to be running)-- `npm test:only` - Run tests without linting or coverage.-- `npm test:watch` - You can even re-run tests on file changes!-- `npm test:prod` - Run tests with minified code.-- `npm run test:examples` - Test written examples on pure JS for better understanding module usage.-- `npm run lint` - Run ESlint with airbnb-config-- `npm run cover` - Get coverage report for your code.-- `npm run build` - Babel will transpile ES6 => ES5 and minify the code.-- `npm run prepublish` - Hook for npm. Do all the checks before publishing your module.---## Publishing--Bump the semver.--```sh-npm publish --access=public-```diff --git a/libraries/supabase-js/package.json b/libraries/supabase-js/package.jsondeleted file mode 100644index 042160d2de4..00000000000--- a/libraries/supabase-js/package.json+++ /dev/null@@ -1,57 +0,0 @@-{- "name": "@supabase/supabase-js",- "version": "0.1.33",- "description": "Supabase Realtime API",- "main": "./lib/index.js",- "scripts": {- "clean": "rimraf lib",- "test": "mocha -r @babel/register -r babel-polyfill test/unit/**/*.js",- "test:integration:only": "mocha --require babel-core/register --require babel-polyfill test/integration/**/*.js",- "test:integration": "docker-compose -f ./test/integration/docker-compose.yml up -d && sleep 10 && mocha -r @babel/register -r babel-polyfill test/integration/**/*.js ; docker-compose -f ./test/integration/docker-compose.yml down",- "test:prod": "cross-env BABEL_ENV=production npm run test",- "test:watch": "npm test -- --watch",- "test:examples": "node examples/",- "cover": "nyc --check-coverage && npm test",- "build": "BABEL_ENV=production babel src --out-dir lib",- "prepublish": "npm run clean && npm run build",- "deploy": "npm version patch && npm publish --access=public"- },- "files": [- "lib",- "src"- ],- "repository": "https://github.com/supabase/supabase",- "keywords": [- "supabase",- "realtime",- "postgrest",- "javascript"- ],- "author": "Supabase",- "license": "MIT",- "bugs": {- "url": "https://github.com/supabase/supabase/issues"- },- "homepage": "https://supabase.io",- "devDependencies": {- "@babel/cli": "^7.8.3",- "@babel/core": "^7.8.3",- "@babel/preset-env": "^7.8.3",- "@babel/register": "^7.8.3",- "babel-plugin-add-module-exports": "^1.0.0",- "babel-polyfill": "^6.26.0",- "babel-preset-minify": "^0.5.1",- "chai": "^4.1.2",- "cross-env": "^7.0.2",- "jest-websocket-mock": "^2.0.1",- "mocha": "^7.1.0",- "nyc": "^15.0.0",- "rimraf": "^3.0.2"- },- "dependencies": {- "@supabase/doctest-js": "^0.1.0",- "@supabase/postgrest-js": "^0.16.0",- "@supabase/realtime-js": "^0.1.8",- "superagent": "^5.2.1"- }-}diff --git a/libraries/supabase-js/src/Realtime.js b/libraries/supabase-js/src/Realtime.jsdeleted file mode 100644index 045849a9fd5..00000000000--- a/libraries/supabase-js/src/Realtime.js+++ /dev/null@@ -1,155 +0,0 @@-import { Socket } from '@supabase/realtime-js'-import * as ChangeMapper from './utils/ChangeMapper'--class Realtime {- constructor(- tableName,- realtimeUrl,- schema,- apikey,- uuid,- eventType,- callbackFunction,- queryFilters- ) {- this.tableName = tableName- this.realtimeUrl = realtimeUrl- this.schema = schema- this.apikey = apikey- this.uuid = uuid-- this.socket = null- this.channel = null- this.listeners = {}-- this.queryFilters = queryFilters-- this.on(eventType, callbackFunction)- }-- /**- * REALTIME FUNCTIONALITY- */-- createListener() {- let socketUrl = `${this.realtimeUrl}`-- var filterString = ''- this.queryFilters.forEach((queryFilter) => {- switch (queryFilter.filter) {- case 'filter':- // temporary solution- // this is the only thing we are supporting at the moment- if (queryFilter.operator === 'eq') {- // right now, the string is replaced instead of being stacked- // the server does not support multiple eq. statements- // as such, we will only process the very last eq. statement provided- filterString = `:${queryFilter.columnName}=${queryFilter.operator}.${queryFilter.criteria}`- }- break- default:- break- }- })-- let channel =- this.tableName == '*'- ? 'realtime:*'- : `realtime:${this.schema}:${this.tableName}${filterString}`- this.socket = new Socket(socketUrl, { params: { apikey: this.apikey } })- this.channel = this.socket.channel(channel)-- this.socket.onOpen(() => {- console.debug(`${this.realtimeUrl}: REALTIME CONNECTED`)- })- this.socket.onClose(() => {- console.debug(`${this.realtimeUrl}: REALTIME DISCONNECTED`)- })- }-- on(eventType, callbackFunction) {- if (this.socket == null) this.createListener()-- this.channel.on(eventType, (payload) => {- let payloadEnriched = {- schema: payload.schema,- table: payload.table,- commit_timestamp: payload.commit_timestamp,- }- let newData = {}- let oldData = {}- let oldDataEnriched = {}-- switch (payload.type) {- case 'INSERT':- newData = ChangeMapper.convertChangeData(payload.columns, payload.record)- payloadEnriched.eventType = 'INSERT'- payloadEnriched.new = newData-- break-- case 'UPDATE':- oldData = ChangeMapper.convertChangeData(payload.columns, payload.old_record)- newData = ChangeMapper.convertChangeData(payload.columns, payload.record)-- Object.keys(oldData).forEach((key) => {- if (oldData[key] != null) oldDataEnriched[key] = oldData[key]- })-- payloadEnriched.eventType = 'UPDATE'- payloadEnriched.old = oldDataEnriched- payloadEnriched.new = newData-- break-- case 'DELETE':- oldData = ChangeMapper.convertChangeData(payload.columns, payload.old_record)-- Object.keys(oldData).forEach((key) => {- if (oldData[key] != null) oldDataEnriched[key] = oldData[key]- })-- payloadEnriched.eventType = 'DELETE'- payloadEnriched.old = oldDataEnriched-- break-- default:- break- }-- callbackFunction(payloadEnriched)- })-- this.listeners[eventType] = callbackFunction- return this- }-- subscribe() {- if (this.socket == null) this.createListener()-- this.socket.connect()-- if (this.channel.state !== 'joined') {- this.channel- .join()- .receive('ok', (resp) =>- console.debug(`${this.realtimeUrl}: Joined Realtime successfully `, resp)- )- .receive('error', (resp) => console.debug(`${this.realtimeUrl}: Unable to join `, resp))- .receive('timeout', () =>- console.debug(`${this.realtimeUrl}: Network timeout. Still waiting...`)- )- }-- return this- }-- unsubscribe() {- if (this.socket) this.socket.disconnect()-- return this- }-}--export default Realtimediff --git a/libraries/supabase-js/src/index.js b/libraries/supabase-js/src/index.jsdeleted file mode 100644index a953145de77..00000000000--- a/libraries/supabase-js/src/index.js+++ /dev/null@@ -1,227 +0,0 @@-import { uuid } from './utils/Helpers'-import Realtime from './Realtime'-import { PostgrestClient } from '@supabase/postgrest-js'--class SupabaseClient {- constructor(supabaseUrl, supabaseKey, options = {}) {- this.supabaseUrl = null- this.supabaseKey = null- this.restUrl = null- this.realtimeUrl = null- this.schema = 'public'- this.subscriptions = {}-- this.tableName = null- this.queryFilters = []-- if (options.schema) this.schema = options.schema-- this.authenticate(supabaseUrl, supabaseKey)- }-- /**- * General Functionalities- */-- authenticate(supabaseUrl, supabaseKey) {- this.supabaseUrl = supabaseUrl- this.supabaseKey = supabaseKey- this.restUrl = `${supabaseUrl}/rest/v1`- this.realtimeUrl = `${supabaseUrl}/realtime/v1`.replace('http', 'ws')- }-- clear() {- this.tableName = null- this.queryFilters = []- }-- from(tableName) {- this.tableName = tableName- return this- }-- /**- * Realtime Functionalities- */-- on(eventType, callbackFunction) {- let identifier = uuid()-- this.subscriptions[identifier] = new Realtime(- this.tableName,- this.realtimeUrl,- this.schema,- this.supabaseKey,- identifier,- eventType,- callbackFunction,- this.queryFilters- )-- this.clear()- return this.subscriptions[identifier]- }-- getSubscriptions() {- return Object.values(this.subscriptions)- }-- removeSubscription(mySubscription) {- mySubscription.unsubscribe()- delete this.subscriptions[mySubscription.uuid]- }-- /**- * REST Functionalities- */-- rpc(functionName, functionParameters = null) {- let rest = new PostgrestClient(this.restUrl, {- headers: { apikey: this.supabaseKey },- schema: this.schema,- })- return rest.rpc(functionName, functionParameters)- }-- initClient() {- let rest = new PostgrestClient(this.restUrl, {- headers: { apikey: this.supabaseKey },- schema: this.schema,- })- let api = rest.from(this.tableName)-- // go through queryFilters- this.queryFilters.forEach((queryFilter) => {- switch (queryFilter.filter) {- case 'filter':- api.filter(queryFilter.columnName, queryFilter.operator, queryFilter.criteria)- break-- case 'match':- api.match(queryFilter.query)- break-- case 'order':- api.order(queryFilter.property, queryFilter.ascending, queryFilter.nullsFirst)- break-- case 'range':- api.range(queryFilter.from, queryFilter.to)- break-- case 'single':- api.single()- break-- default:- break- }- })-- this.clear()- return api- }-- select(columnQuery = '*', options = {}) {- let api = this.initClient()- return api.select(columnQuery, options)- }-- insert(data, options = {}) {- let api = this.initClient()- return api.insert(data, options)- }-- update(data, options = {}) {- let api = this.initClient()- return api.update(data, options)- }-- delete(options = {}) {- let api = this.initClient()- return api.delete(options)- }-- filter(columnName, operator, criteria) {- this.queryFilters.push({- filter: 'filter',- columnName,- operator,- criteria,- })-- return this- }-- match(query) {- this.queryFilters.push({- filter: 'match',- query,- })-- return this- }-- order(property, ascending = false, nullsFirst = false) {- this.queryFilters.push({- filter: 'order',- property,- ascending,- nullsFirst,- })-- return this- }-- range(from, to) {- this.queryFilters.push({- filter: 'range',- from,- to,- })-- return this- }-- single() {- this.queryFilters.push({ filter: 'single' })-- return this- }-}--// pre-empts if any of the filters are used before select-const advancedFilters = [- 'eq',- 'neq',- 'gt',- 'lt',- 'gte',- 'lte',- 'like',- 'ilike',- 'is',- 'in',- 'cs',- 'cd',- 'ova',- 'ovr',- 'sl',- 'sr',- 'nxr',- 'nxl',- 'adj',-]--advancedFilters.forEach(- (operator) =>- (SupabaseClient.prototype[operator] = function filterValue(columnName, criteria) {- return this.filter(columnName, operator, criteria)- })-)--const createClient = (supabaseUrl, supabaseKey, options = {}) => {- return new SupabaseClient(supabaseUrl, supabaseKey, options)-}--export { createClient }diff --git a/libraries/supabase-js/src/utils/ChangeMapper.js b/libraries/supabase-js/src/utils/ChangeMapper.jsdeleted file mode 100644index 5dcac4be814..00000000000--- a/libraries/supabase-js/src/utils/ChangeMapper.js+++ /dev/null@@ -1,189 +0,0 @@-// # Lifted from epgsql (src/epgsql_binary.erl), this module licensed under-// # 3-clause BSD found here: https://raw.githubusercontent.com/epgsql/epgsql/devel/LICENSE--/**- * Takes an array of columns and an object of string values then converts each string value- * to its mapped type- * @param {{name: String, type: String}[]} columns- * @param {Object} records- * @param {Object} options The map of various options that can be applied to the mapper- * @param {Array} options.skipTypes The array of types that should not be converted- *- * @example convertChangeData([{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], {first_name: 'Paul', age:'33'}, {})- * //=>{ first_name: 'Paul', age: 33 }- */-export const convertChangeData = (columns, records, options = {}) => {- let result = {}- let skipTypes = typeof options.skipTypes !== 'undefined' ? options.skipTypes : []- Object.entries(records).map(([key, value]) => {- result[key] = convertColumn(key, columns, records, skipTypes)- })- return result-}--/**- * Converts the value of an individual column- * @param {String} columnName The column that you want to convert- * @param {{name: String, type: String}[]} columns All of the columns- * @param {Object} records The map of string values- * @param {Array} skipTypes An array of types that should not be converted- * @return {object} Useless information- *- * @example convertColumn('age', [{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], ['Paul', '33'], [])- * //=> 33- * @example convertColumn('age', [{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], ['Paul', '33'], ['int4'])- * //=> "33"- */-export const convertColumn = (columnName, columns, records, skipTypes) => {- let column = columns.find(x => x.name == columnName)- if(skipTypes.includes(column.type)) return noop(records[columnName])- else return convertCell(column.type, records[columnName])-}--/**- * If the value of the cell is `null`, returns null.- * Otherwise converts the string value to the correct type.- * @param {String} type A postgres column type- * @param {String} stringValue The cell value- *- * @example convertCell('bool', 'true')- * //=> true- * @example convertCell('int8', '10')- * //=> 10- * @example convertCell('_int4', '{1,2,3,4}')- * //=> [1,2,3,4]- */-export const convertCell = (type, stringValue) => {- try {- if (stringValue === null) return null-- // if data type is an array- if (type.charAt(0) === '_') {- let arrayValue = type.slice(1, type.length)- return toArray(stringValue, arrayValue)- }-- // If not null, convert to correct type.- switch (type) {- case 'abstime':- return noop(stringValue) // To allow users to cast it based on Timezone- case 'bool':- return toBoolean(stringValue)- case 'date':- return noop(stringValue) // To allow users to cast it based on Timezone- case 'daterange':- return toDateRange(stringValue)- case 'float4':- return toFloat(stringValue)- case 'float8':- return toFloat(stringValue)- case 'int2':- return toInt(stringValue)- case 'int4':- return toInt(stringValue)- case 'int4range':- return toIntRange(stringValue)- case 'int8':- return toInt(stringValue)- case 'int8range':- return toIntRange(stringValue)- case 'json':- return toJson(stringValue)- case 'jsonb':- return toJson(stringValue)- case 'money':- return toFloat(stringValue)- case 'numeric':- return toFloat(stringValue)- case 'oid':- return toInt(stringValue)- case 'reltime':- return noop(stringValue) // To allow users to cast it based on Timezone- case 'time':- return noop(stringValue) // To allow users to cast it based on Timezone- case 'timestamp':- return toTimestampString(stringValue) // Format to be consistent with PostgREST- case 'timestamptz':- return noop(stringValue) // To allow users to cast it based on Timezone- case 'timetz':- return noop(stringValue) // To allow users to cast it based on Timezone- case 'tsrange':- return toDateRange(stringValue)- case 'tstzrange':- return toDateRange(stringValue)- default:- // All the rest will be returned as strings- return noop(stringValue)- }- } catch (error) {- console.log(`Could not convert cell of type ${type} and value ${stringValue}`)- console.log(`This is the error: ${error}`)- return stringValue- }-}--export const noop = stringValue => {- return stringValue-}-export const toBoolean = stringValue => {- switch (stringValue) {- case 't':- return true- case 'f':- return false- default:- return null- }-}-export const toDate = stringValue => {- return new Date(stringValue)-}-export const toDateRange = stringValue => {- let arr = JSON.parse(stringValue)- return [new Date(arr[0]), new Date(arr[1])]-}-export const toFloat = stringValue => {- return parseFloat(stringValue)-}-export const toInt = stringValue => {- return parseInt(stringValue)-}-export const toIntRange = stringValue => {- let arr = JSON.parse(stringValue)- return [parseInt(arr[0]), parseInt(arr[1])]-}-export const toJson = stringValue => {- return JSON.parse(stringValue)-}--/**- * Converts a Postgres Array into a native JS array- * @example toArray('{1,2,3,4}', 'int4')- * //=> [1,2,3,4]- * @example toArray('{}', 'int4')- * //=> []- */-export const toArray = (stringValue, type) => {- // this takes off the '{' & '}'- let stringEnriched = stringValue.slice(1, stringValue.length - 1)-- // converts the string into an array- // if string is empty (meaning the array was empty), an empty array will be immediately returned- let stringArray = stringEnriched.length > 0 ? stringEnriched.split(',') : []- let array = stringArray.map(string => {- return convertCell(type, string)- })-- return array-}--/**- * Fixes timestamp to be ISO-8601. Swaps the space between the date and time for a 'T'- * See https://github.com/supabase/supabase/issues/18- * @returns {string}- * @example toTimestampString('2019-09-10 00:00:00')- * //=> '2019-09-10T00:00:00'- */-export const toTimestampString = stringValue => {- return stringValue.replace(' ', 'T')-}\ No newline at end of filediff --git a/libraries/supabase-js/src/utils/Helpers.js b/libraries/supabase-js/src/utils/Helpers.jsdeleted file mode 100644index 7bb4b969738..00000000000--- a/libraries/supabase-js/src/utils/Helpers.js+++ /dev/null@@ -1,8 +0,0 @@-export function uuid() {- function s4() {- return Math.floor((1 + Math.random()) * 0x10000)- .toString(16)- .substring(1)- }- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4()-}diff --git a/libraries/supabase-js/test/integration/db/00-schema.sql b/libraries/supabase-js/test/integration/db/00-schema.sqldeleted file mode 100644index 93a6cc52ced..00000000000--- a/libraries/supabase-js/test/integration/db/00-schema.sql+++ /dev/null@@ -1,66 +0,0 @@---- Create the Replication publication-CREATE PUBLICATION supabase_realtime FOR ALL TABLES;---- Create a second schema-CREATE SCHEMA personal;---- USERS-CREATE TYPE public.user_status AS ENUM ('ONLINE', 'OFFLINE');-CREATE TABLE public.users (- id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,- inserted_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL,- updated_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL,- data jsonb DEFAULT null,- username text,- status user_status DEFAULT 'ONLINE'::public.user_status-);-ALTER TABLE public.users REPLICA IDENTITY FULL; -- Send "previous data" to supabase-COMMENT ON COLUMN public.users.data IS 'For unstructured data and prototyping.';---- CHANNELS-CREATE TABLE public.channels (- id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,- inserted_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL,- updated_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL,- data jsonb DEFAULT null,- slug text-);-ALTER TABLE public.users REPLICA IDENTITY FULL; -- Send "previous data" to supabase-COMMENT ON COLUMN public.channels.data IS 'For unstructured data and prototyping.';---- MESSAGES-CREATE TABLE public.messages (- id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,- inserted_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL,- updated_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL,- data jsonb DEFAULT null,- message text,- user_id bigint REFERENCES users NOT NULL,- channel_id bigint REFERENCES channels NOT NULL-);-ALTER TABLE public.messages REPLICA IDENTITY FULL; -- Send "previous data" to supabase-COMMENT ON COLUMN public.messages.data IS 'For unstructured data and prototyping.';--CREATE FUNCTION public.show_schema()-RETURNS text AS $$- SELECT 'public';-$$ LANGUAGE SQL IMMUTABLE;---- SECOND SCHEMA USERS-CREATE TYPE personal.user_status AS ENUM ('ONLINE', 'OFFLINE');-CREATE TABLE personal.users (- id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,- inserted_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL,- updated_at timestamp without time zone DEFAULT timezone('utc'::text, now()) NOT NULL,- data jsonb DEFAULT null,- username text,- status user_status DEFAULT 'ONLINE'::user_status-);-ALTER TABLE personal.users REPLICA IDENTITY FULL; -- Send "previous data" to supabase-COMMENT ON COLUMN personal.users.data IS 'For unstructured data and prototyping.';--CREATE FUNCTION personal.show_schema()-RETURNS text AS $$- SELECT 'personal';-$$ LANGUAGE SQL IMMUTABLE;\ No newline at end of filediff --git a/libraries/supabase-js/test/integration/db/01-dummy-data.sql b/libraries/supabase-js/test/integration/db/01-dummy-data.sqldeleted file mode 100644index e616f4274b5..00000000000--- a/libraries/supabase-js/test/integration/db/01-dummy-data.sql+++ /dev/null@@ -1,28 +0,0 @@-INSERT INTO- public.users (username)-VALUES- ('supabot'),- ('kiwicopple'),- ('awalias'),- ('dragarcia');--INSERT INTO- public.channels (slug)-VALUES- ('public'),- ('random');--INSERT INTO- public.messages (message, channel_id, user_id)-VALUES- ('Hello World 👋', 1, 1),- ('Perfection is attained, not when there is nothing more to add, but when there is nothing left to take away.', 2, 1);--INSERT INTO- personal.users (username)-VALUES- ('supabot'),- ('kiwicopple'),- ('awalias'),- ('dragarcia'),- ('leroyjenkins');\ No newline at end of filediff --git a/libraries/supabase-js/test/integration/docker-compose.yml b/libraries/supabase-js/test/integration/docker-compose.ymldeleted file mode 100644index 6e85623b8a2..00000000000--- a/libraries/supabase-js/test/integration/docker-compose.yml+++ /dev/null@@ -1,31 +0,0 @@-version: '3'--services:- supabase:- image: supabase/supabase-dev:0.1.9- ports:- - "8000:8000"- environment:- DB_HOST: db- DB_NAME: postgres- DB_USER: postgres- DB_PASSWORD: postgres- DB_PORT: 5432- DB_SCHEMA: public, personal- depends_on:- - db- db:- image: postgres:12- ports:- - "6543:5432"- volumes:- - ./db:/docker-entrypoint-initdb.d/- command:- - "postgres"- - "-c"- - "wal_level=logical"- environment:- POSTGRES_DB: postgres- POSTGRES_USER: postgres- POSTGRES_PASSWORD: postgres- POSTGRES_PORT: 5432diff --git a/libraries/supabase-js/test/integration/testFilters.js b/libraries/supabase-js/test/integration/testFilters.jsdeleted file mode 100644index 1456e67630c..00000000000--- a/libraries/supabase-js/test/integration/testFilters.js+++ /dev/null@@ -1,81 +0,0 @@-import { assert } from 'chai'-import { createClient } from '../../src'--describe('test reading from the rest interface', () => {- const supabase = createClient('http://localhost:8000', 'examplekey')- const expectedQueryArray = [- 'name=eq.New Zealand',- 'id=gt.20',- 'id=lt.20',- 'id=gte.20',- 'id=lte.20',- 'name=like.*United*',- 'name=ilike.*United*',- 'name=is.null',- 'name=in.(China,France)',- 'name=neq.China',- 'countries=cs.{China,France}',- 'countries=cd.{China,France}',- 'allies=ov.{China,France}',- 'population_range=ov.(100,500)',- 'population_range=sl.(100,500)',- 'population_range=sr.(100,500)',- 'population_range=nxl.(100,500)',- 'population_range=nxr.(100,500)',- 'population_range=adj.(100,500)',- ]-- it('should be able to take in filters before an actual request is made', async () => {- const response = supabase- .from('countries')- .eq('name', 'New Zealand')- .gt('id', 20)- .lt('id', 20)- .gte('id', 20)- .lte('id', 20)- .like('name', '%United%')- .ilike('name', '%United%')- .is('name', null)- .in('name', ['China', 'France'])- .neq('name', 'China')- .cs('countries', ['China', 'France'])- .cd('countries', ['China', 'France'])- .ova('allies', ['China', 'France'])- .ovr('population_range', [100, 500])- .sl('population_range', [100, 500])- .sr('population_range', [100, 500])- .nxl('population_range', [100, 500])- .nxr('population_range', [100, 500])- .adj('population_range', [100, 500])- .select('*')-- assert.deepEqual(response._query, expectedQueryArray)- })-- it('should be able to take in filters after an actual request is made', async () => {- const response = supabase- .from('countries')- .select('*')- .eq('name', 'New Zealand')- .gt('id', 20)- .lt('id', 20)- .gte('id', 20)- .lte('id', 20)- .like('name', '%United%')- .ilike('name', '%United%')- .is('name', null)- .in('name', ['China', 'France'])- .neq('name', 'China')- .cs('countries', ['China', 'France'])- .cd('countries', ['China', 'France'])- .ova('allies', ['China', 'France'])- .ovr('population_range', [100, 500])- .sl('population_range', [100, 500])- .sr('population_range', [100, 500])- .nxl('population_range', [100, 500])- .nxr('population_range', [100, 500])- .adj('population_range', [100, 500])-- assert.deepEqual(response._query, expectedQueryArray)- })-})diff --git a/libraries/supabase-js/test/integration/testRealtime.js b/libraries/supabase-js/test/integration/testRealtime.jsdeleted file mode 100644index 109260c6535..00000000000--- a/libraries/supabase-js/test/integration/testRealtime.js+++ /dev/null@@ -1,152 +0,0 @@-import { assert } from 'chai'-import { createClient } from '../../src'--describe('test various subscriptions', function() {- const supabase = createClient('http://localhost:8000', 'examplekey')-- afterEach(function() {- const subscriptions = supabase.getSubscriptions()- for (const sub of subscriptions) {- supabase.removeSubscription(sub)- }- console.log('subscriptions removed')- })-- // test adding and removing a subscription- it('can add and remove a subscription', function() {- const subscription = supabase- .from('*')- .on('*', null)- .subscribe()-- assert(subscription.uuid === supabase.getSubscriptions()[0].uuid, "uuid's not equal")-- supabase.removeSubscription(subscription)-- assert(supabase.getSubscriptions().length === 0, 'subscriptions not empty')- })-- // test double wildcard, all events, all tables- it('from(*).on(*).subscribe()', function(done) {- const callbackAction = function(record) {- assert(record.new.message === 'hello, mocha', 'inserted message is incorrect')- done()- }- const subscription = supabase- .from('*')- .on('*', callbackAction)- .subscribe()-- subscription.channel.socket.conn.addEventListener('open', function(event) {- supabase- .from('messages')- .insert([{ message: 'hello, mocha', user_id: 1, channel_id: 1 }])- .then()- .catch(console.error)- })- }).timeout(10000)-- // test events on specific table- it('from("messages").on("*").subscribe()', function(done) {- const callbackAction = function(record) {- assert(record.new.message === 'hello, mocha fans', 'inserted message is incorrect')- done()- }- const subscription = supabase- .from('messages')- .on('*', callbackAction)- .subscribe()-- subscription.channel.socket.conn.addEventListener('open', function(event) {- supabase- .from('messages')- .insert([{ message: 'hello, mocha fans', user_id: 1, channel_id: 1 }])- .then()- .catch(console.error)- })- }).timeout(10000)-- // test update message- it('from(messages).on(UPDATE).subscribe()', function(done) {- const callbackAction = function(record) {- assert(- record.new.message === 'updated message yo',- 'updated message does not have correct text'- )- done()- }- const subscription = supabase- .from('messages')- .on('UPDATE', callbackAction)- .subscribe()-- subscription.channel.socket.conn.addEventListener('open', function(event) {- supabase- .from('messages')- .insert([{ message: 'update test', user_id: 1, channel_id: 1 }])- .then(function(response) {- supabase- .from('messages')- .filter('id', 'eq', response.body[0].id)- .update({ message: 'updated message yo' })- .then()- .catch(console.error)- })- .catch(console.error)- })- }).timeout(10000)-- // test delete message- it('from("messages").on("DELETE").subscribe()', function(done) {- const callbackAction = function(record) {- assert(record.old.message === 'delete test', 'deleted message does not have correct id')- done()- }- const subscription = supabase- .from('messages')- .on('DELETE', callbackAction)- .subscribe()-- subscription.channel.socket.conn.addEventListener('open', function(event) {- supabase- .from('messages')- .insert([{ message: 'delete test', user_id: 1, channel_id: 1 }])- .then(function(response) {- supabase- .from('messages')- .filter('id', 'eq', response.body[0].id)- .delete()- .then()- .catch(console.error)- })- .catch(console.error)- })- }).timeout(10000)-- // test on INSERT- it('from("*").on("INSERT").subscribe()', function(done) {- const callbackAction = function(record) {- assert(record.new.message === 'hello, mocha fans, Y2K', 'inserted message is incorrect')- done()- }- const subscription = supabase- .from('messages')- .on('INSERT', callbackAction)- .subscribe()-- subscription.channel.socket.conn.addEventListener('open', function(event) {- supabase- .from('messages')- .insert([{ message: 'hello, mocha fans, Y2K', user_id: 1, channel_id: 1 }])- .then()- .catch(console.error)- })- }).timeout(10000)-- after(function() {- setTimeout(function() {- console.log('ending process')- process.exit(0)- }, 5000)- })-})diff --git a/libraries/supabase-js/test/integration/testRest.js b/libraries/supabase-js/test/integration/testRest.jsdeleted file mode 100644index 8ef7e62ba0b..00000000000--- a/libraries/supabase-js/test/integration/testRest.js+++ /dev/null@@ -1,187 +0,0 @@-import { assert } from 'chai'-import { createClient } from '../../src'--describe('test reading from the rest interface', () => {- const supabase = createClient('http://localhost:8000', 'examplekey')-- it('from() and select()', async () => {- const response = await supabase- .from('users')- .select()- .order('id', false, false)- assert(response.body[3].status === 'ONLINE', 'should return 4 records with all columns')- })-- it('order()', async () => {- const response = await supabase- .from('users')- .select('*')- .order('id', false, false)- assert(response.body[0].id === 4, 'id should equal 4, since order is descending')- })-- it('range()', async () => {- const response = await supabase- .from('users')- .select('*')- .range(0, 3)- .order('id', false, false)- assert(response.body[3].id === 1, 'last item should be id 1')- assert(response.body[0].id === 4, 'first item should be id 4')- })-- it('single()', async () => {- const response = await supabase- .from('users')- .eq('id', '3')- .select('*')- .single()- assert(response.body.id === 3, 'single should return one result as an object not an array')- })-- it('filter()', async () => {- const response = await supabase- .from('users')- .filter('id', 'lte', 3)- .filter('username', 'in', ['awalias', 'supabot'])- .select('*')- assert(response.body.length === 2, 'should return two records, awalias, and supabot')- })-- if('not()', async () => {- const response = await supabase- .from('users')- .not('id', 'lte', 3)- .select('*')- assert(response.body.length === 1, 'should return one record')- assert(response.body[0].username === 'dragarcia')- })-- it('match()', async () => {- const response = await supabase- .from('users')- .match({ username: 'awalias' })- .select('*')- assert(response.body.length === 1, 'should return one record')- assert(response.body[0].username == 'awalias', 'should return one record, awalias')- })-- it('eq()', async () => {- const response = await supabase- .from('users')- .eq('username', 'supabot')- .select('id')- assert(response.body[0].id === 1, 'id should equal 1')- })-- it('lt()', async () => {- const response = await supabase- .from('users')- .lt('id', '3')- .select('*')- assert(response.body.length === 2, 'should be 2 members with id less than 3')- })-- it('lte()', async () => {- const response = await supabase- .from('users')- .lte('id', '3')- .select('*')- assert(response.body.length === 3, 'should be 3 members with id less than or equal to 3')- })-- it('gt()', async () => {- const response = await supabase- .from('users')- .gt('id', '3')- .select('*')- assert(response.body.length === 1, 'should be 1 members with id greater than 3')- })-- it('gte()', async () => {- const response = await supabase- .from('users')- .gte('id', '3')- .select('*')- assert(response.body.length === 2, 'should be 2 members with id equal to or greater than 3')- })-- it('like()', async () => {- const response = await supabase- .from('users')- .like('username', '%upAbo%')- .select('*')- assert(response.body.length === 0, 'should be 2 members with id equal to or greater than 3')- })-- it('ilike()', async () => {- const response = await supabase- .from('users')- .ilike('username', '%upabo%')- .select('*')- assert(response.body.length === 1, 'should be 2 members with id equal to or greater than 3')- })-- it('is()', async () => {- const response = await supabase- .from('users')- .is('data', null)- .select('*')- assert(response.body.length === 4, 'should be 4 members')- })-- it('in()', async () => {- const response = await supabase- .from('users')- .in('id', [2, 3])- .select('*')- assert(response.body[0].id === 2, 'first item should be id 2')- assert(response.body[1].id === 3, 'last (and second) item should be id 3')- })-- it('neq()', async () => {- const response = await supabase- .from('users')- .neq('id', '3')- .select('*')- assert(response.body.length === 3, 'should be all except id 3')- })-})--describe('test rpc()', () => {- const supabase = createClient('http://localhost:8000', 'examplekey')-- it('should return a value', async () => {- const response = await supabase.rpc('show_schema')- assert(response.body === 'public')- })-})--describe('test multi schema', () => {- const supabase = createClient('http://localhost:8000', 'examplekey', {schema: 'personal'})-- it('should return a value from the other schema', async () => {- const response = await supabase- .from('users')- .eq('username', 'leroyjenkins')- .select('*')-- assert(response.body.length === 1)- assert(response.body[0].username === 'leroyjenkins')- })-- it('should be able to update a value on the other schema', async () => {- const response = await supabase- .from('users')- .eq('username', 'leroyjenkins')- .update({username: 'jenkinsleroy'})-- assert(response.body.length === 1)- assert(response.body[0].username === 'jenkinsleroy')- })-- it('should return a value', async () => {- const response = await supabase.rpc('show_schema')- assert(response.body === 'personal')- })-})diff --git a/libraries/supabase-js/test/unit/index.js b/libraries/supabase-js/test/unit/index.jsdeleted file mode 100644index ab6e627c040..00000000000--- a/libraries/supabase-js/test/unit/index.js+++ /dev/null@@ -1,8 +0,0 @@-import doctest from '@supabase/doctest-js'-const { createClient } = require('../../src/index.js')--describe('Doctests', () => {- // file paths are relative to root of directory- doctest('src/utils/ChangeMapper.js')- doctest('src/index.js', { instance: new createClient('https://test.supabase.co', 'abc-def') })-})\ No newline at end of file