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

Copy flow files so that the module returns typed values #51

Merged
merged 11 commits into from
Jan 16, 2019
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"scripts": {
"prepublish": "yarn run build",
"build": "babel ./src -d ./lib",
"build": "babel ./src -d ./lib && flow-copy-source src lib",
Copy link
Contributor

Choose a reason for hiding this comment

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

would be nice to switch the order of these so the babel options like --watch can still be used with build

Copy link
Contributor

Choose a reason for hiding this comment

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

also nit: ./src ./lib to match all the other relative paths

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point. We'd probably want a kind of watch command to do both of these things, wouldn't we?

Copy link
Contributor

Choose a reason for hiding this comment

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

yea something like that or like start for development

"lint": "eslint .",
"test": "jest",
"test-inspect": "node --inspect-brk ./node_modules/.bin/jest --runInBand",
Expand Down Expand Up @@ -49,6 +49,7 @@
"eslint-plugin-prettier": "^2.6.2",
"eslint-plugin-react": "^7.11.1",
"flow-bin": "^0.80.0",
"flow-copy-source": "^2.0.2",
"flow-typed": "^2.5.1",
"jest": "^23.6.0",
"jest-fetch-mock": "GrahamTheCoder/jest-fetch-mock#blob-fix",
Expand Down
2 changes: 1 addition & 1 deletion src/AUTO/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
import type { AbstractInterface } from "../";
import type { AbstractInterface } from "../types";
import AbstractCLI, { type Options as OptionsCLI } from "../AbstractCLI";
import AbstractAPI, { type Options as OptionsAPI } from "../AbstractAPI";

Expand Down
2 changes: 1 addition & 1 deletion src/AbstractAPI/Cursor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @flow */
import type { CursorMeta, CursorPromise, CursorResponse } from "../";
import type { CursorMeta, CursorPromise, CursorResponse } from "../types";

export default class Cursor<T> {
lastResponse: ?Promise<CursorResponse<T> | void>;
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractAPI/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type {
AccessToken,
Activity,
Notification
} from "../";
} from "../types";
import randomTraceId from "./randomTraceId";
import Cursor from "./Cursor";

Expand Down
2 changes: 1 addition & 1 deletion src/AbstractCLI/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
LayerDescriptor,
CollectionDescriptor,
AccessTokenOption
} from "../";
} from "../types";

const logSpawn = log.extend("AbstractCLI:spawn");
const logError = log.extend("AbstractCLI:error");
Expand Down
2 changes: 1 addition & 1 deletion src/Client/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
import type { AbstractInterface, AccessTokenOption } from "../";
import type { AbstractInterface, AccessTokenOption } from "../types";
import { AUTO } from "../transports";

type Options = {
Expand Down
6 changes: 5 additions & 1 deletion src/sketch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// @flow
/* global process NSString PROSketchBootstrap */
import type { ProjectDescriptor, BranchDescriptor, FileDescriptor } from ".";
import type {
ProjectDescriptor,
BranchDescriptor,
FileDescriptor
} from "./types";

export function isSketchPlugin() {
// New versions of skpm set process type to "sketch". For older
Expand Down
2 changes: 1 addition & 1 deletion src/support/factories.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
CollectionDescriptor,
CommentDescriptor,
UserDescriptor
} from "../";
} from "../types";

export function buildOptions(options: *) {
return {
Expand Down
20 changes: 11 additions & 9 deletions src/index.js.flow → src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ export type CommitDescriptor = {|

export type BranchDescriptor = {|
...ObjectDescriptor,
sha: $PropertyType<ObjectDescriptor, "sha"> | "latest"
sha: $PropertyType<ObjectDescriptor, "sha">
|};

export type FileDescriptor = {|
...ObjectDescriptor,
sha: $PropertyType<ObjectDescriptor, "sha"> | "latest",
sha: $PropertyType<ObjectDescriptor, "sha">,
fileId: string
|};

Expand All @@ -55,7 +55,7 @@ export type PageDescriptor = {|

export type LayerDescriptor = {|
...ObjectDescriptor,
sha: $PropertyType<ObjectDescriptor, "sha"> | "latest",
sha: $PropertyType<ObjectDescriptor, "sha">,
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding a note here for future us. Flow doesn't appear to be refining the literal "latest" when a desscriptor (like CommitDescriptor) and descriptor that supports latest are in a union

screenshot 2019-01-08 15 53 42

fileId: string,
pageId: string,
layerId: string
Expand Down Expand Up @@ -327,7 +327,7 @@ export type User = {

export type Organization = {
billingEmail?: string,
features: {[feature: string]: boolean},
features: { [feature: string]: boolean },
hasBillingInfo?: boolean,
id: string,
isUsernameOrganization?: boolean,
Expand Down Expand Up @@ -1300,7 +1300,9 @@ export interface AbstractInterface {
};

organizations?: {
info: (organizationDescriptor: OrganizationDescriptor) => Promise<Organization>,
info: (
organizationDescriptor: OrganizationDescriptor
) => Promise<Organization>,
list: () => Promise<Organization[]>
};

Expand Down Expand Up @@ -1391,15 +1393,15 @@ export interface AbstractInterface {
objectDescriptor?: OrganizationDescriptor,
options?: ListOptions
) => CursorPromise<Notification[]>,
info: (notificationDescriptor: NotificationDescriptor) => Promise<Notification>
info: (
notificationDescriptor: NotificationDescriptor
) => Promise<Notification>
};

users?: {
list: (
objectDescriptor: OrganizationDescriptor | ProjectDescriptor
) => Promise<User[]>,
info: (
userDescriptor: UserDescriptor
) => Promise<User>
info: (userDescriptor: UserDescriptor) => Promise<User>
};
}
Copy link
Contributor

@amccloud amccloud Jan 8, 2019

Choose a reason for hiding this comment

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

Should we export some/all of these types in index.js so that we can have access to Abstract.ShareDescriptor or Abstract.types.ShareDescriptor in application code

2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
FileDescriptor,
LayerDescriptor,
ShareDescriptor
} from "./";
} from "./types";

export function objectBranchDescriptor(
objectDescriptor:
Expand Down
Loading