Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bothrs/util

Package Overview
Dependencies
Maintainers
5
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bothrs/util - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2-1

dist/airtable-env.js

35

airtable-env.ts

@@ -9,5 +9,7 @@ import {

remove as removePure,
Environment,
FieldSet,
Environment,
Packed,
SelectOptions,
Unpacked,
} from './airtable'

@@ -22,40 +24,43 @@ export { byIds, pack, serialize, unpack, where } from './airtable'

export async function create(
export async function create<T extends FieldSet>(
tableName: string,
fields: FieldSet
): Promise<FieldSet> {
fields: T
): Promise<Unpacked<T>> {
return createPure(env, tableName, fields)
}
export async function find(tableName: string, id: string): Promise<FieldSet> {
export async function find<T extends FieldSet>(
tableName: string,
id: string
): Promise<Unpacked<T>> {
return findPure(env, tableName, id)
}
export async function first(
export async function first<T extends FieldSet>(
tableName: string,
filter: SelectOptions = {}
): Promise<FieldSet | null> {
): Promise<T | null> {
return firstPure(env, tableName, filter)
}
export async function select(
export async function select<T extends FieldSet>(
tableName: string,
filter: SelectOptions = {}
): Promise<FieldSet[]> {
): Promise<T[]> {
return selectPure(env, tableName, filter)
}
export async function selectAll(
export async function selectAll<T extends FieldSet>(
tableName: string,
filter: SelectOptions = {},
prepend: FieldSet[] = []
): Promise<FieldSet[]> {
prepend: Packed<T>[] = []
): Promise<T[]> {
return selectAllPure(env, tableName, filter, prepend)
}
export async function update(
export async function update<T extends FieldSet>(
tableName: string,
id: string,
fields: FieldSet
): Promise<FieldSet> {
fields: T
): Promise<Unpacked<T>> {
return updatePure(env, tableName, id, fields)

@@ -62,0 +67,0 @@ }

@@ -21,7 +21,7 @@ import { serialize } from './url'

export async function create(
export async function create<T extends FieldSet>(
env: Environment,
tableName: string,
fields: FieldSet
): Promise<FieldSet> {
fields: T
): Promise<Unpacked<T>> {
env.log && env.log('create', tableName, fields)

@@ -39,7 +39,7 @@ const body = await fetch(app(env.app) + tableName, {

export async function find(
export async function find<T extends FieldSet>(
env: Environment,
tableName: string,
id: string
): Promise<FieldSet> {
): Promise<Unpacked<T>> {
env.log && env.log('find', tableName, id)

@@ -55,17 +55,17 @@ const body = await fetch(app(env.app) + tableName + '/' + id, {

export async function first(
export async function first<T extends FieldSet>(
env: Environment,
tableName: string,
filter: SelectOptions = {}
): Promise<FieldSet | null> {
): Promise<Unpacked<T> | null> {
env.log && env.log('first', tableName, filter)
const items = await select(env, tableName, filter)
const items = await select<T>(env, tableName, filter)
return items.length ? items[0] : null
}
export async function select(
export async function select<T extends FieldSet>(
env: Environment,
tableName: string,
filter: SelectOptions = {}
): Promise<FieldSet[]> {
): Promise<Unpacked<T>[]> {
env.log && env.log('select', tableName, filter)

@@ -86,8 +86,8 @@ const body = await fetch(app(env.app) + tableName + '?' + serialize(filter), {

export async function selectAll(
export async function selectAll<T extends FieldSet>(
env: Environment,
tableName: string,
filter: SelectOptions = {},
prepend: FieldSet[] = []
): Promise<FieldSet[]> {
prepend: Packed<T>[] = []
): Promise<Unpacked<T>[]> {
env.log && env.log('selectAll', tableName, filter, prepend.length)

@@ -102,3 +102,3 @@ const body = await fetch(app(env.app) + tableName + '?' + serialize(filter), {

if (offset) {
return selectAll(
return selectAll<T>(
env,

@@ -117,8 +117,8 @@ tableName,

export async function update(
export async function update<T extends FieldSet>(
env: Environment,
tableName: string,
id: string,
fields: FieldSet
): Promise<FieldSet> {
fields: T
): Promise<Unpacked<T>> {
env.log && env.log('update', tableName, fields)

@@ -136,7 +136,7 @@ const body = await fetch(app(env.app) + tableName + '/' + id, {

export async function remove(
export async function remove<T extends FieldSet>(
env: Environment,
tableName: string,
id: string
): Promise<FieldSet> {
): Promise<Unpacked<T>> {
env.log && env.log('remove', tableName, id)

@@ -155,3 +155,5 @@ const body = await fetch(app(env.app) + tableName + '/' + id, {

export function pack(fields: FieldSet) {
export function pack<T extends FieldSet & { _id: string }>(
fields: Unpacked<T>
): Packed<FieldSet> {
return {

@@ -164,3 +166,7 @@ id: fields._id,

export function unpack({ id: _id, fields, createdTime }: FieldSet) {
export function unpack<T extends FieldSet>({
id: _id,
fields,
createdTime,
}: Packed<T>): Unpacked<T> {
return {

@@ -204,5 +210,14 @@ _id,

export interface Packed<T extends FieldSet> {
id: string
fields: T
createdTime: string
}
export type Unpacked<T extends FieldSet> = T & {
_id: string
}
export interface FieldSet {
_id?: string
[key: string]: any
}
{
"name": "@bothrs/util",
"version": "2.0.1",
"version": "2.0.2-1",
"description": "Common helper functions",

@@ -13,3 +13,5 @@ "license": "MIT",

"prepare": "yarn fix",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"preversion": "yarn fix",
"postversion": "echo $npm_package_version && sleep 3 && git push --tags && yarn publish . --tag $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
},

@@ -16,0 +18,0 @@ "dependencies": {},

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc