Skip to content

Commit 5865b65

Browse files
authored
feat(cbor): add Smithy RPCv2 CBOR protocol generator (#1280)
* feat(cbor): add Smithy RPCv2 CBOR protocol * feat(cbor): add doc block to submodule enum * remove AwsQueryCompat, it will be in AWS codegen
1 parent fa63800 commit 5865b65

File tree

92 files changed

+12353
-80
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+12353
-80
lines changed

.changeset/itchy-zebras-yawn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/core": minor
3+
---
4+
5+
cbor (de)serializer for JS

.changeset/strong-rings-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/smithy-client": minor
3+
---
4+
5+
handle timestamp cbor tag

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,37 @@ jobs:
2828
- name: clean and build
2929
run: ./gradlew clean build -Plog-tests
3030

31+
protocol-tests:
32+
runs-on: ${{ matrix.os }}
33+
name: Protocol Tests
34+
strategy:
35+
matrix:
36+
java: [17]
37+
os: [ubuntu-latest]
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: gradle/wrapper-validation-action@v2
42+
- uses: actions/setup-node@v4
43+
with:
44+
node-version: 16
45+
cache: "yarn"
46+
47+
- name: Set up JDK ${{ matrix.java }}
48+
uses: actions/setup-java@v4
49+
with:
50+
java-version: ${{ matrix.java }}
51+
distribution: 'corretto'
52+
53+
- name: clean and build
54+
run: ./gradlew clean build -Plog-tests
55+
- name: Install dependencies
56+
run: yarn
57+
- name: Build packages
58+
run: yarn build
59+
- name: Run protocol tests
60+
run: yarn test:protocols
61+
3162
lint-typescript:
3263
runs-on: ubuntu-latest
3364
name: TypeScript Lint

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ wrapper/
2424
.attach_pid*
2525

2626
# local scripting
27-
Makefile
2827
workspace
2928

3029
# Visual Studio Code

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.PHONY: build sync
2+
3+
build:
4+
./gradlew clean build publishToMavenLocal
5+
6+
sync:
7+
gh repo sync $$GITHUB_USERNAME/smithy-typescript -b main
8+
git fetch --all
9+
10+
generate-protocol-tests:
11+
./gradlew :smithy-typescript-protocol-test-codegen:build
12+
rm -rf ./private/smithy-rpcv2-cbor
13+
cp -r ./smithy-typescript-protocol-test-codegen/build/smithyprojections/smithy-typescript-protocol-test-codegen/smithy-rpcv2-cbor/typescript-codegen ./private/smithy-rpcv2-cbor
14+
cp ./packages/core/jest.config.js ./private/smithy-rpcv2-cbor
15+
npx prettier --write ./private/smithy-rpcv2-cbor
16+
yarn
17+
18+
test-protocols:
19+
(cd ./private/smithy-rpcv2-cbor && npx jest)

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ subprojects {
7373
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.2")
7474
testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.2")
7575
testImplementation("org.hamcrest:hamcrest:2.2")
76+
testImplementation("org.mockito:mockito-junit-jupiter:5.12.0")
7677
}
7778

7879
// Reusable license copySpec

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"build": "turbo run build",
1010
"test": "turbo run test",
1111
"test:integration": "yarn build-test-packages && turbo run test:integration",
12+
"test:protocols": "make generate-protocol-tests test-protocols",
1213
"lint": "turbo run lint",
1314
"lint-fix": "turbo run lint -- --fix",
1415
"lint:pkgJson": "yarn lint:dependencies",

packages/core/cbor.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
/**
3+
* Do not edit:
4+
* This is a compatibility redirect for contexts that do not understand package.json exports field.
5+
*/
6+
module.exports = require("./dist-cjs/submodules/cbor/index.js");

packages/core/package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",
1212
"lint": "npx eslint -c ../../.eslintrc.js \"src/**/*.ts\" && node ./scripts/lint",
1313
"format": "prettier --config ../../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\"",
14-
"test": "yarn g:jest"
14+
"test": "yarn g:jest --maxWorkers=1",
15+
"test:cbor:perf": "node ./scripts/cbor-perf.mjs"
1516
},
1617
"main": "./dist-cjs/index.js",
1718
"module": "./dist-es/index.js",
@@ -29,6 +30,13 @@
2930
"node": "./package.json",
3031
"import": "./package.json",
3132
"require": "./package.json"
33+
},
34+
"./cbor": {
35+
"module": "./dist-es/submodules/cbor/index.js",
36+
"node": "./dist-cjs/submodules/cbor/index.js",
37+
"import": "./dist-es/submodules/cbor/index.js",
38+
"require": "./dist-cjs/submodules/cbor/index.js",
39+
"types": "./dist-types/submodules/cbor/index.d.ts"
3240
}
3341
},
3442
"author": {
@@ -44,7 +52,9 @@
4452
"@smithy/protocol-http": "workspace:^",
4553
"@smithy/smithy-client": "workspace:^",
4654
"@smithy/types": "workspace:^",
55+
"@smithy/util-body-length-browser": "workspace:^",
4756
"@smithy/util-middleware": "workspace:^",
57+
"@smithy/util-utf8": "workspace:^",
4858
"tslib": "^2.6.2"
4959
},
5060
"engines": {
@@ -58,7 +68,8 @@
5868
}
5969
},
6070
"files": [
61-
"dist-*/**"
71+
"dist-*/**",
72+
"./cbor.js"
6273
],
6374
"homepage": "https://github.com/awslabs/smithy-typescript/tree/main/packages/core",
6475
"repository": {
@@ -70,6 +81,7 @@
7081
"@types/node": "^16.18.96",
7182
"concurrently": "7.0.0",
7283
"downlevel-dts": "0.10.1",
84+
"json-bigint": "^1.0.0",
7385
"rimraf": "3.0.2",
7486
"typedoc": "0.23.23"
7587
},

0 commit comments

Comments
 (0)