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

Refactor: Move DataStore Model schema to Internal directory #563

Merged
merged 7 commits into from
Jun 25, 2020

Conversation

lawmicha
Copy link
Contributor

Issue #, if available:

Description of changes:

  • Moved the Model related classes over to Model/Internal.
  • Moved Model Schema related classes to Model/Internl/Schema
  • Since AnyModel is only used internally in DataStore only. Moved this over to AWSPluginsCore

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@lawmicha lawmicha marked this pull request as ready for review June 18, 2020 19:13
@lawmicha lawmicha requested a review from palpatim June 18, 2020 19:13
@lawmicha lawmicha self-assigned this Jun 18, 2020
@lawmicha lawmicha requested a review from drochetti June 18, 2020 19:17
@@ -9,6 +9,7 @@ import Foundation

// MARK: - Embeddable

/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have something a little more noticeable and dire:

/// <rest of comment>
/// - Warning: Although this has `public` access, it is intended for internal use and should not be used directly
///   by host applications. The behavior of this may change without warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, taking this comment and applying it below the existing comment for classes. removing from extensions

@@ -7,6 +7,7 @@

import Foundation

/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
/// Protocol that represents a `Codable` Enum that can be persisted and easily
/// integrate with remote APIs since it must have a raw `String` value.
///
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

below: change "simple enums (i.e. the ones that don't have arguments)" to "enums without associated values"

@@ -5,6 +5,9 @@
// SPDX-License-Identifier: Apache-2.0
//

import Amplify

/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be on the public symbol, not the extension wrapper

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this can be removed, since this was moved to AWSPluginsCore

@@ -8,6 +8,7 @@
import Amplify
import Foundation
import SQLite
import AWSPluginsCore

typealias ModelValues = [String: Any?]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below: a public func (from(dictionary:)) on a non-public type doesn't make sense. Remove public from the func

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updating

@lawmicha lawmicha force-pushed the lawmicha/internal branch from 4ac2795 to 3223fed Compare June 18, 2020 21:10
@lawmicha lawmicha changed the base branch from lawmicha/customtype to master June 18, 2020 21:11
@lawmicha lawmicha requested a review from palpatim June 18, 2020 21:15
@@ -7,7 +7,10 @@

import Foundation

/// Note that although this is public, it is intended for internal use and not consumed directly by host applications.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops, removed, checked if there was another instance left

Copy link
Member

@palpatim palpatim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, I don't thiknk we can make Model internal

@lawmicha
Copy link
Contributor Author

lawmicha commented Jun 22, 2020

while a codegenerated model looks like this in jazzy docs, none of the fields marked as internal. which is expected

image

Clicking through to the Model docs:

image
The highlighted ones here are marked as internal
Some reasoning behind this:

  • Made Model not internal
  • id is used by the developer in many methods like query(byId) and is part of the concrete Model class
  • I can see modelName may be used in developer code somewhere, potentially used when filtering on mutationEvents from DataStore publisher
  • i think everthing else should be marked as internal

@lawmicha lawmicha requested a review from palpatim June 22, 2020 23:23
@palpatim palpatim changed the base branch from master to main June 24, 2020 14:55
Copy link
Member

@palpatim palpatim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, let's try this in a sample app to ensure that moving files & types between modules don't result in any code changes required for a customer project. Assuming everything is transparent, ship it.

@lawmicha
Copy link
Contributor Author

As discussed, let's try this in a sample app to ensure that moving files & types between modules don't result in any code changes required for a customer project. Assuming everything is transparent, ship it.

looks like things check out in the sample app. Following these instructions from the discord message helped set up the local podspec repo. Using ./CircleciScripts/setup_private_specs.sh 1.0.1 1.0.1-unreleased since this local branch is on 1.0.1, will replace the local podspec's with 1.0.1-unreleased for the cocoapods repo.

In sample app's Podfile, i explicitly referenced pod 'Amplify', '1.0.1-unreleased' rather than ~> since it was resolving to 1.0.2 (I also have 1.0.2 in my private local repo)

@lawmicha lawmicha merged commit 468e885 into main Jun 25, 2020
@lawmicha lawmicha deleted the lawmicha/internal branch June 25, 2020 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants