@workerbase/sdk
Advanced tools
Comparing version 0.1.21 to 0.1.22
@@ -20,11 +20,11 @@ import { DatabasesSDK } from './resources/Databases'; | ||
declare const _default: { | ||
databases: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
roles: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
skills: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
users: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
locations: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
media: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
functions: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
events: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
databases: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
roles: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
skills: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
users: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
locations: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
media: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
functions: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
events: (workerbase: import(".").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
}; | ||
export default _default; |
import { DatabaseItem, ItemPayload, DatabaseItemPOST } from '../types/databaseItems'; | ||
import { BasicMethods, BasicMethodTypes } from '../utils/WorkerbaseRessource'; | ||
import { ListOptions } from '../types/pagination'; | ||
export interface DatabaseItemSDK extends Pick<BasicMethodTypes<{ | ||
@@ -10,7 +11,10 @@ GET: DatabaseItem; | ||
createMany: (items: DatabaseItemPOST[]) => Promise<DatabaseItem[]>; | ||
query: (payload: any) => Promise<{ | ||
graphql: (payload: any, options?: ListOptions) => Promise<{ | ||
success: boolean; | ||
}>; | ||
query: (payload: any, options?: ListOptions) => Promise<{ | ||
success: boolean; | ||
}>; | ||
} | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
export default _default; |
@@ -69,2 +69,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var gql_query_builder_1 = require("gql-query-builder"); | ||
var doRequest_1 = require("../utils/doRequest"); | ||
@@ -81,2 +82,61 @@ var WorkerbaseRessource_1 = __importStar(require("../utils/WorkerbaseRessource")); | ||
methods: { | ||
graphql: function (spec) { return function (payload, options) { | ||
if (options === void 0) { options = {}; } | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
var graphqlQuery, data; | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
graphqlQuery = gql_query_builder_1.query({ | ||
operation: 'databaseitems', | ||
fields: [ | ||
{ | ||
edges: [ | ||
'_id', | ||
'externalId', | ||
'payload', | ||
{ meta: ['createdAt', 'updatedAt'] }, | ||
], | ||
}, | ||
{ | ||
pageInfo: [ | ||
'page', | ||
'perpage', | ||
'sort', | ||
'order', | ||
'maxpage', | ||
'totalItems', | ||
], | ||
}, | ||
], | ||
variables: { | ||
page: options.page || 1, | ||
perpage: options.perpage || 100, | ||
sort: options.sort || 'meta.createdAt', | ||
order: { | ||
value: options.order || 'desc', | ||
type: 'GraphQLSortOrder', | ||
}, | ||
textSearch: options.textSearch || '', | ||
filter: { | ||
type: 'WorkerbaseDatabaseitemsFilter', | ||
value: __assign(__assign({}, (payload || {})), { database: { | ||
EQ: (_a = spec === null || spec === void 0 ? void 0 : spec.parent) === null || _a === void 0 ? void 0 : _a.slug, | ||
} }), | ||
}, | ||
}, | ||
}); | ||
return [4 /*yield*/, doRequest_1.doRequest(spec._api, 'graphql', { | ||
method: 'POST', | ||
data: graphqlQuery, | ||
params: __assign({}, options), | ||
}, process.env.DATABASES_SERVICE_HOST)]; | ||
case 1: | ||
data = (_b.sent()).data; | ||
return [2 /*return*/, data.data]; | ||
} | ||
}); | ||
}); | ||
}; }, | ||
query: function (spec) { return function (payload, options) { | ||
@@ -83,0 +143,0 @@ if (options === void 0) { options = {}; } |
@@ -12,3 +12,3 @@ import { Database, DatabasePOST, DatabasePUT } from '../types/databases'; | ||
}>; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
export default _default; |
@@ -12,3 +12,3 @@ import { Event, EventPOST, EventPUT } from '../types/events'; | ||
} | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
export default _default; |
@@ -13,3 +13,3 @@ import { WorkerbaseFunction, WorkerbaseFunctionPOST, WorkerbaseFunctionPUT } from '../types/functions'; | ||
} | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
export default _default; |
@@ -12,3 +12,3 @@ import { Location, LocationPUT, LocationPOST, LocationPart, LocationLevel } from '../types/locations'; | ||
} | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
export default _default; |
@@ -8,3 +8,3 @@ import { MediaBase } from '../types/media'; | ||
}>, BasicMethods.LIST | BasicMethods.DELETE>; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
export default _default; |
@@ -8,3 +8,3 @@ import { Role, RolePUT, RolePOST } from '../types/roles'; | ||
}>; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
export default _default; |
@@ -8,3 +8,3 @@ import { Skill, SkillPUT, SkillPOST } from '../types/skills'; | ||
}>; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
export default _default; |
@@ -8,3 +8,3 @@ import { Task, TaskPUT, TaskPOST } from '../types/tasks'; | ||
}>; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
export default _default; |
@@ -8,3 +8,3 @@ import { User, UserPUT, UserPOST } from '../types/users'; | ||
}>; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string) => void; | ||
declare const _default: (workerbase: import("..").WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; | ||
export default _default; |
export interface ListOptions { | ||
page?: number; | ||
perpage?: number; | ||
textSearch?: string; | ||
sort?: string; | ||
@@ -5,0 +6,0 @@ order?: 'desc' | 'asc'; |
@@ -94,3 +94,5 @@ "use strict"; | ||
baseUrl = parseurl_1.default({ url: api.url }).href; | ||
url = baseUrl + "api/" + apiVersion + "/" + endpoint; | ||
url = endpoint === 'graphql' | ||
? baseUrl + "graphql" | ||
: baseUrl + "api/" + apiVersion + "/" + endpoint; | ||
_g.label = 1; | ||
@@ -97,0 +99,0 @@ case 1: |
@@ -38,6 +38,7 @@ import { WorkerbaseSdk, API } from '..'; | ||
basePath: string; | ||
parent: any; | ||
}) => Function>; | ||
internalHostname?: string; | ||
childApis?: Record<string, (workerbase: WorkerbaseSdk, parentAPIPath?: string) => void>; | ||
childApis?: Record<string, (workerbase: WorkerbaseSdk, parentAPIPath?: string, parent?: any) => void>; | ||
transformData?: (data: Item['GET']) => TransformedItem; | ||
}): (workerbase: WorkerbaseSdk, parentAPIPath?: string) => void; | ||
}): (workerbase: WorkerbaseSdk, parentAPIPath?: string, parent?: {}) => void; |
@@ -136,5 +136,6 @@ "use strict"; | ||
function default_1(params) { | ||
return function (workerbase, parentAPIPath) { | ||
return function (workerbase, parentAPIPath, parent) { | ||
var _this = this; | ||
if (parentAPIPath === void 0) { parentAPIPath = ''; } | ||
if (parent === void 0) { parent = {}; } | ||
var childApis = params.childApis, includeBasics = params.includeBasics, path = params.path, methods = params.methods, internalHostname = params.internalHostname; | ||
@@ -148,3 +149,3 @@ var fullPath = parentAPIPath + path; | ||
Object.keys(childApis).forEach(function (key) { | ||
transformedData[key] = new childApis[key](workerbase, fullPath + "/" + data._id + "/"); | ||
transformedData[key] = new childApis[key](workerbase, fullPath + "/" + data._id + "/", data); | ||
}); | ||
@@ -164,2 +165,3 @@ return transformedData; | ||
basePath: fullPath, | ||
parent: parent, | ||
}); | ||
@@ -166,0 +168,0 @@ }); |
{ | ||
"name": "@workerbase/sdk", | ||
"version": "0.1.21", | ||
"description": "", | ||
"scripts": { | ||
"prepare": "npm run build", | ||
"test": "echo \"Error: no test specified\" && exit 0", | ||
"build": "tsc", | ||
"watch": "tsc -w --preserveWatchOutput", | ||
"lint": "eslint --ext .js,.ts ./src/", | ||
"lint:fix": "eslint --ext .js,.ts ./src/ --fix" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@git.workerbase.io:public-projects/workerbase-sdk.git" | ||
}, | ||
"files": [ | ||
"dist/**" | ||
], | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
"name": "@workerbase/sdk", | ||
"version": "0.1.22", | ||
"description": "", | ||
"scripts": { | ||
"prepare": "npm run build", | ||
"test": "echo \"Error: no test specified\" && exit 0", | ||
"build": "tsc", | ||
"watch": "tsc -w --preserveWatchOutput", | ||
"lint": "eslint --ext .js,.ts ./src/", | ||
"lint:fix": "eslint --ext .js,.ts ./src/ --fix" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git@git.workerbase.io:public-projects/workerbase-sdk.git" | ||
}, | ||
"files": [ | ||
"dist/**" | ||
], | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
} | ||
}, | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@commitlint/cli": "^8.3.5", | ||
"@commitlint/config-conventional": "^8.3.4", | ||
"@types/node": "^14.0.13", | ||
"@typescript-eslint/eslint-plugin": "^2.24.0", | ||
"@typescript-eslint/parser": "^2.24.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb": "^18.1.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-import": "^2.21.2", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-react": "^7.20.0", | ||
"eslint-plugin-react-hooks": "^2.5.0", | ||
"prettier": "^1.19.1", | ||
"typescript": "^3.9.5" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.19.2", | ||
"gql-query-builder": "^3.6.0", | ||
"parseurl": "^1.3.3" | ||
} | ||
}, | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@commitlint/cli": "^8.3.5", | ||
"@commitlint/config-conventional": "^8.3.4", | ||
"@types/node": "^14.0.13", | ||
"@typescript-eslint/eslint-plugin": "^2.24.0", | ||
"@typescript-eslint/parser": "^2.24.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb": "^18.1.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-import": "^2.21.2", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-react": "^7.20.0", | ||
"eslint-plugin-react-hooks": "^2.5.0", | ||
"prettier": "^1.19.1", | ||
"typescript": "^3.9.5" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.19.2", | ||
"parseurl": "^1.3.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
100010
1587
3
25
+ Addedgql-query-builder@^3.6.0
+ Addedgql-query-builder@3.8.0(transitive)