Compare commits
92 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8031c7da4f | |||
| 08554fc864 | |||
| 9168174747 | |||
| fd9054a387 | |||
| 84efce792b | |||
| 0bc4da1864 | |||
| d7ea4f217f | |||
| 3971adafd6 | |||
| 1392070b31 | |||
| 85b9e88fc1 | |||
| 92fc894d4b | |||
| b033cfa82b | |||
| 86cba3ce2b | |||
| c752487f9f | |||
| 95f51b0d32 | |||
| 9a5c1283ce | |||
| da1f0c7b7e | |||
| 0bb72f0d9d | |||
| 19e64fd4b2 | |||
| 63f286cd0b | |||
| e89ccbbe1a | |||
| f77e315623 | |||
| 9db161b3f2 | |||
| 83ec9a7888 | |||
| 6128b4293f | |||
| 6f68ec9c29 | |||
| 10c1009430 | |||
| c635995bf6 | |||
| 1198450ea4 | |||
| 3d4545be64 | |||
| 363c389928 | |||
| addc3f9d86 | |||
| 44fc99ecb7 | |||
| f52d6c46cb | |||
| f558d5dce3 | |||
| f9093a34e5 | |||
| 23cb40c4ab | |||
| 9bd6140065 | |||
| a14bb06d4e | |||
| 01576e77df | |||
| f1e16e9d55 | |||
| 4f210dae04 | |||
| 8669cf59f8 | |||
| 6e6402cb38 | |||
| 7b62630fd1 | |||
| eee4f0f8c2 | |||
| 23fa79bdd9 | |||
| edc9917a20 | |||
| 99cffeba8c | |||
| 7e92e7a2aa | |||
| 15aa627d7f | |||
| 8844f1837e | |||
| 6d1b85a14f | |||
| b2d6568b66 | |||
| 72f455393b | |||
| bd3fe6a47c | |||
| e7710f0f8e | |||
| e9034027eb | |||
| 685384b147 | |||
| 5973aaea10 | |||
| 639287f69c | |||
| a43decd473 | |||
| a532061879 | |||
| 15ac7c041e | |||
| 770d45f981 | |||
| 50b59a88c3 | |||
| 0bad9914c8 | |||
| aee00f3f21 | |||
| 2abdd4b645 | |||
| 71ef1acd8b | |||
| 23114a2912 | |||
| ee989f927d | |||
| 1ff15c7b44 | |||
| 6e9fb590a0 | |||
| 9700865934 | |||
| cf9e5a70b6 | |||
| 50c360ae79 | |||
| b671945fa7 | |||
| eb4787ddfa | |||
| 3ffd6c63e0 | |||
| a5a8316ee0 | |||
| 17083c9474 | |||
| 3e6f9988d6 | |||
| fe1504d1a9 | |||
| c753e13859 | |||
| fc2ffa75ba | |||
| de43e34c11 | |||
| 70eb1059d2 | |||
| 9e5c204c8f | |||
| e0f2782c8b | |||
| baf2132d1b | |||
| eef502f42f |
@@ -0,0 +1,3 @@
|
||||
for /f "tokens=1 delims=-" %%i in ("%CIRCLE_TAG%") do set "TAG=%%i.%WORKFLOW_NUM%"
|
||||
for /f "tokens=1 delims=/" %%j in ("%CIRCLE_TAG%") do set "SEMVER=%%j"
|
||||
tools\InnoSetup\ISCC.exe tools\powerbi.iss /Sbyparam=$p /DINFO_VERSION=%TAG% /DVERSION=%SEMVER% %*
|
||||
@@ -0,0 +1,175 @@
|
||||
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
||||
# See: https://circleci.com/docs/2.0/configuration-reference
|
||||
version: 2.1
|
||||
|
||||
orbs:
|
||||
win: circleci/windows@5.0
|
||||
|
||||
commands:
|
||||
setup_digicert:
|
||||
description: Set up Digicert Keylocker certificate for code-signing
|
||||
steps:
|
||||
- run:
|
||||
name: "Digicert Signing Manager Setup"
|
||||
command: |
|
||||
cd C:\
|
||||
curl.exe -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:$env:SM_API_KEY" -o smtools-windows-x64.msi
|
||||
msiexec.exe /i smtools-windows-x64.msi /quiet /qn | Wait-Process
|
||||
- run:
|
||||
name: Setup Digicert ONE Client Cert
|
||||
command: |
|
||||
cd C:\
|
||||
echo $env:SM_CLIENT_CERT_FILE_B64 > certificate.txt
|
||||
certutil -decode certificate.txt certificate.p12
|
||||
- run:
|
||||
name: Sync Certs
|
||||
command: |
|
||||
& $env:SSM\smksp_cert_sync.exe
|
||||
|
||||
jobs:
|
||||
build-visual:
|
||||
docker:
|
||||
- image: cimg/node:18.20.3
|
||||
steps:
|
||||
- checkout
|
||||
- run: node --version
|
||||
- run:
|
||||
name: "npm install"
|
||||
command: "npm i"
|
||||
working_directory: src/powerbi-visual
|
||||
- run:
|
||||
name: Set version
|
||||
command: |
|
||||
npm version ${CIRCLE_TAG:-2.0.0} --allow-same-version
|
||||
working_directory: src/powerbi-visual
|
||||
- run:
|
||||
name: "npm run build"
|
||||
command: "npm run build"
|
||||
working_directory: src/powerbi-visual
|
||||
- run:
|
||||
name: "npm run pack"
|
||||
command: "npm run pack"
|
||||
working_directory: src/powerbi-visual
|
||||
- store_artifacts:
|
||||
path: dist/*.pbiviz
|
||||
- persist_to_workspace:
|
||||
root: ./
|
||||
paths:
|
||||
- src/powerbi-visual/dist/*.pbiviz
|
||||
|
||||
build-connector:
|
||||
executor:
|
||||
name: win/default
|
||||
shell: powershell.exe
|
||||
environment:
|
||||
SSM: 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools'
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Set connector internal version"
|
||||
command: |
|
||||
$env:VERSION = if([string]::IsNullOrEmpty($env:CIRCLE_TAG)) { "2.0.0" } else { $env:CIRCLE_TAG }
|
||||
(Get-Content ./Speckle.pq).replace('[Version = "2.0.0"]', '[Version = "'+$($env:VERSION)+'"]') | Set-Content ./Speckle.pq
|
||||
working_directory: src/powerbi-data-connector
|
||||
- run:
|
||||
name: "Build Data Connector"
|
||||
command: "msbuild Speckle.proj /restore /consoleloggerparameters:NoSummary /property:GenerateFullPaths=true"
|
||||
working_directory: src/powerbi-data-connector
|
||||
- run:
|
||||
name: Create PQX file
|
||||
command: .\tools\MakePQX\MakePQX.exe pack -mz src/powerbi-data-connector/bin/Speckle.mez -t src/powerbi-data-connector/bin/Speckle.pqx
|
||||
- persist_to_workspace:
|
||||
root: ./
|
||||
paths:
|
||||
- src/powerbi-data-connector/bin/Speckle.pqx
|
||||
|
||||
build-installer:
|
||||
executor:
|
||||
name: win/default
|
||||
shell: powershell.exe
|
||||
environment:
|
||||
SSM: 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools'
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: ./
|
||||
- unless: # Build installers unsigned on non-tagged builds
|
||||
condition: << pipeline.git.tag >>
|
||||
steps:
|
||||
- run:
|
||||
name: Build Installer
|
||||
shell: cmd.exe #does not work in powershell
|
||||
environment:
|
||||
WORKFLOW_NUM: << pipeline.number >>
|
||||
CIRCLE_TAG: 2.0.0
|
||||
command: .circleci\build-installer.bat
|
||||
- when: # Setup certificates and build installers signed for tagged builds
|
||||
condition: << pipeline.git.tag >>
|
||||
steps:
|
||||
- setup_digicert
|
||||
- run:
|
||||
name: Build Installer
|
||||
shell: cmd.exe #does not work in powershell
|
||||
environment:
|
||||
WORKFLOW_NUM: << pipeline.number >>
|
||||
command: .circleci\build-installer.bat /DSIGN_INSTALLER /DCODE_SIGNING_CERT_FINGERPRINT=%SM_CODE_SIGNING_CERT_SHA1_HASH%
|
||||
- store_artifacts:
|
||||
path: ./installer
|
||||
- persist_to_workspace:
|
||||
root: ./
|
||||
paths:
|
||||
- installer/*.exe
|
||||
|
||||
deploy-connector-to-feed:
|
||||
docker:
|
||||
- image: mcr.microsoft.com/dotnet/sdk:6.0
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: ./
|
||||
- run:
|
||||
name: Install Manager Feed CLI
|
||||
command: dotnet tool install --global Speckle.Manager.Feed
|
||||
- run:
|
||||
name: Upload new version
|
||||
command: |
|
||||
TAG=$(if [ "${CIRCLE_TAG}" ]; then echo $CIRCLE_TAG; else echo "2.0.0"; fi;)
|
||||
SEMVER=$(echo "$TAG" | sed -e 's/\/[a-zA-Z-]*//')
|
||||
VER=$(echo "$SEMVER" | sed -e 's/-.*//')
|
||||
VERSION=$(echo $VER.$WORKFLOW_NUM)
|
||||
/root/.dotnet/tools/Speckle.Manager.Feed deploy -s powerbi -v ${SEMVER} -u https://releases.speckle.dev/installers/powerbi/powerbi-${SEMVER}.exe -o Win -a Any -f ./installer/powerbi-${SEMVER}.exe
|
||||
environment:
|
||||
WORKFLOW_NUM: << pipeline.number >>
|
||||
|
||||
workflows:
|
||||
build:
|
||||
jobs:
|
||||
- build-connector:
|
||||
context: digicert-keylocker
|
||||
- build-visual
|
||||
- build-installer:
|
||||
context: digicert-keylocker
|
||||
requires:
|
||||
- build-connector
|
||||
- build-visual
|
||||
deploy:
|
||||
jobs:
|
||||
- build-connector:
|
||||
filters: &deploy_filter
|
||||
branches:
|
||||
ignore: /.*/
|
||||
tags:
|
||||
only: /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-\w{1,10})?$/
|
||||
context: digicert-keylocker
|
||||
- build-visual:
|
||||
filters: *deploy_filter
|
||||
- build-installer:
|
||||
filters: *deploy_filter
|
||||
context: digicert-keylocker
|
||||
requires:
|
||||
- build-connector
|
||||
- build-visual
|
||||
- deploy-connector-to-feed:
|
||||
filters: *deploy_filter
|
||||
requires:
|
||||
- build-installer
|
||||
context: do-spaces-speckle-releases
|
||||
@@ -334,3 +334,10 @@ ASALocalRun/
|
||||
.localhistory/
|
||||
|
||||
**/.DS_Store
|
||||
|
||||
**/dist/
|
||||
**/.tmp/
|
||||
**/webpack.statistics.*.html
|
||||
**/webpack.statistics.html
|
||||
**/Thumbs.db
|
||||
installer/
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
</h1>
|
||||
<h3 align="center">
|
||||
Data Connector for Microsoft's PowerBI platform
|
||||
Expected use case is that this data be used as source for the Speckle Visualization for PowerBI (https://github.com/specklesystems/speckle-powerbi-visuals)
|
||||
</h3>
|
||||
<p align="center"><b>Speckle</b> is the data infrastructure for the AEC industry.</p><br/>
|
||||
|
||||
@@ -53,6 +54,7 @@ Go to the [Releases](https://github.com/specklesystems/speckle-powerbi/releases)
|
||||
```
|
||||
YOUR_USER_FOLDER\Documents\Power BI Desktop\Custom Connectors\
|
||||
```
|
||||
If the folder doesn't exist, create it.
|
||||
|
||||
### Allow custom extensions to run
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30804.86
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{4DF76451-A46A-4C0B-BE03-459FAAFA07E6}") = "Speckle", "Speckle\Speckle.mproj", "{D61F9470-E614-45C7-8047-E354FF219408}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D61F9470-E614-45C7-8047-E354FF219408}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{D61F9470-E614-45C7-8047-E354FF219408}.Debug|x86.Build.0 = Debug|x86
|
||||
{D61F9470-E614-45C7-8047-E354FF219408}.Release|x86.ActiveCfg = Release|x86
|
||||
{D61F9470-E614-45C7-8047-E354FF219408}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {765772BB-45FA-4661-9573-F0F182FEB7C1}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,121 +0,0 @@
|
||||
<Project DefaultTargets="BuildExtension" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0b5fe03d-aad9-4bc4-9edf-b543d5e50d29}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>MyRootNamespace</RootNamespace>
|
||||
<AssemblyName>MyAssemblyName</AssemblyName>
|
||||
<EnableUnmanagedDebugging>False</EnableUnmanagedDebugging>
|
||||
<AllowNativeQuery>False</AllowNativeQuery>
|
||||
<AsAction>False</AsAction>
|
||||
<FastCombine>False</FastCombine>
|
||||
<ClearLog>False</ClearLog>
|
||||
<ShowEngineTraces>False</ShowEngineTraces>
|
||||
<ShowUserTraces>False</ShowUserTraces>
|
||||
<LegacyRedirects>False</LegacyRedirects>
|
||||
<SuppressRowErrors>False</SuppressRowErrors>
|
||||
<SuppressCellErrors>False</SuppressCellErrors>
|
||||
<MaxRows>1000</MaxRows>
|
||||
<ExtensionProject>Yes</ExtensionProject>
|
||||
<Name>Speckle</Name>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<!--Should be true, fix this when the debugger is implemented -->
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Speckle.pq">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SpeckleLogo16.png">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SpeckleLogo20.png">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SpeckleLogo24.png">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SpeckleLogo32.png">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SpeckleLogo40.png">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SpeckleLogo48.png">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SpeckleLogo64.png">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SpeckleLogo80.png">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="resources.resx">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Content Include="Speckle.query.pq">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<UsingTask TaskName="BuildExtension" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
|
||||
<ParameterGroup>
|
||||
<InputDirectory ParameterType="System.String" Required="true" />
|
||||
<OutputFile ParameterType="System.String" Required="true" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Using Namespace="System.Globalization" />
|
||||
<Using Namespace="System.IO.Compression " />
|
||||
<Code Type="Fragment" Language="cs"><![CDATA[
|
||||
using(FileStream fileStream = File.Create(OutputFile))
|
||||
using(ZipArchive archiveOut = new ZipArchive(fileStream, ZipArchiveMode.Create, false))
|
||||
{
|
||||
foreach(string fullPath in Directory.EnumerateFiles(InputDirectory))
|
||||
{
|
||||
string filename = Path.GetFileName(fullPath);
|
||||
|
||||
archiveOut.CreateEntryFromFile(fullPath, filename, CompressionLevel.Optimal);
|
||||
}
|
||||
}
|
||||
]]></Code>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
<Target Name="BuildExtension" DependsOnTargets="ExtensionClean">
|
||||
<ItemGroup>
|
||||
<PQFiles Include="@(Compile)" Condition="'%(Extension)' == '.pq'" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<NonPQFiles Include="@(Compile)" Condition="'%(Extension)' != '.pq'" />
|
||||
</ItemGroup>
|
||||
<MakeDir Directories="$(IntermediateOutputPath)" />
|
||||
<MakeDir Directories="$(OutputPath)" />
|
||||
<Copy SourceFiles="@(NonPQFiles)" DestinationFolder="$(IntermediateOutputPath)" />
|
||||
<Copy SourceFiles="@(PQFiles)" DestinationFiles="@(PQFiles->'$(IntermediateOutputPath)%(RecursiveDir)%(FileName).m')" />
|
||||
<BuildExtension InputDirectory="$(IntermediateOutputPath)" OutputFile="$(OutputPath)\$(ProjectName).mez" />
|
||||
<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="$(OutputPath)\$(ProjectName).mez" DestinationFolder="$(UserProfile)\Documents\Power BI Desktop\Custom Connectors">
|
||||
</Copy>
|
||||
</Target>
|
||||
<Target Name="ExtensionClean">
|
||||
<!-- Remove obj folder -->
|
||||
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
|
||||
<!-- Remove bin folder -->
|
||||
<RemoveDir Directories="$(OutputPath)" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,201 +0,0 @@
|
||||
section Speckle;
|
||||
|
||||
/* This is an additional nav bar that can display branches of a stream: not using this for now
|
||||
[DataSource.Kind="Speckle", Publish="Speckle.Publish"]
|
||||
shared Speckle.Contents = Value.ReplaceType(NavigationTable.Simple, type function (url as Uri.Type) as any);
|
||||
|
||||
// set up nav table
|
||||
shared NavigationTable.Simple = (url) as table =>
|
||||
let
|
||||
baseUrl = Uri.Parts(url)[Host] as text,
|
||||
streamId = Text.Split(Uri.Parts(url)[Path], "/"){2},
|
||||
objects = Speckle.GetBranches(baseUrl, streamId),
|
||||
table = #table(
|
||||
{"Name", "Key", "Data", "ItemKind", "ItemName", "IsLeaf"},
|
||||
List.InsertRange(objects, List.Count(objects), {{"GetCommit", "GetCommit", Speckle.GetObjectFromObject(baseUrl, streamId), "Function", "Function", true}})
|
||||
),
|
||||
NavTable = Table.ToNavigationTable(table, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
|
||||
in
|
||||
NavTable;
|
||||
|
||||
Speckle.GetBranches = (url, id) =>
|
||||
let
|
||||
Source = Web.Contents(
|
||||
Text.Combine({"https:/", url, "graphql"}, "/"),
|
||||
[
|
||||
Headers=[
|
||||
#"Method"="POST",
|
||||
#"Content-Type"="application/json"
|
||||
],
|
||||
Content=Text.ToBinary("{""query"": ""query { stream( id: \"""&id&"\"" ) { branches { items { name commits { items { id message sourceApplication authorName createdAt } } } } } }""}")
|
||||
]
|
||||
),
|
||||
#"JSON" = Json.Document(Source),
|
||||
branches = #"JSON"[data][stream][branches][items],
|
||||
branchList = List.Generate(
|
||||
() => [x = 0, y = Speckle.GetBranchAsList(branches{x})],
|
||||
each [x] < List.Count(branches),
|
||||
each [x = [x] + 1, y = Speckle.GetBranchAsList(branches{x})],
|
||||
each [y]
|
||||
)
|
||||
in
|
||||
branchList;
|
||||
|
||||
Speckle.GetBranchAsList = (branchRecord) =>
|
||||
let
|
||||
commits = Table.FromRecords(branchRecord[commits][items]),
|
||||
list = {branchRecord[name], branchRecord[name], commits, "Table", "Table", true}
|
||||
in
|
||||
list;
|
||||
*/
|
||||
|
||||
[DataSource.Kind="Speckle", Publish="Speckle.Publish"]
|
||||
shared Speckle.Contents = Value.ReplaceType(CommitTable, type function (StreamUrl as Uri.Type) as any);
|
||||
|
||||
shared CommitTable = (url) as table =>
|
||||
let
|
||||
// Get server and streamId, and branchName / commitId / objectid from the input url
|
||||
server = Text.Combine({"https://", Uri.Parts(url)[Host]}),
|
||||
segments = Text.Split(Text.AfterDelimiter(Uri.Parts(url)[Path], "/", 0), "/"),
|
||||
streamId = segments{1},
|
||||
branchName = if( List.Count(segments) = 4 and segments{2} = "branches" ) then segments{3} else null,
|
||||
commitId = if (List.Count(segments) = 4 and segments{2} = "commits" ) then segments{3} else null,
|
||||
objectId = if (List.Count(segments) = 4 and segments{2} = "objects" ) then segments{3} else null,
|
||||
|
||||
commitTable = if (commitId <> null) then Speckle.GetObjectFromCommit(server, streamId, commitId)
|
||||
else if (objectId <> null) then Speckle.GetObjectFromObject(server, streamId, objectId, false)
|
||||
else if (branchName <> null) then #table( { "Error" }, { { "Invalid URL, use a stream or commit or object url" } } ) // currently not implemented, see reason below
|
||||
else Speckle.GetObjectFromStream(server, streamId)
|
||||
in
|
||||
commitTable;
|
||||
|
||||
Speckle.GetObjectFromStream = (server, streamId) =>
|
||||
let
|
||||
branchName = "main",
|
||||
Source = Web.Contents(
|
||||
Text.Combine({server, "graphql"}, "/"),
|
||||
[
|
||||
Headers=[
|
||||
#"Method"="POST",
|
||||
#"Content-Type"="application/json"
|
||||
],
|
||||
Content=Text.ToBinary("{""query"": ""query { stream( id: \"""&streamId&"\"" ) { branch (name: \"""&branchName&"\""){ commits (limit: 1) { items { referencedObject } } } } }""}")
|
||||
]
|
||||
),
|
||||
#"JSON" = Json.Document(Source),
|
||||
objectId = #"JSON"[data][stream][branch][commits][items]{0}[referencedObject],
|
||||
objectsTable = Speckle.GetObjectFromObject(server, streamId, objectId, true)
|
||||
in
|
||||
objectsTable;
|
||||
|
||||
/* Not implemented since power query M uri does not have a decode method...def not manually writing a method to handle special chars and emojis
|
||||
Speckle.GetObjectFromBranch = (server, streamId, branchName) =>
|
||||
let
|
||||
Source = Web.Contents(
|
||||
Text.Combine({server, "graphql"}, "/"),
|
||||
[
|
||||
Headers=[
|
||||
#"Method"="POST",
|
||||
#"Content-Type"="application/json"
|
||||
],
|
||||
Content=Text.ToBinary("{""query"": ""query { stream( id: \"""&streamId&"\"" ) { branch (name: \"""&branchName&"\""){ commits (limit: 1) { items { referencedObject } } } } }""}")
|
||||
]
|
||||
),
|
||||
#"JSON" = Json.Document(Source),
|
||||
objectId = #"JSON"[data][stream][branch][commits][items]{0}[referencedObject],
|
||||
objectsTable = Speckle.GetObjectFromObject(server, streamId, objectId)
|
||||
in
|
||||
objectsTable;
|
||||
*/
|
||||
|
||||
shared Speckle.GetObjectFromCommit = (server, streamId, commitId) =>
|
||||
let
|
||||
Source = Web.Contents(
|
||||
Text.Combine({server, "graphql"}, "/"),
|
||||
[
|
||||
Headers=[
|
||||
#"Method"="POST",
|
||||
#"Content-Type"="application/json"
|
||||
],
|
||||
Content=Text.ToBinary("{""query"": ""query { stream( id: \"""&streamId&"\"" ) { commit (id: \"""&commitId&"\""){ referencedObject } } }""}")
|
||||
]
|
||||
),
|
||||
#"JSON" = Json.Document(Source),
|
||||
objectId = #"JSON"[data][stream][commit][referencedObject],
|
||||
objectsTable = Speckle.GetObjectFromObject(server, streamId, objectId, true)
|
||||
in
|
||||
objectsTable;
|
||||
|
||||
Speckle.GetObjectFromObject = (server, streamId, objectId, IsCommitObject) =>
|
||||
let
|
||||
query = if (IsCommitObject) then "{""query"": ""query { stream( id: \"""&streamId&"\"" ) { object (id: \"""&objectId&"\"") { children { objects { data } } } } }""}"
|
||||
else "{""query"": ""query { stream( id: \"""&streamId&"\"" ) { object (id: \"""&objectId&"\"") { data } } }""}",
|
||||
Source = Web.Contents(
|
||||
Text.Combine({server, "graphql"}, "/"),
|
||||
[
|
||||
Headers=[
|
||||
#"Method"="POST",
|
||||
#"Content-Type"="application/json"
|
||||
],
|
||||
Content=Text.ToBinary(query)
|
||||
]
|
||||
),
|
||||
#"JSON" = Json.Document(Source),
|
||||
objects = if (IsCommitObject) then #"JSON"[data][stream][object][children][objects]
|
||||
else {#"JSON"[data][stream][object][data]},
|
||||
objectsTable = Table.FromRecords(objects)
|
||||
in
|
||||
objectsTable;
|
||||
|
||||
// Data Source Kind description
|
||||
Speckle = [
|
||||
Authentication = [
|
||||
Key = [
|
||||
KeyLabel="Personal Access Token",
|
||||
Label = "Private stream"
|
||||
],
|
||||
Implicit = [
|
||||
Label = "Public stream"
|
||||
]
|
||||
],
|
||||
Label = Extension.LoadString("Speckle Connector")
|
||||
];
|
||||
|
||||
// Data Source UI publishing description
|
||||
Speckle.Publish = [
|
||||
Beta = true,
|
||||
Category = "Other",
|
||||
ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
|
||||
LearnMoreUrl = "https://speckle.guide",
|
||||
SourceImage = Speckle.Icons,
|
||||
SourceTypeImage = Speckle.Icons
|
||||
];
|
||||
|
||||
Speckle.Icons = [
|
||||
Icon16 = { Extension.Contents("SpeckleLogo16.png"), Extension.Contents("SpeckleLogo20.png"), Extension.Contents("SpeckleLogo24.png"), Extension.Contents("SpeckleLogo32.png") },
|
||||
Icon32 = { Extension.Contents("SpeckleLogo32.png"), Extension.Contents("SpeckleLogo40.png"), Extension.Contents("SpeckleLogo48.png"), Extension.Contents("SpeckleLogo64.png") }
|
||||
];
|
||||
|
||||
// copy and pasted function from microsoft docs since it's not included yet in M standard lib
|
||||
Table.ToNavigationTable = (
|
||||
table as table,
|
||||
keyColumns as list,
|
||||
nameColumn as text,
|
||||
dataColumn as text,
|
||||
itemKindColumn as text,
|
||||
itemNameColumn as text,
|
||||
isLeafColumn as text
|
||||
) as table =>
|
||||
let
|
||||
tableType = Value.Type(table),
|
||||
newTableType = Type.AddTableKey(tableType, keyColumns, true) meta
|
||||
[
|
||||
NavigationTable.NameColumn = nameColumn,
|
||||
NavigationTable.DataColumn = dataColumn,
|
||||
NavigationTable.ItemKindColumn = itemKindColumn,
|
||||
Preview.DelayColumn = itemNameColumn,
|
||||
NavigationTable.IsLeafColumn = isLeafColumn
|
||||
],
|
||||
navigationTable = Value.ReplaceType(table, newTableType)
|
||||
in
|
||||
navigationTable;
|
||||
@@ -1,5 +0,0 @@
|
||||
// Use this file to write queries to test your data connector
|
||||
let
|
||||
result = Speckle.Contents("https://speckle.xyz/streams/5dfbeb49c9/objects/ed4748572b27cfe008f2592a44ab85f1")
|
||||
in
|
||||
result
|
||||
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"name": "root",
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DataConnector",
|
||||
"path": "src/powerbi-data-connector"
|
||||
},
|
||||
{
|
||||
"name": "Visual",
|
||||
"path": "src/powerbi-visual"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"powerquery.general.mode": "SDK",
|
||||
"powerquery.sdk.defaultQueryFile": "${workspaceFolder}\\src\\powerbi-data-connector\\Speckle.query.pq",
|
||||
"powerquery.sdk.defaultExtension": "${workspaceFolder}\\bin\\${workspaceFolderBasename}.mez",
|
||||
"files.eol": "\n",
|
||||
"files.watcherExclude": {
|
||||
"**/.git/objects/**": true,
|
||||
"**/node_modules/**": true,
|
||||
".tmp": true
|
||||
},
|
||||
"files.exclude": {
|
||||
".tmp": true
|
||||
},
|
||||
"search.exclude": {
|
||||
".tmp": true,
|
||||
"typings": true
|
||||
},
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/pbiviz.json"],
|
||||
"url": "./src/powerbi-visual/node_modules/powerbi-visuals-api/schema.pbiviz.json"
|
||||
},
|
||||
{
|
||||
"fileMatch": ["/capabilities.json"],
|
||||
"url": "./src/powerbi-visual/node_modules/powerbi-visuals-api/schema.capabilities.json"
|
||||
},
|
||||
{
|
||||
"fileMatch": ["/dependencies.json"],
|
||||
"url": "./src/powerbi-visual/node_modules/powerbi-visuals-api/schema.dependencies.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"extensions": {
|
||||
"recommendations": [
|
||||
"ms-dotnettools.csharp",
|
||||
"powerquery.vscode-powerquery-sdk"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"type": "powerquery",
|
||||
"request": "launch",
|
||||
"name": "Test powerquery file",
|
||||
"program": "${workspaceFolder}/${command:AskForPowerQueryFileName}",
|
||||
"additionalArgs": ["--logMashupEngineTraces", "user"],
|
||||
"preLaunchTask": "build"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "powerquery",
|
||||
"operation": "msbuild",
|
||||
"additionalArgs": [
|
||||
"/restore",
|
||||
"/consoleloggerparameters:NoSummary",
|
||||
"/property:GenerateFullPaths=true"
|
||||
],
|
||||
"problemMatcher": ["$msCompile"],
|
||||
"group": "build",
|
||||
"label": "build"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "tests",
|
||||
"command": "${config:powerquery.sdk.tools.location}\\PQTest.exe",
|
||||
"args": [
|
||||
"run-test",
|
||||
"--extension",
|
||||
"${config:powerquery.sdk.defaultExtension}",
|
||||
"--queryFile",
|
||||
"${workspaceFolder}\\tests",
|
||||
"--prettyPrint"
|
||||
],
|
||||
"problemMatcher": [],
|
||||
"dependsOn": ["build"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
[Version = "2.0.0"]
|
||||
section Speckle;
|
||||
|
||||
AuthAppId = "spklpwerbi";
|
||||
AuthAppSecret = "spklpwerbi";
|
||||
|
||||
// The data source definition, used when connecting to any speckle server
|
||||
Speckle = [
|
||||
// This is used when running the connector on an on-premises data gateway
|
||||
TestConnection = (path) => {"Speckle.Api.GetUser", path},
|
||||
// This is the custom authentication strategy for our Connector
|
||||
Authentication = [
|
||||
OAuth = [
|
||||
Label = "Speckle Account",
|
||||
StartLogin = (clientApplication, dataSourcePath, state, display) =>
|
||||
let
|
||||
server = Text.Combine(
|
||||
{Uri.Parts(dataSourcePath)[Scheme], "://", 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(
|
||||
{Uri.Parts(dataSourcePath)[Scheme], "://", Uri.Parts(dataSourcePath)[Host]}
|
||||
),
|
||||
Parts = Uri.Parts(callbackUri)[Query],
|
||||
Source = Web.Contents(
|
||||
Text.Combine({server, "auth", "token"}, "/"),
|
||||
[
|
||||
Headers = [
|
||||
#"Content-Type" = "application/json"
|
||||
],
|
||||
Content = Json.FromValue(
|
||||
[
|
||||
accessCode = Parts[access_code],
|
||||
appId = AuthAppId,
|
||||
appSecret = AuthAppSecret,
|
||||
challenge = state
|
||||
]
|
||||
)
|
||||
]
|
||||
),
|
||||
json = Json.Document(Source)
|
||||
in
|
||||
[
|
||||
access_token = json[token],
|
||||
scope = null,
|
||||
token_type = "bearer",
|
||||
refresh_token = json[refreshToken]
|
||||
],
|
||||
Refresh = (dataSourcePath, refreshToken) =>
|
||||
let
|
||||
server = Text.Combine(
|
||||
{Uri.Parts(dataSourcePath)[Scheme], "://", Uri.Parts(dataSourcePath)[Host]}
|
||||
),
|
||||
Source = Web.Contents(
|
||||
Text.Combine({server, "auth", "token"}, "/"),
|
||||
[
|
||||
Headers = [
|
||||
#"Content-Type" = "application/json"
|
||||
],
|
||||
Content = Json.FromValue(
|
||||
[
|
||||
refreshToken = refreshToken,
|
||||
appId = AuthAppId,
|
||||
appSecret = AuthAppSecret
|
||||
]
|
||||
)
|
||||
]
|
||||
),
|
||||
json = Json.Document(Source)
|
||||
in
|
||||
[
|
||||
access_token = json[token],
|
||||
scope = null,
|
||||
token_type = "bearer",
|
||||
refresh_token = json[refreshToken]
|
||||
]
|
||||
],
|
||||
Key = [
|
||||
KeyLabel = "Personal Access Token",
|
||||
Label = "Private Project"
|
||||
],
|
||||
Implicit = [
|
||||
Label = "Public Project"
|
||||
]
|
||||
],
|
||||
Label = "Speckle"
|
||||
];
|
||||
|
||||
// Gets the object referenced by a specific speckle URL
|
||||
[DataSource.Kind = "Speckle", Publish = "Get.ByUrl.Publish"]
|
||||
shared Speckle.GetByUrl.Structured = Value.ReplaceType(
|
||||
Speckle.LoadFunction("Get.ByUrl.pqm"),
|
||||
type function (
|
||||
url as (
|
||||
Uri.Type meta [
|
||||
Documentation.FieldCaption = "Gets a Speckle Object preserving it's structure",
|
||||
Documentation.FieldDescription = "The url of a model in a Speckle server project. You can copy it directly from your browser.",
|
||||
Documentation.SampleValues = {"https://app.speckle.systems/projects/23401adf/models/1234568"}
|
||||
]
|
||||
)
|
||||
) as record meta [
|
||||
Documentation.Name = "Speckle - Get Structured Object by URL",
|
||||
Documentation.LongDescription = "Returns the Speckle object the URL points to, while also preserving it's structure.
|
||||
Supports all types of model url:#(lf)
|
||||
- Model: will get the latest version of the specified model (i.e. 'https://app.speckle.systems/projects/PROJECT_ID/models/MODEL_ID')#(lf)
|
||||
- Version: will get a specific version from the project (i.e. 'https://app.speckle.systems/projects/PROJECT_ID/models/MODEL_ID@VERSION_ID')
|
||||
"
|
||||
]
|
||||
);
|
||||
|
||||
// [DataSource.Kind = "Speckle", Publish = "NavTable.Publish"]
|
||||
// shared Speckle.GetObjectAsNavTable = Value.ReplaceType(
|
||||
// NavigationTable.Simple, type function (url as Uri.Type) as table
|
||||
// );
|
||||
// Get's a flat list of speckle objects from a URL
|
||||
[DataSource.Kind = "Speckle", Publish = "GetByUrl.Publish"]
|
||||
shared Speckle.GetByUrl = Value.ReplaceType(
|
||||
Speckle.LoadFunction("GetByUrl.pqm"),
|
||||
type function (
|
||||
url as (
|
||||
Uri.Type meta [
|
||||
Documentation.FieldCaption = "Model URL",
|
||||
Documentation.FieldDescription = "The url of a model in a Speckle server. You can copy it directly from your browser.",
|
||||
Documentation.SampleValues = {"https://app.speckle.systems/projects/23401adf/models/1234568"}
|
||||
]
|
||||
)
|
||||
) as table meta [
|
||||
Documentation.Name = "Speckle - Get Model by URL",
|
||||
Documentation.LongDescription = "Returns a flat list of all objects contained in a Speckle model/version of a specific a project.
|
||||
Supports all types of model url:#(lf)
|
||||
- Model: will get the latest version of the specified model (i.e. 'https://app.speckle.systems/projects/PROJECT_ID/models/MODEL_ID')#(lf)
|
||||
- Version: will get a specific version from the project (i.e. 'https://app.speckle.systems/projects/PROJECT_ID/models/MODEL_ID@VERSION_ID')
|
||||
"
|
||||
]
|
||||
);
|
||||
|
||||
// Gets the current authenticated user, if any
|
||||
[DataSource.Kind = "Speckle"]
|
||||
shared Speckle.Api.GetUser = Value.ReplaceType(
|
||||
Speckle.LoadFunction("Api.GetUser.pqm"), type function (url as Uri.Type) as record
|
||||
);
|
||||
|
||||
// Generic fetch function to our GraphQL endpoint
|
||||
[DataSource.Kind = "Speckle"]
|
||||
shared Speckle.Api.Fetch = Value.ReplaceType(
|
||||
Speckle.LoadFunction("Api.Fetch.pqm"),
|
||||
type function (url as Uri.Type, optional query as text, optional variables as record) as record
|
||||
);
|
||||
|
||||
// Parses a stream url and returns a record with the type and values
|
||||
[DataSource.Kind = "Speckle"]
|
||||
shared Speckle.ParseUrl = Value.ReplaceType(
|
||||
Speckle.LoadFunction("ParseStreamUrl.pqm"), type function (url as Uri.Type) as record
|
||||
);
|
||||
|
||||
// [DataSource.Kind = "Speckle"]
|
||||
// shared Speckle.Api.REST.GetObject = Value.ReplaceType(
|
||||
// Speckle.LoadFunction("Api.REST.GetObject.pqm"),
|
||||
// type function (url as Uri.Type, optional streamId as text, optional objectId as text) as list
|
||||
// );
|
||||
Get.ByUrl.Publish = GetPublish("GetStream");
|
||||
|
||||
NavTable.Publish = GetPublish("GetObjectAsNavTable");
|
||||
|
||||
GetByUrl.Publish = GetPublish("GetByUrl");
|
||||
|
||||
GetPublish = Speckle.LoadFunction("GetPublish.pqm");
|
||||
|
||||
// Navigation table utility function
|
||||
Table.ToNavigationTable = Speckle.LoadFunction("Table.ToNavigationTable.pqm");
|
||||
|
||||
// Function to load `pqm` files
|
||||
shared Speckle.LoadFunction = (fileName as text) =>
|
||||
let
|
||||
binary = Extension.Contents(fileName), asText = Text.FromBinary(binary)
|
||||
in
|
||||
try
|
||||
Expression.Evaluate(asText, #shared) catch (e) =>
|
||||
error
|
||||
[
|
||||
Reason = "Speckle.LoadFunction Failure",
|
||||
Message.Format = "Loading '#{0}' failed - '#{1}': '#{2}'",
|
||||
Message.Parameters = {fileName, e[Reason], e[Message]},
|
||||
Detail = [File = fileName, Error = e]
|
||||
];
|
||||
|
||||
shared Speckle.Revit.Parameters.ToNameValueRecord = (r as record, optional exclude as list) as record =>
|
||||
let
|
||||
defaultExclude = {"id", "speckle_type", "applicationId", "totalChildrenCount"},
|
||||
fullExclusion = if exclude = null then defaultExclude else List.Union(defaultExclude, exclude),
|
||||
clean = Record.RemoveFields(r, fullExclusion, MissingField.Ignore),
|
||||
recTable = Record.ToTable(clean),
|
||||
cleanTable = Table.RemoveColumns(recTable, "Name"),
|
||||
expanded = Table.ExpandRecordColumn(
|
||||
cleanTable, "Value", {"name", "value", "applicationInternalName"}, {"Name", "Value", "UID"}
|
||||
),
|
||||
joined = Table.AddColumn(expanded, "Combo", each [Name] & " [" & [UID] & "]"),
|
||||
renamed = Table.RenameColumns(joined, {{"Name", "x"}, {"Combo", "Name"}}),
|
||||
result = Record.FromTable(renamed)
|
||||
in
|
||||
result;
|
||||
|
||||
shared Speckle.Utils.DynamicColumnExpand = (tbl as table, col as text) as table =>
|
||||
let
|
||||
uniqueFields = List.Distinct(List.Combine(List.Transform(Table.Column(tbl, col), Record.FieldNames))),
|
||||
expanded = Table.ExpandRecordColumn(tbl, col, uniqueFields)
|
||||
in
|
||||
expanded;
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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>
|
||||
<IsContinuousIntegrationBuild>false</IsContinuousIntegrationBuild>
|
||||
</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"
|
||||
Condition="$(IsContinuousIntegrationBuild) == 'false'">
|
||||
<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>
|
||||
@@ -0,0 +1,7 @@
|
||||
// Use this file to write queries to test your data connector
|
||||
let
|
||||
result = Speckle.GetByUrl(
|
||||
"https://app.speckle.systems/projects/e2988234fb/models/60b2300470@b1f31a351a,60b2300470"
|
||||
)
|
||||
in
|
||||
result
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
@@ -22,8 +22,10 @@
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing"
|
||||
mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework
|
||||
object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
@@ -59,7 +61,8 @@
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
@@ -112,18 +115,65 @@
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0,
|
||||
Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0,
|
||||
Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ButtonHelp" xml:space="preserve">
|
||||
<value>Connect to Speckle</value>
|
||||
</data>
|
||||
<data name="ButtonTitle" xml:space="preserve">
|
||||
<value>Speckle</value>
|
||||
</data>
|
||||
<data name="DataSourceLabel" xml:space="preserve">
|
||||
<value>Speckle</value>
|
||||
</data>
|
||||
<data name="GetByUrl.Help" xml:space="preserve">
|
||||
<value>Connect to Speckle by Model URL</value>
|
||||
</data>
|
||||
<data name="GetByUrl.Label" xml:space="preserve">
|
||||
<value>Speckle</value>
|
||||
</data>
|
||||
<data name="GetByUrl.Title" xml:space="preserve">
|
||||
<value>Speckle - Get Model by URL</value>
|
||||
</data>
|
||||
<data name="GetObjFromBranch.Help" xml:space="preserve">
|
||||
<value>Connect to Speckle by server URL, stream ID and branch name</value>
|
||||
</data>
|
||||
<data name="GetObjFromBranch.Label" xml:space="preserve">
|
||||
<value>Get the latest commit from a stream's branch</value>
|
||||
</data>
|
||||
<data name="GetObjFromBranch.Title" xml:space="preserve">
|
||||
<value>Speckle - Get Stream branch</value>
|
||||
</data>
|
||||
<data name="GetObjFromCommit.Help" xml:space="preserve">
|
||||
<value>Connect to Speckle by server URL, stream ID and commit ID</value>
|
||||
</data>
|
||||
<data name="GetObjFromCommit.Label" xml:space="preserve">
|
||||
<value>A label</value>
|
||||
</data>
|
||||
<data name="GetObjFromCommit.Title" xml:space="preserve">
|
||||
<value>Speckle - Get Stream commit</value>
|
||||
</data>
|
||||
<data name="GetStream.Help" xml:space="preserve">
|
||||
<value>Connect to Speckle by server URL and stream ID</value>
|
||||
</data>
|
||||
<data name="GetStream.Label" xml:space="preserve">
|
||||
<value>Speckle</value>
|
||||
</data>
|
||||
<data name="GetStream.Title" xml:space="preserve">
|
||||
<value>Speckle - Get Model by URL [Structured]</value>
|
||||
</data>
|
||||
<data name="GetObjectAsNavTable.Title" xml:space="preserve">
|
||||
<value>Speckle - Get Object as NavTable</value>
|
||||
</data>
|
||||
<data name="GetObjectAsNavTable.Label" xml:space="preserve">
|
||||
<value>Speckle</value>
|
||||
</data>
|
||||
<data name="GetObjectAsNavTable.Help" xml:space="preserve">
|
||||
<value>Returns a navigation table for a given object</value>
|
||||
</data>
|
||||
<data name="Traverse.Title" xml:space="preserve">
|
||||
<value>Traverse an object and populate refs</value>
|
||||
</data>
|
||||
<data name="Traverse.Label" xml:space="preserve">
|
||||
<value>Traverse</value>
|
||||
</data>
|
||||
<data name="Traverse.Help" xml:space="preserve">
|
||||
<value>Traverse help</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,48 @@
|
||||
let
|
||||
Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
|
||||
CommitReceived = Extension.LoadFunction("Api.CommitReceived.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, streamId as text, branchName as text, limit as number) as list =>
|
||||
let
|
||||
decodedBranchName = Record.Field(
|
||||
Record.Field(Uri.Parts("http://www.dummy.com?" & Uri.BuildQueryString([A = branchName])), "Query"),
|
||||
"A"
|
||||
),
|
||||
// Hacky way to decode base64 strings: Put them in a url query param and parse the URL
|
||||
apiKey = try Extension.CurrentCredential()[Key] otherwise null,
|
||||
query = "query($streamId: String!, $branchName: String!, $limit: Int!) {
|
||||
stream( id: $streamId ) {
|
||||
branch (name: $branchName ){
|
||||
commits (limit: $limit) {
|
||||
items {
|
||||
id
|
||||
referencedObject
|
||||
sourceApplication
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}",
|
||||
res = Fetch(server, query, [streamId = streamId, branchName = decodedBranchName, limit = limit]),
|
||||
branch = res[stream][branch],
|
||||
commits = branch[commits][items]
|
||||
in
|
||||
if branch = null then
|
||||
error Text.Format("The branch '#{0}' does not exist in stream '#{1}'", {decodedBranchName, streamId})
|
||||
else if List.Count(branch[commits][items]) = 0 then
|
||||
error Text.Format("The branch '#{0}' in stream #{1} has no commits", {decodedBranchName, streamId})
|
||||
else
|
||||
commits
|
||||
@@ -0,0 +1,47 @@
|
||||
let
|
||||
Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
|
||||
Traverse = Extension.LoadFunction("Traverse.pqm"),
|
||||
GetObject = Extension.LoadFunction("Api.GetObject.pqm"),
|
||||
GetStreamCommit = Extension.LoadFunction("Get.StreamCommit.pqm"),
|
||||
GetBranchCommits = Extension.LoadFunction("Get.BranchCommits.pqm"),
|
||||
CommitReceived = Extension.LoadFunction("Api.CommitReceived.pqm"),
|
||||
ParseStreamUrl = Extension.LoadFunction("ParseStreamUrl.pqm"),
|
||||
CleanUpObject = Extension.LoadFunction("CleanUpObject.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
|
||||
(url as text) as record =>
|
||||
let
|
||||
// Get server and streamId, and branchName / commitId / objectid from the input url
|
||||
stream = ParseStreamUrl(url),
|
||||
id = stream[id],
|
||||
server = stream[server],
|
||||
commit =
|
||||
if (stream[urlType] = "Stream") then
|
||||
GetBranchCommits(server, id, "main", 1){0}
|
||||
else if (stream[urlType] = "Branch") then
|
||||
GetBranchCommits(server, id, stream[branch], 1){0}
|
||||
else if (stream[urlType] = "Commit") then
|
||||
GetStreamCommit(server, id, stream[commit])
|
||||
else
|
||||
//We deal with object URLs directly
|
||||
[referencedObject = stream[object]],
|
||||
object = GetObject(server, id, commit[referencedObject]),
|
||||
rr = CommitReceived(server, id, commit),
|
||||
result = Traverse(CleanUpObject(object) meta [server = server, stream = id, commit = commit])
|
||||
in
|
||||
if rr then
|
||||
result
|
||||
else
|
||||
result
|
||||
@@ -0,0 +1,36 @@
|
||||
let
|
||||
Fetch = Extension.LoadFunction("Api.Fetch.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, streamId as text, commitId as text) as record =>
|
||||
let
|
||||
apiKey = try Extension.CurrentCredential()[Key] otherwise null,
|
||||
query = "query($streamId: String!, $commitId: String!) {
|
||||
stream( id: $streamId ) {
|
||||
commit (id: $commitId) {
|
||||
id
|
||||
sourceApplication
|
||||
referencedObject
|
||||
}
|
||||
}
|
||||
}",
|
||||
variables = [streamId = streamId, commitId = commitId],
|
||||
#"JSON" = Fetch(server, query, variables),
|
||||
commit = #"JSON"[stream][commit]
|
||||
in
|
||||
if commit = null then
|
||||
error "The commit did not exist on this stream"
|
||||
else
|
||||
commit
|
||||
@@ -0,0 +1,64 @@
|
||||
(appName as text) =>
|
||||
let
|
||||
replaced = Text.Replace(appName, " ", ""), name = Text.Lower(replaced)
|
||||
in
|
||||
if Text.Contains(name, "dynamo") then
|
||||
"dynamo"
|
||||
else if Text.Contains(name, "revit") then
|
||||
"revit"
|
||||
else if Text.Contains(name, "autocad") then
|
||||
"autocad"
|
||||
else if Text.Contains(name, "civil") then
|
||||
"civil"
|
||||
else if Text.Contains(name, "rhino") then
|
||||
"rhino"
|
||||
else if Text.Contains(name, "grasshopper") then
|
||||
"grasshopper"
|
||||
else if Text.Contains(name, "unity") then
|
||||
"unity"
|
||||
else if Text.Contains(name, "gsa") then
|
||||
"gsa"
|
||||
else if Text.Contains(name, "microstation") then
|
||||
"microstation"
|
||||
else if Text.Contains(name, "openroads") then
|
||||
"openroads"
|
||||
else if Text.Contains(name, "openrail") then
|
||||
"openrail"
|
||||
else if Text.Contains(name, "openbuildings") then
|
||||
"openbuildings"
|
||||
else if Text.Contains(name, "etabs") then
|
||||
"etabs"
|
||||
else if Text.Contains(name, "sap") then
|
||||
"sap"
|
||||
else if Text.Contains(name, "csibridge") then
|
||||
"csibridge"
|
||||
else if Text.Contains(name, "safe") then
|
||||
"safe"
|
||||
else if Text.Contains(name, "teklastructures") then
|
||||
"teklastructures"
|
||||
else if Text.Contains(name, "dxf") then
|
||||
"dxf"
|
||||
else if Text.Contains(name, "excel") then
|
||||
"excel"
|
||||
else if Text.Contains(name, "unreal") then
|
||||
"unreal"
|
||||
else if Text.Contains(name, "powerbi") then
|
||||
"powerbi"
|
||||
else if Text.Contains(name, "blender") then
|
||||
"blender"
|
||||
else if Text.Contains(name, "qgis") then
|
||||
"qgis"
|
||||
else if Text.Contains(name, "arcgis") then
|
||||
"arcgis"
|
||||
else if Text.Contains(name, "sketchup") then
|
||||
"sketchup"
|
||||
else if Text.Contains(name, "archicad") then
|
||||
"archicad"
|
||||
else if Text.Contains(name, "topsolid") then
|
||||
"topsolid"
|
||||
else if Text.Contains(name, "python") then
|
||||
"python"
|
||||
else if Text.Contains(name, "net") then
|
||||
"net"
|
||||
else
|
||||
"other"
|
||||
@@ -0,0 +1,58 @@
|
||||
let
|
||||
Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
|
||||
GetObject = Extension.LoadFunction("Api.GetObject.pqm"),
|
||||
GetAllObjectChildren = Extension.LoadFunction("Api.GetAllObjectChildren.pqm"),
|
||||
GetObjectFromCommit = Extension.LoadFunction("GetObjectFromCommit.pqm"),
|
||||
GetObjectFromBranch = Extension.LoadFunction("GetObjectFromBranch.pqm"),
|
||||
CommitReceived = Extension.LoadFunction("Api.CommitReceived.pqm"),
|
||||
ParseStreamUrl = Extension.LoadFunction("ParseStreamUrl.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
|
||||
(url as text) as table =>
|
||||
let
|
||||
// Get server and streamId, and branchName / commitId / objectid from the input url
|
||||
stream = ParseStreamUrl(url),
|
||||
id = stream[id],
|
||||
server = stream[server],
|
||||
commitObjectsTable =
|
||||
if (stream[urlType] = "Commit") then
|
||||
GetObjectFromCommit(server, id, stream[commit])
|
||||
else if (stream[urlType] = "Object") then
|
||||
GetAllObjectChildren(server, id, stream[object])
|
||||
else if (stream[urlType] = "Branch") then
|
||||
GetObjectFromBranch(server, id, stream[branch])
|
||||
else
|
||||
GetObjectFromBranch(server, id, "main"),
|
||||
addStreamUrl = Table.AddColumn(commitObjectsTable, "Model URL", each server & "/streams/" & id),
|
||||
addParentObjectId = Table.AddColumn(
|
||||
addStreamUrl, "Version 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, {
|
||||
"Model URL",
|
||||
"URL Type",
|
||||
"Version Object ID",
|
||||
"Object ID",
|
||||
"speckle_type",
|
||||
"data"
|
||||
}
|
||||
)
|
||||
in
|
||||
final
|
||||
@@ -0,0 +1,55 @@
|
||||
let
|
||||
Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
|
||||
GetAllObjectChildren = Extension.LoadFunction("Api.GetAllObjectChildren.pqm"),
|
||||
CommitReceived = Extension.LoadFunction("Api.CommitReceived.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, streamId as text, branchName as text) as table =>
|
||||
let
|
||||
decodedBranchName = Record.Field(
|
||||
Record.Field(Uri.Parts("http://www.dummy.com?" & Uri.BuildQueryString([A = branchName])), "Query"),
|
||||
"A"
|
||||
),
|
||||
// Hacky way to decode base64 strings: Put them in a url query param and parse the URL
|
||||
apiKey = try Extension.CurrentCredential()[Key] otherwise null,
|
||||
query = "query($streamId: String!, $branchName: String!) {
|
||||
stream( id: $streamId ) {
|
||||
branch (name: $branchName ){
|
||||
commits (limit: 1) {
|
||||
items {
|
||||
id
|
||||
referencedObject
|
||||
sourceApplication
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}",
|
||||
res = Fetch(server, query, [streamId = streamId, branchName = decodedBranchName]),
|
||||
branch = res[stream][branch],
|
||||
commit = branch[commits][items]{0},
|
||||
objectsTable = GetAllObjectChildren(server, streamId, commit[referencedObject]),
|
||||
rr = CommitReceived(server, streamId, commit)
|
||||
in
|
||||
if branch = null then
|
||||
error Text.Format("The branch '#{0}' does not exist in stream '#{1}'", {decodedBranchName, streamId})
|
||||
else if List.Count(branch[commits][items]) = 0 then
|
||||
error Text.Format("The branch '#{0}' in stream #{1} has no commits", {decodedBranchName, streamId})
|
||||
else
|
||||
// Force evaluation of read receipt (ideally it should happen after fetching, but can't find a way)
|
||||
if rr then
|
||||
objectsTable
|
||||
else
|
||||
objectsTable
|
||||
@@ -0,0 +1,43 @@
|
||||
let
|
||||
Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
|
||||
GetAllObjectChildren = Extension.LoadFunction("Api.GetAllObjectChildren.pqm"),
|
||||
CommitReceived = Extension.LoadFunction("Api.CommitReceived.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, streamId as text, commitId as text) as table =>
|
||||
let
|
||||
apiKey = try Extension.CurrentCredential()[Key] otherwise null,
|
||||
query = "query($streamId: String!, $commitId: String!) {
|
||||
stream( id: $streamId ) {
|
||||
commit (id: $commitId) {
|
||||
id
|
||||
sourceApplication
|
||||
referencedObject
|
||||
authorId
|
||||
}
|
||||
}
|
||||
}",
|
||||
variables = [streamId = streamId, commitId = commitId],
|
||||
#"JSON" = Fetch(server, query, variables),
|
||||
commit = #"JSON"[stream][commit],
|
||||
objectsTable = GetAllObjectChildren(server, streamId, commit[referencedObject]),
|
||||
rr = CommitReceived(server, streamId, commit)
|
||||
in
|
||||
if commit = null then
|
||||
error "The commit did not exist on this stream"
|
||||
else if rr then
|
||||
objectsTable
|
||||
else
|
||||
objectsTable
|
||||
@@ -0,0 +1,33 @@
|
||||
let
|
||||
Speckle.Api.Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
|
||||
Speckle.LogEvent = Extension.LoadFunction("LogEvent.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, streamId, commit) =>
|
||||
let
|
||||
query = "mutation($input: CommitReceivedInput!) {
|
||||
commitReceive(input: $input)
|
||||
}",
|
||||
variables = [
|
||||
input = [
|
||||
streamId = streamId,
|
||||
commitId = commit[id],
|
||||
sourceApplication = "PowerBI"
|
||||
]
|
||||
],
|
||||
s = Speckle.LogEvent(server, commit)
|
||||
in
|
||||
// Read receipts should fail gracefully no matter what
|
||||
try Speckle.Api.Fetch(s, query, variables)[commitReceive] otherwise false
|
||||
@@ -0,0 +1,33 @@
|
||||
(server as text, optional query as text, optional variables as record) as record =>
|
||||
let
|
||||
apiKey = try Extension.CurrentCredential()[Key] otherwise null,
|
||||
defaultQuery = "query {
|
||||
activeUser {
|
||||
email
|
||||
name
|
||||
}
|
||||
serverInfo {
|
||||
name
|
||||
company
|
||||
version
|
||||
}
|
||||
}",
|
||||
Source = Web.Contents(
|
||||
Text.Combine({server, "graphql"}, "/"),
|
||||
[
|
||||
Headers = [
|
||||
#"Method" = "POST",
|
||||
#"Content-Type" = "application/json",
|
||||
#"Authorization" = if apiKey = null then "" else Text.Format("Bearer #{0}", {apiKey})
|
||||
],
|
||||
ManualStatusHandling = {400},
|
||||
Content = Json.FromValue([query = Text.From(query ?? defaultQuery), variables = variables])
|
||||
]
|
||||
),
|
||||
#"JSON" = Json.Document(Source)
|
||||
in
|
||||
// Check if response contains errors, if so, return first error.
|
||||
if Record.HasFields(#"JSON", {"errors"}) then
|
||||
error #"JSON"[errors]{0}[message]
|
||||
else
|
||||
#"JSON"[data]
|
||||
@@ -0,0 +1,46 @@
|
||||
let
|
||||
Table.GenerateByPage = Extension.LoadFunction("Table.GenerateByPage.pqm"),
|
||||
Speckle.Api.GetObjectChildren = Extension.LoadFunction("Api.GetObjectChildren.pqm"),
|
||||
Speckle.Api.GetObject = Extension.LoadFunction("Api.GetObject.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
|
||||
// Read all pages of data.
|
||||
// After every page, we check the "nextCursor" record on the metadata of the previous request.
|
||||
// Table.GenerateByPage will keep asking for more pages until we return null.
|
||||
(server as text, streamId as text, objectId as text, optional cursor as text) as table =>
|
||||
let
|
||||
parentObject = Speckle.Api.GetObject(server, streamId, objectId),
|
||||
childrenTable = Table.GenerateByPage(
|
||||
(previous) =>
|
||||
let
|
||||
// if previous is null, then this is our first page of data
|
||||
nextCursor = if (previous = null) then cursor else Value.Metadata(previous)[Cursor]?,
|
||||
// if the cursor is null but the prevous page is not, we've reached the end
|
||||
page =
|
||||
if (previous <> null and nextCursor = null) then
|
||||
null
|
||||
else
|
||||
Speckle.Api.GetObjectChildren(server, streamId, objectId, 1000, nextCursor)
|
||||
in
|
||||
page
|
||||
),
|
||||
parentTable = Table.FromRecords({[data = parentObject]}),
|
||||
resultTable =
|
||||
if (Table.ColumnCount(childrenTable) = 0) then
|
||||
parentTable
|
||||
else
|
||||
Table.Combine({parentTable, childrenTable})
|
||||
in
|
||||
resultTable meta [server = server, streamId = streamId, objectId = objectId]
|
||||
@@ -0,0 +1,32 @@
|
||||
let
|
||||
Speckle.Api.Fetch = Extension.LoadFunction("Api.Fetch.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, projectId as text, modelId as text) =>
|
||||
let
|
||||
query = "query Project($projectId: String!, $modelId: String!) {
|
||||
project(id: $projectId) {
|
||||
model(id: $modelId) {
|
||||
name
|
||||
}
|
||||
}
|
||||
}",
|
||||
variables = [
|
||||
projectId = projectId,
|
||||
modelId = modelId
|
||||
]
|
||||
in
|
||||
// Read receipts should fail gracefully no matter what
|
||||
try Speckle.Api.Fetch(server, query, variables)[project][model] otherwise null
|
||||
@@ -0,0 +1,28 @@
|
||||
let
|
||||
Speckle.Api.Fetch = Extension.LoadFunction("Api.Fetch.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, streamId as text, objectId as text) =>
|
||||
let
|
||||
query = "query($streamId: String!, $objectId: String!) {
|
||||
stream( id: $streamId ) {
|
||||
object (id: $objectId) {
|
||||
data
|
||||
}
|
||||
}
|
||||
}",
|
||||
#"JSON" = Speckle.Api.Fetch(server, query, [streamId = streamId, objectId = objectId])
|
||||
in
|
||||
#"JSON"[stream][object][data]
|
||||
@@ -0,0 +1,54 @@
|
||||
let
|
||||
Speckle.Api.Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
|
||||
Speckle.CleanUpObjects = Extension.LoadFunction("CleanUpObjects.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,
|
||||
streamId as text,
|
||||
objectId as text,
|
||||
optional limit as number,
|
||||
optional cursor as text,
|
||||
optional select as list
|
||||
) =>
|
||||
let
|
||||
query = "query($streamId: String!, $objectId: String!, $limit: Int, $cursor: String, $select: [String]) {
|
||||
stream( id: $streamId ) {
|
||||
object (id: $objectId) {
|
||||
children(select: $select, limit: $limit, cursor: $cursor) {
|
||||
cursor
|
||||
objects {
|
||||
data
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}",
|
||||
#"JSON" = Speckle.Api.Fetch(
|
||||
server,
|
||||
query,
|
||||
[
|
||||
streamId = streamId,
|
||||
objectId = objectId,
|
||||
limit = limit,
|
||||
cursor = cursor,
|
||||
select = select
|
||||
]
|
||||
),
|
||||
children = #"JSON"[stream][object][children],
|
||||
nextCursor = children[cursor],
|
||||
clean = Speckle.CleanUpObjects(children[objects])
|
||||
in
|
||||
Table.FromRecords(clean) meta [Cursor = nextCursor]
|
||||
@@ -0,0 +1,27 @@
|
||||
(url as text) =>
|
||||
let
|
||||
userType = type [name = text, email = text, id = text],
|
||||
query = "query {
|
||||
activeUser { name email id }
|
||||
}",
|
||||
// Imports
|
||||
Speckle.Api.Fetch = Extension.LoadFunction("Api.Fetch.pqm"),
|
||||
ParseUrl = Extension.LoadFunction("ParseStreamUrl.pqm"),
|
||||
urlObject = ParseUrl(url),
|
||||
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]
|
||||
],
|
||||
user = Speckle.Api.Fetch(urlObject[server], query)[activeUser]
|
||||
in
|
||||
// Read receipts should fail gracefully no matter what
|
||||
Value.ReplaceType(user, userType)
|
||||
@@ -0,0 +1,38 @@
|
||||
(server as text, optional streamId as text, optional objectId as text) as table =>
|
||||
let
|
||||
apiKey = try Extension.CurrentCredential()[Key] otherwise null,
|
||||
Source = Web.Contents(
|
||||
Text.Combine({server, "objects", streamId, objectId}, "/"),
|
||||
[
|
||||
Headers = [
|
||||
#"Method" = "GET",
|
||||
#"Content-Type" = "application/json",
|
||||
#"Authorization" = if apiKey = null then "" else Text.Format("Bearer #{0}", {apiKey})
|
||||
],
|
||||
ManualStatusHandling = {400}
|
||||
]
|
||||
),
|
||||
json = Json.Document(Source),
|
||||
clean = List.Select(json, each _[speckle_type] <> "Speckle.Core.Models.DataChunk"),
|
||||
t = Table.FromColumns({clean}, {"data"}),
|
||||
addStreamUrl = Table.AddColumn(t, "Stream URL", each server & "/streams/" & streamId),
|
||||
addObjectIdCol = Table.AddColumn(addStreamUrl, "Object ID", each try _[data][id] otherwise null),
|
||||
addSpeckleTypeCol = Table.AddColumn(
|
||||
addObjectIdCol, "speckle_type", each try _[data][speckle_type] otherwise null
|
||||
),
|
||||
Speckle.CleanUpObjects = Extension.LoadFunction("CleanUpObjects.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
|
||||
addSpeckleTypeCol
|
||||
@@ -0,0 +1,7 @@
|
||||
(object as record) as record =>
|
||||
let
|
||||
hiddenFields = {"__closure", "totalChildrenCount"},
|
||||
// remove closures from records
|
||||
clean = Record.RemoveFields(object, hiddenFields, MissingField.Ignore)
|
||||
in
|
||||
clean
|
||||
@@ -0,0 +1,17 @@
|
||||
(objects as list) as list =>
|
||||
let
|
||||
// remove closures from records, and remove DataChunk records
|
||||
removeClosureField = List.Transform(
|
||||
objects, each [data = Record.RemoveFields(_[data], "__closure", MissingField.Ignore)]
|
||||
),
|
||||
removeTotals = List.Transform(
|
||||
removeClosureField,
|
||||
each
|
||||
[
|
||||
data = try
|
||||
Record.RemoveFields(_[data], "totalChildrenCount", MissingField.Ignore) otherwise _[data]
|
||||
]
|
||||
),
|
||||
removed = List.Select(removeTotals, each _[data][speckle_type] <> "Speckle.Core.Models.DataChunk")
|
||||
in
|
||||
try removed otherwise objects
|
||||
@@ -0,0 +1,30 @@
|
||||
let
|
||||
beta = true,
|
||||
category = "Other",
|
||||
icons = [
|
||||
Icon16 = {
|
||||
Extension.Contents("SpeckleLogo16.png"),
|
||||
Extension.Contents("SpeckleLogo20.png"),
|
||||
Extension.Contents("SpeckleLogo24.png"),
|
||||
Extension.Contents("SpeckleLogo32.png")
|
||||
},
|
||||
Icon32 = {
|
||||
Extension.Contents("SpeckleLogo32.png"),
|
||||
Extension.Contents("SpeckleLogo40.png"),
|
||||
Extension.Contents("SpeckleLogo48.png"),
|
||||
Extension.Contents("SpeckleLogo64.png")
|
||||
}
|
||||
]
|
||||
in
|
||||
(key as text) as record =>
|
||||
[
|
||||
Beta = beta,
|
||||
Category = category,
|
||||
ButtonText = {
|
||||
Extension.LoadString(Text.Format("#{0}.Title", {key})),
|
||||
Extension.LoadString(Text.Format("#{0}.Label", {key}))
|
||||
},
|
||||
LearnMoreUrl = "https://speckle.guide",
|
||||
SourceImage = icons,
|
||||
SourceTypeImage = icons
|
||||
]
|
||||
@@ -0,0 +1,50 @@
|
||||
let
|
||||
GetApplicationSlug = Extension.LoadFunction("GetApplicationSlug.pqm"),
|
||||
GetUser = Extension.LoadFunction("Api.GetUser.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 any) =>
|
||||
let
|
||||
trackUrl = "https://analytics.speckle.systems/track?ip=1",
|
||||
user = GetUser(server),
|
||||
isMultiplayer = user[id] <> commit[authorId],
|
||||
body = [
|
||||
event = "Receive",
|
||||
properties = [
|
||||
server_id = Hash(server),
|
||||
token = "acd87c5a50b56df91a795e999812a3a4",
|
||||
hostApp = "powerbi",
|
||||
sourceHostApp = GetApplicationSlug(commit[sourceApplication]),
|
||||
sourceHostAppVersion = commit[sourceApplication],
|
||||
isMultiplayer = user[id] <> commit[authorId]
|
||||
]
|
||||
],
|
||||
Result = Web.Contents(
|
||||
trackUrl,
|
||||
[
|
||||
Headers = [
|
||||
#"Method" = "POST",
|
||||
#"Accept" = "text/plain",
|
||||
#"Content-Type" = "application/json"
|
||||
],
|
||||
Content = Text.ToBinary(Text.Combine({"data=", Text.FromBinary(Json.FromValue(body))}))
|
||||
]
|
||||
),
|
||||
// Hack to force execution
|
||||
Join = Text.Combine({server, Text.From(Json.Document(Result))}, "_____"),
|
||||
Disjoin = Text.Split(Join, "_____"){0}
|
||||
in
|
||||
Disjoin
|
||||
@@ -0,0 +1,81 @@
|
||||
let
|
||||
GetModel = Extension.LoadFunction("Api.GetModel.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]
|
||||
],
|
||||
IsFe2Url = (segments as list) as logical => List.Count(segments) = 4 and segments{2} = "models",
|
||||
GetUrlType = (branchName as nullable text, commitId as nullable text, objectId as nullable text) as text =>
|
||||
if (commitId <> null) then
|
||||
"Commit"
|
||||
else if (objectId <> null) then
|
||||
"Object"
|
||||
else if (branchName <> null) then
|
||||
"Branch"
|
||||
else
|
||||
"Stream",
|
||||
ParseFe1Url = (server as text, segments as list) as record =>
|
||||
let
|
||||
streamId = segments{1},
|
||||
branchName = if (List.Count(segments) = 4 and segments{2} = "branches") then segments{3} else null,
|
||||
commitId = if (List.Count(segments) = 4 and segments{2} = "commits") then segments{3} else null,
|
||||
objectId = if (List.Count(segments) = 4 and segments{2} = "objects") then segments{3} else null,
|
||||
urlType = GetUrlType(branchName, commitId, objectId)
|
||||
in
|
||||
[
|
||||
urlType = urlType,
|
||||
server = server as text,
|
||||
id = streamId as nullable text,
|
||||
branch = branchName as nullable text,
|
||||
commit = commitId as nullable text,
|
||||
object = objectId as nullable text
|
||||
],
|
||||
ParseFe2Url = (server as text, segments as list) as record =>
|
||||
let
|
||||
streamId = segments{1},
|
||||
modelList = segments{3},
|
||||
isMultimodel = Text.Contains(modelList, ","),
|
||||
firstModel = Text.Split(modelList, ","){0},
|
||||
modelAndVersion = Text.Split(firstModel, "@"),
|
||||
modelId = modelAndVersion{0},
|
||||
versionId = if (List.Count(modelAndVersion) > 1) then modelAndVersion{1} else null,
|
||||
model = if (modelId <> null) then GetModel(server, streamId, modelId) else null,
|
||||
urlType = GetUrlType(model[name], versionId, null)
|
||||
in
|
||||
if isMultimodel then
|
||||
error
|
||||
Error.Record(
|
||||
"NotSupported",
|
||||
"Multi-model URLs are not supported.",
|
||||
"Try to select just one single model in the web app and paste that in."
|
||||
)
|
||||
else
|
||||
[
|
||||
urlType = urlType,
|
||||
server = server,
|
||||
id = streamId,
|
||||
branch = model[name],
|
||||
commit = versionId,
|
||||
object = null
|
||||
]
|
||||
in
|
||||
(url as text) as record =>
|
||||
let
|
||||
// Get server and streamId, and branchName / commitId / objectid from the input url
|
||||
server = Text.Combine({Uri.Parts(url)[Scheme], "://", Uri.Parts(url)[Host]}),
|
||||
segments = Text.Split(Text.AfterDelimiter(Uri.Parts(url)[Path], "/", 0), "/"),
|
||||
isFe2 = IsFe2Url(segments)
|
||||
in
|
||||
if (isFe2) then
|
||||
ParseFe2Url(server, segments)
|
||||
else
|
||||
ParseFe1Url(server, segments)
|
||||
@@ -0,0 +1,67 @@
|
||||
let
|
||||
GetObject = Extension.LoadFunction("Api.GetObject.pqm"),
|
||||
Diagnostics.Log = Extension.LoadFunction("Diagnostics.pqm")[LogValue],
|
||||
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]
|
||||
],
|
||||
//TODO: Not implemented yet
|
||||
TraverseTable = (item as table) as table => item,
|
||||
// Will traverse an undetermined value (list, table, record).
|
||||
TraverseValue = (i as any) as any =>
|
||||
let
|
||||
item = Diagnostics.Log("Traverse value", i) meta Value.Metadata(i)
|
||||
in
|
||||
if Value.Is(item, type list) then
|
||||
// Return a transformed list by traversing all items
|
||||
Diagnostics.Log(
|
||||
"List travered",
|
||||
List.Transform(item, (a) => @TraverseValue(Value.ReplaceMetadata(a, Value.Metadata(i))))
|
||||
)
|
||||
else if Value.Is(item, type record) then
|
||||
// Traverse this record individually
|
||||
TraverseRecord(item)
|
||||
else if Value.Is(item, type table) then
|
||||
// Traverse this table
|
||||
TraverseTable(item)
|
||||
else
|
||||
// If none of the above, assume it's just a primitive type and return it as-is.
|
||||
item,
|
||||
// Traverses a generic record
|
||||
TraverseRecord = (object as record) as any =>
|
||||
let
|
||||
isSpeckle = Diagnostics.Log("Is Speckle", Record.HasFields(object, {"speckle_type"})),
|
||||
isReference = Diagnostics.Log("Is Reference", object[speckle_type] = "reference"),
|
||||
// Get the names of all fields
|
||||
fields = Record.FieldNames(object),
|
||||
// Remove all known fields that don't need traversing
|
||||
cleanFields = List.RemoveItems(fields, {"id", "speckle_type", "applicationId"}),
|
||||
// Transform the list of field names into a set of transform operations
|
||||
transformOps = List.Transform(
|
||||
cleanFields, each {_, (a) => TraverseValue(Value.ReplaceMetadata(a, Value.Metadata(object)))}
|
||||
),
|
||||
// Get the object's metadata (server and stream will be saved in here)
|
||||
info = Value.Metadata(object)
|
||||
in
|
||||
// Transform all fields and return the modified object
|
||||
if (isReference) then
|
||||
// Swap reference for call to GetObject
|
||||
() =>
|
||||
TraverseValue(
|
||||
Value.ReplaceMetadata(
|
||||
GetObject(info[server], info[stream], object[referencedId]), Value.Metadata(object)
|
||||
)
|
||||
)
|
||||
else
|
||||
try Record.TransformFields(object, transformOps, MissingField.Error) otherwise error "oopsies"
|
||||
in
|
||||
TraverseValue
|
||||
@@ -0,0 +1,2 @@
|
||||
// Use this file to write queries to test your data connector
|
||||
let result = Speckle.Api.Fetch("https://latest.speckle.dev") in Record.ToTable(result)
|
||||
@@ -0,0 +1,7 @@
|
||||
// Use this file to write queries to test your data connector
|
||||
let
|
||||
result = Speckle.Api.REST.GetObject(
|
||||
"https://latest.speckle.dev", "5f284e5c70", "85e5f250fe591ea74d8d5dc1137a9341"
|
||||
)
|
||||
in
|
||||
result
|
||||
@@ -0,0 +1,30 @@
|
||||
section UnitTestingUnitTests;
|
||||
|
||||
UT = Speckle.LoadFunction("Facts.pqm");
|
||||
Fact = UT[Fact];
|
||||
|
||||
Facts.Summarize = UT[SummarizeFacts];
|
||||
|
||||
shared Speckle.UnitTest = [
|
||||
// Put any common variables here if you only want them to be evaluated once
|
||||
// Fact(<Name of the Test>, <Expected Value>, <Actual Value>)
|
||||
// <Expected Value> and <Actual Value> can be a literal or let statement
|
||||
facts = {
|
||||
Fact(
|
||||
"Check that this function returns 'ABC'",
|
||||
// name of the test
|
||||
"ABC",
|
||||
// expected value
|
||||
UnitTesting.ReturnsABC()
|
||||
// expression to evaluate (let or single statement)
|
||||
),
|
||||
Fact("Check that this function returns '123'", "123", UnitTesting.Returns123()),
|
||||
Fact("Result should contain 5 rows", 5, Table.RowCount(UnitTesting.ReturnsTableWithFiveRows())),
|
||||
Fact("Values should be equal (using a let statement)", "Hello World", let a = "Hello World" in a)
|
||||
},
|
||||
report = Facts.Summarize(facts)
|
||||
][report];
|
||||
|
||||
shared UnitTesting.ReturnsABC = () => "ABC";
|
||||
shared UnitTesting.Returns123 = () => "123";
|
||||
shared UnitTesting.ReturnsTableWithFiveRows = () => Table.Repeat(#table({"a"}, {{1}}), 5);
|
||||
@@ -0,0 +1,2 @@
|
||||
// Use this file to write queries to test your data connector
|
||||
let result = Speckle.Get.ByUrl("https://latest.speckle.dev/streams/3d25474a18") in Record.ToTable(result)
|
||||
@@ -0,0 +1,2 @@
|
||||
// Use this file to write queries to test your data connector
|
||||
let result = Speckle.GetByUrl("https://latest.speckle.dev/streams/5f284e5c70/objects/85e5f250fe591ea74d8d5dc1137a9341") in result
|
||||
@@ -0,0 +1,376 @@
|
||||
let
|
||||
Diagnostics.LogValue = (prefix, value) =>
|
||||
Diagnostics.Trace(
|
||||
TraceLevel.Information,
|
||||
prefix & ": " & (try Diagnostics.ValueToText(value) otherwise "<error getting value>"),
|
||||
value
|
||||
),
|
||||
Diagnostics.LogValue2 = (prefix, value, result, optional delayed) =>
|
||||
Diagnostics.Trace(TraceLevel.Information, prefix & ": " & Diagnostics.ValueToText(value), result, delayed),
|
||||
Diagnostics.LogFailure = (text, function) =>
|
||||
let
|
||||
result = try function()
|
||||
in
|
||||
if result[HasError] then
|
||||
Diagnostics.LogValue2(text, result[Error], () => error result[Error], true)
|
||||
else
|
||||
result[Value],
|
||||
Diagnostics.WrapFunctionResult = (innerFunction as function, outerFunction as function) as function =>
|
||||
Function.From(Value.Type(innerFunction), (list) => outerFunction(() => Function.Invoke(innerFunction, list))),
|
||||
Diagnostics.WrapHandlers = (handlers as record) as record =>
|
||||
Record.FromList(
|
||||
List.Transform(
|
||||
Record.FieldNames(handlers),
|
||||
(h) =>
|
||||
Diagnostics.WrapFunctionResult(Record.Field(handlers, h), (fn) => Diagnostics.LogFailure(h, fn))
|
||||
),
|
||||
Record.FieldNames(handlers)
|
||||
),
|
||||
Diagnostics.ValueToText = (value) =>
|
||||
let
|
||||
_canBeIdentifier = (x) =>
|
||||
let
|
||||
keywords = {
|
||||
"and",
|
||||
"as",
|
||||
"each",
|
||||
"else",
|
||||
"error",
|
||||
"false",
|
||||
"if",
|
||||
"in",
|
||||
"is",
|
||||
"let",
|
||||
"meta",
|
||||
"not",
|
||||
"otherwise",
|
||||
"or",
|
||||
"section",
|
||||
"shared",
|
||||
"then",
|
||||
"true",
|
||||
"try",
|
||||
"type"
|
||||
},
|
||||
charAlpha = (c as number) => (c >= 65 and c <= 90) or (c >= 97 and c <= 122) or c = 95,
|
||||
charDigit = (c as number) => c >= 48 and c <= 57
|
||||
in
|
||||
try
|
||||
charAlpha(Character.ToNumber(Text.At(x, 0)))
|
||||
and List.MatchesAll(
|
||||
Text.ToList(x), (c) => let num = Character.ToNumber(c) in charAlpha(num)
|
||||
or charDigit(num)
|
||||
)
|
||||
and not List.MatchesAny(keywords, (li) => li = x) otherwise false,
|
||||
Serialize.Binary = (x) => "#binary(" & Serialize(Binary.ToList(x)) & ") ",
|
||||
Serialize.Date = (x) =>
|
||||
"#date(" & Text.From(Date.Year(x)) & ", " & Text.From(Date.Month(x)) & ", " & Text.From(Date.Day(x))
|
||||
& ") ",
|
||||
Serialize.Datetime = (x) =>
|
||||
"#datetime("
|
||||
& Text.From(Date.Year(DateTime.Date(x)))
|
||||
& ", "
|
||||
& Text.From(Date.Month(DateTime.Date(x)))
|
||||
& ", "
|
||||
& Text.From(Date.Day(DateTime.Date(x)))
|
||||
& ", "
|
||||
& Text.From(Time.Hour(DateTime.Time(x)))
|
||||
& ", "
|
||||
& Text.From(Time.Minute(DateTime.Time(x)))
|
||||
& ", "
|
||||
& Text.From(Time.Second(DateTime.Time(x)))
|
||||
& ") ",
|
||||
Serialize.Datetimezone = (x) =>
|
||||
let
|
||||
dtz = DateTimeZone.ToRecord(x)
|
||||
in
|
||||
"#datetimezone("
|
||||
& Text.From(dtz[Year])
|
||||
& ", "
|
||||
& Text.From(dtz[Month])
|
||||
& ", "
|
||||
& Text.From(dtz[Day])
|
||||
& ", "
|
||||
& Text.From(dtz[Hour])
|
||||
& ", "
|
||||
& Text.From(dtz[Minute])
|
||||
& ", "
|
||||
& Text.From(dtz[Second])
|
||||
& ", "
|
||||
& Text.From(dtz[ZoneHours])
|
||||
& ", "
|
||||
& Text.From(dtz[ZoneMinutes])
|
||||
& ") ",
|
||||
Serialize.Duration = (x) =>
|
||||
let
|
||||
dur = Duration.ToRecord(x)
|
||||
in
|
||||
"#duration("
|
||||
& Text.From(dur[Days])
|
||||
& ", "
|
||||
& Text.From(dur[Hours])
|
||||
& ", "
|
||||
& Text.From(dur[Minutes])
|
||||
& ", "
|
||||
& Text.From(dur[Seconds])
|
||||
& ") ",
|
||||
Serialize.Function = (x) =>
|
||||
_serialize_function_param_type(
|
||||
Type.FunctionParameters(Value.Type(x)), Type.FunctionRequiredParameters(Value.Type(x))
|
||||
)
|
||||
& " as "
|
||||
& _serialize_function_return_type(Value.Type(x))
|
||||
& " => (...) ",
|
||||
Serialize.List = (x) =>
|
||||
"{"
|
||||
& List.Accumulate(
|
||||
x, "", (seed, item) => if seed = "" then Serialize(item) else seed & ", " & Serialize(item)
|
||||
)
|
||||
& "} ",
|
||||
Serialize.Logical = (x) => Text.From(x),
|
||||
Serialize.Null = (x) => "null",
|
||||
Serialize.Number = (x) =>
|
||||
let
|
||||
Text.From = (i as number) as text =>
|
||||
if Number.IsNaN(i) then
|
||||
"#nan"
|
||||
else if i = Number.PositiveInfinity then
|
||||
"#infinity"
|
||||
else if i = Number.NegativeInfinity then
|
||||
"-#infinity"
|
||||
else
|
||||
Text.From(i)
|
||||
in
|
||||
Text.From(x),
|
||||
Serialize.Record = (x) =>
|
||||
"[ "
|
||||
& List.Accumulate(
|
||||
Record.FieldNames(x),
|
||||
"",
|
||||
(seed, item) =>
|
||||
(if seed = "" then Serialize.Identifier(item) else seed & ", " & Serialize.Identifier(
|
||||
item
|
||||
))
|
||||
& " = "
|
||||
& Serialize(Record.Field(x, item))
|
||||
)
|
||||
& " ] ",
|
||||
Serialize.Table = (x) =>
|
||||
"#table( type " & _serialize_table_type(Value.Type(x)) & ", " & Serialize(Table.ToRows(x)) & ") ",
|
||||
Serialize.Text = (x) => """" & _serialize_text_content(x) & """",
|
||||
_serialize_text_content = (x) =>
|
||||
let
|
||||
escapeText = (n as number) as text =>
|
||||
"#(#)(" & Text.PadStart(Number.ToText(n, "X", "en-US"), 4, "0") & ")"
|
||||
in
|
||||
List.Accumulate(
|
||||
List.Transform(
|
||||
Text.ToList(x),
|
||||
(c) =>
|
||||
let
|
||||
n = Character.ToNumber(c)
|
||||
in
|
||||
if n = 9 then
|
||||
"#(#)(tab)"
|
||||
else if n = 10 then
|
||||
"#(#)(lf)"
|
||||
else if n = 13 then
|
||||
"#(#)(cr)"
|
||||
else if n = 34 then
|
||||
""""""
|
||||
else if n = 35 then
|
||||
"#(#)(#)"
|
||||
else if n < 32 then
|
||||
escapeText(n)
|
||||
else if n < 127 then
|
||||
Character.FromNumber(n)
|
||||
else
|
||||
escapeText(n)
|
||||
),
|
||||
"",
|
||||
(s, i) => s & i
|
||||
),
|
||||
Serialize.Identifier = (x) => if _canBeIdentifier(x) then x else "#""" & _serialize_text_content(x) & """",
|
||||
Serialize.Time = (x) =>
|
||||
"#time("
|
||||
& Text.From(Time.Hour(x))
|
||||
& ", "
|
||||
& Text.From(Time.Minute(x))
|
||||
& ", "
|
||||
& Text.From(Time.Second(x))
|
||||
& ") ",
|
||||
Serialize.Type = (x) => "type " & _serialize_typename(x),
|
||||
_serialize_typename = (x, optional funtype as logical) =>
|
||||
/* Optional parameter: Is this being used as part of a function signature? */ let
|
||||
isFunctionType = (x as type) =>
|
||||
try if Type.FunctionReturn(x) is type then true else false otherwise false,
|
||||
isTableType = (x as type) =>
|
||||
try if Type.TableSchema(x) is table then true else false otherwise false,
|
||||
isRecordType = (x as type) =>
|
||||
try if Type.ClosedRecord(x) is type then true else false otherwise false,
|
||||
isListType = (x as type) => try if Type.ListItem(x) is type then true else false otherwise false
|
||||
in
|
||||
if funtype = null and isTableType(x) then
|
||||
_serialize_table_type(x)
|
||||
else if funtype = null and isListType(x) then
|
||||
"{ " & @_serialize_typename(Type.ListItem(x)) & " }"
|
||||
else if funtype = null and isFunctionType(x) then
|
||||
"function " & _serialize_function_type(x)
|
||||
else if funtype = null and isRecordType(x) then
|
||||
_serialize_record_type(x)
|
||||
else if x = type any then
|
||||
"any"
|
||||
else
|
||||
let
|
||||
base = Type.NonNullable(x)
|
||||
in
|
||||
(if Type.IsNullable(x) then "nullable " else "")
|
||||
& (
|
||||
if base = type anynonnull then
|
||||
"anynonnull"
|
||||
else if base = type binary then
|
||||
"binary"
|
||||
else if base = type date then
|
||||
"date"
|
||||
else if base = type datetime then
|
||||
"datetime"
|
||||
else if base = type datetimezone then
|
||||
"datetimezone"
|
||||
else if base = type duration then
|
||||
"duration"
|
||||
else if base = type logical then
|
||||
"logical"
|
||||
else if base = type none then
|
||||
"none"
|
||||
else if base = type null then
|
||||
"null"
|
||||
else if base = type number then
|
||||
"number"
|
||||
else if base = type text then
|
||||
"text"
|
||||
else if base = type time then
|
||||
"time"
|
||||
else if base = type type then
|
||||
"type"
|
||||
else /* Abstract types: */ if base = type function then
|
||||
"function"
|
||||
else if base = type table then
|
||||
"table"
|
||||
else if base = type record then
|
||||
"record"
|
||||
else if base = type list then
|
||||
"list"
|
||||
else
|
||||
"any /*Actually unknown type*/"
|
||||
),
|
||||
_serialize_table_type = (x) =>
|
||||
let
|
||||
schema = Type.TableSchema(x)
|
||||
in
|
||||
"table "
|
||||
& (
|
||||
if Table.IsEmpty(schema) then
|
||||
""
|
||||
else
|
||||
"["
|
||||
& List.Accumulate(
|
||||
List.Transform(
|
||||
Table.ToRecords(Table.Sort(schema, "Position")),
|
||||
each Serialize.Identifier(_[Name]) & " = " & _[Kind]
|
||||
),
|
||||
"",
|
||||
(seed, item) => (if seed = "" then item else seed & ", " & item)
|
||||
)
|
||||
& "] "
|
||||
),
|
||||
_serialize_record_type = (x) =>
|
||||
let
|
||||
flds = Type.RecordFields(x)
|
||||
in
|
||||
if Record.FieldCount(flds) = 0 then
|
||||
"record"
|
||||
else
|
||||
"["
|
||||
& List.Accumulate(
|
||||
Record.FieldNames(flds),
|
||||
"",
|
||||
(seed, item) =>
|
||||
seed
|
||||
& (if seed <> "" then ", " else "")
|
||||
& (
|
||||
Serialize.Identifier(item)
|
||||
& "="
|
||||
& _serialize_typename(Record.Field(flds, item)[Type])
|
||||
)
|
||||
)
|
||||
& (if Type.IsOpenRecord(x) then ",..." else "")
|
||||
& "]",
|
||||
_serialize_function_type = (x) =>
|
||||
_serialize_function_param_type(Type.FunctionParameters(x), Type.FunctionRequiredParameters(x))
|
||||
& " as "
|
||||
& _serialize_function_return_type(x),
|
||||
_serialize_function_param_type = (t, n) =>
|
||||
let
|
||||
funsig = Table.ToRecords(
|
||||
Table.TransformColumns(
|
||||
Table.AddIndexColumn(Record.ToTable(t), "isOptional", 1), {"isOptional", (x) => x > n}
|
||||
)
|
||||
)
|
||||
in
|
||||
"("
|
||||
& List.Accumulate(
|
||||
funsig,
|
||||
"",
|
||||
(seed, item) =>
|
||||
(if seed = "" then "" else seed & ", ")
|
||||
& (if item[isOptional] then "optional " else "")
|
||||
& Serialize.Identifier(item[Name])
|
||||
& " as "
|
||||
& _serialize_typename(item[Value], true)
|
||||
)
|
||||
& ")",
|
||||
_serialize_function_return_type = (x) => _serialize_typename(Type.FunctionReturn(x), true),
|
||||
Serialize = (x) as text =>
|
||||
if x is binary then
|
||||
try Serialize.Binary(x) otherwise "null /*serialize failed*/"
|
||||
else if x is date then
|
||||
try Serialize.Date(x) otherwise "null /*serialize failed*/"
|
||||
else if x is datetime then
|
||||
try Serialize.Datetime(x) otherwise "null /*serialize failed*/"
|
||||
else if x is datetimezone then
|
||||
try Serialize.Datetimezone(x) otherwise "null /*serialize failed*/"
|
||||
else if x is duration then
|
||||
try Serialize.Duration(x) otherwise "null /*serialize failed*/"
|
||||
else if x is function then
|
||||
try Serialize.Function(x) otherwise "null /*serialize failed*/"
|
||||
else if x is list then
|
||||
try Serialize.List(x) otherwise "null /*serialize failed*/"
|
||||
else if x is logical then
|
||||
try Serialize.Logical(x) otherwise "null /*serialize failed*/"
|
||||
else if x is null then
|
||||
try Serialize.Null(x) otherwise "null /*serialize failed*/"
|
||||
else if x is number then
|
||||
try Serialize.Number(x) otherwise "null /*serialize failed*/"
|
||||
else if x is record then
|
||||
try Serialize.Record(x) otherwise "null /*serialize failed*/"
|
||||
else if x is table then
|
||||
try Serialize.Table(x) otherwise "null /*serialize failed*/"
|
||||
else if x is text then
|
||||
try Serialize.Text(x) otherwise "null /*serialize failed*/"
|
||||
else if x is time then
|
||||
try Serialize.Time(x) otherwise "null /*serialize failed*/"
|
||||
else if x is type then
|
||||
try Serialize.Type(x) otherwise "null /*serialize failed*/"
|
||||
else
|
||||
"[#_unable_to_serialize_#]"
|
||||
in
|
||||
try Serialize(value) otherwise "<serialization failed>"
|
||||
in
|
||||
[
|
||||
LogValue = Diagnostics.LogValue,
|
||||
LogValue2 = Diagnostics.LogValue2,
|
||||
LogFailure = Diagnostics.LogFailure,
|
||||
WrapFunctionResult = Diagnostics.WrapFunctionResult,
|
||||
WrapHandlers = Diagnostics.WrapHandlers,
|
||||
ValueToText = Diagnostics.ValueToText
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
// This is here as reference for copy/pasting wherever there is need for importing pqm files.
|
||||
let
|
||||
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
|
||||
Extension.LoadFunction
|
||||
@@ -0,0 +1,231 @@
|
||||
let
|
||||
/// COMMON UNIT TESTING CODE
|
||||
Fact = (_subject as text, _expected, _actual) as record =>
|
||||
[
|
||||
expected = try _expected,
|
||||
safeExpected = if expected[HasError] then "Expected : " & @ValueToText(expected[Error]) else expected[
|
||||
Value
|
||||
],
|
||||
actual = try _actual,
|
||||
safeActual = if actual[HasError] then "Actual : " & @ValueToText(actual[Error]) else actual[Value],
|
||||
attempt = try safeExpected = safeActual,
|
||||
result = if attempt[HasError] or not attempt[Value] then "Failure" else "Success",
|
||||
resultOp = if result = "Success" then " = " else " <> ",
|
||||
addendumEvalAttempt = if attempt[HasError] then @ValueToText(attempt[Error]) else "",
|
||||
addendumEvalExpected = try @ValueToText(safeExpected) otherwise "...",
|
||||
addendumEvalActual = try @ValueToText(safeActual) otherwise "...",
|
||||
fact = [
|
||||
Result = result & " " & addendumEvalAttempt,
|
||||
Notes = _subject,
|
||||
Details = " (" & addendumEvalExpected & resultOp & addendumEvalActual & ")"
|
||||
]
|
||||
][fact],
|
||||
Facts = (_subject as text, _predicates as list) => List.Transform(_predicates, each Fact(_subject, _{0}, _{1})),
|
||||
Facts.Summarize = (_facts as list) as table =>
|
||||
[
|
||||
Fact.CountSuccesses = (count, i) =>
|
||||
[
|
||||
result = try i[Result],
|
||||
sum = if result[HasError] or not Text.StartsWith(result[Value], "Success") then count else count + 1
|
||||
][sum],
|
||||
passed = List.Accumulate(_facts, 0, Fact.CountSuccesses),
|
||||
total = List.Count(_facts),
|
||||
format = if passed = total then "All #{0} Passed !!!" else "#{0} Passed - #{1} Failed",
|
||||
result = if passed = total then "Success" else "Failed",
|
||||
rate = Number.IntegerDivide(100 * passed, total),
|
||||
header = [
|
||||
Result = result,
|
||||
Notes = Text.Format(format, {passed, total - passed}),
|
||||
Details = Text.Format("#{0}% success rate", {rate})
|
||||
],
|
||||
report = Table.FromRecords(List.Combine({{header}, _facts}))
|
||||
][report],
|
||||
ValueToText = (value, optional depth) =>
|
||||
let
|
||||
List.TransformAndCombine = (list, transform, separator) =>
|
||||
Text.Combine(List.Transform(list, transform), separator),
|
||||
Serialize.Binary = (x) => "#binary(" & Serialize(Binary.ToList(x)) & ") ",
|
||||
Serialize.Function = (x) =>
|
||||
_serialize_function_param_type(
|
||||
Type.FunctionParameters(Value.Type(x)), Type.FunctionRequiredParameters(Value.Type(x))
|
||||
)
|
||||
& " as "
|
||||
& _serialize_function_return_type(Value.Type(x))
|
||||
& " => (...) ",
|
||||
Serialize.List = (x) => "{" & List.TransformAndCombine(x, Serialize, ", ") & "} ",
|
||||
Serialize.Record = (x) =>
|
||||
"[ "
|
||||
& List.TransformAndCombine(
|
||||
Record.FieldNames(x),
|
||||
(item) => Serialize.Identifier(item) & " = " & Serialize(Record.Field(x, item)),
|
||||
", "
|
||||
)
|
||||
& " ] ",
|
||||
Serialize.Table = (x) =>
|
||||
"#table( type " & _serialize_table_type(Value.Type(x)) & ", " & Serialize(Table.ToRows(x)) & ") ",
|
||||
Serialize.Identifier = Expression.Identifier,
|
||||
Serialize.Type = (x) => "type " & _serialize_typename(x),
|
||||
_serialize_typename = (x, optional funtype as logical) =>
|
||||
/* Optional parameter: Is this being used as part of a function signature? */ let
|
||||
isFunctionType = (x as type) =>
|
||||
try if Type.FunctionReturn(x) is type then true else false otherwise false,
|
||||
isTableType = (x as type) =>
|
||||
try if Type.TableSchema(x) is table then true else false otherwise false,
|
||||
isRecordType = (x as type) =>
|
||||
try if Type.ClosedRecord(x) is type then true else false otherwise false,
|
||||
isListType = (x as type) => try if Type.ListItem(x) is type then true else false otherwise false
|
||||
in
|
||||
if funtype = null and isTableType(x) then
|
||||
_serialize_table_type(x)
|
||||
else if funtype = null and isListType(x) then
|
||||
"{ " & @_serialize_typename(Type.ListItem(x)) & " }"
|
||||
else if funtype = null and isFunctionType(x) then
|
||||
"function " & _serialize_function_type(x)
|
||||
else if funtype = null and isRecordType(x) then
|
||||
_serialize_record_type(x)
|
||||
else if x = type any then
|
||||
"any"
|
||||
else
|
||||
let
|
||||
base = Type.NonNullable(x)
|
||||
in
|
||||
(if Type.IsNullable(x) then "nullable " else "")
|
||||
& (
|
||||
if base = type anynonnull then
|
||||
"anynonnull"
|
||||
else if base = type binary then
|
||||
"binary"
|
||||
else if base = type date then
|
||||
"date"
|
||||
else if base = type datetime then
|
||||
"datetime"
|
||||
else if base = type datetimezone then
|
||||
"datetimezone"
|
||||
else if base = type duration then
|
||||
"duration"
|
||||
else if base = type logical then
|
||||
"logical"
|
||||
else if base = type none then
|
||||
"none"
|
||||
else if base = type null then
|
||||
"null"
|
||||
else if base = type number then
|
||||
"number"
|
||||
else if base = type text then
|
||||
"text"
|
||||
else if base = type time then
|
||||
"time"
|
||||
else if base = type type then
|
||||
"type"
|
||||
else /* Abstract types: */ if base = type function then
|
||||
"function"
|
||||
else if base = type table then
|
||||
"table"
|
||||
else if base = type record then
|
||||
"record"
|
||||
else if base = type list then
|
||||
"list"
|
||||
else
|
||||
"any /*Actually unknown type*/"
|
||||
),
|
||||
_serialize_table_type = (x) =>
|
||||
let
|
||||
schema = Type.TableSchema(x)
|
||||
in
|
||||
"table "
|
||||
& (
|
||||
if Table.IsEmpty(schema) then
|
||||
""
|
||||
else
|
||||
"["
|
||||
& List.TransformAndCombine(
|
||||
Table.ToRecords(Table.Sort(schema, "Position")),
|
||||
each Serialize.Identifier(_[Name]) & " = " & _[Kind],
|
||||
", "
|
||||
)
|
||||
& "] "
|
||||
),
|
||||
_serialize_record_type = (x) =>
|
||||
let
|
||||
flds = Type.RecordFields(x)
|
||||
in
|
||||
if Record.FieldCount(flds) = 0 then
|
||||
"record"
|
||||
else
|
||||
"["
|
||||
& List.TransformAndCombine(
|
||||
Record.FieldNames(flds),
|
||||
(item) =>
|
||||
Serialize.Identifier(item)
|
||||
& "="
|
||||
& _serialize_typename(Record.Field(flds, item)[Type]),
|
||||
", "
|
||||
)
|
||||
& (if Type.IsOpenRecord(x) then ", ..." else "")
|
||||
& "]",
|
||||
_serialize_function_type = (x) =>
|
||||
_serialize_function_param_type(Type.FunctionParameters(x), Type.FunctionRequiredParameters(x))
|
||||
& " as "
|
||||
& _serialize_function_return_type(x),
|
||||
_serialize_function_param_type = (t, n) =>
|
||||
let
|
||||
funsig = Table.ToRecords(
|
||||
Table.TransformColumns(
|
||||
Table.AddIndexColumn(Record.ToTable(t), "isOptional", 1), {"isOptional", (x) => x > n}
|
||||
)
|
||||
)
|
||||
in
|
||||
"("
|
||||
& List.TransformAndCombine(
|
||||
funsig,
|
||||
(item) =>
|
||||
(if item[isOptional] then "optional " else "")
|
||||
& Serialize.Identifier(item[Name])
|
||||
& " as "
|
||||
& _serialize_typename(item[Value], true),
|
||||
", "
|
||||
)
|
||||
& ")",
|
||||
_serialize_function_return_type = (x) => _serialize_typename(Type.FunctionReturn(x), true),
|
||||
Serialize = (x) as text =>
|
||||
if x is binary then
|
||||
try Serialize.Binary(x) otherwise "null /*serialize failed*/"
|
||||
else if x is date then
|
||||
try Expression.Constant(x) otherwise "null /*serialize failed*/"
|
||||
else if x is datetime then
|
||||
try Expression.Constant(x) otherwise "null /*serialize failed*/"
|
||||
else if x is datetimezone then
|
||||
try Expression.Constant(x) otherwise "null /*serialize failed*/"
|
||||
else if x is duration then
|
||||
try Expression.Constant(x) otherwise "null /*serialize failed*/"
|
||||
else if x is function then
|
||||
try Serialize.Function(x) otherwise "null /*serialize failed*/"
|
||||
else if x is list then
|
||||
try Serialize.List(x) otherwise "null /*serialize failed*/"
|
||||
else if x is logical then
|
||||
try Expression.Constant(x) otherwise "null /*serialize failed*/"
|
||||
else if x is null then
|
||||
try Expression.Constant(x) otherwise "null /*serialize failed*/"
|
||||
else if x is number then
|
||||
try Expression.Constant(x) otherwise "null /*serialize failed*/"
|
||||
else if x is record then
|
||||
try Serialize.Record(x) otherwise "null /*serialize failed*/"
|
||||
else if x is table then
|
||||
try Serialize.Table(x) otherwise "null /*serialize failed*/"
|
||||
else if x is text then
|
||||
try Expression.Constant(x) otherwise "null /*serialize failed*/"
|
||||
else if x is time then
|
||||
try Expression.Constant(x) otherwise "null /*serialize failed*/"
|
||||
else if x is type then
|
||||
try Serialize.Type(x) otherwise "null /*serialize failed*/"
|
||||
else
|
||||
"[#_unable_to_serialize_#]"
|
||||
in
|
||||
try Serialize(value) otherwise "<serialization failed>"
|
||||
in
|
||||
[
|
||||
Fact = Fact,
|
||||
Facts = Facts,
|
||||
SummarizeFacts = Facts.Summarize,
|
||||
ValueToText = ValueToText
|
||||
]
|
||||
@@ -0,0 +1,12 @@
|
||||
(Value as text) =>
|
||||
let
|
||||
Solution = Binary.ToText(
|
||||
Binary.FromList(
|
||||
Binary.ToList(Binary.Compress(Text.ToBinary(Value, BinaryEncoding.Base64), Compression.GZip))
|
||||
)
|
||||
)
|
||||
in
|
||||
if Value = null then
|
||||
null
|
||||
else
|
||||
Solution
|
||||
@@ -0,0 +1,23 @@
|
||||
(getNextPage as function) as table =>
|
||||
let
|
||||
listOfPages = List.Generate(
|
||||
() => getNextPage(null),
|
||||
// get the first page of data
|
||||
(lastPage) => lastPage <> null,
|
||||
// stop when the function returns null
|
||||
(lastPage) => getNextPage(lastPage)
|
||||
// pass the previous page to the next function call
|
||||
),
|
||||
// concatenate the pages together
|
||||
tableOfPages = Table.FromList(listOfPages, Splitter.SplitByNothing(), {"Column1"}),
|
||||
firstRow = tableOfPages{0} ?
|
||||
in
|
||||
// if we didn't get back any pages of data, return an empty table
|
||||
// otherwise set the table type based on the columns of the first page
|
||||
if (firstRow = null) then
|
||||
Table.FromRows({})
|
||||
else
|
||||
Value.ReplaceType(
|
||||
Table.ExpandTableColumn(tableOfPages, "Column1", Table.ColumnNames(firstRow[Column1])),
|
||||
Value.Type(firstRow[Column1])
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
(
|
||||
table as table,
|
||||
keyColumns as list,
|
||||
nameColumn as text,
|
||||
dataColumn as text,
|
||||
itemKindColumn as text,
|
||||
itemNameColumn as text,
|
||||
isLeafColumn as text
|
||||
) as table =>
|
||||
let
|
||||
tableType = Value.Type(table),
|
||||
newTableType = Type.AddTableKey(tableType, keyColumns, true) meta [
|
||||
NavigationTable.NameColumn = nameColumn,
|
||||
NavigationTable.DataColumn = dataColumn,
|
||||
NavigationTable.ItemKindColumn = itemKindColumn,
|
||||
Preview.DelayColumn = itemNameColumn,
|
||||
NavigationTable.IsLeafColumn = isLeafColumn
|
||||
],
|
||||
navigationTable = Value.ReplaceType(table, newTableType)
|
||||
in
|
||||
navigationTable
|
||||
@@ -0,0 +1,14 @@
|
||||
(producer as function, interval as function, optional count as number) as any =>
|
||||
let
|
||||
list = List.Generate(
|
||||
() => {0, null},
|
||||
(state) => state{0} <> null and (count = null or state{0} < count),
|
||||
(state) =>
|
||||
if state{1} <> null then
|
||||
{null, state{1}}
|
||||
else
|
||||
{1 + state{0}, Function.InvokeAfter(() => producer(state{0}), interval(state{0}))},
|
||||
(state) => state{1}
|
||||
)
|
||||
in
|
||||
List.Last(list)
|
||||
@@ -0,0 +1,37 @@
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
const config = {
|
||||
root: true,
|
||||
parser: 'vue-eslint-parser',
|
||||
parserOptions: {
|
||||
parser: '@typescript-eslint/parser',
|
||||
requireConfigFile: false,
|
||||
ecmaVersion: 2020,
|
||||
sourceType: 'module'
|
||||
},
|
||||
plugins: ['@typescript-eslint'],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:vue/vue3-recommended',
|
||||
'plugin:@typescript-eslint/eslint-recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'prettier'
|
||||
],
|
||||
env: {
|
||||
node: true,
|
||||
commonjs: true
|
||||
},
|
||||
ignorePatterns: [
|
||||
'node_modules',
|
||||
'dist',
|
||||
'public',
|
||||
'events.json',
|
||||
'.*.{ts,js,vue,tsx,jsx}',
|
||||
'generated/**/*'
|
||||
],
|
||||
rules: {
|
||||
'no-var': 'off',
|
||||
'@typescript-eslint/ban-ts-comment': 'warn'
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = config
|
||||
@@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
- Using welcoming and inclusive language
|
||||
- Being respectful of differing viewpoints and experiences
|
||||
- Gracefully accepting constructive criticism
|
||||
- Focusing on what is best for the community
|
||||
- Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
- The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
- Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
- Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at hello@speckle.systems. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
@@ -0,0 +1,50 @@
|
||||
# Speckle Contribution Guidelines
|
||||
|
||||
## Introduction
|
||||
|
||||
Thank you for reading this! Speckle's a rather wide network of parts that depend on each other, either directly, indirectly or even just cosmetically.
|
||||
|
||||
> **Speckle** is a quite large ecosystem of moving parts. Any changes may have unintended effects, that can cause problems quickly for many people (and processes) that rely on Speckle.
|
||||
|
||||
This means that what might look like a simple quick change in one repo may have a big hidden cost that propagates around other parts of the project. We're all here to help each other, and this guide is meant to help you get started and promote a framework that can untangle all these dependecies through discussion!
|
||||
|
||||
## Bugs & Issues 🐞
|
||||
|
||||
### Found a new bug?
|
||||
|
||||
- First step is to check whether this is a new bug! We encourage you to search through the issues of the project in question **and** associated repos!
|
||||
|
||||
- If you come up with nothing, **open a new issue with a clear title and description**, as much relevant information as possible: system configuration, code samples & steps to reproduce the problem.
|
||||
|
||||
- Can't mention this often enough: tells us how to reproduce the problem! We will ignore or flag as such issues without reproduction steps.
|
||||
|
||||
- Try to reference & note all potentially affected projects.
|
||||
|
||||
### Sending a PR for Bug Fixes
|
||||
|
||||
You fixed something! Great! We hope you logged it first :) Make sure though that you've covered the lateral thinking needed for a bug report, as described above, also in your implementation! If there any tests, make sure they all pass. If there are none, it means they're missing - so add them!
|
||||
|
||||
## New Features 🎉
|
||||
|
||||
The golden rule is to Discuss First!
|
||||
|
||||
- Before embarking on adding a new feature, suggest it first as an issue with the `enhancement` label and/or title - this will allow relevant people to pitch in
|
||||
- We'll now discuss your requirements and see how and if they fit within the Speckle ecosystem.
|
||||
- The last step is to actually start writing code & submit a PR so we can follow along!
|
||||
- All new features should, if and where possible, come with tests. We won't merge without!
|
||||
|
||||
> Many clients may potentially have overlapping scopes, some features might already be in dev somewhere else, or might have been postponed to the next major release due to api instability in that area. For example, adding a delete stream button in the accounts panel in rhino: this feature was planned for speckle admin, and the whole functionality of the accounts panel in rhino is to be greatly reduced!
|
||||
|
||||
## Cosmetic Patches ✨
|
||||
|
||||
Changes that are cosmetic in nature and do not add anything substantial to the stability or functionality of Speckle **will generally not be accepted**.
|
||||
|
||||
Why? However trivial the changes might seem, there might be subtle reasons for the original code to be as it is. Furthermore, there are a lot of potential hidden costs (that even maintainers themselves are not aware of fully!) and they eat up review time unncessarily.
|
||||
|
||||
> **Examples**: modifying the colour of an UI element in one client may have a big hidden cost and need propagation in several other clients that implement a similar ui element. Changing the default port or specifiying `localhost` instead of `0.0.0.0` breaks cross-vm debugging and developing.
|
||||
|
||||
## Wrap up
|
||||
|
||||
Don't worry if you get things wrong. We all do, including project owners: this document should've been here a long time ago. There's plenty of room for discussion on our community [forum](https://discourse.speckle.works).
|
||||
|
||||
🙌❤️💙💚💜🙌
|
||||
@@ -0,0 +1,110 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Help improve Speckle!
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
<!---
|
||||
|
||||
Provide a short summary in the Title above. Examples of good Issue titles:
|
||||
|
||||
* "Bug: Error from server when reticulating splines"
|
||||
* "Bug: Revit crashes when installing connector"
|
||||
|
||||
-->
|
||||
|
||||
## Prerequisites
|
||||
|
||||
<!---
|
||||
|
||||
Please answer the following questions before submitting an issue.
|
||||
|
||||
-->
|
||||
|
||||
- [ ] I read the [contribution guidelines](https://github.com/specklesystems/speckle-server/blob/main/CONTRIBUTING.md)
|
||||
- [ ] I checked the [documentation](https://speckle.guide/) and found no answer.
|
||||
- [ ] I checked [existing issues](../issues?q=is%3Aissue) and found no similar issue. <!-- If you do find an existing issue, please show your support by liking it :+1: instead of creating a new issue -->
|
||||
- [ ] I checked the [community forum](https://speckle.community/) for related discussions and found no answer.
|
||||
- [ ] I'm reporting the issue to the correct repository (see also [speckle-server](https://github.com/specklesystems/speckle-server), [speckle-sharp](https://github.com/specklesystems/speckle-sharp), [specklepy](https://github.com/specklesystems/specklepy), [speckle-docs](https://github.com/specklesystems/speckle-docs), and [others](https://github.com/orgs/specklesystems/repositories))
|
||||
|
||||
## What package are you referring to?
|
||||
|
||||
<!---
|
||||
Is it related to the server (backend) only, or does this bug relate to the frontend, viewer, objectloader or any other package?
|
||||
-->
|
||||
|
||||
## Describe the bug
|
||||
|
||||
<!---
|
||||
A clear and concise description of what the bug is.
|
||||
-->
|
||||
|
||||
## To Reproduce
|
||||
|
||||
<!---
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
-->
|
||||
|
||||
## Expected behavior
|
||||
|
||||
<!---
|
||||
A clear and concise description of what you expected to happen.
|
||||
-->
|
||||
|
||||
## Screenshots
|
||||
<!---
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
-->
|
||||
|
||||
## System Info
|
||||
If applicable, please fill in the below details - they help a lot!
|
||||
|
||||
### Desktop (please complete the following information):
|
||||
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
### Smartphone (please complete the following information):
|
||||
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
## Failure Logs
|
||||
|
||||
<!---
|
||||
Please include any relevant log snippets or files here, or upload as a file.
|
||||
|
||||
If including inline, please use markdown code block syntax. https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks
|
||||
For example:
|
||||
|
||||
```
|
||||
your log output here
|
||||
```
|
||||
-->
|
||||
|
||||
## Additional context
|
||||
|
||||
<!---
|
||||
Add any other context about the problem here.
|
||||
-->
|
||||
|
||||
## Proposed Solution (if any)
|
||||
|
||||
<!---
|
||||
Let us know what how you would solve this.
|
||||
-->
|
||||
|
||||
#### Optional: Affected Projects
|
||||
<!---
|
||||
Does this issue propagate to other dependencies or dependents? If so, list them here with links!
|
||||
-->
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for Speckle!
|
||||
title: ''
|
||||
labels: enhancement, question
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
<!---
|
||||
|
||||
Provide a short summary in the Title above. Examples of good Issue titles:
|
||||
|
||||
* "Enhancement: Connector for Minecraft"
|
||||
* "Enhancement: Web viewer should support tesseracts"
|
||||
|
||||
-->
|
||||
|
||||
## Prerequisites
|
||||
|
||||
<!---
|
||||
|
||||
Please answer the following questions before submitting an issue.
|
||||
|
||||
-->
|
||||
|
||||
- [ ] I read the [contribution guidelines](https://github.com/specklesystems/speckle-server/blob/main/CONTRIBUTING.md)
|
||||
- [ ] I checked the [documentation](https://speckle.guide/) and found no answer.
|
||||
- [ ] I checked [existing issues](../issues?q=is%3Aissue) and found no similar issue. <!-- If you do find an existing issue, please show your support by liking it :+1: instead of creating a new issue -->
|
||||
- [ ] I checked the [community forum](https://speckle.community/) for related discussions and found no answer.
|
||||
- [ ] I'm requesting the feature to the correct repository (see also [speckle-server](https://github.com/specklesystems/speckle-server), [speckle-sharp](https://github.com/specklesystems/speckle-sharp), [specklepy](https://github.com/specklesystems/specklepy), [speckle-docs](https://github.com/specklesystems/speckle-docs), and [others](https://github.com/orgs/specklesystems/repositories))
|
||||
|
||||
## What package are you referring to?
|
||||
<!---
|
||||
Is it related to the server (backend) only, or does this feature request relate to the frontend, viewer, objectloader or any other package?
|
||||
-->
|
||||
|
||||
## Is your feature request related to a problem? Please describe.
|
||||
<!---
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
-->
|
||||
|
||||
## Describe the solution you'd like
|
||||
<!---
|
||||
A clear and concise description of what you want to happen.
|
||||
-->
|
||||
|
||||
## Describe alternatives you've considered
|
||||
<!---
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
-->
|
||||
|
||||
## Additional context
|
||||
<!---
|
||||
Add any other context or screenshots about the feature request here.
|
||||
|
||||
Have you seen this feature implemented in any other software? Can you provide screenshots or links to video or documentation?
|
||||
What works well about these existing features in other software? What doesn't work well?
|
||||
-->
|
||||
|
||||
## Related issues or community discussions
|
||||
<!---
|
||||
Is this feature request related to (but sufficiently distinct from) any existing issues?
|
||||
Does this feature request require other features to be available beforehand?
|
||||
Has this feature been discussed in the community forum, please link here? https://speckle.community/
|
||||
-->
|
||||
@@ -0,0 +1,86 @@
|
||||
<!---
|
||||
|
||||
Provide a short summary in the Title above. Examples of good PR titles:
|
||||
|
||||
* "Feature: adds metrics to component"
|
||||
|
||||
* "Fix: resolves duplication in comment thread"
|
||||
|
||||
* "Update: apollo v2.34.0"
|
||||
|
||||
-->
|
||||
|
||||
## Description & motivation
|
||||
|
||||
<!---
|
||||
|
||||
Describe your changes, and why you're making them. What benefit will this have to others?
|
||||
|
||||
Is this linked to an open Github issue, a thread in Speckle community,
|
||||
or another pull request? Link it here.
|
||||
|
||||
If it is related to a Github issue, and resolves it, please link to the issue number, e.g.:
|
||||
Fixes #85, Fixes #22, Fixes username/repo#123
|
||||
Connects #123
|
||||
|
||||
-->
|
||||
|
||||
## Changes:
|
||||
|
||||
<!---
|
||||
|
||||
- Item 1
|
||||
- Item 2
|
||||
|
||||
-->
|
||||
|
||||
## To-do before merge
|
||||
|
||||
<!---
|
||||
|
||||
(Optional -- remove this section if not needed)
|
||||
|
||||
Include any notes about things that need to happen before this PR is merged, e.g.:
|
||||
|
||||
- [ ] Change the base branch
|
||||
|
||||
- [ ] Ensure PR #56 is merged
|
||||
|
||||
-->
|
||||
|
||||
## Screenshots:
|
||||
|
||||
<!---
|
||||
|
||||
Include a screenshot the before and after. This can be a screenshot of a plugin, web frontend, or output in a terminal.
|
||||
|
||||
-->
|
||||
|
||||
## Validation of changes:
|
||||
|
||||
<!---
|
||||
|
||||
Describe what tests have been added or amended, and why these demonstrate it works and will prevent this feature being accidentally broken by future changes.
|
||||
|
||||
-->
|
||||
|
||||
## Checklist:
|
||||
|
||||
<!---
|
||||
|
||||
This checklist is mostly useful as a reminder of small things that can easily be
|
||||
|
||||
forgotten – it is meant as a helpful tool rather than hoops to jump through.
|
||||
|
||||
Put an `x` in all the items that apply, make notes next to any that haven't been
|
||||
|
||||
addressed, and remove any items that are not relevant to this PR.
|
||||
|
||||
-->
|
||||
|
||||
- [ ] My pull request follows the guidelines in the [Contributing guide](https://github.com/specklesystems/speckle-server/blob/main/CONTRIBUTING.md)?
|
||||
- [ ] My pull request does not duplicate any other open [Pull Requests](../../pulls) for the same update/change?
|
||||
- [ ] My commits are related to the pull request and do not amend unrelated code or documentation.
|
||||
- [ ] My code follows a similar style to existing code.
|
||||
- [ ] I have added appropriate tests.
|
||||
- [ ] I have updated or added relevant documentation.
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"trailingComma": "none",
|
||||
"tabWidth": 2,
|
||||
"semi": false,
|
||||
"endOfLine": "auto",
|
||||
"bracketSpacing": true,
|
||||
"vueIndentScriptAndStyle": false,
|
||||
"htmlWhitespaceSensitivity": "ignore",
|
||||
"printWidth": 100,
|
||||
"singleQuote": true
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debugger",
|
||||
"type": "chrome",
|
||||
"request": "attach",
|
||||
"port": 8080,
|
||||
"sourceMaps": true,
|
||||
"webRoot": "${cwd}/"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"editor.tabSize": 4,
|
||||
"editor.insertSpaces": true,
|
||||
"files.eol": "\n",
|
||||
"files.watcherExclude": {
|
||||
"**/.git/objects/**": true,
|
||||
"**/node_modules/**": true,
|
||||
".tmp": true
|
||||
},
|
||||
"files.exclude": {
|
||||
".tmp": true
|
||||
},
|
||||
"files.associations": {
|
||||
"*.resjson": "json"
|
||||
},
|
||||
"search.exclude": {
|
||||
".tmp": true,
|
||||
"typings": true
|
||||
},
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/pbiviz.json"],
|
||||
"url": "./node_modules/powerbi-visuals-api/schema.pbiviz.json"
|
||||
},
|
||||
{
|
||||
"fileMatch": ["/capabilities.json"],
|
||||
"url": "./node_modules/powerbi-visuals-api/schema.capabilities.json"
|
||||
},
|
||||
{
|
||||
"fileMatch": ["/dependencies.json"],
|
||||
"url": "./node_modules/powerbi-visuals-api/schema.dependencies.json"
|
||||
}
|
||||
],
|
||||
"vue.codeActions.enabled": false
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2020 AEC Systems
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,89 @@
|
||||
<h1 align="center">
|
||||
<img src="https://user-images.githubusercontent.com/2679513/131189167-18ea5fe1-c578-47f6-9785-3748178e4312.png" width="150px"/><br/>
|
||||
Speckle | PowerBI Visuals
|
||||
</h1>
|
||||
<h3 align="center">
|
||||
3D Viewer for PowerBI and more...
|
||||
Expected use case is that the visual displays data pulled from Speckle via the Speckle Data Connector for PowerBI (https://github.com/specklesystems/speckle-powerbi)
|
||||
</h3>
|
||||
|
||||
> ⚠️ This repo is still in very early stages of development, use at your own risk!
|
||||
|
||||
<p align="center"><b>Speckle</b> is data infrastructure for the AEC industry.</p><br/>
|
||||
|
||||
<p align="center"><a href="https://twitter.com/SpeckleSystems"><img src="https://img.shields.io/twitter/follow/SpeckleSystems?style=social" alt="Twitter Follow"></a> <a href="https://speckle.community"><img src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fspeckle.community&style=flat-square&logo=discourse&logoColor=white" alt="Community forum users"></a> <a href="https://speckle.systems"><img src="https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square" alt="website"></a> <a href="https://speckle.guide/dev/"><img src="https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&logo=read-the-docs&logoColor=white" alt="docs"></a></p>
|
||||
<p align="center"></p>
|
||||
|
||||
# About Speckle
|
||||
|
||||
What is Speckle? Check our 
|
||||
|
||||
### Features
|
||||
|
||||
- **Object-based:** say goodbye to files! Speckle is the first object based platform for the AEC industry
|
||||
- **Version control:** Speckle is the Git & Hub for geometry and BIM data
|
||||
- **Collaboration:** share your designs collaborate with others
|
||||
- **3D Viewer:** see your CAD and BIM models online, share and embed them anywhere
|
||||
- **Interoperability:** get your CAD and BIM models into other software without exporting or importing
|
||||
- **Real time:** get real time updates and notifications and changes
|
||||
- **GraphQL API:** get what you need anywhere you want it
|
||||
- **Webhooks:** the base for a automation and next-gen pipelines
|
||||
- **Built for developers:** we are building Speckle with developers in mind and got tools for every stack
|
||||
- **Built for the AEC industry:** Speckle connectors are plugins for the most common software used in the industry such as Revit, Rhino, Grasshopper, AutoCAD, Civil 3D, Excel, Unreal Engine, Unity, QGIS, Blender and more!
|
||||
|
||||
### Try Speckle now!
|
||||
|
||||
Give Speckle a try in no time by:
|
||||
|
||||
- [](https://app.speckle.systems) ⇒ creating an account
|
||||
- [](https://marketplace.digitalocean.com/apps/speckle-server?refcode=947a2b5d7dc1) ⇒ deploying an instance in 1 click
|
||||
|
||||
### Resources
|
||||
|
||||
- [](https://speckle.community) for help, feature requests or just to hang with other speckle enthusiasts, check out our community forum!
|
||||
- [](https://speckle.systems) our tutorials portal is full of resources to get you started using Speckle
|
||||
- [](https://speckle.guide/dev/) reference on almost any end-user and developer functionality
|
||||
|
||||

|
||||
|
||||
# Repo structure
|
||||
|
||||
This repo follows the default structure of any Custom PowerBI Visual, generated by the `pbiviz` tool.
|
||||
|
||||
For now, it only contains a single visual -> The Speckle 3D Viewer
|
||||
|
||||
For more information about how a PowerBI visual is structured, you can check out the [official documentation](https://docs.microsoft.com/en-us/power-bi/developer/visuals/visual-project-structure)
|
||||
|
||||
### Other repos
|
||||
|
||||
Make sure to also check and ⭐️ these other Speckle repositories:
|
||||
|
||||
- [`speckle-server`](https://github.com/specklesystems/speckle-server): Server and Web packages
|
||||
- [`specklepy`](https://github.com/specklesystems/specklepy): Python SDK 🐍
|
||||
- [`speckle-excel`](https://github.com/specklesystems/speckle-excel): Excel connector
|
||||
- [`speckle-unity`](https://github.com/specklesystems/speckle-unity): Unity 3D connector
|
||||
- [`speckle-blender`](https://github.com/specklesystems/speckle-blender): Blender connector
|
||||
- [`speckle-unreal`](https://github.com/specklesystems/speckle-unreal): Unreal Engine Connector
|
||||
- [`speckle-qgis`](https://github.com/specklesystems/speckle-qgis): QGIS connectod
|
||||
- [`speckle-powerbi`](https://github.com/specklesystems/speckle-powerbi): PowerBi connector
|
||||
- and more [connectos & tooling](https://github.com/specklesystems/)!
|
||||
|
||||
## Developing and Debugging
|
||||
|
||||
There's a neat guide on setting up your environment for developing visuals [here](https://docs.microsoft.com/en-us/power-bi/developer/visuals/environment-setup)
|
||||
|
||||
You'll need to properly set up the certificate in order to be able to use the hot-reloading feature.
|
||||
|
||||
> Hot Reload will only work on PowerBI Web (**not** on Desktop).
|
||||
|
||||
### Contributing
|
||||
|
||||
Please make sure you read the [contribution guidelines](.github/CONTRIBUTING.md) for an overview of the best practices we try to follow.
|
||||
|
||||
### Security
|
||||
|
||||
For any security vulnerabilities or concerns, please contact us directly at security[at]speckle.systems.
|
||||
|
||||
### License
|
||||
|
||||
Unless otherwise described, the code in this repository is licensed under the Apache-2.0 License. Please note that some modules, extensions or code herein might be otherwise licensed. This is indicated either in the root of the containing folder under a different license file, or in the respective file's header. If you have any questions, don't hesitate to get in touch with us via [email](mailto:hello@speckle.systems).
|
||||
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,241 @@
|
||||
{
|
||||
"dataRoles": [
|
||||
{
|
||||
"displayName": "Model URL",
|
||||
"kind": "Grouping",
|
||||
"name": "stream"
|
||||
},
|
||||
{
|
||||
"displayName": "Version Object ID",
|
||||
"kind": "Grouping",
|
||||
"name": "parentObject"
|
||||
},
|
||||
{
|
||||
"displayName": "Object ID",
|
||||
"kind": "Grouping",
|
||||
"name": "object"
|
||||
},
|
||||
{
|
||||
"displayName": "Color By",
|
||||
"kind": "Grouping",
|
||||
"name": "objectColorBy"
|
||||
},
|
||||
{
|
||||
"displayName": "Tooltip Data",
|
||||
"kind": "Measure",
|
||||
"name": "objectData"
|
||||
}
|
||||
],
|
||||
"dataViewMappings": [
|
||||
{
|
||||
"matrix": {
|
||||
"rows": {
|
||||
"dataReductionAlgorithm": {
|
||||
"top": {
|
||||
"count": 30000
|
||||
}
|
||||
},
|
||||
"select": [
|
||||
{
|
||||
"bind": {
|
||||
"to": "stream"
|
||||
}
|
||||
},
|
||||
{
|
||||
"bind": {
|
||||
"to": "parentObject"
|
||||
}
|
||||
},
|
||||
{
|
||||
"bind": {
|
||||
"to": "objectColorBy"
|
||||
}
|
||||
},
|
||||
{
|
||||
"for": {
|
||||
"in": "object"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"values": {
|
||||
"select": [
|
||||
{
|
||||
"bind": {
|
||||
"to": "objectData"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"objects": {
|
||||
"camera": {
|
||||
"properties": {
|
||||
"defaultView": {
|
||||
"type": {
|
||||
"enumeration": [
|
||||
{
|
||||
"displayName": "Perspective",
|
||||
"value": "perspective"
|
||||
},
|
||||
{
|
||||
"displayName": "Top",
|
||||
"value": "top"
|
||||
},
|
||||
{
|
||||
"displayName": "Front",
|
||||
"value": "front"
|
||||
},
|
||||
{
|
||||
"displayName": "Left",
|
||||
"value": "left"
|
||||
},
|
||||
{
|
||||
"displayName": "Back",
|
||||
"value": "back"
|
||||
},
|
||||
{
|
||||
"displayName": "Right",
|
||||
"value": "right"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"allowCameraUnder": {
|
||||
"type": {
|
||||
"bool": true
|
||||
}
|
||||
},
|
||||
"zoomOnDataChange": {
|
||||
"type": {
|
||||
"bool": true
|
||||
}
|
||||
},
|
||||
"projection": {
|
||||
"type": {
|
||||
"enumeration": [
|
||||
{
|
||||
"displayName": "Perspective",
|
||||
"value": "perspective"
|
||||
},
|
||||
{
|
||||
"displayName": "Orthographic",
|
||||
"value": "orthographic"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"color": {
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": {
|
||||
"bool": true
|
||||
}
|
||||
},
|
||||
"fill": {
|
||||
"type": {
|
||||
"fill": {
|
||||
"solid": {
|
||||
"color": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"context": {
|
||||
"type": {
|
||||
"enumeration": [
|
||||
{
|
||||
"displayName": "Hidden",
|
||||
"value": "hidden"
|
||||
},
|
||||
{
|
||||
"displayName": "Ghosted",
|
||||
"value": "ghosted"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"lighting": {
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": {
|
||||
"bool": true
|
||||
}
|
||||
},
|
||||
"intensity": {
|
||||
"type": {
|
||||
"numeric": true
|
||||
}
|
||||
},
|
||||
"elevation": {
|
||||
"type": {
|
||||
"numeric": true
|
||||
}
|
||||
},
|
||||
"azimuth": {
|
||||
"type": {
|
||||
"numeric": true
|
||||
}
|
||||
},
|
||||
"indirect": {
|
||||
"type": {
|
||||
"numeric": true
|
||||
}
|
||||
},
|
||||
"shadows": {
|
||||
"type": {
|
||||
"bool": true
|
||||
}
|
||||
},
|
||||
"shadowCatcher": {
|
||||
"type": {
|
||||
"bool": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"privileges": [
|
||||
{
|
||||
"essential": true,
|
||||
"name": "WebAccess",
|
||||
"parameters": [
|
||||
"https://speckle.xyz",
|
||||
"https://*.speckle.xyz",
|
||||
"https://latest.speckle.dev",
|
||||
"https://*.speckle.dev",
|
||||
"https://analytics.speckle.systems",
|
||||
"*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"essential": false,
|
||||
"name": "ExportContent"
|
||||
},
|
||||
{
|
||||
"essential": true,
|
||||
"name": "LocalStorage",
|
||||
"parameters": []
|
||||
}
|
||||
],
|
||||
"sorting": {
|
||||
"default": {}
|
||||
},
|
||||
"supportsEmptyDataView": true,
|
||||
"supportsHighlight": true,
|
||||
"supportsKeyboardFocus": true,
|
||||
"supportsLandingPage": true,
|
||||
"keepAllMetadataColumns": true,
|
||||
"supportsMultiVisualSelection": true,
|
||||
"supportsSynchronizingFilterState": true,
|
||||
"suppressDefaultTitle": true,
|
||||
"tooltips": {
|
||||
"supportEnhancedTooltips": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"name": "@specklesystems/powerbi-visual",
|
||||
"description": "A 3D viewer for Speckle Object in PowerBI",
|
||||
"repository": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/specklesystems/speckle-powerbi-visuals"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"pbiviz": "pbiviz",
|
||||
"pack": "webpack --config webpack.config.ts",
|
||||
"build": "webpack --config webpack.config.dev.ts",
|
||||
"serve": "webpack-dev-server --config webpack.config.dev.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.21.5",
|
||||
"@babel/runtime-corejs3": "^7.21.5",
|
||||
"@headlessui/vue": "^1.7.13",
|
||||
"@heroicons/vue": "^2.0.12",
|
||||
"@speckle/tailwind-theme": "2.14.7",
|
||||
"@speckle/ui-components": "2.14.7",
|
||||
"@speckle/viewer": "^2.18.14",
|
||||
"color-interpolate": "^1.0.5",
|
||||
"core-js": "^3.30.2",
|
||||
"lodash": "^4.17.21",
|
||||
"postcss-loader": "^7.3.0",
|
||||
"postcss-preset-env": "^8.4.1",
|
||||
"powerbi-visuals-api": "~5.4.0",
|
||||
"powerbi-visuals-utils-colorutils": "^6.0.1",
|
||||
"powerbi-visuals-utils-dataviewutils": "^6.0.1",
|
||||
"powerbi-visuals-utils-formattingmodel": "^5.0.0",
|
||||
"powerbi-visuals-utils-interactivityutils": "^6.0.2",
|
||||
"powerbi-visuals-utils-tooltiputils": "^6.0.1",
|
||||
"regenerator-runtime": "^0.13.11",
|
||||
"vuex": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.21.8",
|
||||
"@babel/eslint-parser": "^7.21.8",
|
||||
"@babel/preset-env": "^7.21.5",
|
||||
"@tailwindcss/forms": "^0.5.3",
|
||||
"@types/lodash": "^4.14.194",
|
||||
"@types/node": "^20.1.7",
|
||||
"@types/regenerator-runtime": "^0.13.1",
|
||||
"@types/three": "^0.152.0",
|
||||
"@types/webpack": "^5.28.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.2",
|
||||
"@typescript-eslint/parser": "^5.59.2",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"babel-loader": "^9.1.2",
|
||||
"base64-inline-loader": "^2.0.1",
|
||||
"css-loader": "^6.7.3",
|
||||
"eslint": "^8.40.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-vue": "^9.13.0",
|
||||
"extra-watch-webpack-plugin": "^1.0.3",
|
||||
"json-loader": "^0.5.7",
|
||||
"mini-css-extract-plugin": "^2.7.5",
|
||||
"postcss": "^8.4.23",
|
||||
"postcss-import": "^15.1.0",
|
||||
"powerbi-visuals-tools": "^5.4.3",
|
||||
"powerbi-visuals-webpack-plugin": "^4.0.0",
|
||||
"prettier": "^2.8.8",
|
||||
"style-loader": "^3.3.2",
|
||||
"tailwindcss": "^3.3.2",
|
||||
"ts-loader": "^9.4.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsconfig-paths-webpack-plugin": "^4.0.1",
|
||||
"typescript": "^5.0.4",
|
||||
"user-agent-data-types": "^0.3.1",
|
||||
"vue": "^3.3.4",
|
||||
"vue-loader": "^17.1.1",
|
||||
"vue-template-compiler": "^2.7.14",
|
||||
"webpack": "^5.83.0",
|
||||
"webpack-bundle-analyzer": "^4.8.0",
|
||||
"webpack-cli": "^5.1.1",
|
||||
"webpack-dev-server": "^4.15.0"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"visual": {
|
||||
"name": "Speckle PowerBI Viewer",
|
||||
"displayName": "Speckle PowerBI Viewer",
|
||||
"guid": "specklePowerBiVisual",
|
||||
"visualClassName": "Visual",
|
||||
"version": "2.0.0",
|
||||
"description": "An interactive 3D viewer for Speckle Data",
|
||||
"supportUrl": "https://speckle.community",
|
||||
"gitHubUrl": "https://github.com/specklesystems/speckle-powerbi-visuals"
|
||||
},
|
||||
"apiVersion": "5.4.0",
|
||||
"author": { "name": "Speckle Systems", "email": "info@speckle.systems" },
|
||||
"assets": { "icon": "assets/logo.png" },
|
||||
"externalJS": [],
|
||||
"style": "style/visual.css",
|
||||
"capabilities": "capabilities.json",
|
||||
"dependencies": null,
|
||||
"stringResources": []
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
'postcss-nesting': {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import HomeView from './views/HomeView.vue'
|
||||
import ViewerView from './views/ViewerView.vue'
|
||||
import { computed } from 'vue'
|
||||
import { useStore } from 'vuex'
|
||||
import { storeKey } from 'src/injectionKeys'
|
||||
|
||||
let store = useStore(storeKey)
|
||||
let status = computed(() => {
|
||||
return store.state.status
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ViewerView v-if="status == 'valid'" />
|
||||
<HomeView v-else />
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,111 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
VideoCameraIcon,
|
||||
CubeIcon,
|
||||
ArrowsPointingOutIcon,
|
||||
PaintBrushIcon
|
||||
} from '@heroicons/vue/24/solid'
|
||||
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
|
||||
import { CanonicalView, SpeckleView } from '@speckle/viewer'
|
||||
import ButtonToggle from 'src/components/controls/ButtonToggle.vue'
|
||||
import ButtonGroup from 'src/components/controls/ButtonGroup.vue'
|
||||
import ButtonSimple from 'src/components/controls/ButtonSimple.vue'
|
||||
import { inject, watch } from 'vue'
|
||||
import { hostKey, viewerHandlerKey } from 'src/injectionKeys'
|
||||
import { resetPalette } from 'src/utils/matrixViewUtils'
|
||||
|
||||
const emits = defineEmits(['update:sectionBox', 'view-clicked', 'clear-palette'])
|
||||
const props = withDefaults(defineProps<{ sectionBox: boolean; views: SpeckleView[] }>(), {
|
||||
sectionBox: false,
|
||||
views: () => []
|
||||
})
|
||||
const viewerHandler = inject(viewerHandlerKey)
|
||||
const canonicalViews = [
|
||||
{ name: 'Top' },
|
||||
{ name: 'Front' },
|
||||
{ name: 'Left' },
|
||||
{ name: 'Back' },
|
||||
{ name: 'Right' }
|
||||
]
|
||||
|
||||
const onZoomExtentsClicked = (ev: MouseEvent) => {
|
||||
console.log('Zoom extents clicked', viewerHandler)
|
||||
viewerHandler.zoomExtents()
|
||||
}
|
||||
const host = inject(hostKey)
|
||||
const onClearPalletteClicked = (ev: MouseEvent) => {
|
||||
console.log('Clear pallette clicked')
|
||||
resetPalette()
|
||||
emits('clear-palette')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ButtonGroup>
|
||||
<ButtonSimple flat secondary @click="onZoomExtentsClicked">
|
||||
<ArrowsPointingOutIcon class="h-5 w-5" />
|
||||
</ButtonSimple>
|
||||
<Menu as="div" class="relative z-30">
|
||||
<MenuButton v-slot="{ open }" as="template">
|
||||
<ButtonToggle flat secondary :active="open">
|
||||
<VideoCameraIcon class="h-5 w-5" />
|
||||
</ButtonToggle>
|
||||
</MenuButton>
|
||||
<Transition
|
||||
enter-active-class="transform ease-out duration-300 transition"
|
||||
enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
|
||||
enter-to-class="translate-y-0 opacity-100 sm:translate-x-0"
|
||||
leave-active-class="transition ease-in duration-100"
|
||||
leave-from-class="opacity-100"
|
||||
leave-to-class="opacity-0"
|
||||
>
|
||||
<MenuItems
|
||||
class="absolute w-60 left-2 -translate-y-8 bottom-2 bg-foundation max-h-64 simple-scrollbar overflow-y-auto outline outline-2 outline-primary-muted rounded-lg shadow-lg overflow-hidden flex flex-col"
|
||||
>
|
||||
<MenuItem
|
||||
v-for="view in canonicalViews"
|
||||
:key="view.name"
|
||||
v-slot="{ active }"
|
||||
as="template"
|
||||
>
|
||||
<button
|
||||
:class="{
|
||||
'bg-primary text-foreground-on-primary': active,
|
||||
'text-foreground': !active,
|
||||
'text-sm py-2 transition': true
|
||||
}"
|
||||
@click="$emit('view-clicked', view.name.toLowerCase() as CanonicalView)"
|
||||
>
|
||||
{{ view.name }}
|
||||
</button>
|
||||
</MenuItem>
|
||||
<MenuItem v-for="view in views" :key="view.name" v-slot="{ active }" as="template">
|
||||
<button
|
||||
:class="{
|
||||
'bg-primary text-foreground-on-primary': active,
|
||||
'text-foreground': !active,
|
||||
'text-sm py-2 transition': true
|
||||
}"
|
||||
@click="$emit('view-clicked', view)"
|
||||
>
|
||||
{{ view.view.name ?? view.name }}
|
||||
</button>
|
||||
</MenuItem>
|
||||
</MenuItems>
|
||||
</Transition>
|
||||
</Menu>
|
||||
<ButtonToggle
|
||||
flat
|
||||
secondary
|
||||
:active="sectionBox"
|
||||
@click="$emit('update:sectionBox', !sectionBox)"
|
||||
>
|
||||
<CubeIcon class="h-5 w-5" />
|
||||
</ButtonToggle>
|
||||
<ButtonSimple flat secondary @click="onClearPalletteClicked">
|
||||
<PaintBrushIcon class="h-5 w-5" />
|
||||
</ButtonSimple>
|
||||
</ButtonGroup>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,184 @@
|
||||
<script async setup lang="ts">
|
||||
import {
|
||||
computed,
|
||||
inject,
|
||||
onBeforeUnmount,
|
||||
onMounted,
|
||||
provide,
|
||||
Ref,
|
||||
ref,
|
||||
watch,
|
||||
watchEffect
|
||||
} from 'vue'
|
||||
import { useStore } from 'vuex'
|
||||
import ViewerControls from 'src/components/ViewerControls.vue'
|
||||
import { CanonicalView, SpeckleView } from '@speckle/viewer'
|
||||
import { CommonLoadingBar } from '@speckle/ui-components'
|
||||
import ViewerHandler from 'src/handlers/viewerHandler'
|
||||
import { useClickDragged } from 'src/composables/useClickDragged'
|
||||
import { isMultiSelect } from 'src/utils/isMultiSelect'
|
||||
import {
|
||||
selectionHandlerKey,
|
||||
storeKey,
|
||||
tooltipHandlerKey,
|
||||
viewerHandlerKey
|
||||
} from 'src/injectionKeys'
|
||||
import { SpeckleDataInput } from 'src/types'
|
||||
import { debounce, throttle } from 'lodash'
|
||||
import { ContextOption } from 'src/settings/colorSettings'
|
||||
|
||||
const selectionHandler = inject(selectionHandlerKey)
|
||||
const tooltipHandler = inject(tooltipHandlerKey)
|
||||
const store = useStore(storeKey)
|
||||
const { dragged } = useClickDragged()
|
||||
|
||||
let viewerHandler: ViewerHandler = null
|
||||
let ac = new AbortController()
|
||||
|
||||
const container = ref<HTMLElement>()
|
||||
let bboxActive = ref(false)
|
||||
let views: Ref<SpeckleView[]> = ref([])
|
||||
let updateTask: Ref<Promise<void>> = ref(null)
|
||||
let setupTask: Promise<void> = null
|
||||
|
||||
const isLoading = computed(() => updateTask.value != null)
|
||||
const input = computed(() => store.state.input)
|
||||
const settings = computed(() => store.state.settings)
|
||||
|
||||
const onCameraMoved = throttle((_) => {
|
||||
const pos = tooltipHandler.currentTooltip?.worldPos
|
||||
if (!pos) return
|
||||
const screenPos = viewerHandler.getScreenPosition(pos)
|
||||
tooltipHandler.move(screenPos)
|
||||
}, 50)
|
||||
|
||||
onMounted(() => {
|
||||
viewerHandler = new ViewerHandler(container.value)
|
||||
provide<ViewerHandler>(viewerHandlerKey, viewerHandler)
|
||||
setupTask = viewerHandler
|
||||
.init()
|
||||
.then(() => viewerHandler.addCameraUpdateEventListener(onCameraMoved))
|
||||
.finally(async () => {
|
||||
if (input.value) await cancelAndHandleDataUpdate()
|
||||
viewerHandler.updateSettings(settings.value)
|
||||
})
|
||||
})
|
||||
|
||||
onBeforeUnmount(async () => {
|
||||
await viewerHandler.dispose()
|
||||
})
|
||||
|
||||
const debounceUpdate = throttle(cancelAndHandleDataUpdate, 500)
|
||||
const debounceSettingsUpdate = throttle(() => viewerHandler.updateSettings(settings.value), 500)
|
||||
watch(input, debounceUpdate)
|
||||
watch(settings, debounceSettingsUpdate)
|
||||
|
||||
watchEffect(() => {
|
||||
if (!isLoading.value) viewerHandler?.setSectionBox(bboxActive.value, input.value.objectIds)
|
||||
})
|
||||
|
||||
function handleDataUpdate(input: Ref<SpeckleDataInput>, signal: AbortSignal) {
|
||||
updateTask.value = setupTask
|
||||
.then(async () => {
|
||||
signal.throwIfAborted()
|
||||
// Clear previous selection
|
||||
await viewerHandler.selectObjects(null)
|
||||
|
||||
// Load
|
||||
await viewerHandler.loadObjectsWithAutoUnload(
|
||||
input.value.objectsToLoad,
|
||||
console.log,
|
||||
console.error,
|
||||
signal
|
||||
)
|
||||
|
||||
// Color
|
||||
await viewerHandler.colorObjectsByGroup(input.value.colorByIds)
|
||||
|
||||
await viewerHandler.unIsolateObjects()
|
||||
const objectsToIsolate =
|
||||
input.value.selectedIds.length == 0 ? input.value.objectIds : input.value.selectedIds
|
||||
if (settings.value.color.context.value != ContextOption.show)
|
||||
await viewerHandler.isolateObjects(
|
||||
objectsToIsolate,
|
||||
settings.value.color.context.value === ContextOption.ghosted
|
||||
)
|
||||
if (settings.value.camera.zoomOnDataChange.value) viewerHandler.zoom(objectsToIsolate)
|
||||
|
||||
// Update available views
|
||||
views.value = viewerHandler.getViews()
|
||||
})
|
||||
.catch((e: Error) => {
|
||||
console.log('Loading operation was aborted', e)
|
||||
})
|
||||
.finally(() => {
|
||||
updateTask.value = null
|
||||
})
|
||||
}
|
||||
|
||||
async function cancelAndHandleDataUpdate() {
|
||||
console.log('Input has changed', input.value)
|
||||
if (updateTask.value) {
|
||||
ac.abort('New input is available')
|
||||
console.log('Cancelling previous load job')
|
||||
await updateTask.value
|
||||
ac = new AbortController()
|
||||
}
|
||||
const signal = ac.signal
|
||||
handleDataUpdate(input, signal)
|
||||
}
|
||||
|
||||
async function onCanvasClick(ev: MouseEvent) {
|
||||
if (dragged.value) return
|
||||
const intersectResult = await viewerHandler.intersect({ x: ev.clientX, y: ev.clientY })
|
||||
const multi = isMultiSelect(ev)
|
||||
const hit = intersectResult?.hit
|
||||
if (hit) {
|
||||
const id = hit.object.id as string
|
||||
if (multi || !selectionHandler.isSelected(id)) await selectionHandler.select(id, multi)
|
||||
tooltipHandler.show(hit, { x: ev.clientX, y: ev.clientY })
|
||||
const selection = selectionHandler.getCurrentSelection()
|
||||
const ids = selection.map((s) => s.id)
|
||||
await viewerHandler.selectObjects(ids)
|
||||
} else {
|
||||
tooltipHandler.hide()
|
||||
if (!multi) {
|
||||
selectionHandler.clear()
|
||||
await viewerHandler.selectObjects(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function onCanvasAuxClick(ev: MouseEvent) {
|
||||
if (ev.button != 2 || dragged.value) return
|
||||
const intersectResult = await viewerHandler.intersect({ x: ev.clientX, y: ev.clientY })
|
||||
await selectionHandler.showContextMenu(ev, intersectResult?.hit)
|
||||
}
|
||||
|
||||
function onClearPalette() {
|
||||
cancelAndHandleDataUpdate()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col justify-center items-center">
|
||||
<div
|
||||
ref="container"
|
||||
class="fixed h-full w-full z-0"
|
||||
@click="onCanvasClick"
|
||||
@auxclick="onCanvasAuxClick"
|
||||
/>
|
||||
<div class="z-30 w-1/2 px-10">
|
||||
<common-loading-bar :loading="isLoading" />
|
||||
</div>
|
||||
<viewer-controls
|
||||
v-if="!isLoading"
|
||||
v-model:section-box="bboxActive"
|
||||
:views="views"
|
||||
class="fixed bottom-6"
|
||||
@view-clicked="(view) => viewerHandler.setView(view)"
|
||||
@clearPalette="onClearPalette"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,8 @@
|
||||
<template>
|
||||
<button
|
||||
class="bg-foundation text-foreground shadow-md rounded-lg h-10 flex justify-center space-x-2 px-1"
|
||||
>
|
||||
<slot></slot>
|
||||
</button>
|
||||
</template>
|
||||
<script setup lang="ts"></script>
|
||||
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<button
|
||||
ref="button"
|
||||
:class="`transition rounded-lg w-10 h-10 flex items-center justify-center ${shadowClasses} ${colorClasses} active:scale-[0.9] outline-none`"
|
||||
>
|
||||
<slot></slot>
|
||||
</button>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
|
||||
let active = ref(false)
|
||||
let button = ref<HTMLElement>()
|
||||
|
||||
const props = defineProps<{
|
||||
flat?: boolean
|
||||
secondary?: boolean
|
||||
}>()
|
||||
|
||||
const shadowClasses = computed(() => (props.flat ? '' : 'shadow-md'))
|
||||
|
||||
const colorClasses = computed(() => {
|
||||
const parts = []
|
||||
if (active.value) {
|
||||
if (props.secondary) parts.push('bg-foundation text-primary')
|
||||
else parts.push('bg-primary text-foreground-on-primary')
|
||||
} else {
|
||||
parts.push('bg-foundation text-foreground')
|
||||
}
|
||||
return parts.join(' ')
|
||||
})
|
||||
|
||||
const onPointerDown = () => (active.value = true)
|
||||
const onPointerUp = () => (active.value = false)
|
||||
|
||||
onMounted(() => {
|
||||
button.value.addEventListener('pointerdown', onPointerDown)
|
||||
button.value.addEventListener('pointerup', onPointerUp)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
button.value.removeEventListener('pointerdown', onPointerDown)
|
||||
button.value.removeEventListener('pointerup', onPointerUp)
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<button
|
||||
:class="`transition rounded-lg w-10 h-10 flex items-center justify-center ${shadowClasses} ${colorClasses} active:scale-[0.9] outline-none`"
|
||||
>
|
||||
<slot></slot>
|
||||
</button>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
active?: boolean
|
||||
flat?: boolean
|
||||
secondary?: boolean
|
||||
}>()
|
||||
|
||||
const shadowClasses = computed(() => (props.flat ? '' : 'shadow-md'))
|
||||
|
||||
const colorClasses = computed(() => {
|
||||
const parts = []
|
||||
if (props.active) {
|
||||
if (props.secondary) parts.push('bg-foundation text-primary')
|
||||
else parts.push('bg-primary text-foreground-on-primary')
|
||||
} else {
|
||||
parts.push('bg-foundation text-foreground')
|
||||
}
|
||||
return parts.join(' ')
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,51 @@
|
||||
import { ref, onMounted, onUnmounted, Ref } from 'vue'
|
||||
|
||||
// by convention, composable function names start with "use"
|
||||
export function useClickDragged(threshold = 1) {
|
||||
// state encapsulated and managed by the composable
|
||||
const dragged = ref(false)
|
||||
const distance = ref(0)
|
||||
const start: Ref<{ x: number; y: number }> = ref(null)
|
||||
const current: Ref<{ x: number; y: number }> = ref(null)
|
||||
function onPointerMove(ev) {
|
||||
distance.value = Math.sqrt(
|
||||
Math.pow(ev.x - start.value.x, 2) * Math.pow(ev.y - start.value.y, 2)
|
||||
)
|
||||
if (distance.value > threshold) {
|
||||
dragged.value = true
|
||||
}
|
||||
}
|
||||
|
||||
function onPointerDown(ev) {
|
||||
dragged.value = false
|
||||
start.value = { x: ev.x, y: ev.y }
|
||||
current.value = start.value
|
||||
distance.value = 0
|
||||
document.addEventListener('pointermove', onPointerMove)
|
||||
}
|
||||
|
||||
function onPointerUp(_) {
|
||||
if (dragged.value === false) reset()
|
||||
|
||||
document.removeEventListener('pointermove', onPointerMove)
|
||||
}
|
||||
function reset() {
|
||||
start.value = null
|
||||
current.value = null
|
||||
distance.value = 0
|
||||
}
|
||||
|
||||
// a composable can also hook into its owner component's
|
||||
// lifecycle to setup and teardown side effects.
|
||||
onMounted(() => {
|
||||
document.addEventListener('pointerdown', onPointerDown)
|
||||
document.addEventListener('pointerup', onPointerUp)
|
||||
})
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('pointerdown', onPointerDown)
|
||||
document.removeEventListener('pointerup', onPointerUp)
|
||||
})
|
||||
|
||||
// expose managed state as return value
|
||||
return { dragged, distance }
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
export default class SelectionHandler {
|
||||
private selectionIdMap: Map<string, powerbi.extensibility.ISelectionId>
|
||||
private currentSelection: Set<string>
|
||||
private selectionManager: powerbi.extensibility.ISelectionManager
|
||||
private host: powerbi.extensibility.visual.IVisualHost
|
||||
|
||||
public constructor(host: powerbi.extensibility.visual.IVisualHost) {
|
||||
this.host = host
|
||||
this.selectionManager = this.host.createSelectionManager()
|
||||
this.selectionIdMap = new Map<string, powerbi.extensibility.ISelectionId>()
|
||||
this.currentSelection = new Set<string>()
|
||||
}
|
||||
|
||||
public async showContextMenu(ev: MouseEvent, hit?) {
|
||||
const selectionId = !hit ? null : this.selectionIdMap.get(hit?.object?.id)
|
||||
|
||||
return this.selectionManager.showContextMenu(selectionId, {
|
||||
x: ev.clientX,
|
||||
y: ev.clientY
|
||||
})
|
||||
}
|
||||
|
||||
public set(url: string, data: powerbi.extensibility.ISelectionId) {
|
||||
this.selectionIdMap.set(url, data)
|
||||
}
|
||||
public async select(url: string, multi = false) {
|
||||
if (multi) {
|
||||
await this.selectionManager.select(this.selectionIdMap.get(url), true)
|
||||
if (this.currentSelection.has(url)) this.currentSelection.delete(url)
|
||||
else this.currentSelection.add(url)
|
||||
} else {
|
||||
await this.selectionManager.select(this.selectionIdMap.get(url), false)
|
||||
this.currentSelection.clear()
|
||||
this.currentSelection.add(url)
|
||||
}
|
||||
}
|
||||
|
||||
public getCurrentSelection(): { id: string; selectionId: powerbi.extensibility.ISelectionId }[] {
|
||||
return [...this.currentSelection].map((entry) => ({
|
||||
id: entry,
|
||||
selectionId: this.selectionIdMap.get(entry)
|
||||
}))
|
||||
}
|
||||
|
||||
public isSelected(id: string) {
|
||||
return this.currentSelection.has(id)
|
||||
}
|
||||
public clear() {
|
||||
this.selectionManager.clear()
|
||||
this.currentSelection.clear()
|
||||
}
|
||||
|
||||
public reset() {
|
||||
this.clear()
|
||||
this.selectionIdMap.clear()
|
||||
}
|
||||
|
||||
public has(url) {
|
||||
return this.selectionIdMap.has(url)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import powerbi from 'powerbi-visuals-api'
|
||||
import ITooltipService = powerbi.extensibility.ITooltipService
|
||||
import { IViewerTooltip } from '../types'
|
||||
import { SpeckleTooltip } from '../interfaces'
|
||||
|
||||
export default class TooltipHandler {
|
||||
private data: Map<string, IViewerTooltip>
|
||||
private tooltipService: ITooltipService
|
||||
public currentTooltip: SpeckleTooltip = null
|
||||
|
||||
constructor(tooltipService) {
|
||||
this.tooltipService = tooltipService
|
||||
this.data = new Map<string, IViewerTooltip>()
|
||||
}
|
||||
|
||||
public setup(data: Map<string, IViewerTooltip>) {
|
||||
this.data = data
|
||||
}
|
||||
|
||||
public show(hit: { guid: string; object?; point }, screenLoc) {
|
||||
const id = hit.object.id as string
|
||||
const objTooltipData: IViewerTooltip = this.data.get(id)
|
||||
if (!objTooltipData) return
|
||||
|
||||
const tooltipData = {
|
||||
coordinates: [screenLoc.x, screenLoc.y],
|
||||
dataItems: objTooltipData.data,
|
||||
identities: [objTooltipData.selectionId],
|
||||
isTouchEvent: false
|
||||
}
|
||||
|
||||
this.currentTooltip = {
|
||||
id: hit.object.id,
|
||||
worldPos: hit.point,
|
||||
screenPos: screenLoc,
|
||||
tooltip: tooltipData
|
||||
}
|
||||
|
||||
this.tooltipService.show(tooltipData)
|
||||
if (Object.keys(tooltipData.dataItems).length > 0) this.tooltipService.show(tooltipData)
|
||||
}
|
||||
|
||||
public hide() {
|
||||
this.tooltipService.hide({ immediately: true, isTouchEvent: false })
|
||||
this.currentTooltip = null
|
||||
}
|
||||
|
||||
public move(pos: { x: number; y: number }) {
|
||||
if (!this.currentTooltip) return
|
||||
this.currentTooltip.tooltip.coordinates = [pos.x, pos.y]
|
||||
this.tooltipService.move(this.currentTooltip.tooltip)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
import {
|
||||
CanonicalView,
|
||||
FilteringState,
|
||||
LegacyViewer,
|
||||
IntersectionQuery,
|
||||
DefaultViewerParams,
|
||||
Box3,
|
||||
SpeckleView,
|
||||
CameraController
|
||||
} from '@speckle/viewer'
|
||||
import { pickViewableHit, projectToScreen } from '../utils/viewerUtils'
|
||||
import _ from 'lodash'
|
||||
import { SpeckleVisualSettingsModel } from 'src/settings/visualSettingsModel'
|
||||
export default class ViewerHandler {
|
||||
private viewer: LegacyViewer
|
||||
private readonly parent: HTMLElement
|
||||
private state: FilteringState
|
||||
private loadedObjectsCache: Set<string> = new Set<string>()
|
||||
private config = {
|
||||
authToken: null,
|
||||
batchSize: 25
|
||||
}
|
||||
private currentSectionBox: Box3 = null
|
||||
private currentSettings: SpeckleVisualSettingsModel
|
||||
|
||||
public getViews() {
|
||||
return this.viewer.getViews()
|
||||
}
|
||||
|
||||
public updateSettings(settings: SpeckleVisualSettingsModel) {
|
||||
// Camera settings
|
||||
switch (settings.camera.projection.value) {
|
||||
case 'perspective':
|
||||
this.viewer.setPerspectiveCameraOn()
|
||||
break
|
||||
case 'orthographic':
|
||||
this.viewer.setOrthoCameraOn()
|
||||
break
|
||||
}
|
||||
|
||||
this.viewer.getExtension(CameraController).controls.maxPolarAngle = settings.camera
|
||||
.allowCameraUnder.value
|
||||
? Math.PI
|
||||
: Math.PI / 2
|
||||
|
||||
// Lighting settings
|
||||
const newConfig = settings.lighting.getViewerConfiguration()
|
||||
this.viewer.setLightConfiguration(newConfig)
|
||||
|
||||
this.currentSettings = settings
|
||||
}
|
||||
|
||||
public setView(view: SpeckleView | CanonicalView) {
|
||||
this.viewer.setView(view)
|
||||
}
|
||||
|
||||
public setSectionBox(active: boolean, objectIds: string[]) {
|
||||
if (active) {
|
||||
if (this.currentSectionBox === null) {
|
||||
const bbox = this.viewer.getSectionBoxFromObjects(objectIds)
|
||||
this.viewer.setSectionBox(bbox)
|
||||
this.currentSectionBox = bbox
|
||||
} else {
|
||||
const bbox = this.viewer.getCurrentSectionBox()
|
||||
if (bbox) this.currentSectionBox = bbox
|
||||
}
|
||||
this.viewer.sectionBoxOn()
|
||||
} else {
|
||||
this.viewer.sectionBoxOff()
|
||||
}
|
||||
this.viewer.requestRender()
|
||||
}
|
||||
|
||||
public addCameraUpdateEventListener(listener: (ev) => void) {
|
||||
this.viewer.getExtension(CameraController).controls.addEventListener('update', listener)
|
||||
}
|
||||
|
||||
public constructor(parent: HTMLElement) {
|
||||
this.parent = parent
|
||||
}
|
||||
|
||||
public async init() {
|
||||
if (this.viewer) return
|
||||
const viewerSettings = DefaultViewerParams
|
||||
viewerSettings.showStats = false
|
||||
viewerSettings.verbose = false
|
||||
const viewer = new LegacyViewer(this.parent, viewerSettings)
|
||||
await viewer.init()
|
||||
this.viewer = viewer
|
||||
}
|
||||
|
||||
public async unloadObjects(
|
||||
objects: string[],
|
||||
signal?: AbortSignal,
|
||||
onObjectUnloaded?: (url: string) => void
|
||||
) {
|
||||
for (const url of objects) {
|
||||
if (signal?.aborted) return
|
||||
await this.viewer
|
||||
.cancelLoad(url, true)
|
||||
.catch((e) => console.warn('Viewer Unload error', url, e))
|
||||
.finally(() => {
|
||||
if (this.loadedObjectsCache.has(url)) this.loadedObjectsCache.delete(url)
|
||||
if (onObjectUnloaded) onObjectUnloaded(url)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public async loadObjectsWithAutoUnload(
|
||||
objectUrls: string[],
|
||||
onLoad: (url: string, index: number) => void,
|
||||
onError: (url: string, error: Error) => void,
|
||||
signal: AbortSignal
|
||||
) {
|
||||
var objectsToUnload = _.difference([...this.loadedObjectsCache], objectUrls)
|
||||
await this.unloadObjects(objectsToUnload, signal)
|
||||
await this.loadObjects(objectUrls, onLoad, onError, signal)
|
||||
}
|
||||
|
||||
public async loadObjects(
|
||||
objectUrls: string[],
|
||||
onLoad: (url: string, index: number) => void,
|
||||
onError: (url: string, error: Error) => void,
|
||||
signal: AbortSignal
|
||||
) {
|
||||
try {
|
||||
let index = 0
|
||||
let promises = []
|
||||
for (const url of objectUrls) {
|
||||
signal.throwIfAborted()
|
||||
console.log('Attempting to load', url)
|
||||
if (!this.loadedObjectsCache.has(url)) {
|
||||
console.log('Object is not in cache')
|
||||
const promise = this.viewer
|
||||
.loadObjectAsync(url, this.config.authToken, false)
|
||||
.then(() => onLoad(url, index++))
|
||||
.catch((e: Error) => onError(url, e))
|
||||
.finally(() => {
|
||||
if (!this.loadedObjectsCache.has(url)) this.loadedObjectsCache.add(url)
|
||||
})
|
||||
promises.push(promise)
|
||||
if (promises.length == this.config.batchSize) {
|
||||
//this.promises.push(Promise.resolve(this.later(1000)))
|
||||
await Promise.all(promises)
|
||||
promises = []
|
||||
}
|
||||
} else {
|
||||
console.log('Object was already in cache')
|
||||
}
|
||||
}
|
||||
await Promise.all(promises)
|
||||
} catch (error) {
|
||||
if (error.name === 'AbortError') return
|
||||
throw new Error(`Load objects failed: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
public async intersect(coords: { x: number; y: number }) {
|
||||
const point = this.viewer.Utils.screenToNDC(
|
||||
coords.x,
|
||||
coords.y,
|
||||
this.parent.clientWidth,
|
||||
this.parent.clientHeight
|
||||
)
|
||||
const intQuery: IntersectionQuery = {
|
||||
operation: 'Pick',
|
||||
point
|
||||
}
|
||||
|
||||
const res = this.viewer.query(intQuery)
|
||||
if (!res) return null
|
||||
return {
|
||||
hit: pickViewableHit(res.objects, this.state),
|
||||
objects: res.objects
|
||||
}
|
||||
}
|
||||
public zoom(objectIds?: string[]) {
|
||||
this.viewer.zoom(objectIds)
|
||||
}
|
||||
|
||||
public zoomExtents() {
|
||||
this.viewer.zoom()
|
||||
}
|
||||
public async unIsolateObjects() {
|
||||
if (this.state.isolatedObjects)
|
||||
this.state = await this.viewer.unIsolateObjects(this.state.isolatedObjects, 'powerbi', true)
|
||||
}
|
||||
|
||||
public async isolateObjects(objectIds, ghost = false) {
|
||||
this.state = await this.viewer.isolateObjects(objectIds, 'powerbi', true, ghost)
|
||||
}
|
||||
|
||||
public async colorObjectsByGroup(
|
||||
groups?: {
|
||||
objectIds: string[]
|
||||
color: string
|
||||
}[]
|
||||
) {
|
||||
this.state = await this.viewer.setUserObjectColors(groups ?? [])
|
||||
}
|
||||
|
||||
public async clear() {
|
||||
if (this.viewer) await this.viewer.unloadAll()
|
||||
this.loadedObjectsCache.clear()
|
||||
}
|
||||
|
||||
public async selectObjects(objectIds: string[] = null) {
|
||||
if (!this.viewer) return
|
||||
await this.viewer.resetHighlight()
|
||||
const objIds = objectIds ?? []
|
||||
this.state = await this.viewer.selectObjects(objIds)
|
||||
}
|
||||
|
||||
public getScreenPosition(worldPosition): { x: number; y: number } {
|
||||
return projectToScreen(
|
||||
this.viewer.getExtension(CameraController).controls.camera,
|
||||
worldPosition
|
||||
)
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
this.viewer.getExtension(CameraController).controls.removeAllEventListeners()
|
||||
this.viewer.dispose()
|
||||
this.viewer = null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
declare module '*.png' {
|
||||
const source: string
|
||||
export default source
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { InjectionKey } from 'vue'
|
||||
import SelectionHandler from 'src/handlers/selectionHandler'
|
||||
import TooltipHandler from 'src/handlers/tooltipHandler'
|
||||
import { Store } from 'vuex'
|
||||
import { SpeckleVisualState } from 'src/store'
|
||||
import ViewerHandler from 'src/handlers/viewerHandler'
|
||||
|
||||
export const selectionHandlerKey: InjectionKey<SelectionHandler> = Symbol()
|
||||
export const tooltipHandlerKey: InjectionKey<TooltipHandler> = Symbol()
|
||||
export const hostKey: InjectionKey<powerbi.extensibility.visual.IVisualHost> = Symbol()
|
||||
export const storeKey: InjectionKey<Store<SpeckleVisualState>> = Symbol()
|
||||
export const viewerHandlerKey: InjectionKey<ViewerHandler> = Symbol()
|
||||
@@ -0,0 +1,20 @@
|
||||
import { IViewerTooltipData } from './types'
|
||||
|
||||
export interface SpeckleSelectionData {
|
||||
id: powerbi.extensibility.ISelectionId
|
||||
data: IViewerTooltipData[]
|
||||
}
|
||||
|
||||
export interface SpeckleTooltip {
|
||||
worldPos: {
|
||||
x: number
|
||||
y: number
|
||||
z: number
|
||||
}
|
||||
screenPos: {
|
||||
x: number
|
||||
y: number
|
||||
}
|
||||
tooltip
|
||||
id: string
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
|
||||
|
||||
export class CameraSettings extends fs.Card {
|
||||
public defaultView: fs.SimpleSlice = new fs.AutoDropdown({
|
||||
name: 'defaultView',
|
||||
displayName: 'Default View',
|
||||
value: 'perspective'
|
||||
})
|
||||
|
||||
public projection = new fs.AutoDropdown({
|
||||
name: 'projection',
|
||||
displayName: 'Projection',
|
||||
value: 'perspective'
|
||||
})
|
||||
|
||||
public allowCameraUnder = new fs.ToggleSwitch({
|
||||
name: 'allowCameraUnder',
|
||||
displayName: 'Allow under model',
|
||||
value: false
|
||||
})
|
||||
|
||||
public zoomOnDataChange = new fs.ToggleSwitch({
|
||||
name: 'zoomOnDataChange',
|
||||
displayName: 'Zoom extent on change',
|
||||
value: true
|
||||
})
|
||||
name = 'camera'
|
||||
displayName = 'Camera'
|
||||
slices: fs.Slice[] = [
|
||||
this.defaultView,
|
||||
this.projection,
|
||||
this.allowCameraUnder,
|
||||
this.zoomOnDataChange
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
|
||||
import {
|
||||
createDataViewWildcardSelector,
|
||||
DataViewWildcardMatchingOption
|
||||
} from 'powerbi-visuals-utils-dataviewutils/lib/dataViewWildcard'
|
||||
import VisualEnumerationInstanceKinds = powerbi.VisualEnumerationInstanceKinds
|
||||
|
||||
export enum ContextOption {
|
||||
hidden = 'hidden',
|
||||
ghosted = 'ghosted',
|
||||
show = 'show'
|
||||
}
|
||||
export class ColorSettings extends fs.Card {
|
||||
public enabled = new fs.ToggleSwitch({
|
||||
name: 'enabled',
|
||||
displayName: 'Enabled',
|
||||
value: true,
|
||||
topLevelToggle: true
|
||||
})
|
||||
|
||||
public fill = new fs.ColorPicker({
|
||||
name: 'fill',
|
||||
displayName: 'Color override',
|
||||
description:
|
||||
'Allows to override the colors of each object based on user-defined rules. Default color does not affect visualization.',
|
||||
value: { value: '#c5c5c5' },
|
||||
defaultColor: { value: '#c5c5c5' },
|
||||
selector: createDataViewWildcardSelector(DataViewWildcardMatchingOption.InstancesAndTotals),
|
||||
altConstantSelector: {
|
||||
static: {}
|
||||
},
|
||||
instanceKind: VisualEnumerationInstanceKinds.ConstantOrRule
|
||||
})
|
||||
|
||||
public context = new fs.AutoDropdown({
|
||||
name: 'context',
|
||||
displayName: 'Context display',
|
||||
description: 'Determines how to display objects not present in the input data table.',
|
||||
value: ContextOption.ghosted
|
||||
})
|
||||
|
||||
name = 'color'
|
||||
displayName = 'Object Display'
|
||||
slices: fs.Slice[] = [this.context, this.fill]
|
||||
}
|
||||
|
||||
export class ColorSelectorSettings extends fs.Card {
|
||||
name = 'colorSelector'
|
||||
displayName = 'Color Selector'
|
||||
slices = []
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
|
||||
import ValidatorType = powerbi.visuals.ValidatorType
|
||||
import { SunLightConfiguration } from '@speckle/viewer'
|
||||
|
||||
export class LightingSettings extends fs.Card {
|
||||
name = 'lighting'
|
||||
displayName = 'Lighting'
|
||||
|
||||
public enabled = new fs.ToggleSwitch({
|
||||
name: 'enabled',
|
||||
displayName: 'Enabled',
|
||||
value: true,
|
||||
topLevelToggle: true
|
||||
})
|
||||
|
||||
public intensity = new fs.Slider({
|
||||
name: 'intensity',
|
||||
displayName: 'Intensity',
|
||||
options: {
|
||||
minValue: { type: ValidatorType.Min, value: 1 },
|
||||
maxValue: { type: ValidatorType.Max, value: 10 }
|
||||
},
|
||||
value: 5
|
||||
})
|
||||
public elevation = new fs.Slider({
|
||||
name: 'elevation',
|
||||
displayName: 'Elevation',
|
||||
options: {
|
||||
minValue: { type: ValidatorType.Min, value: 0 },
|
||||
maxValue: { type: ValidatorType.Max, value: Math.PI }
|
||||
},
|
||||
value: 1.33
|
||||
})
|
||||
public azimuth = new fs.Slider({
|
||||
name: 'azimuth',
|
||||
displayName: 'azimuth',
|
||||
options: {
|
||||
minValue: { type: ValidatorType.Min, value: -Math.PI * 0.5 },
|
||||
maxValue: { type: ValidatorType.Max, value: Math.PI * 0.5 }
|
||||
},
|
||||
value: 0.75
|
||||
})
|
||||
public indirect = new fs.Slider({
|
||||
name: 'indirect',
|
||||
displayName: 'indirect',
|
||||
options: {
|
||||
minValue: { type: ValidatorType.Min, value: 0.0 },
|
||||
maxValue: { type: ValidatorType.Max, value: 5.0 }
|
||||
},
|
||||
value: 1.2
|
||||
})
|
||||
|
||||
public shadows = new fs.ToggleSwitch({
|
||||
name: 'shadows',
|
||||
displayName: 'Cast shadows',
|
||||
value: true
|
||||
})
|
||||
|
||||
public shadowCatcher = new fs.ToggleSwitch({
|
||||
name: 'shadowCatcher',
|
||||
displayName: 'Catch Shadows',
|
||||
value: true
|
||||
})
|
||||
|
||||
slices: fs.Slice[] = [
|
||||
this.intensity,
|
||||
this.elevation,
|
||||
this.azimuth,
|
||||
this.indirect,
|
||||
this.shadows,
|
||||
this.shadowCatcher
|
||||
]
|
||||
|
||||
public getViewerConfiguration(): SunLightConfiguration {
|
||||
return {
|
||||
enabled: this.enabled.value,
|
||||
castShadow: this.shadows.value,
|
||||
intensity: this.intensity.value,
|
||||
elevation: this.elevation.value,
|
||||
azimuth: this.azimuth.value,
|
||||
indirectLightIntensity: this.intensity.value,
|
||||
shadowcatcher: this.shadowCatcher.value
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
|
||||
import { ColorSelectorSettings, ColorSettings } from 'src/settings/colorSettings'
|
||||
import { CameraSettings } from 'src/settings/cameraSettings'
|
||||
import { LightingSettings } from 'src/settings/lightingSettings'
|
||||
|
||||
export class SpeckleVisualSettingsModel extends fs.Model {
|
||||
// Building my visual formatting settings card
|
||||
public color: ColorSettings = new ColorSettings()
|
||||
|
||||
public colorSelector: ColorSelectorSettings = new ColorSelectorSettings()
|
||||
|
||||
public camera: CameraSettings = new CameraSettings()
|
||||
|
||||
public lighting: LightingSettings = new LightingSettings()
|
||||
|
||||
cards = [this.color, this.camera, this.lighting]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
declare module '*.vue' {
|
||||
import type { DefineComponent } from 'vue'
|
||||
const component: DefineComponent<{}, {}, any>
|
||||
export default component
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { createStore } from 'vuex'
|
||||
import { SpeckleDataInput } from 'src/types'
|
||||
import { SpeckleVisualSettingsModel } from 'src/settings/visualSettingsModel'
|
||||
export type InputState = 'valid' | 'incomplete' | 'invalid'
|
||||
|
||||
export interface SpeckleVisualState {
|
||||
input?: SpeckleDataInput
|
||||
status: InputState
|
||||
settings: SpeckleVisualSettingsModel
|
||||
}
|
||||
|
||||
// Create a new store instance.
|
||||
export const store = createStore<SpeckleVisualState>({
|
||||
state() {
|
||||
return {
|
||||
input: null,
|
||||
status: 'incomplete',
|
||||
settings: null
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
setInput(state, input?: SpeckleDataInput) {
|
||||
state.input = input
|
||||
},
|
||||
setStatus(state, status: InputState) {
|
||||
state.status = status ?? 'invalid'
|
||||
},
|
||||
setSettings(state, settings: SpeckleVisualSettingsModel) {
|
||||
state.settings = settings
|
||||
},
|
||||
clearInput(state) {
|
||||
state.input = null
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
update(context, status: InputState, input?: SpeckleDataInput) {
|
||||
context.commit('setInput', input)
|
||||
context.commit('setStatus', status)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,19 @@
|
||||
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
|
||||
export interface IViewerTooltipData {
|
||||
displayName: string
|
||||
value: string
|
||||
}
|
||||
|
||||
export interface IViewerTooltip {
|
||||
selectionId: powerbi.extensibility.ISelectionId
|
||||
data: IViewerTooltipData[]
|
||||
}
|
||||
|
||||
export interface SpeckleDataInput {
|
||||
objectsToLoad: string[]
|
||||
objectIds: string[]
|
||||
selectedIds: string[]
|
||||
colorByIds: { objectIds: string[]; slice: fs.ColorPicker; color: string }[]
|
||||
objectTooltipData: Map<string, IViewerTooltip>
|
||||
view: powerbi.DataViewMatrix
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Add data types to window.navigator for use in this file. See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types- for more info.
|
||||
/// <reference types="user-agent-data-types" />
|
||||
export function getOS(): OS {
|
||||
const platform = window.navigator?.userAgentData?.platform || window.navigator.platform,
|
||||
macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K', 'macOS'],
|
||||
windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE']
|
||||
let os = null
|
||||
if (macosPlatforms.indexOf(platform) !== -1) {
|
||||
os = 'MacOS'
|
||||
} else if (windowsPlatforms.indexOf(platform) !== -1) {
|
||||
os = 'Windows'
|
||||
} else if (/Linux/.test(platform)) {
|
||||
os = 'Linux'
|
||||
}
|
||||
return os
|
||||
}
|
||||
|
||||
export enum OS {
|
||||
Windows,
|
||||
MacOS,
|
||||
Linux
|
||||
}
|
||||
|
||||
export const currentOS = getOS()
|
||||
@@ -0,0 +1,7 @@
|
||||
import { currentOS, OS } from './detectOS'
|
||||
|
||||
export function isMultiSelect(e: MouseEvent) {
|
||||
if (!e) return false
|
||||
if (currentOS === OS.MacOS) return e.metaKey || e.shiftKey
|
||||
else return e.ctrlKey || e.shiftKey
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
import powerbi from 'powerbi-visuals-api'
|
||||
import { IViewerTooltip, IViewerTooltipData, SpeckleDataInput } from '../types'
|
||||
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
|
||||
import {
|
||||
createDataViewWildcardSelector,
|
||||
DataViewWildcardMatchingOption
|
||||
} from 'powerbi-visuals-utils-dataviewutils/lib/dataViewWildcard'
|
||||
import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions
|
||||
import { SpeckleVisualSettingsModel } from 'src/settings/visualSettingsModel'
|
||||
|
||||
export function validateMatrixView(options: VisualUpdateOptions): {
|
||||
hasColorFilter: boolean
|
||||
view: powerbi.DataViewMatrix
|
||||
} {
|
||||
const matrixVew = options.dataViews[0].matrix
|
||||
if (!matrixVew) throw new Error('Data does not contain a matrix data view')
|
||||
|
||||
let hasStream = false,
|
||||
hasParentObject = false,
|
||||
hasObject = false,
|
||||
hasColorFilter = false
|
||||
|
||||
matrixVew.rows.levels.forEach((level) => {
|
||||
level.sources.forEach((source) => {
|
||||
if (!hasStream) hasStream = source.roles['stream'] != undefined
|
||||
if (!hasParentObject) hasParentObject = source.roles['parentObject'] != undefined
|
||||
if (!hasObject) hasObject = source.roles['object'] != undefined
|
||||
if (!hasColorFilter) hasColorFilter = source.roles['objectColorBy'] != undefined
|
||||
})
|
||||
})
|
||||
|
||||
if (!hasStream) throw new Error('Missing Stream ID input')
|
||||
if (!hasParentObject) throw new Error('Missing Commit Object ID input')
|
||||
if (!hasObject) throw new Error('Missing Object Id input')
|
||||
return {
|
||||
hasColorFilter,
|
||||
view: matrixVew
|
||||
}
|
||||
}
|
||||
|
||||
function processObjectValues(
|
||||
objectIdChild: powerbi.DataViewMatrixNode,
|
||||
matrixView: powerbi.DataViewMatrix
|
||||
) {
|
||||
const objectData: IViewerTooltipData[] = []
|
||||
let shouldColor = true,
|
||||
shouldSelect = false
|
||||
|
||||
if (objectIdChild.values)
|
||||
Object.keys(objectIdChild.values).forEach((key) => {
|
||||
const value: powerbi.DataViewMatrixNodeValue = objectIdChild.values[key]
|
||||
const k: unknown = key
|
||||
const colInfo = matrixView.valueSources[k as number]
|
||||
const highLightActive = value.highlight !== undefined
|
||||
if (highLightActive) {
|
||||
shouldColor = false
|
||||
}
|
||||
const isHighlighted = value.highlight !== null
|
||||
|
||||
if (highLightActive && isHighlighted) {
|
||||
shouldSelect = true
|
||||
shouldColor = true
|
||||
}
|
||||
const propData: IViewerTooltipData = {
|
||||
displayName: colInfo.displayName,
|
||||
value: value.value.toString()
|
||||
}
|
||||
objectData.push(propData)
|
||||
})
|
||||
return { data: objectData, shouldColor, shouldSelect }
|
||||
}
|
||||
|
||||
function processObjectNode(
|
||||
objectIdChild: powerbi.DataViewMatrixNode,
|
||||
host: powerbi.extensibility.visual.IVisualHost,
|
||||
matrixView: powerbi.DataViewMatrix
|
||||
): {
|
||||
data: IViewerTooltipData[]
|
||||
shouldColor: boolean
|
||||
shouldSelect: boolean
|
||||
id: string
|
||||
selectionId: powerbi.visuals.ISelectionId
|
||||
color?: string
|
||||
} {
|
||||
const objId = objectIdChild.value as string
|
||||
// Create selection IDs for each object
|
||||
const nodeSelection = host
|
||||
.createSelectionIdBuilder()
|
||||
.withMatrixNode(objectIdChild, matrixView.rows.levels)
|
||||
.createSelectionId()
|
||||
// Create value records for the tooltips
|
||||
const objectValues = processObjectValues(objectIdChild, matrixView)
|
||||
const res = { id: objId, selectionId: nodeSelection, color: undefined, ...objectValues }
|
||||
// Process node objects, if any.
|
||||
if (objectIdChild.objects) {
|
||||
//@ts-ignore
|
||||
const color = objectIdChild.objects.color.fill.solid.color as string
|
||||
console.log('⚠️ HAS objects', color)
|
||||
if (color) {
|
||||
res.color = color
|
||||
res.shouldColor = true
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
function processObjectIdLevel(
|
||||
parentObjectIdChild: powerbi.DataViewMatrixNode,
|
||||
host: powerbi.extensibility.visual.IVisualHost,
|
||||
matrixView: powerbi.DataViewMatrix
|
||||
) {
|
||||
return parentObjectIdChild.children?.map((objectIdChild) =>
|
||||
processObjectNode(objectIdChild, host, matrixView)
|
||||
)
|
||||
}
|
||||
|
||||
export let previousPalette = null
|
||||
|
||||
export function resetPalette() {
|
||||
previousPalette = null
|
||||
}
|
||||
export function processMatrixView(
|
||||
matrixView: powerbi.DataViewMatrix,
|
||||
host: powerbi.extensibility.visual.IVisualHost,
|
||||
hasColorFilter: boolean,
|
||||
settings: SpeckleVisualSettingsModel,
|
||||
onSelectionPair: (objId: string, selectionId: powerbi.extensibility.ISelectionId) => void
|
||||
): SpeckleDataInput {
|
||||
const objectUrlsToLoad = [],
|
||||
objectIds = [],
|
||||
selectedIds = [],
|
||||
colorByIds = [],
|
||||
objectTooltipData = new Map<string, IViewerTooltip>()
|
||||
|
||||
matrixView.rows.root.children.forEach((streamUrlChild) => {
|
||||
const url = streamUrlChild.value
|
||||
|
||||
streamUrlChild.children?.forEach((parentObjectIdChild) => {
|
||||
const parentId = parentObjectIdChild.value
|
||||
objectUrlsToLoad.push(`${url}/objects/${parentId}`)
|
||||
|
||||
if (!hasColorFilter) {
|
||||
processObjectIdLevel(parentObjectIdChild, host, matrixView).forEach((objRes) => {
|
||||
objectIds.push(objRes.id)
|
||||
onSelectionPair(objRes.id, objRes.selectionId)
|
||||
if (objRes.shouldSelect) selectedIds.push(objRes.id)
|
||||
if (objRes.color) {
|
||||
let group = colorByIds.find((g) => g.color === objRes.color)
|
||||
if (!group) {
|
||||
group = {
|
||||
color: objRes.color,
|
||||
objectIds: []
|
||||
}
|
||||
colorByIds.push(group)
|
||||
}
|
||||
group.objectIds.push(objRes.id)
|
||||
}
|
||||
objectTooltipData.set(objRes.id, {
|
||||
selectionId: objRes.selectionId,
|
||||
data: objRes.data
|
||||
})
|
||||
})
|
||||
} else {
|
||||
if (previousPalette) host.colorPalette['colorPalette'] = previousPalette
|
||||
parentObjectIdChild.children?.forEach((colorByChild) => {
|
||||
const colorSelectionId = host
|
||||
.createSelectionIdBuilder()
|
||||
.withMatrixNode(colorByChild, matrixView.rows.levels)
|
||||
.createSelectionId()
|
||||
|
||||
const color = host.colorPalette.getColor(colorByChild.value as string)
|
||||
if (colorByChild.objects) {
|
||||
console.log(
|
||||
'⚠️COLOR NODE HAS objects',
|
||||
colorByChild.objects,
|
||||
colorByChild.objects.color?.fill
|
||||
)
|
||||
}
|
||||
|
||||
const colorSlice = new fs.ColorPicker({
|
||||
name: 'selectorFill',
|
||||
displayName: colorByChild.value.toString(),
|
||||
value: {
|
||||
value: color.value
|
||||
},
|
||||
selector: colorSelectionId.getSelector()
|
||||
})
|
||||
|
||||
const colorGroup = {
|
||||
color: color.value,
|
||||
slice: colorSlice,
|
||||
objectIds: []
|
||||
}
|
||||
|
||||
processObjectIdLevel(colorByChild, host, matrixView).forEach((objRes) => {
|
||||
objectIds.push(objRes.id)
|
||||
onSelectionPair(objRes.id, objRes.selectionId)
|
||||
if (objRes.shouldSelect) selectedIds.push(objRes.id)
|
||||
if (objRes.shouldColor) {
|
||||
colorGroup.objectIds.push(objRes.id)
|
||||
}
|
||||
objectTooltipData.set(objRes.id, {
|
||||
selectionId: objRes.selectionId,
|
||||
data: objRes.data
|
||||
})
|
||||
})
|
||||
if (colorGroup.objectIds.length > 0) colorByIds.push(colorGroup)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
previousPalette = host.colorPalette['colorPalette']
|
||||
|
||||
return {
|
||||
objectsToLoad: objectUrlsToLoad,
|
||||
objectIds,
|
||||
selectedIds,
|
||||
colorByIds: colorByIds.length > 0 ? colorByIds : null,
|
||||
objectTooltipData,
|
||||
view: matrixView
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
const TRACK_URL = 'https://analytics.speckle.systems/track?ip=1'
|
||||
const MIXPANEL_TOKEN = 'acd87c5a50b56df91a795e999812a3a4'
|
||||
const HOST_APP_NAME = 'powerbi-visual'
|
||||
|
||||
export enum Event {
|
||||
Create = 'Create',
|
||||
Reload = 'Reload',
|
||||
Settings = 'Settings'
|
||||
}
|
||||
|
||||
export enum SettingsChangedType {
|
||||
Gradient = 'Gradient',
|
||||
DefaultCamera = 'DefaultCamera',
|
||||
OrthoMode = 'OrthoMode'
|
||||
}
|
||||
|
||||
export class Tracker {
|
||||
public static async track(event: Event, properties: any = {}) {
|
||||
return this.trackEvents([
|
||||
{
|
||||
event,
|
||||
properties
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
private static async trackEvents(events: Array<{ event: Event; properties: any }>) {
|
||||
try {
|
||||
await fetch(TRACK_URL, {
|
||||
method: 'POST',
|
||||
body:
|
||||
'data=' +
|
||||
JSON.stringify(
|
||||
events.map((e) => {
|
||||
Object.assign(e.properties, {
|
||||
token: MIXPANEL_TOKEN,
|
||||
hostApp: HOST_APP_NAME
|
||||
})
|
||||
return e
|
||||
})
|
||||
)
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('Create track failed', e)
|
||||
}
|
||||
}
|
||||
|
||||
public static loaded() {
|
||||
return this.track(Event.Create)
|
||||
}
|
||||
|
||||
public static dataReload() {
|
||||
return this.track(Event.Reload)
|
||||
}
|
||||
|
||||
public static settingsChanged(type: SettingsChangedType) {
|
||||
return this.track(Event.Settings, { type })
|
||||
}
|
||||
}
|
||||