Skip to content

Commit

Permalink
Update main with changes in dev (#42)
Browse files Browse the repository at this point in the history
* feat: Added isMultiplayer to receive log

* Adds universal OAuth, preliminary connector installer and new column in GetByURL table (#41)

* ci: Added step to sign MEZ file

* ci: Fix output dir

* ci: Added innosetup installer test

* ci: Fix path

* ci: Fix sign tool path 🤦🏼‍♂️

* ci: Don't sign

* feat: Added parent object column to GetByUrl result

* feat: Universal OAuth login

* fix: Installer function fail, non-critical. Reverted to simple implementation
  • Loading branch information
AlanRynne authored May 11, 2023
1 parent 83ec9a7 commit 9db161b
Show file tree
Hide file tree
Showing 54 changed files with 12,087 additions and 96 deletions.
15 changes: 14 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ jobs:
- run:
name: "Build Data Connector"
command: "msbuild Speckle.proj /restore /consoleloggerparameters:NoSummary /property:GenerateFullPaths=true"
- run:
name: Create Innosetup signing cert
command: |
echo $env:PFX_B64 > "tools\AEC Systems Ltd.txt"
certutil -decode "tools\AEC Systems Ltd.txt" "tools\AEC Systems Ltd.pfx"
- run:
name: Create Signed PFX file
command: .\tools\MakePQX\MakePQX.exe pack -mz bin/Speckle.mez -t bin/Speckle.pqx -c "tools\AEC Systems Ltd.pfx" -p $env:PFX_PSW
- run:
name: Build Installer
command: tools\InnoSetup\ISCC.exe tools\powerbi.iss /Sbyparam=$p
shell: cmd.exe #does not work in powershell
- store_artifacts:
path: ./bin
- persist_to_workspace:
Expand All @@ -40,7 +52,7 @@ workflows:
build:
jobs:
- build-connector:
context: github-dev-bot
context: innosetup
deploy:
jobs:
- build-connector:
Expand All @@ -49,6 +61,7 @@ workflows:
ignore: /.*/ # For testing only: /ci\/.*/
tags:
only: /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-\w{1,10})?$/
context: innosetup
- deploy-connector:
filters:
branches:
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/close-issue.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/open-issue.yml

This file was deleted.

28 changes: 16 additions & 12 deletions Speckle.pq
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[Version = "2.0.0"]
section Speckle;

AuthAppId = "63463ba25d";
AuthAppSecret = "c317a7ce45";
AuthServer = "https://speckle.xyz";
AuthAppId = "spklpwerbi";
AuthAppSecret = "spklpwerbi";

// The data source definition, used when connecting to any speckle server
Speckle = [
Expand All @@ -14,18 +13,22 @@ Speckle = [
OAuth = [
Label = "Speckle.xyz",
StartLogin = (clientApplication, dataSourcePath, state, display) =>
[
LoginUri = Text.Combine({AuthServer, "authn", "verify", AuthAppId, state}, "/"),
CallbackUri = "https://oauth.powerbi.com/views/oauthredirect.html",
WindowHeight = 800,
WindowWidth = 600,
Context = null
],
let
server = Text.Combine({"https://", Uri.Parts(dataSourcePath)[Host]})
in
[
LoginUri = Text.Combine({server, "authn", "verify", AuthAppId, state}, "/"),
CallbackUri = "https://oauth.powerbi.com/views/oauthredirect.html",
WindowHeight = 800,
WindowWidth = 600,
Context = null
],
FinishLogin = (clientApplication, dataSourcePath, context, callbackUri, state) =>
let
server = Text.Combine({"https://", Uri.Parts(dataSourcePath)[Host]}),
Parts = Uri.Parts(callbackUri)[Query],
Source = Web.Contents(
Text.Combine({AuthServer, "auth", "token"}, "/"),
Text.Combine({server, "auth", "token"}, "/"),
[
Headers = [
#"Content-Type" = "application/json"
Expand All @@ -50,8 +53,9 @@ Speckle = [
],
Refresh = (dataSourcePath, refreshToken) =>
let
server = Text.Combine({"https://", Uri.Parts(dataSourcePath)[Host]}),
Source = Web.Contents(
Text.Combine({AuthServer, "auth", "token"}, "/"),
Text.Combine({server, "auth", "token"}, "/"),
[
Headers = [
#"Content-Type" = "application/json"
Expand Down
81 changes: 44 additions & 37 deletions Speckle.proj
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="BuildMez">
<PropertyGroup>
<OutputPath Condition="'$(OutputPath)' == ''">$(MSBuildProjectDirectory)\bin\</OutputPath>
<IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">$(MSBuildProjectDirectory)\obj\</IntermediateOutputPath>
<MezIntermediatePath>$(IntermediateOutputPath)MEZ\</MezIntermediatePath>
<MezOutputPath>$(OutputPath)$(MsBuildProjectName).mez</MezOutputPath>
</PropertyGroup>
<ItemGroup>
<MezContent Include="Speckle.pq" />
<MezContent Include="utilities\**\*.pqm" />
<MezContent Include="speckle\**\*.pqm" />
<MezContent Include="assets\SpeckleLogo16.png" />
<MezContent Include="assets\SpeckleLogo20.png" />
<MezContent Include="assets\SpeckleLogo24.png" />
<MezContent Include="assets\SpeckleLogo32.png" />
<MezContent Include="assets\SpeckleLogo40.png" />
<MezContent Include="assets\SpeckleLogo48.png" />
<MezContent Include="assets\SpeckleLogo64.png" />
<MezContent Include="assets\SpeckleLogo80.png" />
<MezContent Include="assets\resources.resx" />
</ItemGroup>
<Target Name="BuildMez" AfterTargets="Build" Inputs="@(MezContent)" Outputs="$(MezOutputPath)">
<RemoveDir Directories="$(MezIntermediatePath)" />
<Copy SourceFiles="@(MezContent)" DestinationFolder="$(MezIntermediatePath)" />
<MakeDir Directories="$(OutputPath)" Condition="!Exists('$(OutputPath)')" />
<ZipDirectory SourceDirectory="$(MezIntermediatePath)" DestinationFile="$(MezOutputPath)" Overwrite="true" />
</Target>
<Target Name="CopyToConnectors" AfterTargets="BuildMez">
<Message Text="Copying .mez file to: $(UserProfile)\Documents\Power BI Desktop\Custom Connectors" Importance="High" />
<MakeDir Directories="$(UserProfile)\Documents\Power BI Desktop\Custom Connectors\" />
<Copy SourceFiles="$(MezOutputPath)" DestinationFolder="$(UserProfile)\Documents\Power BI Desktop\Custom Connectors\"/>
</Target>
<Target Name="Clean">
<RemoveDir Directories="$(MezIntermediatePath)" />
<Delete Files="$(MezOutputPath)" />
</Target>
</Project>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="BuildMez">
<PropertyGroup>
<Version Condition="'$(Version)' == ''">2.0.0-wip</Version>
<OutputPath Condition="'$(OutputPath)' == ''">$(MSBuildProjectDirectory)\bin\</OutputPath>
<IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">
$(MSBuildProjectDirectory)\obj\</IntermediateOutputPath>
<MezIntermediatePath>$(IntermediateOutputPath)MEZ\</MezIntermediatePath>
<MezOutputPath>$(OutputPath)$(MsBuildProjectName).mez</MezOutputPath>
</PropertyGroup>
<ItemGroup>
<MezContent Include="Speckle.pq" />
<MezContent Include="utilities\**\*.pqm" />
<MezContent Include="speckle\**\*.pqm" />
<MezContent Include="assets\SpeckleLogo16.png" />
<MezContent Include="assets\SpeckleLogo20.png" />
<MezContent Include="assets\SpeckleLogo24.png" />
<MezContent Include="assets\SpeckleLogo32.png" />
<MezContent Include="assets\SpeckleLogo40.png" />
<MezContent Include="assets\SpeckleLogo48.png" />
<MezContent Include="assets\SpeckleLogo64.png" />
<MezContent Include="assets\SpeckleLogo80.png" />
<MezContent Include="assets\resources.resx" />
</ItemGroup>
<Target Name="BuildMez" AfterTargets="Build" Inputs="@(MezContent)" Outputs="$(MezOutputPath)">
<RemoveDir Directories="$(MezIntermediatePath)" />
<Copy SourceFiles="@(MezContent)" DestinationFolder="$(MezIntermediatePath)" />
<MakeDir Directories="$(OutputPath)" Condition="!Exists('$(OutputPath)')" />
<ZipDirectory SourceDirectory="$(MezIntermediatePath)" DestinationFile="$(MezOutputPath)"
Overwrite="true" />
</Target>
<Target Name="CopyToConnectors" AfterTargets="BuildMez">
<Message
Text="Copying .mez file to: $(UserProfile)\Documents\Power BI Desktop\Custom Connectors"
Importance="High" />
<MakeDir Directories="$(UserProfile)\Documents\Power BI Desktop\Custom Connectors\" />
<Copy SourceFiles="$(MezOutputPath)"
DestinationFolder="$(UserProfile)\Documents\Power BI Desktop\Custom Connectors\" />
</Target>
<Target Name="Clean">
<RemoveDir Directories="$(MezIntermediatePath)" />
<Delete Files="$(MezOutputPath)" />
</Target>
</Project>
2 changes: 1 addition & 1 deletion Speckle.query.pq
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Use this file to write queries to test your data connector
let result = Speckle.GetByUrl.Structured("https://speckle.xyz/streams/ceecc65de7") in Record.ToTable(result)
let result = Speckle.GetByUrl("https://latest.speckle.dev/streams/c1faab5c62/commits/aefb7a5fff") in result
14 changes: 12 additions & 2 deletions speckle/GetByUrl.pqm
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,23 @@ in
GetObjectFromBranch(server, id, "main"),
removeEmpty = Table.RemoveLastN(commitObjectsTable, 1),
addStreamUrl = Table.AddColumn(removeEmpty, "Stream URL", each server & "/streams/" & id),
addUrlType = Table.AddColumn(addStreamUrl, "URL Type", each stream[urlType]),
addParentObjectId = Table.AddColumn(
addStreamUrl, "Commit Object ID", each Value.Metadata(commitObjectsTable)[objectId]
),
addUrlType = Table.AddColumn(addParentObjectId, "URL Type", each stream[urlType]),
addObjectIdCol = Table.AddColumn(addUrlType, "Object ID", each try[data][id] otherwise null),
addSpeckleTypeCol = Table.AddColumn(
addObjectIdCol, "speckle_type", each try[data][speckle_type] otherwise null
),
final = Table.ReorderColumns(
addSpeckleTypeCol, {"Stream URL", "URL Type", "Object ID", "speckle_type", "data"}
addSpeckleTypeCol, {
"Stream URL",
"URL Type",
"Commit Object ID",
"Object ID",
"speckle_type",
"data"
}
)
in
final
1 change: 1 addition & 0 deletions speckle/GetObjectFromCommit.pqm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ in
id
sourceApplication
referencedObject
authorId
}
}
}",
Expand Down
4 changes: 2 additions & 2 deletions speckle/api/Api.CommitReceived.pqm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let
Speckle.Api.Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
Speckle.LogEvent = Extension.LoadFunction("LogEvent.pqm"),
Speckle.Log.Receive = Extension.LoadFunction("Log.Receive.pqm"),
Extension.LoadFunction = (fileName as text) =>
let
binary = Extension.Contents(fileName), asText = Text.FromBinary(binary)
Expand All @@ -27,7 +27,7 @@ in
sourceApplication = "PowerBI"
]
],
s = Speckle.LogEvent(server, commit)
s = Speckle.Log.Receive(server, commit)
in
// Read receipts should fail gracefully no matter what
try Speckle.Api.Fetch(s, query, variables)[commitReceive] otherwise false
11 changes: 7 additions & 4 deletions speckle/api/Api.GetUser.pqm
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
(url as text) =>
let
userType = type [name = text, email = text, id = text],
query = "query {
activeUser { name email }
activeUser { name email id }
}",
// Imports
Speckle.Api.Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
server = Extension.LoadFunction("ParseStreamUrl.pqm"),
ParseUrl = Extension.LoadFunction("ParseStreamUrl.pqm"),
urlObject = ParseUrl(url),
Extension.LoadFunction = (fileName as text) =>
let
binary = Extension.Contents(fileName), asText = Text.FromBinary(binary)
Expand All @@ -18,7 +20,8 @@
Message.Format = "Loading '#{0}' failed - '#{1}': '#{2}'",
Message.Parameters = {fileName, e[Reason], e[Message]},
Detail = [File = fileName, Error = e]
]
],
user = Speckle.Api.Fetch(urlObject[server], query)[activeUser]
in
// Read receipts should fail gracefully no matter what
try Speckle.Api.Fetch(server, query)[activeUser][email] otherwise "hey"
Value.ReplaceType(user, userType)
33 changes: 33 additions & 0 deletions speckle/logging/Log.Receive.pqm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
let
GetApplicationSlug = Extension.LoadFunction("GetApplicationSlug.pqm"),
GetUser = Extension.LoadFunction("Api.GetUser.pqm"),
LogEvent = Extension.LoadFunction("LogEvent.pqm"),
Hash = Extension.LoadFunction("Hash.pqm"),
Extension.LoadFunction = (fileName as text) =>
let
binary = Extension.Contents(fileName), asText = Text.FromBinary(binary)
in
try
Expression.Evaluate(asText, #shared) catch (e) =>
error
[
Reason = "Extension.LoadFunction Failure",
Message.Format = "Loading '#{0}' failed - '#{1}': '#{2}'",
Message.Parameters = {fileName, e[Reason], e[Message]},
Detail = [File = fileName, Error = e]
]
in
(server as text, commit as text) =>
let
user = GetUser(server),
event = "Receive",
properties = [
server_id = Hash(server),
token = "acd87c5a50b56df91a795e999812a3a4",
hostApp = "powerbi",
sourceHostApp = GetApplicationSlug(commit[sourceApplication]),
sourceHostAppVersion = commit[sourceApplication],
isMultiplayer = commit[authorId] <> user[id]
]
in
LogEvent(server, event, properties)
16 changes: 3 additions & 13 deletions speckle/helpers/LogEvent.pqm → speckle/logging/LogEvent.pqm
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
let
GetApplicationSlug = Extension.LoadFunction("GetApplicationSlug.pqm"),
GetUser = Extension.LoadFunction("GetUser.pqm"),
Hash = Extension.LoadFunction("Hash.pqm"),
Extension.LoadFunction = (fileName as text) =>
let
binary = Extension.Contents(fileName), asText = Text.FromBinary(binary)
Expand All @@ -16,19 +13,12 @@ let
Detail = [File = fileName, Error = e]
]
in
(server as text, commit as any) =>
(server as text, event as text, properties as record) =>
let
trackUrl = "https://analytics.speckle.systems/track?ip=1",
user = GetUser(server),
body = [
event = "Receive",
properties = [
server_id = Hash(server),
token = "acd87c5a50b56df91a795e999812a3a4",
hostApp = "powerbi",
sourceHostApp = GetApplicationSlug(commit[sourceApplication]),
sourceHostAppVersion = commit[sourceApplication]
]
event = event,
properties = properties
],
Result = Web.Contents(
trackUrl,
Expand Down
Loading

0 comments on commit 9db161b

Please sign in to comment.