Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions WeniFluxos/WeniFluxos.pq
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,40 @@ MaxAttempts = 3;

AttemptTimeMultiplier = 5;

[DataSource.Kind="WeniFluxos", Publish="WeniFluxos.Publish"]
shared WeniFluxos.Contents = (token as text, optional after as datetime, optional before as datetime) => WeniFluxosNavTable(BaseUrl, token, after, before) as table;

WeniFluxos.GetData = (url as text, token as text, after as nullable datetime, before as nullable datetime) as table => GetAllPagesByNextLink(url, token, after, before);
shared WeniFluxos.ConnectionTest = () =>
let
source = Web.Contents(BaseUrl),
res = Xml.Document(source)
in
res;

WeniFluxosNavTable = (url as text, token as text, after as nullable datetime, before as nullable datetime) as table =>
[DataSource.Kind="WeniFluxos", Publish="WeniFluxos.Publish"]
shared WeniFluxos.Contents = Value.ReplaceType(ContentsImpl, ContentsType);

ContentsType = type function (
token as (type text meta [
Documentation.FieldCaption = "Token",
Documentation.FieldDescription = "User token used for authentication"
]),
optional after as (type datetime meta [
Documentation.FieldCaption = "After",
Documentation.FieldDescription = "Only return data modified after this date"
]),
optional before as (type datetime meta [
Documentation.FieldCaption = "Before",
Documentation.FIeldDescription = "Only return data modified before this date"
]))
as table meta [
Documentation.Name = "Weni Platform data",
Documentation.LongDescription = "Access to data from the weni platform, to get data from your project and transform it, create dashboards and track its metrics and growth."
];

ContentsImpl = (token as text, optional after as datetime, optional before as datetime) as table =>
let
entitiesAsTable = Table.FromList(WeniFluxos.RootEntities, Splitter.SplitByNothing()),
rename = Table.RenameColumns(entitiesAsTable, {{"Column1", "Endpoint"}}),
withEntity = Table.AddColumn(rename, "Name", each Text.BeforeDelimiter([Endpoint],".")),
withData = Table.AddColumn(withEntity, "Data", each WeniFluxos.GetData(Uri.Combine(url, [Endpoint]), token, after, before), Uri.Type),
withData = Table.AddColumn(withEntity, "Data", each WeniFluxos.GetData(Uri.Combine(BaseUrl, [Endpoint]), token, after, before), Uri.Type),
withItemKind = Table.AddColumn(withData, "ItemKind", each "Table", type text),
withItemName = Table.AddColumn(withItemKind, "ItemName", each "Table", type text),
withIsLeaf = Table.AddColumn(withItemName, "IsLeaf", each true, type logical),
Expand All @@ -36,6 +59,8 @@ WeniFluxosNavTable = (url as text, token as text, after as nullable datetime, be
in
navTable;

WeniFluxos.GetData = (url as text, token as text, after as nullable datetime, before as nullable datetime) as table => GetAllPagesByNextLink(url, token, after, before);

Table.ToNavigationTable = (
table as table,
keyColumns as list,
Expand Down Expand Up @@ -137,6 +162,7 @@ TryRequest = (url as text, reqOptions as record, tryCount as number, isRetry as
GetNextLink = (response) as nullable text => Record.FieldOrDefault(response, "next");

WeniFluxos = [
TestConnection = (dataSourcePath) => { "WeniFluxos.ConnectionTest" },
Authentication = [
Implicit = []
],
Expand Down