@xata.io/client
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -26,9 +26,11 @@ export interface XataRecord { | ||
declare type SortDirection = 'asc' | 'desc'; | ||
declare type Operator = '_gt' | '_lt' | '_gte' | '_lte' | '_exists' | '_notExists' | '_endsWith' | '_startsWith' | '_pattern' | '_isNot' | '_includes' | '_includesSubstring' | '_includesPattern' | '_includesAll'; | ||
declare type Operator = '$gt' | '$lt' | '$ge' | '$le' | '$exists' | '$notExists' | '$endsWith' | '$startsWith' | '$pattern' | '$isNot' | '$contains' | '$includes' | '$includesSubstring' | '$includesPattern' | '$includesAll'; | ||
declare type Constraint<T> = Partial<Record<Operator, T>>; | ||
declare type ComparableType = number | Date; | ||
export declare const gt: <T extends ComparableType>(value: T) => Partial<Record<Operator, T>>; | ||
export declare const ge: <T extends ComparableType>(value: T) => Partial<Record<Operator, T>>; | ||
export declare const gte: <T extends ComparableType>(value: T) => Partial<Record<Operator, T>>; | ||
export declare const lt: <T extends ComparableType>(value: T) => Partial<Record<Operator, T>>; | ||
export declare const lte: <T extends ComparableType>(value: T) => Partial<Record<Operator, T>>; | ||
export declare const le: <T extends ComparableType>(value: T) => Partial<Record<Operator, T>>; | ||
export declare const exists: (column: string) => Constraint<string>; | ||
@@ -40,2 +42,3 @@ export declare const notExists: (column: string) => Constraint<string>; | ||
export declare const isNot: <T>(value: T) => Partial<Record<Operator, T>>; | ||
export declare const contains: <T>(value: T) => Partial<Record<Operator, T>>; | ||
export declare const includes: (value: string) => Constraint<string>; | ||
@@ -114,4 +117,4 @@ export declare const includesSubstring: (value: string) => Constraint<string>; | ||
fetch?: unknown; | ||
url: string; | ||
token: string; | ||
databaseURL: string; | ||
apiKey: string; | ||
repositoryFactory?: RepositoryFactory; | ||
@@ -118,0 +121,0 @@ }; |
@@ -12,31 +12,37 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.XataError = exports.BaseClient = exports.RestRespositoryFactory = exports.RestRepository = exports.Repository = exports.Query = exports.includesAll = exports.includesPattern = exports.includesSubstring = exports.includes = exports.isNot = exports.pattern = exports.endsWith = exports.startsWith = exports.notExists = exports.exists = exports.lte = exports.lt = exports.gte = exports.gt = void 0; | ||
const gt = (value) => ({ _gt: value }); | ||
exports.XataError = exports.BaseClient = exports.RestRespositoryFactory = exports.RestRepository = exports.Repository = exports.Query = exports.includesAll = exports.includesPattern = exports.includesSubstring = exports.includes = exports.contains = exports.isNot = exports.pattern = exports.endsWith = exports.startsWith = exports.notExists = exports.exists = exports.le = exports.lte = exports.lt = exports.gte = exports.ge = exports.gt = void 0; | ||
const gt = (value) => ({ $gt: value }); | ||
exports.gt = gt; | ||
const gte = (value) => ({ _gte: value }); | ||
const ge = (value) => ({ $ge: value }); | ||
exports.ge = ge; | ||
const gte = (value) => ({ $ge: value }); | ||
exports.gte = gte; | ||
const lt = (value) => ({ _lt: value }); | ||
const lt = (value) => ({ $lt: value }); | ||
exports.lt = lt; | ||
const lte = (value) => ({ _lte: value }); | ||
const lte = (value) => ({ $le: value }); | ||
exports.lte = lte; | ||
const exists = (column) => ({ _exists: column }); | ||
const le = (value) => ({ $le: value }); | ||
exports.le = le; | ||
const exists = (column) => ({ $exists: column }); | ||
exports.exists = exists; | ||
const notExists = (column) => ({ _notExists: column }); | ||
const notExists = (column) => ({ $notExists: column }); | ||
exports.notExists = notExists; | ||
const startsWith = (value) => ({ _startsWith: value }); | ||
const startsWith = (value) => ({ $startsWith: value }); | ||
exports.startsWith = startsWith; | ||
const endsWith = (value) => ({ _endsWith: value }); | ||
const endsWith = (value) => ({ $endsWith: value }); | ||
exports.endsWith = endsWith; | ||
const pattern = (value) => ({ _pattern: value }); | ||
const pattern = (value) => ({ $pattern: value }); | ||
exports.pattern = pattern; | ||
const isNot = (value) => ({ _isNot: value }); | ||
const isNot = (value) => ({ $isNot: value }); | ||
exports.isNot = isNot; | ||
const contains = (value) => ({ $contains: value }); | ||
exports.contains = contains; | ||
// TODO: these can only be applied to columns of type "multiple" | ||
const includes = (value) => ({ _includes: value }); | ||
const includes = (value) => ({ $includes: value }); | ||
exports.includes = includes; | ||
const includesSubstring = (value) => ({ _includesSubstring: value }); | ||
const includesSubstring = (value) => ({ $includesSubstring: value }); | ||
exports.includesSubstring = includesSubstring; | ||
const includesPattern = (value) => ({ _includesPattern: value }); | ||
const includesPattern = (value) => ({ $includesPattern: value }); | ||
exports.includesPattern = includesPattern; | ||
const includesAll = (value) => ({ _includesAll: value }); | ||
const includesAll = (value) => ({ $includesAll: value }); | ||
exports.includesAll = includesAll; | ||
@@ -190,4 +196,4 @@ class Query { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { url: xatabaseURL } = this.client.options; | ||
const resp = yield this.fetch(`${xatabaseURL}${path}`, { | ||
const { databaseURL } = this.client.options; | ||
const resp = yield this.fetch(`${databaseURL}${path}`, { | ||
method, | ||
@@ -197,3 +203,3 @@ headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${this.client.options.token}` | ||
Authorization: `Bearer ${this.client.options.apiKey}` | ||
}, | ||
@@ -200,0 +206,0 @@ body: JSON.stringify(body) |
@@ -16,4 +16,4 @@ "use strict"; | ||
fetch, | ||
token: '1234', | ||
url: 'https://my-workspace-5df34do.staging.xatabase.co/db/xata:main' | ||
apiKey: '1234', | ||
databaseURL: 'https://my-workspace-5df34do.staging.xatabase.co/db/xata:main' | ||
}, {}); | ||
@@ -20,0 +20,0 @@ const users = new _1.RestRepository(client, 'users'); |
{ | ||
"name": "@xata.io/client", | ||
"version": "0.1.1", | ||
"description": "Xata.io SDK for TypesScript and JavaScript", | ||
"version": "0.1.2", | ||
"description": "Xata.io SDK for TypeScript and JavaScript", | ||
"main": "./dist/index.js", | ||
@@ -6,0 +6,0 @@ "types": "./dist/index.d.ts", |
@@ -7,4 +7,4 @@ import { BaseClient, RestRepository, XataError, XataRecord } from './'; | ||
fetch, | ||
token: '1234', | ||
url: 'https://my-workspace-5df34do.staging.xatabase.co/db/xata:main' | ||
apiKey: '1234', | ||
databaseURL: 'https://my-workspace-5df34do.staging.xatabase.co/db/xata:main' | ||
}, | ||
@@ -11,0 +11,0 @@ {} |
@@ -37,16 +37,17 @@ export interface XataRecord { | ||
type Operator = | ||
| '_gt' | ||
| '_lt' | ||
| '_gte' | ||
| '_lte' | ||
| '_exists' | ||
| '_notExists' | ||
| '_endsWith' | ||
| '_startsWith' | ||
| '_pattern' | ||
| '_isNot' | ||
| '_includes' | ||
| '_includesSubstring' | ||
| '_includesPattern' | ||
| '_includesAll'; | ||
| '$gt' | ||
| '$lt' | ||
| '$ge' | ||
| '$le' | ||
| '$exists' | ||
| '$notExists' | ||
| '$endsWith' | ||
| '$startsWith' | ||
| '$pattern' | ||
| '$isNot' | ||
| '$contains' | ||
| '$includes' | ||
| '$includesSubstring' | ||
| '$includesPattern' | ||
| '$includesAll'; | ||
@@ -59,18 +60,21 @@ // TODO: restrict constraints depending on type? | ||
export const gt = <T extends ComparableType>(value: T): Constraint<T> => ({ _gt: value }); | ||
export const gte = <T extends ComparableType>(value: T): Constraint<T> => ({ _gte: value }); | ||
export const lt = <T extends ComparableType>(value: T): Constraint<T> => ({ _lt: value }); | ||
export const lte = <T extends ComparableType>(value: T): Constraint<T> => ({ _lte: value }); | ||
export const exists = (column: string): Constraint<string> => ({ _exists: column }); | ||
export const notExists = (column: string): Constraint<string> => ({ _notExists: column }); | ||
export const startsWith = (value: string): Constraint<string> => ({ _startsWith: value }); | ||
export const endsWith = (value: string): Constraint<string> => ({ _endsWith: value }); | ||
export const pattern = (value: string): Constraint<string> => ({ _pattern: value }); | ||
export const isNot = <T>(value: T): Constraint<T> => ({ _isNot: value }); | ||
export const gt = <T extends ComparableType>(value: T): Constraint<T> => ({ $gt: value }); | ||
export const ge = <T extends ComparableType>(value: T): Constraint<T> => ({ $ge: value }); | ||
export const gte = <T extends ComparableType>(value: T): Constraint<T> => ({ $ge: value }); | ||
export const lt = <T extends ComparableType>(value: T): Constraint<T> => ({ $lt: value }); | ||
export const lte = <T extends ComparableType>(value: T): Constraint<T> => ({ $le: value }); | ||
export const le = <T extends ComparableType>(value: T): Constraint<T> => ({ $le: value }); | ||
export const exists = (column: string): Constraint<string> => ({ $exists: column }); | ||
export const notExists = (column: string): Constraint<string> => ({ $notExists: column }); | ||
export const startsWith = (value: string): Constraint<string> => ({ $startsWith: value }); | ||
export const endsWith = (value: string): Constraint<string> => ({ $endsWith: value }); | ||
export const pattern = (value: string): Constraint<string> => ({ $pattern: value }); | ||
export const isNot = <T>(value: T): Constraint<T> => ({ $isNot: value }); | ||
export const contains = <T>(value: T): Constraint<T> => ({ $contains: value }); | ||
// TODO: these can only be applied to columns of type "multiple" | ||
export const includes = (value: string): Constraint<string> => ({ _includes: value }); | ||
export const includesSubstring = (value: string): Constraint<string> => ({ _includesSubstring: value }); | ||
export const includesPattern = (value: string): Constraint<string> => ({ _includesPattern: value }); | ||
export const includesAll = (value: string): Constraint<string> => ({ _includesAll: value }); | ||
export const includes = (value: string): Constraint<string> => ({ $includes: value }); | ||
export const includesSubstring = (value: string): Constraint<string> => ({ $includesSubstring: value }); | ||
export const includesPattern = (value: string): Constraint<string> => ({ $includesPattern: value }); | ||
export const includesAll = (value: string): Constraint<string> => ({ $includesAll: value }); | ||
@@ -305,4 +309,4 @@ type FilterConstraints<T> = { | ||
async request(method: string, path: string, body?: unknown) { | ||
const { url: xatabaseURL } = this.client.options; | ||
const resp: Response = await this.fetch(`${xatabaseURL}${path}`, { | ||
const { databaseURL } = this.client.options; | ||
const resp: Response = await this.fetch(`${databaseURL}${path}`, { | ||
method, | ||
@@ -312,3 +316,3 @@ headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${this.client.options.token}` | ||
Authorization: `Bearer ${this.client.options.apiKey}` | ||
}, | ||
@@ -381,4 +385,4 @@ body: JSON.stringify(body) | ||
fetch?: unknown; | ||
url: string; | ||
token: string; | ||
databaseURL: string; | ||
apiKey: string; | ||
repositoryFactory?: RepositoryFactory; | ||
@@ -385,0 +389,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
47660
9
1242
0
2