Skip to content

Commit

Permalink
fix(@aws-amplify/datastore): fix consecutive updates (#7354)
Browse files Browse the repository at this point in the history
  • Loading branch information
iartemiev authored Mar 25, 2021
1 parent 638c94d commit efd2e41
Show file tree
Hide file tree
Showing 10 changed files with 768 additions and 19 deletions.
302 changes: 301 additions & 1 deletion packages/datastore/__tests__/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModelInit, MutableModel, Schema } from '../src/types';
import { ModelInit, MutableModel, Schema, InternalSchema } from '../src/types';

export declare class Model {
public readonly id: string;
Expand Down Expand Up @@ -261,3 +261,303 @@ export function testSchema(): Schema {
version: '1',
};
}

export function internalTestSchema(): InternalSchema {
return {
namespaces: {
datastore: {
name: 'datastore',
relationships: {
Setting: {
indexes: [],
relationTypes: [],
},
},
enums: {},
nonModels: {},
models: {
Setting: {
name: 'Setting',
pluralName: 'Settings',
syncable: false,
fields: {
id: {
name: 'id',
type: 'ID',
isRequired: true,
isArray: false,
},
key: {
name: 'key',
type: 'String',
isRequired: true,
isArray: false,
},
value: {
name: 'value',
type: 'String',
isRequired: true,
isArray: false,
},
},
},
},
},
user: {
name: 'user',
enums: {},
models: {
Model: {
name: 'Model',
pluralName: 'Models',
syncable: true,
fields: {
id: {
name: 'id',
isArray: false,
type: 'ID',
isRequired: true,
},
field1: {
name: 'field1',
isArray: false,
type: 'String',
isRequired: true,
},
optionalField1: {
name: 'optionalField1',
isArray: false,
type: 'String',
isRequired: false,
},
dateCreated: {
name: 'dateCreated',
isArray: false,
type: 'AWSDateTime',
isRequired: true,
attributes: [],
},
emails: {
name: 'emails',
isArray: true,
type: 'AWSEmail',
isRequired: true,
attributes: [],
isArrayNullable: true,
},
ips: {
name: 'ips',
isArray: true,
type: 'AWSIPAddress',
isRequired: false,
attributes: [],
isArrayNullable: true,
},
metadata: {
name: 'metadata',
isArray: false,
type: {
nonModel: 'Metadata',
},
isRequired: false,
attributes: [],
},
},
},
LocalModel: {
name: 'LocalModel',
pluralName: 'LocalModels',
syncable: false,
fields: {
id: {
name: 'id',
isArray: false,
type: 'ID',
isRequired: true,
},
field1: {
name: 'field1',
isArray: false,
type: 'String',
isRequired: true,
},
},
},
},
nonModels: {
Metadata: {
name: 'Metadata',
fields: {
author: {
name: 'author',
isArray: false,
type: 'String',
isRequired: true,
attributes: [],
},
tags: {
name: 'tags',
isArray: true,
type: 'String',
isRequired: false,
isArrayNullable: true,
attributes: [],
},
rewards: {
name: 'rewards',
isArray: true,
type: 'String',
isRequired: true,
attributes: [],
},
penNames: {
name: 'penNames',
isArray: true,
type: 'String',
isRequired: true,
isArrayNullable: true,
attributes: [],
},
nominations: {
name: 'nominations',
isArray: true,
type: 'String',
isRequired: false,
attributes: [],
},
misc: {
name: 'misc',
isArray: true,
type: 'String',
isRequired: false,
isArrayNullable: true,
attributes: [],
},
},
},
},
relationships: {
Model: {
indexes: [],
relationTypes: [],
},
LocalModel: {
indexes: [],
relationTypes: [],
},
},
},
sync: {
name: 'sync',
relationships: {
MutationEvent: {
indexes: [],
relationTypes: [],
},
ModelMetadata: {
indexes: [],
relationTypes: [],
},
},
enums: {
OperationType: {
name: 'OperationType',
values: ['CREATE', 'UPDATE', 'DELETE'],
},
},
nonModels: {},
models: {
MutationEvent: {
name: 'MutationEvent',
pluralName: 'MutationEvents',
syncable: false,
fields: {
id: {
name: 'id',
type: 'ID',
isRequired: true,
isArray: false,
},
model: {
name: 'model',
type: 'String',
isRequired: true,
isArray: false,
},
data: {
name: 'data',
type: 'String',
isRequired: true,
isArray: false,
},
modelId: {
name: 'modelId',
type: 'String',
isRequired: true,
isArray: false,
},
operation: {
name: 'operation',
type: {
enum: 'Operationtype',
},
isArray: false,
isRequired: true,
},
condition: {
name: 'condition',
type: 'String',
isArray: false,
isRequired: true,
},
},
},
ModelMetadata: {
name: 'ModelMetadata',
pluralName: 'ModelsMetadata',
syncable: false,
fields: {
id: {
name: 'id',
type: 'ID',
isRequired: true,
isArray: false,
},
namespace: {
name: 'namespace',
type: 'String',
isRequired: true,
isArray: false,
},
model: {
name: 'model',
type: 'String',
isRequired: true,
isArray: false,
},
lastSync: {
name: 'lastSync',
type: 'Int',
isRequired: false,
isArray: false,
},
lastFullSync: {
name: 'lastFullSync',
type: 'Int',
isRequired: false,
isArray: false,
},
fullSyncInterval: {
name: 'fullSyncInterval',
type: 'Int',
isRequired: true,
isArray: false,
},
},
},
},
},
},
version: '1',
};
}
Loading

0 comments on commit efd2e41

Please sign in to comment.