Skip to content

Commit

Permalink
release: Amplify JS release (aws-amplify#12563)
Browse files Browse the repository at this point in the history
  • Loading branch information
elorzafe authored Nov 13, 2023
2 parents 91fd013 + a5eb335 commit 1983a03
Show file tree
Hide file tree
Showing 79 changed files with 8,369 additions and 330 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/callable-npm-publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ jobs:
working-directory: ./amplify-js
run: |
git push origin release
git push -f origin required-release
if [ $(git tag -l "required-release") ]; then git push -f origin required-release; fi
git push --force-with-lease origin release:main
30 changes: 25 additions & 5 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,29 @@ jobs:
- github-actions-test
- tsc-compliance-test
runs-on: ubuntu-latest
# This is a bit of a hack - Branch protections depend upon selected
# workflows that run on hardware, not parents of many callable workflows.
# Adding this so that unit and bundle checks can be a single protection line.
if: success() # only run when all checks have passed
# store success output flag for ci job
outputs:
success: ${{ steps.setoutput.outputs.success }}
steps:
- name: All tests passed
run: echo "All tests passed"
- id: setoutput
run: echo "::set-output name=success::true"
ci:
runs-on: ubuntu-latest
if: always() # always run, so we never skip the check
name: ci - Unit and Bundle tests have passed
needs: all-unit-tests-pass
env:
PASSED: ${{ needs.all-unit-tests-pass.outputs.success }}
steps:
# this job passes only when output of all-unit-tests-pass job is set
# in case at least one of the checks fails, all-unit-tests-pass is skipped
# and the output will not be set, which will then cause the ci job to fail
- run: |
if [[ $PASSED == "true" ]]; then
echo "All checks have passed"
exit 0
else
echo "One or more checks have failed"
exit 1
fi
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"unlink-all": "lerna exec --no-bail --parallel -- yarn unlink; exit 0",
"publish:preid": "./scripts/preid-env-vars-exist.sh && lerna publish --canary --force-publish --dist-tag=${PREID_PREFIX} --preid=${PREID_PREFIX}${PREID_HASH_SUFFIX} --yes",
"publish:main": "lerna publish --canary --force-publish --dist-tag=unstable --preid=unstable${PREID_HASH_SUFFIX} --yes",
"publish:release": "lerna publish from-package --dist-tag=v6 --message 'chore(release): Publish [ci skip]' --yes",
"publish:release": "lerna publish --conventional-commits --dist-tag=v6 --message 'chore(release): Publish [ci skip]' --yes",
"publish:v5-stable": "lerna publish --conventional-commits --yes --dist-tag=stable-5 --message 'chore(release): Publish [ci skip]' --no-verify-access",
"publish:verdaccio": "lerna publish --canary --force-publish --no-push --dist-tag=unstable --preid=unstable --yes",
"ts-coverage": "lerna run ts-coverage",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jest.mock(
);

describe('createServerRunner', () => {
let createServerRunner;
let createServerRunner: any;

const mockParseAWSExports = jest.fn();
const mockCreateAWSCredentialsAndIdentityIdProvider = jest.fn();
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-nextjs/data/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@aws-amplify/adapter-nextjs/data",
"main": "../dist/cjs/api/index.js",
"browser": "../dist/esm/api/index.mjs",
"module": "../dist/esm/api/index.mjs",
"typings": "../dist/esm/api/index.d.ts"
}
7 changes: 6 additions & 1 deletion packages/adapter-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"jest-fetch-mock": "3.0.3",
"next": ">= 13.5.0 < 15.0.0",
"rollup": "3.29.4",
"typescript": "5.1.6"
"typescript": "5.0.2"
},
"publishConfig": {
"access": "public"
Expand All @@ -39,6 +39,11 @@
"import": "./dist/esm/api/index.mjs",
"require": "./dist/cjs/api/index.js"
},
"./data": {
"types": "./dist/esm/api/index.d.ts",
"import": "./dist/esm/api/index.mjs",
"require": "./dist/cjs/api/index.js"
},
"./package.json": "./package.json"
},
"files": [
Expand Down
33 changes: 26 additions & 7 deletions packages/adapter-nextjs/src/api/generateServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
AmplifyServer,
} from '@aws-amplify/core/internals/adapter-core';
import {
V6Client,
V6ClientSSR,
V6ClientSSRRequest,
V6ClientSSRCookies,
GraphQLMethod,
GraphQLMethodSSR,
__amplify,
Expand All @@ -18,6 +18,20 @@ import {
import { NextServer } from '../types';
import { createServerRunnerForAPI } from './createServerRunnerForAPI';
import { getAmplifyConfig } from '../utils';
import { GraphQLAuthMode } from '@aws-amplify/core/internals/utils';

type CookiesClientParams = {
cookies: NextServer.ServerComponentContext['cookies'];
config: NextServer.CreateServerRunnerInput['config'];
authMode?: GraphQLAuthMode;
authToken?: string;
};

type ReqClientParams = {
config: NextServer.CreateServerRunnerInput['config'];
authMode?: GraphQLAuthMode;
authToken?: string;
};

/**
* Generates an API client that can be used inside a Next.js Server Component with Dynamic Rendering
Expand All @@ -33,8 +47,9 @@ export function generateServerClientUsingCookies<
>({
config,
cookies,
}: NextServer.ServerComponentContext &
NextServer.CreateServerRunnerInput): V6Client<T> {
authMode,
authToken,
}: CookiesClientParams): V6ClientSSRCookies<T> {
if (typeof cookies !== 'function') {
throw new AmplifyServerContextError({
message:
Expand All @@ -58,9 +73,11 @@ export function generateServerClientUsingCookies<
fn(getAmplifyServerContext(contextSpec).amplify),
});

return generateServerClient<T, V6Client<T>>({
return generateServerClient<T, V6ClientSSRCookies<T>>({
amplify: getAmplify,
config: resourcesConfig,
authMode,
authToken,
});
}

Expand All @@ -82,13 +99,15 @@ export function generateServerClientUsingCookies<
*/
export function generateServerClientUsingReqRes<
T extends Record<any, any> = never
>({ config }: NextServer.CreateServerRunnerInput): V6ClientSSR<T> {
>({ config, authMode, authToken }: ReqClientParams): V6ClientSSRRequest<T> {
const amplifyConfig = getAmplifyConfig(config);
// passing `null` instance because each (future model) method must retrieve a valid instance
// from server context
const client = generateServerClient<T, V6ClientSSR<T>>({
const client = generateServerClient<T, V6ClientSSRRequest<T>>({
amplify: null,
config: amplifyConfig,
authMode,
authToken,
});

// TODO: improve this and the next type
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-nextjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"target": "es2020",
"noImplicitAny": false,
"noImplicitAny": true,
"lib": ["dom", "es2019", "esnext.asynciterable"],
"module": "commonjs",
"moduleResolution": "node",
Expand Down
Loading

0 comments on commit 1983a03

Please sign in to comment.