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

feat(cbor): add Smithy RPCv2 CBOR protocol generator #1280

Merged
merged 3 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/itchy-zebras-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/core": minor
---

cbor (de)serializer for JS
5 changes: 5 additions & 0 deletions .changeset/strong-rings-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/smithy-client": minor
---

handle timestamp cbor tag
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,37 @@ jobs:
- name: clean and build
run: ./gradlew clean build -Plog-tests

protocol-tests:
runs-on: ${{ matrix.os }}
name: Protocol Tests
strategy:
matrix:
java: [17]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
- uses: actions/setup-node@v4
with:
node-version: 16
cache: "yarn"

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'corretto'

- name: clean and build
run: ./gradlew clean build -Plog-tests
- name: Install dependencies
run: yarn
- name: Build packages
run: yarn build
- name: Run protocol tests
run: yarn test:protocols

lint-typescript:
runs-on: ubuntu-latest
name: TypeScript Lint
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ wrapper/
.attach_pid*

# local scripting
Makefile
workspace

# Visual Studio Code
Expand Down
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: build sync

build:
./gradlew clean build publishToMavenLocal

sync:
gh repo sync $$GITHUB_USERNAME/smithy-typescript -b main
milesziemer marked this conversation as resolved.
Show resolved Hide resolved
git fetch --all

generate-protocol-tests:
./gradlew :smithy-typescript-protocol-test-codegen:build
rm -rf ./private/smithy-rpcv2-cbor
cp -r ./smithy-typescript-protocol-test-codegen/build/smithyprojections/smithy-typescript-protocol-test-codegen/smithy-rpcv2-cbor/typescript-codegen ./private/smithy-rpcv2-cbor
cp ./packages/core/jest.config.js ./private/smithy-rpcv2-cbor
npx prettier --write ./private/smithy-rpcv2-cbor
yarn

test-protocols:
(cd ./private/smithy-rpcv2-cbor && npx jest)
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ subprojects {
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.2")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.2")
testImplementation("org.hamcrest:hamcrest:2.2")
testImplementation("org.mockito:mockito-junit-jupiter:5.12.0")
}

// Reusable license copySpec
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build": "turbo run build",
"test": "turbo run test",
"test:integration": "yarn build-test-packages && turbo run test:integration",
"test:protocols": "make generate-protocol-tests test-protocols",
"lint": "turbo run lint",
"lint-fix": "turbo run lint -- --fix",
"lint:pkgJson": "yarn lint:dependencies",
Expand Down
6 changes: 6 additions & 0 deletions packages/core/cbor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

/**
* Do not edit:
* This is a compatibility redirect for contexts that do not understand package.json exports field.
*/
module.exports = require("./dist-cjs/submodules/cbor/index.js");
16 changes: 14 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",
"lint": "npx eslint -c ../../.eslintrc.js \"src/**/*.ts\" && node ./scripts/lint",
"format": "prettier --config ../../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\"",
"test": "yarn g:jest"
"test": "yarn g:jest --maxWorkers=1",
"test:cbor:perf": "node ./scripts/cbor-perf.mjs"
},
"main": "./dist-cjs/index.js",
"module": "./dist-es/index.js",
Expand All @@ -29,6 +30,13 @@
"node": "./package.json",
"import": "./package.json",
"require": "./package.json"
},
"./cbor": {
"module": "./dist-es/submodules/cbor/index.js",
"node": "./dist-cjs/submodules/cbor/index.js",
"import": "./dist-es/submodules/cbor/index.js",
"require": "./dist-cjs/submodules/cbor/index.js",
"types": "./dist-types/submodules/cbor/index.d.ts"
}
},
"author": {
Expand All @@ -44,7 +52,9 @@
"@smithy/protocol-http": "workspace:^",
"@smithy/smithy-client": "workspace:^",
"@smithy/types": "workspace:^",
"@smithy/util-body-length-browser": "workspace:^",
"@smithy/util-middleware": "workspace:^",
"@smithy/util-utf8": "workspace:^",
"tslib": "^2.6.2"
},
"engines": {
Expand All @@ -58,7 +68,8 @@
}
},
"files": [
"dist-*/**"
"dist-*/**",
"./cbor.js"
],
"homepage": "https://github.com/awslabs/smithy-typescript/tree/main/packages/core",
"repository": {
Expand All @@ -70,6 +81,7 @@
"@types/node": "^16.18.96",
"concurrently": "7.0.0",
"downlevel-dts": "0.10.1",
"json-bigint": "^1.0.0",
"rimraf": "3.0.2",
"typedoc": "0.23.23"
},
Expand Down
Loading
Loading