Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
restructured types with new jsTypes from easybasejs
Browse files Browse the repository at this point in the history
  • Loading branch information
dilan-dio4 committed May 29, 2021
1 parent 7d14552 commit aed6acc
Show file tree
Hide file tree
Showing 9 changed files with 13,996 additions and 14,061 deletions.
27,852 changes: 13,822 additions & 14,030 deletions example/package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/EasybaseContext.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { createContext } from "react";
import {
ContextValue,
UseReturnValue
} from "./types/types";
import {
ConfigureFrameOptions,
StatusResponse,
AddRecordOptions,
UpdateRecordAttachmentOptions,
FrameConfiguration,
QueryOptions,
ContextValue,
UseReturnValue,
EmailTemplate
} from "./types";
} from "./types/jsTypes";
import { SQW } from "EasyQB/types/sq";
import { NewExpression } from "EasyQB/types/expression";

Expand Down
12 changes: 7 additions & 5 deletions src/EasybaseProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React, { useState, useEffect, Fragment, useRef } from "react";
import EasybaseContext from "./EasybaseContext";
import deepEqual from "fast-deep-equal";
import {
EasybaseProviderProps,
ContextValue,
UseReturnValue
} from "./types/types";
import {
POST_TYPES,
FrameConfiguration,
Expand All @@ -10,12 +15,9 @@ import {
StatusResponse,
ConfigureFrameOptions,
DeleteRecordOptions,
EasybaseProviderProps,
ContextValue,
DB_STATUS,
EXECUTE_COUNT,
UseReturnValue
} from "./types";
EXECUTE_COUNT
} from "./types/jsTypes"
import imageExtensions from "./assets/image-extensions.json";
import videoExtensions from "./assets/video-extensions.json";
import utilsFactory from "../node_modules/easybasejs/src/EasybaseProvider/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/cache.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Globals } from "./types";
import { Globals } from "./types/jsTypes";
import Storage from 'react-native-storage';

let storage: Storage;
Expand Down
File renamed without changes.
159 changes: 159 additions & 0 deletions src/types/jsTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
export interface ConfigureFrameOptions {
/** Edit starting index from which records will be retrieved from. Useful for paging. */
offset?: number;
/** Limit the amount of records to be retrieved. Set to -1 or null to return all records. Can be used in combination with offset. */
limit?: number | null;
/** Table to sync frame with. (Projects only) */
tableName?: string;
}

export interface EasybaseProviderPropsOptions {
/** Custom authentication string. Can be set in integration menu. If it is set, it is required to access integration. This acts as an extra layer of security and extensibility. */
authentication?: string;
/** Log Easybase react status and events to console. */
logging?: boolean;
}

export interface EasybaseProviderProps {
/** EasyBase ebconfig object. Can be downloaded in the integration drawer next to 'React Token'. This is automatically generated. */
ebconfig: Ebconfig;
/** Optional configuration parameters. */
options?: EasybaseProviderPropsOptions
}

export interface FrameConfiguration {
/** Edit starting index from which records will be retrieved from. Useful for paging. */
offset: number;
/** Limit the amount of records to be retrieved. Set to -1 or null to return all records. Can be used in combination with offset. */
limit: number | null;
/** Table to sync frame with. (Projects only) */
tableName?: string;
}

export interface Ebconfig {
tt?: string,
integration: string,
version: string
}

export interface AddRecordOptions {
/** If true, record will be inserted at the end of the collection rather than the front. Overwrites absoluteIndex. */
insertAtEnd?: boolean;
/** Values to post to EasyBase collection. Format is { column name: value } */
newRecord: Record<string, any>;
/** Table to post new record to. (Projects only) */
tableName?: string;
}

export interface DeleteRecordOptions {
record: Record<string, any>;
/** Table to delete record from. (Projects only) */
tableName?: string;
}

export interface QueryOptions {
/** Name of the query saved in Easybase's Visual Query Builder */
queryName: string;
/** If you would like to sort the order of your query by a column. Pass the name of that column here */
sortBy?: string;
/** By default, columnToSortBy will sort your query by ascending value (1, 2, 3...). To sort by descending set this to true */
descending?: boolean;
/** Edit starting index from which records will be retrieved from. Useful for paging. */
offset?: number;
/** Limit the amount of records to be retrieved. Can be used in combination with offset. */
limit?: number;
/** This object can be set to overwrite the query values as set in the integration menu. If your query is setup to find records where 'age' >= 0, passing in { age: 50 } will query where 'age' >= 50. Read more: https://easybase.io/about/2020/09/15/Customizing-query-values/ */
customQuery?: Record<string, any>;
/** Table to query. (Projects only) */
tableName?: string;
}

export interface FileFromURI {
/** Path on local device to the attachment. Usually received from react-native-image-picker or react-native-document-picker */
uri: string,
/** Name of the file with proper extension */
name: string,
/** File MIME type */
type: string
}

export interface UpdateRecordAttachmentOptions {
/** EasyBase Record to attach this attachment to */
record: Record<string, any>;
/** The name of the column that is of type file/image/video */
columnName: string;
/** Either an HTML File element containing the correct type of attachment or a FileFromURI object for React Native instances.
* For React Native use libraries such as react-native-image-picker and react-native-document-picker.
* The file name must have a proper file extension corresponding to the attachment.
*/
attachment: File | FileFromURI;
/** Table to post attachment to. (Projects only) */
tableName?: string;
}

export interface StatusResponse {
/** Returns true if the operation was successful */
success: boolean;
/** Readable description of the the operation's status */
message: string;
/** Will represent a corresponding error if an error was thrown during the operation. */
errorCode?: string;
}

export interface EmailTemplate {
/** Optional header of email that will be sent to user with verification code */
greeting?: string;
/** Optional name of application for placement within email */
appName?: string;
/** Optional footer of verification email often used for disclaimers. Can be a valid HTML string */
footer?: string;
}

export enum POST_TYPES {
UPLOAD_ATTACHMENT = "upload_attachment",
HANDSHAKE = "handshake",
VALID_TOKEN = "valid_token",
GET_FRAME = "get_frame",
TABLE_SIZE = "table_size",
COLUMN_TYPES = "column_types",
SYNC_STACK = "sync_stack",
SYNC_DELETE = "sync_delete",
SYNC_INSERT = "sync_insert",
GET_QUERY = "get_query",
USER_ATTRIBUTES = "user_attributes",
SET_ATTRIBUTE = "set_attribute",
SIGN_UP = "sign_up",
REQUEST_TOKEN = "request_token",
EASY_QB = "easyqb",
RESET_PASSWORD = "reset_password",
FORGOT_PASSWORD_SEND = "forgot_password_send",
FORGOT_PASSWORD_CONFIRM = "forgot_password_confirm"
}

export enum DB_STATUS {
ERROR = "error",
PENDING = "pending",
SUCCESS = "success"
}

export enum EXECUTE_COUNT {
ALL = "all",
ONE = "one"
}

export interface AuthPostResponse {
success: boolean;
data: any;
}

export interface Globals {
ebconfig: Ebconfig;
token: string;
refreshToken: string;
integrationID: string;
session: number;
options: EasybaseProviderPropsOptions;
instance: string;
mounted: boolean;
newTokenCallback(): void;
}
File renamed without changes.
24 changes: 2 additions & 22 deletions src/types.tsx → src/types/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NewExpression } from "EasyQB/types/expression";
import {
EXECUTE_COUNT,
DB_STATUS
} from "../node_modules/easybasejs/src/EasybaseProvider/types"
} from "easybasejs/src/EasybaseProvider/types"

import type {
Ebconfig,
Expand All @@ -16,27 +16,7 @@ import type {
AddRecordOptions,
DeleteRecordOptions,
EmailTemplate
} from "../node_modules/easybasejs/src/EasybaseProvider/types"

export type {
FileFromURI,
Globals,
Ebconfig,
ConfigureFrameOptions,
StatusResponse,
UpdateRecordAttachmentOptions,
FrameConfiguration,
QueryOptions,
AddRecordOptions,
DeleteRecordOptions,
EmailTemplate
} from "../node_modules/easybasejs/src/EasybaseProvider/types"

export {
POST_TYPES,
EXECUTE_COUNT,
DB_STATUS
} from "../node_modules/easybasejs/src/EasybaseProvider/types"
} from "easybasejs/src/EasybaseProvider/types"

export interface EasybaseProviderPropsOptions {
/** Custom authentication string. Can be set in integration menu. If it is set, it is required to access integration. This acts as an extra layer of security and extensibility. */
Expand Down
File renamed without changes.

0 comments on commit aed6acc

Please sign in to comment.