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

migrate api-v6 work; update imports to match updated patterns; update lerna config and global package.json; update dev dependencies for api packages; add config + credential + error utils; #11921

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3a0a21c
migrate generateClient code to 'next'; build config updates to allow …
david-mcafee Aug 23, 2023
b332f77
Merge branch 'next' into next-api-v6
david-mcafee Aug 29, 2023
82dccba
update config
david-mcafee Aug 29, 2023
b329ff2
update cache import
david-mcafee Aug 29, 2023
d511f15
config updates
david-mcafee Aug 29, 2023
f954659
update envrc; add TODO; config updates
david-mcafee Aug 29, 2023
a3aa4f0
update unit test
david-mcafee Aug 29, 2023
a0f5d45
add tests + fixtures + utils
david-mcafee Aug 30, 2023
229de78
update types
david-mcafee Aug 30, 2023
4efe8f8
Merge branch 'next' into next-api-v6
david-mcafee Aug 30, 2023
31bb50a
update yarn.lock
david-mcafee Aug 30, 2023
58057e6
update 'core' imports
david-mcafee Aug 31, 2023
253cd3d
update yarn.lock
david-mcafee Aug 31, 2023
68803a8
Merge branch 'next' into next-api-v6
david-mcafee Aug 31, 2023
bb54e4e
test
david-mcafee Aug 31, 2023
0b24be2
add back internals package.json
david-mcafee Aug 31, 2023
a27c826
revert api-graphql package.json changes
david-mcafee Aug 31, 2023
ace02f4
config updates
david-mcafee Aug 31, 2023
c29df95
add api-rest to global config
david-mcafee Aug 31, 2023
1e1f010
add pubsub to lerna config and package.json
david-mcafee Aug 31, 2023
c2912f0
update all core imports
david-mcafee Aug 31, 2023
daeac44
Merge branch 'next' into next-api-v6
david-mcafee Aug 31, 2023
1d88977
replace amplify.register with amplify.configure
david-mcafee Sep 1, 2023
8b869b4
add resolveConfig + resolveCredentials + error utils
david-mcafee Sep 1, 2023
ef3d04f
add preliminary api-graphql config and options types
david-mcafee Sep 1, 2023
29c8166
Merge branch 'next' into next-api-v6
david-mcafee Sep 1, 2023
d931d89
more auth changes
david-mcafee Sep 1, 2023
a24765a
Merge branch 'next' into next-api-v6
david-mcafee Sep 1, 2023
ae6c6ed
todos
david-mcafee Sep 2, 2023
f478dac
Draft version of internal post method (#11969)
elorzafe Sep 2, 2023
4399cc0
add todos
david-mcafee Sep 2, 2023
aaaf731
type updates; package.json updates
david-mcafee Sep 2, 2023
9c21be0
remove pubsub imports
david-mcafee Sep 2, 2023
b945cf6
update
david-mcafee Sep 5, 2023
0787b12
Merge branch 'next' into next-api-v6
david-mcafee Sep 5, 2023
650189e
Add cancel requests and subscriptions to V6 (#11978)
elorzafe Sep 6, 2023
9801391
Merge branch 'next' into next-api-v6
david-mcafee Sep 6, 2023
6cc2b99
update API config types
david-mcafee Sep 7, 2023
821e90c
type updates, API updates
david-mcafee Sep 7, 2023
aa234e2
revert yarn.lock changes
david-mcafee Sep 7, 2023
27e17d2
chore: Update to stabalize yarn.lock
stocaaro Sep 7, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/push-preid-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
branches:
# Change this to your branch name where "example-preid" corresponds to the preid you want your changes released on
- feat/example-preid-branch/main
- next-api-v6

jobs:
e2e:
Expand Down
6 changes: 5 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"packages/analytics",
"packages/storage",
"packages/aws-amplify",
"packages/adapter-nextjs"
"packages/adapter-nextjs",
"packages/api",
"packages/api-rest",
"packages/api-graphql",
"packages/amplify-v6-types-package"
],
"exact": true,
"version": "independent",
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
"packages/analytics",
"packages/storage",
"packages/aws-amplify",
"packages/adapter-nextjs"
"packages/adapter-nextjs",
"packages/api",
"packages/api-graphql",
"packages/api-rest",
"packages/amplify-v6-types-package"
],
"nohoist": [
"**/@types/react-native",
Expand Down Expand Up @@ -113,7 +117,8 @@
"@types/babel__traverse": "7.20.0",
"path-scurry": "1.10.0",
"**/glob/minipass": "6.0.2",
"nx": "16.7.0"
"nx": "16.7.0",
"@smithy/types": "2.1.0"
},
"jest": {
"resetMocks": true,
Expand Down
77 changes: 77 additions & 0 deletions packages/amplify-v6-types-package/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

export declare const __modelMeta__: unique symbol;

export type ExtractModelMeta<T extends Record<any, any>> =
T[typeof __modelMeta__];

type Prettify<T> = T extends object
? {
[P in keyof T]: Prettify<T[P]>;
}
: T;

// tslint gets confused by template literal types
// tslint:disable:semicolon
type FlattenKeys<
T extends Record<string, unknown> = {},
Key = keyof T
> = Key extends string
? T[Key] extends Record<string, unknown>
? `${Key}.${FlattenKeys<T[Key]>}` | `${Key}.*`
: `${Key}`
: never;

type Model = Record<string, any>;
type Joined<
M extends Model,
Paths extends Array<FlattenKeys<M>>
> = Paths extends never[]
? M
: Prettify<
{
[k in Paths[number] | keyof M as k extends `${infer A}.${string}`
? A
: never]: k extends `${infer A}.${infer B}`
? B extends `${string}.${string}`
? Joined<M[A], B extends FlattenKeys<M[A]> ? [B] : never>
: B extends `*`
? M[A]
: Pick<M[A], B>
: never;
} & {
[k in Paths[number] as k extends `${string}.${string}`
? never
: k]: M[k];
}
>;

type ModelIdentifier<Model extends Record<any, any>> = Prettify<
Record<Model['identifier'] & string, string>
>;

export type ModelTypes<
T extends Record<any, any>,
ModelMeta extends Record<any, any> = ExtractModelMeta<T>
> = {
[K in keyof T]: K extends string
? T[K] extends Record<string, unknown>
? {
create: (model: T[K]) => Promise<T[K]>;
update: (
model: Prettify<
{
id: string;
} & Partial<T[K]>
>
) => Promise<T[K]>;
delete: (identifier: ModelIdentifier<ModelMeta[K]>) => Promise<T[K]>;
get: (identifier: ModelIdentifier<ModelMeta[K]>) => Promise<T[K]>;
list<SS extends FlattenKeys<T[K]>[]>(obj?: {
selectionSet?: SS;
}): Promise<Array<Joined<T[K], SS>>>;
}
: never
: never;
};
12 changes: 12 additions & 0 deletions packages/amplify-v6-types-package/index.v3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

export declare const __modelMeta__: unique symbol;

export type ExtractModelMeta<T extends Record<any, any>> =
T[typeof __modelMeta__];

export type ModelTypes<
T extends Record<any, any> = never,
ModelMeta extends Record<any, any> = any
> = any;
30 changes: 30 additions & 0 deletions packages/amplify-v6-types-package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@aws-amplify/types-package-alpha",
"version": "0.0.0",
"main": "./lib/index.js",
"module": "./lib-esm/index.js",
"types": "./lib-esm/index.d.ts",
"license": "UNLICENSED",
"typesVersions": {
"<5": {
"lib-esm/index.d.ts": [
"index.v3.ts"
]
}
},
"publishConfig": {
"access": "public"
},
"scripts": {
"lint": "eslint \"**/*.ts*\"",
"build:cjs": "rimraf lib && tsc -p ./tsconfig.build.json -m commonjs --outDir lib",
"build:esm": "rimraf lib-esm && tsc -p ./tsconfig.build.json -m esnext --outDir lib-esm",
"build": "npm run clean && npm run build:esm && npm run build:cjs",
"test": "echo \"No tests\"",
"clean": "npm run clean:size && rimraf lib-esm lib dist",
"clean:size": "rimraf dual-publish-tmp tmp*"
},
"devDependencies": {
"typescript": "^5.1.6"
}
}
4 changes: 4 additions & 0 deletions packages/amplify-v6-types-package/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {}
}
Loading
Loading