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

Cgerman/client cache #3

Merged
merged 74 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
83318bc
Init Commit Alot Broken
CalebGerman Aug 8, 2023
78dc74a
Finished Client Interfaces
CalebGerman Aug 11, 2023
db671e1
Cleaned Up And Added Validation For Some Interfaces
CalebGerman Aug 11, 2023
fbdd047
Edited Clients
CalebGerman Aug 15, 2023
ecd62ba
Cleaned Up Clients And Renamed Files
CalebGerman Aug 15, 2023
a44ebce
Moved Files To Correct Place
CalebGerman Aug 15, 2023
e8c5391
Fixed File Imports
CalebGerman Aug 16, 2023
fd525ff
Fixed Yarn Package Utils Pull In
CalebGerman Aug 16, 2023
f88f396
Pulled in new package
CalebGerman Aug 18, 2023
382ba04
Mad new package
CalebGerman Aug 18, 2023
2ef5f46
Mad new package
CalebGerman Aug 18, 2023
f52dff7
Added Lint Ignore Flags For Any And Deprecated Property
CalebGerman Aug 18, 2023
8cfeb07
Fixed linting Issues
CalebGerman Aug 18, 2023
4e43241
Fixed Export Issue
CalebGerman Aug 18, 2023
87e4c91
Moved Everything into One File
CalebGerman Aug 21, 2023
4a384c4
combined some interfaces
CalebGerman Aug 21, 2023
b9ca301
removed unused interfaces and moved files around
CalebGerman Aug 21, 2023
e1b1d08
Address PR Comments
CalebGerman Aug 22, 2023
da8d411
Fixed Linting Error
CalebGerman Aug 22, 2023
027e968
Fixed Linting Error
CalebGerman Aug 23, 2023
2fafd5c
Addressed Comments On PR
CalebGerman Aug 24, 2023
ba7d791
Addressed Comments On PR
CalebGerman Aug 25, 2023
19e5653
Fixed imports and moved CommonClientInterface out
CalebGerman Aug 29, 2023
465fcc5
Got rid of dto suffix on files
CalebGerman Aug 29, 2023
4cf3942
merged files
CalebGerman Aug 29, 2023
35931db
Combined Interfaces and cleaned up comments
CalebGerman Aug 30, 2023
ec37522
Moved File
CalebGerman Aug 30, 2023
8591f12
removed linting code
CalebGerman Aug 30, 2023
19335ee
Got rid of body args
CalebGerman Aug 31, 2023
1bc3eb9
fixed type errors
CalebGerman Aug 31, 2023
9d2be19
Changed return types
CalebGerman Aug 31, 2023
ab9ff3c
Apply suggestions from code review
CalebGerman Sep 1, 2023
f2f0177
Apply suggestions from code review
CalebGerman Sep 1, 2023
ea8f49a
Apply suggestions from code review
CalebGerman Sep 1, 2023
8658b36
Apply suggestions from code review
CalebGerman Sep 1, 2023
761456b
Apply suggestions from code review
CalebGerman Sep 1, 2023
be663f4
Apply suggestions from code review
CalebGerman Sep 1, 2023
cdc3ef5
Apply suggestions from code review
CalebGerman Sep 1, 2023
1b65b26
Apply suggestions from code review
CalebGerman Sep 1, 2023
a67c6c9
Apply suggestions from code review
CalebGerman Sep 1, 2023
10c6d71
Apply suggestions from code review
CalebGerman Sep 1, 2023
32884c4
Apply suggestions from code review
CalebGerman Sep 1, 2023
1b7cf75
Apply suggestions from code review
CalebGerman Sep 1, 2023
b196963
Apply suggestions from code review
CalebGerman Sep 1, 2023
4a84437
Apply suggestions from code review
CalebGerman Sep 1, 2023
1cec64f
Apply suggestions from code review
CalebGerman Sep 1, 2023
ee20995
Apply suggestions from code review
CalebGerman Sep 1, 2023
df0af30
Apply suggestions from code review
CalebGerman Sep 1, 2023
db0eb71
Apply suggestions from code review
CalebGerman Sep 1, 2023
85fbf41
Addressed Comments
CalebGerman Sep 1, 2023
ec6e77d
Addressed Comments
CalebGerman Sep 1, 2023
d20bb40
Addressed Comments
CalebGerman Sep 1, 2023
5864616
Addressed Comments
CalebGerman Sep 1, 2023
99c1906
Addressed Comments
CalebGerman Sep 5, 2023
d935e74
Fixed ITwin Spelling And Fixed Imports Formmat
CalebGerman Sep 6, 2023
a94f7b4
Apply suggestions from code review
CalebGerman Sep 6, 2023
5950dd1
Apply suggestions from code review
CalebGerman Sep 6, 2023
4d7a2ed
Apply suggestions from code review
CalebGerman Sep 6, 2023
2e8dc4a
updated read me
CalebGerman Sep 6, 2023
790e659
Merge branch 'Cgerman/ClientCache' of https://github.com/iTwin/saved-…
CalebGerman Sep 6, 2023
fe7bd02
Apply suggestions from code review
CalebGerman Sep 6, 2023
c8cc794
Fixed Linting Errors
CalebGerman Sep 6, 2023
93a9b54
Merge branch 'Cgerman/ClientCache' of https://github.com/iTwin/saved-…
CalebGerman Sep 6, 2023
bb3b1ef
Moved Symbols Around In ItwinSavedViewsClient SavedViewClient
CalebGerman Sep 6, 2023
1afbd50
Moved order of things around
CalebGerman Sep 7, 2023
b3ab060
Added API Tests
CalebGerman Sep 7, 2023
13b1692
Moved Methods Around
CalebGerman Sep 7, 2023
9ae3166
Apply suggestions from code review
CalebGerman Sep 8, 2023
cbd6ba3
Fixed Tests Up
CalebGerman Sep 8, 2023
38a405f
Merge branch 'Cgerman/ClientCache' of https://github.com/iTwin/saved-…
CalebGerman Sep 8, 2023
84f7b1b
Fixed Spacing
CalebGerman Sep 8, 2023
c76f036
Apply suggestions from code review
CalebGerman Sep 11, 2023
58a5ef0
Apply suggestions from code review
CalebGerman Sep 11, 2023
b406d7c
Renamed File updated exports and fixed readme
CalebGerman Sep 11, 2023
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"lint": "eslint '**/*.{ts,tsx}'",
"typecheck": "run-p --silent typecheck:*",
"typecheck:components": "npm run typecheck --prefix packages/saved-views-react",
"typecheck:client": "npm run typecheck --prefix packages/saved-views-client",
"typecheck:backend": "npm run typecheck --prefix packages/test-app-backend",
"typecheck:frontend": "npm run typecheck --prefix packages/test-app-frontend",
"release": "ts-node --esm scripts/release.ts"
Expand Down
5 changes: 5 additions & 0 deletions packages/saved-views-client/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"no-console": "warn"
}
}
9 changes: 9 additions & 0 deletions packages/saved-views-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

All notable changes to this package will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/iTwin/saved-views-react/tree/HEAD/packages/saved-views-client)

Initial package release.
9 changes: 9 additions & 0 deletions packages/saved-views-client/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# MIT License

Copyright © 2023 Bentley Systems, Incorporated. All rights reserved.

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.
31 changes: 31 additions & 0 deletions packages/saved-views-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# @itwin/saved-views-client

## About

## Installation

```shell
npm install @itwin/saved-views-client
```

roluk marked this conversation as resolved.
Show resolved Hide resolved
## Example
CalebGerman marked this conversation as resolved.
Show resolved Hide resolved

```TypeScript
import { ITwinSavedViewsClient } from "@itwin/saved-views-client";

const iTwinSavedViewsClient = new ITwinSavedViewsClient({
getAccessToken: () => { return token; };
});

const res = await iTwinSavedViewsClient.getSavedViewMinimal({
savedViewId:"ID",
})
```

## Contributing

We welcome contributions to make this package better. You can submit feature requests or report bugs by creating an [issue](https://github.com/iTwin/saved-views-react/issues).

---

Copyright © Bentley Systems, Incorporated. All rights reserved. See [LICENSE.md](./LICENSE.md) for license terms and full copyright notice.
54 changes: 54 additions & 0 deletions packages/saved-views-client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@itwin/saved-views-client",
"version": "0.1.0",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/iTwin/saved-views-react.git",
"directory": "packages/saved-views-client"
},
"homepage": "https://github.com/iTwin/saved-views-react/packages/saved-views-client",
"author": {
"name": "Bentley Systems, Inc.",
"url": "https://www.bentley.com"
},
"types": "./lib/cjs/index.d.ts",
"exports": {
".": {
"import": {
"types": "./lib/esm/index.d.ts",
"default": "./lib/esm/index.js"
},
"require": {
"types": "./lib/cjs/index.d.ts",
"default": "./lib/cjs/index.js"
}
}
},
"files": [
"./lib",
"./public"
],
"scripts": {
"build": "run-p build:**",
"build:transpile:esm": "tsc --project ./tsconfig.build.json",
"test": "vitest",
"test:cover": "vitest run --coverage",
"test:watch": "vitest watch",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@types/uuid": "^9.0.2",
"@vitest/coverage-v8": "^0.33.0",
"happy-dom": "^10.5.2",
"npm-run-all": "^4.1.5",
"typescript": "^5.1.6",
"vite": "^4.4.7",
"vitest": "^0.33.0"
},
"dependencies": {
"base64-arraybuffer": "^1.0.2",
"class-validator": "^0.14.0",
"uuid": "^9.0.0"
}
}
81 changes: 81 additions & 0 deletions packages/saved-views-client/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
trigger:
tags:
include:
- v*.*.*

pr: none

variables:
- name: packageName
value: "saved-views-client"
- name: packageVersion
value: ${{ replace(variables['Build.SourceBranchName'], 'v', '') }}
- name: tarballName
value: itwin-$(packageName)-$(packageVersion).tgz

resources:
repositories:
- repository: templates
type: git
name: iModelTechnologies/imodeljs-build-pipeline-scripts

stages:
- stage: build
displayName: Build
jobs:
- job: Build
steps:
- checkout: self
clean: true
fetchDepth: 1

- task: NodeTool@0
displayName: Use Node.js 18.x
inputs:
versionSpec: 18.x

- task: CmdLine@2
displayName: Install pnpm
inputs:
script: npm install -g pnpm

- task: CmdLine@2
displayName: Audit
inputs:
script: pnpm audit --audit-level=high

- task: CmdLine@2
displayName: Install dependencies
inputs:
script: pnpm install --filter $(packageName)

- task: CmdLine@2
displayName: Build package
inputs:
script: npm run build
workingDirectory: packages/$(packageName)/

- task: CmdLine@2
displayName: Run unit tests
inputs:
script: npm run test:cover
workingDirectory: packages/$(packageName)/

- task: CmdLine@2
displayName: Pack package files
inputs:
script: pnpm pack
workingDirectory: packages/$(packageName)/

- publish: packages/$(packageName)/$(tarballName)
displayName: Publish package artifact
artifact: published-package

- stage: publish
dependsOn: build
displayName: Publish
jobs:
- template: templates/npmjs-publish-deployment.yaml@templates
parameters:
path: $(tarballName)
artifactName: published-package
44 changes: 44 additions & 0 deletions packages/saved-views-client/src/client/ApiUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

export interface CallITwinApiParams {
url: string;
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
getAccessToken: () => Promise<string>;
body?: object | undefined;
headers?: Record<string, string> | undefined;
signal?: AbortSignal | undefined;
}

export async function callITwinApi(args: CallITwinApiParams): Promise<Record<string, unknown>> {
const response = await fetch(args.url, {
method: args.method,
body: args.body && JSON.stringify(args.body),
headers: {
...args.headers,
Authorization: await args.getAccessToken(),
},
signal: args.signal,
});

if (!response.ok) {
await throwBadResponseCodeError(response, "iTwin API request failed.");
}

return response.json();
}

async function throwBadResponseCodeError(response: Response, errorMessage: string): Promise<never> {
let error: unknown;
try {
error = (await response.json()).error;
} catch {
throw new Error(
`${errorMessage} Unexpected response status code: ${response.status} ${response.statusText}.`,
);
}

throw error;
}
Loading
Loading