Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-amplify/amplify-api-next-alpha

Package Overview
Dependencies
Maintainers
10
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-amplify/amplify-api-next-alpha - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

lib-esm/src/MappedTypes/ModelMetadata.d.ts

96

lib-esm/src/ClientSchema.d.ts

@@ -1,8 +0,7 @@

import type { Authorization, ImpliedAuthFields } from './Authorization';
import { type Prettify, type UnionToIntersection, type ExcludeEmpty, type LazyLoader, __modelMeta__ } from '@aws-amplify/amplify-api-next-types-alpha';
import type { ModelField } from './ModelField';
import type { ModelRelationalField, ModelRelationalFieldParamShape, ModelRelationalTypeArgFactory } from './ModelRelationalField';
import type { ModelType, ModelTypeParamShape } from './ModelType';
import { type Prettify, __modelMeta__ } from '@aws-amplify/amplify-api-next-types-alpha';
import type { ModelSchema } from './ModelSchema';
import type { InjectImplicitModelFields } from './MappedTypes/ImplicitFieldInjector';
import type { ResolveSchema, SchemaTypes } from './MappedTypes/ResolveSchema';
import type { ResolveFieldProperties } from './MappedTypes/ResolveFieldProperties';
import type { ModelIdentifier, RelationalMetadata, ExtractExplicitScalarFields } from './MappedTypes/ModelMetadata';
export type ClientSchema<Schema extends ModelSchema<any>> = InternalClientSchema<Schema>;
/**

@@ -16,88 +15,13 @@ * Types for unwrapping generic type args into client-consumable types

*
* @internal @typeParam FlattenedSchema - flattened Schema/Models/Fields structure with field type params extracted
* @typeParam FieldsWithRelationships - Fields + resolved relational fields
* @typeParam ResolvedFields - optionality enforced on nullable types (+?); These are the client-facing types used for CRUDL response shapes
* @internal @typeParam ResolvedSchema - Schema/Models/Fields structure with generic type args extracted
* @internal @typeParam IdentifierMeta - Stores model identifier
* @internal @typeParam ResolvedFields - optionality enforced on nullable types (+?); These are the client-facing types used for CRUDL response shapes
*
* @typeParam Meta - Stores schema metadata: identifier, relationship metadata;
* @internal @typeParam Meta - Stores schema metadata: identifier, relationship metadata;
* used by `API.generateClient` to craft strongly typed mutation inputs; hidden from customer-facing types behind __modelMeta__ symbol
*
*/
export type ClientSchema<Schema extends ModelSchema<any>, FlattenedSchema = FieldTypes<ModelTypes<SchemaTypes<Schema>>>, ExplicitScalarFields = ExtractExplicitScalarFields<Schema>, IdentifierMeta = ModelMeta<SchemaTypes<Schema>>, FieldsWithInjectedModels = InjectImplicitModels<FlattenedSchema>, FieldsWithInjectedImplicitFields = InjectImplicitModelFields<FieldsWithInjectedModels, IdentifierMeta>, FieldsWithRelationships = ResolveRelationships<FieldsWithInjectedImplicitFields>, ResolvedFields extends Record<string, unknown> = Intersection<FilterFieldTypes<RequiredFieldTypes<FieldsWithRelationships>>, FilterFieldTypes<OptionalFieldTypes<FieldsWithRelationships>>, FilterFieldTypes<ModelImpliedAuthFields<Schema>>>, RelationshipMeta = ExtractRelationalMetadata<FlattenedSchema, ResolvedFields>, Meta = IdentifierMeta & RelationshipMeta & ExplicitScalarFields> = Prettify<ResolvedFields & {
type InternalClientSchema<Schema extends ModelSchema<any>, ResolvedSchema = ResolveSchema<Schema>, IdentifierMeta = ModelIdentifier<SchemaTypes<Schema>>, ExplicitScalarFields = ExtractExplicitScalarFields<Schema>, ResolvedFields extends Record<string, unknown> = ResolveFieldProperties<Schema>, RelationshipMeta = RelationalMetadata<ResolvedSchema, ResolvedFields>, Meta = IdentifierMeta & RelationshipMeta & ExplicitScalarFields> = Prettify<ResolvedFields & {
[__modelMeta__]: Meta;
}>;
type ExtractExplicitScalarFields<Schema extends ModelSchema<any>, Scalars = ScalarFieldTypes<ModelTypes<SchemaTypes<Schema>>>> = {
[ModelName in keyof Scalars]: {
explicitScalarTypes: Scalars[ModelName];
};
};
type ExtractRelationalMetadata<FlattenedSchema, ResolvedFields extends Record<string, unknown>> = UnionToIntersection<ExcludeEmpty<{
[ModelName in keyof FlattenedSchema]: {
[Field in keyof FlattenedSchema[ModelName] as FlattenedSchema[ModelName][Field] extends ModelRelationalFieldParamShape ? FlattenedSchema[ModelName][Field]['relationshipType'] extends 'hasMany' ? FlattenedSchema[ModelName][Field]['relatedModel'] : FlattenedSchema[ModelName][Field]['relationshipType'] extends 'hasOne' | 'belongsTo' ? ModelName : FlattenedSchema[ModelName][Field]['relationshipType'] extends 'manyToMany' ? FlattenedSchema[ModelName][Field]['relationName'] extends string ? FlattenedSchema[ModelName][Field]['relationName'] : never : never : never]: FlattenedSchema[ModelName][Field] extends ModelRelationalFieldParamShape ? FlattenedSchema[ModelName][Field] extends ModelRelationalFieldParamShape ? FlattenedSchema[ModelName][Field]['relationshipType'] extends 'manyToMany' ? {
relationships: Record<`${Lowercase<ModelName & string>}`, ResolvedFields[ModelName & string]>;
} : {
relationships: Partial<Record<Field, ResolvedFields[FlattenedSchema[ModelName][Field]['relatedModel']]>>;
} : never : never;
};
}[keyof FlattenedSchema]>>;
type SchemaTypes<T> = T extends ModelSchema<infer R> ? R['models'] : never;
export type ModelTypes<Schema> = {
[Property in keyof Schema]: Schema[Property] extends ModelType<infer R, any> ? R['fields'] : never;
};
type ModelMeta<T> = {
[Property in keyof T]: T[Property] extends ModelType<infer R, any> ? R['identifier'] extends any[] ? {
identifier: R['identifier'][number];
} : never : never;
};
type ModelImpliedAuthFields<Schema extends ModelSchema<any>> = {
[ModelKey in keyof Schema['data']['models']]: Schema['data']['models'][ModelKey] extends ModelType<infer Model, any> ? ImpliedAuthFields<Model['authorization'][number]> & ImpliedAuthFieldsFromFields<Model> : object;
};
type ImpliedAuthFieldsFromFields<T> = UnionToIntersection<T extends ModelTypeParamShape ? T['fields'][keyof T['fields']] extends ModelField<any, any, infer Auth> | ModelRelationalField<any, any, any, infer Auth> ? Auth extends Authorization<any, any> ? ImpliedAuthFields<Auth> : object : object : object>;
/**
* infer and massage field types
*/
type ExtractImplicitModelNames<Schema> = UnionToIntersection<ExcludeEmpty<{
[ModelProp in keyof Schema]: {
[FieldProp in keyof Schema[ModelProp] as Schema[ModelProp][FieldProp] extends ModelRelationalFieldParamShape ? Schema[ModelProp][FieldProp]['relationName'] extends string ? Schema[ModelProp][FieldProp]['relationName'] extends keyof Schema ? never : Schema[ModelProp][FieldProp]['relationName'] : never : never]: {
id?: string;
} & Record<`${Lowercase<ModelProp & string>}`, ModelRelationalTypeArgFactory<ModelProp & string, 'hasMany', false>>;
};
}[keyof Schema]>>;
type InjectImplicitModels<Schema> = Prettify<Schema & ExtractImplicitModelNames<Schema>>;
type GetRelationshipRef<T, RM extends keyof T, TypeArg extends ModelRelationalFieldParamShape, Flat extends boolean, ResolvedModel = ResolveRelationalFieldsForModel<T, RM, Flat>, Model = TypeArg['valueRequired'] extends true ? ResolvedModel : ResolvedModel | null | undefined> = LazyLoader<Model, TypeArg['array']>;
type ResolveRelationalFieldsForModel<Schema, ModelName extends keyof Schema, Flat extends boolean> = {
[FieldName in keyof Schema[ModelName]]: Schema[ModelName][FieldName] extends ModelRelationalFieldParamShape ? Schema[ModelName][FieldName]['relatedModel'] extends keyof Schema ? GetRelationshipRef<Schema, Schema[ModelName][FieldName]['relatedModel'], Schema[ModelName][FieldName], Flat> : never : Schema[ModelName][FieldName];
};
type ResolveRelationships<Schema, Flat extends boolean = false> = {
[ModelProp in keyof Schema]: {
[FieldProp in keyof Schema[ModelProp]]: Schema[ModelProp][FieldProp] extends ModelRelationalFieldParamShape ? Schema[ModelProp][FieldProp]['relatedModel'] extends keyof Schema ? Schema[ModelProp][FieldProp]['relationshipType'] extends 'manyToMany' ? Schema[ModelProp][FieldProp]['relationName'] extends keyof Schema ? GetRelationshipRef<Schema, Schema[ModelProp][FieldProp]['relationName'], Schema[ModelProp][FieldProp], Flat> : never : GetRelationshipRef<Schema, Schema[ModelProp][FieldProp]['relatedModel'], Schema[ModelProp][FieldProp], Flat> : never : Schema[ModelProp][FieldProp];
};
};
type FieldTypes<T> = {
[ModelProp in keyof T]: {
[FieldProp in keyof T[ModelProp]]: T[ModelProp][FieldProp] extends ModelRelationalField<infer R, string, never, any> ? R : T[ModelProp][FieldProp] extends ModelField<infer R, any, any> ? R : never;
};
};
type ScalarFieldTypes<T> = {
[ModelProp in keyof T]: {
[FieldProp in keyof T[ModelProp] as T[ModelProp][FieldProp] extends ModelRelationalField<any, any> ? never : FieldProp]: T[ModelProp][FieldProp] extends ModelField<infer R, any, any> ? R : never;
};
};
type FilterFieldTypes<Schema> = {
[ModelProp in keyof Schema]: {
[FieldProp in keyof Schema[ModelProp] as Schema[ModelProp][FieldProp] extends undefined ? never : FieldProp]: Schema[ModelProp][FieldProp];
};
};
type OptionalFieldTypes<Schema> = {
[ModelProp in keyof Schema]: Partial<{
[FieldProp in keyof Schema[ModelProp]]: null extends Schema[ModelProp][FieldProp] ? Schema[ModelProp][FieldProp] : never;
}>;
};
type RequiredFieldTypes<Schema> = {
[ModelProp in keyof Schema]: {
[FieldProp in keyof Schema[ModelProp]]: null extends Schema[ModelProp][FieldProp] ? never : Schema[ModelProp][FieldProp];
};
};
type Intersection<A, B, C> = A & B & C extends infer U ? {
[P in keyof U]: U[P];
} : never;
export {};
{
"name": "@aws-amplify/amplify-api-next-alpha",
"version": "0.7.1",
"version": "0.7.2",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc