diff --git a/.github/release-please-config.json b/.github/release-please-config.json index 78a432b..9f7bdee 100644 --- a/.github/release-please-config.json +++ b/.github/release-please-config.json @@ -2,6 +2,7 @@ "separate-pull-requests": true, "packages": { "packages/cli": {}, - "packages/core": {} + "packages/core": {}, + "packages/infra": {} } } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2d4fda2..5e5ffff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,10 @@ on: type: boolean description: release packages/core even if it normally wouldn't (e.g. due to release-please checks) default: false + force_release_infra: + type: boolean + description: release packages/infra even if it normally wouldn't (e.g. due to release-please checks) + default: false jobs: release: @@ -79,3 +83,27 @@ jobs: - run: npm publish --access=public --workspace=packages/cli --provenance env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + npm-infra: + name: npm publish @web3-storage/content-claims-infra + needs: release + if: contains(fromJson(needs.release.outputs.paths_released), 'packages/infra') || inputs.force_release_infra + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v2.4.0 + with: + version: 8 + - uses: actions/setup-node@v4 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org' + cache: 'npm' + - run: npm ci + - run: npm run build --workspace=packages/infra + - run: npm publish --access=public --workspace=packages/infra --provenance + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/README.md b/README.md index 6861095..834cd06 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ For more CLI Usage instructions, see the [content-claims-cli README](./packages/ The repo contains the infra deployment code and the service implementation. ``` -├── packages - content-claims core and lambda wrapper +├── packages - content-claims core, CLI and AWS infra └── stacks - sst and AWS CDK code to deploy all the things ``` diff --git a/package-lock.json b/package-lock.json index c8391c6..8e3affa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8168,8 +8168,8 @@ "resolved": "packages/cli", "link": true }, - "node_modules/@web3-storage/content-claims-lambda": { - "resolved": "packages/lambda", + "node_modules/@web3-storage/content-claims-infra": { + "resolved": "packages/infra", "link": true }, "node_modules/@web3-storage/data-segment": { @@ -18949,7 +18949,7 @@ }, "packages/core": { "name": "@web3-storage/content-claims", - "version": "4.0.5", + "version": "5.1.0", "license": "Apache-2.0 OR MIT", "dependencies": { "@ucanto/client": "^9.0.1", @@ -18975,8 +18975,8 @@ "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-13.1.0.tgz", "integrity": "sha512-HzdtdBwxsIkzpeXzhQ5mAhhuxcHbjEHH+JQoxt7hG/2HGFjjwyolLo7hbaexcnhoEuV4e0TNJ8kkpMjiEYY4VQ==" }, - "packages/lambda": { - "name": "@web3-storage/content-claims-lambda", + "packages/infra": { + "name": "@web3-storage/content-claims-infra", "version": "0.0.0", "dependencies": { "@aws-sdk/client-dynamodb": "^3.563.0", @@ -18987,6 +18987,7 @@ "@ucanto/principal": "^9.0.1", "@ucanto/server": "^10.0.0", "@ucanto/transport": "^9.1.1", + "@web3-storage/content-claims": "^5.1.0", "cardex": "^3.0.2", "carstream": "^2.0.0", "multiformats": "^13.1.0", @@ -19003,7 +19004,7 @@ "testcontainers": "^9.9.1" } }, - "packages/lambda/node_modules/cardex": { + "packages/infra/node_modules/cardex": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/cardex/-/cardex-3.0.2.tgz", "integrity": "sha512-0/w/34Uroad916W5Kn0CEAeIKH5Nw69Yv8Z4c2iVSSRzQPMOZbjUEygFZOkSDbDKXy6SgHinDoXrs72idZZ5WQ==", @@ -19018,18 +19019,47 @@ "cardex": "src/bin.js" } }, - "packages/lambda/node_modules/multiformats": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-13.1.0.tgz", - "integrity": "sha512-HzdtdBwxsIkzpeXzhQ5mAhhuxcHbjEHH+JQoxt7hG/2HGFjjwyolLo7hbaexcnhoEuV4e0TNJ8kkpMjiEYY4VQ==" + "packages/infra/node_modules/multiformats": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-13.1.1.tgz", + "integrity": "sha512-JiptvwMmlxlzIlLLwhCi/srf/nk409UL0eUBr0kioRJq15hqqKyg68iftrBvhCRjR6Rw4fkNnSc4ZJXJDuta/Q==" }, - "packages/lambda/node_modules/uint8arrays": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-5.0.3.tgz", - "integrity": "sha512-6LBuKji28kHjgPJMkQ6GDaBb1lRwIhyOYq6pDGwYMoDPfImE9SkuYENVmR0yu9yGgs2clHUSY9fKDukR+AXfqQ==", + "packages/infra/node_modules/uint8arrays": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-5.1.0.tgz", + "integrity": "sha512-vA6nFepEmlSKkMBnLBaUMVvAC4G3CTmO58C12y4sq6WPDOR7mOFYOi7GlrQ4djeSbP6JG9Pv9tJDM97PedRSww==", "dependencies": { "multiformats": "^13.0.0" } + }, + "packages/lambda": { + "name": "@web3-storage/content-claims-lambda", + "version": "0.0.0", + "extraneous": true, + "dependencies": { + "@aws-sdk/client-dynamodb": "^3.563.0", + "@aws-sdk/client-s3": "^3.563.0", + "@aws-sdk/util-dynamodb": "^3.563.0", + "@sentry/serverless": "^7.57.0", + "@ucanto/core": "^10.0.0", + "@ucanto/principal": "^9.0.1", + "@ucanto/server": "^10.0.0", + "@ucanto/transport": "^9.1.1", + "cardex": "^3.0.2", + "carstream": "^2.0.0", + "multiformats": "^13.1.0", + "p-retry": "^6.2.0", + "varint": "^6.0.0" + }, + "devDependencies": { + "@ipld/dag-pb": "^4.0.4", + "@types/aws-lambda": "^8.10.115", + "@types/varint": "^6.0.1", + "ava": "^5.3.1", + "nanoid": "^4.0.2", + "sst": "^2.8.28", + "testcontainers": "^9.9.1" + } } } } diff --git a/packages/lambda/package.json b/packages/infra/package.json similarity index 52% rename from packages/lambda/package.json rename to packages/infra/package.json index c431774..7da1ade 100644 --- a/packages/lambda/package.json +++ b/packages/infra/package.json @@ -1,12 +1,44 @@ { - "name": "@web3-storage/content-claims-lambda", + "name": "@web3-storage/content-claims-infra", "version": "0.0.0", "type": "module", - "private": true, "scripts": { + "build": "tsc --build", "lint": "standard && tsc", "test": "ava --verbose --timeout=5m --no-worker-threads --serial" }, + "files": [ + "src", + "tsconfig.json", + "types" + ], + "exports": { + ".": { + "import": "./types/content-claims.js", + "types": "./types/content-claims.d.ts" + }, + "./lib/config": { + "import": "./types/lib/config.js", + "types": "./types/lib/config.d.ts" + }, + "./lib/store": { + "import": "./types/lib/store/index.js", + "types": "./types/lib/store/index.d.ts" + } + }, + "typesVersions": { + "*": { + "*": [ + "types/*" + ], + "lib/config": [ + "types/lib/config.d.ts" + ], + "lib/store": [ + "types/lib/store/index.d.ts" + ] + } + }, "dependencies": { "@aws-sdk/client-dynamodb": "^3.563.0", "@aws-sdk/client-s3": "^3.563.0", @@ -16,6 +48,7 @@ "@ucanto/principal": "^9.0.1", "@ucanto/server": "^10.0.0", "@ucanto/transport": "^9.1.1", + "@web3-storage/content-claims": "^5.1.0", "cardex": "^3.0.2", "carstream": "^2.0.0", "multiformats": "^13.1.0", diff --git a/packages/lambda/src/content-claims.js b/packages/infra/src/content-claims.js similarity index 100% rename from packages/lambda/src/content-claims.js rename to packages/infra/src/content-claims.js diff --git a/packages/lambda/src/lib/config.js b/packages/infra/src/lib/config.js similarity index 100% rename from packages/lambda/src/lib/config.js rename to packages/infra/src/lib/config.js diff --git a/packages/lambda/src/lib/store/block-index.js b/packages/infra/src/lib/store/block-index.js similarity index 100% rename from packages/lambda/src/lib/store/block-index.js rename to packages/infra/src/lib/store/block-index.js diff --git a/packages/lambda/src/lib/store/dynamo-table.js b/packages/infra/src/lib/store/dynamo-table.js similarity index 100% rename from packages/lambda/src/lib/store/dynamo-table.js rename to packages/infra/src/lib/store/dynamo-table.js diff --git a/packages/lambda/src/lib/store/index.js b/packages/infra/src/lib/store/index.js similarity index 100% rename from packages/lambda/src/lib/store/index.js rename to packages/infra/src/lib/store/index.js diff --git a/packages/lambda/src/lib/store/s3-bucket.js b/packages/infra/src/lib/store/s3-bucket.js similarity index 100% rename from packages/lambda/src/lib/store/s3-bucket.js rename to packages/infra/src/lib/store/s3-bucket.js diff --git a/packages/lambda/src/lib/store/util.js b/packages/infra/src/lib/store/util.js similarity index 100% rename from packages/lambda/src/lib/store/util.js rename to packages/infra/src/lib/store/util.js diff --git a/packages/lambda/sst-env.d.ts b/packages/infra/sst-env.d.ts similarity index 100% rename from packages/lambda/sst-env.d.ts rename to packages/infra/sst-env.d.ts diff --git a/packages/lambda/test/helpers/assertions.js b/packages/infra/test/helpers/assertions.js similarity index 100% rename from packages/lambda/test/helpers/assertions.js rename to packages/infra/test/helpers/assertions.js diff --git a/packages/lambda/test/helpers/aws.js b/packages/infra/test/helpers/aws.js similarity index 100% rename from packages/lambda/test/helpers/aws.js rename to packages/infra/test/helpers/aws.js diff --git a/packages/lambda/test/helpers/carv2-index.js b/packages/infra/test/helpers/carv2-index.js similarity index 100% rename from packages/lambda/test/helpers/carv2-index.js rename to packages/infra/test/helpers/carv2-index.js diff --git a/packages/lambda/test/server.spec.js b/packages/infra/test/server.spec.js similarity index 100% rename from packages/lambda/test/server.spec.js rename to packages/infra/test/server.spec.js diff --git a/packages/lambda/tsconfig.json b/packages/infra/tsconfig.json similarity index 82% rename from packages/lambda/tsconfig.json rename to packages/infra/tsconfig.json index 6250d32..037a0b7 100644 --- a/packages/lambda/tsconfig.json +++ b/packages/infra/tsconfig.json @@ -1,10 +1,11 @@ { "include": ["src"], + "exclude": ["node_modules", "types"], "compilerOptions": { "declaration": true, "declarationMap": true, - "noEmit": true, - "outDir": "dist", + "emitDeclarationOnly": false, + "outDir": "types", "allowJs": true, "checkJs": true, "strict": true, diff --git a/stacks/api.js b/stacks/api.js index c4582f9..fe5c5f6 100644 --- a/stacks/api.js +++ b/stacks/api.js @@ -38,7 +38,7 @@ export function API ({ stack }) { const { claimsBucket } = use(Bucket) const fun = new Function(stack, 'fn', { - handler: 'packages/lambda/src/content-claims.handler', + handler: 'packages/infra/src/content-claims.handler', url: { cors: true, authorizer: 'none'