From 161774c07c0f454fd001cff7b26752866cbcff5f Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Fri, 21 Jun 2019 21:09:23 +0200 Subject: [PATCH 01/11] [react-native] added universal-url, changed Blob to object --- packages/api-bzz-react-native/.babelrc | 1 + packages/api-bzz-react-native/package.json | 33 +++++++++++++ packages/api-bzz-react-native/src/index.js | 48 +++++++++++++++++++ .../api-bzz-react-native/types/index.d.ts | 9 ++++ 4 files changed, 91 insertions(+) create mode 100644 packages/api-bzz-react-native/.babelrc create mode 100644 packages/api-bzz-react-native/package.json create mode 100644 packages/api-bzz-react-native/src/index.js create mode 100644 packages/api-bzz-react-native/types/index.d.ts diff --git a/packages/api-bzz-react-native/.babelrc b/packages/api-bzz-react-native/.babelrc new file mode 100644 index 0000000..70afce3 --- /dev/null +++ b/packages/api-bzz-react-native/.babelrc @@ -0,0 +1 @@ +{ "extends": "../../.babelrc" } diff --git a/packages/api-bzz-react-native/package.json b/packages/api-bzz-react-native/package.json new file mode 100644 index 0000000..d892373 --- /dev/null +++ b/packages/api-bzz-react-native/package.json @@ -0,0 +1,33 @@ +{ + "name": "@erebos/api-bzz-react-native", + "version": "0.8.1", + "description": "Bzz API for react-native", + "repository": "git@github.com:MainframeHQ/erebos.git", + "main": "cjs/index.js", + "module": "esm/index.js", + "types": "types/index.d.ts", + "author": "Mainframe", + "license": "MIT", + "files": [ + "cjs/*", + "esm/*", + "types/*" + ], + "scripts": { + "clean": "del cjs esm", + "build:cjs": "BABEL_ENV='browser-cjs' babel src --out-dir cjs", + "build:esm": "BABEL_ENV='browser-esm' babel src --out-dir esm", + "build:js": "yarn build:cjs && yarn build:esm", + "build:flow": "flow-copy-source src cjs && flow-copy-source src esm", + "build": "yarn clean && yarn build:js && yarn build:flow", + "prepublishOnly": "yarn build" + }, + "dependencies": { + "@babel/runtime": "^7.4.5", + "@erebos/api-bzz-base": "^0.8.1", + "universal-url": "^2.0.0" + }, + "devDependencies": { + "flow-bin": "^0.101.0" + } +} diff --git a/packages/api-bzz-react-native/src/index.js b/packages/api-bzz-react-native/src/index.js new file mode 100644 index 0000000..fe2402b --- /dev/null +++ b/packages/api-bzz-react-native/src/index.js @@ -0,0 +1,48 @@ +// @flow +import { URL } from 'universal-url'; +import BaseBzz, { + type BzzConfig, + type DirectoryData, + type UploadOptions, +} from '@erebos/api-bzz-base' +import type { hexValue } from '@erebos/hex' + +export type * from '@erebos/api-bzz-base' + +export default class Bzz extends BaseBzz { + constructor(config: BzzConfig) { + const { url, ...cfg } = config + super({ ...cfg, url: new URL(url).href }) + this._fetch = window.fetch.bind(window) + } + + uploadDirectory( + directory: DirectoryData, + options?: UploadOptions = {}, + ): Promise { + const form = new FormData() + Object.keys(directory).forEach(key => { + form.append( + key, + { + uri: directory[key].data, + type: directory[key].mimeType, + name: directory[key].name, + }, + key, + ) + }) + if (options.defaultPath != null) { + const file = directory[options.defaultPath] + if (file != null) { + form.append('', { + uri: directory[key].data, + type: directory[key].mimeType, + name: directory[key].name, + }, + '') + } + } + return this._upload(form, options) + } +} diff --git a/packages/api-bzz-react-native/types/index.d.ts b/packages/api-bzz-react-native/types/index.d.ts new file mode 100644 index 0000000..a8992ad --- /dev/null +++ b/packages/api-bzz-react-native/types/index.d.ts @@ -0,0 +1,9 @@ +import BaseBzz, { DirectoryData, UploadOptions } from '@erebos/api-bzz-base' +import { hexValue } from '@erebos/hex' + +export default class Bzz extends BaseBzz { + uploadDirectory( + directory: DirectoryData, + options?: UploadOptions, + ): Promise +} From c5438b8e25c2ef2d1506e4c027621ed3830b0bb7 Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Fri, 21 Jun 2019 22:00:47 +0200 Subject: [PATCH 02/11] fix linter issues --- packages/api-bzz-react-native/src/index.js | 27 +++++++++++++--------- yarn.lock | 13 +++++++++++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/packages/api-bzz-react-native/src/index.js b/packages/api-bzz-react-native/src/index.js index fe2402b..0a22017 100644 --- a/packages/api-bzz-react-native/src/index.js +++ b/packages/api-bzz-react-native/src/index.js @@ -1,5 +1,7 @@ // @flow -import { URL } from 'universal-url'; +/* eslint-env browser */ + +import { URL } from 'universal-url' import BaseBzz, { type BzzConfig, type DirectoryData, @@ -24,23 +26,26 @@ export default class Bzz extends BaseBzz { Object.keys(directory).forEach(key => { form.append( key, - { + ({ uri: directory[key].data, - type: directory[key].mimeType, - name: directory[key].name, - }, + type: directory[key].contentType, + name: key, + }: any), key, ) }) if (options.defaultPath != null) { const file = directory[options.defaultPath] if (file != null) { - form.append('', { - uri: directory[key].data, - type: directory[key].mimeType, - name: directory[key].name, - }, - '') + form.append( + '', + ({ + uri: directory[options.defaultPath].data, + type: directory[options.defaultPath].contentType, + name: options.defaultPath, + }: any), + '', + ) } } return this._upload(form, options) diff --git a/yarn.lock b/yarn.lock index 687d8cb..796a82e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4475,6 +4475,11 @@ hash.js@^1.0.0, hash.js@^1.0.3: inherits "^2.0.3" minimalistic-assert "^1.0.1" +hasurl@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/hasurl/-/hasurl-1.0.0.tgz#e4c619097ae1e8fc906bee904ce47e94f5e1ea37" + integrity sha512-43ypUd3DbwyCT01UYpA99AEZxZ4aKtRxWGBHEIbjcOsUghd9YUON0C+JF6isNjaiwC/UF5neaUudy6JS9jZPZQ== + hmac-drbg@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" @@ -8296,6 +8301,14 @@ unique-slug@^2.0.0: dependencies: imurmurhash "^0.1.4" +universal-url@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/universal-url/-/universal-url-2.0.0.tgz#35e7fc2c3374804905cee67ea289ed3a47669809" + integrity sha512-3DLtXdm/G1LQMCnPj+Aw7uDoleQttNHp2g5FnNQKR6cP6taNWS1b/Ehjjx4PVyvejKi3TJyu8iBraKM4q3JQPg== + dependencies: + hasurl "^1.0.0" + whatwg-url "^7.0.0" + universal-user-agent@^2.0.0, universal-user-agent@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-2.0.3.tgz#9f6f09f9cc33de867bb720d84c08069b14937c6c" From 5b67655f615ee02b13cef8097e45fe8cba7ad1a3 Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Sat, 27 Jul 2019 15:19:41 +0200 Subject: [PATCH 03/11] change file to .ts --- .../src/{index.js => index.ts} | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) rename packages/api-bzz-react-native/src/{index.js => index.ts} (62%) diff --git a/packages/api-bzz-react-native/src/index.js b/packages/api-bzz-react-native/src/index.ts similarity index 62% rename from packages/api-bzz-react-native/src/index.js rename to packages/api-bzz-react-native/src/index.ts index 0a22017..0a86f11 100644 --- a/packages/api-bzz-react-native/src/index.js +++ b/packages/api-bzz-react-native/src/index.ts @@ -1,26 +1,24 @@ -// @flow /* eslint-env browser */ - import { URL } from 'universal-url' -import BaseBzz, { - type BzzConfig, - type DirectoryData, - type UploadOptions, +import { + BaseBzz, + BzzConfig, + DirectoryData, + UploadOptions, } from '@erebos/api-bzz-base' -import type { hexValue } from '@erebos/hex' +import { hexValue } from '@erebos/hex' -export type * from '@erebos/api-bzz-base' +export * from '@erebos/api-bzz-base' -export default class Bzz extends BaseBzz { - constructor(config: BzzConfig) { +export class Bzz extends BaseBzz { + public constructor(config: BzzConfig) { const { url, ...cfg } = config - super({ ...cfg, url: new URL(url).href }) - this._fetch = window.fetch.bind(window) + super(window.fetch.bind(window), { ...cfg, url: new URL(url).href }) } - uploadDirectory( + public uploadDirectory( directory: DirectoryData, - options?: UploadOptions = {}, + options: UploadOptions = {}, ): Promise { const form = new FormData() Object.keys(directory).forEach(key => { @@ -30,7 +28,7 @@ export default class Bzz extends BaseBzz { uri: directory[key].data, type: directory[key].contentType, name: key, - }: any), + } as any), key, ) }) @@ -43,11 +41,11 @@ export default class Bzz extends BaseBzz { uri: directory[options.defaultPath].data, type: directory[options.defaultPath].contentType, name: options.defaultPath, - }: any), + } as any), '', ) } } - return this._upload(form, options) + return this.uploadBody(form, options) } } From 0357c7790b3235047ebc5e3b02472c1083ef2b47 Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Sat, 27 Jul 2019 15:25:28 +0200 Subject: [PATCH 04/11] fix commands in package.json --- packages/api-bzz-react-native/package.json | 10 +++++----- packages/api-bzz-react-native/types/index.d.ts | 9 --------- 2 files changed, 5 insertions(+), 14 deletions(-) delete mode 100644 packages/api-bzz-react-native/types/index.d.ts diff --git a/packages/api-bzz-react-native/package.json b/packages/api-bzz-react-native/package.json index d892373..4a968d7 100644 --- a/packages/api-bzz-react-native/package.json +++ b/packages/api-bzz-react-native/package.json @@ -14,12 +14,12 @@ "types/*" ], "scripts": { - "clean": "del cjs esm", - "build:cjs": "BABEL_ENV='browser-cjs' babel src --out-dir cjs", - "build:esm": "BABEL_ENV='browser-esm' babel src --out-dir esm", + "clean": "del cjs esm types", + "build:cjs": "BABEL_ENV='browser-cjs' babel src --out-dir cjs --extensions \".ts\"", + "build:esm": "BABEL_ENV='browser-esm' babel src --out-dir esm --extensions \".ts\"", "build:js": "yarn build:cjs && yarn build:esm", - "build:flow": "flow-copy-source src cjs && flow-copy-source src esm", - "build": "yarn clean && yarn build:js && yarn build:flow", + "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", + "build": "yarn clean && yarn build:js && yarn build:types", "prepublishOnly": "yarn build" }, "dependencies": { diff --git a/packages/api-bzz-react-native/types/index.d.ts b/packages/api-bzz-react-native/types/index.d.ts deleted file mode 100644 index a8992ad..0000000 --- a/packages/api-bzz-react-native/types/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import BaseBzz, { DirectoryData, UploadOptions } from '@erebos/api-bzz-base' -import { hexValue } from '@erebos/hex' - -export default class Bzz extends BaseBzz { - uploadDirectory( - directory: DirectoryData, - options?: UploadOptions, - ): Promise -} From 11c58a34e6fb82efed6af556fc7dd9c63dc35fc4 Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Tue, 6 Aug 2019 10:14:46 +0200 Subject: [PATCH 05/11] convert react-native version to ts --- .gitignore | 1 + packages/api-bzz-react-native/package.json | 5 +- packages/api-bzz-react-native/src/index.ts | 1 + .../api-bzz-react-native/tsconfig.build.json | 8 +++ .../types/index.d.ts | 0 packages/timeline/types/index.d.ts | 69 ------------------- tsconfig.build.json | 2 +- yarn.lock | 46 ++++++++++++- 8 files changed, 58 insertions(+), 74 deletions(-) create mode 100644 packages/api-bzz-react-native/tsconfig.build.json rename packages/{api-bzz-browser => api-bzz-react-native}/types/index.d.ts (100%) delete mode 100644 packages/timeline/types/index.d.ts diff --git a/.gitignore b/.gitignore index d6e9d82..2347372 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.log /.idea +/.vscode /packages/*/cjs /packages/*/dist /packages/*/esm diff --git a/packages/api-bzz-react-native/package.json b/packages/api-bzz-react-native/package.json index 4a968d7..2c8bbfb 100644 --- a/packages/api-bzz-react-native/package.json +++ b/packages/api-bzz-react-native/package.json @@ -1,6 +1,6 @@ { "name": "@erebos/api-bzz-react-native", - "version": "0.8.1", + "version": "0.9.0", "description": "Bzz API for react-native", "repository": "git@github.com:MainframeHQ/erebos.git", "main": "cjs/index.js", @@ -23,8 +23,7 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@babel/runtime": "^7.4.5", - "@erebos/api-bzz-base": "^0.8.1", + "@erebos/api-bzz-base": "^0.9.0", "universal-url": "^2.0.0" }, "devDependencies": { diff --git a/packages/api-bzz-react-native/src/index.ts b/packages/api-bzz-react-native/src/index.ts index 0a86f11..18fc80f 100644 --- a/packages/api-bzz-react-native/src/index.ts +++ b/packages/api-bzz-react-native/src/index.ts @@ -1,4 +1,5 @@ /* eslint-env browser */ +// @ts-ignore import { URL } from 'universal-url' import { BaseBzz, diff --git a/packages/api-bzz-react-native/tsconfig.build.json b/packages/api-bzz-react-native/tsconfig.build.json new file mode 100644 index 0000000..4e30162 --- /dev/null +++ b/packages/api-bzz-react-native/tsconfig.build.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.build.json", + "compilerOptions": { + "lib": ["dom", "es2015"], + "outDir": "./types" + }, + "include": ["./src/**/*"] +} diff --git a/packages/api-bzz-browser/types/index.d.ts b/packages/api-bzz-react-native/types/index.d.ts similarity index 100% rename from packages/api-bzz-browser/types/index.d.ts rename to packages/api-bzz-react-native/types/index.d.ts diff --git a/packages/timeline/types/index.d.ts b/packages/timeline/types/index.d.ts deleted file mode 100644 index 3b38e18..0000000 --- a/packages/timeline/types/index.d.ts +++ /dev/null @@ -1,69 +0,0 @@ -/// -import { BaseBzz, BaseResponse, FeedParams, FetchOptions, UploadOptions } from '@erebos/api-bzz-base'; -import { hexValue } from '@erebos/hex'; -import { Observable } from 'rxjs'; -export declare const PROTOCOL = "timeline"; -export declare const VERSION = "1.0.0"; -export declare const VERSION_RANGE = "^1.0.0"; -export interface PartialChapter { - protocol: string; - version: string; - timestamp: number; - author: string; - type: string; - content: T; - previous?: string | null; - references?: Array; - signature?: string; -} -export declare type Chapter = PartialChapter & { - id: string; -}; -export declare type DecodeChapter = (res: R) => Promise>; -export declare type EncodeChapter = (chapter: PartialChapter) => Promise; -export interface PollOptions extends FetchOptions { - interval: number; -} -export interface LiveOptions extends PollOptions { - previous?: string; - timestamp?: number; -} -export declare function createChapter(chapter: Partial>): PartialChapter; -export interface MaybeChapter extends Record { - protocol?: string; - version?: string; -} -export declare function validateChapter(chapter: T): T; -export interface TimelineConfig = BaseBzz> { - bzz: Bzz; - feed: string | FeedParams; - decode?: DecodeChapter; - encode?: EncodeChapter; - signParams?: any; -} -export declare class Timeline = BaseBzz> { - protected bzz: Bzz; - protected decode: DecodeChapter; - protected encode: EncodeChapter; - protected feed: string | FeedParams; - protected signParams: any; - constructor(config: TimelineConfig); - getChapter(id: string, options?: FetchOptions): Promise>; - postChapter(chapter: PartialChapter, options?: UploadOptions): Promise; - getLatestChapterID(options?: FetchOptions): Promise; - getLatestChapter(options?: FetchOptions): Promise | null>; - setLatestChapterID(chapterID: string, options?: FetchOptions): Promise; - setLatestChapter(chapter: PartialChapter, options?: UploadOptions): Promise; - addChapter(chapter: PartialChapter, options?: UploadOptions): Promise>; - createAddChapter(chapterDefaults?: Partial>, options?: UploadOptions): (partialChapter: Partial>) => Promise>; - createIterator(initialID?: string, options?: FetchOptions): AsyncIterator>; - createLoader(newestID: string, // inclusive - oldestID: string, // exclusive - options?: FetchOptions): Observable>; - getChapters(newestID: string, // inclusive - oldestID: string, // exclusive - options?: FetchOptions): Promise>>; - pollLatestChapter(options: PollOptions): Observable>; - live(options: LiveOptions): Observable>>; -} -export declare function createTimeline(config: TimelineConfig): Timeline; diff --git a/tsconfig.build.json b/tsconfig.build.json index 05a87f3..b2ab1d7 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -2,7 +2,7 @@ "compilerOptions": { "allowSyntheticDefaultImports": true, "declaration": true, - "lib": ["es2015"], + "lib": ["es2015", "dom"], "moduleResolution": "node", "strict": true, "target": "esnext" diff --git a/yarn.lock b/yarn.lock index 8bf2e4d..d40af3d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -764,7 +764,7 @@ dependencies: regenerator-runtime "^0.13.2" -"@babel/runtime@^7.5.5": +"@babel/runtime@^7.3.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.5": version "7.5.5" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.5.5.tgz#74fba56d35efbeca444091c7850ccd494fd2f132" integrity sha512-28QvEGyQyNkB0/m2B4FU7IEZGK2NUrcMtT6BZEFALTguLk+AUT6ofsHtPk5QyjAdUkpMJ+/Em+quwz4HOt30AQ== @@ -836,6 +836,32 @@ exec-sh "^0.3.2" minimist "^1.2.0" +"@erebos/api-bzz-base@^0.8.1": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@erebos/api-bzz-base/-/api-bzz-base-0.8.1.tgz#da3404fe357bce47aa1e05e4997aa96801443f99" + integrity sha512-hz14pwLy2CklbeuRSChH28COQxlLSMTjJMzuhkvPqNmLo9sSYjgAlPiAM2xqG5fjHaRo4WPACz5gfJs+r7+UyA== + dependencies: + "@babel/runtime" "^7.4.5" + "@erebos/hex" "^0.7.0" + "@erebos/keccak256" "^0.7.0" + rxjs "^6.5.2" + +"@erebos/hex@^0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@erebos/hex/-/hex-0.7.0.tgz#e40341b81d55cc976279cd90cac9ab766ede839c" + integrity sha512-4Qa2U4Y2XsjfTiQmH+MXsoZnxVBx04v/RZVD9ErrrLbX8HN+WAWQv6Z001QzWD+z/Y5aHPmHO/KJwB4cvSl/Dg== + dependencies: + "@babel/runtime" "^7.3.4" + +"@erebos/keccak256@^0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@erebos/keccak256/-/keccak256-0.7.0.tgz#80bc51c54ee0a6270f5928bdd1274d7e8bffc739" + integrity sha512-MLVl/AhSN6hOUxopYC1H/rK/fU/B+fDMqWqdqmHTuANs0pLcG7HXHVEqCiOQz963lMb/9S0eDS21t8Z46AJq8A== + dependencies: + "@babel/runtime" "^7.3.4" + "@erebos/hex" "^0.7.0" + js-sha3 "^0.8.0" + "@evocateur/libnpmaccess@^3.1.2": version "3.1.2" resolved "https://registry.yarnpkg.com/@evocateur/libnpmaccess/-/libnpmaccess-3.1.2.tgz#ecf7f6ce6b004e9f942b098d92200be4a4b1c845" @@ -4427,6 +4453,11 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08" integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg== +flow-bin@^0.101.0: + version "0.101.1" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.101.1.tgz#6175eb4a2e510949decf4750cb573f83ddf303f2" + integrity sha512-+HVuoMgWNK8vIM662Rt6OzlJNTnC+BWChdeYjkPpl70TKiRMt//j6/5x6PH8HVZ/vytOfPZw2b/JrlBHdlGCkQ== + flush-write-stream@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8" @@ -4910,6 +4941,11 @@ hash.js@^1.0.0, hash.js@^1.0.3: inherits "^2.0.3" minimalistic-assert "^1.0.1" +hasurl@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/hasurl/-/hasurl-1.0.0.tgz#e4c619097ae1e8fc906bee904ce47e94f5e1ea37" + integrity sha512-43ypUd3DbwyCT01UYpA99AEZxZ4aKtRxWGBHEIbjcOsUghd9YUON0C+JF6isNjaiwC/UF5neaUudy6JS9jZPZQ== + hmac-drbg@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" @@ -9007,6 +9043,14 @@ unique-slug@^2.0.0: dependencies: imurmurhash "^0.1.4" +universal-url@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/universal-url/-/universal-url-2.0.0.tgz#35e7fc2c3374804905cee67ea289ed3a47669809" + integrity sha512-3DLtXdm/G1LQMCnPj+Aw7uDoleQttNHp2g5FnNQKR6cP6taNWS1b/Ehjjx4PVyvejKi3TJyu8iBraKM4q3JQPg== + dependencies: + hasurl "^1.0.0" + whatwg-url "^7.0.0" + universal-user-agent@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-2.1.0.tgz#5abfbcc036a1ba490cb941f8fd68c46d3669e8e4" From 010f9af6d2ebbe68a0c40214be711491dd51104b Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Tue, 6 Aug 2019 10:29:08 +0200 Subject: [PATCH 06/11] fix dependencies --- packages/api-bzz-react-native/package.json | 1 + yarn.lock | 28 +--------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/packages/api-bzz-react-native/package.json b/packages/api-bzz-react-native/package.json index 2c8bbfb..b4d34b6 100644 --- a/packages/api-bzz-react-native/package.json +++ b/packages/api-bzz-react-native/package.json @@ -23,6 +23,7 @@ "prepublishOnly": "yarn build" }, "dependencies": { + "@babel/runtime": "^7.5.5", "@erebos/api-bzz-base": "^0.9.0", "universal-url": "^2.0.0" }, diff --git a/yarn.lock b/yarn.lock index d40af3d..8893d1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -764,7 +764,7 @@ dependencies: regenerator-runtime "^0.13.2" -"@babel/runtime@^7.3.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.5": +"@babel/runtime@^7.5.5": version "7.5.5" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.5.5.tgz#74fba56d35efbeca444091c7850ccd494fd2f132" integrity sha512-28QvEGyQyNkB0/m2B4FU7IEZGK2NUrcMtT6BZEFALTguLk+AUT6ofsHtPk5QyjAdUkpMJ+/Em+quwz4HOt30AQ== @@ -836,32 +836,6 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@erebos/api-bzz-base@^0.8.1": - version "0.8.1" - resolved "https://registry.yarnpkg.com/@erebos/api-bzz-base/-/api-bzz-base-0.8.1.tgz#da3404fe357bce47aa1e05e4997aa96801443f99" - integrity sha512-hz14pwLy2CklbeuRSChH28COQxlLSMTjJMzuhkvPqNmLo9sSYjgAlPiAM2xqG5fjHaRo4WPACz5gfJs+r7+UyA== - dependencies: - "@babel/runtime" "^7.4.5" - "@erebos/hex" "^0.7.0" - "@erebos/keccak256" "^0.7.0" - rxjs "^6.5.2" - -"@erebos/hex@^0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@erebos/hex/-/hex-0.7.0.tgz#e40341b81d55cc976279cd90cac9ab766ede839c" - integrity sha512-4Qa2U4Y2XsjfTiQmH+MXsoZnxVBx04v/RZVD9ErrrLbX8HN+WAWQv6Z001QzWD+z/Y5aHPmHO/KJwB4cvSl/Dg== - dependencies: - "@babel/runtime" "^7.3.4" - -"@erebos/keccak256@^0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@erebos/keccak256/-/keccak256-0.7.0.tgz#80bc51c54ee0a6270f5928bdd1274d7e8bffc739" - integrity sha512-MLVl/AhSN6hOUxopYC1H/rK/fU/B+fDMqWqdqmHTuANs0pLcG7HXHVEqCiOQz963lMb/9S0eDS21t8Z46AJq8A== - dependencies: - "@babel/runtime" "^7.3.4" - "@erebos/hex" "^0.7.0" - js-sha3 "^0.8.0" - "@evocateur/libnpmaccess@^3.1.2": version "3.1.2" resolved "https://registry.yarnpkg.com/@evocateur/libnpmaccess/-/libnpmaccess-3.1.2.tgz#ecf7f6ce6b004e9f942b098d92200be4a4b1c845" From 3a3afb786aa147d82318c1e58a6baabbb39f3105 Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Tue, 6 Aug 2019 14:36:37 +0200 Subject: [PATCH 07/11] fix linter errors --- packages/api-bzz-react-native/src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/api-bzz-react-native/src/index.ts b/packages/api-bzz-react-native/src/index.ts index 18fc80f..1344ccd 100644 --- a/packages/api-bzz-react-native/src/index.ts +++ b/packages/api-bzz-react-native/src/index.ts @@ -25,11 +25,11 @@ export class Bzz extends BaseBzz { Object.keys(directory).forEach(key => { form.append( key, - ({ + { uri: directory[key].data, type: directory[key].contentType, name: key, - } as any), + } as any, key, ) }) @@ -38,11 +38,11 @@ export class Bzz extends BaseBzz { if (file != null) { form.append( '', - ({ + { uri: directory[options.defaultPath].data, type: directory[options.defaultPath].contentType, name: options.defaultPath, - } as any), + } as any, '', ) } From 40bb8d15a8f558481b8cb9ce367f68f349f65957 Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Tue, 6 Aug 2019 21:29:52 +0200 Subject: [PATCH 08/11] add api-bzz-react-native to readme.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b7e68ce..2e9a807 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ npm install -g @erebos/cli | **Individual APIs** | [`@erebos/api-bzz-browser`](/packages/api-bzz-browser) | [![npm version](https://img.shields.io/npm/v/@erebos/api-bzz-browser.svg)](https://www.npmjs.com/package/@erebos/api-bzz-browser) | Browser-only Swarm (BZZ) APIs | [`@erebos/api-bzz-node`](/packages/api-bzz-node) | [![npm version](https://img.shields.io/npm/v/@erebos/api-bzz-node.svg)](https://www.npmjs.com/package/@erebos/api-bzz-node) | Node-only Swarm (BZZ) APIs +| [`@erebos/api-bzz-react-native`](/packages/api-bzz-react-native) | [![npm version](https://img.shields.io/npm/v/@erebos/api-bzz-react-native.svg)](https://www.npmjs.com/package/@erebos/api-bzz-node) | Experimental React Native Swarm (BZZ) APIs | [`@erebos/api-pss`](/packages/api-pss) | [![npm version](https://img.shields.io/npm/v/@erebos/api-pss.svg)](https://www.npmjs.com/package/@erebos/api-pss) | Postal Services over Swarm (PSS) APIs | [`@erebos/timeline`](/packages/timeline) | [![npm version](https://img.shields.io/npm/v/@erebos/timeline.svg)](https://www.npmjs.com/package/@erebos/timeline) | Feed-based Timeline APIs | **Utilities** From 0ada85f76d1977e019dcb1b6c6fc6e6c93382a7b Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Wed, 7 Aug 2019 14:14:25 +0200 Subject: [PATCH 09/11] fix devDependencies --- packages/api-bzz-react-native/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api-bzz-react-native/package.json b/packages/api-bzz-react-native/package.json index b4d34b6..d1ea567 100644 --- a/packages/api-bzz-react-native/package.json +++ b/packages/api-bzz-react-native/package.json @@ -28,6 +28,6 @@ "universal-url": "^2.0.0" }, "devDependencies": { - "flow-bin": "^0.101.0" + "typescript": "3.5.2" } } From d2a4491d91082ba8e0370874e3e97bc522e2824a Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Wed, 7 Aug 2019 14:37:29 +0200 Subject: [PATCH 10/11] re-add accidentally deleted typings --- packages/api-bzz-browser/types/index.d.ts | 7 +++ packages/timeline/types/index.d.ts | 69 +++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 packages/api-bzz-browser/types/index.d.ts create mode 100644 packages/timeline/types/index.d.ts diff --git a/packages/api-bzz-browser/types/index.d.ts b/packages/api-bzz-browser/types/index.d.ts new file mode 100644 index 0000000..2a0fc1f --- /dev/null +++ b/packages/api-bzz-browser/types/index.d.ts @@ -0,0 +1,7 @@ +import { BaseBzz, BzzConfig, DirectoryData, UploadOptions } from '@erebos/api-bzz-base'; +import { hexValue } from '@erebos/hex'; +export * from '@erebos/api-bzz-base'; +export declare class Bzz extends BaseBzz { + constructor(config: BzzConfig); + uploadDirectory(directory: DirectoryData, options?: UploadOptions): Promise; +} diff --git a/packages/timeline/types/index.d.ts b/packages/timeline/types/index.d.ts new file mode 100644 index 0000000..3b38e18 --- /dev/null +++ b/packages/timeline/types/index.d.ts @@ -0,0 +1,69 @@ +/// +import { BaseBzz, BaseResponse, FeedParams, FetchOptions, UploadOptions } from '@erebos/api-bzz-base'; +import { hexValue } from '@erebos/hex'; +import { Observable } from 'rxjs'; +export declare const PROTOCOL = "timeline"; +export declare const VERSION = "1.0.0"; +export declare const VERSION_RANGE = "^1.0.0"; +export interface PartialChapter { + protocol: string; + version: string; + timestamp: number; + author: string; + type: string; + content: T; + previous?: string | null; + references?: Array; + signature?: string; +} +export declare type Chapter = PartialChapter & { + id: string; +}; +export declare type DecodeChapter = (res: R) => Promise>; +export declare type EncodeChapter = (chapter: PartialChapter) => Promise; +export interface PollOptions extends FetchOptions { + interval: number; +} +export interface LiveOptions extends PollOptions { + previous?: string; + timestamp?: number; +} +export declare function createChapter(chapter: Partial>): PartialChapter; +export interface MaybeChapter extends Record { + protocol?: string; + version?: string; +} +export declare function validateChapter(chapter: T): T; +export interface TimelineConfig = BaseBzz> { + bzz: Bzz; + feed: string | FeedParams; + decode?: DecodeChapter; + encode?: EncodeChapter; + signParams?: any; +} +export declare class Timeline = BaseBzz> { + protected bzz: Bzz; + protected decode: DecodeChapter; + protected encode: EncodeChapter; + protected feed: string | FeedParams; + protected signParams: any; + constructor(config: TimelineConfig); + getChapter(id: string, options?: FetchOptions): Promise>; + postChapter(chapter: PartialChapter, options?: UploadOptions): Promise; + getLatestChapterID(options?: FetchOptions): Promise; + getLatestChapter(options?: FetchOptions): Promise | null>; + setLatestChapterID(chapterID: string, options?: FetchOptions): Promise; + setLatestChapter(chapter: PartialChapter, options?: UploadOptions): Promise; + addChapter(chapter: PartialChapter, options?: UploadOptions): Promise>; + createAddChapter(chapterDefaults?: Partial>, options?: UploadOptions): (partialChapter: Partial>) => Promise>; + createIterator(initialID?: string, options?: FetchOptions): AsyncIterator>; + createLoader(newestID: string, // inclusive + oldestID: string, // exclusive + options?: FetchOptions): Observable>; + getChapters(newestID: string, // inclusive + oldestID: string, // exclusive + options?: FetchOptions): Promise>>; + pollLatestChapter(options: PollOptions): Observable>; + live(options: LiveOptions): Observable>>; +} +export declare function createTimeline(config: TimelineConfig): Timeline; From 01606bd995827285bee8d15f1856cf5663f5b82c Mon Sep 17 00:00:00 2001 From: Mark Vujevits Date: Wed, 7 Aug 2019 14:39:38 +0200 Subject: [PATCH 11/11] remove flow from the lockfile --- yarn.lock | 5 ----- 1 file changed, 5 deletions(-) diff --git a/yarn.lock b/yarn.lock index 8893d1d..612d687 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4427,11 +4427,6 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08" integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg== -flow-bin@^0.101.0: - version "0.101.1" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.101.1.tgz#6175eb4a2e510949decf4750cb573f83ddf303f2" - integrity sha512-+HVuoMgWNK8vIM662Rt6OzlJNTnC+BWChdeYjkPpl70TKiRMt//j6/5x6PH8HVZ/vytOfPZw2b/JrlBHdlGCkQ== - flush-write-stream@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8"