Skip to content

Commit

Permalink
Revert "Revert "wpcom-proxy-request: Return Promise if no callback sp…
Browse files Browse the repository at this point in the history
…ecified (#39683)" (#39721)"

This reverts commit 7f5092a.
  • Loading branch information
ockham authored Feb 27, 2020
1 parent 7f5092a commit 74918ee
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 179 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,3 @@ cached-requests.json
/apps/*/dist/
/apps/*/types/
/packages/*/dist/
# Redundant after https://github.com/Automattic/wp-calypso/pull/39173
# Safe to remove after some time has passed
/packages/*/types/
11 changes: 0 additions & 11 deletions packages/data-stores/global.d.ts

This file was deleted.

4 changes: 4 additions & 0 deletions packages/data-stores/src/shared-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface WpcomClientCredentials {
client_id: string;
client_secret: string;
}
10 changes: 9 additions & 1 deletion packages/data-stores/src/site/controls.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
/**
* External dependencies
*/
import wpcomRequest, { requestAllBlogsAccess } from 'wpcom-proxy-request';

/**
* Internal dependencies
*/
import { wpcomRequest, WpcomClientCredentials } from '../utils';
import { CreateSiteAction } from './types';
import { WpcomClientCredentials } from '../shared-types';

export default function createControls( clientCreds: WpcomClientCredentials ) {
requestAllBlogsAccess().catch( () => {
throw new Error( 'Could not get all blog access.' );
} );
return {
CREATE_SITE: async ( action: CreateSiteAction ) => {
const { authToken, ...providedParams } = action.params;
Expand Down
2 changes: 1 addition & 1 deletion packages/data-stores/src/site/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as actions from './actions';
import * as selectors from './selectors';
import createControls from './controls';
import { DispatchFromMap, SelectFromMap } from '../mapped-types';
import { WpcomClientCredentials } from '../utils';
import { WpcomClientCredentials } from '../shared-types';

export * from './types';
export { State };
Expand Down
10 changes: 9 additions & 1 deletion packages/data-stores/src/user/controls.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
/**
* External dependencies
*/
import wpcomRequest, { requestAllBlogsAccess } from 'wpcom-proxy-request';

/**
* Internal dependencies
*/
import { wpcomRequest, WpcomClientCredentials } from '../utils';
import { CreateAccountAction } from './types';
import { WpcomClientCredentials } from '../shared-types';

export default function createControls( clientCreds: WpcomClientCredentials ) {
requestAllBlogsAccess().catch( () => {
throw new Error( 'Could not get all blog access.' );
} );
return {
CREATE_ACCOUNT: async ( action: CreateAccountAction ) => {
const defaultParams = {
Expand Down
2 changes: 1 addition & 1 deletion packages/data-stores/src/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as resolvers from './resolvers';
import * as selectors from './selectors';
import createControls from './controls';
import { DispatchFromMap, SelectFromMap } from '../mapped-types';
import { WpcomClientCredentials } from '../utils';
import { WpcomClientCredentials } from '../shared-types';

export * from './types';
export { State };
Expand Down
1 change: 0 additions & 1 deletion packages/data-stores/src/utils/index.ts

This file was deleted.

47 changes: 0 additions & 47 deletions packages/data-stores/src/utils/wpcom-wrapper.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/data-stores/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"incremental": true,
"tsBuildInfoFile": "../../.tsc-cache/data-stores"
},
"files": [ "./src/index.ts", "./global.d.ts" ],
"files": [ "./src/index.ts" ],
"exclude": [ "**/docs/*", "**/test/*" ]
}
204 changes: 93 additions & 111 deletions packages/wpcom-proxy-request/History.md
Original file line number Diff line number Diff line change
@@ -1,154 +1,136 @@
6.0.0 / TBD
==================
# 6.0.0 / TBD

* Move the published `build/` folder to `dist/` to align with other Calypso packages
* Upgrade dependency 'debug' to 4.1.1
- Breaking: Return Promise (rather than `XMLHttpRequest` instance) if no callback argument is provided.
- In practice, most people have probably been using the callback rather than the returned `XMLHttpRequest` instance, so this shouldn't be a breaking change for most.
- Add `requestAllBlogsAccess()`.
- Add a few type definitions.
- Move the published `build/` folder to `dist/` to align with other Calypso packages
- Upgrade dependency 'debug' to 4.1.1

5.0.2 / 2018-10-30
==================
# 5.0.2 / 2018-10-30

* Fix the Chrome site isolation workaround to not break file uploads on Safari 10
- Fix the Chrome site isolation workaround to not break file uploads on Safari 10

5.0.1 / 2018-10-29
==================
# 5.0.1 / 2018-10-29

* Work around a Chrome site isolation bug when uploading files
- Work around a Chrome site isolation bug when uploading files

3.0.0 / 2016-07-27
==================
# 3.0.0 / 2016-07-27

* examples: add wp-api example
* client-test-app: add index.html
* Add test stuff - Add tests - Add rules to compile the browser application
* core: improve WP-API integration - detect response error in envelope mode - remove _headers from body and add a thrid response parameter in the callback - add status to headers parameter
* examples: eslint
* examples: update bundle path and global var
* create bundle file only for testing purpose
* pkg: make build in prepublish hook
* pkg: publish only useful files in npm package
* rewrite using ES6
* Add eslint rules
* change compiling process - Use n8-make to make pre-compilation - Make bundle file using Webpack``
* index: opt-in to `supports_error_obj` better Errors
* Use `wp-error` module for common Error handling logic
* index: add missing `uninstall()` function
* Fix TypeError on string body 'error' from rest-proxy
* Add pinghub example
* Add support for persistent connections
- examples: add wp-api example
- client-test-app: add index.html
- Add test stuff - Add tests - Add rules to compile the browser application
- core: improve WP-API integration - detect response error in envelope mode - remove \_headers from body and add a thrid response parameter in the callback - add status to headers parameter
- examples: eslint
- examples: update bundle path and global var
- create bundle file only for testing purpose
- pkg: make build in prepublish hook
- pkg: publish only useful files in npm package
- rewrite using ES6
- Add eslint rules
- change compiling process - Use n8-make to make pre-compilation - Make bundle file using Webpack``
- index: opt-in to `supports_error_obj` better Errors
- Use `wp-error` module for common Error handling logic
- index: add missing `uninstall()` function
- Fix TypeError on string body 'error' from rest-proxy
- Add pinghub example
- Add support for persistent connections

2.0.0 / 2016-03-11
==================
# 2.0.0 / 2016-03-11

* index: opt-in to `supports_error_obj` better Errors
- index: opt-in to `supports_error_obj` better Errors

1.2.0 / 2016-03-09
==================
# 1.2.0 / 2016-03-09

* dist: recompile
* Use `wp-error` module for common Error handling logic
* add missing LICENSE stuff
* index: add missing `uninstall()` function
- dist: recompile
- Use `wp-error` module for common Error handling logic
- add missing LICENSE stuff
- index: add missing `uninstall()` function

1.1.1 / 2016-03-08
==================
# 1.1.1 / 2016-03-08

* fix TypeError on string body 'error' from rest-proxy
- fix TypeError on string body 'error' from rest-proxy

1.1.0 / 2016-02-24
==================
# 1.1.0 / 2016-02-24

* support persistent connections e.g. websockets
* add example for connecting to Pinghub via websocket
- support persistent connections e.g. websockets
- add example for connecting to Pinghub via websocket

1.0.5 / 2015-11-22
==================
# 1.0.5 / 2015-11-22

* package: update "debug" to v2.2.0
- package: update "debug" to v2.2.0

1.0.4 / 2015-02-27
==================
# 1.0.4 / 2015-02-27

* dist: recompile
* wrapping try/catch on an IIFE.
* optimization for short-circuit evaluation.
* detecting support for the structured clone algorithm.
* forcing JSON string for postMessage/onmessage to circumvent IE9 limitations.
- dist: recompile
- wrapping try/catch on an IIFE.
- optimization for short-circuit evaluation.
- detecting support for the structured clone algorithm.
- forcing JSON string for postMessage/onmessage to circumvent IE9 limitations.

1.0.3 / 2015-02-09
==================
# 1.0.3 / 2015-02-09

* index: don't throw in the case that there's no `buffered` Array
* examples: better me.html example output
- index: don't throw in the case that there's no `buffered` Array
- examples: better me.html example output

1.0.2 / 2014-10-21
==================
# 1.0.2 / 2014-10-21

* Republish since npm messed up v1.0.1
- Republish since npm messed up v1.0.1

1.0.1 / 2014-10-21
==================
# 1.0.1 / 2014-10-21

* index: bail if no matching XHR instance was found
* index: use `event` module to listen for XHR events
- index: bail if no matching XHR instance was found
- index: use `event` module to listen for XHR events

1.0.0 / 2014-10-20
==================
# 1.0.0 / 2014-10-20

* index: refactor to not use Promise anymore
* examples: tweak "me.html" example since it no longer returns a Promise
* examples: add "progress" listeners to upload example
* examples: multiply percent complete by 100
* examples: make "upload.html" example use user's primary blog
* package: update "debug" to v2.1.0
* package: update "browserify" to v6.1.0
* package: remove unused "promise" dependency
- index: refactor to not use Promise anymore
- examples: tweak "me.html" example since it no longer returns a Promise
- examples: add "progress" listeners to upload example
- examples: multiply percent complete by 100
- examples: make "upload.html" example use user's primary blog
- package: update "debug" to v2.1.0
- package: update "browserify" to v6.1.0
- package: remove unused "promise" dependency

0.2.5 / 2014-06-26
==================
# 0.2.5 / 2014-06-26

* dist: recompile
* index: honor ports on the host page (#3, @rralian)
- dist: recompile
- index: honor ports on the host page (#3, @rralian)

0.2.4 / 2014-06-24
==================
# 0.2.4 / 2014-06-24

* dist: recompile
* package: update all dependencies
- dist: recompile
- package: update all dependencies

0.2.3 / 2014-06-24
==================
# 0.2.3 / 2014-06-24

* dist: recompile
* index: don't bother doing a debug() call for the metaAPI calls
* index: use %o debug formatter when it makes sense
* index: implement File -> ArrayBuffer manual conversion for Firefox
- dist: recompile
- index: don't bother doing a debug() call for the metaAPI calls
- index: use %o debug formatter when it makes sense
- index: implement File -> ArrayBuffer manual conversion for Firefox

0.2.2 / 2014-06-10
==================
# 0.2.2 / 2014-06-10

* dist: recompile
* examples: add `freshly-pressed.html` example
* package: be loose with the `debug` version
- dist: recompile
- examples: add `freshly-pressed.html` example
- package: be loose with the `debug` version

0.2.1 / 2014-06-05
==================
# 0.2.1 / 2014-06-05

* package: update "debug" to v1.0.0
- package: update "debug" to v1.0.0

0.2.0 / 2014-05-27
==================
# 0.2.0 / 2014-05-27

* index: update <iframe> "src" URL
* examples: fix <script> tag src location
- index: update <iframe> "src" URL
- examples: fix <script> tag src location

0.1.1 / 2014-05-12
==================
# 0.1.1 / 2014-05-12

* examples: add `upload.html` example
* index: rename `res` variable to `body`
* index: bind to iframe "load" event before setting `.src`
- examples: add `upload.html` example
- index: rename `res` variable to `body`
- index: bind to iframe "load" event before setting `.src`

0.1.0 / 2014-04-22
==================
# 0.1.0 / 2014-04-22

* initial release
- initial release
2 changes: 2 additions & 0 deletions packages/wpcom-proxy-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
},
"files": [
"dist",
"types",
"History.md",
"README.md"
],
"types": "types",
"scripts": {
"clean": "npx rimraf dist",
"prepublish": "npm run clean",
Expand Down
Loading

0 comments on commit 74918ee

Please sign in to comment.