Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/supabase

src/index.ts

94 lines · 2.9 KB · TypeScript
import { smokeTest } from './smoke-test.ts'
import { setupUrls } from './setup.ts'
import { optionalBoolean, optionalString, type SupabaseAuthInput } from './types.ts'

export { accounts } from './accounts.ts'
export { smokeTest } from './smoke-test.ts'
export { setupUrls } from './setup.ts'
export { listProjects } from './list-projects.ts'
export { getProject } from './get-project.ts'
export { listOrganizations } from './list-organizations.ts'
export { listUsers } from './list-users.ts'
export { getUser } from './get-user.ts'
export { createUser } from './create-user.ts'
export { updateUser } from './update-user.ts'
export { deleteUser } from './delete-user.ts'
export { selectRows } from './select-rows.ts'
export { insertRows } from './insert-rows.ts'
export { updateRows } from './update-rows.ts'
export { deleteRows } from './delete-rows.ts'
export { listBuckets } from './list-buckets.ts'
export { listObjects } from './list-objects.ts'
export { uploadObject } from './upload-object.ts'
export { deleteObject } from './delete-object.ts'
export { createSignedUrl } from './create-signed-url.ts'
export { request } from './request.ts'
export { managementRequest } from './management-request.ts'

const EXPORTS = [
	'.',
	'./accounts',
	'./smoke-test',
	'./setup',
	'./types',
	'./list-projects',
	'./get-project',
	'./list-organizations',
	'./list-users',
	'./get-user',
	'./create-user',
	'./update-user',
	'./delete-user',
	'./select-rows',
	'./insert-rows',
	'./update-rows',
	'./delete-rows',
	'./list-buckets',
	'./list-objects',
	'./upload-object',
	'./delete-object',
	'./create-signed-url',
	'./request',
	'./management-request',
] as const

/**
 * Describe the Supabase package, auth lanes, and export surface.
 * The default call also runs the safe smoke test (local dry-run, live reads
 * only when secrets already exist).
 * @example
 * import supabase from 'kody:@kody/supabase'
 * const overview = await supabase()
 */
export default async function supabaseOverview(
	input: SupabaseAuthInput & {
		setupOnly?: boolean
		dryRun?: boolean
	} & Record<string, unknown> = {},
) {
	const auth = {
		account: optionalString(input.account, 'account'),
		secretName: optionalString(input.secretName, 'secretName'),
		patSecretName: optionalString(input.patSecretName, 'patSecretName'),
		serviceRoleSecretName: optionalString(
			input.serviceRoleSecretName,
			'serviceRoleSecretName',
		),
		projectRef: optionalString(input.projectRef, 'projectRef'),
		projectUrl: optionalString(input.projectUrl, 'projectUrl'),
	}
	const smoke = await smokeTest({
		...auth,
		setupOnly: optionalBoolean(input.setupOnly, 'setupOnly'),
		dryRun: optionalBoolean(input.dryRun, 'dryRun'),
	})
	return {
		name: '@kody/supabase',
		publicUrl: 'https://kody.codes/@kody/supabase',
		intent:
			'Official helpers for your Supabase projects, Auth admin, PostgREST tables, Storage, and Management API.',
		setup: setupUrls(auth),
		exports: EXPORTS,
		smoke,
	}
}