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

release: Amplify JS release 2024-02-06 #12966

Merged
merged 9 commits into from
Feb 6, 2024
14 changes: 1 addition & 13 deletions .github/integ-config/integ-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ tests:
sample_name: v2/owner-and-group-different-models-default-v2
spec: owner-and-group-different-models-default
browser: *minimal_browser_list
timeout_minutes: 45
retry_count: 10
- test_name: integ_datastore_auth_v2-owner-and-group-same-model-default
desc: 'DataStore Auth CLI v2'
framework: react
Expand All @@ -158,8 +156,6 @@ tests:
sample_name: v2/dynamic-user-pool-groups-default-v2
spec: dynamic-user-pool-groups-default
browser: *minimal_browser_list
timeout_minutes: 45
retry_count: 10
- test_name: integ_datastore_auth_v2-dynamic-user-pool-groups-owner-based-default
desc: 'DataStore Auth CLI v2'
framework: react
Expand Down Expand Up @@ -349,8 +345,6 @@ tests:
sample_name: [v2/related-models]
spec: cpk-related-models
browser: *extended_browser_list
timeout_minutes: 45
retry_count: 10
- test_name: integ_react_datastore_selective_sync
desc: 'DataStore - Selective Sync'
framework: react
Expand All @@ -371,9 +365,7 @@ tests:
category: datastore
sample_name: [v2/amplify-docs-examples]
spec: amplify-docs-examples
browser: *minimal_browser_list
timeout_minutes: 45
retry_count: 10
browser: [chrome]
- test_name: integ_react_datastore_websocket_disruption
desc: 'DataStore - WebSocket Disruption'
framework: react
Expand Down Expand Up @@ -512,17 +504,13 @@ tests:
sample_name: [auth-rsc]
spec: auth-rsc
browser: [chrome]
timeout_minutes: 45
retry_count: 10
- test_name: integ_next_sign_in_with_oauth
desc: 'Sign-in with the OAuth flow'
framework: next
category: auth
sample_name: [sign-in-with-oauth]
spec: sign-in-with-oauth
browser: [chrome]
timeout_minutes: 45
retry_count: 10

# DISABLED Angular/Vue tests:
# TODO: delete tests or add custom ui logic to support them.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"tslint": "^5.7.0",
"tslint-config-airbnb": "^5.8.0",
"typedoc": "^0.17.0",
"typescript": "~5.0.2",
"typescript": "^4.3.5",
"typescript-coverage-report": "^0.6.4",
"uuid-validate": "^0.0.3",
"webpack": "^5.75.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/adapter-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"@types/react-dom": "^18.2.6",
"aws-amplify": "6.0.14",
"jest-fetch-mock": "3.0.3",
"next": ">= 13.5.0 < 15.0.0"
"next": ">= 13.5.0 < 15.0.0",
"typescript": "5.0.2"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"devDependencies": {
"@aws-amplify/core": "6.0.14",
"@aws-amplify/react-native": "1.0.14",
"@aws-sdk/types": "3.398.0"
"@aws-sdk/types": "3.398.0",
"typescript": "5.0.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import { SchemaModel } from '@aws-amplify/core/internals/utils';

export const userSchemaModel: SchemaModel = {
name: 'User',
fields: {
userId: {
name: 'userId',
isArray: false,
type: 'ID',
isRequired: true,
attributes: [],
},
name: {
name: 'name',
isArray: false,
type: 'String',
isRequired: true,
attributes: [],
},
createdTodos: {
name: 'createdTodos',
isArray: true,
type: {
model: 'Todo',
},
isRequired: false,
attributes: [],
isArrayNullable: true,
association: {
connectionType: 'HAS_MANY' as any,
associatedWith: ['userCreatedTodosUserId'],
},
},
assignedTodos: {
name: 'assignedTodos',
isArray: true,
type: {
model: 'Todo',
},
isRequired: false,
attributes: [],
isArrayNullable: true,
association: {
connectionType: 'HAS_MANY' as any,
associatedWith: ['userAssignedTodosUserId'],
},
},
owner: {
name: 'owner',
isArray: false,
type: 'String',
isRequired: false,
attributes: [],
},
createdAt: {
name: 'createdAt',
isArray: false,
type: 'AWSDateTime',
isRequired: true,
attributes: [],
},
updatedAt: {
name: 'updatedAt',
isArray: false,
type: 'AWSDateTime',
isRequired: true,
attributes: [],
},
},
syncable: true,
pluralName: 'Users',
attributes: [
{
type: 'model',
properties: {},
},
{
type: 'key',
properties: {
fields: ['userId'],
},
},
{
type: 'auth',
properties: {
rules: [
{
provider: 'userPools',
ownerField: 'owner',
allow: 'owner',
identityClaim: 'cognito:username',
operations: ['create', 'update', 'delete', 'read'],
},
{
allow: 'public',
operations: ['read'],
},
],
},
},
],
primaryKeyInfo: {
isCustomPrimaryKey: true,
primaryKeyFieldName: 'userId',
sortKeyFieldNames: [],
},
};

export const productSchemaModel: SchemaModel = {
name: 'Product',
fields: {
sku: {
name: 'sku',
isArray: false,
type: 'String',
isRequired: true,
attributes: [],
},
factoryId: {
name: 'factoryId',
isArray: false,
type: 'String',
isRequired: true,
attributes: [],
},
warehouseId: {
name: 'warehouseId',
isArray: false,
type: 'String',
isRequired: true,
attributes: [],
},
description: {
name: 'description',
isArray: false,
type: 'String',
isRequired: false,
attributes: [],
},
owner: {
name: 'owner',
isArray: false,
type: 'String',
isRequired: false,
attributes: [],
},
createdAt: {
name: 'createdAt',
isArray: false,
type: 'AWSDateTime',
isRequired: true,
attributes: [],
},
updatedAt: {
name: 'updatedAt',
isArray: false,
type: 'AWSDateTime',
isRequired: true,
attributes: [],
},
},
syncable: true,
pluralName: 'Products',
attributes: [
{
type: 'model',
properties: {},
},
{
type: 'key',
properties: {
fields: ['sku', 'factoryId', 'warehouseId'],
},
},
{
type: 'auth',
properties: {
rules: [
{
provider: 'userPools',
ownerField: 'owner',
allow: 'owner',
identityClaim: 'cognito:username',
operations: ['create', 'update', 'delete', 'read'],
},
{
allow: 'public',
operations: ['read'],
},
],
},
},
],
primaryKeyInfo: {
isCustomPrimaryKey: true,
primaryKeyFieldName: 'sku',
sortKeyFieldNames: ['factoryId', 'warehouseId'],
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import {
flattenItems,
generateSelectionSet,
customSelectionSetToIR,
} from '../src/internals/APIClient';
generateGraphQLDocument,
} from '../../src/internals/APIClient';

import config from './fixtures/modeled/amplifyconfiguration';
import config from '../fixtures/modeled/amplifyconfiguration';
import {
productSchemaModel,
userSchemaModel,
} from '../fixtures/schema-models/with-custom-primary-key/models';
const modelIntroSchema = config.modelIntrospection as ModelIntrospectionSchema;

describe('APIClient', () => {
Expand Down Expand Up @@ -38,7 +43,7 @@ describe('APIClient', () => {
const normalized = normalizeMutationInput(
note,
noteModelDef,
modelIntroSchema
modelIntroSchema,
);

expect(normalized).toEqual(expectedInput);
Expand Down Expand Up @@ -299,7 +304,7 @@ describe('flattenItems', () => {
const selSet = customSelectionSetToIR(
modelIntroSchema.models,
'CommunityPost',
['poll.question', 'poll.answers.answer', 'poll.answers.votes.id']
['poll.question', 'poll.answers.answer', 'poll.answers.votes.id'],
);

const expected = {
Expand Down Expand Up @@ -383,3 +388,30 @@ describe('flattenItems', () => {
});
});
});

describe('generateGraphQLDocument()', () => {
describe('for `READ` operation', () => {
const modelOperation = 'READ';
const mockModelDefinitions = {
User: userSchemaModel,
Product: productSchemaModel,
};

test.each([
['User', '$userId: ID!'],
['Product', '$sku: String!,$factoryId: String!,$warehouseId: String!'],
])(
'generates arguments for model %s to be %s',
(modelName, expectedArgs) => {
const document = generateGraphQLDocument(
mockModelDefinitions,
modelName,
modelOperation,
);

console.log(document);
expect(document.includes(expectedArgs)).toBe(true);
},
);
});
});
5 changes: 4 additions & 1 deletion packages/api-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@
},
"homepage": "https://aws-amplify.github.io/",
"devDependencies": {
"@aws-amplify/data-schema": "^0.12.11"
"@aws-amplify/data-schema": "^0.12.11",
"typescript": "5.0.2",
"@rollup/plugin-typescript": "11.1.5",
"rollup": "^4.9.6"
},
"files": [
"dist/cjs",
Expand Down
Loading
Loading