Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Device Models Repository Client #14863

Merged
merged 87 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
f19be7a
first commit dmr
YoDaMa Feb 19, 2021
be96c30
rename
YoDaMa Feb 19, 2021
bdfc7fd
many changes
YoDaMa Apr 8, 2021
3f9798a
alot
YoDaMa Apr 8, 2021
8219fa9
refactor around new architecture
YoDaMa Apr 13, 2021
7e15c99
add more changes
YoDaMa Apr 13, 2021
438238f
remove tests and fix readme
YoDaMa Apr 13, 2021
da8a359
readme
YoDaMa Apr 13, 2021
b537e91
update infrastructure
YoDaMa Apr 13, 2021
117b6ba
more
YoDaMa Apr 13, 2021
f0c69e1
adding stuff
YoDaMa Apr 19, 2021
4fca643
linting
YoDaMa Apr 20, 2021
3f7c510
add launch.json to gitignore
YoDaMa Apr 20, 2021
c48dd65
fix vscode ignore
YoDaMa Apr 20, 2021
b755192
multiple
YoDaMa Apr 20, 2021
5589e21
Merge branch 'master' into device-models-tools
YoDaMa Apr 20, 2021
6e78c4e
adding api
YoDaMa Apr 20, 2021
0407787
update documentation
YoDaMa Apr 22, 2021
d20073c
example changes and bugfixes
YoDaMa Apr 24, 2021
a9ee639
refactor
YoDaMa Apr 28, 2021
84e25d9
bugfixes
YoDaMa May 4, 2021
9686d19
bugfixes
YoDaMa May 4, 2021
9650a3e
change readmes
YoDaMa May 4, 2021
bd9e9c4
fix
YoDaMa May 4, 2021
d17b3a6
update tests
YoDaMa May 13, 2021
635fe5b
update npm lock
YoDaMa May 13, 2021
6d99014
add back tests
YoDaMa May 13, 2021
7e33fd2
Fix ReadMe
YoDaMa May 14, 2021
98904a5
fix readme
YoDaMa May 14, 2021
f4e6792
update readmes
YoDaMa May 14, 2021
a393f91
addressing comments
YoDaMa May 17, 2021
76ac761
split URL to node/browser versions and add brower mapping to package.…
chradek May 17, 2021
54a6be1
Merge pull request #1 from chradek/iot-models-repo
YoDaMa May 17, 2021
513fb55
fixes
YoDaMa May 17, 2021
7207a5f
Merge branch 'device-models-tools' of https://github.com/YoDaMa/azure…
YoDaMa May 17, 2021
cc50153
updating samples and tests
YoDaMa May 18, 2021
38ff0f3
Merge remote-tracking branch 'upstream/master' into device-models-tools
YoDaMa May 18, 2021
aa8f0cd
update pnpm
YoDaMa May 18, 2021
684f954
allowinsecureConnection
YoDaMa May 18, 2021
83446b2
remove unnecessary env
YoDaMa May 18, 2021
cf9c75a
point to package
YoDaMa May 18, 2021
8326da7
readability
YoDaMa May 18, 2021
63828a0
remove old api
YoDaMa May 18, 2021
99a5ed5
comments
YoDaMa May 18, 2021
dd61713
tweaks
YoDaMa May 18, 2021
f8daa06
remove resolverError
YoDaMa May 18, 2021
bcfc92f
update resolver code
YoDaMa May 18, 2021
a6fab62
remove then
YoDaMa May 18, 2021
e34ed32
add link
YoDaMa May 18, 2021
7d06b30
fetcher changes
YoDaMa May 18, 2021
88dc580
update code
YoDaMa May 18, 2021
a2804b4
changes
YoDaMa May 18, 2021
e9ac523
fix api
YoDaMa May 19, 2021
3393208
remove en
YoDaMa May 19, 2021
18ff958
normalize
YoDaMa May 19, 2021
b006c90
fix
YoDaMa May 19, 2021
5d836c3
remove circular dependencies and fix mappings
chradek May 19, 2021
86a0a1d
Merge pull request #2 from chradek/iot-models-repo-test
YoDaMa May 19, 2021
92f6998
fix dependency
YoDaMa May 19, 2021
1702077
fix browser tst
YoDaMa May 19, 2021
c9300eb
fix links
YoDaMa May 20, 2021
1a16b3b
remove env
YoDaMa May 20, 2021
c8d840a
fix api ref link
YoDaMa May 20, 2021
ed45199
remove bad link
YoDaMa May 20, 2021
c61bdd5
fix
YoDaMa May 20, 2021
b3a9d2e
samples
YoDaMa May 20, 2021
3bc841a
remove v0 samples
YoDaMa May 20, 2021
9cd6f42
change constant
YoDaMa May 20, 2021
c2a5da1
add const unit test
YoDaMa May 20, 2021
734bda0
address comments
YoDaMa May 20, 2021
14a1861
remove todos
YoDaMa May 20, 2021
c6b2e0e
remove extend
YoDaMa May 20, 2021
8a8360d
remove how to use
YoDaMa May 21, 2021
1e3e54c
formattign
YoDaMa May 21, 2021
fd28662
adjust
YoDaMa May 21, 2021
e4e0aad
date
YoDaMa May 21, 2021
cd32118
update lockfile
YoDaMa May 21, 2021
3c0ba8f
Merge remote-tracking branch 'upstream/master' into device-models-tools
YoDaMa May 21, 2021
09500de
fix
YoDaMa May 21, 2021
3479f5f
fix stuff
YoDaMa May 21, 2021
7558cd8
first
YoDaMa May 21, 2021
626fccd
remove gitignore changes
YoDaMa May 21, 2021
96505be
remove dom
YoDaMa May 21, 2021
471acf5
add documentation
YoDaMa May 21, 2021
897c899
change constants
YoDaMa May 21, 2021
20a7b3c
add dom
YoDaMa May 21, 2021
a80e4a1
add comments for dom
YoDaMa May 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ examples/bin
.vs
TestResults/*
.vscode/*
**/.vscode/*
YoDaMa marked this conversation as resolved.
Show resolved Hide resolved
./**/.vscode/*


# Node #
**/node_modules/
**/cjs/
Expand Down Expand Up @@ -152,4 +154,4 @@ tsdoc-metadata.json
swagger/*.json

#autorest artifacts
code-model-*
code-model-*
56 changes: 55 additions & 1 deletion common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,11 @@
"projectFolder": "sdk/digitaltwins/digital-twins-core",
"versionPolicyName": "client"
},
{
"packageName": "@azure/iot-modelsrepository",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the package name should be updated to @azure/iot-models-repository. The typical convention is to use dashes to separate words in package names (e.g. iot-device-update)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you for the typical convention, but to follow the same naming convention for the existing models repository clients in other languages, (see python), keeping it as @azure/iot-modelsrepository will maintain cross language consistency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we care about 'cross language consistency' for package names? The package names are already quite different for assembly-based systems like C# and Java. I don't think JS customers care about Python package naming conventions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We got feedback from the SDK review board to use modelsrepository as the service name. We are trying to be consistent across language SDKs to make it easier to find the package/code.

I see other JS packages not using that convention eg: @azure/servicefabric

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example is not a track 2 library. Every track 2 package in https://github.com/Azure/azure-sdk-for-js/blob/master/rush.json appears to use dash as a separator.

Do you believe that folks searching npm won't find models-respository over modelsrepository? I would imagine folks would search with a space, and most indexers break on - but would have more trouble doing prefix searches for partial matches.

"projectFolder": "sdk/iot/modelsrepository",
"versionPolicyName": "client"
},
{
"packageName": "@azure-tests/perf-ai-form-recognizer",
"projectFolder": "sdk/formrecognizer/perf-tests/ai-form-recognizer",
Expand Down
1 change: 1 addition & 0 deletions sdk/iot/modelsrepository/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
19 changes: 19 additions & 0 deletions sdk/iot/modelsrepository/.nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"include": [
"dist-esm/src/**/*.js"
],
"exclude": [
"**/*.d.ts",
"dist-esm/src/generated/*"
],
"reporter": [
"text-summary",
"html",
"cobertura"
],
"exclude-after-remap": false,
"sourceMap": true,
"produce-source-map": true,
"instrument": true,
"all": true
}
45 changes: 45 additions & 0 deletions sdk/iot/modelsrepository/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Program",
"program": "${workspaceFolder}/samples/javascript/example.js",
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"console": "integratedTerminal",
"type": "pwa-node"
},
{
"name": "temp-unit-test",
"request": "launch",
"runtimeArgs": ["run", "temp-unit-test"],
"runtimeExecutable": "npm",
"skipFiles": ["<node_internals>/**"],
"console": "externalTerminal",
"type": "pwa-node"
},
{
"type": "chrome",
"request": "attach",
"name": "Attach Karma Chrome",
"address": "localhost",
"port": 9876,
"pathMapping": {
"/": "${workspaceRoot}/",
"/base/": "${workspaceRoot}/"
}
},
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Test",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}\\test\\node\\index.spec.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": ["${workspaceFolder}/out/**/*.js"]
}
]
}
3 changes: 3 additions & 0 deletions sdk/iot/modelsrepository/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Release History

CURRENTLY NO RELEASE HISTORY. TO BE FILLED IN AFTER FIRST RELEASE.
YoDaMa marked this conversation as resolved.
Show resolved Hide resolved
21 changes: 21 additions & 0 deletions sdk/iot/modelsrepository/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
73 changes: 73 additions & 0 deletions sdk/iot/modelsrepository/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Azure IoT Models Repository client library for JavaScript

This package contains an isomorphic Client Library for Azure IoT Models Repository in JavaScript. Use the Azure IoT Models Repository library for JavaScript to pull DTDL files from remote endpoints.

[Source code](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/iot/modelsrepository) |
[Package (npm)](https://www.npmjs.com/package/@azure/iot-modelsrepository/) |
[Samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/storage/iot-modelsrepository/samples)

-------------------------------------

# Getting started

## Key concepts

The Azure IoT Models Repository library for JavaScript is written to interact with the Azure IoT PlugAndPlay Models Repository, for those developers who wish to write applications in JavaScript to do so.
YoDaMa marked this conversation as resolved.
Show resolved Hide resolved

### Currently supported environments

- Node.js version 8.x.x or higher
- Browser JavaScript

### How to Install

The preferred way to install the Azure IoT Models Repository client library for JavaScript is to use the npm package manager. Type the following into a terminal window:

```
npm install @azure/iot-modelsrepository
```

# Examples

## nodejs - Authentication, client creation and get ioTSpaces as an example written in TypeScript.
YoDaMa marked this conversation as resolved.
Show resolved Hide resolved

### Sample code
YoDaMa marked this conversation as resolved.
Show resolved Hide resolved

```ts
import { ModelsRepositoryClient } from "@azure/iot-modelsrepository";

const client = new ModelsRepositoryClient("https://devicemodels.azure.com");
YoDaMa marked this conversation as resolved.
Show resolved Hide resolved
const result = await client.getModels("dtmi:azure:DeviceManagement:DeviceInformation;1");
console.log(result);
```

-----------------------------------------

# Troubleshooting

- If you run into an error, first make sure the model you are access exists at the location you are attempting to get it from.

# Next steps

- Review the [DTDL Spec](https://docs.microsoft.com/en-us/azure/iot-pnp/concepts-model-parser).
- Understand the [Device Models Repository](https://devicemodels.azure.com/).
- Code a IoT Plug and Play 'Device' using the [Azure IoT SDK for Node](https://github.com/Azure/azure-iot-sdk-node/tree/master/device/samples/pnp/readme.md).

# Related projects

- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)

# Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

31 changes: 31 additions & 0 deletions sdk/iot/modelsrepository/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "types/src/index.d.ts",
"docModel": {
"enabled": true
},
"apiReport": {
"enabled": true,
"reportFolder": "./review"
},
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/iot-models-repository.d.ts"
},
"messages": {
"tsdocMessageReporting": {
"default": {
"logLevel": "none"
}
},
"extractorMessageReporting": {
"ae-missing-release-tag": {
"logLevel": "none"
},
"ae-unresolved-link": {
"logLevel": "none"
}
}
}
}
Loading