@activepieces/pieces-common
Advanced tools
Comparing version 0.2.6 to 0.2.7
{ | ||
"name": "@activepieces/pieces-common", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"type": "commonjs", | ||
@@ -13,7 +13,7 @@ "dependencies": { | ||
"semver": "7.5.4", | ||
"@activepieces/pieces-framework": "0.7.10", | ||
"@activepieces/shared": "0.10.59", | ||
"tslib": "2.6.2" | ||
"@activepieces/pieces-framework": "0.7.12", | ||
"@activepieces/shared": "0.10.65", | ||
"tslib": "2.6.1" | ||
}, | ||
"main": "./src/index.js" | ||
} |
@@ -6,5 +6,5 @@ import { OAuth2PropertyValue, PieceAuthProperty } from "@activepieces/pieces-framework"; | ||
auth?: PieceAuthProperty; | ||
baseUrl: string; | ||
authMapping?: (auth: PieceAuthProperty) => HttpHeaders; | ||
}): import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").BasicAuthProperty<boolean> | import("@activepieces/pieces-framework").CustomAuthProperty<boolean, any> | import("@activepieces/pieces-framework").OAuth2Property<boolean, import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").SecretTextProperty<boolean>, { | ||
baseUrl: (auth?: unknown) => string; | ||
authMapping?: (auth: unknown) => HttpHeaders; | ||
}): import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").BasicAuthProperty | import("@activepieces/pieces-framework").CustomAuthProperty<any> | import("@activepieces/pieces-framework").OAuth2Property<any> | import("@activepieces/pieces-framework").SecretTextProperty<boolean>, { | ||
url: import("@activepieces/pieces-framework").ShortTextProperty<true>; | ||
@@ -14,5 +14,5 @@ method: import("@activepieces/pieces-framework").StaticDropdownProperty<HttpMethod, true>; | ||
queryParams: import("@activepieces/pieces-framework").ObjectProperty<true>; | ||
body: import("@activepieces/pieces-framework").JsonProperty<false>; | ||
body: import("../../../../../../../dist/packages/pieces/community/framework/src/lib/property/input/json-property").JsonProperty<false>; | ||
failsafe: import("@activepieces/pieces-framework").CheckboxProperty<false>; | ||
timeout: import("@activepieces/pieces-framework").NumberProperty<false>; | ||
}>; |
@@ -22,6 +22,7 @@ "use strict"; | ||
auth: auth ? auth : undefined, | ||
requireAuth: auth ? true : false, | ||
props: { | ||
url: pieces_framework_1.Property.ShortText({ | ||
displayName: 'URL', | ||
description: 'The endpoint to use. For example, `/models`', | ||
description: 'The endpoint to use. For example, /models', | ||
required: true, | ||
@@ -73,3 +74,3 @@ }), | ||
method, | ||
url: `${baseUrl}${url}`, | ||
url: `${baseUrl(context.auth)}${url}`, | ||
headers: headersValue, | ||
@@ -76,0 +77,0 @@ queryParams: queryParams, |
@@ -28,3 +28,3 @@ "use strict"; | ||
data: request.body, | ||
timeout | ||
timeout, | ||
}; | ||
@@ -31,0 +31,0 @@ const response = yield axios_1.default.request(config); |
@@ -10,3 +10,3 @@ "use strict"; | ||
[authentication_1.AuthenticationType.BEARER_TOKEN]: bearerTokenConverter, | ||
[authentication_1.AuthenticationType.BASIC]: basicTokenConverter | ||
[authentication_1.AuthenticationType.BASIC]: basicTokenConverter, | ||
}; | ||
@@ -13,0 +13,0 @@ } |
@@ -10,7 +10,7 @@ "use strict"; | ||
status: ((_a = _err === null || _err === void 0 ? void 0 : _err.response) === null || _a === void 0 ? void 0 : _a.status) || 500, | ||
body: (_b = _err === null || _err === void 0 ? void 0 : _err.response) === null || _b === void 0 ? void 0 : _b.data | ||
body: (_b = _err === null || _err === void 0 ? void 0 : _err.response) === null || _b === void 0 ? void 0 : _b.data, | ||
}, | ||
request: { | ||
body: _requestBody | ||
} | ||
body: _requestBody, | ||
}, | ||
})); | ||
@@ -25,7 +25,7 @@ this._requestBody = _requestBody; | ||
status: ((_b = (_a = this._err) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.status) || 500, | ||
body: (_d = (_c = this._err) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.data | ||
body: (_d = (_c = this._err) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.data, | ||
}, | ||
request: { | ||
body: this._requestBody | ||
} | ||
body: this._requestBody, | ||
}, | ||
}; | ||
@@ -37,3 +37,3 @@ } | ||
status: ((_b = (_a = this._err) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.status) || 500, | ||
body: (_d = (_c = this._err) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.data | ||
body: (_d = (_c = this._err) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.data, | ||
}; | ||
@@ -43,3 +43,3 @@ } | ||
return { | ||
body: this._requestBody | ||
body: this._requestBody, | ||
}; | ||
@@ -46,0 +46,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { HttpMessageBody } from "./http-message-body"; | ||
import { HttpHeaders } from "./http-headers"; | ||
import { HttpMessageBody } from './http-message-body'; | ||
import { HttpHeaders } from './http-headers'; | ||
export type HttpResponse<RequestBody extends HttpMessageBody = any> = { | ||
@@ -4,0 +4,0 @@ status: number; |
@@ -1,2 +0,2 @@ | ||
import { Store } from "@activepieces/pieces-framework"; | ||
import { Store } from '@activepieces/pieces-framework'; | ||
interface TimebasedPolling<AuthValue, PropsValue> { | ||
@@ -32,3 +32,3 @@ strategy: DedupeStrategy.TIMEBASED; | ||
export declare const pollingHelper: { | ||
poll<AuthValue, PropsValue>(polling: Polling<AuthValue, PropsValue>, { store, auth, propsValue, maxItemsToPoll }: { | ||
poll<AuthValue, PropsValue>(polling: Polling<AuthValue, PropsValue>, { store, auth, propsValue, maxItemsToPoll, }: { | ||
store: Store; | ||
@@ -39,3 +39,3 @@ auth: AuthValue; | ||
}): Promise<unknown[]>; | ||
onEnable<AuthValue_1, PropsValue_1>(polling: Polling<AuthValue_1, PropsValue_1>, { store, auth, propsValue }: { | ||
onEnable<AuthValue_1, PropsValue_1>(polling: Polling<AuthValue_1, PropsValue_1>, { store, auth, propsValue, }: { | ||
store: Store; | ||
@@ -50,3 +50,3 @@ auth: AuthValue_1; | ||
}): Promise<void>; | ||
test<AuthValue_3, PropsValue_3>(polling: Polling<AuthValue_3, PropsValue_3>, { auth, propsValue, store }: { | ||
test<AuthValue_3, PropsValue_3>(polling: Polling<AuthValue_3, PropsValue_3>, { auth, propsValue, store, }: { | ||
store: Store; | ||
@@ -53,0 +53,0 @@ auth: AuthValue_3; |
@@ -12,3 +12,3 @@ "use strict"; | ||
exports.pollingHelper = { | ||
poll(polling, { store, auth, propsValue, maxItemsToPoll }) { | ||
poll(polling, { store, auth, propsValue, maxItemsToPoll, }) { | ||
var _a, _b, _c; | ||
@@ -18,12 +18,24 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
case DedupeStrategy.TIMEBASED: { | ||
const lastEpochMilliSeconds = (_a = (yield store.get("lastPoll"))) !== null && _a !== void 0 ? _a : 0; | ||
const items = yield polling.items({ store, auth, propsValue, lastFetchEpochMS: lastEpochMilliSeconds }); | ||
const lastEpochMilliSeconds = (_a = (yield store.get('lastPoll'))) !== null && _a !== void 0 ? _a : 0; | ||
const items = yield polling.items({ | ||
store, | ||
auth, | ||
propsValue, | ||
lastFetchEpochMS: lastEpochMilliSeconds, | ||
}); | ||
const newLastEpochMilliSeconds = items.reduce((acc, item) => Math.max(acc, item.epochMilliSeconds), lastEpochMilliSeconds); | ||
yield store.put("lastPoll", newLastEpochMilliSeconds); | ||
return items.filter(f => f.epochMilliSeconds > lastEpochMilliSeconds).map((item) => item.data); | ||
yield store.put('lastPoll', newLastEpochMilliSeconds); | ||
return items | ||
.filter((f) => f.epochMilliSeconds > lastEpochMilliSeconds) | ||
.map((item) => item.data); | ||
} | ||
case DedupeStrategy.LAST_ITEM: { | ||
const lastItemId = (yield store.get("lastItem")); | ||
const items = yield polling.items({ store, auth, propsValue, lastItemId }); | ||
const lastItemIndex = items.findIndex(f => f.id === lastItemId); | ||
const lastItemId = yield store.get('lastItem'); | ||
const items = yield polling.items({ | ||
store, | ||
auth, | ||
propsValue, | ||
lastItemId, | ||
}); | ||
const lastItemIndex = items.findIndex((f) => f.id === lastItemId); | ||
let newItems = []; | ||
@@ -43,3 +55,3 @@ if ((0, shared_1.isNil)(lastItemId) || lastItemIndex == -1) { | ||
if (!(0, shared_1.isNil)(newLastItem)) { | ||
yield store.put("lastItem", newLastItem); | ||
yield store.put('lastItem', newLastItem); | ||
} | ||
@@ -51,3 +63,3 @@ return newItems.map((item) => item.data); | ||
}, | ||
onEnable(polling, { store, auth, propsValue }) { | ||
onEnable(polling, { store, auth, propsValue, }) { | ||
var _a; | ||
@@ -57,13 +69,18 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
case DedupeStrategy.TIMEBASED: { | ||
yield store.put("lastPoll", Date.now()); | ||
yield store.put('lastPoll', Date.now()); | ||
break; | ||
} | ||
case DedupeStrategy.LAST_ITEM: { | ||
const items = (yield polling.items({ store, auth, propsValue, lastItemId: null })); | ||
const items = yield polling.items({ | ||
store, | ||
auth, | ||
propsValue, | ||
lastItemId: null, | ||
}); | ||
const lastItemId = (_a = items === null || items === void 0 ? void 0 : items[0]) === null || _a === void 0 ? void 0 : _a.id; | ||
if (!(0, shared_1.isNil)(lastItemId)) { | ||
yield store.put("lastItem", lastItemId); | ||
yield store.put('lastItem', lastItemId); | ||
} | ||
else { | ||
yield store.delete("lastItem"); | ||
yield store.delete('lastItem'); | ||
} | ||
@@ -84,3 +101,3 @@ break; | ||
}, | ||
test(polling, { auth, propsValue, store }) { | ||
test(polling, { auth, propsValue, store, }) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
@@ -90,7 +107,17 @@ let items = []; | ||
case DedupeStrategy.TIMEBASED: { | ||
items = yield polling.items({ store, auth, propsValue, lastFetchEpochMS: 0 }); | ||
items = yield polling.items({ | ||
store, | ||
auth, | ||
propsValue, | ||
lastFetchEpochMS: 0, | ||
}); | ||
break; | ||
} | ||
case DedupeStrategy.LAST_ITEM: { | ||
items = yield polling.items({ store, auth, propsValue, lastItemId: null }); | ||
items = yield polling.items({ | ||
store, | ||
auth, | ||
propsValue, | ||
lastItemId: null, | ||
}); | ||
break; | ||
@@ -101,3 +128,3 @@ } | ||
}); | ||
} | ||
}, | ||
}; | ||
@@ -104,0 +131,0 @@ function getFirstFiveOrAll(array) { |
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
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
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
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
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
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
45492
699
+ Added@activepieces/pieces-framework@0.7.12(transitive)
+ Added@activepieces/shared@0.10.630.10.65(transitive)
+ Addedtslib@2.6.1(transitive)
- Removed@activepieces/pieces-framework@0.7.10(transitive)
- Removed@activepieces/shared@0.10.580.10.59(transitive)
- Removedtslib@1.14.12.6.2(transitive)
Updated@activepieces/shared@0.10.65
Updatedtslib@2.6.1