Skip to content

Commit

Permalink
Feat: add meta directly in idk (#137)
Browse files Browse the repository at this point in the history
* Feat: add meta directly in idk

* Fix: icons
  • Loading branch information
harshithmullapudi authored Jul 13, 2023
1 parent 91f5d70 commit 39999bc
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 10 deletions.
2 changes: 1 addition & 1 deletion engine-idk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poozle/engine-idk",
"version": "0.1.13",
"version": "0.1.17",
"description": "Used to develop integrations for Poozle",
"license": "MIT",
"author": "Poozle <support@poozle.in>",
Expand Down
23 changes: 15 additions & 8 deletions engine-idk/src/bases/base_path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,29 @@ export class BasePath {
}

async baseRun(method: string, headers: AxiosHeaders, params: Params, config: Config) {
const responseFromRun = await this.run(method, headers, params, config);
const responseFromRun: any = await this.run(method, headers, params, config);

// if this is a request directly to the integration
if (params.proxy) {
return responseFromRun;
}

if (Array.isArray(responseFromRun)) {
const data = responseFromRun.map((responseItem: any) =>
if (responseFromRun.meta && Array.isArray(responseFromRun.data)) {
const data = responseFromRun.data.map((responseItem: any) =>
this.convertToModel(
responseItem,
params.queryParams?.raw === true || params.queryParams?.raw === 'true' ? true : false,
),
);

const meta = await this.getMetaParams(data, params);
const meta = await this.getMetaParams(responseFromRun, params);

return {
data,
meta,
};
}

return {
data: this.convertToModel(
responseFromRun,
Expand All @@ -71,13 +72,19 @@ export class BasePath {
}

// Written by the integration
async getMetaParams(_data: any, _params: Params): Promise<Meta> {
async getMetaParams(response: any, params: Params): Promise<Meta> {
const current_cursor =
typeof params.queryParams?.cursor === 'string' ? params.queryParams?.cursor : '';

const next_cursor = response.meta ? response.meta.next_cursor : '';
const before_cursor = response.meta ? response.meta.previous_cursor : '';

return {
limit: 0,
cursors: {
before: '0',
current: '0',
next: '0',
before: before_cursor,
current: current_cursor,
next: next_cursor,
},
};
}
Expand Down
36 changes: 35 additions & 1 deletion engine-idk/src/common_models/documentation/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,41 @@ export interface Content {
export interface Block {
id: string;
parent_id: string;
block_type: string;
block_type: BlockType;
content: Content[];
children: Block[];
}

export const enum BlockType {
bookmark,
breadcrumb,
bulleted_list_item,
callout,
child_database,
child_page,
column,
column_list,
divider,
embed,
equation,
file,
heading_1,
heading_2,
heading_3,
image,
link_preview,
link_to_page,
numbered_list_item,
paragraph,
pdf,
quote,
synced_block,
table,
table_of_contents,
table_row,
template,
to_do,
toggle,
unsupported,
video,
}
5 changes: 5 additions & 0 deletions engine-idk/src/common_models/documentation/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export const PageSchema = {
type: 'string',
default: '',
},
type: {
type: 'string',
default: '',
},
created_at: {
type: 'string',
default: '',
Expand All @@ -34,6 +38,7 @@ export interface Page {
id: string;
parent_id: string;
title: string;
type?: string;
created_by: string;
created_at: string;
updated_at: string;
Expand Down
File renamed without changes

0 comments on commit 39999bc

Please sign in to comment.