Skip to content

Commit

Permalink
squash me to the previous
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiSF committed Nov 29, 2023
1 parent 5f99c50 commit 38f7430
Show file tree
Hide file tree
Showing 24 changed files with 92 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { AuthModeStrategy } from '~/types';
import { AuthModeStrategy } from '~/src/types';

// Default behavior is to use the primary auth mode for an API,
// so we are returning an empty array so that DataStore will default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ModelAttributeAuthAllow,
ModelAttributeAuthProperty,
ModelAttributeAuthProvider,
} from '~/types';
} from '~/src/types';
import { GraphQLAuthMode } from '@aws-amplify/core/internals/utils';

function getProviderFromRule(
Expand Down
29 changes: 17 additions & 12 deletions packages/datastore/src/datastore/datastore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ import {
isBrowser,
} from '@aws-amplify/core/internals/utils';
import { Observable, SubscriptionLike, filter } from 'rxjs';
import { defaultAuthStrategy, multiAuthStrategy } from '~/authModeStrategies';
import {
defaultAuthStrategy,
multiAuthStrategy,
} from '~/src/authModeStrategies';
import {
ModelPredicateCreator,
ModelSortPredicateCreator,
PredicateAll,
isPredicatesAll,
} from '~/predicates';
import { Adapter } from '~/storage/adapter';
import { ExclusiveStorage as Storage } from '~/storage/storage';
import { ModelRelationship } from '~/storage/relationship';
import { ControlMessage, SyncEngine } from '~/sync';
} from '~/src/predicates';
import { Adapter } from '~/src/storage/adapter';
import { ExclusiveStorage as Storage } from '~/src/storage/storage';
import { ModelRelationship } from '~/src/storage/relationship';
import { ControlMessage, SyncEngine } from '~/src/sync';
import {
AmplifyContext,
AuthModeStrategy,
Expand Down Expand Up @@ -69,8 +72,8 @@ import {
isModelFieldType,
isNonModelFieldType,
isSchemaModelWithAttributes,
} from '~/types';
import type { __modelMeta__ } from '~/types';
} from '~/src/types';
import type { __modelMeta__ } from '~/src/types';
import {
DATASTORE,
DeferredCallbackResolver,
Expand All @@ -92,15 +95,15 @@ import {
monotonicUlidFactory,
registerNonModelClass,
sortCompareFunction,
} from '~/util';
} from '~/src/util';
import {
GroupCondition,
internals,
predicateFor,
recursivePredicateFor,
} from '~/predicates/next';
import { getIdentifierValue } from '~/sync/utils';
import DataStoreConnectivity from '~/sync/datastoreConnectivity';
} from '~/src/predicates/next';
import { getIdentifierValue } from '~/src/sync/utils';
import DataStoreConnectivity from '~/src/sync/datastoreConnectivity';

setAutoFreeze(true);
enablePatches();
Expand Down Expand Up @@ -651,6 +654,8 @@ const validateModelFields =
);
}
}
} else if (!isRequired && v === undefined) {
// no-op
} else if (typeof v !== jsType && v !== null) {
throw new Error(
`Field ${name} should be of type ${jsType}, ${typeof v} received. ${v}`,
Expand Down
7 changes: 5 additions & 2 deletions packages/datastore/src/predicates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import {
PredicatesGroup,
ProducerModelPredicate,
SchemaModel,
} from '~/types';
import { extractPrimaryKeyFieldNames, extractPrimaryKeyValues } from '~/util';
} from '~/src/types';
import {
extractPrimaryKeyFieldNames,
extractPrimaryKeyValues,
} from '~/src/util';

export { ModelSortPredicateCreator } from './sort';

Expand Down
8 changes: 4 additions & 4 deletions packages/datastore/src/predicates/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import {
RecursiveModelPredicateAggregateExtender,
RecursiveModelPredicateExtender,
ModelPredicate as StoragePredicate,
} from '~/types';
import { ExclusiveStorage as StorageAdapter } from '~/storage/storage';
import { ModelRelationship } from '~/storage/relationship';
import { asyncEvery, asyncSome } from '~/util';
} from '~/src/types';
import { ExclusiveStorage as StorageAdapter } from '~/src/storage/storage';
import { ModelRelationship } from '~/src/storage/relationship';
import { asyncEvery, asyncSome } from '~/src/util';

import {
ModelPredicateCreator as FlatModelPredicateCreator,
Expand Down
2 changes: 1 addition & 1 deletion packages/datastore/src/predicates/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
SortDirection,
SortPredicate,
SortPredicatesGroup,
} from '~/types';
} from '~/src/types';

export class ModelSortPredicateCreator {
private static sortPredicateGroupsMap = new WeakMap<
Expand Down
4 changes: 2 additions & 2 deletions packages/datastore/src/storage/adapter/AsyncStorageAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
PersistentModelConstructor,
PredicatesGroup,
QueryOne,
} from '~/types';
} from '~/src/types';
import {
DEFAULT_PRIMARY_KEY_VALUE_SEPARATOR,
getIndexKeys,
Expand All @@ -18,7 +18,7 @@ import {
keysEqual,
traverseModel,
validatePredicate,
} from '~/util';
} from '~/src/util';

import AsyncStorageDatabase from './AsyncStorageDatabase';
import { StorageAdapterBase } from './StorageAdapterBase';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
PaginationInput,
PersistentModel,
QueryOne,
} from '~/types';
} from '~/src/types';
import {
DEFAULT_PRIMARY_KEY_VALUE_SEPARATOR,
indexNameFromKeys,
monotonicUlidFactory,
} from '~/util';
} from '~/src/util';

import { createInMemoryStore } from './InMemoryStore';

Expand Down
4 changes: 2 additions & 2 deletions packages/datastore/src/storage/adapter/IndexedDBAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
QueryOne,
isPredicateGroup,
isPredicateObj,
} from '~/types';
} from '~/src/types';
import {
getStorename,
inMemoryPagination,
Expand All @@ -22,7 +22,7 @@ import {
keysEqual,
traverseModel,
validatePredicate,
} from '~/util';
} from '~/src/util';
import { ConsoleLogger } from '@aws-amplify/core';

import { StorageAdapterBase } from './StorageAdapterBase';
Expand Down
10 changes: 5 additions & 5 deletions packages/datastore/src/storage/adapter/StorageAdapterBase.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { ModelInstanceCreator } from '~/datastore/datastore';
import { ModelPredicateCreator } from '~/predicates';
import { ModelInstanceCreator } from '~/src/datastore/datastore';
import { ModelPredicateCreator } from '~/src/predicates';
import {
InternalSchema,
ModelInstanceMetadata,
Expand All @@ -15,7 +15,7 @@ import {
PredicatesGroup,
QueryOne,
isPredicateObj,
} from '~/types';
} from '~/src/types';
import {
NAMESPACES,
extractPrimaryKeyFieldNames,
Expand All @@ -25,8 +25,8 @@ import {
isModelConstructor,
traverseModel,
validatePredicate,
} from '~/util';
import { ModelRelationship } from '~/storage/relationship';
} from '~/src/util';
import { ModelRelationship } from '~/src/storage/relationship';
import { ConsoleLogger } from '@aws-amplify/core';

import { Adapter } from './index';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { Adapter } from '..';
import AsyncStorageAdapter from '~/storage/adapter/AsyncStorageAdapter';
import AsyncStorageAdapter from '~/src/storage/adapter/AsyncStorageAdapter';

Check warning on line 4 in packages/datastore/src/storage/adapter/getDefaultAdapter/index.native.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/datastore

Using exported name 'AsyncStorageAdapter' as identifier for default export

const getDefaultAdapter: () => Adapter = () => {
return AsyncStorageAdapter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { Adapter } from '..';
import IndexedDBAdapter from '~/storage/adapter/IndexedDBAdapter';
import AsyncStorageAdapter from '~/storage/adapter/AsyncStorageAdapter';
import IndexedDBAdapter from '~/src/storage/adapter/IndexedDBAdapter';
import AsyncStorageAdapter from '~/src/storage/adapter/AsyncStorageAdapter';

Check warning on line 5 in packages/datastore/src/storage/adapter/getDefaultAdapter/index.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/datastore

Using exported name 'AsyncStorageAdapter' as identifier for default export
import { isBrowser, isWebWorker } from '@aws-amplify/core/internals/utils';

const getDefaultAdapter: () => Adapter = () => {
Expand Down
12 changes: 6 additions & 6 deletions packages/datastore/src/storage/adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ import {
PersistentModelConstructor,
QueryOne,
SystemComponent,
} from '~/types';
} from '~/src/types';

export interface Adapter extends SystemComponent {
clear(): Promise<void>;
save<T extends PersistentModel>(
model: T,
condition?: ModelPredicate<T>
condition?: ModelPredicate<T>,
): Promise<[T, OpType.INSERT | OpType.UPDATE][]>;
delete<T extends PersistentModel>(
modelOrModelConstructor: T | PersistentModelConstructor<T>,
condition?: ModelPredicate<T>
condition?: ModelPredicate<T>,
): Promise<[T[], T[]]>;
query<T extends PersistentModel>(
modelConstructor: PersistentModelConstructor<T>,
predicate?: ModelPredicate<T>,
pagination?: PaginationInput<T>
pagination?: PaginationInput<T>,
): Promise<T[]>;
queryOne<T extends PersistentModel>(
modelConstructor: PersistentModelConstructor<T>,
firstOrLast: QueryOne
firstOrLast: QueryOne,
): Promise<T | undefined>;
batchSave<T extends PersistentModel>(
modelConstructor: PersistentModelConstructor<T>,
items: ModelInstanceMetadata[]
items: ModelInstanceMetadata[],
): Promise<[T, OpType][]>;
}
2 changes: 1 addition & 1 deletion packages/datastore/src/storage/relationship.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { ModelFieldType, ModelMeta, isFieldAssociation } from '~/types';
import { ModelFieldType, ModelMeta, isFieldAssociation } from '~/src/types';

/**
* Defines a relationship from a LOCAL model.field to a REMOTE model.field and helps
Expand Down
10 changes: 5 additions & 5 deletions packages/datastore/src/storage/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
import { Observable, Subject, filter, map } from 'rxjs';

Check warning on line 3 in packages/datastore/src/storage/storage.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/datastore

Deprecated: Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8
import { Patch } from 'immer';
import { ModelInstanceCreator } from '~/datastore/datastore';
import { ModelPredicateCreator } from '~/predicates';
import { ModelInstanceCreator } from '~/src/datastore/datastore';
import { ModelPredicateCreator } from '~/src/predicates';
import {
InternalSchema,
InternalSubscriptionMessage,
Expand All @@ -19,15 +19,15 @@ import {
SchemaNamespace,
SubscriptionMessage,
isTargetNameAssociation,
} from '~/types';
} from '~/src/types';
import {
NAMESPACES,
STORAGE,
isModelConstructor,
validatePredicate,
valuesEqual,
} from '~/util';
import { getIdentifierValue } from '~/sync/utils';
} from '~/src/util';
import { getIdentifierValue } from '~/src/sync/utils';
import { Mutex } from '@aws-amplify/core/internals/utils';
import { ConsoleLogger } from '@aws-amplify/core';

Expand Down
12 changes: 6 additions & 6 deletions packages/datastore/src/sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { BackgroundProcessManager } from '@aws-amplify/core/internals/utils';
import { ConsoleLogger, Hub } from '@aws-amplify/core';
import { Observable, SubscriptionLike, filter, of } from 'rxjs';
import { ModelInstanceCreator } from '~/datastore/datastore';
import { ModelPredicateCreator } from '~/predicates';
import { ExclusiveStorage as Storage } from '~/storage/storage';
import { ModelInstanceCreator } from '~/src/datastore/datastore';
import { ModelPredicateCreator } from '~/src/predicates';
import { ExclusiveStorage as Storage } from '~/src/storage/storage';
import {
AmplifyContext,
AuthModeStrategy,
Expand All @@ -26,9 +26,9 @@ import {
SchemaModel,
SchemaNamespace,
TypeConstructorMap,
} from '~/types';
import type { __modelMeta__ } from '~/types';
import { SYNC, USER, getNow } from '~/util';
} from '~/src/types';
import type { __modelMeta__ } from '~/src/types';
import { SYNC, USER, getNow } from '~/src/util';
import {
ConnectionState,
CONNECTION_STATE_CHANGE as PUBSUB_CONNECTION_STATE_CHANGE,
Expand Down
4 changes: 2 additions & 2 deletions packages/datastore/src/sync/merger.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { Storage } from '~/storage/storage';
import { Storage } from '~/src/storage/storage';
import {
ModelInstanceMetadata,
OpType,
PersistentModelConstructor,
SchemaModel,
} from '~/types';
} from '~/src/types';

import { MutationEventOutbox } from './outbox';
import { getIdentifierValue } from './utils';
Expand Down
10 changes: 5 additions & 5 deletions packages/datastore/src/sync/outbox.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { ModelPredicateCreator } from '~/predicates';
import { ModelPredicateCreator } from '~/src/predicates';
import {
ExclusiveStorage as Storage,
Storage as StorageClass,
StorageFacade,
} from '~/storage/storage';
import { ModelInstanceCreator } from '~/datastore/datastore';
} from '~/src/storage/storage';
import { ModelInstanceCreator } from '~/src/datastore/datastore';
import {
InternalSchema,
PersistentModel,
PersistentModelConstructor,
QueryOne,
SchemaModel,
} from '~/types';
import { SYNC, USER, valuesEqual } from '~/util';
} from '~/src/types';
import { SYNC, USER, valuesEqual } from '~/src/util';

import { TransformerMutationType, getIdentifierValue } from './utils';

Expand Down
4 changes: 2 additions & 2 deletions packages/datastore/src/sync/processors/errorMaps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { ErrorType } from '~/types';
import { resolveServiceErrorStatusCode } from '~/sync/utils';
import { ErrorType } from '~/src/types';
import { resolveServiceErrorStatusCode } from '~/src/sync/utils';

export type ErrorMap = Partial<{
[key in ErrorType]: (error: Error) => boolean;
Expand Down
Loading

0 comments on commit 38f7430

Please sign in to comment.