@aws-amplify/data-schema 0.13.18 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,7 +37,7 @@ type InternalCustomData = CustomData & {
37
37
  authorization: Authorization<any, any, any>[];
38
38
  };
39
39
  export type CustomOperationParamShape = {
40
- arguments: CustomArguments;
40
+ arguments: CustomArguments | null;
41
41
  returnType: CustomReturnType | null;
42
42
  functionRef: string | null;
43
43
  authorization: Authorization<any, any, any>[];
@@ -69,7 +69,7 @@ export type InternalCustom<B extends CustomOperationBrand = any> = CustomOperati
69
69
  };
70
70
  export type QueryCustomOperation = CustomOperation<CustomOperationParamShape, any, typeof queryBrand>;
71
71
  export declare function query(): CustomOperation<{
72
- arguments: CustomArguments;
72
+ arguments: null;
73
73
  returnType: null;
74
74
  functionRef: null;
75
75
  authorization: [];
@@ -78,7 +78,7 @@ export declare function query(): CustomOperation<{
78
78
  }, never, typeof queryBrand>;
79
79
  export type MutationCustomOperation = CustomOperation<CustomOperationParamShape, any, typeof mutationBrand>;
80
80
  export declare function mutation(): CustomOperation<{
81
- arguments: CustomArguments;
81
+ arguments: null;
82
82
  returnType: null;
83
83
  functionRef: null;
84
84
  authorization: [];
@@ -87,7 +87,7 @@ export declare function mutation(): CustomOperation<{
87
87
  }, never, typeof mutationBrand>;
88
88
  export type SubscriptionCustomOperation = CustomOperation<CustomOperationParamShape, any, typeof subscriptionBrand>;
89
89
  export declare function subscription(): CustomOperation<{
90
- arguments: CustomArguments;
90
+ arguments: null;
91
91
  returnType: null;
92
92
  functionRef: null;
93
93
  authorization: [];
@@ -28,7 +28,7 @@ export type CustomOpShapes<Schema extends GenericModelSchema<any>> = {
28
28
  /**
29
29
  * Digs out custom operation arguments, mapped to the intended graphql types.
30
30
  */
31
- export type CustomOpArguments<Shape extends CustomOperationParamShape> = {
31
+ export type CustomOpArguments<Shape extends CustomOperationParamShape> = Shape['arguments'] extends null ? never : {
32
32
  [FieldName in keyof Shape['arguments']]: Shape['arguments'][FieldName] extends ModelField<infer R, any, any> ? R : never;
33
33
  };
34
34
  /**
@@ -43,7 +43,7 @@ type IdentifierFields<T extends ModelTypeParamShape> = keyof IdentifierMap<T> &
43
43
  type IdentifierType<T extends ModelTypeParamShape, Fields extends string = IdentifierFields<T>> = Array<Fields>;
44
44
  export type ModelType<T extends ModelTypeParamShape, K extends keyof ModelType<T> = never> = Omit<{
45
45
  identifier<ID extends IdentifierType<T> = []>(identifier: ID): ModelType<SetTypeSubArg<T, 'identifier', ID>, K | 'identifier'>;
46
- secondaryIndexes<const Indexes extends readonly ModelIndexType<SecondaryIndexFields<ExtractType<T>>, SecondaryIndexFields<ExtractType<T>>, unknown, never, any>[] = readonly [], const IndexesIR extends readonly any[] = SecondaryIndexToIR<Indexes, ExtractType<T>>>(indexes: Indexes): ModelType<SetTypeSubArg<T, 'secondaryIndexes', IndexesIR>, K | 'secondaryIndexes'>;
46
+ secondaryIndexes<const SecondaryIndexPKPool extends string = SecondaryIndexFields<ExtractType<T>>, const Indexes extends readonly ModelIndexType<string, string, unknown, readonly [], any>[] = readonly [], const IndexesIR extends readonly any[] = SecondaryIndexToIR<Indexes, ExtractType<T>>>(callback: (index: <PK extends SecondaryIndexPKPool>(pk: PK) => ModelIndexType<SecondaryIndexPKPool, PK, ReadonlyArray<Exclude<SecondaryIndexPKPool, PK>>>) => Indexes): ModelType<SetTypeSubArg<T, 'secondaryIndexes', IndexesIR>, K | 'secondaryIndexes'>;
47
47
  authorization<AuthRuleType extends Authorization<any, any, any>>(rules: AuthRuleType[]): ModelType<SetTypeSubArg<T, 'authorization', AuthRuleType[]>, K | 'authorization'>;
48
48
  }, K> & Brand<typeof brandName>;
49
49
  /**
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.model = exports.isSchemaModelType = void 0;
4
4
  const util_1 = require("./util");
5
+ const ModelIndex_1 = require("./ModelIndex");
5
6
  const brandName = 'modelType';
6
7
  function _model(fields) {
7
8
  const data = {
@@ -15,8 +16,8 @@ function _model(fields) {
15
16
  data.identifier = identifier;
16
17
  return this;
17
18
  },
18
- secondaryIndexes(indexes) {
19
- data.secondaryIndexes = indexes;
19
+ secondaryIndexes(callback) {
20
+ data.secondaryIndexes = callback(ModelIndex_1.modelIndex);
20
21
  return this;
21
22
  },
22
23
  authorization(rules) {
@@ -1,6 +1,5 @@
1
1
  import { schema } from './ModelSchema';
2
2
  import { model } from './ModelType';
3
- import { modelIndex } from './ModelIndex';
4
3
  import { id, string, integer, float, boolean, date, time, datetime, timestamp, email, json, phone, url, ipAddress } from './ModelField';
5
4
  import { ref } from './RefType';
6
5
  import { hasOne, hasMany, belongsTo, manyToMany } from './ModelRelationalField';
@@ -9,4 +8,4 @@ import { customType } from './CustomType';
9
8
  import { enumType } from './EnumType';
10
9
  import { query, mutation, subscription } from './CustomOperation';
11
10
  import { handler } from './Handler';
12
- export { schema, model, modelIndex as index, ref, customType, enumType as enum, query, mutation, subscription, hasOne, hasMany, belongsTo, manyToMany, allow, id, string, integer, float, boolean, date, time, datetime, timestamp, email, json, phone, url, ipAddress, handler, };
11
+ export { schema, model, ref, customType, enumType as enum, query, mutation, subscription, hasOne, hasMany, belongsTo, manyToMany, allow, id, string, integer, float, boolean, date, time, datetime, timestamp, email, json, phone, url, ipAddress, handler, };
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handler = exports.ipAddress = exports.url = exports.phone = exports.json = exports.email = exports.timestamp = exports.datetime = exports.time = exports.date = exports.boolean = exports.float = exports.integer = exports.string = exports.id = exports.allow = exports.manyToMany = exports.belongsTo = exports.hasMany = exports.hasOne = exports.subscription = exports.mutation = exports.query = exports.enum = exports.customType = exports.ref = exports.index = exports.model = exports.schema = void 0;
3
+ exports.handler = exports.ipAddress = exports.url = exports.phone = exports.json = exports.email = exports.timestamp = exports.datetime = exports.time = exports.date = exports.boolean = exports.float = exports.integer = exports.string = exports.id = exports.allow = exports.manyToMany = exports.belongsTo = exports.hasMany = exports.hasOne = exports.subscription = exports.mutation = exports.query = exports.enum = exports.customType = exports.ref = exports.model = exports.schema = void 0;
4
4
  const ModelSchema_1 = require("./ModelSchema");
5
5
  Object.defineProperty(exports, "schema", { enumerable: true, get: function () { return ModelSchema_1.schema; } });
6
6
  const ModelType_1 = require("./ModelType");
7
7
  Object.defineProperty(exports, "model", { enumerable: true, get: function () { return ModelType_1.model; } });
8
- const ModelIndex_1 = require("./ModelIndex");
9
- Object.defineProperty(exports, "index", { enumerable: true, get: function () { return ModelIndex_1.modelIndex; } });
10
8
  const ModelField_1 = require("./ModelField");
11
9
  Object.defineProperty(exports, "id", { enumerable: true, get: function () { return ModelField_1.id; } });
12
10
  Object.defineProperty(exports, "string", { enumerable: true, get: function () { return ModelField_1.string; } });