author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
19,400
15.07.2017 19:03:55
-32,400
4d722fb25026c9706d5e6aab0ef7a918f4f16ff8
fix(almin): Move `Context.on*` handler to `Context.events.on*` `Context.on*` is deprecated and prepare migration scripts This deprecated handler will be removed next release
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/Context.ts", "new_path": "packages/almin/src/Context.ts", "diff": "@@ -22,8 +22,6 @@ import { TransactionContext } from \"./UnitOfWork/TransactionContext\";\nimport { createSingleStoreGroup } from \"./UILayer/SingleStoreGroup\";\nimport { StoreGroupLike } from \"./UILayer/StoreGroupLike\";\nimport { LifeCycleEventHub } from \"./LifeCycleEventHub\";\n-import { TransactionBeganPayload } from \"./payload/TransactionBeganPayload\";\n-import { TransactionEndedPayload } from \"./payload/TransactionEndedPayload\";\nimport { StoreChangedPayload } from \"./payload/StoreChangedPayload\";\nexport interface ContextArgs<T> {\n@@ -328,23 +326,11 @@ Please enable strict mode via \\`new Context({ dispatcher, store, options: { stri\n);\n}\n- /**\n- * Register `handler` function that is called when begin `Context.transaction`.\n- */\n- onBeginTransaction(handler: (payload: TransactionBeganPayload, meta: DispatcherPayloadMeta) => void) {\n- return this.lifeCycleEventHub.onBeginTransaction(handler);\n- }\n-\n- /**\n- * Register `handler` function that is called when `Context.transaction` is ended.\n- */\n- onEndTransaction(handler: (payload: TransactionEndedPayload, meta: DispatcherPayloadMeta) => void) {\n- return this.lifeCycleEventHub.onEndTransaction(handler);\n- }\n-\n/**\n* Register `handler` function to Context.\n* `handler` is called when each useCases will execute.\n+ * @deprecated\n+ * Use `context.events.onWillExecuteEachUseCase` insteadof it.\n*/\nonWillExecuteEachUseCase(handler: (payload: WillExecutedPayload, meta: DispatcherPayloadMeta) => void): () => void {\nreturn this.lifeCycleEventHub.onWillExecuteEachUseCase(handler);\n@@ -369,6 +355,9 @@ Please enable strict mode via \\`new Context({ dispatcher, store, options: { stri\n*\n* context.useCase(dispatchUseCase).execute();\n* ```\n+ *\n+ * @deprecated\n+ * Use `context.events.onDispatch` insteadof it.\n*/\nonDispatch(handler: (payload: DispatchedPayload, meta: DispatcherPayloadMeta) => void): () => void {\nreturn this.lifeCycleEventHub.onDispatch(handler);\n@@ -376,6 +365,8 @@ Please enable strict mode via \\`new Context({ dispatcher, store, options: { stri\n/**\n* `handler` is called when each useCases are executed.\n+ * @deprecated\n+ * Use `context.events.onDidExecuteEachUseCase` insteadof it.\n*/\nonDidExecuteEachUseCase(handler: (payload: DidExecutedPayload, meta: DispatcherPayloadMeta) => void): () => void {\nreturn this.lifeCycleEventHub.onDidExecuteEachUseCase(handler);\n@@ -384,6 +375,8 @@ Please enable strict mode via \\`new Context({ dispatcher, store, options: { stri\n/**\n* `handler` is called when each useCases are completed.\n* This `handler` is always called asynchronously.\n+ * @deprecated\n+ * Use `context.events.onCompleteEachUseCase` insteadof it.\n*/\nonCompleteEachUseCase(handler: (payload: CompletedPayload, meta: DispatcherPayloadMeta) => void): () => void {\nreturn this.lifeCycleEventHub.onCompleteEachUseCase(handler);\n@@ -397,6 +390,8 @@ Please enable strict mode via \\`new Context({ dispatcher, store, options: { stri\n* - Throw exception in a UseCase\n* - Return rejected promise in a UseCase\n* - Call `UseCase#throwError(error)`\n+ * @deprecated\n+ * Use `context.events.onErrorDispatch` insteadof it.\n*/\nonErrorDispatch(handler: (payload: ErrorPayload, meta: DispatcherPayloadMeta) => void): () => void {\nreturn this.lifeCycleEventHub.onErrorDispatch(handler);\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/LifeCycleEventHub.ts", "new_path": "packages/almin/src/LifeCycleEventHub.ts", "diff": "@@ -42,6 +42,9 @@ export class LifeCycleEventHub {\nreturn releaseHandler;\n}\n+ /**\n+ * Register `handler` function that is called when begin `Context.transaction`.\n+ */\nonBeginTransaction(handler: (payload: TransactionBeganPayload, meta: DispatcherPayloadMeta) => void) {\nconst releaseHandler = this.dispatcher.onDispatch(function onBeginTransaction(payload, meta) {\nif (isTransactionBeganPayload(payload)) {\n@@ -52,6 +55,9 @@ export class LifeCycleEventHub {\nreturn releaseHandler;\n}\n+ /**\n+ * Register `handler` function that is called when `Context.transaction` is ended.\n+ */\nonEndTransaction(handler: (payload: TransactionEndedPayload, meta: DispatcherPayloadMeta) => void) {\nconst releaseHandler = this.dispatcher.onDispatch(function onEndTransaction(payload, meta) {\nif (isTransactionEndedPayload(payload)) {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/Context-test.js", "new_path": "packages/almin/test/Context-test.js", "diff": "@@ -337,22 +337,22 @@ describe(\"Context\", function() {\nconst doneNotCall = () => {\nthrow new Error(\"It should not called\");\n};\n- context.onWillExecuteEachUseCase(() => {\n+ context.events.onWillExecuteEachUseCase(() => {\ndoneNotCall();\n});\n- context.onDidExecuteEachUseCase(() => {\n+ context.events.onDidExecuteEachUseCase(() => {\ndoneNotCall();\n});\n- context.onDispatch(() => {\n+ context.events.onDispatch(() => {\ndoneNotCall();\n});\ncontext.onChange(() => {\ndoneNotCall();\n});\n- context.onErrorDispatch(() => {\n+ context.events.onErrorDispatch(() => {\ndoneNotCall();\n});\n- context.onCompleteEachUseCase(() => {\n+ context.events.onCompleteEachUseCase(() => {\ndoneNotCall();\n});\n// when\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/Context-transaction-test.js", "new_path": "packages/almin/test/Context-transaction-test.js", "diff": "@@ -143,7 +143,7 @@ describe(\"Context#transaction\", () => {\n});\nconst beginTransactions = [];\nconst endTransaction = [];\n- context.onBeginTransaction((payload, meta) => {\n+ context.events.onBeginTransaction((payload, meta) => {\nbeginTransactions.push(payload);\nassert.strictEqual(meta.isTrusted, true, \"meta.isTrusted should be true\");\nassert.strictEqual(meta.useCase, null, \"meta.useCase should be null\");\n@@ -153,7 +153,7 @@ describe(\"Context#transaction\", () => {\nassert.strictEqual(typeof meta.transaction, \"object\", \"transaction object\");\nassert.strictEqual(typeof meta.transaction.name, \"string\", \"transaction object\");\n});\n- context.onEndTransaction((payload, meta) => {\n+ context.events.onEndTransaction((payload, meta) => {\nendTransaction.push(payload);\nassert.strictEqual(meta.isTrusted, true, \"meta.isTrusted should be true\");\nassert.strictEqual(meta.useCase, null, \"meta.useCase should be null\");\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/DispatcherPayloadMeta-test.js", "new_path": "packages/almin/test/DispatcherPayloadMeta-test.js", "diff": "@@ -21,7 +21,7 @@ describe(\"DispatcherPayloadMeta\", () => {\n});\nconst useCase = new NoDispatchUseCase();\nlet actualMeta = null;\n- context.onWillExecuteEachUseCase((payload, meta) => {\n+ context.events.onWillExecuteEachUseCase((payload, meta) => {\nactualMeta = meta;\n});\nreturn context.useCase(useCase).execute().then(() => {\n@@ -42,7 +42,7 @@ describe(\"DispatcherPayloadMeta\", () => {\n});\nconst useCase = new DispatchUseCase();\nlet actualMeta = null;\n- context.onDispatch((payload, meta) => {\n+ context.events.onDispatch((payload, meta) => {\nactualMeta = meta;\n});\nreturn context.useCase(useCase).execute({ type: \"test\" }).then(() => {\n@@ -63,7 +63,7 @@ describe(\"DispatcherPayloadMeta\", () => {\n});\nconst useCase = new NoDispatchUseCase();\nlet actualMeta = null;\n- context.onDidExecuteEachUseCase((payload, meta) => {\n+ context.events.onDidExecuteEachUseCase((payload, meta) => {\nactualMeta = meta;\n});\nreturn context.useCase(useCase).execute().then(() => {\n@@ -83,7 +83,7 @@ describe(\"DispatcherPayloadMeta\", () => {\n});\nconst useCase = new ReturnPromiseUseCase();\nlet actualMeta = null;\n- context.onDidExecuteEachUseCase((payload, meta) => {\n+ context.events.onDidExecuteEachUseCase((payload, meta) => {\nactualMeta = meta;\n});\nreturn context.useCase(useCase).execute().then(() => {\n@@ -105,7 +105,7 @@ describe(\"DispatcherPayloadMeta\", () => {\n});\nconst useCase = new NoDispatchUseCase();\nlet actualMeta = null;\n- context.onCompleteEachUseCase((payload, meta) => {\n+ context.events.onCompleteEachUseCase((payload, meta) => {\nactualMeta = meta;\n});\nreturn context.useCase(useCase).execute().then(() => {\n@@ -127,7 +127,7 @@ describe(\"DispatcherPayloadMeta\", () => {\n});\nconst useCase = new ErrorUseCase();\nlet actualMeta = null;\n- context.onErrorDispatch((payload, meta) => {\n+ context.events.onErrorDispatch((payload, meta) => {\nactualMeta = meta;\n});\nreturn context.useCase(useCase).execute().catch(() => {\n@@ -154,10 +154,10 @@ describe(\"DispatcherPayloadMeta\", () => {\nconst didMeta = [];\nconst completeMeta = [];\nlet childDispatchMeta = null;\n- context.onWillExecuteEachUseCase((payload, meta) => willMeta.push(meta));\n- context.onDidExecuteEachUseCase((payload, meta) => didMeta.push(meta));\n- context.onCompleteEachUseCase((payload, meta) => completeMeta.push(meta));\n- context.onDispatch((payload, meta) => (childDispatchMeta = meta));\n+ context.events.onWillExecuteEachUseCase((payload, meta) => willMeta.push(meta));\n+ context.events.onDidExecuteEachUseCase((payload, meta) => didMeta.push(meta));\n+ context.events.onCompleteEachUseCase((payload, meta) => completeMeta.push(meta));\n+ context.events.onDispatch((payload, meta) => (childDispatchMeta = meta));\nreturn context.useCase(parentUseCase).execute().then(() => {\nconst [parentWillMeta, childWillMeta] = willMeta;\nconst [childDidMeta, parentDidMeta] = didMeta;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/StoreGroup-edge-case-test.js", "new_path": "packages/almin/test/StoreGroup-edge-case-test.js", "diff": "@@ -76,10 +76,10 @@ describe(\"StoreGroup edge case\", function() {\ncontext.onChange(() => {\ncallStack.push(\"change\");\n});\n- context.onDidExecuteEachUseCase(() => {\n+ context.events.onDidExecuteEachUseCase(() => {\ncallStack.push(\"did\");\n});\n- context.onCompleteEachUseCase(() => {\n+ context.events.onCompleteEachUseCase(() => {\ncallStack.push(\"complete\");\n});\nreturn context.useCase(new ReturnPromiseUseCase()).execute().then(() => {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/StoreGroup-test.js", "new_path": "packages/almin/test/StoreGroup-test.js", "diff": "@@ -282,7 +282,7 @@ describe(\"StoreGroup\", function() {\ndispatcher: new Dispatcher(),\nstore: storeGroup\n});\n- context.onDispatch(payload => {\n+ context.events.onDispatch(payload => {\ndispatchedPayload = payload;\n});\n// when\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/UseCase-test.js", "new_path": "packages/almin/test/UseCase-test.js", "diff": "@@ -94,10 +94,10 @@ describe(\"UseCase\", function() {\nconst expectedType = expectedCallStackOfAUseCase.shift();\nassert.equal(type, expectedType);\n});\n- context.onWillExecuteEachUseCase((payload, meta) => {\n+ context.events.onWillExecuteEachUseCase((payload, meta) => {\ncallStack.push(`${meta.useCase.name}:will`);\n});\n- context.onDidExecuteEachUseCase((payload, meta) => {\n+ context.events.onDidExecuteEachUseCase((payload, meta) => {\ncallStack.push(`${meta.useCase.name}:did`);\n});\n// when\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/UseCaseContext-test.js", "new_path": "packages/almin/test/UseCaseContext-test.js", "diff": "@@ -22,7 +22,7 @@ describe(\"UseCaseContext\", () => {\ndispatcher,\nstore: createStore({ name: \"test\" })\n});\n- context.onDispatch(payload => {\n+ context.events.onDispatch(payload => {\ndispatched.push(payload);\n});\nreturn context.useCase(new ParentUseCase()).execute().then(() => {\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): Move `Context.on*` handler to `Context.events.on*` `Context.on*` is deprecated and prepare migration scripts https://github.com/almin/migration-tools/pull/1 This deprecated handler will be removed next release
19,400
15.07.2017 19:23:32
-32,400
2a9d78fbc3d6a7a24ef768c6771460be9ed990f7
docs(almin): add events documents
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/Context.ts", "new_path": "packages/almin/src/Context.ts", "diff": "@@ -130,11 +130,7 @@ export class Context<T> {\n* Return almin life cycle events hub.\n* You can observe life cycle events on almin.\n*\n- * ## Notes\n- *\n- * If you want to know the change of registered store, please use `context.onChange`.\n- * `context.onChange` is optimized for updating View.\n- * By contrast, `context.events.*` is not optimized data. it is useful for logging.\n+ * See LifeCycleEventHub\n*/\nget events() {\nreturn this.lifeCycleEventHub;\n@@ -159,19 +155,30 @@ export class Context<T> {\n}\n/**\n- * If anyone store that is passed to constructor is changed, then call `onChange`.\n- * `onChange` arguments is an array of `Store` instances.\n+ * If anyone store that is passed to constructor is changed, `handler` is called.\n+ * `onChange` arguments is an array of `Store` instances that are changed.\n*\n* It returns unSubscribe function.\n* If you want to release handler, the returned function.\n*\n+ * It is useful for updating view in the `handler`.\n+ *\n* ### Example\n*\n* ```js\n* const unSubscribe = context.onChange(changingStores => {\n* console.log(changingStores); // Array<Store>\n+ * // Update view\n* });\n* ```\n+ *\n+ *\n+ * ## Notes\n+ *\n+ * If you want to know the change of registered store, please use `context.onChange`.\n+ * `context.onChange` is optimized for updating View.\n+ * By contrast, `context.events.*` is not optimized data. it is useful for logging.\n+ *\n*/\nonChange(handler: (changingStores: Array<StoreLike<any>>) => void): () => void {\nreturn this.storeGroup.onChange(handler);\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/LifeCycleEventHub.ts", "new_path": "packages/almin/src/LifeCycleEventHub.ts", "diff": "@@ -16,9 +16,12 @@ export interface LifeCycleEventHubArgs {\n}\n/**\n- * Wrapper of dispatcher that can observe all almin life-cycle events\n+ * LifeCycleEventHub provide the way for observing almin life-cycle events.\n*\n- * @see https://almin.js.org/docs/tips/usecase-lifecycle.html\n+ * ## See also\n+ *\n+ * - https://almin.js.org/docs/tips/usecase-lifecycle.html\n+ * - almin-logger implementation\n*/\nexport class LifeCycleEventHub {\nprivate releaseHandlers: (() => void)[];\n@@ -31,7 +34,33 @@ export class LifeCycleEventHub {\nthis.releaseHandlers = [];\n}\n- // handlers\n+ /**\n+ * Register `handler` function that is called when Store is changed.\n+ *\n+ * ## Notes\n+ *\n+ * This event should not use for updating view.\n+ *\n+ * ```js\n+ * // BAD\n+ * context.events.onChangeStore(() => {\n+ * updateView();\n+ * })\n+ * ```\n+ *\n+ * You should use `context.onChange` for updating view.\n+ *\n+ * ```\n+ * // GOOD\n+ * context.onChange(() => {\n+ * updateView();\n+ * })\n+ * ```\n+ *\n+ * Because, `context.onChange` is optimized for updating view.\n+ * By contrast, `context.events.onChangeStore` is not optimized data.\n+ * It is useful data for logging.\n+ */\nonChangeStore(handler: (payload: StoreChangedPayload, meta: DispatcherPayloadMeta) => void) {\nconst releaseHandler = this.dispatcher.onDispatch(function onChangeStore(payload, meta) {\nif (isStoreChangedPayload(payload)) {\n@@ -44,6 +73,8 @@ export class LifeCycleEventHub {\n/**\n* Register `handler` function that is called when begin `Context.transaction`.\n+ *\n+ * This `handler` will be not called when `Context.useCase` is executed.\n*/\nonBeginTransaction(handler: (payload: TransactionBeganPayload, meta: DispatcherPayloadMeta) => void) {\nconst releaseHandler = this.dispatcher.onDispatch(function onBeginTransaction(payload, meta) {\n@@ -57,6 +88,8 @@ export class LifeCycleEventHub {\n/**\n* Register `handler` function that is called when `Context.transaction` is ended.\n+ *\n+ * This `handler` will be not called when `Context.useCase` is executed.\n*/\nonEndTransaction(handler: (payload: TransactionEndedPayload, meta: DispatcherPayloadMeta) => void) {\nconst releaseHandler = this.dispatcher.onDispatch(function onEndTransaction(payload, meta) {\n" } ]
TypeScript
MIT License
almin/almin
docs(almin): add events documents
19,400
15.07.2017 22:00:08
-32,400
9bd11ef979fd433b8c08eda3da733550d4f1933b
docs(introduction): Update Unit of Work
[ { "change_type": "MODIFY", "old_path": "docs/introduction/principle.md", "new_path": "docs/introduction/principle.md", "diff": "@@ -14,4 +14,4 @@ Following figure describe it:\n[![unit of work](../resources/unit-of-work.png)][unit-of-work]\n-[unit-of-work]: http://www.nomnoml.com/#view/%23padding%3A%2010%0A%5BLifeCycle%7C%0A%09%5BUseCase%20Executor%20A%7C%0A%20%20%20%20%09%5B%3Cusecase%3EChild%20UseCase%5D%0A%20%20%20%20%5D%20--%3E%20%5BUseCase%20Executor%20B%5D%0A%09%5BUseCase%20Executor%20B%7C%0A%20%20%20%20%09%5B%3Cusecase%3EUseCase%5D%0A%20%20%20%20%5D%20--%3E%20%5BDispatcher%5D%0A%20%20%20%20%2F%2F%20%5BDispatcher%5D%20--%3E%20%5BStoreGroup%5D%0A%20%20%20%20%5BStoreGroup%5D%0A%20%20%20%20%2F%2F%20unit%20of%20work%0A%20%20%20%20%5BDispatcher%5D%20Payload--%3E%20%5BUnit%20of%20work%5D%0A%20%20%20%20%5BUnit%20of%20work%7C%0A%20%20%20%20%09%5BDispatched%20Payload%5D%0A%20%20%20%20%20%20%20%20%5BSystem%20Payload%5D%0A%20%20%20%20%5D%20-%3E%20%5BStoreGroup%5D%0A%20%20%20%20%2F%2F%20to%20view%0A%20%20%20%20%5BStoreGroup%7C%20%0A%20%20%20%20%09%5BStore%5D%0A%20%20%20%20%20%20%20%20%5B%3Cnote%3Eif%20any%20store%20is%20change%2C%20it%20emit%20changed%5D%0A%20%20%20%20%5D%0A%20%20%20%20%0A%20%20%20%20%5BStoreGroup%5D%20changed%20--%3E%20%5BView%5D%0A%5D\n+[unit-of-work]: http://www.nomnoml.com/#view/%23padding%3A%2010%0A%0A%5BUseCase%7C%0A%20%20%20%20%5BUseCase%20Executor%20A%7C%0A%20%20%20%20%20%20%20%20%5B%3Cusecase%3EChild%20UseCase%5D%0A%20%20%20%20%5D%20--%3E%20%5BUseCase%20Executor%20B%5D%0A%20%20%20%20%5BUseCase%20Executor%20B%7C%0A%20%20%20%20%20%20%20%20%5B%3Cusecase%3EUseCase%5D%0A%20%20%20%20%5D%0A%5D%0A%5BUnit%20of%20Work%7C%0A%20%20%20%20%5BCommitments%7C%0A%20%20%20%20%20%20%20%20%5BDispatched%20Payload%5D%0A%20%20%20%20%20%20%20%20%5BSystem%20Payload%5D%0A%20%20%20%20%5D%0A%5D%0A%5BStoreGroup%7C%0A%20%20%20%20%5BStore%5D%0A%20%20%20%20%5B%3Cnote%3Eif%20any%20store%20is%20change%2C%20it%20emit%20changed%5D%0A%5D%0A%5BUseCase%5D%20payload%20--%3E%20%5BLifeCycleEventHub%7C%0A%09%5BDispatcher%5D%0A%5D%0A%5BUseCase%5D%20payload%20--%3E%20%5B%3Creadonly%3EUnit%20of%20Work%5D%0A%5BUnit%20of%20Work%5D%20%3Ctransaction%20event%3E%20--%3E%20%5BLifeCycleEventHub%5D%0A%5BUnit%20of%20Work%5D%20Commitment%20--%3E%20%5BStoreGroup%5D%20%0A%5BStoreGroup%5D%20changes%20--%3E%20%5BLifeCycleEventHub%5D%0A%5BLifeCycleEventHub%5D%20%3C-%20%5BContext%5D%0A\n" }, { "change_type": "MODIFY", "old_path": "docs/resources/unit-of-work.png", "new_path": "docs/resources/unit-of-work.png", "diff": "Binary files a/docs/resources/unit-of-work.png and b/docs/resources/unit-of-work.png differ\n" } ]
TypeScript
MIT License
almin/almin
docs(introduction): Update Unit of Work
19,400
15.07.2017 22:34:31
-32,400
111101a0e7209e66a902a94a36e5d8d27bab5e7b
docs(almin): update JSDoc
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/Context.ts", "new_path": "packages/almin/src/Context.ts", "diff": "@@ -24,6 +24,9 @@ import { StoreGroupLike } from \"./UILayer/StoreGroupLike\";\nimport { LifeCycleEventHub } from \"./LifeCycleEventHub\";\nimport { StoreChangedPayload } from \"./payload/StoreChangedPayload\";\n+/**\n+ * Context arguments\n+ */\nexport interface ContextArgs<T> {\ndispatcher: Dispatcher;\nstore: StoreLike<T>;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/DispatcherPayloadMeta.ts", "new_path": "packages/almin/src/DispatcherPayloadMeta.ts", "diff": "@@ -5,6 +5,9 @@ import { Dispatcher } from \"./Dispatcher\";\nimport { UseCase } from \"./UseCase\";\nimport { UseCaseLike } from \"./UseCaseLike\";\n+/**\n+ * Transaction data\n+ */\nexport interface Transaction {\n// Transaction name\nreadonly name: string;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UILayer/StoreGroup.ts", "new_path": "packages/almin/src/UILayer/StoreGroup.ts", "diff": "@@ -197,14 +197,10 @@ export class StoreGroup<T> extends Dispatcher implements StoreGroupLike {\n/**\n* If exist working UseCase, return true\n*/\n- protected get existWorkingUseCase() {\n+ private get existWorkingUseCase() {\nreturn this._workingUseCaseMap.size > 0;\n}\n- protected get isInitializedWithStateNameMap() {\n- return this._storeStateMap.size > 0;\n- }\n-\n/**\n* Return the state object that merge each stores's state\n*/\n" }, { "change_type": "MODIFY", "old_path": "tools/update-api-reference.sh", "new_path": "tools/update-api-reference.sh", "diff": "#!/bin/bash\ndeclare projectDir=$(git rev-parse --show-toplevel)\n-declare srcDir=\"${projectDir}/packages/almin/lib\"\n+declare alminDir=\"${projectDir}/packages/almin\"\n+declare srcDir=\"${projectDir}/packages/almin/lib/src\"\ndeclare docDir=\"${projectDir}/docs\"\n# add build result\nfunction addDoc(){\n@@ -10,9 +11,12 @@ function addDoc(){\nmv ${projectDir}/__obj/docs/**${fileName}*.html ${projectDir}/docs/api/${fileName}md\necho \"Create: ${docDir}/api/${fileName}md\"\n}\n+cd \"${alminDir}\"\nnpm run build\n+cd \"${projectDir}\"\n# update\naddDoc \"${srcDir}/Context.d.ts\"\n+addDoc \"${srcDir}/LifeCycleEventHub.d.ts\"\naddDoc \"${srcDir}/Dispatcher.d.ts\"\naddDoc \"${srcDir}/DispatcherPayloadMeta.d.ts\"\naddDoc \"${srcDir}/Store.d.ts\"\n" } ]
TypeScript
MIT License
almin/almin
docs(almin): update JSDoc
19,400
16.07.2017 10:06:44
-32,400
ff7ee706782499dd9b5dc8e36edda92515f24ee6
chore(almin): remove unused log
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/UILayer/StoreGroup.ts", "new_path": "packages/almin/src/UILayer/StoreGroup.ts", "diff": "@@ -419,7 +419,6 @@ But, ${store.name}#getState() was called.`\nconst prevState = this._stateCacheMap.get(store);\nconst nextState = store.getState();\n// mark `store` as `emitChange`ed store in a UseCase life-cycle\n- console.log(\"mark\", prevState, nextState);\nthis.storeGroupEmitChangeChecker.mark(store, prevState, nextState);\nif (this.isStrictMode) {\n// warning if this store is not allowed update at the time\n" } ]
TypeScript
MIT License
almin/almin
chore(almin): remove unused log
19,400
16.07.2017 12:21:40
-32,400
f00c4af79ed3db22bd6c0685f7d6e4237b9af460
chore(almin): improve return value warning
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/Context.ts", "new_path": "packages/almin/src/Context.ts", "diff": "@@ -337,7 +337,8 @@ Please enable strict mode via \\`new Context({ dispatcher, store, options: { stri\n// unitOfWork automatically close on transactionContext exited\n// by design.\nconst promise = transactionHandler(context);\n- if (!promise) {\n+ const isResultPromise = typeof promise === \"object\" && promise !== null && typeof promise.then == \"function\";\n+ if (!isResultPromise) {\nthrow new Error(`transaction context should return promise.\nTransaction should be exited after all useCases have been completed.\n" } ]
TypeScript
MIT License
almin/almin
chore(almin): improve return value warning
19,400
16.07.2017 17:44:24
-32,400
81e58e61c8063174845617f8c2f3becf68800f4b
fix(almin): move to DevDeps
[ { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"aluminium\"\n],\n\"devDependencies\": {\n+ \"@types/mocha\": \"^2.2.41\",\n\"@types/node\": \"^8.0.12\",\n\"cpx\": \"^1.5.0\",\n\"cross-env\": \"^5.0.1\",\n\"zuul\": \"^3.10.1\"\n},\n\"dependencies\": {\n- \"@types/mocha\": \"^2.2.41\",\n\"map-like\": \"^2.0.0\",\n\"shallow-equal-object\": \"^1.0.1\"\n}\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): move @types/mocha to DevDeps
19,400
20.07.2017 00:11:29
-32,400
7e340e21ca276362ed8ea90f6ace11a96267c178
chore(almin): add description for executor
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -235,15 +235,19 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\nUseCaseInstanceMap.delete(this.useCase);\n}\n+ /**\n+ * @private like\n+ */\nonRelease(handler: () => void): void {\nthis.on(\"USECASE_EXECUTOR_RELEASE\", handler);\n}\n/**\n* Similar to `execute(arguments)`, but it accept an executor function insteadof `arguments`\n- *\n* `executor(useCase => useCase.execute())` return a Promise object that resolved with undefined.\n*\n+ * This method is type-safe. It is useful for TypeScript.\n+ *\n* ## Example\n*\n* ```js\n@@ -268,6 +272,11 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n* .executor(useCase => useCase.execute(\"value\"))\n* ```\n*\n+ * ### I'm use TypeScript, Should I use `executor`?\n+ *\n+ * Yes. It is type-safe by default.\n+ * In other words, JavaScript User have not benefits.\n+ *\n* ### Why executor's result always undefined?\n*\n* UseCaseExecutor always resolve `undefined` data by design.\n" } ]
TypeScript
MIT License
almin/almin
chore(almin): add description for executor
19,400
20.07.2017 00:23:52
-32,400
0fc43620b0b496cc38fe443c79ac0ba728f4217e
test(almin): Convert Store-test to TypeScript
[ { "change_type": "RENAME", "old_path": "packages/almin/test/Store-test.js", "new_path": "packages/almin/test/Store-test.ts", "diff": "@@ -5,13 +5,18 @@ const assert = require(\"assert\");\nimport { ErrorPayload } from \"../src/payload/ErrorPayload\";\nimport { Store } from \"../src/Store\";\nimport { UseCase } from \"../src/UseCase\";\n-import { createStore } from \"./helper/create-store\";\n+import { createStore } from \"./helper/create-new-store\";\ndescribe(\"Store\", function() {\ndescribe(\"#name\", () => {\ndescribe(\"when define displayName\", () => {\nit(\"#name is same with displayName\", () => {\n- class MyStore extends Store {}\n+ class MyStore extends Store {\n+ getState() {\n+ return {};\n+ }\n+ }\n+\nconst expectedName = \"Expected Store\";\nMyStore.displayName = expectedName;\nconst store = new MyStore();\n@@ -19,21 +24,14 @@ describe(\"Store\", function() {\n});\n});\n});\n- describe(\"#getState\", () => {\n- describe(\"when has not implemented\", () => {\n- it(\"throw error\", () => {\n- class MyStore extends Store {}\n- const store = new MyStore();\n- assert.throws(() => {\n- store.getState();\n- }, /should be implemented/);\n- });\n- });\n- });\ndescribe(\"#setState\", () => {\ndescribe(\"when newState tha is not updatable state\", () => {\nit(\"should not update with newState\", () => {\n- class MyStore extends Store {\n+ type State = { key: string };\n+\n+ class MyStore extends Store<State> {\n+ state: State;\n+\nconstructor() {\nsuper();\nthis.state = {\n@@ -41,7 +39,7 @@ describe(\"Store\", function() {\n};\n}\n- shouldStateUpdate(prevState, nextState) {\n+ shouldStateUpdate(prevState: State, nextState: State) {\nreturn prevState.key !== nextState.key;\n}\n@@ -49,6 +47,7 @@ describe(\"Store\", function() {\nreturn this.state;\n}\n}\n+\nconst store = new MyStore();\nconst currentState = store.getState();\nstore.setState({\n@@ -60,7 +59,11 @@ describe(\"Store\", function() {\n});\ndescribe(\"when newState that is updatable state\", () => {\nit(\"should not update with newState\", () => {\n- class MyStore extends Store {\n+ type State = { key: string };\n+\n+ class MyStore extends Store<State> {\n+ state: State;\n+\nconstructor() {\nsuper();\nthis.state = {\n@@ -68,7 +71,7 @@ describe(\"Store\", function() {\n};\n}\n- shouldStateUpdate(prevState, nextState) {\n+ shouldStateUpdate(prevState: State, nextState: State) {\nreturn prevState.key !== nextState.key;\n}\n@@ -76,6 +79,7 @@ describe(\"Store\", function() {\nreturn this.state;\n}\n}\n+\nconst store = new MyStore();\nconst currentState = store.getState();\nstore.setState({\n@@ -125,11 +129,16 @@ describe(\"Store\", function() {\n});\nit(\"can override by sub class\", () => {\nclass CustomShouldStateUpdateStore extends Store {\n- shouldStateUpdate(prev, next) {\n+ shouldStateUpdate(_prev: any, _next: any) {\n// always true\nreturn true;\n}\n+\n+ getState() {\n+ return {};\n}\n+ }\n+\nconst store = new CustomShouldStateUpdateStore();\nassert(store.shouldStateUpdate({ a: 1 }, { a: 1 }));\n});\n@@ -150,13 +159,17 @@ describe(\"Store\", function() {\n// Related https://github.com/almin/almin/issues/190\ndescribe(\"when call Store#setState out of UseCase\", () => {\nit(\"should be called Store#onChange\", done => {\n- class AStore extends Store {\n+ type State = number;\n+\n+ class AStore extends Store<State> {\n+ state: State;\n+\nconstructor() {\nsuper();\nthis.state = 0;\n}\n- updateState(state) {\n+ updateState(state: State) {\nthis.setState(state);\n}\n@@ -164,10 +177,9 @@ describe(\"Store\", function() {\nreturn this.state;\n}\n}\n+\nconst aStore = new AStore();\n- const expectedState = {\n- expected: \"value\"\n- };\n+ const expectedState: State = 42;\naStore.onChange(() => {\nassert.ok(aStore.getState(), expectedState);\ndone();\n@@ -180,6 +192,7 @@ describe(\"Store\", function() {\ndescribe(\"when useCaseName is minified\", function() {\nit(\"can receive error from UseCase\", function(done) {\nconst store = createStore({ name: \"test\" });\n+\nclass TestUseCase extends UseCase {\nexecute() {\nconst domainError = new Error(\"domain error\");\n@@ -187,6 +200,7 @@ describe(\"Store\", function() {\nthis.throwError(domainError);\n}\n}\n+\nconst testUseCase = new TestUseCase();\ntestUseCase.name = \"minified\";\n// delegate\n@@ -205,6 +219,7 @@ describe(\"Store\", function() {\n});\nit(\"should receive error from UseCase\", function(done) {\nconst store = createStore({ name: \"test\" });\n+\nclass TestUseCase extends UseCase {\nexecute() {\nconst domainError = new Error(\"domain error\");\n@@ -212,6 +227,7 @@ describe(\"Store\", function() {\nthis.throwError(domainError);\n}\n}\n+\nconst testUseCase = new TestUseCase();\n// delegate\ntestUseCase.pipe(store);\n" } ]
TypeScript
MIT License
almin/almin
test(almin): Convert Store-test to TypeScript
19,400
20.07.2017 10:33:46
-32,400
6167b9d2d7f657f537401ed2d313644505b83b44
chore(almin): update comments
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -277,10 +277,10 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n* Yes. It is type-safe by default.\n* In other words, JavaScript User have not benefits.\n*\n- * ### Why executor's result always undefined?\n+ * ### Why executor's result always to be undefined?\n*\n* UseCaseExecutor always resolve `undefined` data by design.\n- * In CQRS, the command always have a void return type.\n+ * In CQRS, the command always have returned void type.\n*\n* - http://cqrs.nu/Faq\n*\n" } ]
TypeScript
MIT License
almin/almin
chore(almin): update comments
19,400
20.07.2017 10:39:50
-32,400
f54cf55460a67af550c1256f01e9b3ed9f00dbd1
test(almin-logger): add transaction tests
[ { "change_type": "MODIFY", "old_path": "packages/almin-logger/test/AsyncLogger-test.js", "new_path": "packages/almin-logger/test/AsyncLogger-test.js", "diff": "@@ -108,6 +108,45 @@ describe(\"AsyncLogger\", function() {\n});\n});\n});\n+ context(\"when transaction\", () => {\n+ it(\"should be nest of logGroup \", () => {\n+ const consoleMock = ConsoleMock.create();\n+ const logger = new AsyncLogger({\n+ console: consoleMock\n+ });\n+ const context = new Context({\n+ store: createStore(),\n+ dispatcher: new Dispatcher(),\n+ options: {\n+ strict: true\n+ }\n+ });\n+ logger.startLogging(context);\n+\n+ const results = [];\n+ logger.on(AlminLogger.Events.output, function(logGroup) {\n+ results.push(logGroup);\n+ });\n+ return context\n+ .transaction(\"transaction\", transactionContext => {\n+ return transactionContext.useCase(new NoDispatchUseCase()).execute().then(() => {\n+ transactionContext.commit();\n+ });\n+ })\n+ .then(() => {\n+ assert(results.length === 1);\n+ const [logGroup] = results;\n+ assert(logGroup.title === \"transaction\");\n+ assert(logGroup.children.length === 1);\n+ const [noDispatchUseCaseLogGroup] = logGroup.children;\n+ assert(noDispatchUseCaseLogGroup.children.length === 3);\n+ const [will, did, complete] = noDispatchUseCaseLogGroup.children;\n+ assert(will.payload instanceof WillExecutedPayload);\n+ assert(did.payload instanceof DidExecutedPayload);\n+ assert(complete.payload instanceof CompletedPayload);\n+ });\n+ });\n+ });\ncontext(\"when nest useCase\", () => {\nit(\"should nest of logGroup \", () => {\nconst consoleMock = ConsoleMock.create();\n" } ]
TypeScript
MIT License
almin/almin
test(almin-logger): add transaction tests
19,400
20.07.2017 23:39:09
-32,400
f7e654a0a070d21f5632c5598c54b0bf2264b27e
docs(api): add link to new api
[ { "change_type": "MODIFY", "old_path": "SUMMARY.md", "new_path": "SUMMARY.md", "diff": "- [UseCase is already released](docs/warnings/usecase-is-already-released.md)\n- API Reference\n- [Dispatcher](./docs/api/Dispatcher.md)\n+ - [DispatcherPayloadMeta](./docs/api/DispatcherPayloadMeta.md)\n- [Store](./docs/api/Store.md)\n- [Store Group](./docs/api/StoreGroup.md)\n- [UseCase](./docs/api/UseCase.md)\n- [Context](./docs/api/Context.md)\n- [UseCaseContext](./docs/api/UseCaseContext.md)\n+ - [UseCaseExecutor](./docs/api/UseCaseExecutor.md)\n+ - [LifeCycleEventHub](./docs/api/LifeCycleEventHub.md)\n- [GLOSSARY](./docs/GLOSSARY.md)\n" }, { "change_type": "MODIFY", "old_path": "docs/api/LifeCycleEventHub.md", "new_path": "docs/api/LifeCycleEventHub.md", "diff": "## Interface\n```typescript\n+export declare class LifeCycleEventHub {\nonChangeStore(handler: (payload: StoreChangedPayload, meta: DispatcherPayloadMeta) => void): () => void;\nonBeginTransaction(handler: (payload: TransactionBeganPayload, meta: DispatcherPayloadMeta) => void): () => void;\nonEndTransaction(handler: (payload: TransactionEndedPayload, meta: DispatcherPayloadMeta) => void): () => void;\n@@ -20,6 +21,18 @@ onChangeStore(handler: (payload: StoreChangedPayload, meta: DispatcherPayloadMet\n----\n+### `export declare class LifeCycleEventHub {`\n+\n+\n+LifeCycleEventHub provide the way for observing almin life-cycle events.\n+\n+## See also\n+\n+- https://almin.js.org/docs/tips/usecase-lifecycle.html\n+- almin-logger implementation\n+\n+----\n+\n### `onChangeStore(handler: (payload: StoreChangedPayload, meta: DispatcherPayloadMeta) => void): () => void;`\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/LifeCycleEventHub.ts", "new_path": "packages/almin/src/LifeCycleEventHub.ts", "diff": "@@ -24,6 +24,9 @@ export interface LifeCycleEventHubArgs {\n* - almin-logger implementation\n*/\nexport class LifeCycleEventHub {\n+ /**\n+ * @private\n+ */\nprivate releaseHandlers: (() => void)[];\nprivate dispatcher: Dispatcher;\nprivate storeGroup: StoreGroupLike;\n" }, { "change_type": "MODIFY", "old_path": "tools/d.ts-markdown.jst", "new_path": "tools/d.ts-markdown.jst", "diff": "<%\nfunction shouldIgnoreSection(section) {\nif (/^\\s*$/.test(section.docsText)) { return true; }\n- if (/^\\s*$/.test(section.codeText)) { return true; }\n+ if (/^\\s+$/.test(section.codeText)) { return true; }\n// private method\nif (/private /.test(section.codeText)) { return true; }\n// @private\n" } ]
TypeScript
MIT License
almin/almin
docs(api): add link to new api
19,400
27.07.2017 20:24:11
-32,400
f87af4635693e131e14ad8f057057af4d19f6bc1
docs(almin-logger): fix name
[ { "change_type": "MODIFY", "old_path": "packages/almin-logger/README.md", "new_path": "packages/almin-logger/README.md", "diff": "@@ -27,7 +27,7 @@ Old IE need [console-polyfill](https://github.com/paulmillr/console-polyfill \"co\n## Usage\n```js\n-import ContextLogger from \"almin-logger\";\n+import AlminLogger from \"almin-logger\";\n// your store\nimport AppStore from \"./stores/AppStore\";\n// context\n@@ -40,7 +40,7 @@ const appContext = new Context({\nstore: AppStore.create()\n});\n// Create Logger\n-const logger = new ContextLogger();\n+const logger = new AlminLogger();\n// Start logger\nlogger.startLogging(appContext);\n```\n@@ -49,7 +49,7 @@ See [Examples](./examples) for more details.\n## Options:\n-### `new ContextLogger(options)`\n+### `new AlminLogger(options)`\n```js\nconst DefaultOptions = {\n" } ]
TypeScript
MIT License
almin/almin
docs(almin-logger): fix name
19,400
29.07.2017 11:22:21
-32,400
e9aae52ff75f59c5a380f53dd8a7659132dbf37d
dcos(tips): Update logging
[ { "change_type": "MODIFY", "old_path": "docs/tips/logging.md", "new_path": "docs/tips/logging.md", "diff": "## Feature\n-- Execution log of UseCase\n-- Multiple Execution warning log of UseCase\n-- Changed log of Store\n-- Nesting log support if the browser support`console.groupCollapsed`.\n-- Async(default) and Sync logger\n+- Logging execution of UseCase\n+- Logging changed of Store\n+- Support Nesting log if the browser support`console.groupCollapsed`.\n+- Async logging\nPlease see [almin-logger](https://www.npmjs.com/package/almin-logger \"almin-logger\") for details.\n" } ]
TypeScript
MIT License
almin/almin
dcos(tips): Update logging
19,402
01.08.2017 21:39:56
-32,400
d5320117b0309d1197a5c73d6b38f3d7a92fd94e
docs(tutorial): fix a typo
[ { "change_type": "MODIFY", "old_path": "docs/tutorial/todomvc/README.md", "new_path": "docs/tutorial/todomvc/README.md", "diff": "@@ -140,7 +140,7 @@ export default class TodoList {\n}\n```\n-We can focus on bushiness logic because domain model is a just plain JavaScript.\n+We can focus on business logic because domain model is a just plain JavaScript.\n### Where domain model are stored?\n" } ]
TypeScript
MIT License
almin/almin
docs(tutorial): fix a typo (#272)
19,400
04.09.2017 10:54:59
-32,400
c6a387a01b1447c91029d7deb21f5516395c7359
chore(gitbook): update plugin
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"gitbook-cli\": \"2.3.0\",\n\"gitbook-plugin-advanced-emoji\": \"^0.2.2\",\n\"gitbook-plugin-forkmegithub\": \"^2.2.0\",\n- \"gitbook-plugin-include-codeblock\": \"^3.1.1\",\n+ \"gitbook-plugin-include-codeblock\": \"^3.1.3\",\n\"husky\": \"^0.14.3\",\n\"lerna\": \"^2.0.0\",\n\"lint-staged\": \"^4.0.1\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -1766,9 +1766,9 @@ gitbook-plugin-forkmegithub@^2.2.0:\nversion \"2.2.0\"\nresolved \"https://registry.yarnpkg.com/gitbook-plugin-forkmegithub/-/gitbook-plugin-forkmegithub-2.2.0.tgz#b64b62a1402b099b1b48c396a9d5b0aba967c04a\"\n-gitbook-plugin-include-codeblock@^3.1.1:\n- version \"3.1.1\"\n- resolved \"https://registry.yarnpkg.com/gitbook-plugin-include-codeblock/-/gitbook-plugin-include-codeblock-3.1.1.tgz#2233e0ce3fd58644a183a7a39639164d742b2622\"\n+gitbook-plugin-include-codeblock@^3.1.3:\n+ version \"3.1.3\"\n+ resolved \"https://registry.yarnpkg.com/gitbook-plugin-include-codeblock/-/gitbook-plugin-include-codeblock-3.1.3.tgz#8de4d3c3b4eaae18e7faf1bd3347640c7537a714\"\ndependencies:\nentities \"^1.1.1\"\nhandlebars \"^4.0.5\"\n" } ]
TypeScript
MIT License
almin/almin
chore(gitbook): update plugin
19,402
06.09.2017 00:12:33
-32,400
b897efca54811e467a1a4abb1df83143d8c7c519
docs(tutorial): fix link
[ { "change_type": "MODIFY", "old_path": "docs/tutorial/todomvc/README.md", "new_path": "docs/tutorial/todomvc/README.md", "diff": "@@ -333,7 +333,7 @@ export default class TodoStore extends Store {\n```\nIn other way, you can implement updating state from changes of `todoListRepository`.\n-Because, `Store#receivePayload` is called in the [Almin life-cycle](../tips/usecase-lifecycle.md).\n+Because, `Store#receivePayload` is called in the [Almin life-cycle](../../tips/usecase-lifecycle.md).\n- onDispatch\n- onError\n" } ]
TypeScript
MIT License
almin/almin
docs(tutorial): fix link (#275)
19,400
19.09.2017 08:45:10
-32,400
cbaf78955adcaf46102690a4c353005b4cc27a1f
docs(almin): add more details
[ { "change_type": "MODIFY", "old_path": "docs/tips/performance-profile.md", "new_path": "docs/tips/performance-profile.md", "diff": "# Performance profile\n-> Almin 1.4.0+\n+> New in Almin 1.4.0+\nYou can profiling UseCase execute, StoreGroup write/read, Store update using the browser developer tool timeline.\n@@ -10,6 +10,8 @@ The example of profiling result.\n## Metrics\n+Performance profile metrics.\n+\n| Mark | Duration |\n| ------------------------ | ---------------------------------------- |\n@@ -22,7 +24,15 @@ The example of profiling result.\n| `[UserCase#complete]` | From **did execute** to **complete** for each UseCase |\n-Related: [UseCase LifeCycle](./usecase-lifecycle.md)\n+Notes: Some metrics require strict mode.\n+\n+`[StoreGroup#write]` and `[Store#receivePayload]` require strict mode compatible Store implementation.\n+In other words, you should implement `receivePayload` on your Store.\n+\n+For more information about life-cycle, see following:\n+\n+- [Strict mode](./strict-mode.md)\n+- [UseCase LifeCycle](./usecase-lifecycle.md)\n## How to use?\n" } ]
TypeScript
MIT License
almin/almin
docs(almin): add more details
19,400
20.09.2017 10:17:56
-32,400
ff31c6d8f23b303c74b5fbaec7486a702cdc256a
chore(meta): Update description
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"private\": true,\n\"name\": \"almin-monorepo\",\n\"version\": \"0.11.0\",\n- \"description\": \"almin monorepo.\",\n+ \"description\": \"Almin monorepo.\",\n\"directories\": {\n\"doc\": \"docs\",\n\"example\": \"example\"\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"url\": \"https://github.com/almin/almin/issues\"\n},\n\"version\": \"0.14.0\",\n- \"description\": \"Flux/CQRS patterns for JavaScript app.\",\n+ \"description\": \"Client-side DDD/CQRS for JavaScript.\",\n\"main\": \"lib/src/index.js\",\n\"types\": \"lib/src/index.d.ts\",\n\"directories\": {\n" } ]
TypeScript
MIT License
almin/almin
chore(meta): Update description
19,400
29.09.2017 23:39:06
-32,400
105d696e49536d381e01e7617db0eecd9b9f92f3
docs(almin): update description
[ { "change_type": "MODIFY", "old_path": ".textlintrc", "new_path": ".textlintrc", "diff": "\"comments\": true\n},\n\"rules\": {\n+ \"prh\": {\n+ \"rulePaths\": [\n+ \"prh.yml\"\n+ ]\n+ },\n\"alex\": {\n\"allow\": [\n\"execute\",\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"textlint-rule-alex\": \"^1.0.1\",\n\"textlint-rule-common-misspellings\": \"^1.0.1\",\n\"textlint-rule-no-dead-link\": \"^3.0.1\",\n+ \"textlint-rule-prh\": \"^5.0.1\",\n\"typescript\": \"^2.4.2\"\n},\n\"scripts\": {\n\"test:bench\": \"cd perf/benchmark && npm it\",\n\"exec\": \"lerna exec\",\n\"start:docs\": \"gitbook serve\",\n- \"lint:docs\": \"textlint --cache -f pretty-error docs/\",\n- \"lint:docs:fix\": \"textlint --fix --cache docs/\",\n+ \"lint:docs\": \"textlint --cache -f pretty-error README.md docs/\",\n+ \"lint:docs:fix\": \"textlint --fix --cache README.md docs/\",\n\"build:docs\": \"gitbook build\",\n\"build:docs:api\": \"bash ./tools/update-api-reference.sh\",\n\"ci\": \"lerna run ci --ignore benchmark\",\n" }, { "change_type": "MODIFY", "old_path": "perf/benchmark/yarn.lock", "new_path": "perf/benchmark/yarn.lock", "diff": "@@ -68,13 +68,6 @@ almin@^0.12.0:\nobject-assign \"^4.1.0\"\nshallow-equal-object \"^1.0.1\"\n-almin@^0.14.0:\n- version \"0.14.0\"\n- resolved \"https://registry.yarnpkg.com/almin/-/almin-0.14.0.tgz#c625feddbf4739c4bd3079d819c9e25a92451aba\"\n- dependencies:\n- map-like \"^2.0.0\"\n- shallow-equal-object \"^1.0.1\"\n-\nalmin@^0.9.0:\nversion \"0.9.1\"\nresolved \"https://registry.yarnpkg.com/almin/-/almin-0.9.1.tgz#8aa21bb02984700f27bd405a280c3c6407297d19\"\n@@ -1985,10 +1978,6 @@ map-like@^1.0.3, map-like@^1.1.2:\nversion \"1.1.2\"\nresolved \"https://registry.yarnpkg.com/map-like/-/map-like-1.1.2.tgz#f42a301ebd9290372b9e4ddc49e5df9804a507b9\"\n-map-like@^2.0.0:\n- version \"2.0.0\"\n- resolved \"https://registry.yarnpkg.com/map-like/-/map-like-2.0.0.tgz#94496d49ad333c0dc3234b27adbbd1e8535953b4\"\n-\nmedia-typer@0.3.0:\nversion \"0.3.0\"\nresolved \"https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "prh.yml", "diff": "+version: 1\n+rules:\n+ - expected: Almin\n+ patterns:\n+ - Almin.js\n+ - expected: almin\n+ patterns:\n+ - almin.js\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -755,6 +755,10 @@ commander@2.9.0, commander@>=2.9.0, commander@^2.9.0:\ndependencies:\ngraceful-readlink \">= 1.0.0\"\n+commandpost@^1.2.1:\n+ version \"1.2.1\"\n+ resolved \"https://registry.yarnpkg.com/commandpost/-/commandpost-1.2.1.tgz#2e9c4c7508b9dc704afefaa91cab92ee6054cc68\"\n+\ncompare-func@^1.3.1:\nversion \"1.3.2\"\nresolved \"https://registry.yarnpkg.com/compare-func/-/compare-func-1.3.2.tgz#99dd0ba457e1f9bc722b12c08ec33eeab31fa648\"\n@@ -1158,6 +1162,10 @@ diff@^2.2.2:\nversion \"2.2.3\"\nresolved \"https://registry.yarnpkg.com/diff/-/diff-2.2.3.tgz#60eafd0d28ee906e4e8ff0a52c1229521033bf99\"\n+diff@^3.3.0:\n+ version \"3.3.1\"\n+ resolved \"https://registry.yarnpkg.com/diff/-/diff-3.3.1.tgz#aa8567a6eed03c531fc89d3f711cd0e5259dec75\"\n+\ndom-serializer@0, dom-serializer@0.1.0, dom-serializer@~0.1.0:\nversion \"0.1.0\"\nresolved \"https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.0.tgz#073c697546ce0780ce23be4a28e293e40bc30c82\"\n@@ -1320,6 +1328,10 @@ esprima@^3.1.1:\nversion \"3.1.3\"\nresolved \"https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633\"\n+esprima@^4.0.0:\n+ version \"4.0.0\"\n+ resolved \"https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804\"\n+\nevent-stream@~3.1.5:\nversion \"3.1.7\"\nresolved \"https://registry.yarnpkg.com/event-stream/-/event-stream-3.1.7.tgz#b4c540012d0fe1498420f3d8946008db6393c37a\"\n@@ -2499,6 +2511,13 @@ js-yaml@^3.2.4, js-yaml@^3.4.3, js-yaml@^3.6.1:\nargparse \"^1.0.7\"\nesprima \"^3.1.1\"\n+js-yaml@^3.9.1:\n+ version \"3.10.0\"\n+ resolved \"https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc\"\n+ dependencies:\n+ argparse \"^1.0.7\"\n+ esprima \"^4.0.0\"\n+\njsbn@~0.1.0:\nversion \"0.1.1\"\nresolved \"https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513\"\n@@ -3938,6 +3957,14 @@ pretty-format@^20.0.3:\nansi-regex \"^2.1.1\"\nansi-styles \"^3.0.0\"\n+prh@^5.4.3:\n+ version \"5.4.3\"\n+ resolved \"https://registry.yarnpkg.com/prh/-/prh-5.4.3.tgz#d3864a6de2f35c6603e33c700106dce01c22876d\"\n+ dependencies:\n+ commandpost \"^1.2.1\"\n+ diff \"^3.3.0\"\n+ js-yaml \"^3.9.1\"\n+\nprocess-nextick-args@~1.0.6:\nversion \"1.0.7\"\nresolved \"https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3\"\n@@ -5028,6 +5055,14 @@ textlint-rule-no-dead-link@^3.0.1:\nisomorphic-fetch \"^2.2.1\"\ntextlint-rule-helper \"^2.0.0\"\n+textlint-rule-prh@^5.0.1:\n+ version \"5.0.1\"\n+ resolved \"https://registry.yarnpkg.com/textlint-rule-prh/-/textlint-rule-prh-5.0.1.tgz#bab66be6b03258880f3fbf466b689ed2ff379b0c\"\n+ dependencies:\n+ prh \"^5.4.3\"\n+ textlint-rule-helper \"^2.0.0\"\n+ untildify \"^3.0.2\"\n+\ntextlint@^8.2.1:\nversion \"8.2.1\"\nresolved \"https://registry.yarnpkg.com/textlint/-/textlint-8.2.1.tgz#6803ab76cdf9532aac0ea106a89e09ae6aa7975d\"\n@@ -5348,6 +5383,10 @@ untildify@^2.1.0:\ndependencies:\nos-homedir \"^1.0.0\"\n+untildify@^3.0.2:\n+ version \"3.0.2\"\n+ resolved \"https://registry.yarnpkg.com/untildify/-/untildify-3.0.2.tgz#7f1f302055b3fea0f3e81dc78eb36766cb65e3f1\"\n+\nunzip-response@^1.0.2:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/unzip-response/-/unzip-response-1.0.2.tgz#b984f0877fc0a89c2c773cc1ef7b5b232b5b06fe\"\n" } ]
TypeScript
MIT License
almin/almin
docs(almin): update description
19,400
18.11.2017 23:15:20
-32,400
819879163e7e1f32789bcd32643019ae9d090fee
refactor(almin): refactor Dispatch tests
[ { "change_type": "RENAME", "old_path": "packages/almin/test/Dispatcher-test.js", "new_path": "packages/almin/test/Dispatcher-test.ts", "diff": "// LICENSE : MIT\n\"use strict\";\nconst assert = require(\"assert\");\n-\n-import { Dispatcher } from \"../src/Dispatcher\";\n+import { Dispatcher } from \"../src/\";\ndescribe(\"Dispatcher\", function() {\ndescribe(\"#onDispatch\", function() {\n@@ -19,16 +18,40 @@ describe(\"Dispatcher\", function() {\n});\n});\ndescribe(\"#dispatch\", function() {\n- it(\"should dispatch with payload object, otherwise throw error\", function() {\n+ it(\"when dispatch string, should throw error\", function() {\nconst dispatcher = new Dispatcher();\ntry {\n- dispatcher.dispatch(\"it is not payload\");\n+ dispatcher.dispatch(\"it is not payload\" as any);\nthrow new Error(\"UNREACHED\");\n} catch (error) {\nassert(error.message !== \"UNREACHED\");\n}\n});\n- it(\"should dispatch with payload object that has type propery\", function(done) {\n+ it(\"when dispatch with payload that has string type, should pass test\", function(done) {\n+ const dispatcher = new Dispatcher();\n+ const expectedPayload = {\n+ type: \"string type\"\n+ };\n+ dispatcher.onDispatch(payload => {\n+ assert.deepEqual(payload, expectedPayload);\n+ done();\n+ });\n+ dispatcher.dispatch(expectedPayload);\n+ });\n+ it(\"when dispatch with payload that has object type, should pass test\", function(done) {\n+ const dispatcher = new Dispatcher();\n+ const expectedPayload = {\n+ type: {\n+ /* string Symbol anything */\n+ }\n+ };\n+ dispatcher.onDispatch(payload => {\n+ assert.deepEqual(payload, expectedPayload);\n+ done();\n+ });\n+ dispatcher.dispatch(expectedPayload);\n+ });\n+ it(\"when dispatch with payload object that has type property, should pass test\", function(done) {\nconst dispatcher = new Dispatcher();\nconst expectedPayload = {\ntype: {\n@@ -41,7 +64,7 @@ describe(\"Dispatcher\", function() {\n});\ndispatcher.dispatch(expectedPayload);\n});\n- it(\"should pass payload object to listening handler\", function(done) {\n+ it(\"when dispatch payload object, listen handler catch the payload\", function(done) {\nconst dispatcher = new Dispatcher();\nconst expectedPayload = {\ntype: \"pay\",\n" } ]
TypeScript
MIT License
almin/almin
refactor(almin): refactor Dispatch tests
19,400
18.11.2017 23:42:15
-32,400
186c6157a5782e5ab94f93b38d7b1074607ddff4
fix(almin): Payload subclass need to define "type" property
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/payload/ChangedPayload.ts", "new_path": "packages/almin/src/payload/ChangedPayload.ts", "diff": "@@ -13,6 +13,7 @@ export const TYPE = \"ALMIN__ChangedPayload__\";\n* @deprecated\n*/\nexport class ChangedPayload extends Payload {\n+ type: typeof TYPE;\nconstructor() {\nsuper({ type: TYPE });\nconsole.warn(\"ChangedPayload will be removed.\");\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/payload/CompletedPayload.ts", "new_path": "packages/almin/src/payload/CompletedPayload.ts", "diff": "@@ -9,6 +9,7 @@ import { Payload } from \"./Payload\";\nexport const TYPE = \"ALMIN__COMPLETED_EACH_USECASE__\";\nexport class CompletedPayload extends Payload {\n+ type: typeof TYPE;\n/**\n* the value is returned by the useCase\n* Difference of DidExecutedPayload, the value always is resolved value.\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/payload/DidExecutedPayload.ts", "new_path": "packages/almin/src/payload/DidExecutedPayload.ts", "diff": "@@ -9,6 +9,7 @@ import { Payload } from \"./Payload\";\nexport const TYPE = \"ALMIN__DID_EXECUTED_EACH_USECASE__\";\nexport class DidExecutedPayload extends Payload {\n+ type: typeof TYPE;\n/**\n* the value is returned by the useCase\n* Maybe Promise or some value or undefined.\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/payload/ErrorPayload.ts", "new_path": "packages/almin/src/payload/ErrorPayload.ts", "diff": "@@ -12,6 +12,7 @@ export const TYPE = \"ALMIN__ErrorPayload__\";\n* This payload is executed\n*/\nexport class ErrorPayload extends Payload {\n+ type: typeof TYPE;\n/**\n* the `error` in the UseCase\n*/\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/payload/InitializedPayload.ts", "new_path": "packages/almin/src/payload/InitializedPayload.ts", "diff": "@@ -13,6 +13,7 @@ export const TYPE = \"Almin__InitializedPayload__\";\n* DO NOT USE THIS in your application.\n*/\nexport class InitializedPayload extends Payload {\n+ type: typeof TYPE;\nconstructor() {\nsuper({ type: TYPE });\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/payload/Payload.ts", "new_path": "packages/almin/src/payload/Payload.ts", "diff": "@@ -11,7 +11,7 @@ export abstract class Payload {\n* A `type` property which may not be `undefined`\n* It is a good idea to use string constants or Symbol for payload types.\n*/\n- readonly type: any;\n+ abstract readonly type: any;\nconstructor(args?: PayloadArgs) {\nif (args) {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/payload/StoreChangedPayload.ts", "new_path": "packages/almin/src/payload/StoreChangedPayload.ts", "diff": "@@ -12,6 +12,7 @@ export const TYPE = \"ALMIN_STORE_IS_CHANGED__\";\n* ChangePayload is that represent a store is changed.\n*/\nexport class StoreChangedPayload extends Payload {\n+ type: typeof TYPE;\nstore: StoreLike<any>;\nconstructor(store: StoreLike<any>) {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/payload/TransactionBeganPayload.ts", "new_path": "packages/almin/src/payload/TransactionBeganPayload.ts", "diff": "@@ -11,6 +11,7 @@ export const TYPE = \"ALMIN_BEGAN_OF_TRANSACTION__\";\n* TransactionBeganPayload is begin of transaction\n*/\nexport class TransactionBeganPayload extends Payload {\n+ type: typeof TYPE;\n// transaction name\nname: string;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/payload/TransactionEndedPayload.ts", "new_path": "packages/almin/src/payload/TransactionEndedPayload.ts", "diff": "@@ -11,6 +11,7 @@ export const TYPE = \"ALMIN_ENF_OF_TRANSACTION__\";\n* TransactionEndedPayload is end of transaction\n*/\nexport class TransactionEndedPayload extends Payload {\n+ type: typeof TYPE;\n// transaction name\nname: string;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/payload/WillExecutedPayload.ts", "new_path": "packages/almin/src/payload/WillExecutedPayload.ts", "diff": "@@ -9,6 +9,7 @@ import { Payload } from \"./Payload\";\nexport const TYPE = \"ALMIN__WILL_EXECUTED_EACH_USECASE__\";\nexport class WillExecutedPayload extends Payload {\n+ type: typeof TYPE;\n/**\n* a array for argument of the useCase\n*/\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/Dispatcher-test.ts", "new_path": "packages/almin/test/Dispatcher-test.ts", "diff": "// LICENSE : MIT\n\"use strict\";\nconst assert = require(\"assert\");\n-import { Dispatcher } from \"../src/\";\n+import { Dispatcher, Payload } from \"../src/\";\ndescribe(\"Dispatcher\", function() {\ndescribe(\"#onDispatch\", function() {\n@@ -27,6 +27,37 @@ describe(\"Dispatcher\", function() {\nassert(error.message !== \"UNREACHED\");\n}\n});\n+ it(\"when dispatch Payload instance that have not type, should throw error\", function() {\n+ const dispatcher = new Dispatcher();\n+\n+ // @ts-ignore\n+ class MyPayload extends Payload {}\n+\n+ try {\n+ dispatcher.dispatch(new MyPayload());\n+ throw new Error(\"UNREACHED\");\n+ } catch (error) {\n+ assert(error.message !== \"UNREACHED\");\n+ }\n+ });\n+ it(\"when dispatch Payload instance, should pass test\", function(done) {\n+ const dispatcher = new Dispatcher();\n+\n+ class MyPayload extends Payload {\n+ type: string;\n+\n+ // Not have type\n+ constructor() {\n+ super({ type: \"MyPayload\" });\n+ }\n+ }\n+\n+ dispatcher.onDispatch(payload => {\n+ assert.ok(payload instanceof MyPayload);\n+ done();\n+ });\n+ dispatcher.dispatch(new MyPayload());\n+ });\nit(\"when dispatch with payload that has string type, should pass test\", function(done) {\nconst dispatcher = new Dispatcher();\nconst expectedPayload = {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/typescript/almin-loading.ts", "new_path": "packages/almin/test/typescript/almin-loading.ts", "diff": "// Loading UseCase & Store Example\nimport { Context, Store, Dispatcher, UseCase, Payload } from \"../../src/index\";\n+\n// custom payload\nclass LoadingPayload extends Payload {\n+ type = \"MyPayload\";\n+\nconstructor(public isLoading: boolean) {\n- super({ type: \"MyPayload\" });\n+ super();\n}\n}\n+\ntype UpdateLoadingUseCaseArg = boolean;\n+\nclass UpdateLoadingUseCase extends UseCase {\nexecute(isLoading: UpdateLoadingUseCaseArg) {\nthis.dispatch(new LoadingPayload(isLoading));\n}\n}\n+\nclass LoadingState {\nconstructor(public isLoading: boolean) {}\n@@ -19,6 +25,7 @@ class LoadingState {\nreturn new LoadingState(isLoading);\n}\n}\n+\nclass LoadingStore extends Store<LoadingState> {\nstate: LoadingState;\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): Payload subclass need to define "type" property
19,400
19.11.2017 00:22:28
-32,400
6fa723ee00a8dab98059cc48cc68f82b648fd218
chore(almin): Upgrade TypeScript 2.6.1
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"textlint-rule-common-misspellings\": \"^1.0.1\",\n\"textlint-rule-no-dead-link\": \"^3.0.1\",\n\"textlint-rule-prh\": \"^5.0.1\",\n- \"typescript\": \"^2.4.2\"\n+ \"typescript\": \"~2.6.1\"\n},\n\"scripts\": {\n\"precommit\": \"lint-staged\",\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"sinon\": \"^2.3.8\",\n\"size-limit\": \"^0.11.4\",\n\"source-map-support\": \"^0.4.15\",\n- \"typescript\": \"~2.3.1\",\n+ \"typescript\": \"~2.6.1\",\n\"zuul\": \"^3.10.1\"\n},\n\"dependencies\": {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/Context.ts", "new_path": "packages/almin/src/Context.ts", "diff": "@@ -14,7 +14,6 @@ import { WillExecutedPayload } from \"./payload/WillExecutedPayload\";\nimport { UseCaseFunction } from \"./FunctionalUseCaseContext\";\nimport { FunctionalUseCase } from \"./FunctionalUseCase\";\nimport { StateMap } from \"./UILayer/StoreGroupTypes\";\n-import { UseCaseLike } from \"./UseCaseLike\";\nimport { UseCaseUnitOfWork } from \"./UnitOfWork/UseCaseUnitOfWork\";\nimport { StoreGroup } from \"./UILayer/StoreGroup\";\nimport { createUseCaseExecutor } from \"./UseCaseExecutorFactory\";\n@@ -25,6 +24,7 @@ import { LifeCycleEventHub } from \"./LifeCycleEventHub\";\nimport { StoreChangedPayload } from \"./payload/StoreChangedPayload\";\nimport AlminInstruments from \"./instrument/AlminInstruments\";\nimport { ContextConfig } from \"./ContextConfig\";\n+import { UseCase } from \"./UseCase\";\nconst deprecateWarning = (methodName: string) => {\nconsole.warn(`Deprecated: Context.prototype.${methodName} is deprecated.\n@@ -147,8 +147,7 @@ export class Context<T> {\n// life-cycle event hub\nthis.lifeCycleEventHub = new LifeCycleEventHub({\n- dispatcher: this.dispatcher,\n- storeGroup: this.storeGroup\n+ dispatcher: this.dispatcher\n});\nconst options = args.options || {};\n@@ -288,8 +287,8 @@ export class Context<T> {\n* context.useCase(awesomeUseCase).execute([1, 2, 3]);\n* ```\n*/\n+ useCase<T extends UseCase>(useCase: T): UseCaseExecutor<T>;\nuseCase(useCase: UseCaseFunction): UseCaseExecutor<FunctionalUseCase>;\n- useCase<T extends UseCaseLike>(useCase: T): UseCaseExecutor<T>;\nuseCase(useCase: any): UseCaseExecutor<any> {\nconst useCaseExecutor = createUseCaseExecutor(useCase, this.dispatcher);\nconst unitOfWork = new UseCaseUnitOfWork({\n@@ -424,7 +423,7 @@ Please enable strict mode via \\`new Context({ dispatcher, store, options: { stri\nstoreGroup: this.storeGroup,\noptions: { autoCommit: false }\n});\n- const createUseCaseExecutorAndOpenUoW = <T extends UseCaseLike>(useCase: T): UseCaseExecutor<T> => {\n+ const createUseCaseExecutorAndOpenUoW = <T extends UseCase>(useCase: T): UseCaseExecutor<T> => {\nconst useCaseExecutor = createUseCaseExecutor(useCase, this.dispatcher);\nunitOfWork.open(useCaseExecutor);\nreturn useCaseExecutor;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/FunctionalUseCaseContext.ts", "new_path": "packages/almin/src/FunctionalUseCaseContext.ts", "diff": "@@ -11,7 +11,14 @@ import { Payload } from \"./payload/Payload\";\n* }\n* ```\n*/\n-export type UseCaseFunction = (context?: FunctionalUseCaseContext) => (...args: Array<any>) => any;\n+export type UseCaseFunction = (context: FunctionalUseCaseContext) => (...args: Array<any>) => any;\n+\n+/**\n+ * Is `v` is UseCaseFunction?\n+ */\n+export const isUseCaseFunction = (v: any): v is UseCaseFunction => {\n+ return typeof v === \"function\";\n+};\n/**\n* Send only dispatcher\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/LifeCycleEventHub.ts", "new_path": "packages/almin/src/LifeCycleEventHub.ts", "diff": "@@ -5,14 +5,12 @@ import { DispatcherPayloadMeta } from \"./DispatcherPayloadMeta\";\nimport { DidExecutedPayload, isDidExecutedPayload } from \"./payload/DidExecutedPayload\";\nimport { CompletedPayload, isCompletedPayload } from \"./payload/CompletedPayload\";\nimport { ErrorPayload, isErrorPayload } from \"./payload/ErrorPayload\";\n-import { StoreGroupLike } from \"./UILayer/StoreGroupLike\";\n-import { TransactionBeganPayload, isTransactionBeganPayload } from \"./payload/TransactionBeganPayload\";\n-import { TransactionEndedPayload, isTransactionEndedPayload } from \"./payload/TransactionEndedPayload\";\n+import { isTransactionBeganPayload, TransactionBeganPayload } from \"./payload/TransactionBeganPayload\";\n+import { isTransactionEndedPayload, TransactionEndedPayload } from \"./payload/TransactionEndedPayload\";\nimport { isStoreChangedPayload, StoreChangedPayload } from \"./payload/StoreChangedPayload\";\nexport interface LifeCycleEventHubArgs {\ndispatcher: Dispatcher;\n- storeGroup: StoreGroupLike;\n}\n/**\n@@ -29,11 +27,9 @@ export class LifeCycleEventHub {\n*/\nprivate releaseHandlers: (() => void)[];\nprivate dispatcher: Dispatcher;\n- private storeGroup: StoreGroupLike;\nconstructor(args: LifeCycleEventHubArgs) {\nthis.dispatcher = args.dispatcher;\n- this.storeGroup = args.storeGroup;\nthis.releaseHandlers = [];\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UILayer/SingleStoreGroup.ts", "new_path": "packages/almin/src/UILayer/SingleStoreGroup.ts", "diff": "@@ -13,14 +13,11 @@ import { StoreLike } from \"../StoreLike\";\n*/\nexport class SingleStoreGroup<T extends Store> extends Dispatcher implements StoreGroupLike {\nprivate storeGroup: StoreGroup<{ target: T }>;\n- private store: T;\n-\n- name: string;\n+ readonly name: string;\nconstructor(store: T) {\nsuper();\nthis.name = `SingleStoreGroup(${store.name})`;\n- this.store = store;\nthis.storeGroup = new StoreGroup({\ntarget: store\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UILayer/StoreStateMap.ts", "new_path": "packages/almin/src/UILayer/StoreStateMap.ts", "diff": "import { MapLike } from \"map-like\";\nimport { Store } from \"../Store\";\nimport { StoreMap } from \"./StoreGroupTypes\";\n+\n/**\n* TODO: make strong type\n*/\n@@ -31,7 +32,8 @@ export class StoreStateMap extends MapLike<Store, string> {\n*/\nexport function createStoreStateMap<T>(mappingObject: StoreMap<T>): StoreStateMap {\nconst map = new StoreStateMap();\n- const keys = Object.keys(mappingObject);\n+ // Suppress: Element implicitly has an 'any' type because type 'StoreMap<T>' has no index signature.\n+ const keys = Object.keys(mappingObject) as (keyof T)[];\nfor (let i = 0; i < keys.length; i++) {\nconst stateName = keys[i];\nconst store = mappingObject[stateName];\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutorFactory.ts", "new_path": "packages/almin/src/UseCaseExecutorFactory.ts", "diff": "import { UseCaseExecutorImpl } from \"./UseCaseExecutor\";\n-import { UseCaseFunction } from \"./FunctionalUseCaseContext\";\n+import { isUseCaseFunction, UseCaseFunction } from \"./FunctionalUseCaseContext\";\nimport { FunctionalUseCase } from \"./FunctionalUseCase\";\n-import { UseCaseLike } from \"./UseCaseLike\";\nimport { isUseCase, UseCase } from \"./UseCase\";\nimport * as assert from \"assert\";\nimport { Dispatcher } from \"./Dispatcher\";\n@@ -10,10 +9,7 @@ export function createUseCaseExecutor(\nuseCase: UseCaseFunction,\ndispatcher: Dispatcher\n): UseCaseExecutorImpl<FunctionalUseCase>;\n-export function createUseCaseExecutor<T extends UseCaseLike>(\n- useCase: T,\n- dispatcher: Dispatcher\n-): UseCaseExecutorImpl<T>;\n+export function createUseCaseExecutor<T extends UseCase>(useCase: T, dispatcher: Dispatcher): UseCaseExecutorImpl<T>;\nexport function createUseCaseExecutor(useCase: any, dispatcher: Dispatcher): UseCaseExecutorImpl<any> {\n// instance of UseCase\nif (isUseCase(useCase)) {\n@@ -22,7 +18,7 @@ export function createUseCaseExecutor(useCase: any, dispatcher: Dispatcher): Use\nparent: isUseCase(dispatcher) ? dispatcher : null,\ndispatcher\n});\n- } else if (typeof useCase === \"function\") {\n+ } else if (isUseCaseFunction(useCase)) {\n// When pass UseCase constructor itself, throw assertion error\nassert.ok(\nObject.getPrototypeOf && Object.getPrototypeOf(useCase) !== UseCase,\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/Dispatcher-test.ts", "new_path": "packages/almin/test/Dispatcher-test.ts", "diff": "@@ -30,7 +30,7 @@ describe(\"Dispatcher\", function() {\nit(\"when dispatch Payload instance that have not type, should throw error\", function() {\nconst dispatcher = new Dispatcher();\n- // @ts-ignore\n+ // @ts-ignore: missing type\nclass MyPayload extends Payload {}\ntry {\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -5270,9 +5270,9 @@ typedarray@^0.0.6:\nversion \"0.0.6\"\nresolved \"https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777\"\n-typescript@^2.4.2:\n- version \"2.4.2\"\n- resolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.4.2.tgz#f8395f85d459276067c988aa41837a8f82870844\"\n+typescript@^2.6.1:\n+ version \"2.6.1\"\n+ resolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.6.1.tgz#ef39cdea27abac0b500242d6726ab90e0c846631\"\nuglify-js@^2.6:\nversion \"2.8.22\"\n" } ]
TypeScript
MIT License
almin/almin
chore(almin): Upgrade TypeScript 2.6.1
19,400
25.11.2017 14:15:41
-32,400
7c31364ae4ce53f855eb4780fbf43f834fa08e07
feat(almin): Support UseCase#shouldExecute
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCase.ts", "new_path": "packages/almin/src/UseCase.ts", "diff": "@@ -102,6 +102,15 @@ export abstract class UseCase extends Dispatcher implements UseCaseLike {\nreturn new UseCaseContext(this);\n}\n+ /**\n+ * Should useCase execute?\n+ * Return true by default\n+ * @returns {boolean}\n+ */\n+ shouldExecute(..._: Array<any>): boolean {\n+ return true;\n+ }\n+\n/**\n* `UseCase#execute()` method should be overwrite by subclass.\n*\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -12,15 +12,15 @@ import { WillExecutedPayload } from \"./payload/WillExecutedPayload\";\nimport { UseCaseLike } from \"./UseCaseLike\";\nimport { Payload } from \"./payload/Payload\";\n-interface onWillExecuteArgs {\n+interface onWillNotExecuteArgs {\n(...args: Array<any>): void;\n}\n-interface onDidExecuteArgs {\n- (value?: any): void;\n+interface onWillExecuteArgs {\n+ (...args: Array<any>): void;\n}\n-interface onCompleteArgs {\n+interface onDidExecuteArgs {\n(value?: any): void;\n}\n@@ -30,9 +30,9 @@ interface onCompleteArgs {\n*/\nconst proxifyUseCase = <T extends UseCaseLike>(\nuseCase: T,\n+ onWillNotExecute: onWillNotExecuteArgs,\nonWillExecute: onWillExecuteArgs,\n- onDidExecute: onDidExecuteArgs,\n- onComplete: onCompleteArgs\n+ onDidExecute: onDidExecuteArgs\n): T => {\nlet isExecuted = false;\nconst execute = (...args: Array<any>) => {\n@@ -42,13 +42,26 @@ const proxifyUseCase = <T extends UseCaseLike>(\n}\n}\nisExecuted = true;\n- // before execute\n+ // should the useCase execute?\n+ if (typeof useCase.shouldExecute === \"function\") {\n+ const shouldExecute = useCase.shouldExecute(args);\n+ if (typeof shouldExecute !== \"boolean\") {\n+ throw new Error(\n+ `${useCase.name}>#shouldExecute should return boolean value. Actual result: ${shouldExecute}`\n+ );\n+ }\n+ if (!shouldExecute) {\n+ return onWillNotExecute(args);\n+ }\n+ }\n+ // will execute\nonWillExecute(args);\n// execute\nconst result = useCase.execute(...args);\n- // after execute\n+ // did execute\nonDidExecute(result);\n- return onComplete(result);\n+ // plain result\n+ return result;\n};\n// Add debug displayName\nif (process.env.NODE_ENV !== \"production\") {\n@@ -161,6 +174,10 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n}\n}\n+ private willNotExecuteUseCase(args?: any[]): void {\n+ console.log(\"this is will not args\", args);\n+ }\n+\n/**\n* @param [args] arguments of the UseCase\n*/\n@@ -292,7 +309,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n* You should not relay on the data of the command result.\n*/\nexecutor(executor: (useCase: Pick<T, \"execute\">) => any): Promise<void> {\n- const startingExecutor = (resolve: Function, reject: Function): void => {\n+ const startingExecutor = new Promise((resolve, reject) => {\nif (typeof executor !== \"function\") {\nconsole.error(\n\"Warning(UseCase): executor argument should be function. But this argument is not function: \",\n@@ -304,19 +321,21 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n// proxiedUseCase will resolve by UseCaseWrapper#execute\nconst proxyfiedUseCase = proxifyUseCase<T>(\nthis.useCase,\n+ args => {\n+ this.willNotExecuteUseCase(args);\n+ },\nargs => {\nthis.willExecuteUseCase(args);\n},\nvalue => {\nthis.didExecuteUseCase(value);\n- },\n- value => {\n- resolve(value);\n}\n);\n- return executor(proxyfiedUseCase);\n- };\n- return new Promise(startingExecutor)\n+ const executedResult = executor(proxyfiedUseCase);\n+ // always put promise wrap on executed result\n+ return Promise.resolve(executedResult).then(resolve, reject);\n+ });\n+ return startingExecutor\n.then(result => {\nthis.completeUseCase(result);\nthis.release();\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseLike.ts", "new_path": "packages/almin/src/UseCaseLike.ts", "diff": "@@ -4,6 +4,7 @@ import { Dispatcher } from \"./Dispatcher\";\nexport interface UseCaseLike extends Dispatcher {\nid: string;\nname: string;\n+ shouldExecute?(...args: Array<any>): boolean;\nexecute(...args: Array<any>): any;\nthrowError(error: Error): void;\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/UseCase-test.js", "new_path": "packages/almin/test/UseCase-test.js", "diff": "@@ -27,12 +27,14 @@ describe(\"UseCase\", function() {\nclass ExampleUseCase extends UseCase {\nexecute() {}\n}\n+\nconst useCase = new ExampleUseCase();\nassert(useCase.name === \"ExampleUseCase\");\n});\ndescribe(\"when define displayName\", () => {\nit(\"#name is same with displayName\", () => {\nclass MyUseCase extends UseCase {}\n+\nconst expectedName = \"Expected UseCase\";\nMyUseCase.displayName = expectedName;\nconst store = new MyUseCase();\n@@ -47,6 +49,7 @@ describe(\"UseCase\", function() {\nthis.throwError(new Error(\"error\"));\n}\n}\n+\nconst testUseCase = new TestUseCase();\n// then\ntestUseCase.onDispatch(({ type, error }) => {\n@@ -65,6 +68,7 @@ describe(\"UseCase\", function() {\nreturn \"b\";\n}\n}\n+\nclass AUseCase extends UseCase {\nexecute() {\nconst bUseCase = new BUseCase();\n@@ -72,6 +76,7 @@ describe(\"UseCase\", function() {\nuseCaseContext.useCase(bUseCase).execute();\n}\n}\n+\nconst aUseCase = new AUseCase();\n// for reference fn.name\nconst bUseCase = new BUseCase();\n@@ -116,6 +121,7 @@ describe(\"UseCase\", function() {\nassert(typeof this.dispatch === \"function\");\n}\n}\n+\nconst dispatcher = new Dispatcher();\nconst context = new Context({\ndispatcher,\n@@ -129,6 +135,7 @@ describe(\"UseCase\", function() {\ndescribe(\"when not implemented execute()\", function() {\nit(\"should assert error on constructor\", function() {\nclass TestUseCase extends UseCase {}\n+\ntry {\nconst useCase = new TestUseCase();\nuseCase.execute();\n@@ -153,16 +160,19 @@ describe(\"UseCase\", function() {\nconst childPayload = {\ntype: \"ChildUseCase\"\n};\n+\nclass ChildUseCase extends UseCase {\nexecute() {\nthis.dispatch(childPayload);\n}\n}\n+\nclass ParentUseCase extends UseCase {\nexecute() {\nreturn this.context.useCase(new ChildUseCase()).execute();\n}\n}\n+\nit(\"should delegate dispatch to parent -> dispatcher\", function() {\nconst dispatcher = new Dispatcher();\nconst context = new Context({\n@@ -216,12 +226,14 @@ describe(\"UseCase\", function() {\nassert(/Warning\\(UseCase\\):.*?is already released/.test(warningMessage), warningMessage);\ndone();\n};\n+\nclass ChildUseCase extends UseCase {\nexecute() {\nthis.dispatch(childPayload);\nfinishCallBack();\n}\n}\n+\nclass ParentUseCase extends UseCase {\nexecute() {\n// ChildUseCase is independent from Parent\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/UseCaseExecutor-test.js", "new_path": "packages/almin/test/UseCaseExecutor-test.js", "diff": "@@ -168,6 +168,88 @@ describe(\"UseCaseExecutor\", function() {\n});\n});\n});\n+ describe(\"#shouldExecute\", () => {\n+ describe(\"when implemented shouldExecute()\", function() {\n+ it(\"should called before execute\", function() {\n+ const called = [];\n+\n+ class TestUseCase extends UseCase {\n+ shouldExecute() {\n+ called.push(\"shouldExecute\");\n+ return true;\n+ }\n+\n+ execute() {\n+ called.push(\"execute\");\n+ }\n+ }\n+\n+ const dispatcher = new Dispatcher();\n+ const executor = new UseCaseExecutorImpl({\n+ useCase: new TestUseCase(),\n+ dispatcher\n+ });\n+ return executor.execute().then(() => {\n+ assert.deepEqual(called, [\"shouldExecute\", \"execute\"]);\n+ });\n+ });\n+ });\n+ describe(\"when shouldExecute() => false\", function() {\n+ it(\"should not call UseCase#execute\", function() {\n+ const called = [];\n+\n+ class TestUseCase extends UseCase {\n+ shouldExecute() {\n+ called.push(\"shouldExecute\");\n+ return false;\n+ }\n+\n+ execute() {\n+ called.push(\"execute\");\n+ }\n+ }\n+\n+ const dispatcher = new Dispatcher();\n+ const executor = new UseCaseExecutorImpl({\n+ useCase: new TestUseCase(),\n+ dispatcher\n+ });\n+ return executor.execute().then(() => {\n+ assert.deepEqual(called, [\"shouldExecute\"]);\n+ });\n+ });\n+ });\n+ describe(\"when shouldExecute() => undefined\", function() {\n+ it(\"should throw error\", function() {\n+ const called = [];\n+\n+ class TestUseCase extends UseCase {\n+ shouldExecute() {\n+ called.push(\"shouldExecute\");\n+ }\n+\n+ execute() {\n+ called.push(\"execute\");\n+ }\n+ }\n+\n+ const dispatcher = new Dispatcher();\n+ const executor = new UseCaseExecutorImpl({\n+ useCase: new TestUseCase(),\n+ dispatcher\n+ });\n+ return executor.execute().then(\n+ () => {\n+ assert.fail(\"SHOULD NOT RESOLVED\");\n+ },\n+ error => {\n+ assert.ok(error instanceof Error);\n+ assert.deepEqual(called, [\"shouldExecute\"]);\n+ }\n+ );\n+ });\n+ });\n+ });\ndescribe(\"#execute\", function() {\nit(\"should catch sync throwing error in UseCase\", () => {\nconst dispatcher = new Dispatcher();\n" } ]
TypeScript
MIT License
almin/almin
feat(almin): Support UseCase#shouldExecute
19,400
25.11.2017 17:06:21
-32,400
7c0aed3beaa5c78f329edc74b00ae40f3c7b9334
feat(almin): Add "onWillNotExecuteEachUseCase" to LifeCycleEventHub
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/LifeCycleEventHub.ts", "new_path": "packages/almin/src/LifeCycleEventHub.ts", "diff": "@@ -8,6 +8,7 @@ import { ErrorPayload, isErrorPayload } from \"./payload/ErrorPayload\";\nimport { isTransactionBeganPayload, TransactionBeganPayload } from \"./payload/TransactionBeganPayload\";\nimport { isTransactionEndedPayload, TransactionEndedPayload } from \"./payload/TransactionEndedPayload\";\nimport { isStoreChangedPayload, StoreChangedPayload } from \"./payload/StoreChangedPayload\";\n+import { isWillNotExecutedPayload, WillNotExecutedPayload } from \"./payload/WillNotExecutedPayload\";\nexport interface LifeCycleEventHubArgs {\ndispatcher: Dispatcher;\n@@ -100,6 +101,23 @@ export class LifeCycleEventHub {\nreturn releaseHandler;\n}\n+ /**\n+ * Register `handler` function to Context.\n+ * `handler` is called when each useCases will not execute.\n+ * In other words, `UseCase#shouldExecute` return false.\n+ */\n+ onWillNotExecuteEachUseCase(\n+ handler: (payload: WillNotExecutedPayload, meta: DispatcherPayloadMeta) => void\n+ ): () => void {\n+ const releaseHandler = this.dispatcher.onDispatch(function onWillNotExecuteEachUseCase(payload, meta) {\n+ if (isWillNotExecutedPayload(payload)) {\n+ handler(payload, meta);\n+ }\n+ });\n+ this.releaseHandlers.push(releaseHandler);\n+ return releaseHandler;\n+ }\n+\n/**\n* Register `handler` function to Context.\n* `handler` is called when each useCases will execute.\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCase.ts", "new_path": "packages/almin/src/UseCase.ts", "diff": "@@ -103,8 +103,12 @@ export abstract class UseCase extends Dispatcher implements UseCaseLike {\n}\n/**\n- * Should useCase execute?\n- * Return true by default\n+ * Should does the UseCase execute?\n+ * Return `true` by default\n+ *\n+ * shouldExecute() is invoked before execute() when Executor execute the UseCase.\n+ * Currently, if shouldExecute() returns false, then execute() will not be invoked.\n+ *\n* @returns {boolean}\n*/\nshouldExecute(..._: Array<any>): boolean {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -11,6 +11,7 @@ import { DidExecutedPayload } from \"./payload/DidExecutedPayload\";\nimport { WillExecutedPayload } from \"./payload/WillExecutedPayload\";\nimport { UseCaseLike } from \"./UseCaseLike\";\nimport { Payload } from \"./payload/Payload\";\n+import { WillNotExecutedPayload } from \"./payload/WillNotExecutedPayload\";\ninterface onWillNotExecuteArgs {\n(...args: Array<any>): void;\n@@ -46,8 +47,10 @@ const proxifyUseCase = <T extends UseCaseLike>(\nif (typeof useCase.shouldExecute === \"function\") {\nconst shouldExecute = useCase.shouldExecute(args);\nif (typeof shouldExecute !== \"boolean\") {\n- throw new Error(\n+ return Promise.reject(\n+ new Error(\n`${useCase.name}>#shouldExecute should return boolean value. Actual result: ${shouldExecute}`\n+ )\n);\n}\nif (!shouldExecute) {\n@@ -175,7 +178,17 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n}\nprivate willNotExecuteUseCase(args?: any[]): void {\n- console.log(\"this is will not args\", args);\n+ const payload = new WillNotExecutedPayload({\n+ args\n+ });\n+ const meta = new DispatcherPayloadMetaImpl({\n+ useCase: this.useCase,\n+ dispatcher: this._dispatcher,\n+ parentUseCase: this._parentUseCase,\n+ isTrusted: true,\n+ isUseCaseFinished: true\n+ });\n+ this.dispatch(payload, meta);\n}\n/**\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/almin/src/payload/WillNotExecutedPayload.ts", "diff": "+// LICENSE : MIT\n+\"use strict\";\n+import { Payload } from \"./Payload\";\n+\n+/**\n+ * XXX: This is exported for an unit testing.\n+ * DO NOT USE THIS in your application.\n+ */\n+export const TYPE = \"ALMIN__WILL_NOT_EXECUTE_USECASE__\";\n+\n+export class WillNotExecutedPayload extends Payload {\n+ type: typeof TYPE;\n+ /**\n+ * a array for argument of the useCase\n+ */\n+ args: Array<any>;\n+\n+ constructor({ args = [] }: { args?: Array<any> }) {\n+ super({ type: TYPE });\n+ this.args = args;\n+ }\n+}\n+\n+export function isWillNotExecutedPayload(v: Payload): v is WillNotExecutedPayload {\n+ return v.type === TYPE;\n+}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/Context-test.js", "new_path": "packages/almin/test/Context-test.js", "diff": "@@ -12,6 +12,7 @@ import { createStore } from \"./helper/create-new-store\";\nimport { createEchoStore } from \"./helper/EchoStore\";\nimport { DispatchUseCase } from \"./use-case/DispatchUseCase\";\nimport { ParentUseCase } from \"./use-case/NestingUseCase\";\n+import { NotExecuteUseCase } from \"./use-case/NotExecuteUseCase\";\nimport { SyncNoDispatchUseCase } from \"./use-case/SyncNoDispatchUseCase\";\nconst sinon = require(\"sinon\");\n@@ -161,7 +162,49 @@ describe(\"Context\", function() {\nstoreGroup.emitChange();\n});\n});\n+ describe(\"#onWillNotExecuteEachUseCase\", () => {\n+ it(\"should be called when UseCase#shouldExecute() return false\", done => {\n+ const dispatcher = new Dispatcher();\n+ const appContext = new Context({\n+ dispatcher,\n+ store: createStore({ name: \"test\" })\n+ });\n+ const notExecuteUseCase = new NotExecuteUseCase();\n+ // then\n+ appContext.events.onWillNotExecuteEachUseCase((payload, meta) => {\n+ assert.ok(Array.isArray(payload.args));\n+ assert.ok(typeof meta.timeStamp === \"number\");\n+ assert.equal(meta.useCase, notExecuteUseCase);\n+ assert.equal(meta.dispatcher, dispatcher);\n+ assert.equal(meta.parentUseCase, null);\n+ assert.equal(meta.isUseCaseFinished, true);\n+ done();\n+ });\n+ // when\n+ appContext.useCase(notExecuteUseCase).execute();\n+ });\n+ });\ndescribe(\"#onWillExecuteEachUseCase\", function() {\n+ it(\"should not called onWillNotExecuteEachUseCase\", function() {\n+ const dispatcher = new Dispatcher();\n+ const appContext = new Context({\n+ dispatcher,\n+ store: createStore({ name: \"test\" })\n+ });\n+ const testUseCase = new TestUseCase();\n+ // then\n+ let isOnWillNotExecuteEachUseCaseCalled = false;\n+ appContext.events.onWillNotExecuteEachUseCase((payload, meta) => {\n+ isOnWillNotExecuteEachUseCaseCalled = true;\n+ });\n+ // when\n+ return appContext\n+ .useCase(testUseCase)\n+ .execute()\n+ .then(() => {\n+ assert.ok(!isOnWillNotExecuteEachUseCaseCalled, \"onWillNotExecuteEachUseCase should not called\");\n+ });\n+ });\nit(\"should called before UseCase will execute\", function(done) {\nconst dispatcher = new Dispatcher();\nconst appContext = new Context({\n@@ -372,6 +415,9 @@ describe(\"Context\", function() {\ncontext.events.onEndTransaction(() => {\ndoneNotCall();\n});\n+ context.events.onWillNotExecuteEachUseCase(() => {\n+ doneNotCall();\n+ });\ncontext.events.onWillExecuteEachUseCase(() => {\ndoneNotCall();\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/UseCaseExecutor-test.js", "new_path": "packages/almin/test/UseCaseExecutor-test.js", "diff": "@@ -209,6 +209,29 @@ describe(\"UseCaseExecutor\", function() {\n}\n}\n+ const dispatcher = new Dispatcher();\n+ const executor = new UseCaseExecutorImpl({\n+ useCase: new TestUseCase(),\n+ dispatcher\n+ });\n+ return executor.execute().then(() => {\n+ assert.deepEqual(called, [\"shouldExecute\"]);\n+ });\n+ });\n+ it(\"should call onWillNotExecuteEachUseCase handler\", function() {\n+ const called = [];\n+\n+ class TestUseCase extends UseCase {\n+ shouldExecute() {\n+ called.push(\"shouldExecute\");\n+ return false;\n+ }\n+\n+ execute() {\n+ called.push(\"execute\");\n+ }\n+ }\n+\nconst dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new TestUseCase(),\n" } ]
TypeScript
MIT License
almin/almin
feat(almin): Add "onWillNotExecuteEachUseCase" to LifeCycleEventHub
19,400
25.11.2017 17:10:34
-32,400
749c22e29aa943dfccef9c922401b78a204df8da
docs(UseCase): add onWillNotExecuteEachUseCase
[ { "change_type": "MODIFY", "old_path": "docs/tips/usecase-lifecycle.md", "new_path": "docs/tips/usecase-lifecycle.md", "diff": "@@ -11,6 +11,7 @@ For more information about logging, see [Logging tips](./logging.md).\n|--------------------------|----------------------------------------|\n| onBeginTransaction | A transaction begin |\n| onEndTransaction | A transaction end |\n+| onWillNotExecuteEachUseCase | A UseCase will not Execute |\n| onWillExecuteEachUseCase | Each UseCase will Execute |\n| onDispatch @1 | UseCase call `this.dispatch(payload)` |\n| onErrorDispatch @1 | UseCase call `this.throwError(new Error())` |\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/index.ts", "new_path": "packages/almin/src/index.ts", "diff": "@@ -12,6 +12,7 @@ export { StoreChangedPayload } from \"./payload/StoreChangedPayload\";\nexport { ErrorPayload } from \"./payload/ErrorPayload\";\nexport { TransactionBeganPayload } from \"./payload/TransactionBeganPayload\";\nexport { TransactionEndedPayload } from \"./payload/TransactionEndedPayload\";\n+export { WillNotExecutedPayload } from \"./payload/WillNotExecutedPayload\";\nexport { WillExecutedPayload } from \"./payload/WillExecutedPayload\";\nexport { DidExecutedPayload } from \"./payload/DidExecutedPayload\";\nexport { CompletedPayload } from \"./payload/CompletedPayload\";\n" } ]
TypeScript
MIT License
almin/almin
docs(UseCase): add onWillNotExecuteEachUseCase
19,400
25.11.2017 19:14:24
-32,400
d9e6a9dcafbbc0b025c2ec257310bb73bfa18c57
feat(almin-logger): Support "WillNotExecutedPayload"
[ { "change_type": "MODIFY", "old_path": "packages/almin-logger/src/AsyncLogger.ts", "new_path": "packages/almin-logger/src/AsyncLogger.ts", "diff": "@@ -19,7 +19,8 @@ import {\nTransactionEndedPayload,\nUseCase,\nUseCaseLike,\n- WillExecutedPayload\n+ WillExecutedPayload,\n+ WillNotExecutedPayload\n} from \"almin\";\nimport { MapLike } from \"map-like\";\n// FIXME: Almin 0.12 support pull-based Store\n@@ -49,6 +50,10 @@ const tryGetState = (store: StoreLike) => {\n* CUseCase Complete\n* AUseCase Complete\n*\n+ * -----\n+ *\n+ * AUseCase will not execute\n+ *\n*/\nexport default class AsyncLogger extends EventEmitter {\nprivate useCaseLogGroupMap: MapLike<UseCaseLike, LogGroup>;\n@@ -144,6 +149,39 @@ export default class AsyncLogger extends EventEmitter {\n}\nthis._transactionMap.delete(meta.transaction.id);\n};\n+ const onWillNptExecuteEachUseCase = (payload: WillNotExecutedPayload, meta: DispatcherPayloadMeta) => {\n+ const useCase = meta.useCase;\n+ if (!useCase) {\n+ return;\n+ }\n+ const parentUseCase =\n+ meta.parentUseCase !== useCase && meta.parentUseCase instanceof UseCase ? meta.parentUseCase : null;\n+ const parentSuffix = parentUseCase ? ` <- ${parentUseCase.name}` : \"\";\n+ const useCaseName = useCase ? useCase.name : \"<no-name>\";\n+ const title = `${useCaseName}${parentSuffix}`;\n+ const args = payload.args.length && payload.args.length > 0 ? payload.args : [undefined];\n+ const log = [`${useCaseName} not execute:`].concat(args);\n+ const useCases = this.useCaseLogGroupMap.keys();\n+ const existWorkingUseCase = useCases.length !== 0;\n+ if (existWorkingUseCase) {\n+ const logGroup = this.useCaseLogGroupMap.get(useCase);\n+ if (!logGroup) {\n+ return;\n+ }\n+ logGroup.addChunk(\n+ new LogChunk({\n+ log: [log],\n+ payload,\n+ useCase: meta.useCase,\n+ timeStamp: meta.timeStamp\n+ })\n+ );\n+ } else {\n+ // immediately dump log\n+ const logGroup = new LogGroup({ title, useCaseName: useCaseName });\n+ this.printLogger.printLogGroup(logGroup);\n+ }\n+ };\n/**\n* @param {WillExecutedPayload} payload\n* @param {DispatcherPayloadMeta} meta\n@@ -364,6 +402,9 @@ export default class AsyncLogger extends EventEmitter {\ncontext.events.onCompleteEachUseCase(onCompleteUseCase),\ncontext.events.onErrorDispatch(onErrorHandler)\n];\n+ if (context.events.onWillNotExecuteEachUseCase) {\n+ this._releaseHandlers.push(context.events.onWillNotExecuteEachUseCase(onWillNptExecuteEachUseCase));\n+ }\n}\nstopLogging() {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-logger/test/AsyncLogger-test.js", "new_path": "packages/almin-logger/test/AsyncLogger-test.js", "diff": "\"use strict\";\nconst assert = require(\"assert\");\nimport {\n- Context,\n- Store,\n- Dispatcher,\nCompletedPayload,\n+ Context,\nDidExecutedPayload,\n+ Dispatcher,\nErrorPayload,\n+ Store,\nWillExecutedPayload\n} from \"almin\";\n+import AlminLogger from \"../src/AlminLogger\";\nimport AsyncLogger from \"../src/AsyncLogger\";\nimport { LogGroup } from \"../src/log/LogGroup\";\n-import AlminLogger from \"../src/AlminLogger\";\nimport ConsoleMock from \"./helper/ConsoleMock\";\n-import NoDispatchUseCase from \"./usecase/NoDispatchUseCase\";\n+import { createStore } from \"./store/create-store\";\n+import DispatchUseCase from \"./usecase/DispatchUseCase\";\nimport ErrorUseCase from \"./usecase/ErrorUseCase\";\n+import { ParentUseCase } from \"./usecase/NestingUseCase\";\n+import NoDispatchUseCase from \"./usecase/NoDispatchUseCase\";\n+import { NotExecuteUseCase } from \"./usecase/NotExecuteUseCase\";\nimport WrapUseCase from \"./usecase/WrapUseCase\";\n-import DispatchUseCase from \"./usecase/DispatchUseCase\";\n-import { ParentUseCase, ChildUseCase } from \"./usecase/NestingUseCase\";\n-import { createStore } from \"./store/create-store\";\ndescribe(\"AsyncLogger\", function() {\nit(\"can start and stop\", () => {\n@@ -285,6 +286,41 @@ describe(\"AsyncLogger\", function() {\n});\n});\n});\n+\n+ it(\"should log willNotExecute event\", function() {\n+ const consoleMock = ConsoleMock.create();\n+ const logger = new AsyncLogger({\n+ console: consoleMock\n+ });\n+ const dispatcher = new Dispatcher();\n+ const store = createStore();\n+ const context = new Context({\n+ store,\n+ dispatcher\n+ });\n+ const useCase = new NotExecuteUseCase();\n+ logger.startLogging(context);\n+ // yet not called\n+ assert(!consoleMock.groupCollapsed.called);\n+ assert(!consoleMock.log.called);\n+ // Then\n+ let actualLogGroup = null;\n+ logger.on(AlminLogger.Events.output, function(logGroup) {\n+ actualLogGroup = logGroup;\n+ });\n+ // When\n+ return context\n+ .useCase(useCase)\n+ .execute()\n+ .then(() => {\n+ assert(consoleMock.groupCollapsed.called);\n+ const expectOutput = `NotExecuteUseCase`;\n+ const isContain = consoleMock.log.calls.some(call => {\n+ return call.arg && call.arg.indexOf(expectOutput) !== -1;\n+ });\n+ assert.ok(isContain, `${expectOutput} is not found.`);\n+ });\n+ });\nit(\"should log dispatch event\", function() {\nconst consoleMock = ConsoleMock.create();\nconst logger = new AsyncLogger({\n" } ]
TypeScript
MIT License
almin/almin
feat(almin-logger): Support "WillNotExecutedPayload"
19,400
17.12.2017 00:15:39
-32,400
5cde0ce11d2f0cd6d4147308bfcedc43ee514b41
chore(website): install before build
[ { "change_type": "MODIFY", "old_path": "lerna.json", "new_path": "lerna.json", "diff": "\"lerna\": \"2.5.1\",\n\"commands\": {\n\"publish\": {\n- \"concurrency\": 1,\n- \"ignore\": [\n- \"example-*\",\n- \"*.md\"\n- ]\n+ \"concurrency\": 1\n}\n},\n\"packages\": [\n\"packages/*\",\n\"packages/almin-logger/examples\",\n\"examples/*\",\n- \"perf/*\",\n- \"website\"\n+ \"perf/*\"\n],\n\"npmClient\": \"yarn\",\n\"version\": \"independent\"\n" }, { "change_type": "MODIFY", "old_path": "tools/push-to-github-io.sh", "new_path": "tools/push-to-github-io.sh", "diff": "@@ -6,7 +6,7 @@ declare parentDir=$(cd $(dirname $(cd $(dirname $0);pwd));pwd)\ndeclare repositoryUrl=\"git@github.com:almin/almin.github.io.git\"\ndeclare toBranch=\"master\"\ndeclare commitMessage=\"Deploy docusaurus build [skip ci]\"\n-declare commands=\"npm run build:docs\"\n+declare websiteDir=\"${parentDir}/website/\"\ndeclare distDir=\"${parentDir}/website/build/almin\"\nif [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]\n@@ -53,8 +53,11 @@ git clone ${repositoryUrl} \"${tmpDir}/almin.github.io\"\necho \"Remove files\"\nremove_files_in_dir \"${tmpDir}/almin.github.io\"\n# execute command\n+echo \"Install\"\n+cd \"${websiteDir}\"\n+yarn install\necho \"Update content\"\n-execute \"$commands\"\n+yarn run build\necho \"Copy files\"\ncp -Rf \"${distDir}/\"* \"${tmpDir}/almin.github.io/\"\necho \"Commit and push\"\n" } ]
TypeScript
MIT License
almin/almin
chore(website): install before build
19,400
17.12.2017 01:13:16
-32,400
b8b1cab8ac64d5084f7a2b608f23e85788e2bfdb
chore(website): add br
[ { "change_type": "MODIFY", "old_path": "website/pages/en/index.js", "new_path": "website/pages/en/index.js", "diff": "@@ -137,7 +137,7 @@ Now, We can implement web app with [Flux](https://github.com/facebook/flux),\n[Redux](https://github.com/reactjs/redux), [MobX](https://github.com/mobxjs/mobx) etc.\nBut, We often hear a story like following:\n-> The control flow of *[[LIBRARY]]* is cool.\n+> The control flow of *[[LIBRARY]]* is cool.<br>\n> But how to implement domain logic?\nAlmin aim to help you focus domain logic on your application.\n" } ]
TypeScript
MIT License
almin/almin
chore(website): add br
19,400
17.12.2017 01:13:31
-32,400
7487091318d1a35e72a78038904a9edec85aa854
chore(website): add !
[ { "change_type": "MODIFY", "old_path": "website/pages/en/index.js", "new_path": "website/pages/en/index.js", "diff": "@@ -137,7 +137,7 @@ Now, We can implement web app with [Flux](https://github.com/facebook/flux),\n[Redux](https://github.com/reactjs/redux), [MobX](https://github.com/mobxjs/mobx) etc.\nBut, We often hear a story like following:\n-> The control flow of *[[LIBRARY]]* is cool.<br>\n+> The control flow of *[[LIBRARY]]* is cool!<br>\n> But how to implement domain logic?\nAlmin aim to help you focus domain logic on your application.\n" } ]
TypeScript
MIT License
almin/almin
chore(website): add !
19,400
21.01.2018 20:24:43
-32,400
9fc41e1831db0daab1d3a66bb118afa07eece5f8
test(almin): Convert UseCaseExecutor tests to TypeScript
[ { "change_type": "RENAME", "old_path": "packages/almin/test/UseCaseExecutor-test.js", "new_path": "packages/almin/test/UseCaseExecutor-test.ts", "diff": "// LICENSE : MIT\n\"use strict\";\n-const sinon = require(\"sinon\");\n-const assert = require(\"assert\");\n+import * as assert from \"assert\";\n+import sinon = require(\"sinon\");\nimport { SyncNoDispatchUseCase } from \"./use-case/SyncNoDispatchUseCase\";\n-import { Dispatcher } from \"../src/Dispatcher\";\n-import { UseCase } from \"../src/UseCase\";\n+import { Dispatcher, Payload, UseCase } from \"../src/\";\nimport { UseCaseExecutorImpl } from \"../src/UseCaseExecutor\";\nimport { CallableUseCase } from \"./use-case/CallableUseCase\";\nimport { ThrowUseCase } from \"./use-case/ThrowUseCase\";\n@@ -14,7 +13,7 @@ import { isCompletedPayload } from \"../src/payload/CompletedPayload\";\ndescribe(\"UseCaseExecutor\", function() {\ndescribe(\"#executor\", () => {\n- let consoleErrorStub = null;\n+ let consoleErrorStub: any = null;\nbeforeEach(() => {\nconsoleErrorStub = sinon.stub(console, \"error\");\n});\n@@ -25,7 +24,8 @@ describe(\"UseCaseExecutor\", function() {\nconst dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new ThrowUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\nreturn executor.executor(useCase => useCase.execute()).then(\n() => {\n@@ -40,9 +40,10 @@ describe(\"UseCaseExecutor\", function() {\nconst dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new SyncNoDispatchUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\n- return executor.executor(\" THIS IS WRONG \").then(\n+ return executor.executor(\" THIS IS WRONG \" as any).then(\n() => {\nthrow new Error(\"SHOULD NOT CALLED\");\n},\n@@ -62,15 +63,10 @@ describe(\"UseCaseExecutor\", function() {\nconst callableUseCase = new CallableUseCase();\nconst executor = new UseCaseExecutorImpl({\nuseCase: callableUseCase,\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\n- return executor\n- .executor(useCase =>\n- useCase.execute({\n- type: \"type\"\n- })\n- )\n- .then(\n+ return executor.executor(useCase => useCase.execute()).then(\n() => {\nassert(callableUseCase.isExecuted, \"UseCase#execute should be called\");\n},\n@@ -83,7 +79,8 @@ describe(\"UseCaseExecutor\", function() {\nconst dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new SyncNoDispatchUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\nreturn executor.executor(useCase => {\nassert(useCase instanceof UseCase === false, \"useCase is wrapped object. it is not UseCase\");\n@@ -96,7 +93,8 @@ describe(\"UseCaseExecutor\", function() {\nconst callableUseCase = new CallableUseCase();\nconst executor = new UseCaseExecutorImpl({\nuseCase: callableUseCase,\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\nexecutor\n.executor(useCase => {\n@@ -115,7 +113,8 @@ describe(\"UseCaseExecutor\", function() {\nconst dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new SyncNoDispatchUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\nreturn executor\n.executor(useCase => {\n@@ -139,16 +138,17 @@ describe(\"UseCaseExecutor\", function() {\nconst dispatcher = new Dispatcher();\nclass SyncUseCase extends UseCase {\n- execute(payload) {\n+ execute(payload: Payload) {\nthis.dispatch(payload);\n}\n}\n- const callStack = [];\n+ const callStack: string[] = [];\nconst expectedCallStack = [\"will\", \"dispatch\", \"did\", \"complete\"];\nconst executor = new UseCaseExecutorImpl({\nuseCase: new SyncUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\n// then\nexecutor.onDispatch(payload => {\n@@ -171,7 +171,7 @@ describe(\"UseCaseExecutor\", function() {\ndescribe(\"#shouldExecute\", () => {\ndescribe(\"when implemented shouldExecute()\", function() {\nit(\"should called before execute\", function() {\n- const called = [];\n+ const called: string[] = [];\nclass TestUseCase extends UseCase {\nshouldExecute() {\n@@ -187,7 +187,8 @@ describe(\"UseCaseExecutor\", function() {\nconst dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new TestUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\nreturn executor.execute().then(() => {\nassert.deepEqual(called, [\"shouldExecute\", \"execute\"]);\n@@ -196,7 +197,7 @@ describe(\"UseCaseExecutor\", function() {\n});\ndescribe(\"when shouldExecute() => false\", function() {\nit(\"should not call UseCase#execute\", function() {\n- const called = [];\n+ const called: string[] = [];\nclass TestUseCase extends UseCase {\nshouldExecute() {\n@@ -212,14 +213,15 @@ describe(\"UseCaseExecutor\", function() {\nconst dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new TestUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\nreturn executor.execute().then(() => {\nassert.deepEqual(called, [\"shouldExecute\"]);\n});\n});\nit(\"should call onWillNotExecuteEachUseCase handler\", function() {\n- const called = [];\n+ const called: string[] = [];\nclass TestUseCase extends UseCase {\nshouldExecute() {\n@@ -235,7 +237,8 @@ describe(\"UseCaseExecutor\", function() {\nconst dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new TestUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\nreturn executor.execute().then(() => {\nassert.deepEqual(called, [\"shouldExecute\"]);\n@@ -244,11 +247,12 @@ describe(\"UseCaseExecutor\", function() {\n});\ndescribe(\"when shouldExecute() => undefined\", function() {\nit(\"should throw error\", function() {\n- const called = [];\n+ const called: string[] = [];\nclass TestUseCase extends UseCase {\nshouldExecute() {\ncalled.push(\"shouldExecute\");\n+ return undefined as any;\n}\nexecute() {\n@@ -259,7 +263,8 @@ describe(\"UseCaseExecutor\", function() {\nconst dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new TestUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\nreturn executor.execute().then(\n() => {\n@@ -278,7 +283,8 @@ describe(\"UseCaseExecutor\", function() {\nconst dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new ThrowUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\nreturn executor.execute().then(\n() => {\n@@ -292,7 +298,7 @@ describe(\"UseCaseExecutor\", function() {\ndescribe(\"when UseCase is sync\", function() {\nit(\"execute is called\", function(done) {\n// given\n- const expectedPayload = {\n+ const ExpectedPayload = {\ntype: \"SyncUseCase\",\nvalue: \"value\"\n};\n@@ -300,7 +306,7 @@ describe(\"UseCaseExecutor\", function() {\nclass SyncUseCase extends UseCase {\n// 2\n- execute(payload) {\n+ execute(payload: typeof ExpectedPayload) {\n// 3\nthis.dispatch(payload);\n}\n@@ -309,23 +315,24 @@ describe(\"UseCaseExecutor\", function() {\n// when\nconst executor = new UseCaseExecutorImpl({\nuseCase: new SyncUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\n// 4\n- executor.onDispatch(({ type, value }) => {\n- if (type === expectedPayload.type) {\n- assert.equal(value, expectedPayload.value);\n+ executor.onDispatch((payload: any) => {\n+ if (payload.type === ExpectedPayload.type) {\n+ assert.equal(payload.value, ExpectedPayload.value);\ndone();\n}\n});\n// then\n- executor.execute(expectedPayload); // 1\n+ executor.execute(ExpectedPayload); // 1\n});\n});\ndescribe(\"when UseCase is async\", function() {\nit(\"execute is called\", function() {\n// given\n- const expectedPayload = {\n+ const ExpectedPayload = {\ntype: \"SyncUseCase\",\nvalue: \"value\"\n};\n@@ -333,7 +340,7 @@ describe(\"UseCaseExecutor\", function() {\nclass AsyncUseCase extends UseCase {\n// 2\n- execute(payload) {\n+ execute(payload: Payload) {\nreturn Promise.resolve().then(() => {\n// 3\nthis.dispatch(payload);\n@@ -347,20 +354,21 @@ describe(\"UseCaseExecutor\", function() {\n// when\nconst executor = new UseCaseExecutorImpl({\nuseCase: new AsyncUseCase(),\n- dispatcher\n+ dispatcher,\n+ parent: null\n});\nexecutor.onDispatch((payload, meta) => {\nif (isDidExecutedPayload(payload) && meta.useCase instanceof AsyncUseCase) {\nisCalledDidExecuted = true;\n} else if (isCompletedPayload(payload) && meta.useCase instanceof AsyncUseCase) {\nisCalledCompleted = true;\n- } else if (payload.type === expectedPayload.type) {\n- assert.equal(payload.value, expectedPayload.value);\n+ } else if (payload.type === ExpectedPayload.type) {\n+ assert.equal((payload as typeof ExpectedPayload).value, ExpectedPayload.value);\nisCalledUseCase = true;\n}\n});\n// then\n- return executor.execute(expectedPayload).then(() => {\n+ return executor.execute(ExpectedPayload).then(() => {\nassert(isCalledUseCase);\nassert(isCalledDidExecuted);\nassert(isCalledCompleted);\n" }, { "change_type": "RENAME", "old_path": "packages/almin/test/use-case/ErrorUseCase.js", "new_path": "packages/almin/test/use-case/ErrorUseCase.ts", "diff": "// LICENSE : MIT\n\"use strict\";\n-import { UseCase } from \"../../src/UseCase\";\n+import { UseCase } from \"../../src\";\nexport class ErrorUseCase extends UseCase {\nexecute() {\nreturn Promise.reject(new Error(\"error\"));\n" }, { "change_type": "RENAME", "old_path": "packages/almin/test/use-case/NestingUseCase.js", "new_path": "packages/almin/test/use-case/NestingUseCase.ts", "diff": "// LICENSE : MIT\n\"use strict\";\n-import { UseCase } from \"../../src/UseCase\";\n+import { UseCase } from \"../../src\";\n// Parent -> ChildUseCase\nexport class ParentUseCase extends UseCase {\n+ private childUseCase: ChildUseCase;\nconstructor() {\nsuper();\nthis.childUseCase = new ChildUseCase();\n" }, { "change_type": "RENAME", "old_path": "packages/almin/test/use-case/NotExecuteUseCase.js", "new_path": "packages/almin/test/use-case/NotExecuteUseCase.ts", "diff": "" }, { "change_type": "RENAME", "old_path": "packages/almin/test/use-case/ThrowUseCase.js", "new_path": "packages/almin/test/use-case/ThrowUseCase.ts", "diff": "// LICENSE : MIT\n\"use strict\";\n-import { UseCase } from \"../../src/UseCase\";\n+import { UseCase } from \"../../src\";\nexport class ThrowUseCase extends UseCase {\nexecute() {\n// throw Error insteadof returning rejected promise\n" } ]
TypeScript
MIT License
almin/almin
test(almin): Convert UseCaseExecutor tests to TypeScript
19,400
21.01.2018 22:17:15
-32,400
71313e6e1bc6dfcdcc569211548f828d4cf80bee
test(almin): use ts-node-test-register
[ { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"lint:fix\": \"npm-run-all -p lint:*:fix\",\n\"lint:js\": \"eslint --config ../../.eslintrc.json --cache test/\",\n\"lint:js:fix\": \"eslint --fix --config ../../.eslintrc.json --cache test/\",\n- \"test\": \"run-s build:test lint test:js\",\n- \"test:js\": \"cross-env NODE_ENV=development mocha out/test\",\n+ \"test\": \"run-s lint test:js\",\n+ \"test:js\": \"cross-env NODE_ENV=development mocha \\\"test/**/*.{js,ts}\\\"\",\n\"test:saucelabs\": \"npm run build:test && zuul -- out/test/*-test.js\",\n\"test:browser\": \"npm run build:test && zuul --local 8080 --ui mocha-bdd -- out/test/*-test.js\",\n- \"posttest\": \"rimraf out/\",\n+ \"posttest\": \"npm run clean\",\n\"presize\": \"npm-run-all -s clean build\",\n\"size\": \"size-limit\",\n\"ci\": \"npm test && npm run size\",\n\"sinon\": \"^2.3.8\",\n\"size-limit\": \"^0.14.0\",\n\"source-map-support\": \"^0.4.15\",\n+ \"ts-node\": \"^4.1.0\",\n+ \"ts-node-test-register\": \"^1.0.1\",\n\"typescript\": \"~2.6.2\",\n\"zuul\": \"^3.10.1\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/mocha.opts", "new_path": "packages/almin/test/mocha.opts", "diff": "--recursive\n--require env-development\n+--require ts-node-test-register\n--require source-map-support/register\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -8791,6 +8791,12 @@ try-resolve@^1.0.1:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/try-resolve/-/try-resolve-1.0.1.tgz#cfde6fabd72d63e5797cfaab873abbe8e700e912\"\n+ts-node-test-register@^1.0.1:\n+ version \"1.0.1\"\n+ resolved \"https://registry.yarnpkg.com/ts-node-test-register/-/ts-node-test-register-1.0.1.tgz#2496000aabcaca96973ece6164ffd6f1c2f6a82d\"\n+ dependencies:\n+ read-pkg \"^3.0.0\"\n+\nts-node@^4.1.0:\nversion \"4.1.0\"\nresolved \"https://registry.yarnpkg.com/ts-node/-/ts-node-4.1.0.tgz#36d9529c7b90bb993306c408cd07f7743de20712\"\n" } ]
TypeScript
MIT License
almin/almin
test(almin): use ts-node-test-register
19,400
22.01.2018 15:24:10
-32,400
f8d402ddc620e80c35fa1c30e766a90c10810aa0
fix(almin): fix to call didExecute when UseCase throw error fix
[ { "change_type": "MODIFY", "old_path": "packages/almin/test/UseCaseExecutor-test.ts", "new_path": "packages/almin/test/UseCaseExecutor-test.ts", "diff": "@@ -10,6 +10,11 @@ import { ThrowUseCase } from \"./use-case/ThrowUseCase\";\nimport { isWillExecutedPayload } from \"../src/payload/WillExecutedPayload\";\nimport { isDidExecutedPayload } from \"../src/payload/DidExecutedPayload\";\nimport { isCompletedPayload } from \"../src/payload/CompletedPayload\";\n+import { isErrorPayload } from \"../src/payload/ErrorPayload\";\n+\n+const shouldNotCalled = () => {\n+ throw new Error(\"This should not be called\");\n+};\ndescribe(\"UseCaseExecutor\", function() {\ndescribe(\"#executor\", () => {\n@@ -128,6 +133,35 @@ describe(\"UseCaseExecutor\", function() {\n});\n});\n});\n+ describe(\"when UseCase throw error\", function() {\n+ // Test: https://github.com/almin/almin/issues/310#issuecomment-359249751\n+ it(\"dispatch will -> error -> did -> complete\", function() {\n+ const callStack: string[] = [];\n+ const expectedCallStack = [\"will\", \"error\", \"did\", \"complete\"];\n+ const dispatcher = new Dispatcher();\n+ const executor = new UseCaseExecutorImpl({\n+ useCase: new ThrowUseCase(),\n+ dispatcher,\n+ parent: null\n+ });\n+ // then\n+ executor.onDispatch(payload => {\n+ if (isWillExecutedPayload(payload)) {\n+ callStack.push(\"will\");\n+ } else if (isDidExecutedPayload(payload)) {\n+ callStack.push(\"did\");\n+ } else if (isCompletedPayload(payload)) {\n+ callStack.push(\"complete\");\n+ } else if (isErrorPayload(payload)) {\n+ callStack.push(\"error\");\n+ }\n+ });\n+ // when\n+ return executor.execute().catch(() => {\n+ assert.deepStrictEqual(callStack, expectedCallStack);\n+ });\n+ });\n+ });\ndescribe(\"when UseCase is successful completion\", function() {\nit(\"dispatch will -> did\", function() {\n// given\n@@ -216,9 +250,12 @@ describe(\"UseCaseExecutor\", function() {\ndispatcher,\nparent: null\n});\n- return executor.execute().then(() => {\n+\n+ const notExpected = executor.execute().then(shouldNotCalled, shouldNotCalled);\n+ const expected = Promise.resolve().then(() => {\nassert.deepEqual(called, [\"shouldExecute\"]);\n});\n+ return Promise.race([notExpected, expected]);\n});\nit(\"should call onWillNotExecuteEachUseCase handler\", function() {\nconst called: string[] = [];\n@@ -240,9 +277,11 @@ describe(\"UseCaseExecutor\", function() {\ndispatcher,\nparent: null\n});\n- return executor.execute().then(() => {\n+ const notExpected = executor.execute().then(shouldNotCalled, shouldNotCalled);\n+ const expected = Promise.resolve().then(() => {\nassert.deepEqual(called, [\"shouldExecute\"]);\n});\n+ return Promise.race([notExpected, expected]);\n});\n});\ndescribe(\"when shouldExecute() => undefined\", function() {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/mocha.opts", "new_path": "packages/almin/test/mocha.opts", "diff": "--recursive\n--require env-development\n--require ts-node-test-register\n---require source-map-support/register\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): fix to call didExecute when UseCase throw error fix #310
19,400
22.01.2018 15:40:14
-32,400
3004a3d56c3a544a46704722f95cc75ac13846d2
fix(almin-logger): fix test case
[ { "change_type": "MODIFY", "old_path": "packages/almin-logger/test/AsyncLogger-test.js", "new_path": "packages/almin-logger/test/AsyncLogger-test.js", "diff": "@@ -22,6 +22,9 @@ import NoDispatchUseCase from \"./usecase/NoDispatchUseCase\";\nimport { NotExecuteUseCase } from \"./usecase/NotExecuteUseCase\";\nimport WrapUseCase from \"./usecase/WrapUseCase\";\n+const shouldNotCalled = () => {\n+ throw new Error(\"This should not be called\");\n+};\ndescribe(\"AsyncLogger\", function() {\nit(\"can start and stop\", () => {\nconst consoleMock = ConsoleMock.create();\n@@ -309,10 +312,11 @@ describe(\"AsyncLogger\", function() {\nactualLogGroup = logGroup;\n});\n// When\n- return context\n+ const unExpectedPromise = context\n.useCase(useCase)\n.execute()\n- .then(() => {\n+ .then(shouldNotCalled, shouldNotCalled);\n+ const expected = Promise.resolve().then(() => {\nassert(consoleMock.groupCollapsed.called);\nconst expectOutput = `NotExecuteUseCase`;\nconst isContain = consoleMock.log.calls.some(call => {\n@@ -320,6 +324,7 @@ describe(\"AsyncLogger\", function() {\n});\nassert.ok(isContain, `${expectOutput} is not found.`);\n});\n+ return Promise.race([unExpectedPromise, expected]);\n});\nit(\"should log dispatch event\", function() {\nconst consoleMock = ConsoleMock.create();\n" } ]
TypeScript
MIT License
almin/almin
fix(almin-logger): fix test case
19,400
22.01.2018 15:40:32
-32,400
b160b847e699e41ce0c1f0d3b1f80c0b0e8c213c
chore(almin): use deepEqual for browser
[ { "change_type": "MODIFY", "old_path": "packages/almin/test/UseCaseExecutor-test.ts", "new_path": "packages/almin/test/UseCaseExecutor-test.ts", "diff": "@@ -158,7 +158,7 @@ describe(\"UseCaseExecutor\", function() {\n});\n// when\nreturn executor.execute().catch(() => {\n- assert.deepStrictEqual(callStack, expectedCallStack);\n+ assert.deepEqual(callStack, expectedCallStack);\n});\n});\n});\n" } ]
TypeScript
MIT License
almin/almin
chore(almin): use deepEqual for browser
19,400
22.01.2018 19:28:17
-32,400
cd888ce827416f7593d6504e11ddb3930721a357
refactor(almin): refactor UseCaseExecutor
[ { "change_type": "MODIFY", "old_path": "packages/almin-logger/test/AsyncLogger-test.js", "new_path": "packages/almin-logger/test/AsyncLogger-test.js", "diff": "@@ -22,9 +22,6 @@ import NoDispatchUseCase from \"./usecase/NoDispatchUseCase\";\nimport { NotExecuteUseCase } from \"./usecase/NotExecuteUseCase\";\nimport WrapUseCase from \"./usecase/WrapUseCase\";\n-const shouldNotCalled = () => {\n- throw new Error(\"This should not be called\");\n-};\ndescribe(\"AsyncLogger\", function() {\nit(\"can start and stop\", () => {\nconst consoleMock = ConsoleMock.create();\n@@ -312,11 +309,10 @@ describe(\"AsyncLogger\", function() {\nactualLogGroup = logGroup;\n});\n// When\n- const unExpectedPromise = context\n+ return context\n.useCase(useCase)\n.execute()\n- .then(shouldNotCalled, shouldNotCalled);\n- const expected = Promise.resolve().then(() => {\n+ .then(() => {\nassert(consoleMock.groupCollapsed.called);\nconst expectOutput = `NotExecuteUseCase`;\nconst isContain = consoleMock.log.calls.some(call => {\n@@ -324,7 +320,6 @@ describe(\"AsyncLogger\", function() {\n});\nassert.ok(isContain, `${expectOutput} is not found.`);\n});\n- return Promise.race([unExpectedPromise, expected]);\n});\nit(\"should log dispatch event\", function() {\nconst consoleMock = ConsoleMock.create();\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/UseCaseExecutor-test.ts", "new_path": "packages/almin/test/UseCaseExecutor-test.ts", "diff": "@@ -12,10 +12,6 @@ import { isDidExecutedPayload } from \"../src/payload/DidExecutedPayload\";\nimport { isCompletedPayload } from \"../src/payload/CompletedPayload\";\nimport { isErrorPayload } from \"../src/payload/ErrorPayload\";\n-const shouldNotCalled = () => {\n- throw new Error(\"This should not be called\");\n-};\n-\ndescribe(\"UseCaseExecutor\", function() {\ndescribe(\"#executor\", () => {\nlet consoleErrorStub: any = null;\n@@ -48,11 +44,7 @@ describe(\"UseCaseExecutor\", function() {\ndispatcher,\nparent: null\n});\n- return executor.executor(\" THIS IS WRONG \" as any).then(\n- () => {\n- throw new Error(\"SHOULD NOT CALLED\");\n- },\n- error => {\n+ return executor.executor(\" THIS IS WRONG \" as any).catch(error => {\nassert.ok(consoleErrorStub.called, \"should be called console.error\");\nconst warningMessage = consoleErrorStub.getCalls()[0].args[0];\nassert.ok(/executor.*? arguments should be function/.test(error.message));\n@@ -60,8 +52,7 @@ describe(\"UseCaseExecutor\", function() {\nwarningMessage,\n\"Warning(UseCase): executor argument should be function. But this argument is not function: \"\n);\n- }\n- );\n+ });\n});\nit(\"should accept executor(useCase => {}) function arguments\", () => {\nconst dispatcher = new Dispatcher();\n@@ -251,11 +242,9 @@ describe(\"UseCaseExecutor\", function() {\nparent: null\n});\n- const notExpected = executor.execute().then(shouldNotCalled, shouldNotCalled);\n- const expected = Promise.resolve().then(() => {\n+ return executor.execute().then(() => {\nassert.deepEqual(called, [\"shouldExecute\"]);\n});\n- return Promise.race([notExpected, expected]);\n});\nit(\"should call onWillNotExecuteEachUseCase handler\", function() {\nconst called: string[] = [];\n@@ -277,11 +266,10 @@ describe(\"UseCaseExecutor\", function() {\ndispatcher,\nparent: null\n});\n- const notExpected = executor.execute().then(shouldNotCalled, shouldNotCalled);\n- const expected = Promise.resolve().then(() => {\n+ // willNotExecute:true => resolve\n+ return executor.execute().then(() => {\nassert.deepEqual(called, [\"shouldExecute\"]);\n});\n- return Promise.race([notExpected, expected]);\n});\n});\ndescribe(\"when shouldExecute() => undefined\", function() {\n" } ]
TypeScript
MIT License
almin/almin
refactor(almin): refactor UseCaseExecutor
19,400
22.01.2018 20:01:36
-32,400
f6c447703f8c87a7f1436c1f406159e4814595e7
test(almin): add LifeCycle method order tests
[ { "change_type": "MODIFY", "old_path": "packages/almin/test/DispatcherPayloadMeta-test.js", "new_path": "packages/almin/test/DispatcherPayloadMeta-test.js", "diff": "@@ -6,7 +6,7 @@ import { CompletedPayload, Context, DidExecutedPayload } from \"../src/\";\nimport { Dispatcher } from \"../src/Dispatcher\";\nimport { createStore } from \"./helper/create-new-store\";\nimport { DispatchUseCase } from \"./use-case/DispatchUseCase\";\n-import { ErrorUseCase } from \"./use-case/ErrorUseCase\";\n+import { AsyncErrorUseCase } from \"./use-case/AsyncErrorUseCase\";\nimport { ParentUseCase } from \"./use-case/NestingUseCase\";\nimport { SyncNoDispatchUseCase } from \"./use-case/SyncNoDispatchUseCase\";\nimport { AsyncUseCase } from \"./use-case/AsyncUseCase\";\n@@ -140,7 +140,7 @@ describe(\"DispatcherPayloadMeta\", () => {\ndispatcher,\nstore: createStore({ name: \"test\" })\n});\n- const useCase = new ErrorUseCase();\n+ const useCase = new AsyncErrorUseCase();\nlet actualMeta = null;\ncontext.events.onErrorDispatch((payload, meta) => {\nactualMeta = meta;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/UseCaseExecutor-test.ts", "new_path": "packages/almin/test/UseCaseExecutor-test.ts", "diff": "@@ -44,7 +44,11 @@ describe(\"UseCaseExecutor\", function() {\ndispatcher,\nparent: null\n});\n- return executor.executor(\" THIS IS WRONG \" as any).catch(error => {\n+ return executor.executor(\" THIS IS WRONG \" as any).then(\n+ () => {\n+ throw new Error(\"SHOULD NOT CALLED\");\n+ },\n+ error => {\nassert.ok(consoleErrorStub.called, \"should be called console.error\");\nconst warningMessage = consoleErrorStub.getCalls()[0].args[0];\nassert.ok(/executor.*? arguments should be function/.test(error.message));\n@@ -52,7 +56,8 @@ describe(\"UseCaseExecutor\", function() {\nwarningMessage,\n\"Warning(UseCase): executor argument should be function. But this argument is not function: \"\n);\n- });\n+ }\n+ );\n});\nit(\"should accept executor(useCase => {}) function arguments\", () => {\nconst dispatcher = new Dispatcher();\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/almin/test/UseCaseLifeCycle-test.ts", "diff": "+/*\n+LifeCycle method order of call.\n+\n+| UseCase Type | Will | Did | Error | Complete | Return Promise |\n+| -------------------- | ---- | ---- | ----- | -------- | ----------------------------------- |\n+| Sync Success | 1 | 2 | -- | 3 | resolve(then) |\n+| Async Success | 1 | 2 | -- | 3 | resolve(then) |\n+| Sync Failure | 1 | 3 | 2 | 4 | reject(catch) |\n+| Async Failure | 1 | 2 | 3 | 4 | reject(catch) |\n+| ShouldExecute: false | -- | -- | -- | -- | resolve(then) - prevent memory leak |\n+\n+ */\n+import * as assert from \"assert\";\n+import { Context, Dispatcher } from \"../src\";\n+import { createStore } from \"./helper/create-new-store\";\n+import { NotExecuteUseCase } from \"./use-case/NotExecuteUseCase\";\n+import { SyncNoDispatchUseCase } from \"./use-case/SyncNoDispatchUseCase\";\n+import { AsyncUseCase } from \"./use-case/AsyncUseCase\";\n+import { AsyncErrorUseCase } from \"./use-case/AsyncErrorUseCase\";\n+import { ThrowUseCase } from \"./use-case/ThrowUseCase\";\n+\n+enum EventType {\n+ WillNot = \"WillNot\",\n+ Will = \"Will\",\n+ Did = \"Did\",\n+ Error = \"Error\",\n+ Complete = \"Complete\"\n+}\n+\n+const shouldNotCalled = () => {\n+ throw new Error(\"This should not be called\");\n+};\n+const createLogger = (context: Context<any>) => {\n+ const eventLog: EventType[] = [];\n+ context.events.onWillNotExecuteEachUseCase(() => {\n+ eventLog.push(EventType.WillNot);\n+ });\n+ context.events.onWillExecuteEachUseCase(() => {\n+ eventLog.push(EventType.Will);\n+ });\n+ context.events.onDidExecuteEachUseCase(() => {\n+ eventLog.push(EventType.Did);\n+ });\n+ context.events.onErrorDispatch(() => {\n+ eventLog.push(EventType.Error);\n+ });\n+ context.events.onCompleteEachUseCase(() => {\n+ eventLog.push(EventType.Complete);\n+ });\n+ return {\n+ getLog() {\n+ return eventLog;\n+ }\n+ };\n+};\n+describe(\"UseCaseLifeCycle\", () => {\n+ it(\"Sync Success\", () => {\n+ const context = new Context({\n+ dispatcher: new Dispatcher(),\n+ store: createStore({ name: \"test\" })\n+ });\n+ const logger = createLogger(context);\n+ return context\n+ .useCase(new SyncNoDispatchUseCase())\n+ .execute()\n+ .then(() => {\n+ assert.deepEqual(logger.getLog(), [EventType.Will, EventType.Did, EventType.Complete]);\n+ }, shouldNotCalled);\n+ });\n+ it(\"ASync Success\", () => {\n+ const context = new Context({\n+ dispatcher: new Dispatcher(),\n+ store: createStore({ name: \"test\" })\n+ });\n+ const logger = createLogger(context);\n+ return context\n+ .useCase(new AsyncUseCase())\n+ .execute()\n+ .then(() => {\n+ assert.deepEqual(logger.getLog(), [EventType.Will, EventType.Did, EventType.Complete]);\n+ }, shouldNotCalled);\n+ });\n+ it(\"Sync Failure\", () => {\n+ const context = new Context({\n+ dispatcher: new Dispatcher(),\n+ store: createStore({ name: \"test\" })\n+ });\n+ const logger = createLogger(context);\n+ return context\n+ .useCase(new ThrowUseCase())\n+ .execute()\n+ .then(shouldNotCalled, () => {\n+ assert.deepEqual(logger.getLog(), [EventType.Will, EventType.Error, EventType.Did, EventType.Complete]);\n+ });\n+ });\n+ it(\"ASync Failure\", () => {\n+ const context = new Context({\n+ dispatcher: new Dispatcher(),\n+ store: createStore({ name: \"test\" })\n+ });\n+ const logger = createLogger(context);\n+ return context\n+ .useCase(new AsyncErrorUseCase())\n+ .execute()\n+ .then(shouldNotCalled, () => {\n+ assert.deepEqual(logger.getLog(), [EventType.Will, EventType.Did, EventType.Error, EventType.Complete]);\n+ });\n+ });\n+ it(\"ShouldExecute() => false\", () => {\n+ const context = new Context({\n+ dispatcher: new Dispatcher(),\n+ store: createStore({ name: \"test\" })\n+ });\n+ const logger = createLogger(context);\n+ return context\n+ .useCase(new NotExecuteUseCase())\n+ .execute()\n+ .then(() => {\n+ assert.deepEqual(logger.getLog(), [EventType.WillNot]);\n+ }, shouldNotCalled);\n+ });\n+});\n" }, { "change_type": "RENAME", "old_path": "packages/almin/test/use-case/ErrorUseCase.ts", "new_path": "packages/almin/test/use-case/AsyncErrorUseCase.ts", "diff": "// LICENSE : MIT\n\"use strict\";\nimport { UseCase } from \"../../src\";\n-export class ErrorUseCase extends UseCase {\n+export class AsyncErrorUseCase extends UseCase {\nexecute() {\nreturn Promise.reject(new Error(\"error\"));\n}\n" } ]
TypeScript
MIT License
almin/almin
test(almin): add LifeCycle method order tests
19,400
22.01.2018 20:22:03
-32,400
6eba834e2136b3dd50875346145639ff9c56cc89
docs(almin): add comments
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -371,6 +371,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n}\n// Notes: proxyfiedUseCase has not timeout\n// proxiedUseCase will resolve by UseCaseWrapper#execute\n+ // For more details, see <UseCaseLifeCycle-test.ts>\nconst proxyfiedUseCase = proxifyUseCase<T>(this.useCase, {\nonWillNotExecute: args => {\nthis.willNotExecuteUseCase(args);\n@@ -416,7 +417,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n});\n}\ncase \"SuccessExecuteNoReturnValue\":\n- // just success execute\n+ // The UseCase#execute just success without return value\nreturn resolve();\n}\n});\n" } ]
TypeScript
MIT License
almin/almin
docs(almin): add comments
19,400
22.01.2018 20:39:07
-32,400
54eacd0c377b200134b74d2880ac09e3a6011e0e
chore(pacakge): update dependencies
[ { "change_type": "MODIFY", "old_path": "lerna.json", "new_path": "lerna.json", "diff": "{\n- \"lerna\": \"2.7.1\",\n+ \"lerna\": \"2.8.0\",\n\"commands\": {\n\"publish\": {\n\"concurrency\": 1\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"eslint-config-prettier\": \"^2.9.0\",\n\"eslint-plugin-prettier\": \"^2.5.0\",\n\"husky\": \"^0.14.3\",\n- \"lerna\": \"^2.7.1\",\n- \"lint-staged\": \"^6.0.0\",\n+ \"lerna\": \"^2.8.0\",\n+ \"lint-staged\": \"^6.0.1\",\n\"prettier\": \"^1.10.2\",\n- \"textlint\": \"^10.1.2\",\n+ \"textlint\": \"^10.1.3\",\n\"textlint-filter-rule-comments\": \"^1.2.2\",\n\"textlint-rule-alex\": \"^1.0.1\",\n\"textlint-rule-common-misspellings\": \"^1.0.1\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "isomorphic-fetch \"^2.2.1\"\ntextlint-rule-helper \"^2.0.0\"\n-\"@textlint/ast-node-types@^4.0.0\":\n- version \"4.0.0\"\n- resolved \"https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-4.0.0.tgz#0e6cbbf3c58376ba4d229ec489cf757afcb95538\"\n+\"@textlint/ast-node-types@^4.0.1\":\n+ version \"4.0.1\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-4.0.1.tgz#7a051bf87b33d592c370a9fa11f6b72a14833fdc\"\n-\"@textlint/feature-flag@^3.0.3\":\n- version \"3.0.3\"\n- resolved \"https://registry.yarnpkg.com/@textlint/feature-flag/-/feature-flag-3.0.3.tgz#32dd69fc53310645f509e705b8e074a1bb3d30c3\"\n+\"@textlint/feature-flag@^3.0.4\":\n+ version \"3.0.4\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/feature-flag/-/feature-flag-3.0.4.tgz#4290a4bb53da28c1f5f1d5ce0f4ae6630ab939ea\"\ndependencies:\nmap-like \"^2.0.0\"\n-\"@textlint/kernel@^2.0.4\":\n- version \"2.0.4\"\n- resolved \"https://registry.yarnpkg.com/@textlint/kernel/-/kernel-2.0.4.tgz#3c0c4329ac6ca52b6b0410499f5bb4575aef2471\"\n+\"@textlint/fixer-formatter@^3.0.3\":\n+ version \"3.0.3\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/fixer-formatter/-/fixer-formatter-3.0.3.tgz#66bba19f131623d81e0286579035be83a7d8af96\"\n+ dependencies:\n+ \"@textlint/kernel\" \"^2.0.5\"\n+ chalk \"^1.1.3\"\n+ debug \"^2.1.0\"\n+ diff \"^2.2.2\"\n+ interop-require \"^1.0.0\"\n+ is-file \"^1.0.0\"\n+ string-width \"^1.0.1\"\n+ text-table \"^0.2.0\"\n+ try-resolve \"^1.0.1\"\n+\n+\"@textlint/kernel@^2.0.5\":\n+ version \"2.0.5\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/kernel/-/kernel-2.0.5.tgz#7ce8215a47e9753949ebd3132eabec65df81bcc5\"\ndependencies:\n- \"@textlint/ast-node-types\" \"^4.0.0\"\n- \"@textlint/feature-flag\" \"^3.0.3\"\n+ \"@textlint/ast-node-types\" \"^4.0.1\"\n+ \"@textlint/feature-flag\" \"^3.0.4\"\n\"@types/bluebird\" \"^3.5.18\"\nbluebird \"^3.5.1\"\ndebug \"^2.6.6\"\ndeep-equal \"^1.0.1\"\nobject-assign \"^4.1.1\"\nstructured-source \"^3.0.2\"\n- txt-ast-traverse \"^2.0.3\"\n+ txt-ast-traverse \"^2.0.4\"\n+\n+\"@textlint/linter-formatter@^3.0.3\":\n+ version \"3.0.3\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/linter-formatter/-/linter-formatter-3.0.3.tgz#20d144ee5d469651db9e6da5a208828dc1337429\"\n+ dependencies:\n+ \"@azu/format-text\" \"^1.0.1\"\n+ \"@azu/style-format\" \"^1.0.0\"\n+ \"@textlint/kernel\" \"^2.0.5\"\n+ chalk \"^1.0.0\"\n+ concat-stream \"^1.5.1\"\n+ js-yaml \"^3.2.4\"\n+ optionator \"^0.8.1\"\n+ pluralize \"^2.0.0\"\n+ string-width \"^1.0.1\"\n+ string.prototype.padstart \"^3.0.0\"\n+ strip-ansi \"^3.0.1\"\n+ table \"^3.7.8\"\n+ text-table \"^0.2.0\"\n+ try-resolve \"^1.0.1\"\n+ xml-escape \"^1.0.0\"\n+\n+\"@textlint/markdown-to-ast@^6.0.4\":\n+ version \"6.0.4\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/markdown-to-ast/-/markdown-to-ast-6.0.4.tgz#e0a7da156e70e08ff39e82d4097733827d521c30\"\n+ dependencies:\n+ \"@textlint/ast-node-types\" \"^4.0.1\"\n+ debug \"^2.1.3\"\n+ remark \"^7.0.1\"\n+ structured-source \"^3.0.2\"\n+ traverse \"^0.6.6\"\n+\n+\"@textlint/text-to-ast@^3.0.4\":\n+ version \"3.0.4\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/text-to-ast/-/text-to-ast-3.0.4.tgz#6e2f3cf5fcc09ed0bcfecca70ca7523c7dc4631a\"\n+ dependencies:\n+ \"@textlint/ast-node-types\" \"^4.0.1\"\n\"@types/bluebird@^3.5.18\":\nversion \"3.5.19\"\n@@ -2286,6 +2336,15 @@ cosmiconfig@^3.1.0:\nparse-json \"^3.0.0\"\nrequire-from-string \"^2.0.1\"\n+cosmiconfig@^4.0.0:\n+ version \"4.0.0\"\n+ resolved \"https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-4.0.0.tgz#760391549580bbd2df1e562bc177b13c290972dc\"\n+ dependencies:\n+ is-directory \"^0.3.1\"\n+ js-yaml \"^3.9.0\"\n+ parse-json \"^4.0.0\"\n+ require-from-string \"^2.0.1\"\n+\ncpx@^1.5.0:\nversion \"1.5.0\"\nresolved \"https://registry.yarnpkg.com/cpx/-/cpx-1.5.0.tgz#185be018511d87270dedccc293171e37655ab88f\"\n@@ -5003,9 +5062,9 @@ left-pad@^1.2.0:\nversion \"1.2.0\"\nresolved \"https://registry.yarnpkg.com/left-pad/-/left-pad-1.2.0.tgz#d30a73c6b8201d8f7d8e7956ba9616087a68e0ee\"\n-lerna@^2.7.1:\n- version \"2.7.1\"\n- resolved \"https://registry.yarnpkg.com/lerna/-/lerna-2.7.1.tgz#abd536376eca5e9f41a6d611da5b744534ef906f\"\n+lerna@^2.8.0:\n+ version \"2.8.0\"\n+ resolved \"https://registry.yarnpkg.com/lerna/-/lerna-2.8.0.tgz#309a816fca5c73ea38f9f20e314a836e99b54cf0\"\ndependencies:\nasync \"^1.5.0\"\nchalk \"^2.1.0\"\n@@ -5068,14 +5127,14 @@ limit-spawn@0.0.3:\nversion \"0.0.3\"\nresolved \"https://registry.yarnpkg.com/limit-spawn/-/limit-spawn-0.0.3.tgz#cc09c24467a0f0a1ed10a5196dba597cad3f65dc\"\n-lint-staged@^6.0.0:\n- version \"6.0.0\"\n- resolved \"https://registry.yarnpkg.com/lint-staged/-/lint-staged-6.0.0.tgz#7ab7d345f2fe302ff196f1de6a005594ace03210\"\n+lint-staged@^6.0.1:\n+ version \"6.0.1\"\n+ resolved \"https://registry.yarnpkg.com/lint-staged/-/lint-staged-6.0.1.tgz#855f2993ab4a265430e2fd9828427e648d65e6b4\"\ndependencies:\napp-root-path \"^2.0.0\"\nchalk \"^2.1.0\"\ncommander \"^2.11.0\"\n- cosmiconfig \"^3.1.0\"\n+ cosmiconfig \"^4.0.0\"\ndebug \"^3.1.0\"\ndedent \"^0.7.0\"\nexeca \"^0.8.0\"\n@@ -5451,16 +5510,6 @@ markdown-table@^1.1.0:\nversion \"1.1.0\"\nresolved \"https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.0.tgz#1f5ae61659ced8808d882554c32e8b3f38dd1143\"\n-markdown-to-ast@^6.0.3:\n- version \"6.0.3\"\n- resolved \"https://registry.yarnpkg.com/markdown-to-ast/-/markdown-to-ast-6.0.3.tgz#c939442fee0e2074975cd7049ce8103d7be8f021\"\n- dependencies:\n- \"@textlint/ast-node-types\" \"^4.0.0\"\n- debug \"^2.1.3\"\n- remark \"^7.0.1\"\n- structured-source \"^3.0.2\"\n- traverse \"^0.6.6\"\n-\nmarked@GerHobbelt/marked#master:\nversion \"0.3.6-2\"\nresolved \"https://codeload.github.com/GerHobbelt/marked/tar.gz/15e137e836033daf7b697ac987b50f27f61b3ada\"\n@@ -8563,51 +8612,17 @@ textlint-filter-rule-comments@^1.2.2:\nversion \"1.2.2\"\nresolved \"https://registry.yarnpkg.com/textlint-filter-rule-comments/-/textlint-filter-rule-comments-1.2.2.tgz#3a72c494994e068e0e4aaad0f24ea7cfe338503a\"\n-textlint-fixer-formatter@^3.0.2:\n- version \"3.0.2\"\n- resolved \"https://registry.yarnpkg.com/textlint-fixer-formatter/-/textlint-fixer-formatter-3.0.2.tgz#dfe50ceead4c6255e67dcc83bd2e2b872e3f7ad8\"\n- dependencies:\n- \"@textlint/kernel\" \"^2.0.4\"\n- chalk \"^1.1.3\"\n- debug \"^2.1.0\"\n- diff \"^2.2.2\"\n- interop-require \"^1.0.0\"\n- is-file \"^1.0.0\"\n- string-width \"^1.0.1\"\n- text-table \"^0.2.0\"\n- try-resolve \"^1.0.1\"\n-\n-textlint-formatter@^3.0.2:\n- version \"3.0.2\"\n- resolved \"https://registry.yarnpkg.com/textlint-formatter/-/textlint-formatter-3.0.2.tgz#afe10d15dee7ebb9f9dae7c77c68414e7ab37df3\"\n- dependencies:\n- \"@azu/format-text\" \"^1.0.1\"\n- \"@azu/style-format\" \"^1.0.0\"\n- \"@textlint/kernel\" \"^2.0.4\"\n- chalk \"^1.0.0\"\n- concat-stream \"^1.5.1\"\n- js-yaml \"^3.2.4\"\n- optionator \"^0.8.1\"\n- pluralize \"^2.0.0\"\n- string-width \"^1.0.1\"\n- string.prototype.padstart \"^3.0.0\"\n- strip-ansi \"^3.0.1\"\n- table \"^3.7.8\"\n- text-table \"^0.2.0\"\n- try-resolve \"^1.0.1\"\n- xml-escape \"^1.0.0\"\n-\n-textlint-plugin-markdown@^4.0.5:\n- version \"4.0.5\"\n- resolved \"https://registry.yarnpkg.com/textlint-plugin-markdown/-/textlint-plugin-markdown-4.0.5.tgz#aa1411b52590f5c90eb4b5c7768f4e43a0e75411\"\n+textlint-plugin-markdown@^4.0.6:\n+ version \"4.0.6\"\n+ resolved \"https://registry.yarnpkg.com/textlint-plugin-markdown/-/textlint-plugin-markdown-4.0.6.tgz#80cde048a14761e26a98c339ce6faaee35a988e2\"\ndependencies:\n- markdown-to-ast \"^6.0.3\"\n+ \"@textlint/markdown-to-ast\" \"^6.0.4\"\n-textlint-plugin-text@^3.0.5:\n- version \"3.0.5\"\n- resolved \"https://registry.yarnpkg.com/textlint-plugin-text/-/textlint-plugin-text-3.0.5.tgz#99fd305903c369569212afff0773bdcb726fe334\"\n+textlint-plugin-text@^3.0.6:\n+ version \"3.0.6\"\n+ resolved \"https://registry.yarnpkg.com/textlint-plugin-text/-/textlint-plugin-text-3.0.6.tgz#05f4c1d3c6fb6b5322b91752ccbb9ed547688872\"\ndependencies:\n- txt-to-ast \"^3.0.3\"\n+ \"@textlint/text-to-ast\" \"^3.0.4\"\ntextlint-rule-alex@^1.0.1:\nversion \"1.2.0\"\n@@ -8643,13 +8658,15 @@ textlint-rule-prh@^5.0.1:\ntextlint-rule-helper \"^2.0.0\"\nuntildify \"^3.0.2\"\n-textlint@^10.1.2:\n- version \"10.1.2\"\n- resolved \"https://registry.yarnpkg.com/textlint/-/textlint-10.1.2.tgz#d29feb085c1a47ac515cb314fefbbc1cd43d6c51\"\n+textlint@^10.1.3:\n+ version \"10.1.3\"\n+ resolved \"https://registry.yarnpkg.com/textlint/-/textlint-10.1.3.tgz#8be8776010b49024d332811182dadc995d78f892\"\ndependencies:\n- \"@textlint/ast-node-types\" \"^4.0.0\"\n- \"@textlint/feature-flag\" \"^3.0.3\"\n- \"@textlint/kernel\" \"^2.0.4\"\n+ \"@textlint/ast-node-types\" \"^4.0.1\"\n+ \"@textlint/feature-flag\" \"^3.0.4\"\n+ \"@textlint/fixer-formatter\" \"^3.0.3\"\n+ \"@textlint/kernel\" \"^2.0.5\"\n+ \"@textlint/linter-formatter\" \"^3.0.3\"\n\"@types/bluebird\" \"^3.5.18\"\nbluebird \"^3.0.5\"\ndebug \"^2.1.0\"\n@@ -8670,12 +8687,10 @@ textlint@^10.1.2:\nread-pkg \"^1.1.0\"\nread-pkg-up \"^3.0.0\"\nstructured-source \"^3.0.2\"\n- textlint-fixer-formatter \"^3.0.2\"\n- textlint-formatter \"^3.0.2\"\n- textlint-plugin-markdown \"^4.0.5\"\n- textlint-plugin-text \"^3.0.5\"\n+ textlint-plugin-markdown \"^4.0.6\"\n+ textlint-plugin-text \"^3.0.6\"\ntry-resolve \"^1.0.1\"\n- txt-ast-traverse \"^2.0.3\"\n+ txt-ast-traverse \"^2.0.4\"\nunique-concat \"^0.2.2\"\nutf-8-validate \"^4.0.0\"\n@@ -8839,17 +8854,11 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0:\nversion \"0.14.5\"\nresolved \"https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64\"\n-txt-ast-traverse@^2.0.3:\n- version \"2.0.3\"\n- resolved \"https://registry.yarnpkg.com/txt-ast-traverse/-/txt-ast-traverse-2.0.3.tgz#7cd3f363233cbec4f27e4b7f8672400a4fdfe926\"\n- dependencies:\n- \"@textlint/ast-node-types\" \"^4.0.0\"\n-\n-txt-to-ast@^3.0.3:\n- version \"3.0.3\"\n- resolved \"https://registry.yarnpkg.com/txt-to-ast/-/txt-to-ast-3.0.3.tgz#052660c5e753f8d029f0f28ff5da2812a6abb24b\"\n+txt-ast-traverse@^2.0.4:\n+ version \"2.0.4\"\n+ resolved \"https://registry.yarnpkg.com/txt-ast-traverse/-/txt-ast-traverse-2.0.4.tgz#1d6f7eae7faf93fcd1a498531c2d8bffc6b7105b\"\ndependencies:\n- \"@textlint/ast-node-types\" \"^4.0.0\"\n+ \"@textlint/ast-node-types\" \"^4.0.1\"\ntype-check@~0.3.2:\nversion \"0.3.2\"\n" } ]
TypeScript
MIT License
almin/almin
chore(pacakge): update dependencies
19,400
22.01.2018 20:43:43
-32,400
8cd63a0cf2f06d209d310fe9b6cb86c4e4b254c1
fix(almin): fix CHANGELOG file
[ { "change_type": "MODIFY", "old_path": "packages/almin/CHANGELOG.md", "new_path": "packages/almin/CHANGELOG.md", "diff": "@@ -6,107 +6,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline\n<a name=\"0.15.2\"></a>\n## 0.15.2 (2018-01-22)\n-\n### Bug Fixes\n-* **almin:** add warning to no-commit transaction ([#246](https://github.com/almin/almin/issues/246)) ([3417c22](https://github.com/almin/almin/commit/3417c22)), closes [#240](https://github.com/almin/almin/issues/240)\n-* **almin:** Do not call duplicated Store#onChange ([#231](https://github.com/almin/almin/issues/231)) ([d089295](https://github.com/almin/almin/commit/d089295))\n-* **almin:** export UseCaseExecutor from index ([#243](https://github.com/almin/almin/issues/243)) ([1b3d515](https://github.com/almin/almin/commit/1b3d515))\n-* **almin:** fix immutability warning of StoreGroup ([#205](https://github.com/almin/almin/issues/205)) ([705f583](https://github.com/almin/almin/commit/705f583))\n* **almin:** fix to call didExecute when UseCase throw error ([f8d402d](https://github.com/almin/almin/commit/f8d402d)), closes [#310](https://github.com/almin/almin/issues/310)\n-* **almin:** fix transaction && limit multiple commit ([#249](https://github.com/almin/almin/issues/249)) ([51d9a95](https://github.com/almin/almin/commit/51d9a95))\n-* **almin:** Fix unused function argument in StoreGroup, Context ([#217](https://github.com/almin/almin/issues/217)) ([19499be](https://github.com/almin/almin/commit/19499be))\n-* **almin:** fix warning message format ([#195](https://github.com/almin/almin/issues/195)) ([630fe17](https://github.com/almin/almin/commit/630fe17))\n-* **almin:** Make Payload abstract class ([#286](https://github.com/almin/almin/issues/286)) ([131feda](https://github.com/almin/almin/commit/131feda))\n-* **almin:** make StoreGroup#state public ([#213](https://github.com/almin/almin/issues/213)) ([316770a](https://github.com/almin/almin/commit/316770a))\n-* **almin:** move [@types](https://github.com/types)/mocha to DevDeps ([81e58e6](https://github.com/almin/almin/commit/81e58e6))\n-* **almin:** Move `Context.on*` handler to `Context.events.on*` ([4d722fb](https://github.com/almin/almin/commit/4d722fb))\n-* **almin:** Payload subclass need to define \"type\" property ([186c615](https://github.com/almin/almin/commit/186c615))\n-* **almin:** Store#receivePayload work without StoreGroup ([#191](https://github.com/almin/almin/issues/191)) ([400dc65](https://github.com/almin/almin/commit/400dc65)), closes [#190](https://github.com/almin/almin/issues/190)\n-* **almin:** tryUpdateState should be called before actual finished ([#242](https://github.com/almin/almin/issues/242)) ([149b244](https://github.com/almin/almin/commit/149b244))\n-* **Store:** Store#onDispatch receive only dispatched the Payload by UseCase#dispatch ([#255](https://github.com/almin/almin/issues/255)) ([df1d309](https://github.com/almin/almin/commit/df1d309))\n-* **UseCase:** make UseCase#execute `abstract` ([#223](https://github.com/almin/almin/issues/223)) ([56d18a1](https://github.com/almin/almin/commit/56d18a1)), closes [#155](https://github.com/almin/almin/issues/155)\n-\n-\n-### Code Refactoring\n-\n-* **almin:** introduce Unit of work ([#224](https://github.com/almin/almin/issues/224)) ([8e08549](https://github.com/almin/almin/commit/8e08549))\n-\n-\n-### Features\n-\n-* **almin:** Add \"onWillNotExecuteEachUseCase\" to LifeCycleEventHub ([7c0aed3](https://github.com/almin/almin/commit/7c0aed3))\n-* **almin:** add BeginTransaction/EndTransaction Payload ([#238](https://github.com/almin/almin/issues/238)) ([b4f8574](https://github.com/almin/almin/commit/b4f8574))\n-* **almin:** add StoreChangedPayload ([16d0442](https://github.com/almin/almin/commit/16d0442))\n-* **almin:** Add UnitOfWork#id property ([#257](https://github.com/almin/almin/issues/257)) ([8e6bd1b](https://github.com/almin/almin/commit/8e6bd1b))\n-* **almin:** Context#transaction ([#226](https://github.com/almin/almin/issues/226)) ([e013d84](https://github.com/almin/almin/commit/e013d84))\n-* **almin:** Introduce Almin Instruments ([#280](https://github.com/almin/almin/issues/280)) ([e0e8eb2](https://github.com/almin/almin/commit/e0e8eb2))\n-* **almin:** support TransactionContext#id and meta.transaction.id ([#266](https://github.com/almin/almin/issues/266)) ([1c14f75](https://github.com/almin/almin/commit/1c14f75))\n-* **almin:** Support UseCase#shouldExecute ([7c31364](https://github.com/almin/almin/commit/7c31364))\n-* **textlintrc:** add Save button ([60b18a9](https://github.com/almin/almin/commit/60b18a9))\n-* **UseCase:** Fluent style UseCase ([#194](https://github.com/almin/almin/issues/194)) ([29933bb](https://github.com/almin/almin/commit/29933bb))\n-\n-\n-### Performance Improvements\n-\n-* **almin:** add scalable stores perf test ([#187](https://github.com/almin/almin/issues/187)) ([06f4556](https://github.com/almin/almin/commit/06f4556))\n-* **benchmark:** add increase-store-benchmark ([#197](https://github.com/almin/almin/issues/197)) ([c7b2611](https://github.com/almin/almin/commit/c7b2611))\n-\n-\n-### Tests\n-\n-* **almin:** Remove IE9/IE10 from E2E Tests ([#234](https://github.com/almin/almin/issues/234)) ([a069ec7](https://github.com/almin/almin/commit/a069ec7))\n-\n-\n-### BREAKING CHANGES\n-\n-* **Store:** Store#onDispatch receive only your events\n-It is difference with Store#receivePayload.\n-\n-* fix typo\n-\n-* docs(Store): Update Store\n-\n-* docs(LifeCycleEventHub): fix example\n-\n-* chore(Store): describe `Store#receivePayload` role\n-\n-* chore: fix example\n-\n-* docs: Update docs\n-\n-* docs: Update docs\n-\n-* docs: Update docs\n-\n-* docs: Update docs\n-* **almin:** remove on* handler from UseCaseExecutor.\n-Use UseCaseExecutor#onDispatch instead of it.\n-\n-We don't know this handler use-case.\n-* **almin:** Drop IE9/IE10 support\n-* **almin:** Store can not receive un-important payload by Store#onDsipatch.\n-It means that Store#onDispatch can't receive willExecutePayload.\n-In other words, Store#onDispatch is same with Store#receivePayload.\n-\n-* refactor(Context): exact factory task to UseCaseExecutorFactory\n-\n-* refactor(almin): UnitOfWork can open/close for useCaseExecutor\n-\n-* docs(almin): add document about Unit of Work\n-\n-* docs(almin): add delegating payload\n-\n-* refactor(almin): UnitOfWork use `Payload` term\n-\n-* test(almin): add test for UnitOfWork\n-\n-* test(almin): add release test\n-\n-* docs(almin): add docs to UoW\n-\n-\n-\n<a name=\"0.15.1\"></a>\n## 0.15.1 (2018-01-18)\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): fix CHANGELOG file
19,400
27.01.2018 21:56:58
-32,400
5794e05e4b98df910b6e9888436872ffa8f60f06
test(almin): Convert StoreGroup-edge-case-test to TypeScript
[ { "change_type": "RENAME", "old_path": "packages/almin/test/StoreGroup-edge-case-test.js", "new_path": "packages/almin/test/StoreGroup-edge-case-test.ts", "diff": "// LICENSE : MIT\n\"use strict\";\nconst assert = require(\"assert\");\n-const sinon = require(\"sinon\");\nimport { Context, Dispatcher, Store, StoreGroup, UseCase } from \"../src/\";\nimport { createUpdatableStoreWithUseCase } from \"./helper/create-update-store-usecase\";\nimport { AsyncUseCase } from \"./use-case/AsyncUseCase\";\n@@ -108,7 +107,7 @@ describe(\"StoreGroup edge case\", function() {\nstore: storeGroup\n});\n- const callStack = [];\n+ const callStack: string[] = [];\ncontext.onChange(() => {\ncallStack.push(\"change\");\n});\n" } ]
TypeScript
MIT License
almin/almin
test(almin): Convert StoreGroup-edge-case-test to TypeScript
19,400
27.01.2018 23:20:26
-32,400
c51353152f3e7de2f268d59ebb61fd30c8d4eba1
test(almin): add failure test for a bug
[ { "change_type": "ADD", "old_path": null, "new_path": "packages/almin/test/LifeCycleEventHub-test.ts", "diff": "+import * as assert from \"assert\";\n+import { Context, DispatchedPayload, Dispatcher, DispatcherPayloadMeta, StoreGroup } from \"../src\";\n+import { createUpdatableStoreWithUseCase } from \"./helper/create-update-store-usecase\";\n+\n+describe(\"LifeCycleEventHub\", () => {\n+ // https://github.com/almin/almin/issues/328\n+ it(\"should sent `onDispatch` at once when dispatch and update store in UseCase\", () => {\n+ const { MockStore: AStore, MockUseCase: AUseCase } = createUpdatableStoreWithUseCase(\"A\");\n+ const aStore = new AStore();\n+ const storeGroup = new StoreGroup({\n+ a: aStore\n+ });\n+ const context = new Context({\n+ dispatcher: new Dispatcher(),\n+ store: storeGroup\n+ });\n+ const dispatchedLogs: [DispatchedPayload, DispatcherPayloadMeta][] = [];\n+ context.events.onDispatch((payload, meta) => {\n+ dispatchedLogs.push([payload, meta]);\n+ });\n+\n+ // useCase\n+ class ExampleUseCase extends AUseCase {\n+ execute() {\n+ this.dispatchUpdateState({\n+ value: \"update value\"\n+ });\n+ }\n+ }\n+\n+ return context\n+ .useCase(new ExampleUseCase())\n+ .executor(useCase => useCase.execute())\n+ .then(() => {\n+ assert.equal(dispatchedLogs.length, 1, \"should be dispatched at once\");\n+ });\n+ });\n+});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/helper/create-new-store.ts", "new_path": "packages/almin/test/helper/create-new-store.ts", "diff": "@@ -16,12 +16,14 @@ export interface MockStore {\n/**\n* This helper is for creating Store\n*/\n-export function createStore({ name, state }: { name: string; state?: any }) {\n- class MockStore extends Store implements MockStore {\n+export function createStore<T>({ name, state }: { name: string; state?: T }) {\n+ class MockStore extends Store<T | undefined> implements MockStore {\n+ state: T | undefined;\n+\nconstructor() {\nsuper();\nthis.name = name;\n- this.state = state || \"value\";\n+ this.state = state;\n}\n/**\n" } ]
TypeScript
MIT License
almin/almin
test(almin): add failure test for a bug #328
19,400
27.01.2018 23:31:45
-32,400
6aaaec959580fd5e8add6471dafd8a9c24bac144
fix(almin): fix trouble emit `StoreChangedPayload` In some case, LifeCycleEventHub#onDispatch receive StoreChangedPayload This fixes that `StoreChangedPayload` always be `isTrust: true` payload. `LifeCycleEventHub#onDispatch` ignore trusted Payload. As a result, LifeCycleEventHub#onDispatch have not received StoreChangedPayload. fix
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/Context.ts", "new_path": "packages/almin/src/Context.ts", "diff": "@@ -158,6 +158,7 @@ export class Context<T> {\nif (this.config.strict) {\nthis.storeGroup.useStrict();\n}\n+ // If some stores are changed, emit StoreChangedPayload\n// Store -> StoreGroup -> LifeCycleEventHub\nconst storeGroupOnChangeToStoreChangedPayload = (\nstores: Array<StoreLike<any>>,\n@@ -165,17 +166,17 @@ export class Context<T> {\n) => {\nstores.forEach(store => {\nconst payload = new StoreChangedPayload(store);\n- // FIXME: store#emitChange -> isTruest:false event\n// Should not included in StoreChanged Event\n- const meta = details\n- ? details.meta\n- : new DispatcherPayloadMetaImpl({\n+ // inherit some context from the reason of change details\n+ const transaction = details && details.meta && details.meta.transaction;\n+ const isUseCaseFinished = details && details.meta && details.meta.isUseCaseFinished;\n+ const meta = new DispatcherPayloadMetaImpl({\nuseCase: undefined,\ndispatcher: this.dispatcher,\nparentUseCase: null,\n- isTrusted: true,\n- isUseCaseFinished: false,\n- transaction: undefined\n+ isTrusted: true, // <= StoreChangedPayload is always trusted\n+ isUseCaseFinished: isUseCaseFinished,\n+ transaction: transaction\n});\nthis.dispatcher.dispatch(payload, meta);\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UILayer/StoreGroup.ts", "new_path": "packages/almin/src/UILayer/StoreGroup.ts", "diff": "@@ -466,18 +466,13 @@ But, ${store.name}#getState() was called.`\n/**\n* Observe changes of the store group.\n*\n- * `details` is the reason of changing stores.\n- * If `details` it not found, the reason by system.\n- *\n- * For example, the user can change store using `Store#emitChange` manually.\n+ * For example, the user can change store using `Store#setState` manually.\n* In this case, the `details` is defined and report.\n*\n- * Contrast, almin try to update store in a lifecycle.\n+ * Contrast, almin try to update store in a lifecycle(didUseCase, completeUseCase etc...).\n* In this case, the `details` is not defined and report.\n*\n- * TODO(azu): we should always define `details`\n- *\n- * onChange workflow: https://code2flow.com/mHFviS\n+ * StoreGroup#onChange workflow: https://code2flow.com/mHFviS\n*/\nonChange(handler: (stores: Array<Store<T>>, details?: StoreGroupReasonForChange) => void): () => void {\nthis.on(CHANGE_STORE_GROUP, handler);\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): fix trouble emit `StoreChangedPayload` In some case, LifeCycleEventHub#onDispatch receive StoreChangedPayload #328 This fixes that `StoreChangedPayload` always be `isTrust: true` payload. `LifeCycleEventHub#onDispatch` ignore trusted Payload. As a result, LifeCycleEventHub#onDispatch have not received StoreChangedPayload. fix #328
19,400
27.01.2018 23:35:04
-32,400
27eb46d8c5ae7cf12fe3986912afa5841b0521a7
chore(almin): add details comment
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/Context.ts", "new_path": "packages/almin/src/Context.ts", "diff": "@@ -174,7 +174,10 @@ export class Context<T> {\nuseCase: undefined,\ndispatcher: this.dispatcher,\nparentUseCase: null,\n- isTrusted: true, // <= StoreChangedPayload is always trusted\n+ // StoreChangedPayload is always trusted.\n+ // Because, StoreChangedPayload is created by almin, not user.\n+ // Related issue: https://github.com/almin/almin/issues/328\n+ isTrusted: true,\nisUseCaseFinished: isUseCaseFinished,\ntransaction: transaction\n});\n" } ]
TypeScript
MIT License
almin/almin
chore(almin): add details comment
19,400
27.01.2018 23:45:40
-32,400
8586af9d20f9e28ea110500953ac8e9dd0c4e3e6
refactor(almin): remove unused args for DispatcherPayloadMeta use default value instead of non meaning arguments.
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/Context.ts", "new_path": "packages/almin/src/Context.ts", "diff": "@@ -171,9 +171,7 @@ export class Context<T> {\nconst transaction = details && details.meta && details.meta.transaction;\nconst isUseCaseFinished = details && details.meta && details.meta.isUseCaseFinished;\nconst meta = new DispatcherPayloadMetaImpl({\n- useCase: undefined,\ndispatcher: this.dispatcher,\n- parentUseCase: null,\n// StoreChangedPayload is always trusted.\n// Because, StoreChangedPayload is created by almin, not user.\n// Related issue: https://github.com/almin/almin/issues/328\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/DispatcherPayloadMeta.ts", "new_path": "packages/almin/src/DispatcherPayloadMeta.ts", "diff": "@@ -21,7 +21,7 @@ export interface Transaction {\n*/\nexport interface DispatcherPayloadMetaArgs {\nuseCase?: UseCaseLike;\n- dispatcher?: Dispatcher | Dispatcher;\n+ dispatcher?: Dispatcher;\nisUseCaseFinished?: boolean;\nparentUseCase?: UseCase | null;\nisTrusted: boolean;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UILayer/StoreGroup.ts", "new_path": "packages/almin/src/UILayer/StoreGroup.ts", "diff": "@@ -231,16 +231,8 @@ export class StoreGroup<T> extends Dispatcher implements StoreGroupLike {\n// InitializedPayload for passing to Store if the state change is not related payload.\nconst payload = new InitializedPayload();\nconst meta = new DispatcherPayloadMetaImpl({\n- // this dispatch payload generated by this UseCase\n- useCase: undefined,\n- // dispatcher is the UseCase\ndispatcher: this,\n- // parent is the same with UseCase. because this useCase dispatch the payload\n- parentUseCase: null,\n- // the user create this payload\n- isTrusted: true,\n- // Always false because the payload is dispatched from this working useCase.\n- isUseCaseFinished: false\n+ isTrusted: true\n});\n// 1. write in read\nthis.writePhaseInRead(stores, payload, meta);\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UnitOfWork/UseCaseUnitOfWork.ts", "new_path": "packages/almin/src/UnitOfWork/UseCaseUnitOfWork.ts", "diff": "@@ -87,16 +87,8 @@ export class UseCaseUnitOfWork {\nthis.isTransactionWorking = true;\nconst payload = new TransactionBeganPayload(this.name);\nconst meta = new DispatcherPayloadMetaImpl({\n- // this dispatch payload generated by this UseCase\n- useCase: undefined,\n- // dispatcher is the UseCase\ndispatcher: this.dispatcher,\n- // parent is the same with UseCase. because this useCase dispatch the payload\n- parentUseCase: null,\n- // the user create this payload\nisTrusted: true,\n- // Always false because the payload is dispatched from this working useCase.\n- isUseCaseFinished: false,\ntransaction: transaction\n});\nthis.dispatcher.dispatch(payload, meta);\n@@ -171,16 +163,8 @@ Not to allow to do multiple commits in a transaction`);\n// payload, meta\nconst payload = new TransactionEndedPayload(this.name);\nconst meta = new DispatcherPayloadMetaImpl({\n- // this dispatch payload generated by this UseCase\n- useCase: undefined,\n- // dispatcher is the UseCase\ndispatcher: this.dispatcher,\n- // parent is the same with UseCase. because this useCase dispatch the payload\n- parentUseCase: null,\n- // the user create this payload\nisTrusted: true,\n- // Always false because the payload is dispatched from this working useCase.\n- isUseCaseFinished: false,\ntransaction: transaction\n});\nreturn {\n" } ]
TypeScript
MIT License
almin/almin
refactor(almin): remove unused args for DispatcherPayloadMeta use default value instead of non meaning arguments.
19,400
28.01.2018 00:07:09
-32,400
c30e56ec5745ca4f74f9d89615f7d5fb2130e4df
test(almin): Convert UnitOfWork test to TypeScript
[ { "change_type": "RENAME", "old_path": "packages/almin/test/UnitOfWork-test.js", "new_path": "packages/almin/test/UnitOfWork-test.ts", "diff": "\"use strict\";\nimport * as assert from \"assert\";\nimport { DispatcherPayloadMetaImpl } from \"../src/DispatcherPayloadMeta\";\n-import { Payload } from \"../src/index\";\n-import { UnitOfWork } from \"../src/UnitOfWork/UnitOfWork\";\n+import { Commitment, UnitOfWork } from \"../src/UnitOfWork/UnitOfWork\";\nconst createMockStoreGroup = () => {\n- const commitments = [];\n+ const commitments: Commitment[] = [];\nreturn {\ncommitments,\nmockStoreGroup: {\n- commit(payload) {\n- commitments.push(payload);\n+ commit(commitment: Commitment) {\n+ commitments.push(commitment);\n}\n}\n};\n};\nlet commitmentId = 0;\n-const createCommitment = () => {\n- return [new Payload({ type: `Example ${commitmentId++}` }), new DispatcherPayloadMetaImpl({})];\n+const createCommitment = (): Commitment => {\n+ const commitId = commitmentId++;\n+ return {\n+ payload: { type: `Example ${commitId}` },\n+ meta: new DispatcherPayloadMetaImpl({\n+ isTrusted: true\n+ }),\n+ debugId: String(commitmentId)\n+ };\n};\ndescribe(\"UnitOfWork\", () => {\ndescribe(\"id\", () => {\n" } ]
TypeScript
MIT License
almin/almin
test(almin): Convert UnitOfWork test to TypeScript
19,400
28.01.2018 00:13:42
-32,400
96206abee48413a14ec5c35f6f9ca7b4774af052
test(almin): Convert UseCase test to TypeScript
[ { "change_type": "RENAME", "old_path": "packages/almin/test/UseCase-test.js", "new_path": "packages/almin/test/UseCase-test.ts", "diff": "// LICENSE : MIT\n\"use strict\";\n-const assert = require(\"assert\");\n-const sinon = require(\"sinon\");\n-import { Context } from \"../src/Context\";\n-import { Dispatcher } from \"../src/Dispatcher\";\n+import { SinonStub } from \"sinon\";\n+import { Context, DispatchedPayload, Dispatcher, ErrorPayload, UseCase } from \"../src\";\nimport { TYPE as CompletedPayloadType } from \"../src/payload/CompletedPayload\";\nimport { TYPE as DidExecutedPayloadType } from \"../src/payload/DidExecutedPayload\";\nimport { TYPE as WillExecutedPayloadType } from \"../src/payload/WillExecutedPayload\";\n-import { UseCase } from \"../src/UseCase\";\nimport { UseCaseContext } from \"../src/UseCaseContext\";\nimport { createStore } from \"./helper/create-new-store\";\n+const assert = require(\"assert\");\n+const sinon = require(\"sinon\");\n+\ndescribe(\"UseCase\", function() {\ndescribe(\"id\", () => {\nit(\"should have unique id in instance\", () => {\n- const aUseCase = new UseCase();\n+ class ExampleUseCase extends UseCase {\n+ execute(..._: Array<any>): any {}\n+ }\n+\n+ const aUseCase = new ExampleUseCase();\nassert(typeof aUseCase.id === \"string\");\n- const bUseCase = new UseCase();\n+ const bUseCase = new ExampleUseCase();\nassert(typeof bUseCase.id === \"string\");\nassert(aUseCase.id !== bUseCase.id);\n});\n@@ -33,7 +37,9 @@ describe(\"UseCase\", function() {\n});\ndescribe(\"when define displayName\", () => {\nit(\"#name is same with displayName\", () => {\n- class MyUseCase extends UseCase {}\n+ class MyUseCase extends UseCase {\n+ execute(..._: Array<any>): any {}\n+ }\nconst expectedName = \"Expected UseCase\";\nMyUseCase.displayName = expectedName;\n@@ -52,8 +58,11 @@ describe(\"UseCase\", function() {\nconst testUseCase = new TestUseCase();\n// then\n- testUseCase.onDispatch(({ type, error }) => {\n- assert(error instanceof Error);\n+ testUseCase.onDispatch(payload => {\n+ assert.ok(payload instanceof ErrorPayload, \"should be instance of ErrorPayload\");\n+ if (payload instanceof ErrorPayload) {\n+ assert(payload.error instanceof Error);\n+ }\ndone();\n});\n// when\n@@ -80,7 +89,7 @@ describe(\"UseCase\", function() {\nconst aUseCase = new AUseCase();\n// for reference fn.name\nconst bUseCase = new BUseCase();\n- const callStack = [];\n+ const callStack: string[] = [];\nconst expectedCallStackOfAUseCase = [WillExecutedPayloadType, DidExecutedPayloadType, CompletedPayloadType];\nconst expectedCallStack = [\n`${aUseCase.name}:will`,\n@@ -99,11 +108,11 @@ describe(\"UseCase\", function() {\nconst expectedType = expectedCallStackOfAUseCase.shift();\nassert.equal(type, expectedType);\n});\n- context.events.onWillExecuteEachUseCase((payload, meta) => {\n- callStack.push(`${meta.useCase.name}:will`);\n+ context.events.onWillExecuteEachUseCase((_payload, meta) => {\n+ callStack.push(`${meta.useCase && meta.useCase.name}:will`);\n});\n- context.events.onDidExecuteEachUseCase((payload, meta) => {\n- callStack.push(`${meta.useCase.name}:did`);\n+ context.events.onDidExecuteEachUseCase((_payload, meta) => {\n+ callStack.push(`${meta.useCase && meta.useCase.name}:did`);\n});\n// when\nreturn context\n@@ -134,14 +143,15 @@ describe(\"UseCase\", function() {\n});\ndescribe(\"when not implemented execute()\", function() {\nit(\"should assert error on constructor\", function() {\n- class TestUseCase extends UseCase {}\n+ // @ts-ignore\n+ class WrongImplementUseCase extends UseCase {}\ntry {\n- const useCase = new TestUseCase();\n+ const useCase = new WrongImplementUseCase();\nuseCase.execute();\nthrow new Error(\"unreachable\");\n} catch (error) {\n- assert(error.name === \"TypeError\");\n+ assert.equal(error.name, \"TypeError\");\n}\n});\n});\n@@ -179,7 +189,7 @@ describe(\"UseCase\", function() {\ndispatcher,\nstore: createStore({ name: \"test\" })\n});\n- const dispatchedPayloads = [];\n+ const dispatchedPayloads: DispatchedPayload[] = [];\ndispatcher.onDispatch(payload => {\ndispatchedPayloads.push(payload);\n});\n@@ -205,7 +215,7 @@ describe(\"UseCase\", function() {\n*/\ndescribe(\"when child is completed after parent did completed\", function() {\n- let consoleErrorStub = null;\n+ let consoleErrorStub: SinonStub;\nbeforeEach(() => {\nconsoleErrorStub = sinon.stub(console, \"error\");\n});\n@@ -216,7 +226,7 @@ describe(\"UseCase\", function() {\nconst childPayload = {\ntype: \"ChildUseCase\"\n};\n- const dispatchedPayloads = [];\n+ const dispatchedPayloads: DispatchedPayload[] = [];\nconst finishCallBack = () => {\n// childPayload should not be delegated to dispatcher(root)\nassert(dispatchedPayloads.indexOf(childPayload) === -1);\n" } ]
TypeScript
MIT License
almin/almin
test(almin): Convert UseCase test to TypeScript
19,400
28.01.2018 00:25:13
-32,400
ff3ed9bfa7e58ab742a87aeec72ef46133c8c008
test(almin): Convert DispatcherPayloadMeta test to TypeScript
[ { "change_type": "RENAME", "old_path": "packages/almin/test/DispatcherPayloadMeta-test.js", "new_path": "packages/almin/test/DispatcherPayloadMeta-test.ts", "diff": "const assert = require(\"assert\");\nimport { MapLike } from \"map-like\";\nimport { CompletedPayload, Context, DidExecutedPayload } from \"../src/\";\n-import { Dispatcher } from \"../src/Dispatcher\";\n+import { Dispatcher, DispatcherPayloadMeta } from \"../src\";\nimport { createStore } from \"./helper/create-new-store\";\nimport { DispatchUseCase } from \"./use-case/DispatchUseCase\";\nimport { AsyncErrorUseCase } from \"./use-case/AsyncErrorUseCase\";\n@@ -20,8 +20,8 @@ describe(\"DispatcherPayloadMeta\", () => {\nstore: createStore({ name: \"test\" })\n});\nconst useCase = new SyncNoDispatchUseCase();\n- let actualMeta = null;\n- context.events.onWillExecuteEachUseCase((payload, meta) => {\n+ let actualMeta: DispatcherPayloadMeta;\n+ context.events.onWillExecuteEachUseCase((_payload, meta) => {\nactualMeta = meta;\n});\nreturn context\n@@ -44,8 +44,8 @@ describe(\"DispatcherPayloadMeta\", () => {\nstore: createStore({ name: \"test\" })\n});\nconst useCase = new DispatchUseCase();\n- let actualMeta = null;\n- context.events.onDispatch((payload, meta) => {\n+ let actualMeta: DispatcherPayloadMeta;\n+ context.events.onDispatch((_payload, meta) => {\nactualMeta = meta;\n});\nreturn context\n@@ -68,8 +68,8 @@ describe(\"DispatcherPayloadMeta\", () => {\nstore: createStore({ name: \"test\" })\n});\nconst useCase = new SyncNoDispatchUseCase();\n- let actualMeta = null;\n- context.events.onDidExecuteEachUseCase((payload, meta) => {\n+ let actualMeta: DispatcherPayloadMeta;\n+ context.events.onDidExecuteEachUseCase((_payload, meta) => {\nactualMeta = meta;\n});\nreturn context\n@@ -91,8 +91,8 @@ describe(\"DispatcherPayloadMeta\", () => {\nstore: createStore({ name: \"test\" })\n});\nconst useCase = new AsyncUseCase();\n- let actualMeta = null;\n- context.events.onDidExecuteEachUseCase((payload, meta) => {\n+ let actualMeta: DispatcherPayloadMeta;\n+ context.events.onDidExecuteEachUseCase((_payload, meta) => {\nactualMeta = meta;\n});\nreturn context\n@@ -116,8 +116,8 @@ describe(\"DispatcherPayloadMeta\", () => {\nstore: createStore({ name: \"test\" })\n});\nconst useCase = new SyncNoDispatchUseCase();\n- let actualMeta = null;\n- context.events.onCompleteEachUseCase((payload, meta) => {\n+ let actualMeta: DispatcherPayloadMeta;\n+ context.events.onCompleteEachUseCase((_payload, meta) => {\nactualMeta = meta;\n});\nreturn context\n@@ -141,8 +141,8 @@ describe(\"DispatcherPayloadMeta\", () => {\nstore: createStore({ name: \"test\" })\n});\nconst useCase = new AsyncErrorUseCase();\n- let actualMeta = null;\n- context.events.onErrorDispatch((payload, meta) => {\n+ let actualMeta: DispatcherPayloadMeta;\n+ context.events.onErrorDispatch((_payload, meta) => {\nactualMeta = meta;\n});\nreturn context\n@@ -168,14 +168,14 @@ describe(\"DispatcherPayloadMeta\", () => {\n});\nconst parentUseCase = new ParentUseCase();\nconst childUseCase = parentUseCase.childUseCase;\n- const willMeta = [];\n- const didMeta = [];\n- const completeMeta = [];\n- let childDispatchMeta = null;\n- context.events.onWillExecuteEachUseCase((payload, meta) => willMeta.push(meta));\n- context.events.onDidExecuteEachUseCase((payload, meta) => didMeta.push(meta));\n- context.events.onCompleteEachUseCase((payload, meta) => completeMeta.push(meta));\n- context.events.onDispatch((payload, meta) => (childDispatchMeta = meta));\n+ const willMeta: DispatcherPayloadMeta[] = [];\n+ const didMeta: DispatcherPayloadMeta[] = [];\n+ const completeMeta: DispatcherPayloadMeta[] = [];\n+ let childDispatchMeta: DispatcherPayloadMeta;\n+ context.events.onWillExecuteEachUseCase((_payload, meta) => willMeta.push(meta));\n+ context.events.onDidExecuteEachUseCase((_payload, meta) => didMeta.push(meta));\n+ context.events.onCompleteEachUseCase((_payload, meta) => completeMeta.push(meta));\n+ context.events.onDispatch((_payload, meta) => (childDispatchMeta = meta));\nreturn context\n.useCase(parentUseCase)\n.execute()\n@@ -240,6 +240,7 @@ describe(\"DispatcherPayloadMeta\", () => {\n}\nfinishedCallback();\n}\n+ return;\n});\nreturn context\n.useCase(useCase)\n" }, { "change_type": "RENAME", "old_path": "packages/almin/test/FunctionalUseCase-test.js", "new_path": "packages/almin/test/FunctionalUseCase-test.ts", "diff": "// LICENSE : MIT\n\"use strict\";\n-const assert = require(\"assert\");\n-const sinon = require(\"sinon\");\n-import { Context } from \"../src/Context\";\n-import { Dispatcher } from \"../src/Dispatcher\";\n-import { UseCase } from \"../src/UseCase\";\n+import * as assert from \"assert\";\n+import { Context, Dispatcher, UseCase } from \"../src\";\nimport { createEchoStore } from \"./helper/EchoStore\";\n+import { SinonStub } from \"sinon\";\n+\n+const sinon = require(\"sinon\");\ndescribe(\"FunctionalUseCase\", function() {\n- let consoleErrorStub = null;\n+ let consoleErrorStub: SinonStub;\nbeforeEach(() => {\nconsoleErrorStub = sinon.stub(console, \"error\");\n});\n@@ -28,12 +28,14 @@ describe(\"FunctionalUseCase\", function() {\nexecute() {}\n}\n+\nconst dispatcher = new Dispatcher();\nconst context = new Context({\ndispatcher,\n- store: createEchoStore({ echo: { a: \"a\" } })\n+ store: createEchoStore({ name: \"test\", echo: { a: \"a\" } })\n});\nassert.throws(() => {\n+ // @ts-ignore\ncontext.useCase(WriteToTextlintrcUseCase.create).execute();\n// ~~\n// missing call ()\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/use-case/NestingUseCase.ts", "new_path": "packages/almin/test/use-case/NestingUseCase.ts", "diff": "import { UseCase } from \"../../src\";\n// Parent -> ChildUseCase\nexport class ParentUseCase extends UseCase {\n- private childUseCase: ChildUseCase;\n+ public childUseCase: ChildUseCase;\nconstructor() {\nsuper();\nthis.childUseCase = new ChildUseCase();\n" } ]
TypeScript
MIT License
almin/almin
test(almin): Convert DispatcherPayloadMeta test to TypeScript
19,400
28.01.2018 00:30:41
-32,400
0b14de7fe40106188cfbdc0d8a90d102df481ccd
test(almin): Convert Context test to TypeScript
[ { "change_type": "RENAME", "old_path": "packages/almin/test/Context-test.js", "new_path": "packages/almin/test/Context-test.ts", "diff": "// LICENSE : MIT\n\"use strict\";\nimport * as assert from \"assert\";\n-import { Context } from \"../src/Context\";\n-import { Dispatcher } from \"../src/Dispatcher\";\n-import { CompletedPayload, DidExecutedPayload, WillExecutedPayload } from \"../src/index\";\n-import { Store } from \"../src/Store\";\n-import { StoreGroup } from \"../src/UILayer/StoreGroup\";\n-import { UseCase } from \"../src/UseCase\";\n+import {\n+ CompletedPayload,\n+ Context,\n+ DidExecutedPayload,\n+ DispatchedPayload,\n+ Dispatcher,\n+ DispatcherPayloadMeta,\n+ Store,\n+ StoreGroup,\n+ UseCase,\n+ WillExecutedPayload\n+} from \"../src\";\nimport { UseCaseExecutorImpl } from \"../src/UseCaseExecutor\";\nimport { createStore } from \"./helper/create-new-store\";\nimport { createEchoStore } from \"./helper/EchoStore\";\nimport { DispatchUseCase } from \"./use-case/DispatchUseCase\";\nimport { ParentUseCase } from \"./use-case/NestingUseCase\";\nimport { NotExecuteUseCase } from \"./use-case/NotExecuteUseCase\";\n-import { SyncNoDispatchUseCase } from \"./use-case/SyncNoDispatchUseCase\";\n+import { SinonStub } from \"sinon\";\n+import { UseCaseFunction } from \"../src/FunctionalUseCaseContext\";\nconst sinon = require(\"sinon\");\n@@ -35,7 +42,7 @@ class ThrowUseCase extends UseCase {\ndescribe(\"Context\", function() {\ncontext(\"Deprecated API\", () => {\n- let consoleErrorStub = null;\n+ let consoleErrorStub: SinonStub;\nbeforeEach(() => {\nconsoleErrorStub = sinon.stub(console, \"warn\");\n});\n@@ -70,7 +77,7 @@ describe(\"Context\", function() {\n}\n}\n- const dispatchedPayload = [];\n+ const dispatchedPayload: [DispatchedPayload, DispatcherPayloadMeta][] = [];\nclass ReceiveStore extends Store {\nconstructor() {\n@@ -194,7 +201,7 @@ describe(\"Context\", function() {\nconst testUseCase = new TestUseCase();\n// then\nlet isOnWillNotExecuteEachUseCaseCalled = false;\n- appContext.events.onWillNotExecuteEachUseCase((payload, meta) => {\n+ appContext.events.onWillNotExecuteEachUseCase(() => {\nisOnWillNotExecuteEachUseCaseCalled = true;\n});\n// when\n@@ -233,7 +240,7 @@ describe(\"Context\", function() {\nconst testUseCase = new TestUseCase();\nconst expectedArguments = \"param\";\n// then\n- appContext.events.onWillExecuteEachUseCase((payload, meta) => {\n+ appContext.events.onWillExecuteEachUseCase((payload, _meta) => {\nassert.ok(payload.args.length === 1);\nconst [arg] = payload.args;\nassert.ok(arg === expectedArguments);\n@@ -261,7 +268,7 @@ describe(\"Context\", function() {\n}\nconst eventUseCase = new EventUseCase();\n- const isCalled = {\n+ const isCalled: { [index: string]: boolean } = {\nwill: false,\ndispatch: false,\ndid: false,\n@@ -276,7 +283,7 @@ describe(\"Context\", function() {\nassert.equal(meta.parentUseCase, null);\n});\n// onDispatch should not called when UseCase will/did execute.\n- appContext.events.onDispatch((payload, meta) => {\n+ appContext.events.onDispatch((payload, _meta) => {\nisCalled.dispatch = true;\nassert.ok(typeof payload === \"object\");\nassert.equal(payload, expectedPayload);\n@@ -315,7 +322,7 @@ describe(\"Context\", function() {\n});\nconst testUseCase = new TestUseCase();\n// then\n- appContext.events.onDidExecuteEachUseCase((payload, meta) => {\n+ appContext.events.onDidExecuteEachUseCase((_payload, meta) => {\nassert.equal(meta.useCase, testUseCase);\ndone();\n});\n@@ -333,7 +340,7 @@ describe(\"Context\", function() {\nconst testUseCase = new TestUseCase();\n// then\nlet isCalled = false;\n- appContext.events.onCompleteEachUseCase((payload, meta) => {\n+ appContext.events.onCompleteEachUseCase(() => {\nisCalled = true;\n});\n// when\n@@ -387,6 +394,7 @@ describe(\"Context\", function() {\nstore: createEchoStore({ echo: { \"1\": 1 } })\n});\nassert.throws(() => {\n+ // @ts-ignore\nappContext.useCase(TestUseCase);\n});\n});\n@@ -465,11 +473,11 @@ describe(\"Context\", function() {\ndispatcher,\nstore: createEchoStore({ echo: { \"1\": 1 } })\n});\n- const callStack = [];\n- appContext.events.onDispatch((payload, meta) => {\n+ const callStack: DispatchedPayload[] = [];\n+ appContext.events.onDispatch((payload, _meta) => {\ncallStack.push(payload);\n});\n- const useCase = ({ dispatcher }) => {\n+ const useCase: UseCaseFunction = ({ dispatcher }) => {\nreturn value => {\ndispatcher.dispatch({\ntype: \"Example\",\n@@ -495,20 +503,20 @@ describe(\"Context\", function() {\ndispatcher,\nstore: createEchoStore({ echo: { \"1\": 1 } })\n});\n- const callStack = [];\n- appContext.events.onDispatch((payload, meta) => {\n+ const callStack: DispatchedPayload[] = [];\n+ appContext.events.onDispatch((payload, _meta) => {\ncallStack.push(payload);\n});\n- appContext.events.onWillExecuteEachUseCase((payload, meta) => {\n+ appContext.events.onWillExecuteEachUseCase((payload, _meta) => {\ncallStack.push(payload);\n});\n- appContext.events.onDidExecuteEachUseCase((payload, meta) => {\n+ appContext.events.onDidExecuteEachUseCase((payload, _meta) => {\ncallStack.push(payload);\n});\n- appContext.events.onCompleteEachUseCase((payload, meta) => {\n+ appContext.events.onCompleteEachUseCase((payload, _meta) => {\ncallStack.push(payload);\n});\n- const useCase = ({ dispatcher }) => {\n+ const useCase: UseCaseFunction = ({ dispatcher }) => {\nreturn value => {\ndispatcher.dispatch({\ntype: \"Example\",\n@@ -530,7 +538,7 @@ describe(\"Context\", function() {\nCompletedPayload\n];\nassert.equal(callStack.length, expectedCallStackOfAUseCase.length);\n- expectedCallStackOfAUseCase.forEach((payload, index) => {\n+ expectedCallStackOfAUseCase.forEach((_payload, index) => {\nconst ExpectedPayloadConstructor = expectedCallStackOfAUseCase[index];\nassert.ok(callStack[index] instanceof ExpectedPayloadConstructor);\n});\n@@ -540,12 +548,14 @@ describe(\"Context\", function() {\ndescribe(\"Constructor with Store instance\", () => {\nit(\"should Context delegate payload to Store#receivePayload\", () => {\nclass CounterStore extends Store {\n+ public receivePayloadList: any[];\n+\nconstructor() {\nsuper();\nthis.receivePayloadList = [];\n}\n- receivePayload(payload) {\n+ receivePayload(payload: any) {\nthis.receivePayloadList.push(payload);\n}\n" }, { "change_type": "RENAME", "old_path": "packages/almin/test/helper/EchoStore.js", "new_path": "packages/almin/test/helper/EchoStore.ts", "diff": "// LICENSE : MIT\n\"use strict\";\n-import { Store } from \"../../src/Store\";\n-export function createEchoStore({ name, echo }) {\n+import { Store } from \"../../src\";\n+\n+export interface CreateEchoStore {\n+ name?: string;\n+ echo: any;\n+}\n+\n+export function createEchoStore({ name, echo }: CreateEchoStore) {\nclass TestStore extends Store {\nconstructor() {\nsuper();\n@@ -15,5 +21,6 @@ export function createEchoStore({ name, echo }) {\nreturn echo;\n}\n}\n+\nreturn new TestStore();\n}\n" } ]
TypeScript
MIT License
almin/almin
test(almin): Convert Context test to TypeScript
19,400
28.01.2018 00:31:43
-32,400
3644432ecdcf189f40d51dc101fc9a831c418f93
test(almin): Convert AlminPerfMarker test to TypeScript
[ { "change_type": "MODIFY", "old_path": "packages/almin/test/AlminPerfMarker-test.ts", "new_path": "packages/almin/test/AlminPerfMarker-test.ts", "diff": "import { AlminPerfMarker } from \"../src/instrument/AlminPerfMarker\";\nimport * as assert from \"assert\";\nimport { createUpdatableStoreWithUseCase } from \"./helper/create-update-store-usecase\";\n-import { StoreGroup } from \"../src/UILayer/StoreGroup\";\n-import { Dispatcher } from \"../src/Dispatcher\";\n-import { Context } from \"../src/Context\";\n+import { Context, Dispatcher, StoreGroup } from \"../src\";\nimport AlminInstruments from \"../src/instrument/AlminInstruments\";\ndescribe(\"AlminPerfMarker\", () => {\n" }, { "change_type": "RENAME", "old_path": "packages/almin/test/UseCaseUnitOfWork-test.js", "new_path": "packages/almin/test/UseCaseUnitOfWork-test.ts", "diff": "" } ]
TypeScript
MIT License
almin/almin
test(almin): Convert AlminPerfMarker test to TypeScript
19,400
28.01.2018 20:39:17
-32,400
52b9125a42da1402a3d1cb6f45609c138aa0acad
fix(almin): fix test scripts
[ { "change_type": "MODIFY", "old_path": "packages/almin-react-container/test/almin-react-container-test.tsx", "new_path": "packages/almin-react-container/test/almin-react-container-test.tsx", "diff": "@@ -5,7 +5,8 @@ import * as React from \"react\";\nimport * as TestUtils from \"react-dom/test-utils\";\nconst createTestStore = <T extends {}>(initialState: T) => {\n- class TestStore extends Store {\n+ class TestStore extends Store<T> {\n+ state: T;\nconstructor() {\nsuper();\nthis.state = initialState;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"test:js\": \"cross-env NODE_ENV=development mocha \\\"test/**/*.{js,ts}\\\"\",\n\"test:saucelabs\": \"npm run build:test && zuul -- out/test/*-test.js\",\n\"test:browser\": \"npm run build:test && zuul --local 8080 --ui mocha-bdd -- out/test/*-test.js\",\n- \"posttest\": \"npm run clean\",\n\"presize\": \"npm-run-all -s clean build\",\n\"size\": \"size-limit\",\n\"ci\": \"npm test && npm run size\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -5364,9 +5364,9 @@ markdown-table@^1.1.0:\nversion \"1.1.1\"\nresolved \"https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.1.tgz#4b3dd3a133d1518b8ef0dbc709bf2a1b4824bc8c\"\n-\"marked@github:gerhobbelt/marked#master\":\n+marked@GerHobbelt/marked#master:\nversion \"0.3.6-2\"\n- resolved \"https://codeload.github.com/gerhobbelt/marked/tar.gz/15e137e836033daf7b697ac987b50f27f61b3ada\"\n+ resolved \"https://codeload.github.com/GerHobbelt/marked/tar.gz/15e137e836033daf7b697ac987b50f27f61b3ada\"\nmath-expression-evaluator@^1.2.14:\nversion \"1.2.17\"\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): fix test scripts
19,400
28.01.2018 20:42:28
-32,400
39b42ddb8035e8922ed997aa4b28d233940da46a
chore(packages): update dependencies
[ { "change_type": "MODIFY", "old_path": "packages/almin-react-container/package.json", "new_path": "packages/almin-react-container/package.json", "diff": "},\n\"devDependencies\": {\n\"@types/node\": \"^9.3.0\",\n- \"@types/react\": \"16.0.34\",\n+ \"@types/react\": \"16.0.35\",\n\"@types/react-dom\": \"16.0.3\",\n\"almin\": \"^0.15.2\",\n\"babel-preset-env\": \"^1.6.1\",\n},\n\"dependencies\": {\n\"shallow-equal-object\": \"^1.0.1\"\n+ },\n+ \"resolutions\": {\n+ \"@types/react\": \"16.0.35\",\n+ \"@types/react-dom\": \"16.0.3\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "version \"4.0.1\"\nresolved \"https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-4.0.1.tgz#7a051bf87b33d592c370a9fa11f6b72a14833fdc\"\n+\"@textlint/ast-traverse@^2.0.5\":\n+ version \"2.0.5\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/ast-traverse/-/ast-traverse-2.0.5.tgz#9a19202da705d4f8649367387129dd5a493c9f42\"\n+ dependencies:\n+ \"@textlint/ast-node-types\" \"^4.0.1\"\n+\n\"@textlint/feature-flag@^3.0.4\":\nversion \"3.0.4\"\nresolved \"https://registry.yarnpkg.com/@textlint/feature-flag/-/feature-flag-3.0.4.tgz#4290a4bb53da28c1f5f1d5ce0f4ae6630ab939ea\"\ndependencies:\nmap-like \"^2.0.0\"\n-\"@textlint/fixer-formatter@^3.0.3\":\n- version \"3.0.3\"\n- resolved \"https://registry.yarnpkg.com/@textlint/fixer-formatter/-/fixer-formatter-3.0.3.tgz#66bba19f131623d81e0286579035be83a7d8af96\"\n+\"@textlint/fixer-formatter@^3.0.4\":\n+ version \"3.0.4\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/fixer-formatter/-/fixer-formatter-3.0.4.tgz#e6e74347b96c2a563be0b67ba008a7b43d5896c1\"\ndependencies:\n- \"@textlint/kernel\" \"^2.0.5\"\n+ \"@textlint/kernel\" \"^2.0.6\"\nchalk \"^1.1.3\"\ndebug \"^2.1.0\"\ndiff \"^2.2.2\"\ntext-table \"^0.2.0\"\ntry-resolve \"^1.0.1\"\n-\"@textlint/kernel@^2.0.5\":\n- version \"2.0.5\"\n- resolved \"https://registry.yarnpkg.com/@textlint/kernel/-/kernel-2.0.5.tgz#7ce8215a47e9753949ebd3132eabec65df81bcc5\"\n+\"@textlint/kernel@^2.0.6\":\n+ version \"2.0.6\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/kernel/-/kernel-2.0.6.tgz#5d1630915261a038d15ef44b1da0b5275d481090\"\ndependencies:\n\"@textlint/ast-node-types\" \"^4.0.1\"\n+ \"@textlint/ast-traverse\" \"^2.0.5\"\n\"@textlint/feature-flag\" \"^3.0.4\"\n\"@types/bluebird\" \"^3.5.18\"\nbluebird \"^3.5.1\"\ndeep-equal \"^1.0.1\"\nobject-assign \"^4.1.1\"\nstructured-source \"^3.0.2\"\n- txt-ast-traverse \"^2.0.4\"\n-\"@textlint/linter-formatter@^3.0.3\":\n- version \"3.0.3\"\n- resolved \"https://registry.yarnpkg.com/@textlint/linter-formatter/-/linter-formatter-3.0.3.tgz#20d144ee5d469651db9e6da5a208828dc1337429\"\n+\"@textlint/linter-formatter@^3.0.4\":\n+ version \"3.0.4\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/linter-formatter/-/linter-formatter-3.0.4.tgz#78937749c7e3d4fdac5812f1845c565d9dbb6a57\"\ndependencies:\n\"@azu/format-text\" \"^1.0.1\"\n\"@azu/style-format\" \"^1.0.0\"\n- \"@textlint/kernel\" \"^2.0.5\"\n+ \"@textlint/kernel\" \"^2.0.6\"\nchalk \"^1.0.0\"\nconcat-stream \"^1.5.1\"\njs-yaml \"^3.2.4\"\ntry-resolve \"^1.0.1\"\nxml-escape \"^1.0.0\"\n-\"@textlint/markdown-to-ast@^6.0.4\":\n- version \"6.0.4\"\n- resolved \"https://registry.yarnpkg.com/@textlint/markdown-to-ast/-/markdown-to-ast-6.0.4.tgz#e0a7da156e70e08ff39e82d4097733827d521c30\"\n+\"@textlint/markdown-to-ast@^6.0.5\":\n+ version \"6.0.5\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/markdown-to-ast/-/markdown-to-ast-6.0.5.tgz#6151ee8eb799d4dac1930c86ab255833cc94d2f0\"\ndependencies:\n\"@textlint/ast-node-types\" \"^4.0.1\"\ndebug \"^2.1.3\"\nstructured-source \"^3.0.2\"\ntraverse \"^0.6.6\"\n-\"@textlint/text-to-ast@^3.0.4\":\n- version \"3.0.4\"\n- resolved \"https://registry.yarnpkg.com/@textlint/text-to-ast/-/text-to-ast-3.0.4.tgz#6e2f3cf5fcc09ed0bcfecca70ca7523c7dc4631a\"\n+\"@textlint/text-to-ast@^3.0.5\":\n+ version \"3.0.5\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/text-to-ast/-/text-to-ast-3.0.5.tgz#1bd198752059a93f9957381c9f663d3ea3132bd4\"\ndependencies:\n\"@textlint/ast-node-types\" \"^4.0.1\"\n+\"@textlint/textlint-plugin-markdown@^4.0.7\":\n+ version \"4.0.7\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/textlint-plugin-markdown/-/textlint-plugin-markdown-4.0.7.tgz#d1608e62767abf1b394001a057b3a3791bef0f87\"\n+ dependencies:\n+ \"@textlint/markdown-to-ast\" \"^6.0.5\"\n+\n+\"@textlint/textlint-plugin-text@^3.0.7\":\n+ version \"3.0.7\"\n+ resolved \"https://registry.yarnpkg.com/@textlint/textlint-plugin-text/-/textlint-plugin-text-3.0.7.tgz#4e50f1c1834f1b28bf646331c95f1fc34a101970\"\n+ dependencies:\n+ \"@textlint/text-to-ast\" \"^3.0.5\"\n+\n\"@types/bluebird@^3.5.18\":\n- version \"3.5.19\"\n- resolved \"https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.19.tgz#1a47308819ac2d1d6d1ca4f5d800ac84924100de\"\n+ version \"3.5.20\"\n+ resolved \"https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.20.tgz#f6363172add6f4eabb8cada53ca9af2781e8d6a1\"\n\"@types/mocha@^2.2.41\", \"@types/mocha@^2.2.44\":\n- version \"2.2.46\"\n- resolved \"https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.46.tgz#b04713f7759d1cf752effdaae7b3969e285ebc16\"\n+ version \"2.2.47\"\n+ resolved \"https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.47.tgz#30bbd880834d4af0f609025f282a69b8d4458f06\"\n\"@types/node@*\", \"@types/node@^9.3.0\":\n- version \"9.3.0\"\n- resolved \"https://registry.yarnpkg.com/@types/node/-/node-9.3.0.tgz#3a129cda7c4e5df2409702626892cb4b96546dd5\"\n+ version \"9.4.0\"\n+ resolved \"https://registry.yarnpkg.com/@types/node/-/node-9.4.0.tgz#b85a0bcf1e1cc84eb4901b7e96966aedc6f078d1\"\n\"@types/react-dom@16.0.3\":\nversion \"16.0.3\"\n\"@types/node\" \"*\"\n\"@types/react\" \"*\"\n-\"@types/react@*\", \"@types/react@16.0.34\":\n- version \"16.0.34\"\n- resolved \"https://registry.yarnpkg.com/@types/react/-/react-16.0.34.tgz#7a8f795afd8a404a9c4af9539b24c75d3996914e\"\n+\"@types/react@*\", \"@types/react@16.0.35\":\n+ version \"16.0.35\"\n+ resolved \"https://registry.yarnpkg.com/@types/react/-/react-16.0.35.tgz#7ce8a83cad9690fd965551fc513217a74fc9e079\"\n\"@types/sinon@^4.1.3\":\nversion \"4.1.3\"\n@@ -1607,8 +1625,8 @@ caniuse-api@^1.5.2:\nlodash.uniq \"^4.5.0\"\ncaniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639:\n- version \"1.0.30000793\"\n- resolved \"https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000793.tgz#3c00c66e423a7a1907c7dd96769a78b2afa8a72e\"\n+ version \"1.0.30000798\"\n+ resolved \"https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000798.tgz#92f26f77f89cc2a4d60487f41e0b3d2a6c3fe341\"\ncaniuse-lite@^1.0.30000792:\nversion \"1.0.30000792\"\n@@ -2718,7 +2736,11 @@ doctrine@^2.1.0:\ndependencies:\nesutils \"^2.0.2\"\n-domain-browser@^1.1.1, domain-browser@~1.1.0:\n+domain-browser@^1.1.1:\n+ version \"1.2.0\"\n+ resolved \"https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda\"\n+\n+domain-browser@~1.1.0:\nversion \"1.1.7\"\nresolved \"https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc\"\n@@ -3873,8 +3895,8 @@ global-dirs@^0.1.0:\nini \"^1.3.4\"\nglobals@^11.0.1:\n- version \"11.1.0\"\n- resolved \"https://registry.yarnpkg.com/globals/-/globals-11.1.0.tgz#632644457f5f0e3ae711807183700ebf2e4633e4\"\n+ version \"11.2.0\"\n+ resolved \"https://registry.yarnpkg.com/globals/-/globals-11.2.0.tgz#aa2ece052a787563ba70a3dcd9dc2eb8a9a0488c\"\nglobals@^9.18.0:\nversion \"9.18.0\"\n@@ -4735,8 +4757,8 @@ jest-validate@^21.1.0:\npretty-format \"^21.2.1\"\njs-base64@^2.1.9:\n- version \"2.4.1\"\n- resolved \"https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.1.tgz#e02813181cd53002888e918935467acb2910e596\"\n+ version \"2.4.3\"\n+ resolved \"https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.3.tgz#2e545ec2b0f2957f41356510205214e98fad6582\"\njs-tokens@^3.0.0, js-tokens@^3.0.2:\nversion \"3.0.2\"\n@@ -4761,8 +4783,8 @@ jsbn@~0.1.0:\nresolved \"https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513\"\njsdom@^11.3.0:\n- version \"11.6.0\"\n- resolved \"https://registry.yarnpkg.com/jsdom/-/jsdom-11.6.0.tgz#7334781595ee8bdeea9742fc33fab5cdad6d195f\"\n+ version \"11.6.1\"\n+ resolved \"https://registry.yarnpkg.com/jsdom/-/jsdom-11.6.1.tgz#43fffc10072597a8ee9680cba46900d9e4dbeba2\"\ndependencies:\nabab \"^1.0.4\"\nacorn \"^5.3.0\"\n@@ -4986,8 +5008,8 @@ limit-spawn@0.0.3:\nresolved \"https://registry.yarnpkg.com/limit-spawn/-/limit-spawn-0.0.3.tgz#cc09c24467a0f0a1ed10a5196dba597cad3f65dc\"\nlint-staged@^6.0.1:\n- version \"6.0.1\"\n- resolved \"https://registry.yarnpkg.com/lint-staged/-/lint-staged-6.0.1.tgz#855f2993ab4a265430e2fd9828427e648d65e6b4\"\n+ version \"6.1.0\"\n+ resolved \"https://registry.yarnpkg.com/lint-staged/-/lint-staged-6.1.0.tgz#28f600c10a6cbd249ceb003118a1552e53544a93\"\ndependencies:\napp-root-path \"^2.0.0\"\nchalk \"^2.1.0\"\n@@ -5591,8 +5613,8 @@ minimist@~0.0.1:\nresolved \"https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf\"\nmississippi@^1.3.0:\n- version \"1.3.0\"\n- resolved \"https://registry.yarnpkg.com/mississippi/-/mississippi-1.3.0.tgz#d201583eb12327e3c5c1642a404a9cacf94e34f5\"\n+ version \"1.3.1\"\n+ resolved \"https://registry.yarnpkg.com/mississippi/-/mississippi-1.3.1.tgz#2a8bb465e86550ac8b36a7b6f45599171d78671e\"\ndependencies:\nconcat-stream \"^1.5.0\"\nduplexify \"^3.4.2\"\n@@ -6835,8 +6857,8 @@ pump@^1.0.0, pump@^1.0.1:\nonce \"^1.3.1\"\npump@^2.0.0:\n- version \"2.0.0\"\n- resolved \"https://registry.yarnpkg.com/pump/-/pump-2.0.0.tgz#7946da1c8d622b098e2ceb2d3476582470829c9d\"\n+ version \"2.0.1\"\n+ resolved \"https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909\"\ndependencies:\nend-of-stream \"^1.1.0\"\nonce \"^1.3.1\"\n@@ -7172,8 +7194,8 @@ regexpu-core@^2.0.0:\nregjsparser \"^0.1.4\"\nregistry-auth-token@^3.0.1:\n- version \"3.3.1\"\n- resolved \"https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.3.1.tgz#fb0d3289ee0d9ada2cbb52af5dfe66cb070d3006\"\n+ version \"3.3.2\"\n+ resolved \"https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.3.2.tgz#851fd49038eecb586911115af845260eec983f20\"\ndependencies:\nrc \"^1.1.6\"\nsafe-buffer \"^5.0.1\"\n@@ -7195,13 +7217,12 @@ regjsparser@^0.1.4:\njsesc \"~0.5.0\"\nremark-message-control@^4.0.0:\n- version \"4.0.2\"\n- resolved \"https://registry.yarnpkg.com/remark-message-control/-/remark-message-control-4.0.2.tgz#103d277418ce747fc0143542596c82c853990d51\"\n+ version \"4.1.0\"\n+ resolved \"https://registry.yarnpkg.com/remark-message-control/-/remark-message-control-4.1.0.tgz#60bc7700a87381404c956dc04e688518d3830cff\"\ndependencies:\nmdast-comment-marker \"^1.0.0\"\n- trim \"0.0.1\"\n- unist-util-visit \"^1.0.0\"\n- vfile-location \"^2.0.0\"\n+ unified-message-control \"^1.0.0\"\n+ xtend \"^4.0.1\"\nremark-parse@^3.0.0:\nversion \"3.0.1\"\n@@ -7792,8 +7813,8 @@ source-map-support@^0.4.15:\nsource-map \"^0.5.6\"\nsource-map-support@^0.5.0:\n- version \"0.5.2\"\n- resolved \"https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.2.tgz#1a6297fd5b2e762b39688c7fc91233b60984f0a5\"\n+ version \"0.5.3\"\n+ resolved \"https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.3.tgz#2b3d5fff298cfa4d1afd7d4352d569e9a0158e76\"\ndependencies:\nsource-map \"^0.6.0\"\n@@ -8367,18 +8388,6 @@ textlint-filter-rule-comments@^1.2.2:\nversion \"1.2.2\"\nresolved \"https://registry.yarnpkg.com/textlint-filter-rule-comments/-/textlint-filter-rule-comments-1.2.2.tgz#3a72c494994e068e0e4aaad0f24ea7cfe338503a\"\n-textlint-plugin-markdown@^4.0.6:\n- version \"4.0.6\"\n- resolved \"https://registry.yarnpkg.com/textlint-plugin-markdown/-/textlint-plugin-markdown-4.0.6.tgz#80cde048a14761e26a98c339ce6faaee35a988e2\"\n- dependencies:\n- \"@textlint/markdown-to-ast\" \"^6.0.4\"\n-\n-textlint-plugin-text@^3.0.6:\n- version \"3.0.6\"\n- resolved \"https://registry.yarnpkg.com/textlint-plugin-text/-/textlint-plugin-text-3.0.6.tgz#05f4c1d3c6fb6b5322b91752ccbb9ed547688872\"\n- dependencies:\n- \"@textlint/text-to-ast\" \"^3.0.4\"\n-\ntextlint-rule-alex@^1.0.1:\nversion \"1.2.0\"\nresolved \"https://registry.yarnpkg.com/textlint-rule-alex/-/textlint-rule-alex-1.2.0.tgz#b1a105971b2d9e69cc05c9ae42768f03b7202b5d\"\n@@ -8414,14 +8423,17 @@ textlint-rule-prh@^5.0.1:\nuntildify \"^3.0.2\"\ntextlint@^10.1.3:\n- version \"10.1.3\"\n- resolved \"https://registry.yarnpkg.com/textlint/-/textlint-10.1.3.tgz#8be8776010b49024d332811182dadc995d78f892\"\n+ version \"10.1.4\"\n+ resolved \"https://registry.yarnpkg.com/textlint/-/textlint-10.1.4.tgz#980ad55b09328bd8a4c040a103a469c6297f0bc7\"\ndependencies:\n\"@textlint/ast-node-types\" \"^4.0.1\"\n+ \"@textlint/ast-traverse\" \"^2.0.5\"\n\"@textlint/feature-flag\" \"^3.0.4\"\n- \"@textlint/fixer-formatter\" \"^3.0.3\"\n- \"@textlint/kernel\" \"^2.0.5\"\n- \"@textlint/linter-formatter\" \"^3.0.3\"\n+ \"@textlint/fixer-formatter\" \"^3.0.4\"\n+ \"@textlint/kernel\" \"^2.0.6\"\n+ \"@textlint/linter-formatter\" \"^3.0.4\"\n+ \"@textlint/textlint-plugin-markdown\" \"^4.0.7\"\n+ \"@textlint/textlint-plugin-text\" \"^3.0.7\"\n\"@types/bluebird\" \"^3.5.18\"\nbluebird \"^3.0.5\"\ndebug \"^2.1.0\"\n@@ -8442,10 +8454,7 @@ textlint@^10.1.3:\nread-pkg \"^1.1.0\"\nread-pkg-up \"^3.0.0\"\nstructured-source \"^3.0.2\"\n- textlint-plugin-markdown \"^4.0.6\"\n- textlint-plugin-text \"^3.0.6\"\ntry-resolve \"^1.0.1\"\n- txt-ast-traverse \"^2.0.4\"\nunique-concat \"^0.2.2\"\nutf-8-validate \"^4.0.0\"\n@@ -8486,8 +8495,8 @@ timers-browserify@^1.0.1:\nprocess \"~0.11.0\"\ntimers-browserify@^2.0.4:\n- version \"2.0.4\"\n- resolved \"https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.4.tgz#96ca53f4b794a5e7c0e1bd7cc88a372298fa01e6\"\n+ version \"2.0.6\"\n+ resolved \"https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.6.tgz#241e76927d9ca05f4d959819022f5b3664b64bae\"\ndependencies:\nsetimmediate \"^1.0.4\"\n@@ -8586,10 +8595,14 @@ tsconfig@^7.0.0:\nstrip-bom \"^3.0.0\"\nstrip-json-comments \"^2.0.0\"\n-tty-browserify@0.0.0, tty-browserify@~0.0.0:\n+tty-browserify@0.0.0:\nversion \"0.0.0\"\nresolved \"https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6\"\n+tty-browserify@~0.0.0:\n+ version \"0.0.1\"\n+ resolved \"https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811\"\n+\ntunnel-agent@^0.6.0:\nversion \"0.6.0\"\nresolved \"https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd\"\n@@ -8604,12 +8617,6 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0:\nversion \"0.14.5\"\nresolved \"https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64\"\n-txt-ast-traverse@^2.0.4:\n- version \"2.0.4\"\n- resolved \"https://registry.yarnpkg.com/txt-ast-traverse/-/txt-ast-traverse-2.0.4.tgz#1d6f7eae7faf93fcd1a498531c2d8bffc6b7105b\"\n- dependencies:\n- \"@textlint/ast-node-types\" \"^4.0.1\"\n-\ntype-check@~0.3.2:\nversion \"0.3.2\"\nresolved \"https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72\"\n@@ -8644,8 +8651,8 @@ ua-parser-js@^0.7.9:\nresolved \"https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac\"\nuglify-es@^3.3.4:\n- version \"3.3.8\"\n- resolved \"https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.8.tgz#f2c68e6cff0d0f9dc9577e4da207151c2e753b7e\"\n+ version \"3.3.9\"\n+ resolved \"https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677\"\ndependencies:\ncommander \"~2.13.0\"\nsource-map \"~0.6.1\"\n@@ -8763,6 +8770,14 @@ unified-engine@^3.1.0:\nx-is-string \"^0.1.0\"\nxtend \"^4.0.1\"\n+unified-message-control@^1.0.0:\n+ version \"1.0.3\"\n+ resolved \"https://registry.yarnpkg.com/unified-message-control/-/unified-message-control-1.0.3.tgz#fbe4372a933a95ad71820a9a0da155956d3d42d5\"\n+ dependencies:\n+ trim \"0.0.1\"\n+ unist-util-visit \"^1.0.0\"\n+ vfile-location \"^2.0.0\"\n+\nunified@^6.0.0, unified@^6.1.0:\nversion \"6.1.6\"\nresolved \"https://registry.yarnpkg.com/unified/-/unified-6.1.6.tgz#5ea7f807a0898f1f8acdeefe5f25faa010cc42b1\"\n@@ -9321,8 +9336,8 @@ yargs-parser@^8.1.0:\ncamelcase \"^4.1.0\"\nyargs@^10.1.1:\n- version \"10.1.1\"\n- resolved \"https://registry.yarnpkg.com/yargs/-/yargs-10.1.1.tgz#5fe1ea306985a099b33492001fa19a1e61efe285\"\n+ version \"10.1.2\"\n+ resolved \"https://registry.yarnpkg.com/yargs/-/yargs-10.1.2.tgz#454d074c2b16a51a43e2fb7807e4f9de69ccb5c5\"\ndependencies:\ncliui \"^4.0.0\"\ndecamelize \"^1.1.1\"\n" } ]
TypeScript
MIT License
almin/almin
chore(packages): update dependencies
19,400
08.02.2018 10:46:23
-32,400
92cdcf9c50ace61270f984c90cabd400ded025b8
feat(almin): Make `dispatcher` optional
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/Context.ts", "new_path": "packages/almin/src/Context.ts", "diff": "@@ -51,11 +51,15 @@ See https://github.com/almin/almin/releases/tag/almin%400.13.10 for more details\n*/\nexport interface ContextArgs<T> {\n/**\n- * Pass Dispatcher instance\n+ * Dispatcher instance.\n+ *\n+ * Notes: Almin 0.16+\n+ *\n+ * It it optional parameter.\n*/\n- dispatcher: Dispatcher;\n+ dispatcher?: Dispatcher;\n/**\n- * Pass StoreGroup instance\n+ * StoreGroup instance\n*/\nstore: StoreLike<T>;\n/**\n@@ -100,8 +104,7 @@ export class Context<T> {\nprivate config: ContextConfig;\n/**\n- * `dispatcher` is an instance of `Dispatcher`.\n- * `store` is an instance of StoreLike implementation\n+ * Context should be initialized with `store` that is an instance of StoreLike implementation\n*\n* ### Example\n*\n@@ -109,7 +112,6 @@ export class Context<T> {\n*\n* ```js\n* const context = new Context({\n- * dispatcher: new Dispatcher(),\n* store: new MyStore()\n* });\n* ```\n@@ -121,7 +123,6 @@ export class Context<T> {\n* new AStore(), new BStore(), new CStore()\n* ]);\n* const context = new Context({\n- * dispatcher: new Dispatcher(),\n* store: storeGroup\n* });\n* ```\n@@ -129,8 +130,10 @@ export class Context<T> {\nconstructor(args: ContextArgs<T>) {\nconst store = args.store;\nStoreGroupValidator.validateInstance(store);\n- // central dispatcher\n- this.dispatcher = args.dispatcher;\n+ // Central dispatcher\n+ // Almin 0.16+: dispatcher is optional.\n+ // https://github.com/almin/almin/issues/185\n+ this.dispatcher = args.dispatcher || new Dispatcher();\n// Implementation Note:\n// Delegate dispatch event to Store|StoreGroup from Dispatcher\n// StoreGroup call each Store#receivePayload, but pass directly Store is not.\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/Context-test.ts", "new_path": "packages/almin/test/Context-test.ts", "diff": "@@ -21,6 +21,7 @@ import { ParentUseCase } from \"./use-case/NestingUseCase\";\nimport { NotExecuteUseCase } from \"./use-case/NotExecuteUseCase\";\nimport { SinonStub } from \"sinon\";\nimport { UseCaseFunction } from \"../src/FunctionalUseCaseContext\";\n+import { createUpdatableStoreWithUseCase } from \"./helper/create-update-store-usecase\";\nconst sinon = require(\"sinon\");\n@@ -545,6 +546,40 @@ describe(\"Context\", function() {\n});\n});\n+ describe(\"Dispatcher\", () => {\n+ it(\"`dispatcher` is optional\", () => {\n+ const { MockStore, MockUseCase } = createUpdatableStoreWithUseCase(\"test\");\n+\n+ class UpdateUseCase extends MockUseCase {\n+ execute() {\n+ this.dispatchUpdateState({\n+ value: \"update\"\n+ });\n+ }\n+ }\n+\n+ // Context class provide observing and communicating with **Store** and **UseCase**\n+ const store = new MockStore();\n+ const storeGroup = new StoreGroup({\n+ test: store\n+ });\n+ const context = new Context({\n+ dispatcher: new Dispatcher(),\n+ store: storeGroup\n+ });\n+ return context\n+ .useCase(new UpdateUseCase())\n+ .execute()\n+ .then(() => {\n+ assert.deepEqual(storeGroup.getState(), {\n+ test: {\n+ value: \"update\"\n+ }\n+ });\n+ });\n+ });\n+ });\n+\ndescribe(\"Constructor with Store instance\", () => {\nit(\"should Context delegate payload to Store#receivePayload\", () => {\nclass CounterStore extends Store {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/helper/create-update-store-usecase.ts", "new_path": "packages/almin/test/helper/create-update-store-usecase.ts", "diff": "@@ -4,6 +4,7 @@ import { Payload, Store, UseCase } from \"../../src\";\nimport { shallowEqual } from \"shallow-equal-object\";\nexport function createUpdatableStoreWithUseCase(name: string) {\n+ let isSharedStateChanged = false;\nlet sharedState = {};\n/**\n@@ -13,6 +14,7 @@ export function createUpdatableStoreWithUseCase(name: string) {\n*/\nconst requestUpdateState = (newState: any) => {\nsharedState = newState;\n+ isSharedStateChanged = true;\n};\nclass StoreUpdatePayload implements Payload {\n@@ -53,8 +55,9 @@ export function createUpdatableStoreWithUseCase(name: string) {\nreceivePayload(payload: Payload) {\nif (payload instanceof StoreUpdatePayload) {\nthis.setState(payload.state);\n- } else if (!shallowEqual(this.state, sharedState)) {\n+ } else if (isSharedStateChanged && !shallowEqual(this.state, sharedState)) {\nthis.setState(sharedState);\n+ isSharedStateChanged = false;\n}\n}\n" } ]
TypeScript
MIT License
almin/almin
feat(almin): Make `dispatcher` optional
19,400
08.02.2018 10:48:07
-32,400
68a6fbc66ad02424e4822bf89204c5b9fd9f67e1
docs(almin): update API reference
[ { "change_type": "MODIFY", "old_path": "docs/_ContextAPI.md", "new_path": "docs/_ContextAPI.md", "diff": "@@ -11,7 +11,7 @@ title: Context\n```typescript\nexport interface ContextArgs<T> {\n- dispatcher: Dispatcher;\n+ dispatcher?: Dispatcher;\nstore: StoreLike<T>;\noptions?: {\nstrict?: boolean;\n@@ -57,17 +57,21 @@ const appContext = new Context({\n----\n-### `dispatcher: Dispatcher;`\n+### `dispatcher?: Dispatcher;`\n-Pass Dispatcher instance\n+Dispatcher instance.\n+\n+Notes: Almin 0.16+\n+\n+It it optional parameter.\n----\n### `store: StoreLike<T>;`\n-Pass StoreGroup instance\n+StoreGroup instance\n----\n@@ -116,8 +120,7 @@ Context class provide observing and communicating with **Store** and **UseCase**\n### `constructor(args: ContextArgs<T>);`\n-`dispatcher` is an instance of `Dispatcher`.\n-`store` is an instance of StoreLike implementation\n+Context should be initialized with `store` that is an instance of StoreLike implementation\n### Example\n@@ -125,7 +128,6 @@ It is minimal initialization.\n```js\nconst context = new Context({\n- dispatcher: new Dispatcher(),\nstore: new MyStore()\n});\n```\n@@ -137,7 +139,6 @@ const storeGroup = new StoreGroup([\nnew AStore(), new BStore(), new CStore()\n]);\nconst context = new Context({\n- dispatcher: new Dispatcher(),\nstore: storeGroup\n});\n```\n" }, { "change_type": "MODIFY", "old_path": "docs/_StoreGroupAPI.md", "new_path": "docs/_StoreGroupAPI.md", "diff": "@@ -77,7 +77,13 @@ shouldStateUpdate(prevState, nextState) {\nObserve changes of the store group.\n-onChange workflow: https://code2flow.com/mHFviS\n+For example, the user can change store using `Store#setState` manually.\n+In this case, the `details` is defined and report.\n+\n+Contrast, almin try to update store in a lifecycle(didUseCase, completeUseCase etc...).\n+In this case, the `details` is not defined and report.\n+\n+StoreGroup#onChange workflow: https://code2flow.com/mHFviS\n----\n" } ]
TypeScript
MIT License
almin/almin
docs(almin): update API reference
19,400
08.02.2018 20:01:03
-32,400
9e7a77668da8160a79a0072ffb9a42a913dc7cc1
fix(almin): remove `dispatcher` from DispatchPayloadMeta
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/Context.ts", "new_path": "packages/almin/src/Context.ts", "diff": "@@ -174,7 +174,6 @@ export class Context<T> {\nconst transaction = details && details.meta && details.meta.transaction;\nconst isUseCaseFinished = details && details.meta && details.meta.isUseCaseFinished;\nconst meta = new DispatcherPayloadMetaImpl({\n- dispatcher: this.dispatcher,\n// StoreChangedPayload is always trusted.\n// Because, StoreChangedPayload is created by almin, not user.\n// Related issue: https://github.com/almin/almin/issues/328\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/Dispatcher.ts", "new_path": "packages/almin/src/Dispatcher.ts", "diff": "@@ -130,7 +130,6 @@ export class Dispatcher extends EventEmitter {\n} else {\n// the `payload` object generated by user\nconst dispatchOnlyMeta = new DispatcherPayloadMetaImpl({\n- dispatcher: this,\nisTrusted: false\n});\nthis.emit(ON_DISPATCH, payload, dispatchOnlyMeta);\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/DispatcherPayloadMeta.ts", "new_path": "packages/almin/src/DispatcherPayloadMeta.ts", "diff": "@@ -19,14 +19,13 @@ export interface Transaction {\n* Dispatch Payload Meta arguments.\n* @private\n*/\n-export interface DispatcherPayloadMetaArgs {\n+export type DispatcherPayloadMetaArgs = {\nuseCase?: UseCaseLike;\n- dispatcher?: Dispatcher;\nisUseCaseFinished?: boolean;\nparentUseCase?: UseCase | null;\nisTrusted: boolean;\ntransaction?: Transaction;\n-}\n+};\n/**\n* `DispatcherPayloadMeta` is a meta object for `payload`.\n@@ -39,7 +38,6 @@ export interface DispatcherPayloadMetaArgs {\n* console.log(meta); // instance of DispatcherPayloadMeta\n* console.log(meta.useCase); // reference to UseCase\n* console.log(meta.parentUseCase); // reference to Parent UseCase\n- * console.log(meta.dispatcher); // reference to Dispatcher\n* console.log(meta.timeStamp); // Timestamp\n* console.log(meta.isTrusted); // Is it system payload?\n* });\n@@ -51,26 +49,6 @@ export interface DispatcherPayloadMeta {\n*/\nreadonly useCase: UseCaseLike | null;\n- /**\n- * A dispatcher of the payload\n- * In other word, the payload is dispatched by `this.dispatcher`\n- *\n- * ## Dispatcher in a useCase\n- *\n- * In following example, this.dispatcher is same with this.useCase.\n- *\n- * ```js\n- * class Example extends UseCase {\n- * execute(){\n- * this.dispatch({ type })\n- * // ^^^^\n- * // === this dispatcher === this.useCase\n- * }\n- * }\n- * ```\n- */\n- readonly dispatcher: UseCase | Dispatcher | null;\n-\n/**\n* A parent useCase of the `this.useCase`,\n* When useCase is nesting, parentUseCase is a UseCase.\n@@ -112,7 +90,6 @@ export interface DispatcherPayloadMeta {\n*/\nexport class DispatcherPayloadMetaImpl implements DispatcherPayloadMeta {\nreadonly useCase: UseCaseLike | null;\n- readonly dispatcher: UseCase | Dispatcher | null;\nreadonly parentUseCase: UseCase | Dispatcher | null;\nreadonly timeStamp: number;\nreadonly isTrusted: boolean;\n@@ -121,7 +98,6 @@ export class DispatcherPayloadMetaImpl implements DispatcherPayloadMeta {\nconstructor(args: DispatcherPayloadMetaArgs) {\nthis.useCase = args.useCase || null;\n- this.dispatcher = args.dispatcher === undefined ? null : args.dispatcher;\nthis.parentUseCase = args.parentUseCase || null;\nthis.timeStamp = Date.now();\nthis.isTrusted = args.isTrusted;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/FunctionalUseCase.ts", "new_path": "packages/almin/src/FunctionalUseCase.ts", "diff": "@@ -78,8 +78,6 @@ export class FunctionalUseCase extends Dispatcher implements UseCaseLike {\nconst useCaseMeta = new DispatcherPayloadMetaImpl({\n// this dispatch payload generated by this UseCase\nuseCase: this,\n- // dispatcher is the UseCase\n- dispatcher: this,\n// parent is the same with UseCase. because this useCase dispatch the payload\nparentUseCase: null,\n// the user create this payload\n@@ -117,7 +115,6 @@ export class FunctionalUseCase extends Dispatcher implements UseCaseLike {\nthrowError(error?: Error | any): void {\nconst meta = new DispatcherPayloadMetaImpl({\nuseCase: this,\n- dispatcher: this,\nisTrusted: true,\nisUseCaseFinished: false\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UILayer/StoreGroup.ts", "new_path": "packages/almin/src/UILayer/StoreGroup.ts", "diff": "@@ -231,7 +231,6 @@ export class StoreGroup<T> extends Dispatcher implements StoreGroupLike {\n// InitializedPayload for passing to Store if the state change is not related payload.\nconst payload = new InitializedPayload();\nconst meta = new DispatcherPayloadMetaImpl({\n- dispatcher: this,\nisTrusted: true\n});\n// 1. write in read\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UnitOfWork/UseCaseUnitOfWork.ts", "new_path": "packages/almin/src/UnitOfWork/UseCaseUnitOfWork.ts", "diff": "@@ -87,7 +87,6 @@ export class UseCaseUnitOfWork {\nthis.isTransactionWorking = true;\nconst payload = new TransactionBeganPayload(this.name);\nconst meta = new DispatcherPayloadMetaImpl({\n- dispatcher: this.dispatcher,\nisTrusted: true,\ntransaction: transaction\n});\n@@ -163,7 +162,6 @@ Not to allow to do multiple commits in a transaction`);\n// payload, meta\nconst payload = new TransactionEndedPayload(this.name);\nconst meta = new DispatcherPayloadMetaImpl({\n- dispatcher: this.dispatcher,\nisTrusted: true,\ntransaction: transaction\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCase.ts", "new_path": "packages/almin/src/UseCase.ts", "diff": "@@ -144,8 +144,6 @@ export abstract class UseCase extends Dispatcher implements UseCaseLike {\n: new DispatcherPayloadMetaImpl({\n// this dispatch payload generated by this UseCase\nuseCase: this,\n- // dispatcher is the UseCase\n- dispatcher: this,\n// parent is the same with UseCase. because this useCase dispatch the payload\nparentUseCase: null,\n// the user create this payload\n@@ -176,7 +174,6 @@ export abstract class UseCase extends Dispatcher implements UseCaseLike {\nthrowError(error?: Error | any): void {\nconst meta = new DispatcherPayloadMetaImpl({\nuseCase: this,\n- dispatcher: this,\nisTrusted: true,\nisUseCaseFinished: false\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -166,11 +166,6 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n*/\nprivate _parentUseCase: UseCase | null;\n- /**\n- * A dispatcher instance\n- */\n- private _dispatcher: Dispatcher;\n-\n/**\n* callable release handlers that are called in release()\n*/\n@@ -185,7 +180,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n*\n* **internal** documentation\n*/\n- constructor({ useCase, parent, dispatcher }: { useCase: T; parent: UseCase | null; dispatcher: Dispatcher }) {\n+ constructor({ useCase, parent }: { useCase: T; parent: UseCase | null }) {\nsuper();\nif (process.env.NODE_ENV !== \"production\") {\n// execute and finish =>\n@@ -199,7 +194,6 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\nthis.useCase = useCase;\nthis._parentUseCase = parent;\n- this._dispatcher = dispatcher;\nthis._releaseHandlers = [];\n/**\n* ## Delegating Payload\n@@ -223,7 +217,6 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n});\nconst meta = new DispatcherPayloadMetaImpl({\nuseCase: this.useCase,\n- dispatcher: this._dispatcher,\nparentUseCase: this._parentUseCase,\nisTrusted: true,\nisUseCaseFinished: true\n@@ -243,7 +236,6 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n});\nconst meta = new DispatcherPayloadMetaImpl({\nuseCase: this.useCase,\n- dispatcher: this._dispatcher,\nparentUseCase: this._parentUseCase,\nisTrusted: true,\nisUseCaseFinished: false\n@@ -270,7 +262,6 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n});\nconst meta = new DispatcherPayloadMetaImpl({\nuseCase: this.useCase,\n- dispatcher: this._dispatcher,\nparentUseCase: this._parentUseCase,\nisTrusted: true,\nisUseCaseFinished\n@@ -288,7 +279,6 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n});\nconst meta = new DispatcherPayloadMetaImpl({\nuseCase: this.useCase,\n- dispatcher: this._dispatcher,\nparentUseCase: this._parentUseCase,\nisTrusted: true,\nisUseCaseFinished: true\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutorFactory.ts", "new_path": "packages/almin/src/UseCaseExecutorFactory.ts", "diff": "@@ -15,8 +15,7 @@ export function createUseCaseExecutor(useCase: any, dispatcher: Dispatcher): Use\nif (isUseCase(useCase)) {\nreturn new UseCaseExecutorImpl({\nuseCase,\n- parent: isUseCase(dispatcher) ? dispatcher : null,\n- dispatcher\n+ parent: isUseCase(dispatcher) ? dispatcher : null\n});\n} else if (isUseCaseFunction(useCase)) {\n// When pass UseCase constructor itself, throw assertion error\n@@ -29,8 +28,7 @@ The argument is UseCase constructor itself: ${useCase}`\nconst functionalUseCase = new FunctionalUseCase(useCase);\nreturn new UseCaseExecutorImpl({\nuseCase: functionalUseCase,\n- parent: isUseCase(dispatcher) ? dispatcher : null,\n- dispatcher\n+ parent: isUseCase(dispatcher) ? dispatcher : null\n});\n}\nthrow new Error(`Context#useCase argument should be UseCase: ${useCase}`);\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/Context-test.ts", "new_path": "packages/almin/test/Context-test.ts", "diff": "@@ -109,7 +109,7 @@ describe(\"Context\", function() {\nconst [payload, meta] = dispatchedPayload[0];\nassert.deepEqual(payload, DISPATCHED_EVENT);\nassert.strictEqual(meta.useCase, useCase);\n- assert.strictEqual(meta.dispatcher, useCase);\n+ assert.strictEqual(meta.isTrusted, false);\nassert.strictEqual(meta.parentUseCase, null);\nassert.strictEqual(typeof meta.timeStamp, \"number\");\n});\n@@ -183,7 +183,6 @@ describe(\"Context\", function() {\nassert.ok(Array.isArray(payload.args));\nassert.ok(typeof meta.timeStamp === \"number\");\nassert.equal(meta.useCase, notExecuteUseCase);\n- assert.equal(meta.dispatcher, dispatcher);\nassert.equal(meta.parentUseCase, null);\nassert.equal(meta.isUseCaseFinished, true);\ndone();\n@@ -225,7 +224,6 @@ describe(\"Context\", function() {\nassert.ok(Array.isArray(payload.args));\nassert.ok(typeof meta.timeStamp === \"number\");\nassert.equal(meta.useCase, testUseCase);\n- assert.equal(meta.dispatcher, dispatcher);\nassert.equal(meta.parentUseCase, null);\ndone();\n});\n@@ -280,7 +278,6 @@ describe(\"Context\", function() {\nisCalled.will = true;\nassert.ok(payload instanceof WillExecutedPayload);\nassert.equal(meta.useCase, eventUseCase);\n- assert.equal(meta.dispatcher, dispatcher);\nassert.equal(meta.parentUseCase, null);\n});\n// onDispatch should not called when UseCase will/did execute.\n@@ -292,15 +289,15 @@ describe(\"Context\", function() {\nappContext.events.onDidExecuteEachUseCase((payload, meta) => {\nisCalled.did = true;\nassert.ok(payload instanceof DidExecutedPayload);\n+ assert.equal(meta.isTrusted, true);\nassert.equal(meta.useCase, eventUseCase);\n- assert.equal(meta.dispatcher, dispatcher);\nassert.equal(meta.parentUseCase, null);\n});\nappContext.events.onCompleteEachUseCase((payload, meta) => {\nisCalled.complete = true;\nassert.ok(payload instanceof CompletedPayload);\n+ assert.equal(meta.isTrusted, true);\nassert.equal(meta.useCase, eventUseCase);\n- assert.equal(meta.dispatcher, dispatcher);\nassert.equal(meta.parentUseCase, null);\n});\n// when\n@@ -366,7 +363,6 @@ describe(\"Context\", function() {\nassert.ok(payload.error instanceof Error);\nassert.equal(typeof meta.timeStamp, \"number\");\nassert.equal(meta.useCase, throwUseCase);\n- assert.equal(meta.dispatcher, throwUseCase);\nassert.equal(meta.parentUseCase, null);\ndone();\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/Context-transaction-test.ts", "new_path": "packages/almin/test/Context-transaction-test.ts", "diff": "@@ -467,7 +467,6 @@ describe(\"Context#transaction\", () => {\nbeginTransactions.push(payload);\nassert.strictEqual(meta.isTrusted, true, \"meta.isTrusted should be true\");\nassert.strictEqual(meta.useCase, null, \"meta.useCase should be null\");\n- assert.strictEqual(meta.dispatcher, dispatcher, \"meta.dispatcher should be dispatcher\");\nassert.strictEqual(meta.parentUseCase, null, \"meta.parentUseCase should be null\");\nassert.strictEqual(typeof meta.timeStamp, \"number\");\nassert.strictEqual(typeof meta.transaction, \"object\", \"transaction object\");\n@@ -477,7 +476,6 @@ describe(\"Context#transaction\", () => {\nendTransaction.push(payload);\nassert.strictEqual(meta.isTrusted, true, \"meta.isTrusted should be true\");\nassert.strictEqual(meta.useCase, null, \"meta.useCase should be null\");\n- assert.strictEqual(meta.dispatcher, dispatcher, \"meta.dispatcher should be dispatcher\");\nassert.strictEqual(meta.parentUseCase, null, \"meta.parentUseCase should be null\");\nassert.strictEqual(typeof meta.timeStamp, \"number\");\nassert.strictEqual(typeof meta.transaction, \"object\", \"transaction object\");\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/DispatcherPayloadMeta-test.ts", "new_path": "packages/almin/test/DispatcherPayloadMeta-test.ts", "diff": "@@ -29,7 +29,6 @@ describe(\"DispatcherPayloadMeta\", () => {\n.execute()\n.then(() => {\nassert(actualMeta.useCase === useCase);\n- assert(actualMeta.dispatcher === dispatcher);\nassert(actualMeta.parentUseCase === null);\nassert(actualMeta.transaction === undefined);\nassert(typeof actualMeta.timeStamp === \"number\");\n@@ -53,7 +52,6 @@ describe(\"DispatcherPayloadMeta\", () => {\n.execute({ type: \"test\" })\n.then(() => {\nassert(actualMeta.useCase === useCase);\n- assert(actualMeta.dispatcher === useCase);\nassert(actualMeta.parentUseCase === null);\nassert(actualMeta.transaction === undefined);\nassert(typeof actualMeta.timeStamp === \"number\");\n@@ -77,7 +75,6 @@ describe(\"DispatcherPayloadMeta\", () => {\n.execute()\n.then(() => {\nassert(actualMeta.useCase === useCase);\n- assert(actualMeta.dispatcher === dispatcher);\nassert(actualMeta.parentUseCase === null);\nassert(actualMeta.isUseCaseFinished === true);\nassert(actualMeta.transaction === undefined);\n@@ -100,7 +97,6 @@ describe(\"DispatcherPayloadMeta\", () => {\n.execute()\n.then(() => {\nassert(actualMeta.useCase === useCase);\n- assert(actualMeta.dispatcher === dispatcher);\nassert(actualMeta.parentUseCase === null);\nassert(actualMeta.isUseCaseFinished === false);\nassert(actualMeta.transaction === undefined);\n@@ -125,7 +121,6 @@ describe(\"DispatcherPayloadMeta\", () => {\n.execute()\n.then(() => {\nassert(actualMeta.useCase === useCase);\n- assert(actualMeta.dispatcher === dispatcher);\nassert(actualMeta.parentUseCase === null);\nassert(actualMeta.isUseCaseFinished === true);\nassert(actualMeta.transaction === undefined);\n@@ -150,7 +145,6 @@ describe(\"DispatcherPayloadMeta\", () => {\n.execute()\n.catch(() => {\nassert(actualMeta.useCase === useCase);\n- assert(actualMeta.dispatcher === useCase);\nassert(actualMeta.parentUseCase === null);\nassert(actualMeta.isUseCaseFinished === false);\nassert(actualMeta.transaction === undefined);\n@@ -185,33 +179,26 @@ describe(\"DispatcherPayloadMeta\", () => {\nconst [childCompleteMeta, parentCompleteMeta] = completeMeta;\n// parent\nassert(parentWillMeta.useCase === parentUseCase);\n- assert(parentWillMeta.dispatcher === dispatcher);\nassert(parentWillMeta.parentUseCase === null);\nassert(typeof parentWillMeta.timeStamp === \"number\");\nassert(parentDidMeta.useCase === parentUseCase);\n- assert(parentDidMeta.dispatcher === dispatcher);\nassert(parentDidMeta.parentUseCase === null);\nassert(typeof parentDidMeta.timeStamp === \"number\");\nassert(parentCompleteMeta.useCase === parentUseCase);\n- assert(parentCompleteMeta.dispatcher === dispatcher);\nassert(parentCompleteMeta.parentUseCase === null);\nassert(typeof parentCompleteMeta.timeStamp === \"number\");\n// child\nassert(childWillMeta.useCase === childUseCase);\n- assert(childWillMeta.dispatcher === parentUseCase);\nassert(childWillMeta.parentUseCase === parentUseCase);\nassert(typeof childWillMeta.timeStamp === \"number\");\nassert(childDidMeta.useCase === childUseCase);\n- assert(childDidMeta.dispatcher === parentUseCase);\nassert(childDidMeta.parentUseCase === parentUseCase);\nassert(typeof childDidMeta.timeStamp === \"number\");\nassert(childCompleteMeta.useCase === childUseCase);\n- assert(childCompleteMeta.dispatcher === parentUseCase);\nassert(childCompleteMeta.parentUseCase === parentUseCase);\nassert(typeof childCompleteMeta.timeStamp === \"number\");\n// childDispatchMeta\nassert(childDispatchMeta.useCase === childUseCase);\n- assert(childDispatchMeta.dispatcher === childUseCase);\nassert(childDispatchMeta.parentUseCase === null);\nassert(typeof childDispatchMeta.timeStamp === \"number\");\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/UseCaseExecutor-test.ts", "new_path": "packages/almin/test/UseCaseExecutor-test.ts", "diff": "// LICENSE : MIT\n\"use strict\";\nimport * as assert from \"assert\";\n-import sinon = require(\"sinon\");\nimport { SyncNoDispatchUseCase } from \"./use-case/SyncNoDispatchUseCase\";\n-import { Dispatcher, Payload, UseCase } from \"../src/\";\n+import { Payload, UseCase } from \"../src/\";\nimport { UseCaseExecutorImpl } from \"../src/UseCaseExecutor\";\nimport { CallableUseCase } from \"./use-case/CallableUseCase\";\nimport { ThrowUseCase } from \"./use-case/ThrowUseCase\";\n@@ -11,6 +10,7 @@ import { isWillExecutedPayload } from \"../src/payload/WillExecutedPayload\";\nimport { isDidExecutedPayload } from \"../src/payload/DidExecutedPayload\";\nimport { isCompletedPayload } from \"../src/payload/CompletedPayload\";\nimport { isErrorPayload } from \"../src/payload/ErrorPayload\";\n+import sinon = require(\"sinon\");\ndescribe(\"UseCaseExecutor\", function() {\ndescribe(\"#executor\", () => {\n@@ -22,10 +22,8 @@ describe(\"UseCaseExecutor\", function() {\nconsoleErrorStub.restore();\n});\nit(\"should catch sync throwing error in UseCase\", () => {\n- const dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new ThrowUseCase(),\n- dispatcher,\nparent: null\n});\nreturn executor.executor(useCase => useCase.execute()).then(\n@@ -38,10 +36,8 @@ describe(\"UseCaseExecutor\", function() {\n);\n});\nit(\"should throw error when pass non-executor function and output console.error\", () => {\n- const dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new SyncNoDispatchUseCase(),\n- dispatcher,\nparent: null\n});\nreturn executor.executor(\" THIS IS WRONG \" as any).then(\n@@ -60,11 +56,9 @@ describe(\"UseCaseExecutor\", function() {\n);\n});\nit(\"should accept executor(useCase => {}) function arguments\", () => {\n- const dispatcher = new Dispatcher();\nconst callableUseCase = new CallableUseCase();\nconst executor = new UseCaseExecutorImpl({\nuseCase: callableUseCase,\n- dispatcher,\nparent: null\n});\nreturn executor.executor(useCase => useCase.execute()).then(\n@@ -77,10 +71,8 @@ describe(\"UseCaseExecutor\", function() {\n);\n});\nit(\"executor(useCase => {}) useCase is actual wrapper object\", () => {\n- const dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new SyncNoDispatchUseCase(),\n- dispatcher,\nparent: null\n});\nreturn executor.executor(useCase => {\n@@ -90,11 +82,9 @@ describe(\"UseCaseExecutor\", function() {\n});\n});\nit(\"can call useCase.execute() by async\", done => {\n- const dispatcher = new Dispatcher();\nconst callableUseCase = new CallableUseCase();\nconst executor = new UseCaseExecutorImpl({\nuseCase: callableUseCase,\n- dispatcher,\nparent: null\n});\nexecutor\n@@ -111,10 +101,8 @@ describe(\"UseCaseExecutor\", function() {\nassert(callableUseCase.isExecuted === false, \"UseCase#execute is not called yet.\");\n});\nit(\"should show warning when UseCase#execute twice\", () => {\n- const dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new SyncNoDispatchUseCase(),\n- dispatcher,\nparent: null\n});\nreturn executor\n@@ -134,10 +122,8 @@ describe(\"UseCaseExecutor\", function() {\nit(\"dispatch will -> error -> did -> complete\", function() {\nconst callStack: string[] = [];\nconst expectedCallStack = [\"will\", \"error\", \"did\", \"complete\"];\n- const dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new ThrowUseCase(),\n- dispatcher,\nparent: null\n});\n// then\n@@ -165,7 +151,6 @@ describe(\"UseCaseExecutor\", function() {\ntype: \"SyncUseCase\",\nvalue: \"value\"\n};\n- const dispatcher = new Dispatcher();\nclass SyncUseCase extends UseCase {\nexecute(payload: Payload) {\n@@ -177,7 +162,6 @@ describe(\"UseCaseExecutor\", function() {\nconst expectedCallStack = [\"will\", \"dispatch\", \"did\", \"complete\"];\nconst executor = new UseCaseExecutorImpl({\nuseCase: new SyncUseCase(),\n- dispatcher,\nparent: null\n});\n// then\n@@ -214,10 +198,8 @@ describe(\"UseCaseExecutor\", function() {\n}\n}\n- const dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new TestUseCase(),\n- dispatcher,\nparent: null\n});\nreturn executor.execute().then(() => {\n@@ -240,10 +222,8 @@ describe(\"UseCaseExecutor\", function() {\n}\n}\n- const dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new TestUseCase(),\n- dispatcher,\nparent: null\n});\n@@ -265,10 +245,8 @@ describe(\"UseCaseExecutor\", function() {\n}\n}\n- const dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new TestUseCase(),\n- dispatcher,\nparent: null\n});\n// willNotExecute:true => resolve\n@@ -292,10 +270,8 @@ describe(\"UseCaseExecutor\", function() {\n}\n}\n- const dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new TestUseCase(),\n- dispatcher,\nparent: null\n});\nreturn executor.execute().then(\n@@ -312,10 +288,8 @@ describe(\"UseCaseExecutor\", function() {\n});\ndescribe(\"#execute\", function() {\nit(\"should catch sync throwing error in UseCase\", () => {\n- const dispatcher = new Dispatcher();\nconst executor = new UseCaseExecutorImpl({\nuseCase: new ThrowUseCase(),\n- dispatcher,\nparent: null\n});\nreturn executor.execute().then(\n@@ -334,7 +308,6 @@ describe(\"UseCaseExecutor\", function() {\ntype: \"SyncUseCase\",\nvalue: \"value\"\n};\n- const dispatcher = new Dispatcher();\nclass SyncUseCase extends UseCase {\n// 2\n@@ -347,7 +320,6 @@ describe(\"UseCaseExecutor\", function() {\n// when\nconst executor = new UseCaseExecutorImpl({\nuseCase: new SyncUseCase(),\n- dispatcher,\nparent: null\n});\n// 4\n@@ -368,7 +340,6 @@ describe(\"UseCaseExecutor\", function() {\ntype: \"SyncUseCase\",\nvalue: \"value\"\n};\n- const dispatcher = new Dispatcher();\nclass AsyncUseCase extends UseCase {\n// 2\n@@ -386,7 +357,6 @@ describe(\"UseCaseExecutor\", function() {\n// when\nconst executor = new UseCaseExecutorImpl({\nuseCase: new AsyncUseCase(),\n- dispatcher,\nparent: null\n});\nexecutor.onDispatch((payload, meta) => {\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): remove `dispatcher` from DispatchPayloadMeta
19,400
08.02.2018 20:11:01
-32,400
7a666b72f4e60c641710f1f6189e53c4d84e54b4
fix(almin): Add readonly modifier to `transaction`
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/DispatcherPayloadMeta.ts", "new_path": "packages/almin/src/DispatcherPayloadMeta.ts", "diff": "@@ -81,7 +81,7 @@ export interface DispatcherPayloadMeta {\n* If the payload object is dispatched in a transaction, to be transaction object\n* otherwise, to be undefined\n*/\n- transaction?: Transaction;\n+ readonly transaction?: Transaction;\n}\n/**\n@@ -94,7 +94,7 @@ export class DispatcherPayloadMetaImpl implements DispatcherPayloadMeta {\nreadonly timeStamp: number;\nreadonly isTrusted: boolean;\nreadonly isUseCaseFinished: boolean;\n- transaction?: Transaction;\n+ readonly transaction?: Transaction;\nconstructor(args: DispatcherPayloadMetaArgs) {\nthis.useCase = args.useCase || null;\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): Add readonly modifier to `transaction`
19,400
24.02.2018 13:03:59
-32,400
f12cef36e849ce1e4edbec8cab1e74bc2979dbda
fix(react-container): should initialize before other component We have used componentDidMount instead of componentWillMount in But, Almin React Container should be initialized before other component. Because, this component subscribe `Context#onChange`. In other words, Almin React Container can not handle `Context#onchange` when some store has been changed in Other Component#componentDidMount.
[ { "change_type": "MODIFY", "old_path": "packages/almin-react-container/src/almin-react-container.tsx", "new_path": "packages/almin-react-container/src/almin-react-container.tsx", "diff": "@@ -35,9 +35,14 @@ export class AlminReactContainer {\nstate: P;\nunSubscribe: () => void | null;\n+ onChangeHandler = () => {\n+ this.setState(context.getState());\n+ };\n+\nconstructor(props: any) {\nsuper(props);\nthis.state = context.getState();\n+ this.unSubscribe = context.onChange(this.onChangeHandler);\n}\nshouldComponentUpdate(_nextProps: any, nextState: any) {\n@@ -46,13 +51,6 @@ export class AlminReactContainer {\nreturn !shallowEqual(this.state, nextState);\n}\n- componentDidMount() {\n- const onChangeHandler = () => {\n- this.setState(context.getState());\n- };\n- this.unSubscribe = context.onChange(onChangeHandler);\n- }\n-\ncomponentWillUnmount() {\nif (typeof this.unSubscribe === \"function\") {\nthis.unSubscribe();\n" } ]
TypeScript
MIT License
almin/almin
fix(react-container): should initialize before other component We have used componentDidMount instead of componentWillMount in #321 But, Almin React Container should be initialized before other component. Because, this component subscribe `Context#onChange`. In other words, Almin React Container can not handle `Context#onchange` when some store has been changed in Other Component#componentDidMount.
19,400
11.03.2018 15:00:12
-32,400
6c007a76d082845183dfc7ea32d78ee636e0e478
feat(usecase-container): add
[ { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/usecase-container/LICENSE", "diff": "+Copyright (c) 2018 azu\n+\n+Permission is hereby granted, free of charge, to any person obtaining a copy\n+of this software and associated documentation files (the \"Software\"), to deal\n+in the Software without restriction, including without limitation the rights\n+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+copies of the Software, and to permit persons to whom the Software is\n+furnished to do so, subject to the following conditions:\n+\n+The above copyright notice and this permission notice shall be included in all\n+copies or substantial portions of the Software.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+SOFTWARE.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/usecase-container/package.json", "diff": "+{\n+ \"name\": \"usecase-container\",\n+ \"version\": \"1.0.0\",\n+ \"description\": \"A mediator for UseCase and Command.\",\n+ \"keywords\": [\n+ \"almin\",\n+ \"command\",\n+ \"usecase\"\n+ ],\n+ \"homepage\": \"https://github.com/almin/almin/tree/master/packages/@almin/usecase-container/\",\n+ \"bugs\": {\n+ \"url\": \"https://github.com/almin/almin/issues\"\n+ },\n+ \"license\": \"MIT\",\n+ \"author\": \"azu\",\n+ \"files\": [\n+ \"bin/\",\n+ \"lib/\",\n+ \"src/\"\n+ ],\n+ \"main\": \"lib/usecase-container.js\",\n+ \"types\": \"lib/usecase-container.d.ts\",\n+ \"directories\": {\n+ \"lib\": \"lib\",\n+ \"test\": \"test\"\n+ },\n+ \"repository\": {\n+ \"type\": \"git\",\n+ \"url\": \"https://github.com/almin/almin.git\"\n+ },\n+ \"scripts\": {\n+ \"build\": \"cross-env NODE_ENV=production tsc -p .\",\n+ \"prepublish\": \"npm run --if-present build\",\n+ \"test\": \"mocha \\\"test/**/*.ts\\\"\",\n+ \"prettier\": \"prettier --write \\\"**/*.{js,jsx,ts,tsx,css}\\\"\",\n+ \"watch\": \"tsc -p . --watch\"\n+ },\n+ \"peerDependencies\": {\n+ \"almin\": \"^0.16.0\"\n+ },\n+ \"devDependencies\": {\n+ \"@types/mocha\": \"^2.2.48\",\n+ \"@types/node\": \"^9.4.7\",\n+ \"cross-env\": \"^5.1.4\",\n+ \"mocha\": \"^5.0.4\",\n+ \"prettier\": \"^1.11.1\",\n+ \"ts-node\": \"^5.0.1\",\n+ \"typescript\": \"^2.7.2\"\n+ },\n+ \"prettier\": {\n+ \"singleQuote\": false,\n+ \"printWidth\": 120,\n+ \"tabWidth\": 4\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/usecase-container/src/UseCaseContainer.ts", "diff": "+import { UseCase, Context } from \"almin\";\n+\n+export type Construct<T> = {\n+ new (...args: any[]): T;\n+};\n+\n+export class UseCaseBinder<P extends UseCase, Command> {\n+ constructor(\n+ private context: Context<any>,\n+ public CommandConstructors: Construct<Command>[] = [],\n+ public useCases: P[] = []\n+ ) {}\n+\n+ bind<V extends UseCase, K extends Construct<Command>>(\n+ CommandConstructor: K,\n+ useCase: V\n+ ): UseCaseBinder<V | P, K | Command> {\n+ return new UseCaseBinder(\n+ this.context,\n+ [...this.CommandConstructors, CommandConstructor],\n+ [...this.useCases, useCase]\n+ );\n+ }\n+\n+ send(command: Command) {\n+ const CommandConstructor = (command as any).constructor;\n+ if (!CommandConstructor) {\n+ throw new Error(`This command have not .constructor property: ${command}`);\n+ }\n+ const useCases: UseCase[] = [];\n+ this.CommandConstructors.forEach((TargetCommandConstructor, index) => {\n+ if (CommandConstructor === TargetCommandConstructor) {\n+ useCases.push(this.useCases[index]);\n+ }\n+ });\n+ if (useCases.length === 0) {\n+ throw new Error(`This command have not mapped any UseCase: ${command}`);\n+ }\n+ const executedPromises = useCases.map(useCase => {\n+ this.context.useCase(useCase).executor(useCase => useCase.execute(command));\n+ });\n+ return Promise.all(executedPromises);\n+ }\n+}\n+\n+/**\n+ * A mediator for UseCase and Command.\n+ * A UseCase is almin's UseCase implementation.\n+ * A Command is UseCase#execute\n+ *\n+ * @example\n+ *\n+ * ```\n+ * const container = UseCaseContainer\n+ * .create(context)\n+ * .bind(TestCommandA, new TestUseCase())\n+ * .bind(TestCommandB, new TestUseCase());\n+ * container.send(new TestCommandA());\n+ * ```\n+ *\n+ *\n+ */\n+export class UseCaseContainer {\n+ static create(context: Context<any>) {\n+ return {\n+ bind: function<V extends UseCase, K>(CommandConstructor: Construct<K>, useCase: V): UseCaseBinder<V, K> {\n+ return new UseCaseBinder(context, [CommandConstructor], [useCase]);\n+ }\n+ };\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/usecase-container/src/index.ts", "diff": "+export { UseCaseContainer } from \"./UseCaseContainer\";\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/usecase-container/test/UseCaseContainer-test.ts", "diff": "+import { UseCase, Context } from \"almin\";\n+import { UseCaseContainer } from \"../src\";\n+import { NopeStore } from \"./helper/NopeStore\";\n+import * as assert from \"assert\";\n+\n+describe(\"UseCaseContainer\", () => {\n+ it(\"should send command to bound useCase\", () => {\n+ const context = new Context({\n+ store: new NopeStore()\n+ });\n+\n+ class TestCommand {\n+ type = \"TestCommand\";\n+ }\n+\n+ const executed: TestCommand[] = [];\n+\n+ class TestUseCase extends UseCase {\n+ execute(command: TestCommand) {\n+ executed.push(command);\n+ }\n+ }\n+\n+ const container = UseCaseContainer.create(context).bind(TestCommand, new TestUseCase());\n+ return container.send(new TestCommand()).then(() => {\n+ assert.strictEqual(executed.length, 1);\n+ assert.ok(executed[0] instanceof TestCommand);\n+ });\n+ });\n+ it(\"should bind multple command and useCase\", () => {\n+ const context = new Context({\n+ store: new NopeStore()\n+ });\n+\n+ class TestCommandA {\n+ type = \"TestCommandA\";\n+ }\n+ class TestCommandB {\n+ type = \"TestCommandB\";\n+ }\n+\n+ const executed: (TestCommandA | TestCommandB)[] = [];\n+\n+ class TestUseCaseA extends UseCase {\n+ execute(command: TestCommandA) {\n+ executed.push(command);\n+ }\n+ }\n+ class TestUseCaseB extends UseCase {\n+ execute(command: TestCommandB) {\n+ executed.push(command);\n+ }\n+ }\n+\n+ const container = UseCaseContainer.create(context)\n+ .bind(TestCommandA, new TestUseCaseA())\n+ .bind(TestCommandB, new TestUseCaseB());\n+ return container\n+ .send(new TestCommandA())\n+ .then(() => {\n+ assert.strictEqual(executed.length, 1);\n+ assert.ok(executed[0] instanceof TestCommandA);\n+ })\n+ .then(() => {\n+ return container.send(new TestCommandB());\n+ })\n+ .then(() => {\n+ assert.strictEqual(executed.length, 2);\n+ assert.ok(executed[1] instanceof TestCommandB);\n+ });\n+ });\n+\n+ it(\"should bind a Command to multiple useCase\", () => {\n+ const context = new Context({\n+ store: new NopeStore()\n+ });\n+\n+ class TestCommand {\n+ type = \"TestCommand\";\n+ }\n+ const executed: TestCommand[] = [];\n+\n+ class TestUseCaseA extends UseCase {\n+ execute(command: TestCommand) {\n+ executed.push(command);\n+ }\n+ }\n+ class TestUseCaseB extends UseCase {\n+ execute(command: TestCommand) {\n+ executed.push(command);\n+ }\n+ }\n+\n+ const container = UseCaseContainer.create(context)\n+ .bind(TestCommand, new TestUseCaseA())\n+ .bind(TestCommand, new TestUseCaseB());\n+ return container.send(new TestCommand()).then(() => {\n+ assert.strictEqual(executed.length, 2);\n+ assert.ok(executed[0] instanceof TestCommand, \"0 should be TestCommand\");\n+ assert.ok(executed[1] instanceof TestCommand, \"1 should be TestCommand\");\n+ });\n+ });\n+});\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/usecase-container/test/helper/NopeStore.ts", "diff": "+import { Store } from \"almin\";\n+\n+export class NopeStore extends Store {\n+ getState() {\n+ return {};\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/usecase-container/test/mocha.opts", "diff": "+--require ts-node-test-register\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/usecase-container/test/tsconfig.json", "diff": "+{\n+ \"extends\": \"../tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"declaration\": false\n+ },\n+ \"include\": [\n+ \"**/*\"\n+ ]\n+}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/usecase-container/tsconfig.json", "diff": "+{\n+ \"compilerOptions\": {\n+ /* Basic Options */\n+ \"module\": \"commonjs\",\n+ \"moduleResolution\": \"node\",\n+ \"newLine\": \"LF\",\n+ \"outDir\": \"./lib/\",\n+ \"target\": \"es5\",\n+ \"sourceMap\": true,\n+ \"declaration\": true,\n+ \"jsx\": \"preserve\",\n+ \"lib\": [\n+ \"es2017\",\n+ \"dom\"\n+ ],\n+ /* Strict Type-Checking Options */\n+ \"strict\": true,\n+ /* Additional Checks */\n+ \"noUnusedLocals\": true,\n+ /* Report errors on unused locals. */\n+ \"noUnusedParameters\": true,\n+ /* Report errors on unused parameters. */\n+ \"noImplicitReturns\": true,\n+ /* Report error when not all code paths in function return a value. */\n+ \"noFallthroughCasesInSwitch\": true\n+ /* Report errors for fallthrough cases in switch statement. */\n+ },\n+ \"include\": [\n+ \"src/**/*\"\n+ ],\n+ \"exclude\": [\n+ \".git\",\n+ \"node_modules\"\n+ ]\n+}\n\\ No newline at end of file\n" } ]
TypeScript
MIT License
almin/almin
feat(usecase-container): add @almin/usecase-container
19,400
11.03.2018 21:13:03
-32,400
51e4ad6b8d42c48d207c1247d822240b07c7e62f
feat: support UseCaseFactory
[ { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-container/src/UseCaseContainer.ts", "new_path": "packages/@almin/usecase-container/src/UseCaseContainer.ts", "diff": "@@ -3,23 +3,96 @@ import { UseCase, Context } from \"almin\";\nexport type Construct<T> = {\nnew (...args: any[]): T;\n};\n+export type Factory<T, Command = any> = (command: Command) => T;\n-export class UseCaseBinder<P extends UseCase, Command> {\n- constructor(\n- private context: Context<any>,\n- public CommandConstructors: Construct<Command>[] = [],\n- public useCases: P[] = []\n- ) {}\n+export class DuplicateChecker {\n+ private Commands: Construct<{}>[] = [];\n+ private useCases: UseCase[] = [];\n+ private useCaseFactories: Factory<UseCase>[] = [];\n- bind<V extends UseCase, K extends Construct<Command>>(\n+ addCommand(command: Construct<{}>) {\n+ this.Commands.push(command);\n+ }\n+\n+ addUseCase(useCase: UseCase) {\n+ this.useCases.push(useCase);\n+ }\n+\n+ addUseCaseFactory(useCaseFactory: Factory<UseCase>) {\n+ this.useCaseFactories.push(useCaseFactory);\n+ }\n+\n+ hasCommand(command: Construct<{}>) {\n+ return this.Commands.indexOf(command) !== -1;\n+ }\n+\n+ hasUseCase(useCase: UseCase) {\n+ return this.useCases.indexOf(useCase) !== -1;\n+ }\n+\n+ hasUseCaseFactory(useCaseFactory: Factory<UseCase>) {\n+ return this.useCaseFactories.indexOf(useCaseFactory) !== -1;\n+ }\n+}\n+\n+export interface UseCaseBinderArgs<T, P> {\n+ context: Context<any>;\n+ CommandConstructors: T[];\n+ useCases: P[];\n+ duplicateChecker: DuplicateChecker;\n+}\n+\n+export class UseCaseBinder<Command, P extends Factory<UseCase, any>> {\n+ private context: Context<any>;\n+ private CommandConstructors: Construct<Command>[] = [];\n+ private useCases: P[] = [];\n+ private duplicateChecker: DuplicateChecker;\n+\n+ constructor(args: UseCaseBinderArgs<Construct<Command>, P>) {\n+ this.context = args.context;\n+ this.CommandConstructors = args.CommandConstructors;\n+ this.useCases = args.useCases;\n+ this.duplicateChecker = args.duplicateChecker;\n+ }\n+\n+ bind<K extends Construct<Command>, V extends UseCase>(\nCommandConstructor: K,\nuseCase: V\n- ): UseCaseBinder<V | P, K | Command> {\n- return new UseCaseBinder(\n- this.context,\n- [...this.CommandConstructors, CommandConstructor],\n- [...this.useCases, useCase]\n- );\n+ ): UseCaseBinder<K | Command, Factory<V> | P> {\n+ if (this.duplicateChecker.hasCommand(CommandConstructor)) {\n+ throw new Error(`This Command is already bound. One Command to One UseCase. ${CommandConstructor}`);\n+ }\n+ if (this.duplicateChecker.hasUseCase(useCase)) {\n+ throw new Error(`This UseCase is already bound. One Command to One UseCase. ${useCase}`);\n+ }\n+ this.duplicateChecker.addCommand(CommandConstructor);\n+ this.duplicateChecker.addUseCase(useCase);\n+ return new UseCaseBinder({\n+ context: this.context,\n+ CommandConstructors: [...this.CommandConstructors, CommandConstructor],\n+ useCases: [...this.useCases, () => useCase],\n+ duplicateChecker: this.duplicateChecker\n+ });\n+ }\n+\n+ bindFactory<K extends Construct<Command>, V extends Factory<UseCase, any>>(\n+ CommandConstructor: K,\n+ useCaseFactory: V\n+ ): UseCaseBinder<K | Command, V | P> {\n+ if (this.CommandConstructors.indexOf(CommandConstructor) !== -1) {\n+ throw new Error(`This Command is already bound. One Command to One UseCase. ${CommandConstructor}`);\n+ }\n+ if (this.duplicateChecker.hasUseCaseFactory(useCaseFactory)) {\n+ throw new Error(`This UseCaseFactory is already bound. One Command to One UseCase. ${useCaseFactory}`);\n+ }\n+ this.duplicateChecker.addCommand(CommandConstructor);\n+ this.duplicateChecker.addUseCaseFactory(useCaseFactory);\n+ return new UseCaseBinder({\n+ context: this.context,\n+ CommandConstructors: [...this.CommandConstructors, CommandConstructor],\n+ useCases: [...this.useCases, useCaseFactory],\n+ duplicateChecker: this.duplicateChecker\n+ });\n}\nsend(command: Command) {\n@@ -27,19 +100,12 @@ export class UseCaseBinder<P extends UseCase, Command> {\nif (!CommandConstructor) {\nthrow new Error(`This command have not .constructor property: ${command}`);\n}\n- const useCases: UseCase[] = [];\n- this.CommandConstructors.forEach((TargetCommandConstructor, index) => {\n- if (CommandConstructor === TargetCommandConstructor) {\n- useCases.push(this.useCases[index]);\n- }\n- });\n- if (useCases.length === 0) {\n+ const index = this.CommandConstructors.indexOf(CommandConstructor);\n+ if (index === -1) {\nthrow new Error(`This command have not mapped any UseCase: ${command}`);\n}\n- const executedPromises = useCases.map(useCase => {\n- this.context.useCase(useCase).executor(useCase => useCase.execute(command));\n- });\n- return Promise.all(executedPromises);\n+ const useCase = this.useCases[index](command);\n+ return this.context.useCase(useCase).executor(useCase => useCase.execute(command));\n}\n}\n@@ -55,7 +121,9 @@ export class UseCaseBinder<P extends UseCase, Command> {\n* .create(context)\n* .bind(TestCommandA, new TestUseCase())\n* .bind(TestCommandB, new TestUseCase());\n- * container.send(new TestCommandA());\n+ * container.send(new TestCommandA())\n+ * .then(() => {})\n+ * .catch(error => {});\n* ```\n*\n*\n@@ -63,8 +131,35 @@ export class UseCaseBinder<P extends UseCase, Command> {\nexport class UseCaseContainer {\nstatic create(context: Context<any>) {\nreturn {\n- bind: function<V extends UseCase, K>(CommandConstructor: Construct<K>, useCase: V): UseCaseBinder<V, K> {\n- return new UseCaseBinder(context, [CommandConstructor], [useCase]);\n+ bind: function<K, V extends UseCase>(\n+ CommandConstructor: Construct<K>,\n+ useCase: V\n+ ): UseCaseBinder<K, () => V> {\n+ const duplicateChecker = new DuplicateChecker();\n+\n+ duplicateChecker.addCommand(CommandConstructor);\n+ duplicateChecker.addUseCase(useCase);\n+ return new UseCaseBinder({\n+ context,\n+ CommandConstructors: [CommandConstructor],\n+ useCases: [() => useCase],\n+ duplicateChecker\n+ });\n+ },\n+ bindFactory: function<K, V extends Factory<UseCase, K>>(\n+ CommandConstructor: Construct<K>,\n+ useCaseFactory: V\n+ ): UseCaseBinder<K, V> {\n+ const duplicateChecker = new DuplicateChecker();\n+\n+ duplicateChecker.addCommand(CommandConstructor);\n+ duplicateChecker.addUseCaseFactory(useCaseFactory);\n+ return new UseCaseBinder({\n+ context,\n+ CommandConstructors: [CommandConstructor],\n+ useCases: [useCaseFactory],\n+ duplicateChecker\n+ });\n}\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-container/test/UseCaseContainer-test.ts", "new_path": "packages/@almin/usecase-container/test/UseCaseContainer-test.ts", "diff": "@@ -4,7 +4,7 @@ import { NopeStore } from \"./helper/NopeStore\";\nimport * as assert from \"assert\";\ndescribe(\"UseCaseContainer\", () => {\n- it(\"should send command to bound useCase\", () => {\n+ it(\"should send command to bound useCase\", async () => {\nconst context = new Context({\nstore: new NopeStore()\n});\n@@ -22,12 +22,11 @@ describe(\"UseCaseContainer\", () => {\n}\nconst container = UseCaseContainer.create(context).bind(TestCommand, new TestUseCase());\n- return container.send(new TestCommand()).then(() => {\n+ await container.send(new TestCommand());\nassert.strictEqual(executed.length, 1);\nassert.ok(executed[0] instanceof TestCommand);\n});\n- });\n- it(\"should bind multple command and useCase\", () => {\n+ it(\"should bind multiple command and useCase\", async () => {\nconst context = new Context({\nstore: new NopeStore()\n});\n@@ -35,6 +34,7 @@ describe(\"UseCaseContainer\", () => {\nclass TestCommandA {\ntype = \"TestCommandA\";\n}\n+\nclass TestCommandB {\ntype = \"TestCommandB\";\n}\n@@ -46,6 +46,7 @@ describe(\"UseCaseContainer\", () => {\nexecuted.push(command);\n}\n}\n+\nclass TestUseCaseB extends UseCase {\nexecute(command: TestCommandB) {\nexecuted.push(command);\n@@ -55,22 +56,42 @@ describe(\"UseCaseContainer\", () => {\nconst container = UseCaseContainer.create(context)\n.bind(TestCommandA, new TestUseCaseA())\n.bind(TestCommandB, new TestUseCaseB());\n- return container\n- .send(new TestCommandA())\n- .then(() => {\n+ // A =>\n+ await container.send(new TestCommandA());\nassert.strictEqual(executed.length, 1);\nassert.ok(executed[0] instanceof TestCommandA);\n- })\n- .then(() => {\n- return container.send(new TestCommandB());\n- })\n- .then(() => {\n+ // B =>\n+ await container.send(new TestCommandB());\nassert.strictEqual(executed.length, 2);\nassert.ok(executed[1] instanceof TestCommandB);\n});\n+ it(\"UseCase instance should be called multiple\", async () => {\n+ const context = new Context({\n+ store: new NopeStore()\n+ });\n+\n+ class TestCommand {\n+ type = \"TestCommand\";\n+ }\n+\n+ const executed: TestCommand[] = [];\n+\n+ class TestUseCase extends UseCase {\n+ execute(command: TestCommand) {\n+ executed.push(command);\n+ }\n+ }\n+\n+ const container = UseCaseContainer.create(context).bind(TestCommand, new TestUseCase());\n+ // send\n+ await container.send(new TestCommand());\n+ await container.send(new TestCommand());\n+ await container.send(new TestCommand());\n+ // 3 executed\n+ assert.strictEqual(executed.length, 3);\n});\n- it(\"should bind a Command to multiple useCase\", () => {\n+ it(\"UseCaseFactory receive command which is sent\", async () => {\nconst context = new Context({\nstore: new NopeStore()\n});\n@@ -78,6 +99,82 @@ describe(\"UseCaseContainer\", () => {\nclass TestCommand {\ntype = \"TestCommand\";\n}\n+\n+ const executed: TestCommand[] = [];\n+ const executedFactory: TestCommand[] = [];\n+\n+ class TestUseCase extends UseCase {\n+ execute(command: TestCommand) {\n+ executed.push(command);\n+ }\n+ }\n+\n+ const createTestUseCase = (command: TestCommand) => {\n+ executedFactory.push(command);\n+ return new TestUseCase();\n+ };\n+\n+ const container = UseCaseContainer.create(context).bindFactory(TestCommand, createTestUseCase);\n+ // send TestCommand => createTestUseCase()#execute\n+ await container.send(new TestCommand());\n+ assert.strictEqual(executed.length, 1);\n+ assert.strictEqual(executedFactory.length, 1);\n+ assert.ok(executedFactory[0] instanceof TestCommand);\n+ });\n+\n+ it(\"can bind and bindFactory both\", async () => {\n+ const context = new Context({\n+ store: new NopeStore()\n+ });\n+\n+ class CommandA {\n+ type = \"CommandA\";\n+ }\n+\n+ class CommandB {\n+ type = \"CommandB\";\n+ }\n+\n+ const executed: (CommandA | CommandB)[] = [];\n+\n+ class TestUseCaseA extends UseCase {\n+ execute(command: CommandA) {\n+ executed.push(command);\n+ }\n+ }\n+\n+ class TestUseCaseB extends UseCase {\n+ execute(command: CommandB) {\n+ executed.push(command);\n+ }\n+ }\n+\n+ const createTestUseCaseB = (_command: CommandB) => {\n+ return new TestUseCaseB();\n+ };\n+\n+ const container = UseCaseContainer.create(context)\n+ .bind(CommandA, new TestUseCaseA())\n+ .bindFactory(CommandB, createTestUseCaseB);\n+ // send CommandA => execute TestUseCaseA\n+ await container.send(new CommandA());\n+ assert.strictEqual(executed.length, 1);\n+ assert.ok(executed[0] instanceof CommandA);\n+ // send CommandB => execute createTestUseCaseB()\n+ await container.send(new CommandB());\n+ assert.strictEqual(executed.length, 2);\n+ assert.ok(executed[1] instanceof CommandB);\n+ });\n+ context(\"Limitation case\", () => {\n+ it(\"could not bind with same Command\", () => {\n+ const context = new Context({\n+ store: new NopeStore()\n+ });\n+\n+ class TestCommand {\n+ type = \"TestCommand\";\n+ }\n+\nconst executed: TestCommand[] = [];\nclass TestUseCaseA extends UseCase {\n@@ -85,19 +182,43 @@ describe(\"UseCaseContainer\", () => {\nexecuted.push(command);\n}\n}\n+\nclass TestUseCaseB extends UseCase {\nexecute(command: TestCommand) {\nexecuted.push(command);\n}\n}\n- const container = UseCaseContainer.create(context)\n+ assert.throws(() => {\n+ UseCaseContainer.create(context)\n.bind(TestCommand, new TestUseCaseA())\n.bind(TestCommand, new TestUseCaseB());\n- return container.send(new TestCommand()).then(() => {\n- assert.strictEqual(executed.length, 2);\n- assert.ok(executed[0] instanceof TestCommand, \"0 should be TestCommand\");\n- assert.ok(executed[1] instanceof TestCommand, \"1 should be TestCommand\");\n+ }, /This Command is already bound/);\n+ });\n+ it(\"could not bind with same UseCaseFactory\", () => {\n+ const context = new Context({\n+ store: new NopeStore()\n+ });\n+\n+ class TestCommandA {\n+ type = \"TestCommandA\";\n+ }\n+\n+ class TestCommandB {\n+ type = \"TestCommandB\";\n+ }\n+\n+ class TestUseCase extends UseCase {\n+ execute() {}\n+ }\n+\n+ const createTestUseCase = () => new TestUseCase();\n+\n+ assert.throws(() => {\n+ UseCaseContainer.create(context)\n+ .bindFactory(TestCommandA, createTestUseCase)\n+ .bindFactory(TestCommandB, createTestUseCase);\n+ }, /This UseCaseFactory is already bound/);\n});\n});\n});\n" } ]
TypeScript
MIT License
almin/almin
feat: support UseCaseFactory
19,400
11.03.2018 22:05:32
-32,400
80565bcca93b87e2ecb962054f1ebafebf1e6839
refactor: rename ->
[ { "change_type": "MODIFY", "old_path": "lerna.json", "new_path": "lerna.json", "diff": "}\n},\n\"packages\": [\n- \"packages/*\"\n+ \"packages/*\",\n+ \"packages/@almin/*\"\n],\n\"npmClient\": \"yarn\",\n\"useWorkspaces\": true,\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"example\": \"example\"\n},\n\"workspaces\": [\n- \"packages/*\"\n+ \"packages/*\",\n+ \"packages/@almin/*\"\n],\n\"license\": \"MIT\",\n\"devDependencies\": {\n" }, { "change_type": "RENAME", "old_path": "packages/@almin/usecase-container/LICENSE", "new_path": "packages/@almin/usecase-bus/LICENSE", "diff": "" }, { "change_type": "RENAME", "old_path": "packages/@almin/usecase-container/package.json", "new_path": "packages/@almin/usecase-bus/package.json", "diff": "{\n- \"name\": \"usecase-container\",\n+ \"name\": \"usecase-bus\",\n\"version\": \"1.0.0\",\n\"description\": \"A mediator for UseCase and Command.\",\n\"keywords\": [\n\"command\",\n\"usecase\"\n],\n- \"homepage\": \"https://github.com/almin/almin/tree/master/packages/@almin/usecase-container/\",\n+ \"homepage\": \"https://github.com/almin/almin/tree/master/packages/@almin/usecase-bus/\",\n\"bugs\": {\n\"url\": \"https://github.com/almin/almin/issues\"\n},\n\"lib/\",\n\"src/\"\n],\n- \"main\": \"lib/usecase-container.js\",\n- \"types\": \"lib/usecase-container.d.ts\",\n+ \"main\": \"lib/index.js\",\n+ \"types\": \"lib/index.d.ts\",\n\"directories\": {\n\"lib\": \"lib\",\n\"test\": \"test\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/usecase-bus/src/DuplicateChecker.ts", "diff": "+import { Construct, Factory } from \"./UseCaseBus\";\n+import { UseCase } from \"almin\";\n+\n+/**\n+ * Duplicate definition checker\n+ */\n+export class DuplicateChecker {\n+ private Commands: Construct<{}>[] = [];\n+ private useCases: UseCase[] = [];\n+ private useCaseFactories: Factory<UseCase>[] = [];\n+\n+ addCommand(command: Construct<{}>) {\n+ this.Commands.push(command);\n+ }\n+\n+ addUseCase(useCase: UseCase) {\n+ this.useCases.push(useCase);\n+ }\n+\n+ addUseCaseFactory(useCaseFactory: Factory<UseCase>) {\n+ this.useCaseFactories.push(useCaseFactory);\n+ }\n+\n+ hasCommand(command: Construct<{}>) {\n+ return this.Commands.indexOf(command) !== -1;\n+ }\n+\n+ hasUseCase(useCase: UseCase) {\n+ return this.useCases.indexOf(useCase) !== -1;\n+ }\n+\n+ hasUseCaseFactory(useCaseFactory: Factory<UseCase>) {\n+ return this.useCaseFactories.indexOf(useCaseFactory) !== -1;\n+ }\n+}\n" }, { "change_type": "RENAME", "old_path": "packages/@almin/usecase-container/src/UseCaseContainer.ts", "new_path": "packages/@almin/usecase-bus/src/UseCaseBus.ts", "diff": "-import { UseCase, Context } from \"almin\";\n+import { Context, UseCase } from \"almin\";\n+import { DuplicateChecker } from \"./DuplicateChecker\";\nexport type Construct<T> = {\nnew (...args: any[]): T;\n};\nexport type Factory<T, Command = any> = (command: Command) => T;\n-export class DuplicateChecker {\n- private Commands: Construct<{}>[] = [];\n- private useCases: UseCase[] = [];\n- private useCaseFactories: Factory<UseCase>[] = [];\n-\n- addCommand(command: Construct<{}>) {\n- this.Commands.push(command);\n- }\n-\n- addUseCase(useCase: UseCase) {\n- this.useCases.push(useCase);\n- }\n-\n- addUseCaseFactory(useCaseFactory: Factory<UseCase>) {\n- this.useCaseFactories.push(useCaseFactory);\n- }\n-\n- hasCommand(command: Construct<{}>) {\n- return this.Commands.indexOf(command) !== -1;\n- }\n-\n- hasUseCase(useCase: UseCase) {\n- return this.useCases.indexOf(useCase) !== -1;\n- }\n-\n- hasUseCaseFactory(useCaseFactory: Factory<UseCase>) {\n- return this.useCaseFactories.indexOf(useCaseFactory) !== -1;\n- }\n-}\n-\nexport interface UseCaseBinderArgs<T, P> {\ncontext: Context<any>;\nCommandConstructors: T[];\n@@ -128,7 +99,7 @@ export class UseCaseBinder<Command, P extends Factory<UseCase, any>> {\n*\n*\n*/\n-export class UseCaseContainer {\n+export class UseCaseBus {\nstatic create(context: Context<any>) {\nreturn {\nbind: function<K, V extends UseCase>(\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/usecase-bus/src/index.ts", "diff": "+export { UseCaseBus } from \"./UseCaseBus\";\n" }, { "change_type": "RENAME", "old_path": "packages/@almin/usecase-container/test/UseCaseContainer-test.ts", "new_path": "packages/@almin/usecase-bus/test/UseCaseBus-test.ts", "diff": "import { UseCase, Context } from \"almin\";\n-import { UseCaseContainer } from \"../src\";\n+import { UseCaseBus } from \"../src\";\nimport { NopeStore } from \"./helper/NopeStore\";\nimport * as assert from \"assert\";\n-describe(\"UseCaseContainer\", () => {\n+describe(\"UseCaseBus\", () => {\nit(\"should send command to bound useCase\", async () => {\nconst context = new Context({\nstore: new NopeStore()\n@@ -21,8 +21,8 @@ describe(\"UseCaseContainer\", () => {\n}\n}\n- const container = UseCaseContainer.create(context).bind(TestCommand, new TestUseCase());\n- await container.send(new TestCommand());\n+ const bus = UseCaseBus.create(context).bind(TestCommand, new TestUseCase());\n+ await bus.send(new TestCommand());\nassert.strictEqual(executed.length, 1);\nassert.ok(executed[0] instanceof TestCommand);\n});\n@@ -53,15 +53,15 @@ describe(\"UseCaseContainer\", () => {\n}\n}\n- const container = UseCaseContainer.create(context)\n+ const bus = UseCaseBus.create(context)\n.bind(TestCommandA, new TestUseCaseA())\n.bind(TestCommandB, new TestUseCaseB());\n// A =>\n- await container.send(new TestCommandA());\n+ await bus.send(new TestCommandA());\nassert.strictEqual(executed.length, 1);\nassert.ok(executed[0] instanceof TestCommandA);\n// B =>\n- await container.send(new TestCommandB());\n+ await bus.send(new TestCommandB());\nassert.strictEqual(executed.length, 2);\nassert.ok(executed[1] instanceof TestCommandB);\n});\n@@ -82,11 +82,11 @@ describe(\"UseCaseContainer\", () => {\n}\n}\n- const container = UseCaseContainer.create(context).bind(TestCommand, new TestUseCase());\n+ const bus = UseCaseBus.create(context).bind(TestCommand, new TestUseCase());\n// send\n- await container.send(new TestCommand());\n- await container.send(new TestCommand());\n- await container.send(new TestCommand());\n+ await bus.send(new TestCommand());\n+ await bus.send(new TestCommand());\n+ await bus.send(new TestCommand());\n// 3 executed\nassert.strictEqual(executed.length, 3);\n});\n@@ -114,7 +114,7 @@ describe(\"UseCaseContainer\", () => {\nreturn new TestUseCase();\n};\n- const container = UseCaseContainer.create(context).bindFactory(TestCommand, createTestUseCase);\n+ const container = UseCaseBus.create(context).bindFactory(TestCommand, createTestUseCase);\n// send TestCommand => createTestUseCase()#execute\nawait container.send(new TestCommand());\nassert.strictEqual(executed.length, 1);\n@@ -153,15 +153,15 @@ describe(\"UseCaseContainer\", () => {\nreturn new TestUseCaseB();\n};\n- const container = UseCaseContainer.create(context)\n+ const bus = UseCaseBus.create(context)\n.bind(CommandA, new TestUseCaseA())\n.bindFactory(CommandB, createTestUseCaseB);\n// send CommandA => execute TestUseCaseA\n- await container.send(new CommandA());\n+ await bus.send(new CommandA());\nassert.strictEqual(executed.length, 1);\nassert.ok(executed[0] instanceof CommandA);\n// send CommandB => execute createTestUseCaseB()\n- await container.send(new CommandB());\n+ await bus.send(new CommandB());\nassert.strictEqual(executed.length, 2);\nassert.ok(executed[1] instanceof CommandB);\n});\n@@ -190,7 +190,7 @@ describe(\"UseCaseContainer\", () => {\n}\nassert.throws(() => {\n- UseCaseContainer.create(context)\n+ UseCaseBus.create(context)\n.bind(TestCommand, new TestUseCaseA())\n.bind(TestCommand, new TestUseCaseB());\n}, /This Command is already bound/);\n@@ -215,7 +215,7 @@ describe(\"UseCaseContainer\", () => {\nconst createTestUseCase = () => new TestUseCase();\nassert.throws(() => {\n- UseCaseContainer.create(context)\n+ UseCaseBus.create(context)\n.bindFactory(TestCommandA, createTestUseCase)\n.bindFactory(TestCommandB, createTestUseCase);\n}, /This UseCaseFactory is already bound/);\n" }, { "change_type": "RENAME", "old_path": "packages/@almin/usecase-container/test/helper/NopeStore.ts", "new_path": "packages/@almin/usecase-bus/test/helper/NopeStore.ts", "diff": "" }, { "change_type": "RENAME", "old_path": "packages/@almin/usecase-container/test/mocha.opts", "new_path": "packages/@almin/usecase-bus/test/mocha.opts", "diff": "" }, { "change_type": "RENAME", "old_path": "packages/@almin/usecase-container/test/tsconfig.json", "new_path": "packages/@almin/usecase-bus/test/tsconfig.json", "diff": "" }, { "change_type": "RENAME", "old_path": "packages/@almin/usecase-container/tsconfig.json", "new_path": "packages/@almin/usecase-bus/tsconfig.json", "diff": "" }, { "change_type": "DELETE", "old_path": "packages/@almin/usecase-container/src/index.ts", "new_path": null, "diff": "-export { UseCaseContainer } from \"./UseCaseContainer\";\n" } ]
TypeScript
MIT License
almin/almin
refactor: rename @almin/usecase-container -> @almin/usecase-bus
19,400
12.03.2018 09:50:10
-32,400
ada426be85207308fb8b9d167617a8b2d9f169d5
fix: release binding
[ { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-bus/src/UseCaseBus.ts", "new_path": "packages/@almin/usecase-bus/src/UseCaseBus.ts", "diff": "@@ -9,23 +9,29 @@ export type Factory<T, Command = any> = (command: Command) => T;\nexport interface UseCaseBinderArgs<T, P> {\ncontext: Context<any>;\nCommandConstructors: T[];\n- useCases: P[];\n+ useCaseFactories: P[];\nduplicateChecker: DuplicateChecker;\n}\nexport class UseCaseBinder<Command, P extends Factory<UseCase, any>> {\nprivate context: Context<any>;\nprivate CommandConstructors: Construct<Command>[] = [];\n- private useCases: P[] = [];\n+ private useCaseFactories: P[] = [];\nprivate duplicateChecker: DuplicateChecker;\n+ // If true, this binder should not use\n+ private hasDelegateNewBiding = false;\n+\nconstructor(args: UseCaseBinderArgs<Construct<Command>, P>) {\nthis.context = args.context;\nthis.CommandConstructors = args.CommandConstructors;\n- this.useCases = args.useCases;\n+ this.useCaseFactories = args.useCaseFactories;\nthis.duplicateChecker = args.duplicateChecker;\n}\n+ /**\n+ * Bind the `CommandConstructor` to `useCase` instance.\n+ */\nbind<K extends Construct<Command>, V extends UseCase>(\nCommandConstructor: K,\nuseCase: V\n@@ -38,14 +44,19 @@ export class UseCaseBinder<Command, P extends Factory<UseCase, any>> {\n}\nthis.duplicateChecker.addCommand(CommandConstructor);\nthis.duplicateChecker.addUseCase(useCase);\n+ this.releaseBinding();\nreturn new UseCaseBinder({\ncontext: this.context,\nCommandConstructors: [...this.CommandConstructors, CommandConstructor],\n- useCases: [...this.useCases, () => useCase],\n+ useCaseFactories: [...this.useCaseFactories, () => useCase],\nduplicateChecker: this.duplicateChecker\n});\n}\n+ /**\n+ * Bind the `CommandConstructor` to `useCaseFactory`.\n+ * `useCaseFactory` is factory function to create a UseCase instance.\n+ */\nbindFactory<K extends Construct<Command>, V extends Factory<UseCase, any>>(\nCommandConstructor: K,\nuseCaseFactory: V\n@@ -58,26 +69,55 @@ export class UseCaseBinder<Command, P extends Factory<UseCase, any>> {\n}\nthis.duplicateChecker.addCommand(CommandConstructor);\nthis.duplicateChecker.addUseCaseFactory(useCaseFactory);\n+ this.releaseBinding();\nreturn new UseCaseBinder({\ncontext: this.context,\nCommandConstructors: [...this.CommandConstructors, CommandConstructor],\n- useCases: [...this.useCases, useCaseFactory],\n+ useCaseFactories: [...this.useCaseFactories, useCaseFactory],\nduplicateChecker: this.duplicateChecker\n});\n}\nsend(command: Command) {\n+ if (this.hasDelegateNewBiding) {\n+ throw new Error(`You should use last return value of bind/bindFactory to send a Command.\n+NG:\n+\n+const container = UseCaseContainer.create(context);\n+// You should use the return value of bnd\n+container.bind(CommandA, new UseCaseA())\n+ .bind(CommandB, new UseCaseB());\n+// this container is already released\n+container.send(CommandA);\n+\n+OK:\n+\n+const container = UseCaseContainer\n+ .create(context)\n+ .bind(CommandA, new UseCaseA())\n+ .bind(CommandB, new UseCaseB());\n+container.send(CommandA);\n+`);\n+ }\nconst CommandConstructor = (command as any).constructor;\nif (!CommandConstructor) {\n- throw new Error(`This command have not .constructor property: ${command}`);\n+ throw new Error(`This command should be instance of Command: ${command}`);\n}\nconst index = this.CommandConstructors.indexOf(CommandConstructor);\nif (index === -1) {\nthrow new Error(`This command have not mapped any UseCase: ${command}`);\n}\n- const useCase = this.useCases[index](command);\n+ const useCaseFactory = this.useCaseFactories[index];\n+ if (!useCaseFactory) {\n+ throw new Error(`UseCase is not found for the command: ${command}`);\n+ }\n+ const useCase = useCaseFactory(command);\nreturn this.context.useCase(useCase).executor(useCase => useCase.execute(command));\n}\n+\n+ private releaseBinding() {\n+ this.hasDelegateNewBiding = true;\n+ }\n}\n/**\n@@ -90,8 +130,8 @@ export class UseCaseBinder<Command, P extends Factory<UseCase, any>> {\n* ```\n* const container = UseCaseContainer\n* .create(context)\n- * .bind(TestCommandA, new TestUseCase())\n- * .bind(TestCommandB, new TestUseCase());\n+ * .bind(CommandA, new UseCaseA())\n+ * .bind(CommandB, new UseCaseB());\n* container.send(new TestCommandA())\n* .then(() => {})\n* .catch(error => {});\n@@ -101,37 +141,12 @@ export class UseCaseBinder<Command, P extends Factory<UseCase, any>> {\n*/\nexport class UseCaseBus {\nstatic create(context: Context<any>) {\n- return {\n- bind: function<K, V extends UseCase>(\n- CommandConstructor: Construct<K>,\n- useCase: V\n- ): UseCaseBinder<K, () => V> {\nconst duplicateChecker = new DuplicateChecker();\n-\n- duplicateChecker.addCommand(CommandConstructor);\n- duplicateChecker.addUseCase(useCase);\nreturn new UseCaseBinder({\ncontext,\n- CommandConstructors: [CommandConstructor],\n- useCases: [() => useCase],\n- duplicateChecker\n+ duplicateChecker,\n+ CommandConstructors: [],\n+ useCaseFactories: []\n});\n- },\n- bindFactory: function<K, V extends Factory<UseCase, K>>(\n- CommandConstructor: Construct<K>,\n- useCaseFactory: V\n- ): UseCaseBinder<K, V> {\n- const duplicateChecker = new DuplicateChecker();\n-\n- duplicateChecker.addCommand(CommandConstructor);\n- duplicateChecker.addUseCaseFactory(useCaseFactory);\n- return new UseCaseBinder({\n- context,\n- CommandConstructors: [CommandConstructor],\n- useCases: [useCaseFactory],\n- duplicateChecker\n- });\n- }\n- };\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-bus/test/UseCaseBus-test.ts", "new_path": "packages/@almin/usecase-bus/test/UseCaseBus-test.ts", "diff": "@@ -166,6 +166,32 @@ describe(\"UseCaseBus\", () => {\nassert.ok(executed[1] instanceof CommandB);\n});\ncontext(\"Limitation case\", () => {\n+ it(\"could not use old binding instance\", () => {\n+ const context = new Context({\n+ store: new NopeStore()\n+ });\n+\n+ class TestCommandA {\n+ type = \"TestCommandA\";\n+ }\n+\n+ class TestCommandB {\n+ type = \"TestCommandB\";\n+ }\n+ class TestUseCaseA extends UseCase {\n+ execute() {}\n+ }\n+\n+ class TestUseCaseB extends UseCase {\n+ execute() {}\n+ }\n+\n+ assert.throws(() => {\n+ const container = UseCaseBus.create(context).bind(TestCommandA, new TestUseCaseA());\n+ container.bind(TestCommandB, new TestUseCaseB());\n+ container.send(TestCommandA);\n+ }, /You should use last return value of bind/);\n+ });\nit(\"could not bind with same Command\", () => {\nconst context = new Context({\nstore: new NopeStore()\n@@ -175,18 +201,12 @@ describe(\"UseCaseBus\", () => {\ntype = \"TestCommand\";\n}\n- const executed: TestCommand[] = [];\n-\nclass TestUseCaseA extends UseCase {\n- execute(command: TestCommand) {\n- executed.push(command);\n- }\n+ execute() {}\n}\nclass TestUseCaseB extends UseCase {\n- execute(command: TestCommand) {\n- executed.push(command);\n- }\n+ execute() {}\n}\nassert.throws(() => {\n" } ]
TypeScript
MIT License
almin/almin
fix: release binding
19,400
12.03.2018 09:57:53
-32,400
b4fccec124824ceffa3a44fc2d7131b98e8c3ccb
fix: add almin to devDependencies
[ { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-bus/package.json", "new_path": "packages/@almin/usecase-bus/package.json", "diff": "\"devDependencies\": {\n\"@types/mocha\": \"^2.2.48\",\n\"@types/node\": \"^9.4.7\",\n+ \"almin\": \"^0.16.0\",\n\"cross-env\": \"^5.1.4\",\n\"mocha\": \"^5.0.4\",\n\"prettier\": \"^1.11.1\",\n" } ]
TypeScript
MIT License
almin/almin
fix: add almin to devDependencies
19,400
14.03.2018 19:09:59
-32,400
e03cb7c3e80bd93aff1d9c319cdb8194c97b7c4a
chore: rename to UseCaseCommandBus
[ { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-bus/README.md", "new_path": "packages/@almin/usecase-bus/README.md", "diff": "@@ -39,7 +39,7 @@ Install with [npm](https://www.npmjs.com/):\n```ts\nimport { UseCase, Context } from \"almin\";\n-import { UseCaseBus } from \"@almin/usecase-bus\"\n+import { UseCaseCommandBus } from \"@almin/usecase-bus\"\n// async code\n(async () => {\nconst context = new Context({\n@@ -73,7 +73,7 @@ import { UseCaseBus } from \"@almin/usecase-bus\"\n};\n// create binding between Command Constructor and UseCase/UseCaseFactory.\n- const bus = UseCaseBus.create(context)\n+ const bus = UseCaseCommandBus.create(context)\n.bind(CommandA, new TestUseCaseA())\n.bindFactory(CommandB, createTestUseCaseB);\n// send CommandA => execute TestUseCaseA\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-bus/src/DuplicateChecker.ts", "new_path": "packages/@almin/usecase-bus/src/DuplicateChecker.ts", "diff": "-import { Construct, Factory } from \"./UseCaseBus\";\n+import { Construct, Factory } from \"./UseCaseCommandBus\";\nimport { UseCase } from \"almin\";\n/**\n" }, { "change_type": "RENAME", "old_path": "packages/@almin/usecase-bus/src/UseCaseBus.ts", "new_path": "packages/@almin/usecase-bus/src/UseCaseCommandBus.ts", "diff": "@@ -128,7 +128,7 @@ container.send(CommandA);\n* @example\n*\n* ```\n- * const container = UseCaseContainer\n+ * const container = UseCaseCommandBus\n* .create(context)\n* .bind(CommandA, new UseCaseA())\n* .bind(CommandB, new UseCaseB());\n@@ -139,7 +139,7 @@ container.send(CommandA);\n*\n*\n*/\n-export class UseCaseBus {\n+export class UseCaseCommandBus {\nstatic create(context: Context<any>) {\nconst duplicateChecker = new DuplicateChecker();\nreturn new UseCaseBinder({\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-bus/src/index.ts", "new_path": "packages/@almin/usecase-bus/src/index.ts", "diff": "-export { UseCaseBus } from \"./UseCaseBus\";\n+export { UseCaseCommandBus } from \"./UseCaseCommandBus\";\n" }, { "change_type": "RENAME", "old_path": "packages/@almin/usecase-bus/test/UseCaseBus-test.ts", "new_path": "packages/@almin/usecase-bus/test/UseCaseCommandBus-test.ts", "diff": "import { UseCase, Context } from \"almin\";\n-import { UseCaseBus } from \"../src\";\n+import { UseCaseCommandBus } from \"../src\";\nimport { NopeStore } from \"./helper/NopeStore\";\nimport * as assert from \"assert\";\n@@ -21,7 +21,7 @@ describe(\"UseCaseBus\", () => {\n}\n}\n- const bus = UseCaseBus.create(context).bind(TestCommand, new TestUseCase());\n+ const bus = UseCaseCommandBus.create(context).bind(TestCommand, new TestUseCase());\nawait bus.send(new TestCommand());\nassert.strictEqual(executed.length, 1);\nassert.ok(executed[0] instanceof TestCommand);\n@@ -53,7 +53,7 @@ describe(\"UseCaseBus\", () => {\n}\n}\n- const bus = UseCaseBus.create(context)\n+ const bus = UseCaseCommandBus.create(context)\n.bind(TestCommandA, new TestUseCaseA())\n.bind(TestCommandB, new TestUseCaseB());\n// A =>\n@@ -82,7 +82,7 @@ describe(\"UseCaseBus\", () => {\n}\n}\n- const bus = UseCaseBus.create(context).bind(TestCommand, new TestUseCase());\n+ const bus = UseCaseCommandBus.create(context).bind(TestCommand, new TestUseCase());\n// send\nawait bus.send(new TestCommand());\nawait bus.send(new TestCommand());\n@@ -114,7 +114,7 @@ describe(\"UseCaseBus\", () => {\nreturn new TestUseCase();\n};\n- const container = UseCaseBus.create(context).bindFactory(TestCommand, createTestUseCase);\n+ const container = UseCaseCommandBus.create(context).bindFactory(TestCommand, createTestUseCase);\n// send TestCommand => createTestUseCase()#execute\nawait container.send(new TestCommand());\nassert.strictEqual(executed.length, 1);\n@@ -153,7 +153,7 @@ describe(\"UseCaseBus\", () => {\nreturn new TestUseCaseB();\n};\n- const bus = UseCaseBus.create(context)\n+ const bus = UseCaseCommandBus.create(context)\n.bind(CommandA, new TestUseCaseA())\n.bindFactory(CommandB, createTestUseCaseB);\n// send CommandA => execute TestUseCaseA\n@@ -187,7 +187,7 @@ describe(\"UseCaseBus\", () => {\n}\nassert.throws(() => {\n- const container = UseCaseBus.create(context).bind(TestCommandA, new TestUseCaseA());\n+ const container = UseCaseCommandBus.create(context).bind(TestCommandA, new TestUseCaseA());\ncontainer.bind(TestCommandB, new TestUseCaseB());\ncontainer.send(TestCommandA);\n}, /You should use last return value of bind/);\n@@ -210,7 +210,7 @@ describe(\"UseCaseBus\", () => {\n}\nassert.throws(() => {\n- UseCaseBus.create(context)\n+ UseCaseCommandBus.create(context)\n.bind(TestCommand, new TestUseCaseA())\n.bind(TestCommand, new TestUseCaseB());\n}, /This Command is already bound/);\n@@ -235,7 +235,7 @@ describe(\"UseCaseBus\", () => {\nconst createTestUseCase = () => new TestUseCase();\nassert.throws(() => {\n- UseCaseBus.create(context)\n+ UseCaseCommandBus.create(context)\n.bindFactory(TestCommandA, createTestUseCase)\n.bindFactory(TestCommandB, createTestUseCase);\n}, /This UseCaseFactory is already bound/);\n" } ]
TypeScript
MIT License
almin/almin
chore: rename to UseCaseCommandBus
19,400
14.03.2018 19:33:39
-32,400
72fa00c6a5c06ad0c0d384fd4c03c70962285b21
refactor(almin): use `assertOK` instead of `assert` module
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/Dispatcher.ts", "new_path": "packages/almin/src/Dispatcher.ts", "diff": "// LICENSE : MIT\n\"use strict\";\n-import * as assert from \"assert\";\nimport { EventEmitter } from \"events\";\nimport { DispatcherPayloadMeta, DispatcherPayloadMetaImpl } from \"./DispatcherPayloadMeta\";\n@@ -13,6 +12,7 @@ import { TransactionBeganPayload } from \"./payload/TransactionBeganPayload\";\nimport { TransactionEndedPayload } from \"./payload/TransactionEndedPayload\";\nimport { StoreChangedPayload } from \"./payload/StoreChangedPayload\";\nimport { AnyPayload } from \"./payload/AnyPayload\";\n+import { assertOK } from \"./util/assert\";\n/**\n* @private\n@@ -118,10 +118,10 @@ export class Dispatcher extends EventEmitter {\n*/\ndispatch(payload: DispatchedPayload, meta?: DispatcherPayloadMeta): void {\nif (process.env.NODE_ENV !== \"production\") {\n- assert.ok(payload !== undefined && payload !== null, \"payload should not null or undefined\");\n- assert.ok(typeof payload.type !== \"undefined\", \"payload's `type` should be required\");\n+ assertOK(payload !== undefined && payload !== null, \"payload should not null or undefined\");\n+ assertOK(typeof payload.type !== \"undefined\", \"payload's `type` should be required\");\nif (meta !== undefined) {\n- assert.ok(meta instanceof DispatcherPayloadMetaImpl, \"`meta` object is internal arguments.\");\n+ assertOK(meta instanceof DispatcherPayloadMetaImpl, \"`meta` object is internal arguments.\");\n}\n}\n// `meta` must be generated by system\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/FunctionalUseCase.ts", "new_path": "packages/almin/src/FunctionalUseCase.ts", "diff": "@@ -6,8 +6,8 @@ import { Dispatcher } from \"./Dispatcher\";\nimport { generateNewId } from \"./UseCaseIdGenerator\";\nimport { DispatcherPayloadMetaImpl } from \"./DispatcherPayloadMeta\";\nimport { ErrorPayload } from \"./payload/ErrorPayload\";\n-import * as assert from \"assert\";\nimport { Payload } from \"./payload/Payload\";\n+import { assertOK } from \"./util/assert\";\nexport const defaultUseCaseName = \"<Functiona-UseCase>\";\nexport type UseCaseArgs = (context: FunctionalUseCaseContext) => Function;\n@@ -15,7 +15,7 @@ const getFunctionalExecute = (functionalUseCase: UseCaseArgs, context: Functiona\ntry {\nconst execute = functionalUseCase(context);\nif (process.env.NODE_ENV !== \"production\") {\n- assert.ok(typeof execute === \"function\", \"Functional UseCase should return a executor function.\");\n+ assertOK(typeof execute === \"function\", \"Functional UseCase should return a executor function.\");\n}\nreturn execute;\n} catch (error) {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UILayer/StoreGroupValidator.ts", "new_path": "packages/almin/src/UILayer/StoreGroupValidator.ts", "diff": "// LICENSE : MIT\n\"use strict\";\n-import * as assert from \"assert\";\nimport { Dispatcher } from \"../Dispatcher\";\n+import { assertOK } from \"../util/assert\";\n/*\nStoreGroup\n@@ -16,12 +16,12 @@ export class StoreGroupValidator {\n* Context treat StoreGroup like object as StoreGroup.\n*/\nstatic validateInstance(storeGroup: any): void {\n- assert.ok(storeGroup !== undefined, \"store should not be undefined\");\n- assert.ok(Dispatcher.isDispatcher(storeGroup), \"storeGroup should be inherited Dispatcher\");\n- assert.ok(typeof storeGroup.onChange === \"function\", \"StoreGroup should have #onChange method\");\n- assert.ok(typeof storeGroup.getState === \"function\", \"StoreGroup should have #getState method\");\n+ assertOK(storeGroup !== undefined, \"store should not be undefined\");\n+ assertOK(Dispatcher.isDispatcher(storeGroup), \"storeGroup should be inherited Dispatcher\");\n+ assertOK(typeof storeGroup.onChange === \"function\", \"StoreGroup should have #onChange method\");\n+ assertOK(typeof storeGroup.getState === \"function\", \"StoreGroup should have #getState method\");\n// #release is optional\n- assert.ok(\n+ assertOK(\ntypeof storeGroup.release === \"undefined\" || typeof storeGroup.release === \"function\",\n\"StoreGroup may have #release method\"\n);\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseContext.ts", "new_path": "packages/almin/src/UseCaseContext.ts", "diff": "@@ -7,8 +7,7 @@ import { FunctionalUseCase } from \"./FunctionalUseCase\";\nimport { UseCaseFunction } from \"./FunctionalUseCaseContext\";\nimport { UseCaseLike } from \"./UseCaseLike\";\nimport { createUseCaseExecutor } from \"./UseCaseExecutorFactory\";\n-\n-const assert = require(\"assert\");\n+import { assertOK } from \"./util/assert\";\n/**\n* Maybe, `UseCaseContext` is invisible from Public API.\n@@ -75,7 +74,7 @@ export class UseCaseContext {\nuseCase<T extends UseCaseLike>(useCase: T): UseCaseExecutor<T>;\nuseCase(useCase: any): UseCaseExecutor<any> {\nif (process.env.NODE_ENV !== \"production\") {\n- assert(\n+ assertOK(\nuseCase !== this._dispatcher,\n`the useCase(${useCase}) should not equal this useCase(${this._dispatcher})`\n);\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "// LICENSE : MIT\n\"use strict\";\n-import * as assert from \"assert\";\nimport { Dispatcher } from \"./Dispatcher\";\nimport { UseCase } from \"./UseCase\";\nimport { DispatcherPayloadMeta, DispatcherPayloadMetaImpl } from \"./DispatcherPayloadMeta\";\n@@ -12,6 +11,7 @@ import { WillExecutedPayload } from \"./payload/WillExecutedPayload\";\nimport { UseCaseLike } from \"./UseCaseLike\";\nimport { Payload } from \"./payload/Payload\";\nimport { WillNotExecutedPayload } from \"./payload/WillNotExecutedPayload\";\n+import { assertOK } from \"./util/assert\";\ninterface InvalidUsage {\ntype: \"InvalidUsage\";\n@@ -185,8 +185,8 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\nif (process.env.NODE_ENV !== \"production\") {\n// execute and finish =>\nconst useCaseName = useCase.name;\n- assert.ok(typeof useCaseName === \"string\", `UseCase instance should have constructor.name ${useCase}`);\n- assert.ok(\n+ assertOK(typeof useCaseName === \"string\", `UseCase instance should have constructor.name ${useCase}`);\n+ assertOK(\ntypeof useCase.execute === \"function\",\n`UseCase instance should have #execute function: ${useCaseName}`\n);\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutorFactory.ts", "new_path": "packages/almin/src/UseCaseExecutorFactory.ts", "diff": "@@ -2,8 +2,8 @@ import { UseCaseExecutorImpl } from \"./UseCaseExecutor\";\nimport { isUseCaseFunction, UseCaseFunction } from \"./FunctionalUseCaseContext\";\nimport { FunctionalUseCase } from \"./FunctionalUseCase\";\nimport { isUseCase, UseCase } from \"./UseCase\";\n-import * as assert from \"assert\";\nimport { Dispatcher } from \"./Dispatcher\";\n+import { assertOK } from \"./util/assert\";\nexport function createUseCaseExecutor(\nuseCase: UseCaseFunction,\n@@ -19,7 +19,7 @@ export function createUseCaseExecutor(useCase: any, dispatcher: Dispatcher): Use\n});\n} else if (isUseCaseFunction(useCase)) {\n// When pass UseCase constructor itself, throw assertion error\n- assert.ok(\n+ assertOK(\nObject.getPrototypeOf && Object.getPrototypeOf(useCase) !== UseCase,\n`Context#useCase argument should be instance of UseCase.\nThe argument is UseCase constructor itself: ${useCase}`\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/almin/src/util/assert.ts", "diff": "+export function assertOK(expression: boolean, message: string): void {\n+ if (!expression) {\n+ throw new Error(message);\n+ }\n+}\n" } ]
TypeScript
MIT License
almin/almin
refactor(almin): use `assertOK` instead of `assert` module
19,400
28.03.2018 09:29:57
-32,400
6e05dd9fadea2d2596f1c8ca1ebd2db2589453f5
[Git Cancel] Temporary commit for cancel
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"textlint-rule-common-misspellings\": \"^1.0.1\",\n\"textlint-rule-no-dead-link\": \"^4.3.0\",\n\"textlint-rule-prh\": \"^5.0.1\",\n- \"typescript\": \"~2.6.2\"\n+ \"typescript\": \"~2.8.1\"\n},\n\"scripts\": {\n\"precommit\": \"lint-staged\",\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-bus/package.json", "new_path": "packages/@almin/usecase-bus/package.json", "diff": "\"prettier\": \"^1.11.1\",\n\"ts-node\": \"^5.0.1\",\n\"ts-node-test-register\": \"^2.0.0\",\n- \"typescript\": \"^2.7.2\"\n+ \"typescript\": \"^2.8.1\"\n},\n\"prettier\": {\n\"singleQuote\": false,\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-logger/package.json", "new_path": "packages/almin-logger/package.json", "diff": "\"power-assert\": \"^1.4.4\",\n\"rimraf\": \"^2.6.2\",\n\"simple-mock\": \"^0.8.0\",\n- \"typescript\": \"~2.6.2\",\n+ \"typescript\": \"~2.8.1\",\n\"webpack\": \"^3.8.1\",\n\"zuul\": \"^3.10.1\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-react-container/package.json", "new_path": "packages/almin-react-container/package.json", "diff": "},\n\"devDependencies\": {\n\"@types/node\": \"^9.3.0\",\n- \"@types/react\": \"16.0.35\",\n- \"@types/react-dom\": \"16.0.3\",\n+ \"@types/react\": \"16.1.0\",\n+ \"@types/react-dom\": \"16.0.4\",\n\"almin\": \"^0.16.0\",\n\"babel-preset-env\": \"^1.6.1\",\n\"babel-preset-power-assert\": \"^1.0.0\",\n\"react\": \"^16.1.1\",\n\"react-dom\": \"^16.1.1\",\n\"rimraf\": \"^2.6.2\",\n- \"ts-node\": \"^4.1.0\",\n- \"typescript\": \"~2.6.2\"\n+ \"ts-node\": \"^5.0.1\",\n+ \"typescript\": \"~2.8.1\"\n},\n\"dependencies\": {\n\"shallow-equal-object\": \"^1.0.1\"\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"sinon\": \"^2.3.8\",\n\"size-limit\": \"^0.14.0\",\n\"source-map-support\": \"^0.4.15\",\n- \"ts-node\": \"^4.1.0\",\n- \"ts-node-test-register\": \"^1.0.1\",\n- \"typescript\": \"~2.6.2\",\n+ \"ts-node\": \"^5.0.1\",\n+ \"ts-node-test-register\": \"^2.0.0\",\n+ \"typescript\": \"~2.8.1\",\n\"zuul\": \"^3.10.1\"\n},\n\"dependencies\": {\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "\"@types/node\" \"*\"\n\"@types/react\" \"*\"\n-\"@types/react@*\":\n- version \"16.0.36\"\n- resolved \"https://registry.yarnpkg.com/@types/react/-/react-16.0.36.tgz#ceb5639013bdb92a94147883052e69bb2c22c69b\"\n+\"@types/react-dom@16.0.4\":\n+ version \"16.0.4\"\n+ resolved \"https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.0.4.tgz#2e8fd45f5443780ed49bf2cdd9809e6091177a7d\"\n+ dependencies:\n+ \"@types/node\" \"*\"\n+ \"@types/react\" \"*\"\n-\"@types/react@16.0.35\":\n+\"@types/react@*\", \"@types/react@16.0.35\":\nversion \"16.0.35\"\nresolved \"https://registry.yarnpkg.com/@types/react/-/react-16.0.35.tgz#7ce8a83cad9690fd965551fc513217a74fc9e079\"\n+\"@types/react@16.1.0\":\n+ version \"16.1.0\"\n+ resolved \"https://registry.yarnpkg.com/@types/react/-/react-16.1.0.tgz#6c0e9955ce73f332b4a1948d45decaf18c764c6e\"\n+\n\"@types/sinon@^4.1.3\":\nversion \"4.1.3\"\nresolved \"https://registry.yarnpkg.com/@types/sinon/-/sinon-4.1.3.tgz#2ee25e0e302f31e78a945650a60029e08878eaf8\"\n-\"@types/strip-bom@^3.0.0\":\n- version \"3.0.0\"\n- resolved \"https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2\"\n-\n-\"@types/strip-json-comments@0.0.30\":\n- version \"0.0.30\"\n- resolved \"https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1\"\n-\nJSON2@0.1.0:\nversion \"0.1.0\"\nresolved \"https://registry.yarnpkg.com/JSON2/-/JSON2-0.1.0.tgz#8d7493040a63d5835af75f47decb83ab6c8c0790\"\n@@ -325,7 +324,13 @@ ansi-styles@^2.2.1:\nversion \"2.2.1\"\nresolved \"https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe\"\n-ansi-styles@^3.1.0, ansi-styles@^3.2.0:\n+ansi-styles@^3.1.0, ansi-styles@^3.2.1:\n+ version \"3.2.1\"\n+ resolved \"https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d\"\n+ dependencies:\n+ color-convert \"^1.9.0\"\n+\n+ansi-styles@^3.2.0:\nversion \"3.2.0\"\nresolved \"https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88\"\ndependencies:\n@@ -1678,7 +1683,7 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3:\nstrip-ansi \"^3.0.0\"\nsupports-color \"^2.0.0\"\n-chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0:\n+chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0:\nversion \"2.3.0\"\nresolved \"https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba\"\ndependencies:\n@@ -1686,6 +1691,14 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0:\nescape-string-regexp \"^1.0.5\"\nsupports-color \"^4.0.0\"\n+chalk@^2.3.0:\n+ version \"2.3.2\"\n+ resolved \"https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65\"\n+ dependencies:\n+ ansi-styles \"^3.2.1\"\n+ escape-string-regexp \"^1.0.5\"\n+ supports-color \"^5.3.0\"\n+\nchar-split@0.2.0:\nversion \"0.2.0\"\nresolved \"https://registry.yarnpkg.com/char-split/-/char-split-0.2.0.tgz#8755eda641e5db277dd0f509b517c827e50a8edf\"\n@@ -2735,7 +2748,7 @@ diff@3.3.1:\nversion \"3.3.1\"\nresolved \"https://registry.yarnpkg.com/diff/-/diff-3.3.1.tgz#aa8567a6eed03c531fc89d3f711cd0e5259dec75\"\n-diff@3.5.0:\n+diff@3.5.0, diff@^3.1.0:\nversion \"3.5.0\"\nresolved \"https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12\"\n@@ -2743,7 +2756,7 @@ diff@^2.2.2:\nversion \"2.2.3\"\nresolved \"https://registry.yarnpkg.com/diff/-/diff-2.2.3.tgz#60eafd0d28ee906e4e8ff0a52c1229521033bf99\"\n-diff@^3.1.0, diff@^3.3.0:\n+diff@^3.3.0:\nversion \"3.4.0\"\nresolved \"https://registry.yarnpkg.com/diff/-/diff-3.4.0.tgz#b1d85507daf3964828de54b37d0d73ba67dda56c\"\n@@ -4089,6 +4102,10 @@ has-flag@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51\"\n+has-flag@^3.0.0:\n+ version \"3.0.0\"\n+ resolved \"https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd\"\n+\nhas-unicode@^2.0.0:\nversion \"2.0.1\"\nresolved \"https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9\"\n@@ -4192,13 +4209,11 @@ home-or-tmp@^2.0.0:\nos-homedir \"^1.0.0\"\nos-tmpdir \"^1.0.1\"\n-homedir-polyfill@^1.0.1:\n- version \"1.0.1\"\n- resolved \"https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz#4c2bbc8a758998feebf5ed68580f76d46768b4bc\"\n- dependencies:\n- parse-passwd \"^1.0.0\"\n+hosted-git-info@^2.1.4:\n+ version \"2.6.0\"\n+ resolved \"https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.6.0.tgz#23235b29ab230c576aab0d4f13fc046b0b038222\"\n-hosted-git-info@^2.1.4, hosted-git-info@^2.5.0:\n+hosted-git-info@^2.5.0:\nversion \"2.5.0\"\nresolved \"https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.5.0.tgz#6d60e34b3abbc8313062c3b798ef8d901a07af3c\"\n@@ -5393,8 +5408,8 @@ make-dir@^1.0.0:\npify \"^3.0.0\"\nmake-error@^1.1.1:\n- version \"1.3.3\"\n- resolved \"https://registry.yarnpkg.com/make-error/-/make-error-1.3.3.tgz#a97ae14ffd98b05f543e83ddc395e1b2b6e4cc6a\"\n+ version \"1.3.4\"\n+ resolved \"https://registry.yarnpkg.com/make-error/-/make-error-1.3.4.tgz#19978ed575f9e9545d2ff8c13e33b5d18a67d535\"\nmap-like@^2.0.0:\nversion \"2.0.0\"\n@@ -6289,10 +6304,6 @@ parse-latin@^4.0.0:\nunist-util-modify-children \"^1.0.0\"\nunist-util-visit-children \"^1.0.0\"\n-parse-passwd@^1.0.0:\n- version \"1.0.0\"\n- resolved \"https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6\"\n-\nparse5@4.0.0:\nversion \"4.0.0\"\nresolved \"https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608\"\n@@ -7861,9 +7872,9 @@ source-map-support@^0.4.15:\ndependencies:\nsource-map \"^0.5.6\"\n-source-map-support@^0.5.0, source-map-support@^0.5.3:\n- version \"0.5.3\"\n- resolved \"https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.3.tgz#2b3d5fff298cfa4d1afd7d4352d569e9a0158e76\"\n+source-map-support@^0.5.3:\n+ version \"0.5.4\"\n+ resolved \"https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.4.tgz#54456efa89caa9270af7cd624cc2f123e51fbae8\"\ndependencies:\nsource-map \"^0.6.0\"\n@@ -7900,19 +7911,27 @@ spawn-to-readstream@~0.1.3:\nlimit-spawn \"0.0.3\"\nthrough2 \"~0.4.1\"\n-spdx-correct@~1.0.0:\n- version \"1.0.2\"\n- resolved \"https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40\"\n+spdx-correct@^3.0.0:\n+ version \"3.0.0\"\n+ resolved \"https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.0.0.tgz#05a5b4d7153a195bc92c3c425b69f3b2a9524c82\"\ndependencies:\n- spdx-license-ids \"^1.0.2\"\n+ spdx-expression-parse \"^3.0.0\"\n+ spdx-license-ids \"^3.0.0\"\n-spdx-expression-parse@~1.0.0:\n- version \"1.0.4\"\n- resolved \"https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c\"\n+spdx-exceptions@^2.1.0:\n+ version \"2.1.0\"\n+ resolved \"https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz#2c7ae61056c714a5b9b9b2b2af7d311ef5c78fe9\"\n-spdx-license-ids@^1.0.2:\n- version \"1.2.2\"\n- resolved \"https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57\"\n+spdx-expression-parse@^3.0.0:\n+ version \"3.0.0\"\n+ resolved \"https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz#99e119b7a5da00e05491c9fa338b7904823b41d0\"\n+ dependencies:\n+ spdx-exceptions \"^2.1.0\"\n+ spdx-license-ids \"^3.0.0\"\n+\n+spdx-license-ids@^3.0.0:\n+ version \"3.0.0\"\n+ resolved \"https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz#7a7cd28470cc6d3a1cfe6d66886f6bc430d3ac87\"\nsplit-transform-stream@~0.1.1:\nversion \"0.1.1\"\n@@ -8179,7 +8198,7 @@ strip-indent@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68\"\n-strip-json-comments@^2.0.0, strip-json-comments@~2.0.1:\n+strip-json-comments@~2.0.1:\nversion \"2.0.1\"\nresolved \"https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a\"\n@@ -8259,6 +8278,12 @@ supports-color@^5.1.0:\ndependencies:\nhas-flag \"^2.0.0\"\n+supports-color@^5.3.0:\n+ version \"5.3.0\"\n+ resolved \"https://registry.yarnpkg.com/supports-color/-/supports-color-5.3.0.tgz#5b24ac15db80fa927cf5227a4a33fd3c4c7676c0\"\n+ dependencies:\n+ has-flag \"^3.0.0\"\n+\nsvgo@^0.7.0:\nversion \"0.7.2\"\nresolved \"https://registry.yarnpkg.com/svgo/-/svgo-0.7.2.tgz#9f5772413952135c6fefbf40afe6a4faa88b4bb5\"\n@@ -8629,33 +8654,12 @@ tryer@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/tryer/-/tryer-1.0.0.tgz#027b69fa823225e551cace3ef03b11f6ab37c1d7\"\n-ts-node-test-register@^1.0.1:\n- version \"1.0.1\"\n- resolved \"https://registry.yarnpkg.com/ts-node-test-register/-/ts-node-test-register-1.0.1.tgz#2496000aabcaca96973ece6164ffd6f1c2f6a82d\"\n- dependencies:\n- read-pkg \"^3.0.0\"\n-\nts-node-test-register@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/ts-node-test-register/-/ts-node-test-register-2.0.0.tgz#ca4d2b82a19414baa66f0080057e3b35e4a4ddfb\"\ndependencies:\nread-pkg \"^3.0.0\"\n-ts-node@^4.1.0:\n- version \"4.1.0\"\n- resolved \"https://registry.yarnpkg.com/ts-node/-/ts-node-4.1.0.tgz#36d9529c7b90bb993306c408cd07f7743de20712\"\n- dependencies:\n- arrify \"^1.0.0\"\n- chalk \"^2.3.0\"\n- diff \"^3.1.0\"\n- make-error \"^1.1.1\"\n- minimist \"^1.2.0\"\n- mkdirp \"^0.5.1\"\n- source-map-support \"^0.5.0\"\n- tsconfig \"^7.0.0\"\n- v8flags \"^3.0.0\"\n- yn \"^2.0.0\"\n-\nts-node@^5.0.1:\nversion \"5.0.1\"\nresolved \"https://registry.yarnpkg.com/ts-node/-/ts-node-5.0.1.tgz#78e5d1cb3f704de1b641e43b76be2d4094f06f81\"\n@@ -8669,15 +8673,6 @@ ts-node@^5.0.1:\nsource-map-support \"^0.5.3\"\nyn \"^2.0.0\"\n-tsconfig@^7.0.0:\n- version \"7.0.0\"\n- resolved \"https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7\"\n- dependencies:\n- \"@types/strip-bom\" \"^3.0.0\"\n- \"@types/strip-json-comments\" \"0.0.30\"\n- strip-bom \"^3.0.0\"\n- strip-json-comments \"^2.0.0\"\n-\ntty-browserify@0.0.0:\nversion \"0.0.0\"\nresolved \"https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6\"\n@@ -8725,13 +8720,9 @@ typedarray@^0.0.6, typedarray@~0.0.5:\nversion \"0.0.6\"\nresolved \"https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777\"\n-typescript@^2.7.2:\n- version \"2.7.2\"\n- resolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.7.2.tgz#2d615a1ef4aee4f574425cdff7026edf81919836\"\n-\n-typescript@~2.6.2:\n- version \"2.6.2\"\n- resolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4\"\n+typescript@^2.8.1, typescript@~2.8.1:\n+ version \"2.8.1\"\n+ resolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.8.1.tgz#6160e4f8f195d5ba81d4876f9c0cc1fbc0820624\"\nua-parser-js@^0.7.9:\nversion \"0.7.17\"\n@@ -9038,18 +9029,12 @@ uuid@^3.0.0, uuid@^3.0.1, uuid@^3.1.0:\nversion \"3.2.1\"\nresolved \"https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14\"\n-v8flags@^3.0.0:\n- version \"3.0.1\"\n- resolved \"https://registry.yarnpkg.com/v8flags/-/v8flags-3.0.1.tgz#dce8fc379c17d9f2c9e9ed78d89ce00052b1b76b\"\n- dependencies:\n- homedir-polyfill \"^1.0.1\"\n-\nvalidate-npm-package-license@^3.0.1:\n- version \"3.0.1\"\n- resolved \"https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc\"\n+ version \"3.0.3\"\n+ resolved \"https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz#81643bcbef1bdfecd4623793dc4648948ba98338\"\ndependencies:\n- spdx-correct \"~1.0.0\"\n- spdx-expression-parse \"~1.0.0\"\n+ spdx-correct \"^3.0.0\"\n+ spdx-expression-parse \"^3.0.0\"\nvargs@~0.1.0:\nversion \"0.1.0\"\n" } ]
TypeScript
MIT License
almin/almin
[Git Cancel] Temporary commit for cancel
19,400
28.03.2018 09:40:02
-32,400
0231f423fb0f9c24f66409912ea7a504c11d6c45
fix(almin): Make `Payload` abstract class completely BREAKING CHANGE: You can not call `super({ type: "type" })` anymore. `Payload` does not accept arguments
[ { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"ts-node\": \"^5.0.1\",\n\"ts-node-test-register\": \"^2.0.0\",\n\"typescript\": \"~2.8.1\",\n+ \"typings-tester\": \"^0.3.1\",\n\"zuul\": \"^3.10.1\"\n},\n\"dependencies\": {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/FunctionalUseCase.ts", "new_path": "packages/almin/src/FunctionalUseCase.ts", "diff": "@@ -59,11 +59,6 @@ export class FunctionalUseCase extends Dispatcher implements UseCaseLike {\n*/\nexecutor: Function;\n- /**\n- * Dispatcher\n- */\n- dispatcher: Dispatcher;\n-\n/**\n* The default is UseCase name\n*/\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/payload/Payload.ts", "new_path": "packages/almin/src/payload/Payload.ts", "diff": "// LICENSE : MIT\n\"use strict\";\n-\n-export interface PayloadArgs {\n- type: any;\n-}\n-\n-export abstract class Payload {\n+export abstract class Payload<T = any> {\n/**\n* `type` is unique property of the payload.\n* A `type` property which may not be `undefined`\n* It is a good idea to use string constants or Symbol for payload types.\n*/\n- abstract readonly type: any;\n-\n- constructor(args?: PayloadArgs) {\n- if (args) {\n- this.type = args.type;\n- }\n- }\n+ abstract readonly type: T;\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/Dispatcher-test.ts", "new_path": "packages/almin/test/Dispatcher-test.ts", "diff": "@@ -44,12 +44,7 @@ describe(\"Dispatcher\", function() {\nconst dispatcher = new Dispatcher();\nclass MyPayload extends Payload {\n- type: string;\n-\n- // Not have type\n- constructor() {\n- super({ type: \"MyPayload\" });\n- }\n+ type = \"MyPayload\";\n}\ndispatcher.onDispatch(payload => {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/StoreGroup-test.ts", "new_path": "packages/almin/test/StoreGroup-test.ts", "diff": "@@ -43,13 +43,13 @@ describe(\"StoreGroup\", function() {\nnew StoreGroup();\n});\nassert.throws(() => {\n- new StoreGroup([]);\n+ new StoreGroup([] as any);\n});\nassert.throws(() => {\nnew StoreGroup({\na: 1,\nb: 2\n- });\n+ } as any);\n});\n});\nit(\"support stateName and store mapping \", () => {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/mocha.opts", "new_path": "packages/almin/test/mocha.opts", "diff": "--recursive\n--require env-development\n--require ts-node-test-register\n+--timeout 10000\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/almin/test/type-test.ts", "diff": "+import * as assert from \"assert\";\n+import * as path from \"path\";\n+import { check } from \"typings-tester\";\n+\n+describe(\"typings\", () => {\n+ it(\"pass\", () => {\n+ assert.doesNotThrow(() => check([path.join(__dirname, \"typescript/almin.ts\")], \"tsconfig.json\"));\n+ });\n+ it(\"fail\", () => {});\n+});\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -1955,6 +1955,10 @@ commander@>=2.9.0, commander@^2.11.0, commander@^2.13.0, commander@^2.9.0:\nversion \"2.14.1\"\nresolved \"https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa\"\n+commander@^2.12.2:\n+ version \"2.15.1\"\n+ resolved \"https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f\"\n+\ncommander@~2.13.0:\nversion \"2.13.0\"\nresolved \"https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c\"\n@@ -6802,11 +6806,7 @@ preserve@^0.2.0:\nversion \"0.2.0\"\nresolved \"https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b\"\n-prettier@^1.10.2:\n- version \"1.10.2\"\n- resolved \"https://registry.yarnpkg.com/prettier/-/prettier-1.10.2.tgz#1af8356d1842276a99a5b5529c82dd9e9ad3cc93\"\n-\n-prettier@^1.11.1:\n+prettier@^1.10.2, prettier@^1.11.1:\nversion \"1.11.1\"\nresolved \"https://registry.yarnpkg.com/prettier/-/prettier-1.11.1.tgz#61e43fc4cd44e68f2b0dfc2c38cd4bb0fccdcc75\"\n@@ -8713,6 +8713,12 @@ typescript@^2.8.1, typescript@~2.8.1:\nversion \"2.8.1\"\nresolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.8.1.tgz#6160e4f8f195d5ba81d4876f9c0cc1fbc0820624\"\n+typings-tester@^0.3.1:\n+ version \"0.3.1\"\n+ resolved \"https://registry.yarnpkg.com/typings-tester/-/typings-tester-0.3.1.tgz#53bb9784b0ebd7b93192e6fcd908f14501af3878\"\n+ dependencies:\n+ commander \"^2.12.2\"\n+\nua-parser-js@^0.7.9:\nversion \"0.7.17\"\nresolved \"https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac\"\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): Make `Payload` abstract class completely BREAKING CHANGE: You can not call `super({ type: "type" })` anymore. `Payload` does not accept arguments
19,400
28.03.2018 22:05:14
-32,400
9881793f94b20907953811a4e7acb9023e8b828d
feat(almin): Support `context.useCase#execute` typing Use conditional typing
[ { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"lint:js\": \"eslint --config ../../.eslintrc.json --cache test/\",\n\"lint:js:fix\": \"eslint --fix --config ../../.eslintrc.json --cache test/\",\n\"test\": \"run-s lint test:js\",\n- \"test:js\": \"cross-env NODE_ENV=development mocha \\\"test/**/*.{js,ts}\\\"\",\n+ \"test:js\": \"cross-env NODE_ENV=development mocha \\\"test/**/*-test.{js,ts}\\\"\",\n\"test:saucelabs\": \"npm run build:test && zuul -- out/test/*-test.js\",\n\"test:browser\": \"npm run build:test && zuul --local 8080 --ui mocha-bdd -- out/test/*-test.js\",\n\"presize\": \"npm-run-all -s clean build\",\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -13,6 +13,13 @@ import { Payload } from \"./payload/Payload\";\nimport { WillNotExecutedPayload } from \"./payload/WillNotExecutedPayload\";\nimport { assertOK } from \"./util/assert\";\n+// Conditional Typing in TS 2.8 >=\n+// Get Argument of T function and return tuple\n+export type A0<T> = T extends () => any ? T : never;\n+export type A1<T> = T extends (a1: infer R1) => any ? [R1] : [never];\n+export type A2<T> = T extends (a1: infer R1, a2: infer R2) => any ? [R1, R2] : [never, never];\n+export type A3<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3) => any ? [R1, R2, R3] : [never, never, never];\n+\ninterface InvalidUsage {\ntype: \"InvalidUsage\";\nerror: Error;\n@@ -139,11 +146,14 @@ export interface UseCaseExecutor<T extends UseCaseLike> extends Dispatcher {\nexecutor(executor: (useCase: Pick<T, \"execute\">) => any): Promise<void>;\n- execute(): Promise<void>;\n+ // FIXME: should fix `execute()` pattern\n+ execute<P extends A0<T[\"execute\"]>>(): P extends never ? never : Promise<void>;\n+\n+ execute<P extends A1<T[\"execute\"]>>(a1: P[0]): Promise<void>;\n- execute<T>(args: T): Promise<void>;\n+ execute<P extends A2<T[\"execute\"]>>(a1: P[0], a2: P[1]): Promise<void>;\n- execute(...args: Array<any>): Promise<void>;\n+ execute<P extends A3<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2]): Promise<void>;\nrelease(): void;\n}\n@@ -363,10 +373,10 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n// proxiedUseCase will resolve by UseCaseWrapper#execute\n// For more details, see <UseCaseLifeCycle-test.ts>\nconst proxyfiedUseCase = proxifyUseCase<T>(this.useCase, {\n- onWillNotExecute: args => {\n+ onWillNotExecute: (args: any[]) => {\nthis.willNotExecuteUseCase(args);\n},\n- onWillExecute: args => {\n+ onWillExecute: (args: any[]) => {\nthis.willExecuteUseCase(args);\n},\nonDidExecute: (result?: any) => {\n@@ -435,8 +445,10 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n* The `execute(arguments)` is shortcut of `executor(useCase => useCase.execute(arguments)`\n*\n*/\n- execute(): Promise<void>;\n- execute<T>(args: T): Promise<void>;\n+ execute<P extends A0<T[\"execute\"]>>(this: P extends never ? never : this): Promise<void>;\n+ execute<P extends A1<T[\"execute\"]>>(a1: P[0]): Promise<void>;\n+ execute<P extends A2<T[\"execute\"]>>(a1: P[0], a2: P[1]): Promise<void>;\n+ execute<P extends A3<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2]): Promise<void>;\nexecute(...args: Array<any>): Promise<void> {\nreturn this.executor(useCase => useCase.execute(...args));\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/type-test.ts", "new_path": "packages/almin/test/type-test.ts", "diff": "@@ -2,9 +2,18 @@ import * as assert from \"assert\";\nimport * as path from \"path\";\nimport { check } from \"typings-tester\";\n-describe(\"typings\", () => {\n- it(\"pass\", () => {\n- assert.doesNotThrow(() => check([path.join(__dirname, \"typescript/almin.ts\")], \"tsconfig.json\"));\n+const test = (fileName: string) => {\n+ it(`${fileName} should be passed`, () => {\n+ try {\n+ check([path.join(__dirname, `typing-fixtures/${fileName}`)], \"tsconfig.json\");\n+ } catch (error) {\n+ assert.fail(error.stack);\n+ }\n});\n- it(\"fail\", () => {});\n+};\n+describe(\"typings\", () => {\n+ test(\"almin.ts\");\n+ test(\"almin-loading.ts\");\n+ test(\"non-execute-arguments.ts\");\n+ test(\"mismatch-execute-arguments.ts\");\n});\n" }, { "change_type": "RENAME", "old_path": "packages/almin/test/typescript/almin-loading.ts", "new_path": "packages/almin/test/typing-fixtures/almin-loading.ts", "diff": "@@ -54,7 +54,7 @@ const context = new Context({\n});\ncontext\n.useCase(loadingUseCase)\n- .execute<UpdateLoadingUseCaseArg>(true)\n+ .execute(true)\n.then(() => {\n// nope\n});\n" }, { "change_type": "RENAME", "old_path": "packages/almin/test/typescript/almin.ts", "new_path": "packages/almin/test/typing-fixtures/almin.ts", "diff": "@@ -126,7 +126,7 @@ const functionalUseCase = (context: FunctionalUseCaseContext) => {\n// execute - functional execute with ArgT\ncontext\n.useCase(functionalUseCase)\n- .execute<functionUseCaseArgs>(\"1\")\n+ .execute(\"1\")\n.then(() => {\nconst state = context.getState();\nlog(state.aState.a);\n@@ -143,7 +143,7 @@ context\n// execute: usecase with T\ncontext\n.useCase(parentUseCase)\n- .execute<ParentUseCaseArgs>(\"value\")\n+ .execute(\"value\")\n.then(() => {\nconst state = context.getState();\nlog(state.aState.a);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/almin/test/typing-fixtures/mismatch-execute-arguments.ts", "diff": "+import { UseCase, Context } from \"../../src/index\";\n+import { createStore } from \"../helper/create-new-store\";\n+class MyUseCase extends UseCase {\n+ execute(_a1: number, _a2: string) {}\n+}\n+\n+const context = new Context({\n+ store: createStore({ name: \"test\" })\n+});\n+\n+// typings:expect-error\n+context\n+ .useCase(new MyUseCase())\n+ .execute()\n+ .then(() => {\n+ // FIXME:\n+ });\n+// typings:expect-error\n+context.useCase(new MyUseCase()).execute(1);\n+// typings:expect-error\n+context.useCase(new MyUseCase()).execute(1, 2);\n+// typings:expect-error\n+context.useCase(new MyUseCase()).execute(\"\", 2);\n+// typings:expect-error\n+context.useCase(new MyUseCase()).execute({ key: \"value\" });\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/almin/test/typing-fixtures/non-execute-arguments.ts", "diff": "+import { UseCase, Context } from \"../../src/index\";\n+import { createStore } from \"../helper/create-new-store\";\n+class MyUseCase extends UseCase {\n+ execute() {}\n+}\n+\n+const context = new Context({\n+ store: createStore({ name: \"test\" })\n+});\n+\n+context.useCase(new MyUseCase()).execute();\n" } ]
TypeScript
MIT License
almin/almin
feat(almin): Support `context.useCase#execute` typing Use conditional typing
19,400
03.04.2018 10:15:33
-32,400
8570b923574d1debe6909fea616a3ef444b3c181
chore(almin): fix warning message
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/UILayer/StoreGroup.ts", "new_path": "packages/almin/src/UILayer/StoreGroup.ts", "diff": "@@ -388,7 +388,7 @@ But, ${store.name}#getState() was called.`\n* Almin can control all transaction to StoreGroup.\n*\n* It means that StoreGroup doesn't use `this.onDispatch`.\n- * It use `commit` insteadof receive data vis `this.onDispatch`.\n+ * It use `commit` insteadof receive data via `this.onDispatch`.\n*/\ncommit(commitment: Commitment): void {\nconst payload = commitment.payload;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UILayer/StoreGroupEmitChangeChecker.ts", "new_path": "packages/almin/src/UILayer/StoreGroupEmitChangeChecker.ts", "diff": "@@ -52,18 +52,24 @@ const warningIfStatePropertyIsModifiedDirectly = (store: Store, prevState: any,\nconsole.error(\n`Warning(Store): ${\nstore.name\n- }#state property is replaced by different value, but this change **does not** reflect to view.\n-Because, ${store.name}#shouldStateUpdate(prevState, store.state) has returned **false**.\n+ }#state property is replaced by different value directly, but this changes **does not** reflect to view.\n+Because, ${store.name}#shouldStateUpdate(prevState, newState) has returned **false**.\n+It means that you have replaced store's state by new state directly, but it is not correct way.\n-It means that the variance is present between ${store.name}#state property and shouldStateUpdate.\n-You should update the state vis \\`Store#setState\\` method.\n+NG: assign newState to state property directly\n-For example, you should update the state by following:\n+ this.state = newState;\n+\n+The mismatch is occurred between ${store.name}#state property and shouldStateUpdate.\n+You should use \\`Store#setState\\` method for updating store's state.\n+\n+OK: update state via setState\nthis.setState(newState);\n// OR\n+ // setState alias\nif(this.shouldStateUpdate(this.state, newState)){\nthis.state = newState;\n}\n" } ]
TypeScript
MIT License
almin/almin
chore(almin): fix warning message
19,400
26.04.2018 20:24:08
-32,400
8ba58b87d1a4880b032e132f5a35bfa6eea147ca
test(almin): fix execute testing
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -14,11 +14,63 @@ import { WillNotExecutedPayload } from \"./payload/WillNotExecutedPayload\";\nimport { assertOK } from \"./util/assert\";\n// Conditional Typing in TS 2.8 >=\n-// Get Argument of T function and return tuple\n+// Get Arguments of T function and return tuple\nexport type A0<T> = T extends () => any ? T : never;\nexport type A1<T> = T extends (a1: infer R1) => any ? [R1] : [never];\nexport type A2<T> = T extends (a1: infer R1, a2: infer R2) => any ? [R1, R2] : [never, never];\nexport type A3<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3) => any ? [R1, R2, R3] : [never, never, never];\n+export type A4<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4) => any\n+ ? [R1, R2, R3, R4]\n+ : [never, never, never, never];\n+export type A5<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5) => any\n+ ? [R1, R2, R3, R4, R5]\n+ : [never, never, never, never, never];\n+export type A6<T> = T extends (\n+ a1: infer R1,\n+ a2: infer R2,\n+ a3: infer R3,\n+ a4: infer R4,\n+ a5: infer R5,\n+ a6: infer R6\n+) => any\n+ ? [R1, R2, R3, R4, R5, R6]\n+ : [never, never, never, never, never, never];\n+export type A7<T> = T extends (\n+ a1: infer R1,\n+ a2: infer R2,\n+ a3: infer R3,\n+ a4: infer R4,\n+ a5: infer R5,\n+ a6: infer R6,\n+ a7: infer R7\n+) => any\n+ ? [R1, R2, R3, R4, R5, R6, R7]\n+ : [never, never, never, never, never, never, never];\n+export type A8<T> = T extends (\n+ a1: infer R1,\n+ a2: infer R2,\n+ a3: infer R3,\n+ a4: infer R4,\n+ a5: infer R5,\n+ a6: infer R6,\n+ a7: infer R7,\n+ a8: infer R8\n+) => any\n+ ? [R1, R2, R3, R4, R5, R6, R7, R8]\n+ : [never, never, never, never, never, never, never, never];\n+export type A9<T> = T extends (\n+ a1: infer R1,\n+ a2: infer R2,\n+ a3: infer R3,\n+ a4: infer R4,\n+ a5: infer R5,\n+ a6: infer R6,\n+ a7: infer R7,\n+ a8: infer R8,\n+ a9: infer R9\n+) => any\n+ ? [R1, R2, R3, R4, R5, R6, R7, R8, R9]\n+ : [never, never, never, never, never, never, never, never, never];\ninterface InvalidUsage {\ntype: \"InvalidUsage\";\n@@ -146,14 +198,44 @@ export interface UseCaseExecutor<T extends UseCaseLike> extends Dispatcher {\nexecutor(executor: (useCase: Pick<T, \"execute\">) => any): Promise<void>;\n- // FIXME: should fix `execute()` pattern\n- execute<P extends A0<T[\"execute\"]>>(): P extends never ? never : Promise<void>;\n-\n+ // FIXME: `execute()` pattern without hack\n+ execute<P extends A0<T[\"execute\"]>>(this: P extends never ? never : this): Promise<void>;\nexecute<P extends A1<T[\"execute\"]>>(a1: P[0]): Promise<void>;\n-\nexecute<P extends A2<T[\"execute\"]>>(a1: P[0], a2: P[1]): Promise<void>;\n-\nexecute<P extends A3<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2]): Promise<void>;\n+ execute<P extends A4<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3]): Promise<void>;\n+ execute<P extends A5<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4]): Promise<void>;\n+ execute<P extends A6<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5]): Promise<void>;\n+ execute<P extends A7<T[\"execute\"]>>(\n+ a1: P[0],\n+ a2: P[1],\n+ a3: P[2],\n+ a4: P[3],\n+ a5: P[4],\n+ a6: P[5],\n+ a7: P[6]\n+ ): Promise<void>;\n+ execute<P extends A8<T[\"execute\"]>>(\n+ a1: P[0],\n+ a2: P[1],\n+ a3: P[2],\n+ a4: P[3],\n+ a5: P[4],\n+ a6: P[5],\n+ a7: P[6],\n+ a8: P[7]\n+ ): Promise<void>;\n+ execute<P extends A9<T[\"execute\"]>>(\n+ a1: P[0],\n+ a2: P[1],\n+ a3: P[2],\n+ a4: P[3],\n+ a5: P[4],\n+ a6: P[5],\n+ a7: P[6],\n+ a8: P[7],\n+ a9: P[8]\n+ ): Promise<void>;\nrelease(): void;\n}\n@@ -434,7 +516,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n}\n/**\n- * execute UseCase instance.\n+ * Execute UseCase instance.\n* UseCase is a executable object that has `execute` method.\n*\n* This method invoke UseCase's `execute` method and return a promise<void>.\n@@ -444,11 +526,51 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n*\n* The `execute(arguments)` is shortcut of `executor(useCase => useCase.execute(arguments)`\n*\n+ * ### `execute()` typing for TypeScript\n+ *\n+ * > Almin 0.17.0 >=\n+ *\n+ * `execute()` support type check in Almin 0.17.0.\n+ * However, it has a limitation about argument lengths.\n+ * For more details, please see <URL>\n*/\nexecute<P extends A0<T[\"execute\"]>>(this: P extends never ? never : this): Promise<void>;\nexecute<P extends A1<T[\"execute\"]>>(a1: P[0]): Promise<void>;\nexecute<P extends A2<T[\"execute\"]>>(a1: P[0], a2: P[1]): Promise<void>;\nexecute<P extends A3<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2]): Promise<void>;\n+ execute<P extends A4<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3]): Promise<void>;\n+ execute<P extends A5<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4]): Promise<void>;\n+ execute<P extends A6<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5]): Promise<void>;\n+ execute<P extends A7<T[\"execute\"]>>(\n+ a1: P[0],\n+ a2: P[1],\n+ a3: P[2],\n+ a4: P[3],\n+ a5: P[4],\n+ a6: P[5],\n+ a7: P[6]\n+ ): Promise<void>;\n+ execute<P extends A8<T[\"execute\"]>>(\n+ a1: P[0],\n+ a2: P[1],\n+ a3: P[2],\n+ a4: P[3],\n+ a5: P[4],\n+ a6: P[5],\n+ a7: P[6],\n+ a8: P[7]\n+ ): Promise<void>;\n+ execute<P extends A9<T[\"execute\"]>>(\n+ a1: P[0],\n+ a2: P[1],\n+ a3: P[2],\n+ a4: P[3],\n+ a5: P[4],\n+ a6: P[5],\n+ a7: P[6],\n+ a8: P[7],\n+ a9: P[8]\n+ ): Promise<void>;\nexecute(...args: Array<any>): Promise<void> {\nreturn this.executor(useCase => useCase.execute(...args));\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/type-test.ts", "new_path": "packages/almin/test/type-test.ts", "diff": "@@ -14,6 +14,5 @@ const test = (fileName: string) => {\ndescribe(\"typings\", () => {\ntest(\"almin.ts\");\ntest(\"almin-loading.ts\");\n- test(\"non-execute-arguments.ts\");\n- test(\"mismatch-execute-arguments.ts\");\n+ test(\"execute-argument.ts\");\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/typing-fixtures/almin.ts", "new_path": "packages/almin/test/typing-fixtures/almin.ts", "diff": "@@ -180,8 +180,8 @@ context\ncontext\n.transaction(\"my work\", async transactionContext => {\n- await transactionContext.useCase(new MyUseCase()).execute();\n- await transactionContext.useCase(new ParentUseCase()).execute();\n+ await transactionContext.useCase(new MyUseCase()).execute(\"string\");\n+ await transactionContext.useCase(new ParentUseCase()).execute(\"string\");\ntransactionContext.commit();\n})\n.then(() => {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/almin/test/typing-fixtures/execute-argument.ts", "diff": "+import { UseCase, Context } from \"../../src/index\";\n+import { createStore } from \"../helper/create-new-store\";\n+class MyUseCaseNoArgument extends UseCase {\n+ execute() {}\n+}\n+class MyUseCaseA extends UseCase {\n+ execute(_a: string) {}\n+}\n+\n+class MyUseCaseB extends UseCase {\n+ execute(_a: string, _b: number) {}\n+}\n+\n+class MyUseCaseObj extends UseCase {\n+ execute(_args: { a: string; b: number }) {}\n+}\n+\n+class MyUseCaseOptional extends UseCase {\n+ execute(_value?: string) {}\n+}\n+\n+class MyUseCaseDefault extends UseCase {\n+ execute(_value: string = \"string\") {}\n+}\n+const context = new Context({\n+ store: createStore({ name: \"test\" })\n+});\n+\n+// valid\n+context.useCase(new MyUseCaseNoArgument()).execute();\n+context.useCase(new MyUseCaseA()).execute(\"A\");\n+context.useCase(new MyUseCaseB()).execute(\"B\", 2);\n+context.useCase(new MyUseCaseObj()).execute({ a: \"A\", b: 2 });\n+context.useCase(new MyUseCaseOptional()).execute();\n+context.useCase(new MyUseCaseOptional()).execute(\"string\");\n+context.useCase(new MyUseCaseDefault()).execute();\n+context.useCase(new MyUseCaseDefault()).execute(\"string\");\n+// invalid\n+// typings:expect-error\n+context.useCase(new MyUseCaseA()).execute();\n+// typings:expect-error\n+context.useCase(new MyUseCaseA()).execute(1);\n+// typings:expect-error\n+context.useCase(new MyUseCaseA()).execute(1, 2);\n+// typings:expect-error\n+context.useCase(new MyUseCaseA()).execute({ key: \"value\" });\n+// typings:expect-error\n+context.useCase(new MyUseCaseB()).execute(1, 2);\n+// typings:expect-error\n+context.useCase(new MyUseCaseObj()).execute({ a: 1, b: 2 });\n+// typings:expect-error\n+context.useCase(new MyUseCaseOptional()).execute(1, 1);\n+// typings:expect-error\n+context.useCase(new MyUseCaseDefault()).execute(1);\n+\n+// =====\n+// FIXME: These are should be Error, but current not support\n+// =====\n+// more arguments\n+\n+context.useCase(new MyUseCaseA()).execute(\"A\", 1, 1);\n" }, { "change_type": "DELETE", "old_path": "packages/almin/test/typing-fixtures/mismatch-execute-arguments.ts", "new_path": null, "diff": "-import { UseCase, Context } from \"../../src/index\";\n-import { createStore } from \"../helper/create-new-store\";\n-class MyUseCase extends UseCase {\n- execute(_a1: number, _a2: string) {}\n-}\n-\n-const context = new Context({\n- store: createStore({ name: \"test\" })\n-});\n-\n-// typings:expect-error\n-context\n- .useCase(new MyUseCase())\n- .execute()\n- .then(() => {\n- // FIXME:\n- });\n-// typings:expect-error\n-context.useCase(new MyUseCase()).execute(1);\n-// typings:expect-error\n-context.useCase(new MyUseCase()).execute(1, 2);\n-// typings:expect-error\n-context.useCase(new MyUseCase()).execute(\"\", 2);\n-// typings:expect-error\n-context.useCase(new MyUseCase()).execute({ key: \"value\" });\n" }, { "change_type": "DELETE", "old_path": "packages/almin/test/typing-fixtures/non-execute-arguments.ts", "new_path": null, "diff": "-import { UseCase, Context } from \"../../src/index\";\n-import { createStore } from \"../helper/create-new-store\";\n-class MyUseCase extends UseCase {\n- execute() {}\n-}\n-\n-const context = new Context({\n- store: createStore({ name: \"test\" })\n-});\n-\n-context.useCase(new MyUseCase()).execute();\n" } ]
TypeScript
MIT License
almin/almin
test(almin): fix execute testing
19,400
27.04.2018 08:46:00
-32,400
fd763cc10e06799c9a13f0407c31da120e40055c
chore: ignore prettier format
[ { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-bus/package.json", "new_path": "packages/@almin/usecase-bus/package.json", "diff": "\"almin\": \"^0.16.0\",\n\"cross-env\": \"^5.1.4\",\n\"mocha\": \"^5.0.4\",\n- \"prettier\": \"^1.11.1\",\n- \"ts-node\": \"^5.0.1\",\n+ \"prettier\": \"^1.12.1\",\n+ \"ts-node\": \"^6.0.1\",\n\"ts-node-test-register\": \"^2.0.0\",\n- \"typescript\": \"^2.8.1\"\n+ \"typescript\": \"^2.8.3\"\n},\n\"prettier\": {\n\"singleQuote\": false,\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-logger/package.json", "new_path": "packages/almin-logger/package.json", "diff": "\"power-assert\": \"^1.4.4\",\n\"rimraf\": \"^2.6.2\",\n\"simple-mock\": \"^0.8.0\",\n- \"typescript\": \"~2.8.1\",\n+ \"typescript\": \"~2.8.3\",\n\"webpack\": \"^3.8.1\",\n\"zuul\": \"^3.10.1\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-react-container/package.json", "new_path": "packages/almin-react-container/package.json", "diff": "\"react\": \"^16.1.1\",\n\"react-dom\": \"^16.1.1\",\n\"rimraf\": \"^2.6.2\",\n- \"ts-node\": \"^5.0.1\",\n- \"typescript\": \"~2.8.1\"\n+ \"ts-node\": \"^6.0.1\",\n+ \"typescript\": \"~2.8.3\"\n},\n\"dependencies\": {\n\"shallow-equal-object\": \"^1.0.1\"\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"mocha\": \"^3.4.2\",\n\"npm-run-all\": \"^4.0.2\",\n\"power-assert\": \"^1.4.4\",\n+ \"prettier\": \"^1.12.1\",\n\"rimraf\": \"^2.6.2\",\n\"sinon\": \"^2.3.8\",\n\"size-limit\": \"^0.14.0\",\n\"source-map-support\": \"^0.4.15\",\n- \"ts-node\": \"^5.0.1\",\n+ \"ts-node\": \"^6.0.1\",\n\"ts-node-test-register\": \"^2.0.0\",\n- \"typescript\": \"~2.8.1\",\n+ \"typescript\": \"~2.8.3\",\n\"typings-tester\": \"^0.3.1\",\n\"zuul\": \"^3.10.1\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -13,6 +13,7 @@ import { Payload } from \"./payload/Payload\";\nimport { WillNotExecutedPayload } from \"./payload/WillNotExecutedPayload\";\nimport { assertOK } from \"./util/assert\";\n+// prettier-ignore-start\n// Conditional Typing in TS 2.8 >=\n// Get Arguments of T function and return tuple\nexport type A0<T> = T extends () => any ? T : never;\n@@ -71,6 +72,7 @@ export type A9<T> = T extends (\n) => any\n? [R1, R2, R3, R4, R5, R6, R7, R8, R9]\n: [never, never, never, never, never, never, never, never, never];\n+// prettier-ignore-end\ninterface InvalidUsage {\ntype: \"InvalidUsage\";\n@@ -515,6 +517,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n});\n}\n+ // prettier-ignore-start\n/**\n* Execute UseCase instance.\n* UseCase is a executable object that has `execute` method.\n@@ -574,6 +577,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\nexecute(...args: Array<any>): Promise<void> {\nreturn this.executor(useCase => useCase.execute(...args));\n}\n+ // prettier-ignore-end\n/**\n* release all events handler.\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "\"@types/node\" \"*\"\n\"@types/react\" \"*\"\n-\"@types/react@*\", \"@types/react@16.0.35\":\n+\"@types/react@*\":\n+ version \"16.3.12\"\n+ resolved \"https://registry.yarnpkg.com/@types/react/-/react-16.3.12.tgz#68d9146f3e9797e38ffbf22f7ed1dde91a2cfd2e\"\n+ dependencies:\n+ csstype \"^2.2.0\"\n+\n+\"@types/react@16.0.35\":\nversion \"16.0.35\"\nresolved \"https://registry.yarnpkg.com/@types/react/-/react-16.0.35.tgz#7ce8a83cad9690fd965551fc513217a74fc9e079\"\n@@ -2526,6 +2532,10 @@ cssom@0.3.x, \"cssom@>= 0.3.2 < 0.4.0\":\ndependencies:\ncssom \"0.3.x\"\n+csstype@^2.2.0:\n+ version \"2.4.1\"\n+ resolved \"https://registry.yarnpkg.com/csstype/-/csstype-2.4.1.tgz#ba35a94259cffc07ed022954737a1da690dcae2c\"\n+\nctype@0.5.3:\nversion \"0.5.3\"\nresolved \"https://registry.yarnpkg.com/ctype/-/ctype-0.5.3.tgz#82c18c2461f74114ef16c135224ad0b9144ca12f\"\n@@ -6806,10 +6816,14 @@ preserve@^0.2.0:\nversion \"0.2.0\"\nresolved \"https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b\"\n-prettier@^1.10.2, prettier@^1.11.1:\n+prettier@^1.10.2:\nversion \"1.11.1\"\nresolved \"https://registry.yarnpkg.com/prettier/-/prettier-1.11.1.tgz#61e43fc4cd44e68f2b0dfc2c38cd4bb0fccdcc75\"\n+prettier@^1.12.1:\n+ version \"1.12.1\"\n+ resolved \"https://registry.yarnpkg.com/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325\"\n+\npretty-format@^21.2.1:\nversion \"21.2.1\"\nresolved \"https://registry.yarnpkg.com/pretty-format/-/pretty-format-21.2.1.tgz#ae5407f3cf21066cd011aa1ba5fce7b6a2eddb36\"\n@@ -8649,9 +8663,9 @@ ts-node-test-register@^2.0.0:\ndependencies:\nread-pkg \"^3.0.0\"\n-ts-node@^5.0.1:\n- version \"5.0.1\"\n- resolved \"https://registry.yarnpkg.com/ts-node/-/ts-node-5.0.1.tgz#78e5d1cb3f704de1b641e43b76be2d4094f06f81\"\n+ts-node@^6.0.1:\n+ version \"6.0.1\"\n+ resolved \"https://registry.yarnpkg.com/ts-node/-/ts-node-6.0.1.tgz#e2dd65abcadae530d2b2109cfd19202ba9f90402\"\ndependencies:\narrify \"^1.0.0\"\nchalk \"^2.3.0\"\n@@ -8709,7 +8723,11 @@ typedarray@^0.0.6, typedarray@~0.0.5:\nversion \"0.0.6\"\nresolved \"https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777\"\n-typescript@^2.8.1, typescript@~2.8.1:\n+typescript@^2.8.3, typescript@~2.8.3:\n+ version \"2.8.3\"\n+ resolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.8.3.tgz#5d817f9b6f31bb871835f4edf0089f21abe6c170\"\n+\n+typescript@~2.8.1:\nversion \"2.8.1\"\nresolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.8.1.tgz#6160e4f8f195d5ba81d4876f9c0cc1fbc0820624\"\n" } ]
TypeScript
MIT License
almin/almin
chore: ignore prettier format
19,400
27.04.2018 10:58:40
-32,400
d3c11a8dff8126ae7e9723b0484ef343021330f4
chore(prettier): ignore Executor
[ { "change_type": "MODIFY", "old_path": ".prettierignore", "new_path": ".prettierignore", "diff": "@@ -5,3 +5,6 @@ lib/\n*.min.js\n*.min.css\n_book\n+\n+# Prettier does not support flexible ignore\n+/packages/almin/src/UseCaseExecutor.ts\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -13,65 +13,18 @@ import { Payload } from \"./payload/Payload\";\nimport { WillNotExecutedPayload } from \"./payload/WillNotExecutedPayload\";\nimport { assertOK } from \"./util/assert\";\n-// prettier-ignore-start\n// Conditional Typing in TS 2.8 >=\n// Get Arguments of T function and return tuple\nexport type A0<T> = T extends () => any ? T : never;\nexport type A1<T> = T extends (a1: infer R1) => any ? [R1] : [never];\nexport type A2<T> = T extends (a1: infer R1, a2: infer R2) => any ? [R1, R2] : [never, never];\nexport type A3<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3) => any ? [R1, R2, R3] : [never, never, never];\n-export type A4<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4) => any\n- ? [R1, R2, R3, R4]\n- : [never, never, never, never];\n-export type A5<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5) => any\n- ? [R1, R2, R3, R4, R5]\n- : [never, never, never, never, never];\n-export type A6<T> = T extends (\n- a1: infer R1,\n- a2: infer R2,\n- a3: infer R3,\n- a4: infer R4,\n- a5: infer R5,\n- a6: infer R6\n-) => any\n- ? [R1, R2, R3, R4, R5, R6]\n- : [never, never, never, never, never, never];\n-export type A7<T> = T extends (\n- a1: infer R1,\n- a2: infer R2,\n- a3: infer R3,\n- a4: infer R4,\n- a5: infer R5,\n- a6: infer R6,\n- a7: infer R7\n-) => any\n- ? [R1, R2, R3, R4, R5, R6, R7]\n- : [never, never, never, never, never, never, never];\n-export type A8<T> = T extends (\n- a1: infer R1,\n- a2: infer R2,\n- a3: infer R3,\n- a4: infer R4,\n- a5: infer R5,\n- a6: infer R6,\n- a7: infer R7,\n- a8: infer R8\n-) => any\n- ? [R1, R2, R3, R4, R5, R6, R7, R8]\n- : [never, never, never, never, never, never, never, never];\n-export type A9<T> = T extends (\n- a1: infer R1,\n- a2: infer R2,\n- a3: infer R3,\n- a4: infer R4,\n- a5: infer R5,\n- a6: infer R6,\n- a7: infer R7,\n- a8: infer R8,\n- a9: infer R9\n-) => any\n- ? [R1, R2, R3, R4, R5, R6, R7, R8, R9]\n- : [never, never, never, never, never, never, never, never, never];\n+export type A4<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4) => any ? [R1, R2, R3, R4] : [never, never, never, never];\n+export type A5<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5) => any ? [R1, R2, R3, R4, R5] : [never, never, never, never, never];\n+export type A6<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5, a6: infer R6) => any ? [R1, R2, R3, R4, R5, R6] : [never, never, never, never, never, never];\n+export type A7<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5, a6: infer R6, a7: infer R7) => any ? [R1, R2, R3, R4, R5, R6, R7] : [never, never, never, never, never, never, never];\n+export type A8<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5, a6: infer R6, a7: infer R7, a8: infer R8) => any ? [R1, R2, R3, R4, R5, R6, R7, R8] : [never, never, never, never, never, never, never, never];\n+export type A9<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5, a6: infer R6, a7: infer R7, a8: infer R8, a9: infer R9) => any ? [R1, R2, R3, R4, R5, R6, R7, R8, R9] : [never, never, never, never, never, never, never, never, never];\n// prettier-ignore-end\ninterface InvalidUsage {\n@@ -208,36 +161,9 @@ export interface UseCaseExecutor<T extends UseCaseLike> extends Dispatcher {\nexecute<P extends A4<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3]): Promise<void>;\nexecute<P extends A5<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4]): Promise<void>;\nexecute<P extends A6<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5]): Promise<void>;\n- execute<P extends A7<T[\"execute\"]>>(\n- a1: P[0],\n- a2: P[1],\n- a3: P[2],\n- a4: P[3],\n- a5: P[4],\n- a6: P[5],\n- a7: P[6]\n- ): Promise<void>;\n- execute<P extends A8<T[\"execute\"]>>(\n- a1: P[0],\n- a2: P[1],\n- a3: P[2],\n- a4: P[3],\n- a5: P[4],\n- a6: P[5],\n- a7: P[6],\n- a8: P[7]\n- ): Promise<void>;\n- execute<P extends A9<T[\"execute\"]>>(\n- a1: P[0],\n- a2: P[1],\n- a3: P[2],\n- a4: P[3],\n- a5: P[4],\n- a6: P[5],\n- a7: P[6],\n- a8: P[7],\n- a9: P[8]\n- ): Promise<void>;\n+ execute<P extends A7<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6]): Promise<void>;\n+ execute<P extends A8<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6], a8: P[7]): Promise<void>;\n+ execute<P extends A9<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6], a8: P[7], a9: P[8]): Promise<void>;\nrelease(): void;\n}\n@@ -531,7 +457,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n*\n* ### `execute()` typing for TypeScript\n*\n- * > Almin 0.17.0 >=\n+ * > Added: Almin 0.17.0 >=\n*\n* `execute()` support type check in Almin 0.17.0.\n* However, it has a limitation about argument lengths.\n@@ -544,36 +470,9 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\nexecute<P extends A4<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3]): Promise<void>;\nexecute<P extends A5<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4]): Promise<void>;\nexecute<P extends A6<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5]): Promise<void>;\n- execute<P extends A7<T[\"execute\"]>>(\n- a1: P[0],\n- a2: P[1],\n- a3: P[2],\n- a4: P[3],\n- a5: P[4],\n- a6: P[5],\n- a7: P[6]\n- ): Promise<void>;\n- execute<P extends A8<T[\"execute\"]>>(\n- a1: P[0],\n- a2: P[1],\n- a3: P[2],\n- a4: P[3],\n- a5: P[4],\n- a6: P[5],\n- a7: P[6],\n- a8: P[7]\n- ): Promise<void>;\n- execute<P extends A9<T[\"execute\"]>>(\n- a1: P[0],\n- a2: P[1],\n- a3: P[2],\n- a4: P[3],\n- a5: P[4],\n- a6: P[5],\n- a7: P[6],\n- a8: P[7],\n- a9: P[8]\n- ): Promise<void>;\n+ execute<P extends A7<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6]): Promise<void>;\n+ execute<P extends A8<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6], a8: P[7]): Promise<void>;\n+ execute<P extends A9<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6], a8: P[7], a9: P[8]): Promise<void>;\nexecute(...args: Array<any>): Promise<void> {\nreturn this.executor(useCase => useCase.execute(...args));\n}\n" } ]
TypeScript
MIT License
almin/almin
chore(prettier): ignore Executor
19,400
27.04.2018 22:59:17
-32,400
e2097f756792a6e1306290eae9006e8028f6221d
chore(deps): move resolutions to root
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"packages/@almin/*\"\n],\n\"license\": \"MIT\",\n+ \"resolutions\": {\n+ \"@types/react\": \"16.3.13\",\n+ \"@types/react-dom\": \"16.0.5\"\n+ },\n\"devDependencies\": {\n\"@alrra/travis-scripts\": \"^3.0.1\",\n\"@azu/docco\": \"^0.7.2\",\n\"textlint-rule-common-misspellings\": \"^1.0.1\",\n\"textlint-rule-no-dead-link\": \"^4.3.0\",\n\"textlint-rule-prh\": \"^5.0.1\",\n- \"typescript\": \"~2.8.1\"\n+ \"typescript\": \"~2.8.3\"\n},\n\"scripts\": {\n\"precommit\": \"lint-staged\",\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-react-container/package.json", "new_path": "packages/almin-react-container/package.json", "diff": "},\n\"devDependencies\": {\n\"@types/node\": \"^9.3.0\",\n- \"@types/react\": \"16.0.35\",\n- \"@types/react-dom\": \"16.0.3\",\n+ \"@types/react\": \"16.3.13\",\n+ \"@types/react-dom\": \"16.0.5\",\n\"almin\": \"^0.16.0\",\n\"babel-preset-env\": \"^1.6.1\",\n\"babel-preset-power-assert\": \"^1.0.0\",\n\"jsdom\": \"^11.3.0\",\n\"mocha\": \"^4.0.1\",\n\"power-assert\": \"^1.4.4\",\n- \"react\": \"^16.1.1\",\n- \"react-dom\": \"^16.1.1\",\n+ \"react\": \"^16.3.2\",\n+ \"react-dom\": \"^16.3.2\",\n\"rimraf\": \"^2.6.2\",\n\"ts-node\": \"^6.0.1\",\n\"typescript\": \"~2.8.3\"\n},\n\"dependencies\": {\n\"shallow-equal-object\": \"^1.0.1\"\n- },\n- \"resolutions\": {\n- \"@types/react\": \"16.0.35\",\n- \"@types/react-dom\": \"16.0.3\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "version \"9.4.7\"\nresolved \"https://registry.yarnpkg.com/@types/node/-/node-9.4.7.tgz#57d81cd98719df2c9de118f2d5f3b1120dcd7275\"\n-\"@types/react-dom@16.0.3\":\n- version \"16.0.3\"\n- resolved \"https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.0.3.tgz#8accad7eabdab4cca3e1a56f5ccb57de2da0ff64\"\n+\"@types/react-dom@16.0.5\":\n+ version \"16.0.5\"\n+ resolved \"https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.0.5.tgz#a757457662e3819409229e8f86795ff37b371f96\"\ndependencies:\n\"@types/node\" \"*\"\n\"@types/react\" \"*\"\n-\"@types/react@*\":\n- version \"16.3.12\"\n- resolved \"https://registry.yarnpkg.com/@types/react/-/react-16.3.12.tgz#68d9146f3e9797e38ffbf22f7ed1dde91a2cfd2e\"\n+\"@types/react@*\", \"@types/react@16.3.13\":\n+ version \"16.3.13\"\n+ resolved \"https://registry.yarnpkg.com/@types/react/-/react-16.3.13.tgz#47d466462b774556c1174ea0eda22c0578643362\"\ndependencies:\ncsstype \"^2.2.0\"\n-\"@types/react@16.0.35\":\n- version \"16.0.35\"\n- resolved \"https://registry.yarnpkg.com/@types/react/-/react-16.0.35.tgz#7ce8a83cad9690fd965551fc513217a74fc9e079\"\n-\n\"@types/sinon@^4.1.3\":\nversion \"4.1.3\"\nresolved \"https://registry.yarnpkg.com/@types/sinon/-/sinon-4.1.3.tgz#2ee25e0e302f31e78a945650a60029e08878eaf8\"\n@@ -7064,18 +7060,18 @@ rc@^1.0.1, rc@^1.1.0, rc@^1.1.6, rc@^1.1.7:\nminimist \"^1.2.0\"\nstrip-json-comments \"~2.0.1\"\n-react-dom@^16.1.1:\n- version \"16.2.0\"\n- resolved \"https://registry.yarnpkg.com/react-dom/-/react-dom-16.2.0.tgz#69003178601c0ca19b709b33a83369fe6124c044\"\n+react-dom@^16.3.2:\n+ version \"16.3.2\"\n+ resolved \"https://registry.yarnpkg.com/react-dom/-/react-dom-16.3.2.tgz#cb90f107e09536d683d84ed5d4888e9640e0e4df\"\ndependencies:\nfbjs \"^0.8.16\"\nloose-envify \"^1.1.0\"\nobject-assign \"^4.1.1\"\nprop-types \"^15.6.0\"\n-react@^16.1.1:\n- version \"16.2.0\"\n- resolved \"https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba\"\n+react@^16.3.2:\n+ version \"16.3.2\"\n+ resolved \"https://registry.yarnpkg.com/react/-/react-16.3.2.tgz#fdc8420398533a1e58872f59091b272ce2f91ea9\"\ndependencies:\nfbjs \"^0.8.16\"\nloose-envify \"^1.1.0\"\n@@ -8723,10 +8719,6 @@ typescript@^2.8.3, typescript@~2.8.3:\nversion \"2.8.3\"\nresolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.8.3.tgz#5d817f9b6f31bb871835f4edf0089f21abe6c170\"\n-typescript@~2.8.1:\n- version \"2.8.1\"\n- resolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.8.1.tgz#6160e4f8f195d5ba81d4876f9c0cc1fbc0820624\"\n-\ntypings-tester@^0.3.1:\nversion \"0.3.1\"\nresolved \"https://registry.yarnpkg.com/typings-tester/-/typings-tester-0.3.1.tgz#53bb9784b0ebd7b93192e6fcd908f14501af3878\"\n" } ]
TypeScript
MIT License
almin/almin
chore(deps): move resolutions to root
19,400
27.04.2018 23:50:38
-32,400
409290698f117b083d82dd376bd42ba5e8c05783
chore: add issue link
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -459,7 +459,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n*\n* `execute()` support type check in Almin 0.17.0.\n* However, it has a limitation about argument lengths.\n- * For more details, please see <URL>\n+ * For more details, please see <https://github.com/almin/almin/issues/107#issuecomment-384993458>\n*/\nexecute<P extends A0<T[\"execute\"]>>(this: P extends never ? never : this): Promise<void>;\nexecute<P extends A1<T[\"execute\"]>>(a1: P[0]): Promise<void>;\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/typing-fixtures/execute-argument.ts", "new_path": "packages/almin/test/typing-fixtures/execute-argument.ts", "diff": "@@ -59,3 +59,5 @@ context.useCase(new MyUseCaseDefault()).execute(1);\n// more arguments\ncontext.useCase(new MyUseCaseA()).execute(\"A\", 1, 1);\n+// typings:expect-error\n+context.useCase(new MyUseCaseA()).executor(useCase => useCase.execute(\"A\", 1, 1));\n" } ]
TypeScript
MIT License
almin/almin
chore: add issue link
19,400
08.06.2018 08:45:59
-32,400
f878bac09e09284d9a61ea7f147a5fb84eae503a
fix(react-context): fix creating react context instance
[ { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/README.md", "new_path": "packages/@almin/react-context/README.md", "diff": "@@ -8,6 +8,50 @@ Install with [npm](https://www.npmjs.com/):\nnpm install @almin/react-context\n+## Example\n+\n+This is a example of `@almin/react-context`.\n+\n+:memo: Note: [create-test-store.ts](./test/helper/create-test-store.ts) is a test helper\n+\n+```ts\n+import { Context, StoreGroup } from \"almin\";\n+import { createReactContext } from \"@almin/react-context\";\n+// Create Almin context\n+const context = new Context({\n+ // StoreGroup has {a, b, c} state\n+ store: new StoreGroup({\n+ // createTestStore is a test helper that create Store instance of Almin\n+ // See /test/helper/create-test-store.ts\n+ a: createTestStore({ value: \"a\" }),\n+ b: createTestStore({ value: \"b\" }),\n+ c: createTestStore({ value: \"c\" }),\n+ })\n+});\n+// Create React Context that wrap Almin Context\n+const { Consumer, Provider } = createReactContext(context);\n+// Use Provider\n+class App extends React.Component {\n+ render() {\n+ return (\n+ // You should wrap Consumer with Provider\n+ <Provider>\n+ {/* Consumer children props is called when Almin's context is changed */}\n+ <Consumer>\n+ {state => {\n+ return <ul>\n+ <li>{state.a.value}</li>;\n+ <li>{state.b.value}</li>;\n+ <li>{state.c.value}</li>;\n+ </ul>\n+ }}\n+ </Consumer>\n+ </Provider>\n+ );\n+ }\n+}\n+```\n+\n## Usage\n## `createReactContext(AlminContext): { Provider, Consumer, ConsumerQuery }`\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/src/index.ts", "new_path": "packages/@almin/react-context/src/index.ts", "diff": "-export { createReactContext, ConsumerProps, ProviderProps, SubscribeProps } from \"./react-context\";\n+export { createReactContext, ConsumerProps, ProviderProps, ConsumerQueryProps } from \"./react-context\";\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/src/react-context.tsx", "new_path": "packages/@almin/react-context/src/react-context.tsx", "diff": "import { Context } from \"almin\";\nimport * as React from \"react\";\n-\n-let StateContext: null | React.Context<any> = null;\n// Provider\nexport type ProviderProps<T> = {\ninitialState?: T;\n@@ -27,7 +25,7 @@ export function createReactContext<T>(\nConsumerQuery: React.ComponentType<ConsumerQueryProps<T>>;\n} {\nconst initialState = alminContext.getState();\n- StateContext = React.createContext(initialState);\n+ const StateContext: React.Context<any> = React.createContext(initialState);\n// Provider\nclass Provider extends React.PureComponent<ProviderProps<T>> {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/react-context/test/example-test.tsx", "diff": "+import * as assert from \"assert\";\n+import { Context, StoreGroup } from \"almin\";\n+import { createReactContext } from \"../src\";\n+import * as React from \"react\";\n+import * as TestUtils from \"react-dom/test-utils\";\n+import { createTestStore } from \"./helper/create-test-store\";\n+\n+function render<P>(element: React.ReactElement<P>): React.Component<P> {\n+ return TestUtils.renderIntoDocument(element) as React.Component<P>;\n+}\n+describe(\"@almin/react-context\", () => {\n+ describe(\"example\", () => {\n+ it(\"should work\", () => {\n+ // Create Almin context\n+ const context = new Context({\n+ // StoreGroup has {a, b, c} state\n+ store: new StoreGroup({\n+ // createTestStore is a test helper that create Store instance of Almin\n+ a: createTestStore({ value: \"a\" }),\n+ b: createTestStore({ value: \"b\" }),\n+ c: createTestStore({ value: \"c\" })\n+ })\n+ });\n+ // Create React Context that wrap Almin Context\n+ const { Consumer, Provider } = createReactContext(context);\n+ // Use Provider\n+ class App extends React.Component {\n+ render() {\n+ return (\n+ // You should wrap Consumer with Provider\n+ <Provider>\n+ {/* Consumer children props is called when Almin's context is changed */}\n+ <Consumer>\n+ {state => {\n+ return (\n+ <ul>\n+ <li>{state.a.value}</li>;\n+ <li>{state.b.value}</li>;\n+ <li>{state.c.value}</li>;\n+ </ul>\n+ );\n+ }}\n+ </Consumer>\n+ </Provider>\n+ );\n+ }\n+ }\n+ // Test\n+ const tree = render(<App />);\n+ const elements = TestUtils.scryRenderedDOMComponentsWithTag(tree, \"li\");\n+ assert.strictEqual(elements.length, 3);\n+ });\n+ });\n+});\n" } ]
TypeScript
MIT License
almin/almin
fix(react-context): fix creating react context instance
19,400
08.06.2018 10:41:15
-32,400
4e25d0016bd82272793d9e78659f70f470ba837e
docs(README): update API
[ { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/README.md", "new_path": "packages/@almin/react-context/README.md", "diff": "@@ -17,6 +17,8 @@ This is a example of `@almin/react-context`.\n```ts\nimport { Context, StoreGroup } from \"almin\";\nimport { createReactContext } from \"@almin/react-context\";\n+// THIS IS TEST HELPER\n+import { createTestStore } from \"./helper/create-test-store\";\n// Create Almin context\nconst context = new Context({\n// StoreGroup has {a, b, c} state\n@@ -61,6 +63,7 @@ class App extends React.Component {\n```ts\nimport { Context, StoreGroup } from \"almin\";\nimport { createReactContext } from \"@almin/react-context\";\n+import { createTestStore } from \"./helper/create-test-store\";\n// Create Almin context\nconst context = new Context({\nstore: createTestStore({\n@@ -72,14 +75,125 @@ const context = new Context({\nconst { Provider, Consumer, ConsumerQuery } = createReactContext(context);\n```\n-### Provider\n+### `<Provider>`\n+\n+`<Provider>` component allows `<Consumers>` to subscribe to Almin's context changes.\n+It is a just wrapper of React Context's Provider.\n+\n+- [React Context: Provider](https://reactjs.org/docs/context.html#provider)\n+\n+```ts\n+class App extends React.Component {\n+ render() {\n+ return (\n+ // You should wrap Consumer with Provider\n+ <Provider>\n+ {/* Consumer should be under the Provider */}\n+ <Consumer>\n+ {state => { /* state is result of context.getState() */ }}\n+ </Consumer>\n+ <Consumer>\n+ {state => { /* state is result of context.getState() */ }}\n+ </Consumer>\n+ </Provider>\n+ );\n+ }\n+}\n+```\n+\n+Also, you can pass `initialState` to `Provider`.\n+If you does not pass `initialState`, `Consumer`'s state is `context.getState()` value by default.\n+\n+```tsx\n+const context = new Context({\n+ store: createTestStore({\n+ value: \"store-initial\"\n+ })\n+});\n+const { Consumer, Provider } = createReactContext(context);\n+\n+class App extends React.Component {\n+ render() {\n+ return (\n+ <Provider initialState={{ value: \"props-initial\" }}>\n+ <Consumer>\n+ {state => {\n+ // value is \"props-initial\"(not \"store-initial\")\n+ return <p>{state.value}</p>;\n+ }}\n+ </Consumer>\n+ </Provider>\n+ );\n+ }\n+}\n+```\n### Consumer\n+`<Consumer>` component subscribes to Almin's context changes.\n+It is a just wrapper of React Context's Consumer.\n+\n+- [React Context: Consumer](https://reactjs.org/docs/context.html#consumer)\n+\n+`<Consumer>` requires a [function as a child](https://reactjs.org/docs/render-props.html#using-props-other-than-render). The function receives the current context value and returns a React node.\n+\n+```tsx\n+class App extends React.Component {\n+ render() {\n+ return (\n+ // You should wrap Consumer with Provider\n+ <Provider>\n+ {/* Consumer require a function as a children */}\n+ <Consumer>\n+ {state => {\n+ /* render something based on the context value */\n+ return <p>{state.value}</p>;\n+ }}\n+ </Consumer>\n+ </Provider>\n+ );\n+ }\n+}\n+```\n+\n### ConsumerQuery\n`ConsumerQuery` is Consumer + Query component.\n-It can select some state from whole state.\n+It can select some state from whole state. Other things are same with `<Consumer>`.\n+\n+```tsx\n+import { Context, StoreGroup } from \"almin\";\n+import { createReactContext } from \"@almin/react-context\";\n+import { createTestStore } from \"./helper/create-test-store\";\n+// Create Almin Context\n+const context = new Context({\n+ store: new StoreGroup({\n+ aState: createTestStore({\n+ value: \"aState\"\n+ }),\n+ bState: createTestStore({\n+ value: \"bState\"\n+ })\n+ })\n+});\n+// Create React Context\n+const { ConsumerQuery, Provider } = createReactContext(context);\n+\n+class App extends React.Component {\n+ render() {\n+ return (\n+ <Provider>\n+ {/* select aState from whole state */}\n+ <ConsumerQuery selector={(state) => state.aState}>\n+ {aState => { // <= receive aState instead of whole state\n+ return <p>{aState.value}</p>;\n+ }}\n+ </ConsumerQuery>\n+ </Provider>\n+ );\n+ }\n+}\n+```\n## Changelog\n" } ]
TypeScript
MIT License
almin/almin
docs(README): update API
19,400
08.06.2018 20:06:41
-32,400
a7e08abd202b35b1319c7206bf797ae1f2256900
chore(react-context): remove Query
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"textlint-rule-common-misspellings\": \"^1.0.1\",\n\"textlint-rule-no-dead-link\": \"^4.3.0\",\n\"textlint-rule-prh\": \"^5.0.1\",\n- \"typescript\": \"~2.8.3\"\n+ \"typescript\": \"~2.9.1\"\n},\n\"scripts\": {\n\"precommit\": \"lint-staged\",\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/README.md", "new_path": "packages/@almin/react-context/README.md", "diff": "@@ -56,7 +56,7 @@ class App extends React.Component {\n## Usage\n-## `createReactContext(AlminContext): { Provider, Consumer, ConsumerQuery }`\n+## `createReactContext(AlminContext): { Provider, Consumer }`\n`createReactContext` create thee React Components from Almin's `Context` instance.\n@@ -72,7 +72,7 @@ const context = new Context({\n});\n// Create React Context from Almin Context\n// It return these React Components\n-const { Provider, Consumer, ConsumerQuery } = createReactContext(context);\n+const { Provider, Consumer } = createReactContext(context);\n```\n### `<Provider>`\n@@ -105,6 +105,9 @@ Also, you can pass `initialState` to `Provider`.\nIf you does not pass `initialState`, `Consumer`'s state is `context.getState()` value by default.\n```tsx\n+import { Context, StoreGroup } from \"almin\";\n+import { createReactContext } from \"@almin/react-context\";\n+import { createTestStore } from \"./helper/create-test-store\";\nconst context = new Context({\nstore: createTestStore({\nvalue: \"store-initial\"\n@@ -156,45 +159,6 @@ class App extends React.Component {\n}\n```\n-### ConsumerQuery\n-\n-`ConsumerQuery` is Consumer + Query component.\n-It can select some state from whole state. Other things are same with `<Consumer>`.\n-\n-```tsx\n-import { Context, StoreGroup } from \"almin\";\n-import { createReactContext } from \"@almin/react-context\";\n-import { createTestStore } from \"./helper/create-test-store\";\n-// Create Almin Context\n-const context = new Context({\n- store: new StoreGroup({\n- aState: createTestStore({\n- value: \"aState\"\n- }),\n- bState: createTestStore({\n- value: \"bState\"\n- })\n- })\n-});\n-// Create React Context\n-const { ConsumerQuery, Provider } = createReactContext(context);\n-\n-class App extends React.Component {\n- render() {\n- return (\n- <Provider>\n- {/* select aState from whole state */}\n- <ConsumerQuery selector={(state) => state.aState}>\n- {aState => { // <= receive aState instead of whole state\n- return <p>{aState.value}</p>;\n- }}\n- </ConsumerQuery>\n- </Provider>\n- );\n- }\n-}\n-```\n-\n## Changelog\nSee [Releases page](https://github.com/almin/almin/releases).\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/package.json", "new_path": "packages/@almin/react-context/package.json", "diff": "\"react-dom\": \"^16.4.0\",\n\"ts-node\": \"^6.1.0\",\n\"ts-node-test-register\": \"^3.0.0\",\n- \"typescript\": \"^2.8.3\"\n+ \"typescript\": \"^2.9.1\"\n},\n\"resolutions\": {\n\"@types/react\": \"16.3.13\",\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/src/index.ts", "new_path": "packages/@almin/react-context/src/index.ts", "diff": "-export { createReactContext, ConsumerProps, ProviderProps, ConsumerQueryProps } from \"./react-context\";\n+export { createReactContext, ConsumerProps, ProviderProps } from \"./react-context\";\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/test/react-context-test.tsx", "new_path": "packages/@almin/react-context/test/react-context-test.tsx", "diff": "import * as assert from \"assert\";\n-import { Context, StoreGroup } from \"almin\";\n+import { Context } from \"almin\";\nimport { createReactContext } from \"../src\";\nimport * as React from \"react\";\nimport * as TestUtils from \"react-dom/test-utils\";\n@@ -97,116 +97,4 @@ describe(\"@almin/react-context\", () => {\nassert.strictEqual(element.textContent, \"second\");\n});\n});\n- describe(\"Provider/ConsumerQuery\", () => {\n- it(\"should render with the result state of selector\", () => {\n- const context = new Context({\n- store: new StoreGroup({\n- aState: createTestStore({\n- value: \"aState\"\n- }),\n- bState: createTestStore({\n- value: \"bState\"\n- })\n- })\n- });\n- const { ConsumerQuery, Provider } = createReactContext(context);\n-\n- class App extends React.Component {\n- render() {\n- return (\n- <Provider>\n- <ConsumerQuery selector={state => state.aState}>\n- {aState => {\n- return <p>{aState.value}</p>;\n- }}\n- </ConsumerQuery>\n- </Provider>\n- );\n- }\n- }\n- const tree = render(<App />);\n- const element = TestUtils.findRenderedDOMComponentWithTag(tree, \"p\");\n- assert.strictEqual(element.textContent, \"aState\");\n- });\n- it(\"should re-render with updated state\", () => {\n- const aStore = createTestStore({\n- value: \"aState\"\n- });\n- const context = new Context({\n- store: new StoreGroup({\n- aState: aStore,\n- bState: createTestStore({\n- value: \"bState\"\n- })\n- })\n- });\n- const { ConsumerQuery, Provider } = createReactContext(context);\n-\n- class App extends React.Component {\n- render() {\n- return (\n- <Provider>\n- <ConsumerQuery selector={state => state.aState}>\n- {aState => {\n- return <p>{aState.value}</p>;\n- }}\n- </ConsumerQuery>\n- </Provider>\n- );\n- }\n- }\n- const tree = render(<App />);\n- // update\n- aStore.updateState({\n- value: \"newState\"\n- });\n- const element = TestUtils.findRenderedDOMComponentWithTag(tree, \"p\");\n- assert.strictEqual(element.textContent, \"newState\");\n- });\n- it(\"should not re-render without updated state\", () => {\n- const aStore = createTestStore({\n- value: \"aState\"\n- });\n- const bStore = createTestStore({\n- value: \"bState\"\n- });\n- const context = new Context({\n- store: new StoreGroup({\n- aState: aStore,\n- bState: bStore\n- })\n- });\n- const { ConsumerQuery, Provider } = createReactContext(context);\n-\n- let renderCount = 0;\n- class App extends React.Component {\n- render() {\n- return (\n- <Provider>\n- <ConsumerQuery selector={state => state.aState}>\n- {aState => {\n- renderCount++;\n- return <p>{aState.value}</p>;\n- }}\n- </ConsumerQuery>\n- </Provider>\n- );\n- }\n- }\n- const tree = render(<App />);\n- // bStore is updated, but aStore is used\n- bStore.updateState({\n- value: \"1\"\n- });\n- bStore.updateState({\n- value: \"2\"\n- });\n- bStore.updateState({\n- value: \"3\"\n- });\n- const element = TestUtils.findRenderedDOMComponentWithTag(tree, \"p\");\n- assert.strictEqual(element.textContent, \"aState\");\n- assert.strictEqual(renderCount, 1);\n- });\n- });\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-logger/package.json", "new_path": "packages/almin-logger/package.json", "diff": "\"power-assert\": \"^1.5.0\",\n\"rimraf\": \"^2.6.2\",\n\"simple-mock\": \"^0.8.0\",\n- \"typescript\": \"~2.8.3\",\n+ \"typescript\": \"~2.9.1\",\n\"webpack\": \"^3.8.1\",\n\"zuul\": \"^3.10.1\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-react-container/package.json", "new_path": "packages/almin-react-container/package.json", "diff": "\"react-dom\": \"^16.4.0\",\n\"rimraf\": \"^2.6.2\",\n\"ts-node\": \"^6.1.0\",\n- \"typescript\": \"~2.8.3\"\n+ \"typescript\": \"~2.9.1\"\n},\n\"dependencies\": {\n\"shallow-equal-object\": \"^1.0.1\"\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"source-map-support\": \"^0.5.5\",\n\"ts-node\": \"^6.1.0\",\n\"ts-node-test-register\": \"^3.0.0\",\n- \"typescript\": \"~2.8.3\",\n+ \"typescript\": \"~2.9.1\",\n\"typings-tester\": \"^0.3.1\",\n\"zuul\": \"^3.10.1\"\n},\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -9472,10 +9472,14 @@ typedarray@^0.0.6, typedarray@~0.0.5:\nversion \"0.0.6\"\nresolved \"https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777\"\n-typescript@^2.8.3, typescript@~2.8.3:\n+typescript@^2.8.3:\nversion \"2.8.3\"\nresolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.8.3.tgz#5d817f9b6f31bb871835f4edf0089f21abe6c170\"\n+typescript@^2.9.1, typescript@~2.9.1:\n+ version \"2.9.1\"\n+ resolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.9.1.tgz#fdb19d2c67a15d11995fd15640e373e09ab09961\"\n+\ntypings-tester@^0.3.1:\nversion \"0.3.1\"\nresolved \"https://registry.yarnpkg.com/typings-tester/-/typings-tester-0.3.1.tgz#53bb9784b0ebd7b93192e6fcd908f14501af3878\"\n" } ]
TypeScript
MIT License
almin/almin
chore(react-context): remove Query
19,400
08.06.2018 20:09:43
-32,400
d9fd2a8979a23fb9e91979fef919610067980361
chore(react-context): add peerDependencies
[ { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/README.md", "new_path": "packages/@almin/react-context/README.md", "diff": "@@ -8,6 +8,10 @@ Install with [npm](https://www.npmjs.com/):\nnpm install @almin/react-context\n+Requirements:\n+\n+- React 16.3 >=\n+\n## Example\nThis is a example of `@almin/react-context`.\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/package.json", "new_path": "packages/@almin/react-context/package.json", "diff": "\"singleQuote\": false,\n\"tabWidth\": 4\n},\n+ \"peerDependencies\": {\n+ \"react\": \">=16.3.0\"\n+ },\n\"devDependencies\": {\n\"@types/mocha\": \"^5.2.1\",\n\"@types/node\": \"^9.0.0\",\n" } ]
TypeScript
MIT License
almin/almin
chore(react-context): add peerDependencies
19,400
08.06.2018 20:12:57
-32,400
f44a54a82eaafaf155139ff67aaf85429017d3a3
fix(react-context): remove unused type
[ { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/src/react-context.tsx", "new_path": "packages/@almin/react-context/src/react-context.tsx", "diff": "@@ -11,7 +11,7 @@ export type ConsumerProps<T> = {\nchildren: (props: T) => React.ReactNode;\n};\n-export function createReactContext<T, P>(\n+export function createReactContext<T>(\nalminContext: Context<T>\n): {\nProvider: React.ComponentType<ProviderProps<T>>;\n" } ]
TypeScript
MIT License
almin/almin
fix(react-context): remove unused type
19,400
08.06.2018 20:21:28
-32,400
2454e60a75c7b60444174ebc1d53fe25c5f984fc
fix(almin): upgrade TypeScript 2.9
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/UILayer/StoreStateMap.ts", "new_path": "packages/almin/src/UILayer/StoreStateMap.ts", "diff": "@@ -37,7 +37,7 @@ export function createStoreStateMap<T>(mappingObject: StoreMap<T>): StoreStateMa\nfor (let i = 0; i < keys.length; i++) {\nconst stateName = keys[i];\nconst store = mappingObject[stateName];\n- map.set(store, stateName);\n+ map.set(store, String(stateName));\n}\nreturn map;\n}\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): upgrade TypeScript 2.9
19,400
08.06.2018 22:03:58
-32,400
66a773d0fcd183ec6d3642dea9caaf46b8303265
fix(almin-react-container): support TypeScript 2.9
[ { "change_type": "MODIFY", "old_path": "packages/almin-react-container/src/almin-react-container.tsx", "new_path": "packages/almin-react-container/src/almin-react-container.tsx", "diff": "@@ -5,15 +5,10 @@ import { Context } from \"almin\";\nimport { shallowEqual } from \"shallow-equal-object\";\n// Diff typing utilities\n-// https://qiita.com/cotttpan/items/999fe07d079298c35e0c\n-export type AlminReactContainerDiffKey<T extends string, U extends string> = ({ [P in T]: P } &\n- { [P in U]: never } & { [x: string]: never })[T];\n-\n-export type AlminReactContainerOmit<T, K extends keyof T> = Pick<T, AlminReactContainerDiffKey<keyof T, K>>;\n-\n-export type AlminReactContainerDiff<T, U> = AlminReactContainerOmit<T, keyof U & keyof T>;\n-// T - U\n-export type AlminReactContainerWeakDiff<T, U> = AlminReactContainerDiff<T, U> & { [K in keyof U & keyof T]?: T[K] };\n+// Remove types from T that are assignable to U\n+export type AlminReactContainerDiff<T, U> = T extends U ? never : T;\n+// https://stackoverflow.com/questions/49564342/typescript-2-8-remove-properties-in-one-type-from-another\n+export type AlminReactContainerObjectDiff<T, U> = Pick<T, AlminReactContainerDiff<keyof T, keyof U>>;\nexport class AlminReactContainer {\n// T is Custom props\n@@ -29,7 +24,7 @@ export class AlminReactContainer {\nconst componentName = WrappedComponent.displayName || WrappedComponent.name;\n// AlminContainer's props is <T - P> type\n// T is State of Store, P is custom props of the `WrappedComponent`\n- return class AlminContainer extends React.Component<AlminReactContainerWeakDiff<T, P>> {\n+ return class AlminContainer extends React.Component<AlminReactContainerObjectDiff<T, P>> {\nstatic displayName = `AlminContainer(${componentName})`;\nstate: P;\n" } ]
TypeScript
MIT License
almin/almin
fix(almin-react-container): support TypeScript 2.9
19,400
08.06.2018 23:04:23
-32,400
5f270fe2d97f4eb96cd64ba7f3432ac079383e97
feat(store-test-helper): add
[ { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/store-test-helper/LICENSE", "diff": "+Copyright (c) 2018 azu\n+\n+Permission is hereby granted, free of charge, to any person obtaining a copy\n+of this software and associated documentation files (the \"Software\"), to deal\n+in the Software without restriction, including without limitation the rights\n+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+copies of the Software, and to permit persons to whom the Software is\n+furnished to do so, subject to the following conditions:\n+\n+The above copyright notice and this permission notice shall be included in all\n+copies or substantial portions of the Software.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+SOFTWARE.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/store-test-helper/package.json", "diff": "+{\n+ \"name\": \"@almin/store-test-helper\",\n+ \"version\": \"1.0.0\",\n+ \"description\": \"Create Store helper for testing.\",\n+ \"keywords\": [\n+ \"almin\",\n+ \"testing\"\n+ ],\n+ \"homepage\": \"https://github.com/almin/almin/tree/master/packages/@almin/store-test-helper/\",\n+ \"bugs\": {\n+ \"url\": \"https://github.com/almin/almin/issues\"\n+ },\n+ \"license\": \"MIT\",\n+ \"author\": \"azu\",\n+ \"files\": [\n+ \"bin/\",\n+ \"lib/\",\n+ \"src/\"\n+ ],\n+ \"main\": \"lib/store-test-helper.js\",\n+ \"types\": \"lib/store-test-helper.d.ts\",\n+ \"directories\": {\n+ \"lib\": \"lib\",\n+ \"test\": \"test\"\n+ },\n+ \"repository\": {\n+ \"type\": \"git\",\n+ \"url\": \"https://github.com/almin/almin.git\"\n+ },\n+ \"scripts\": {\n+ \"build\": \"cross-env NODE_ENV=production tsc -p .\",\n+ \"prepublish\": \"npm run --if-present build\",\n+ \"test\": \"mocha \\\"test/**/*.ts\\\"\",\n+ \"prettier\": \"prettier --write \\\"**/*.{js,jsx,ts,tsx,css}\\\"\",\n+ \"watch\": \"tsc -p . --watch\"\n+ },\n+ \"prettier\": {\n+ \"printWidth\": 120,\n+ \"singleQuote\": false,\n+ \"tabWidth\": 4\n+ },\n+ \"dependencies\": {\n+ \"almin\": \"^0.16.0\"\n+ },\n+ \"devDependencies\": {\n+ \"@types/mocha\": \"^5.2.1\",\n+ \"@types/node\": \"^10.3.2\",\n+ \"cross-env\": \"^5.1.6\",\n+ \"mocha\": \"^5.2.0\",\n+ \"prettier\": \"^1.13.4\",\n+ \"ts-node\": \"^6.1.0\",\n+ \"ts-node-test-register\": \"^3.0.0\",\n+ \"typescript\": \"^2.9.1\"\n+ },\n+ \"publishConfig\": {\n+ \"access\": \"public\"\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/store-test-helper/test/mocha.opts", "diff": "+--require ts-node-test-register\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/store-test-helper/test/tsconfig.json", "diff": "+{\n+ \"extends\": \"../tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"declaration\": false\n+ },\n+ \"include\": [\n+ \"**/*\"\n+ ]\n+}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/store-test-helper/tsconfig.json", "diff": "+{\n+ \"compilerOptions\": {\n+ /* Basic Options */\n+ \"module\": \"commonjs\",\n+ \"moduleResolution\": \"node\",\n+ \"newLine\": \"LF\",\n+ \"outDir\": \"./lib/\",\n+ \"target\": \"es5\",\n+ \"sourceMap\": true,\n+ \"declaration\": true,\n+ \"jsx\": \"preserve\",\n+ \"lib\": [\n+ \"es2017\",\n+ \"dom\"\n+ ],\n+ /* Strict Type-Checking Options */\n+ \"strict\": true,\n+ /* Additional Checks */\n+ \"noUnusedLocals\": true,\n+ /* Report errors on unused locals. */\n+ \"noUnusedParameters\": true,\n+ /* Report errors on unused parameters. */\n+ \"noImplicitReturns\": true,\n+ /* Report error when not all code paths in function return a value. */\n+ \"noFallthroughCasesInSwitch\": true\n+ /* Report errors for fallthrough cases in switch statement. */\n+ },\n+ \"include\": [\n+ \"src/**/*\"\n+ ],\n+ \"exclude\": [\n+ \".git\",\n+ \"node_modules\"\n+ ]\n+}\n\\ No newline at end of file\n" } ]
TypeScript
MIT License
almin/almin
feat(store-test-helper): add @almin/store-test-helper
19,400
08.06.2018 23:04:49
-32,400
cfc7f220f9055be878c8dabbd9410948fecdca21
refactor(almin): refactor create-new-store helper
[ { "change_type": "MODIFY", "old_path": "packages/almin/test/Context-test.ts", "new_path": "packages/almin/test/Context-test.ts", "diff": "@@ -165,8 +165,8 @@ describe(\"Context\", function() {\ndone();\n});\n// catch multiple changes at one time\n- aStore.mutableStateWithoutEmit({ a: 1 });\n- bStore.mutableStateWithoutEmit({ b: 1 });\n+ aStore.updateStateWithoutEmit({ a: 1 });\n+ bStore.updateStateWithoutEmit({ b: 1 });\nstoreGroup.emitChange();\n});\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/StoreGroup-test.ts", "new_path": "packages/almin/test/StoreGroup-test.ts", "diff": "@@ -14,7 +14,7 @@ const createAsyncChangeStoreUseCase = (store: MockStore) => {\nexecute() {\nreturn Promise.resolve().then(() => {\nconst newState = { a: {} };\n- store.mutableStateWithoutEmit(newState);\n+ store.updateStateWithoutEmit(newState);\n});\n}\n}\n@@ -25,7 +25,7 @@ const createChangeStoreUseCase = (store: MockStore) => {\nclass ChangeTheStoreUseCase extends UseCase {\nexecute() {\nconst newState = { a: {} };\n- store.mutableStateWithoutEmit(newState);\n+ store.updateStateWithoutEmit(newState);\n}\n}\n@@ -449,9 +449,9 @@ describe(\"StoreGroup\", function() {\nclass ChangeABUseCase extends UseCase {\nexecute() {\n- aStore.mutableStateWithoutEmit({ a: 1 });\n+ aStore.updateStateWithoutEmit({ a: 1 });\naStore.emitChange(); // *1\n- bStore.mutableStateWithoutEmit({ b: 1 });\n+ bStore.updateStateWithoutEmit({ b: 1 });\nbStore.emitChange(); // *2\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/helper/create-new-store.ts", "new_path": "packages/almin/test/helper/create-new-store.ts", "diff": "\"use strict\";\nimport { Store } from \"../../src\";\n-export interface MockStore {\n+export interface MockStore<T> {\n// mutate state\n- mutableStateWithoutEmit(newState: any): void;\n+ updateStateWithoutEmit(newState: T): void;\n// setState\n- updateState(newState: any): void;\n+ updateState(newState: T): void;\n// state\ngetState(): any;\n}\n+export interface createStoreArg<T> {\n+ name: string;\n+ state?: T;\n+}\n+\n/**\n* This helper is for creating Store\n*/\n-export function createStore<T>({ name, state }: { name: string; state?: T }) {\n+export function createStore<T>(arg: createStoreArg<T>) {\nclass MockStore extends Store<T | undefined> implements MockStore {\nstate: T | undefined;\nconstructor() {\nsuper();\n- this.name = name;\n- this.state = state;\n+ this.name = arg.name;\n+ this.state = arg.state;\n}\n/**\n- * Directly modify state\n+ * Update state without emitting\n*/\n- mutableStateWithoutEmit(newState: any) {\n+ updateStateWithoutEmit(newState: any) {\nthis.state = newState;\n}\n/**\n- * setState\n- * @param {*} newState\n+ * Update Store's state\n+ * alias to setState\n*/\nupdateState(newState: any) {\nthis.setState(newState);\n}\n+ /**\n+ * Return current statei\n+ */\ngetState() {\nreturn this.state;\n}\n" } ]
TypeScript
MIT License
almin/almin
refactor(almin): refactor create-new-store helper
19,400
08.06.2018 23:05:05
-32,400
b183683ac46ce7c25baf192a25104ae5f05efe93
refactor(react-context): use
[ { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/README.md", "new_path": "packages/@almin/react-context/README.md", "diff": "@@ -16,22 +16,21 @@ Requirements:\nThis is a example of `@almin/react-context`.\n-:memo: Note: [create-test-store.ts](./test/helper/create-test-store.ts) is a test helper\n+:memo: Note: [@almin/store-test-helper](../@almin/store-test-helper) is a test helper for creating almin's `Store`.\n```ts\nimport { Context, StoreGroup } from \"almin\";\n+import { createStore } from \"@almin/store-test-helper\";\nimport { createReactContext } from \"@almin/react-context\";\n-// THIS IS TEST HELPER\n-import { createTestStore } from \"./helper/create-test-store\";\n// Create Almin context\nconst context = new Context({\n// StoreGroup has {a, b, c} state\nstore: new StoreGroup({\n- // createTestStore is a test helper that create Store instance of Almin\n- // See /test/helper/create-test-store.ts\n- a: createTestStore({ value: \"a\" }),\n- b: createTestStore({ value: \"b\" }),\n- c: createTestStore({ value: \"c\" }),\n+ // createStore is a test helper that create Store instance of Almin\n+ // initial state of `a` is { value: \"a\" }\n+ a: createStore({ value: \"a\" }),\n+ b: createStore({ value: \"b\" }),\n+ c: createStore({ value: \"c\" }),\n})\n});\n// Create React Context that wrap Almin Context\n@@ -66,11 +65,11 @@ class App extends React.Component {\n```ts\nimport { Context, StoreGroup } from \"almin\";\n+import { createStore } from \"@almin/store-test-helper\";\nimport { createReactContext } from \"@almin/react-context\";\n-import { createTestStore } from \"./helper/create-test-store\";\n// Create Almin context\nconst context = new Context({\n- store: createTestStore({\n+ store: createStore({\nvalue: \"store-initial\"\n})\n});\n@@ -110,10 +109,10 @@ If you does not pass `initialState`, `Consumer`'s state is `context.getState()`\n```tsx\nimport { Context, StoreGroup } from \"almin\";\n+import { createStore } from \"@almin/store-test-helper\";\nimport { createReactContext } from \"@almin/react-context\";\n-import { createTestStore } from \"./helper/create-test-store\";\nconst context = new Context({\n- store: createTestStore({\n+ store: createStore({\nvalue: \"store-initial\"\n})\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/package.json", "new_path": "packages/@almin/react-context/package.json", "diff": "\"react\": \">=16.3.0\"\n},\n\"devDependencies\": {\n+ \"@almin/store-test-helper\": \"^1.0.0\",\n\"@types/mocha\": \"^5.2.1\",\n\"@types/node\": \"^9.0.0\",\n\"@types/react\": \"^16.3.16\",\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/test/example-test.tsx", "new_path": "packages/@almin/react-context/test/example-test.tsx", "diff": "@@ -3,11 +3,12 @@ import { Context, StoreGroup } from \"almin\";\nimport { createReactContext } from \"../src\";\nimport * as React from \"react\";\nimport * as TestUtils from \"react-dom/test-utils\";\n-import { createTestStore } from \"./helper/create-test-store\";\n+import { createStore } from \"@almin/store-test-helper\";\nfunction render<P>(element: React.ReactElement<P>): React.Component<P> {\nreturn TestUtils.renderIntoDocument(element) as React.Component<P>;\n}\n+\ndescribe(\"@almin/react-context\", () => {\ndescribe(\"example\", () => {\nit(\"should work\", () => {\n@@ -16,13 +17,14 @@ describe(\"@almin/react-context\", () => {\n// StoreGroup has {a, b, c} state\nstore: new StoreGroup({\n// createTestStore is a test helper that create Store instance of Almin\n- a: createTestStore({ value: \"a\" }),\n- b: createTestStore({ value: \"b\" }),\n- c: createTestStore({ value: \"c\" })\n+ a: createStore({ value: \"a\" }),\n+ b: createStore({ value: \"b\" }),\n+ c: createStore({ value: \"c\" })\n})\n});\n// Create React Context that wrap Almin Context\nconst { Consumer, Provider } = createReactContext(context);\n+\n// Use Provider\nclass App extends React.Component {\nrender() {\n@@ -34,7 +36,8 @@ describe(\"@almin/react-context\", () => {\n{state => {\nreturn (\n<ul>\n- <li>{state.a.value}</li>;\n+ <li>{state.a.value}</li>\n+ ;\n<li>{state.b.value}</li>;\n<li>{state.c.value}</li>;\n</ul>\n@@ -45,6 +48,7 @@ describe(\"@almin/react-context\", () => {\n);\n}\n}\n+\n// Test\nconst tree = render(<App />);\nconst elements = TestUtils.scryRenderedDOMComponentsWithTag(tree, \"li\");\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/test/react-context-test.tsx", "new_path": "packages/@almin/react-context/test/react-context-test.tsx", "diff": "@@ -3,7 +3,7 @@ import { Context } from \"almin\";\nimport { createReactContext } from \"../src\";\nimport * as React from \"react\";\nimport * as TestUtils from \"react-dom/test-utils\";\n-import { createTestStore } from \"./helper/create-test-store\";\n+import { createStore } from \"@almin/store-test-helper\";\nfunction render<P>(element: React.ReactElement<P>): React.Component<P> {\nreturn TestUtils.renderIntoDocument(element) as React.Component<P>;\n@@ -12,7 +12,7 @@ describe(\"@almin/react-context\", () => {\ndescribe(\"Provider/Consumer\", () => {\nit(\"should render with initialState props\", () => {\nconst context = new Context({\n- store: createTestStore({\n+ store: createStore({\nvalue: \"store-initial\"\n})\n});\n@@ -38,7 +38,7 @@ describe(\"@almin/react-context\", () => {\n});\nit(\"should render with initial getState() result\", () => {\nconst context = new Context({\n- store: createTestStore({\n+ store: createStore({\nvalue: \"initial\"\n})\n});\n@@ -63,7 +63,7 @@ describe(\"@almin/react-context\", () => {\nassert.strictEqual(element.textContent, \"initial\");\n});\nit(\"should re-render with updated state\", () => {\n- const testStore = createTestStore({\n+ const testStore = createStore({\nvalue: \"initial\"\n});\nconst context = new Context({\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "version \"9.4.1\"\nresolved \"https://registry.yarnpkg.com/@types/node/-/node-9.4.1.tgz#0f636f7837e15d2d73a7f6f3ea0e322eb2a5ab65\"\n+\"@types/node@^10.3.2\":\n+ version \"10.3.2\"\n+ resolved \"https://registry.yarnpkg.com/@types/node/-/node-10.3.2.tgz#3840ec6c12556fdda6e0e6d036df853101d732a4\"\n+\n\"@types/node@^9.0.0\":\nversion \"9.6.7\"\nresolved \"https://registry.yarnpkg.com/@types/node/-/node-9.6.7.tgz#5f3816d1db2155edcde1b2e3aa5d0e5c520cb564\"\n@@ -2577,6 +2581,13 @@ cross-env@^5.1.4:\ncross-spawn \"^5.1.0\"\nis-windows \"^1.0.0\"\n+cross-env@^5.1.6:\n+ version \"5.1.6\"\n+ resolved \"https://registry.yarnpkg.com/cross-env/-/cross-env-5.1.6.tgz#0dc05caf945b24e4b9e3b12871fe0e858d08b38d\"\n+ dependencies:\n+ cross-spawn \"^5.1.0\"\n+ is-windows \"^1.0.0\"\n+\ncross-spawn@^5.0.1, cross-spawn@^5.1.0:\nversion \"5.1.0\"\nresolved \"https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449\"\n@@ -7438,6 +7449,10 @@ prettier@^1.12.1:\nversion \"1.12.1\"\nresolved \"https://registry.yarnpkg.com/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325\"\n+prettier@^1.13.4:\n+ version \"1.13.4\"\n+ resolved \"https://registry.yarnpkg.com/prettier/-/prettier-1.13.4.tgz#31bbae6990f13b1093187c731766a14036fa72e6\"\n+\npretty-format@^22.4.3:\nversion \"22.4.3\"\nresolved \"https://registry.yarnpkg.com/pretty-format/-/pretty-format-22.4.3.tgz#f873d780839a9c02e9664c8a082e9ee79eaac16f\"\n" } ]
TypeScript
MIT License
almin/almin
refactor(react-context): use @almin/store-test-helper
19,400
08.06.2018 23:18:55
-32,400
3eac004c344b4a4f5f02edced78fea7db65438fc
test(store-test-helper): add tests
[ { "change_type": "MODIFY", "old_path": "packages/@almin/store-test-helper/src/store-test-helper.ts", "new_path": "packages/@almin/store-test-helper/src/store-test-helper.ts", "diff": "@@ -16,7 +16,7 @@ export interface MockStore<T> extends Store<T> {\n}\nexport const isCreateStoreArg = (arg: any): arg is createStoreArg<any> => {\n- return typeof arg === \"object\" && typeof arg.name === \"string\" && !(\"state\" in arg);\n+ return typeof arg === \"object\" && typeof arg.name === \"string\";\n};\nexport interface createStoreArg<T> {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/@almin/store-test-helper/test/store-test-helper-test.ts", "diff": "+import { createStore } from \"../src/store-test-helper\";\n+import * as assert from \"assert\";\n+import { Store } from \"almin\";\n+\n+describe(\"@almin/store-test-helper\", () => {\n+ describe(\"createStore\", () => {\n+ it(\"create({ name, state })\", () => {\n+ const initialState = {\n+ value: \"value\"\n+ };\n+ const store = createStore({\n+ name: \"TestStore\",\n+ state: initialState\n+ });\n+ assert.ok(store instanceof Store);\n+ assert.strictEqual(store.name, \"TestStore\");\n+ assert.deepStrictEqual(store.getState(), initialState);\n+ });\n+ it(\"create(state)\", () => {\n+ const initialState = {\n+ value: \"value\"\n+ };\n+ const store = createStore(initialState);\n+ assert.ok(store instanceof Store);\n+ assert.ok(/MockStore<\\d+>/.test(store.name));\n+ assert.deepStrictEqual(store.getState(), initialState);\n+ });\n+ });\n+});\n" } ]
TypeScript
MIT License
almin/almin
test(store-test-helper): add tests
19,400
08.06.2018 23:26:54
-32,400
5cbb5b2cab20e5b48f2409d8190fb7f1ce5bfa90
refactor(store-test-helper): Update Usage
[ { "change_type": "MODIFY", "old_path": "packages/@almin/store-test-helper/README.md", "new_path": "packages/@almin/store-test-helper/README.md", "diff": "@@ -10,7 +10,38 @@ Install with [npm](https://www.npmjs.com/):\n## Usage\n-- [ ] Write usage instructions\n+```ts\n+import { Store } from \"almin\";\n+export interface MockStore<T> extends Store<T> {\n+ updateStateWithoutEmit(newState: T): void;\n+ updateState(newState: T): void;\n+ getState(): any;\n+}\n+/**\n+ * This helper is for creating Store\n+ * @example\n+ * // state only\n+ * // name is increment number automatically\n+ * createStore({ value: \"state\" });\n+ * // with name\n+ * createStore(\"Store Name\", { value: \"state\" });\n+ *\n+ */\n+export declare function createStore<T>(storeName: string, initialState: T): MockStore<T>;\n+export declare function createStore<T>(initialState: T): MockStore<T>;\n+```\n+\n+### Example\n+\n+```ts\n+const initialState = {\n+ value: \"value\"\n+};\n+const store = createStore(\"TestStore\", initialState);\n+assert.ok(store instanceof Store);\n+assert.strictEqual(store.name, \"TestStore\");\n+assert.deepStrictEqual(store.getState(), initialState);\n+```\n## Changelog\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/store-test-helper/src/store-test-helper.ts", "new_path": "packages/@almin/store-test-helper/src/store-test-helper.ts", "diff": "@@ -15,15 +15,6 @@ export interface MockStore<T> extends Store<T> {\ngetState(): any;\n}\n-export const isCreateStoreArg = (arg: any): arg is createStoreArg<any> => {\n- return typeof arg === \"object\" && typeof arg.name === \"string\";\n-};\n-\n-export interface createStoreArg<T> {\n- name: string;\n- state?: T;\n-}\n-\n/**\n* This helper is for creating Store\n* @example\n@@ -31,10 +22,12 @@ export interface createStoreArg<T> {\n* // name is increment number automatically\n* createStore({ value: \"state\" });\n* // with name\n- * createStore({ name: \"store name\", state: { value: \"state\" } });\n+ * createStore(\"Store Name\", { value: \"state\" });\n*\n*/\n-export function createStore<T>(arg: T | createStoreArg<T>): MockStore<T> {\n+export function createStore<T>(storeName: string, initialState: T): MockStore<T>;\n+export function createStore<T>(initialState: T): MockStore<T>;\n+export function createStore<T>(...args: any[]): MockStore<T> {\nclass MockStoreImpl extends Store<T | undefined> implements MockStore<T> {\nstate: T | undefined;\nname: string;\n@@ -42,12 +35,12 @@ export function createStore<T>(arg: T | createStoreArg<T>): MockStore<T> {\nconstructor() {\nsuper();\nstoreCount++;\n- if (isCreateStoreArg(arg)) {\n- this.name = arg.name;\n- this.state = arg.state;\n+ if (typeof args[0] === \"string\") {\n+ this.name = args[0];\n+ this.state = args[1];\n} else {\nthis.name = `MockStore<${storeCount}>`;\n- this.state = arg;\n+ this.state = args[0];\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/store-test-helper/test/store-test-helper-test.ts", "new_path": "packages/@almin/store-test-helper/test/store-test-helper-test.ts", "diff": "@@ -4,14 +4,11 @@ import { Store } from \"almin\";\ndescribe(\"@almin/store-test-helper\", () => {\ndescribe(\"createStore\", () => {\n- it(\"create({ name, state })\", () => {\n+ it(\"create(name, state)\", () => {\nconst initialState = {\nvalue: \"value\"\n};\n- const store = createStore({\n- name: \"TestStore\",\n- state: initialState\n- });\n+ const store = createStore(\"TestStore\", initialState);\nassert.ok(store instanceof Store);\nassert.strictEqual(store.name, \"TestStore\");\nassert.deepStrictEqual(store.getState(), initialState);\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-logger/package.json", "new_path": "packages/almin-logger/package.json", "diff": "\"log\"\n],\n\"devDependencies\": {\n+ \"@almin/store-test-helper\": \"^1.0.0\",\n\"@types/mocha\": \"^5.2.1\",\n\"@types/node\": \"^9.3.0\",\n\"almin\": \"^0.16.0\",\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-logger/test/AsyncLogger-test.js", "new_path": "packages/almin-logger/test/AsyncLogger-test.js", "diff": "@@ -14,7 +14,7 @@ import AlminLogger from \"../src/AlminLogger\";\nimport AsyncLogger from \"../src/AsyncLogger\";\nimport { LogGroup } from \"../src/log/LogGroup\";\nimport ConsoleMock from \"./helper/ConsoleMock\";\n-import { createStore } from \"./store/create-store\";\n+import { createStore } from \"@almin/store-test-helper\";\nimport DispatchUseCase from \"./usecase/DispatchUseCase\";\nimport ErrorUseCase from \"./usecase/ErrorUseCase\";\nimport { ParentUseCase } from \"./usecase/NestingUseCase\";\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/StoreGroup-test.ts", "new_path": "packages/almin/test/StoreGroup-test.ts", "diff": "@@ -9,7 +9,7 @@ import { SinonStub } from \"sinon\";\nconst sinon = require(\"sinon\");\n-const createAsyncChangeStoreUseCase = (store: MockStore) => {\n+const createAsyncChangeStoreUseCase = (store: MockStore<any>) => {\nclass ChangeTheStoreUseCase extends UseCase {\nexecute() {\nreturn Promise.resolve().then(() => {\n@@ -21,7 +21,7 @@ const createAsyncChangeStoreUseCase = (store: MockStore) => {\nreturn new ChangeTheStoreUseCase();\n};\n-const createChangeStoreUseCase = (store: MockStore) => {\n+const createChangeStoreUseCase = (store: MockStore<any>) => {\nclass ChangeTheStoreUseCase extends UseCase {\nexecute() {\nconst newState = { a: {} };\n" } ]
TypeScript
MIT License
almin/almin
refactor(store-test-helper): Update Usage
19,400
08.06.2018 23:29:34
-32,400
87be83b4bb2023777a7e1afbe0d089ee0118d83c
chore(store-test-helper): add clean command
[ { "change_type": "MODIFY", "old_path": "packages/@almin/store-test-helper/package.json", "new_path": "packages/@almin/store-test-helper/package.json", "diff": "\"prepublish\": \"npm run --if-present build\",\n\"test\": \"mocha \\\"test/**/*.ts\\\"\",\n\"prettier\": \"prettier --write \\\"**/*.{js,jsx,ts,tsx,css}\\\"\",\n- \"watch\": \"tsc -p . --watch\"\n+ \"watch\": \"tsc -p . --watch\",\n+ \"clean\": \"rimraf lib/\"\n},\n\"prettier\": {\n\"printWidth\": 120,\n\"cross-env\": \"^5.1.6\",\n\"mocha\": \"^5.2.0\",\n\"prettier\": \"^1.13.4\",\n+ \"rimraf\": \"^2.6.2\",\n\"ts-node\": \"^6.1.0\",\n\"ts-node-test-register\": \"^3.0.0\",\n\"typescript\": \"^2.9.1\"\n" } ]
TypeScript
MIT License
almin/almin
chore(store-test-helper): add clean command
19,400
08.06.2018 23:30:57
-32,400
35fc1d0ed6c52e1c748b5cc8840f5cf3f078b457
chore(react-context): format
[ { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/test/example-test.tsx", "new_path": "packages/@almin/react-context/test/example-test.tsx", "diff": "@@ -36,8 +36,7 @@ describe(\"@almin/react-context\", () => {\n{state => {\nreturn (\n<ul>\n- <li>{state.a.value}</li>\n- ;\n+ <li>{state.a.value}</li>;\n<li>{state.b.value}</li>;\n<li>{state.c.value}</li>;\n</ul>\n" } ]
TypeScript
MIT License
almin/almin
chore(react-context): format
19,400
09.06.2018 00:04:50
-32,400
0bd00a888501b76ddc11d0a56f75f1eda59eef35
chore(deps): add ci scripts
[ { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/package.json", "new_path": "packages/@almin/react-context/package.json", "diff": "\"prepublish\": \"npm run --if-present build\",\n\"test\": \"mocha \\\"test/**/*.tsx\\\"\",\n\"prettier\": \"prettier --write \\\"**/*.{js,jsx,ts,tsx,css}\\\"\",\n- \"watch\": \"tsc -p . --watch\"\n+ \"watch\": \"tsc -p . --watch\",\n+ \"ci\": \"npm run test\"\n},\n\"prettier\": {\n\"printWidth\": 120,\n\"@almin/store-test-helper\": \"^1.0.0\",\n\"@types/mocha\": \"^5.2.1\",\n\"@types/node\": \"^9.0.0\",\n- \"@types/react\": \"^16.3.16\",\n- \"@types/react-dom\": \"^16.0.6\",\n+ \"@types/react\": \"^16.3.13\",\n+ \"@types/react-dom\": \"^16.0.5\",\n\"almin\": \"^0.16.0\",\n\"cross-env\": \"^5.1.4\",\n\"jsdom\": \"^11.9.0\",\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/store-test-helper/package.json", "new_path": "packages/@almin/store-test-helper/package.json", "diff": "\"test\": \"mocha \\\"test/**/*.ts\\\"\",\n\"prettier\": \"prettier --write \\\"**/*.{js,jsx,ts,tsx,css}\\\"\",\n\"watch\": \"tsc -p . --watch\",\n- \"clean\": \"rimraf lib/\"\n+ \"clean\": \"rimraf lib/\",\n+ \"ci\": \"npm run test\"\n},\n\"prettier\": {\n\"printWidth\": 120,\n" } ]
TypeScript
MIT License
almin/almin
chore(deps): add ci scripts
19,400
09.06.2018 00:59:05
-32,400
663d2bf6e217bb4a40906d9d0b31447635d201ca
chore(travis): update yarn version
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -4,7 +4,7 @@ node_js:\n- \"8\"\ncache: yarn\nbefore_install:\n- - curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.3.2\n+ - curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.7.0\n- export PATH=$HOME/.yarn/bin:$PATH\ninstall:\n- yarn install --frozen-lockfile\n" } ]
TypeScript
MIT License
almin/almin
chore(travis): update yarn version
19,400
09.06.2018 01:10:49
-32,400
c46a0915617cc8c663a8ac8b5381b9fe6df8df6a
fix(almin): fix typing test
[ { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"lint:fix\": \"npm-run-all -p lint:*:fix\",\n\"lint:js\": \"eslint --config ../../.eslintrc.json --cache test/\",\n\"lint:js:fix\": \"eslint --fix --config ../../.eslintrc.json --cache test/\",\n- \"test\": \"run-s lint test:js\",\n+ \"test\": \"run-s lint test:js test:type\",\n\"test:js\": \"cross-env NODE_ENV=development mocha \\\"test/**/*-test.{js,ts}\\\"\",\n+ \"test:type\": \"cross-env NODE_ENV=development mocha \\\"type-test/**/*-test.ts\\\"\",\n\"test:saucelabs\": \"npm run build:test && zuul -- out/test/*-test.js\",\n\"test:browser\": \"npm run build:test && zuul --local 8080 --ui mocha-bdd -- out/test/*-test.js\",\n\"presize\": \"npm-run-all -s clean build\",\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/almin/type-test/tsconfig.json", "diff": "+{\n+ \"extends\": \"../tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"allowJs\": true,\n+ \"declaration\": false,\n+ \"outDir\": \"../out/\"\n+ },\n+ \"include\": [\n+ \"../src/**/*\",\n+ \"./**/*\"\n+ ]\n+}\n" }, { "change_type": "RENAME", "old_path": "packages/almin/test/type-test.ts", "new_path": "packages/almin/type-test/type-test.ts", "diff": "" }, { "change_type": "RENAME", "old_path": "packages/almin/test/typing-fixtures/almin-loading.ts", "new_path": "packages/almin/type-test/typing-fixtures/almin-loading.ts", "diff": "" }, { "change_type": "RENAME", "old_path": "packages/almin/test/typing-fixtures/almin.ts", "new_path": "packages/almin/type-test/typing-fixtures/almin.ts", "diff": "" }, { "change_type": "RENAME", "old_path": "packages/almin/test/typing-fixtures/execute-argument.ts", "new_path": "packages/almin/type-test/typing-fixtures/execute-argument.ts", "diff": "" } ]
TypeScript
MIT License
almin/almin
fix(almin): fix typing test
19,400
09.06.2018 01:23:32
-32,400
20ce7266c8f2dd11256e69405a8906d01bfdc21e
test(almin): fix type testing
[ { "change_type": "MODIFY", "old_path": "packages/almin/type-test/typing-fixtures/execute-argument.ts", "new_path": "packages/almin/type-test/typing-fixtures/execute-argument.ts", "diff": "-import { UseCase, Context } from \"../../src/index\";\n-import { createStore } from \"../helper/create-new-store\";\n+import { UseCase, Context, Store } from \"../../src\";\n+\n+class MyStore extends Store<{}> {\n+ constructor(args: { name: string }) {\n+ super();\n+ this.name = args.name;\n+ }\n+ getState() {\n+ return {};\n+ }\n+}\n+\nclass MyUseCaseNoArgument extends UseCase {\nexecute() {}\n}\n+\nclass MyUseCaseA extends UseCase {\nexecute(_a: string) {}\n}\n@@ -22,8 +33,9 @@ class MyUseCaseOptional extends UseCase {\nclass MyUseCaseDefault extends UseCase {\nexecute(_value: string = \"string\") {}\n}\n+\nconst context = new Context({\n- store: createStore({ name: \"test\" })\n+ store: new MyStore({ name: \"test\" })\n});\n// valid\n" } ]
TypeScript
MIT License
almin/almin
test(almin): fix type testing
19,400
09.06.2018 21:31:57
-32,400
9438934832e0bd1ec51112684a8f7304d89b08de
chore(pacakge): add publishConfig
[ { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/package.json", "new_path": "packages/@almin/react-context/package.json", "diff": "},\n\"scripts\": {\n\"build\": \"cross-env NODE_ENV=production tsc -p .\",\n+ \"ci\": \"npm run test\",\n\"prepublish\": \"npm run --if-present build\",\n\"test\": \"mocha \\\"test/**/*.tsx\\\"\",\n\"prettier\": \"prettier --write \\\"**/*.{js,jsx,ts,tsx,css}\\\"\",\n- \"watch\": \"tsc -p . --watch\",\n- \"ci\": \"npm run test\"\n+ \"watch\": \"tsc -p . --watch\"\n},\n\"prettier\": {\n\"printWidth\": 120,\n\"singleQuote\": false,\n\"tabWidth\": 4\n},\n- \"peerDependencies\": {\n- \"react\": \">=16.3.0\"\n- },\n\"devDependencies\": {\n\"@almin/store-test-helper\": \"^1.0.0\",\n\"@types/mocha\": \"^5.2.1\",\n\"ts-node-test-register\": \"^3.0.0\",\n\"typescript\": \"^2.9.1\"\n},\n+ \"peerDependencies\": {\n+ \"react\": \">=16.3.0\"\n+ },\n+ \"publishConfig\": {\n+ \"access\": \"public\"\n+ },\n\"resolutions\": {\n\"@types/react\": \"16.3.13\",\n\"@types/react-dom\": \"16.0.5\"\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/store-test-helper/package.json", "new_path": "packages/@almin/store-test-helper/package.json", "diff": "},\n\"scripts\": {\n\"build\": \"cross-env NODE_ENV=production tsc -p .\",\n+ \"ci\": \"npm run test\",\n+ \"clean\": \"rimraf lib/\",\n\"prepublish\": \"npm run --if-present build\",\n\"test\": \"mocha \\\"test/**/*.ts\\\"\",\n\"prettier\": \"prettier --write \\\"**/*.{js,jsx,ts,tsx,css}\\\"\",\n- \"watch\": \"tsc -p . --watch\",\n- \"clean\": \"rimraf lib/\",\n- \"ci\": \"npm run test\"\n+ \"watch\": \"tsc -p . --watch\"\n},\n\"prettier\": {\n\"printWidth\": 120,\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-bus/package.json", "new_path": "packages/@almin/usecase-bus/package.json", "diff": "\"prettier\": \"prettier --write \\\"**/*.{js,jsx,ts,tsx,css}\\\"\",\n\"watch\": \"tsc -p . --watch\"\n},\n- \"peerDependencies\": {\n- \"almin\": \"^0.16.0\"\n+ \"prettier\": {\n+ \"printWidth\": 120,\n+ \"singleQuote\": false,\n+ \"tabWidth\": 4\n},\n\"devDependencies\": {\n\"@types/mocha\": \"^5.2.1\",\n\"ts-node-test-register\": \"^3.0.0\",\n\"typescript\": \"^2.9.1\"\n},\n- \"prettier\": {\n- \"singleQuote\": false,\n- \"printWidth\": 120,\n- \"tabWidth\": 4\n+ \"peerDependencies\": {\n+ \"almin\": \"^0.16.0\"\n+ },\n+ \"publishConfig\": {\n+ \"access\": \"public\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-logger/package.json", "new_path": "packages/almin-logger/package.json", "diff": "{\n\"name\": \"almin-logger\",\n- \"repository\": {\n- \"type\": \"git\",\n- \"url\": \"git+https://github.com/almin/almin.git\"\n- },\n- \"author\": \"azu\",\n- \"email\": \"azuciao@gmail.com\",\n+ \"version\": \"6.1.5\",\n+ \"description\": \"logger for Almin.js\",\n+ \"keywords\": [\n+ \"almin\",\n+ \"log\",\n+ \"logger\"\n+ ],\n\"homepage\": \"https://github.com/almin/almin/tree/master/packages/almin-logger\",\n+ \"bugs\": {\n+ \"url\": \"https://github.com/almin/almin/issues\"\n+ },\n\"license\": \"MIT\",\n+ \"author\": \"azu\",\n\"files\": [\n\"src/\",\n\"lib/\"\n],\n- \"bugs\": {\n- \"url\": \"https://github.com/almin/almin/issues\"\n- },\n- \"version\": \"6.1.5\",\n- \"description\": \"logger for Almin.js\",\n\"main\": \"lib/src/AlminLogger.js\",\n\"types\": \"lib/src/AlminLogger.d.ts\",\n\"directories\": {\n\"test\": \"test\"\n},\n+ \"repository\": {\n+ \"type\": \"git\",\n+ \"url\": \"git+https://github.com/almin/almin.git\"\n+ },\n\"scripts\": {\n- \"clean\": \"rimraf lib/\",\n\"prebuild\": \"npm run clean\",\n\"build\": \"cross-env NODE_ENV=production tsc -p .\",\n\"build:test\": \"tsc -p test/\",\n- \"watch\": \"tsc -p . --watch\",\n+ \"ci\": \"npm run test\",\n+ \"clean\": \"rimraf lib/\",\n\"prepublish\": \"npm run --if-present build\",\n- \"test:saucelabs\": \"zuul -- lib/test/*-test.js\",\n- \"test:browser\": \"npm run build:test && zuul --local 8080 --ui mocha-bdd -- lib/test/*-test.js\",\n\"test\": \"rimraf out/ && npm run build:test && mocha out/test/\",\n\"posttest\": \"rimraf out/\",\n- \"ci\": \"npm run test\"\n+ \"test:browser\": \"npm run build:test && zuul --local 8080 --ui mocha-bdd -- lib/test/*-test.js\",\n+ \"test:saucelabs\": \"zuul -- lib/test/*-test.js\",\n+ \"watch\": \"tsc -p . --watch\"\n+ },\n+ \"dependencies\": {\n+ \"map-like\": \"^2.0.0\"\n},\n- \"keywords\": [\n- \"almin\",\n- \"logger\",\n- \"log\"\n- ],\n\"devDependencies\": {\n\"@almin/store-test-helper\": \"^1.0.0\",\n\"@types/mocha\": \"^5.2.1\",\n\"peerDependencies\": {\n\"almin\": \"^0.15.0\"\n},\n- \"dependencies\": {\n- \"map-like\": \"^2.0.0\"\n- }\n+ \"email\": \"azuciao@gmail.com\"\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-react-container/package.json", "new_path": "packages/almin-react-container/package.json", "diff": "{\n- \"directories\": {\n- \"test\": \"test\"\n+ \"name\": \"almin-react-container\",\n+ \"version\": \"0.6.4\",\n+ \"description\": \"React bindings for Almin\",\n+ \"keywords\": [\n+ \"almin\",\n+ \"component\",\n+ \"react\"\n+ ],\n+ \"homepage\": \"https://github.com/almin/almin/tree/master/packages/almin-react-container\",\n+ \"bugs\": {\n+ \"url\": \"https://github.com/almin/almin/issues\"\n},\n- \"author\": \"azu\",\n\"license\": \"MIT\",\n+ \"author\": \"azu\",\n\"files\": [\n\"bin/\",\n\"lib/\",\n\"src/\"\n],\n- \"name\": \"almin-react-container\",\n- \"version\": \"0.6.4\",\n- \"description\": \"React bindings for Almin\",\n\"main\": \"lib/almin-react-container.js\",\n\"types\": \"lib/almin-react-container.d.ts\",\n- \"scripts\": {\n- \"test\": \"mocha \\\"test/**/*-test.{ts,tsx}\\\"\",\n- \"build\": \"cross-env NODE_ENV=production tsc -p .\",\n- \"watch\": \"tsc -p . --watch\",\n- \"prepublish\": \"npm run --if-present build\",\n- \"clean\": \"rimraf lib/\"\n+ \"directories\": {\n+ \"test\": \"test\"\n},\n- \"keywords\": [\n- \"react\",\n- \"almin\",\n- \"component\"\n- ],\n\"repository\": {\n\"type\": \"git\",\n\"url\": \"https://github.com/almin/almin.git\"\n},\n- \"bugs\": {\n- \"url\": \"https://github.com/almin/almin/issues\"\n+ \"scripts\": {\n+ \"build\": \"cross-env NODE_ENV=production tsc -p .\",\n+ \"clean\": \"rimraf lib/\",\n+ \"prepublish\": \"npm run --if-present build\",\n+ \"test\": \"mocha \\\"test/**/*-test.{ts,tsx}\\\"\",\n+ \"watch\": \"tsc -p . --watch\"\n},\n- \"homepage\": \"https://github.com/almin/almin/tree/master/packages/almin-react-container\",\n- \"peerDependencies\": {\n- \"almin\": \"^0.15.0\",\n- \"react\": \"^15.0.0 || ^16.0.0\"\n+ \"dependencies\": {\n+ \"shallow-equal-object\": \"^1.0.1\"\n},\n\"devDependencies\": {\n\"@types/node\": \"^9.3.0\",\n\"ts-node\": \"^6.1.0\",\n\"typescript\": \"~2.9.1\"\n},\n- \"dependencies\": {\n- \"shallow-equal-object\": \"^1.0.1\"\n+ \"peerDependencies\": {\n+ \"almin\": \"^0.15.0\",\n+ \"react\": \"^15.0.0 || ^16.0.0\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "{\n\"name\": \"almin\",\n- \"repository\": {\n- \"type\": \"git\",\n- \"url\": \"git+https://github.com/almin/almin.git\"\n- },\n- \"author\": \"azu\",\n- \"email\": \"azuciao@gmail.com\",\n+ \"version\": \"0.16.0\",\n+ \"description\": \"Client-side DDD/CQRS for JavaScript.\",\n+ \"keywords\": [\n+ \"aluminium\",\n+ \"architecture\",\n+ \"cqrs\",\n+ \"ddd\",\n+ \"flux\"\n+ ],\n\"homepage\": \"https://github.com/almin/almin\",\n+ \"bugs\": {\n+ \"url\": \"https://github.com/almin/almin/issues\"\n+ },\n\"license\": \"MIT\",\n+ \"author\": \"azu\",\n\"files\": [\n\"src/\",\n\"lib/src\"\n],\n- \"bugs\": {\n- \"url\": \"https://github.com/almin/almin/issues\"\n- },\n- \"version\": \"0.16.0\",\n- \"description\": \"Client-side DDD/CQRS for JavaScript.\",\n\"main\": \"lib/src/index.js\",\n\"types\": \"lib/src/index.d.ts\",\n\"directories\": {\n\"test\": \"test\"\n},\n+ \"repository\": {\n+ \"type\": \"git\",\n+ \"url\": \"git+https://github.com/almin/almin.git\"\n+ },\n\"scripts\": {\n- \"clean\": \"rimraf lib/\",\n\"build\": \"npm-run-all -s build:src build:lib\",\n- \"build:src\": \"tsc --project .\",\n\"build:lib\": \"npm-run-all -p build:lib:*\",\n\"build:lib:cp_type_def\": \"cpx type-definitions/**/*.js.flow lib/src/ --preserve\",\n+ \"build:src\": \"tsc --project .\",\n\"build:test\": \"tsc --project test/\",\n+ \"ci\": \"npm test && npm run size\",\n+ \"clean\": \"rimraf lib/\",\n\"lint\": \"npm-run-all -p lint:*\",\n\"lint:fix\": \"npm-run-all -p lint:*:fix\",\n\"lint:js\": \"eslint --config ../../.eslintrc.json --cache test/\",\n\"lint:js:fix\": \"eslint --fix --config ../../.eslintrc.json --cache test/\",\n+ \"prepublish\": \"npm run --if-present build\",\n+ \"presize\": \"npm-run-all -s clean build\",\n+ \"size\": \"size-limit\",\n\"test\": \"run-s lint test:js test:type\",\n+ \"test:browser\": \"npm run build:test && zuul --local 8080 --ui mocha-bdd -- out/test/*-test.js\",\n\"test:js\": \"cross-env NODE_ENV=development mocha \\\"test/**/*-test.{js,ts}\\\"\",\n- \"test:type\": \"cross-env NODE_ENV=development mocha \\\"type-test/**/*-test.ts\\\"\",\n\"test:saucelabs\": \"npm run build:test && zuul -- out/test/*-test.js\",\n- \"test:browser\": \"npm run build:test && zuul --local 8080 --ui mocha-bdd -- out/test/*-test.js\",\n- \"presize\": \"npm-run-all -s clean build\",\n- \"size\": \"size-limit\",\n- \"ci\": \"npm test && npm run size\",\n- \"prepublish\": \"npm run --if-present build\"\n+ \"test:type\": \"cross-env NODE_ENV=development mocha \\\"type-test/**/*-test.ts\\\"\"\n+ },\n+ \"dependencies\": {\n+ \"map-like\": \"^2.0.0\",\n+ \"shallow-equal-object\": \"^1.0.1\"\n},\n- \"size-limit\": [\n- {\n- \"path\": \"lib/src/index.js\",\n- \"limit\": \"15 KB\"\n- }\n- ],\n- \"keywords\": [\n- \"flux\",\n- \"cqrs\",\n- \"ddd\",\n- \"architecture\",\n- \"aluminium\"\n- ],\n\"devDependencies\": {\n\"@types/mocha\": \"^5.2.1\",\n\"@types/node\": \"^9.3.0\",\n\"typings-tester\": \"^0.3.1\",\n\"zuul\": \"^3.10.1\"\n},\n- \"dependencies\": {\n- \"map-like\": \"^2.0.0\",\n- \"shallow-equal-object\": \"^1.0.1\"\n+ \"email\": \"azuciao@gmail.com\",\n+ \"size-limit\": [\n+ {\n+ \"path\": \"lib/src/index.js\",\n+ \"limit\": \"15 KB\"\n}\n+ ]\n}\n" } ]
TypeScript
MIT License
almin/almin
chore(pacakge): add publishConfig
19,400
09.06.2018 21:37:16
-32,400
fc9d087f664dbff6927e6798a1d961b5dd831500
chore(package): add "clean" script
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"build:docs\": \"cd website && yarn run build\",\n\"build:docs:api\": \"bash ./tools/update-api-reference.sh\",\n\"ci\": \"lerna run ci --ignore benchmark\",\n+ \"clean\": \"lerna run clean\",\n\"prettier\": \"prettier --write '**/*.{js,jsx,ts,tsx,css}'\"\n},\n\"lint-staged\": {\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/package.json", "new_path": "packages/@almin/react-context/package.json", "diff": "\"prepublish\": \"npm run --if-present build\",\n\"test\": \"mocha \\\"test/**/*.tsx\\\"\",\n\"prettier\": \"prettier --write \\\"**/*.{js,jsx,ts,tsx,css}\\\"\",\n- \"watch\": \"tsc -p . --watch\"\n+ \"watch\": \"tsc -p . --watch\",\n+ \"clean\": \"rimraf lib/\"\n},\n\"prettier\": {\n\"printWidth\": 120,\n\"raf\": \"^3.4.0\",\n\"react\": \"^16.4.0\",\n\"react-dom\": \"^16.4.0\",\n+ \"rimraf\": \"^2.6.2\",\n\"ts-node\": \"^6.1.0\",\n\"ts-node-test-register\": \"^3.0.0\",\n\"typescript\": \"^2.9.1\"\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-bus/package.json", "new_path": "packages/@almin/usecase-bus/package.json", "diff": "{\n- \"name\": \"usecase-bus\",\n+ \"name\": \"@almin/usecase-bus\",\n\"version\": \"1.1.0\",\n\"description\": \"A mediator for UseCase and Command.\",\n\"keywords\": [\n\"prepublish\": \"npm run --if-present build\",\n\"test\": \"mocha \\\"test/**/*.ts\\\"\",\n\"prettier\": \"prettier --write \\\"**/*.{js,jsx,ts,tsx,css}\\\"\",\n- \"watch\": \"tsc -p . --watch\"\n+ \"watch\": \"tsc -p . --watch\",\n+ \"clean\": \"rimraf lib/\"\n},\n\"prettier\": {\n\"printWidth\": 120,\n\"cross-env\": \"^5.1.4\",\n\"mocha\": \"^5.2.0\",\n\"prettier\": \"^1.13.5\",\n+ \"rimraf\": \"^2.6.2\",\n\"ts-node\": \"^6.1.0\",\n\"ts-node-test-register\": \"^3.0.0\",\n\"typescript\": \"^2.9.1\"\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-react-container/package.json", "new_path": "packages/almin-react-container/package.json", "diff": "},\n\"scripts\": {\n\"build\": \"cross-env NODE_ENV=production tsc -p .\",\n- \"clean\": \"rimraf lib/\",\n+ \"clean\": \"rimraf lib/ out/\",\n\"prepublish\": \"npm run --if-present build\",\n\"test\": \"mocha \\\"test/**/*-test.{ts,tsx}\\\"\",\n\"watch\": \"tsc -p . --watch\"\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"build:src\": \"tsc --project .\",\n\"build:test\": \"tsc --project test/\",\n\"ci\": \"npm test && npm run size\",\n- \"clean\": \"rimraf lib/\",\n+ \"clean\": \"rimraf lib/ out/\",\n\"lint\": \"npm-run-all -p lint:*\",\n\"lint:fix\": \"npm-run-all -p lint:*:fix\",\n\"lint:js\": \"eslint --config ../../.eslintrc.json --cache test/\",\n" } ]
TypeScript
MIT License
almin/almin
chore(package): add "clean" script
19,400
09.06.2018 21:40:31
-32,400
9d346dd97ecff7a1e8605293a7551326c36282e2
chore(package): update publish script
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"precommit\": \"lint-staged\",\n\"postcommit\": \"git reset\",\n\"bootstrap\": \"lerna bootstrap\",\n- \"prepublishOnly\": \"npm run build\",\n- \"publish\": \"lerna publish --concurrency 1 --conventional-commits\",\n- \"publish:beta\": \"lerna publish --npm-tag=beta --concurrency 1 --conventional-commits\",\n+ \"publish\": \"npm run clean && npm run build && lerna publish --concurrency 1 --conventional-commits\",\n+ \"publish:beta\": \"npm run clean && npm run build && lerna publish --npm-tag=beta --concurrency 1 --conventional-commits\",\n\"bench\": \"cd perf/benchmark && npm run bench\",\n\"build\": \"lerna run build --ignore 'example-*'\",\n\"test\": \"yarn run build && lerna run test --ignore example-perf-benchmark\",\n" } ]
TypeScript
MIT License
almin/almin
chore(package): update publish script
19,400
09.06.2018 21:53:07
-32,400
398db96c0ee3927b37c854d5e8693d4323e5b91e
chore(website): enable blog
[ { "change_type": "MODIFY", "old_path": "website/siteConfig.js", "new_path": "website/siteConfig.js", "diff": "@@ -25,6 +25,7 @@ const siteConfig = {\n{ search: true },\n{ doc: \"getting-started\", label: \"Docs\" },\n{ doc: \"api\", label: \"API\" },\n+ { blog: true, label: \"Blog\" },\n{ page: \"help\", label: \"Help\" },\n{\nhref: \"https://github.com/almin/almin\",\n" } ]
TypeScript
MIT License
almin/almin
chore(website): enable blog
19,400
09.06.2018 21:55:34
-32,400
d1cd44afa9520b69ab750519b264f7b28fed0af4
chore(blog): update
[ { "change_type": "MODIFY", "old_path": "website/blog/2018-06-09-almin-0.17.md", "new_path": "website/blog/2018-06-09-almin-0.17.md", "diff": "@@ -37,9 +37,10 @@ We already have `context.useCase(someUseCase).executor(useCase => useCase.execut\nIt is a alternative syntax of `context.useCase(someUseCase).execute()`, but it is type-safe method.\nPreviously, Almin can not expected `args` type of `context.useCase(someUseCase).execute(args)`.\n+\nAlmin 0.17 will expect `args` type of `context.useCase(someUseCase).execute(args)`.\n-Examples:\n+Examples: Almin 0.17+\n```ts\nimport { UseCase, Context } from \"almin\";\n" } ]
TypeScript
MIT License
almin/almin
chore(blog): update
19,400
22.08.2018 09:41:06
-32,400
dd69712fc5f2570203022e89cfdada42b1916278
fix(almin): make `UseCaseExecutor#execute` type complete Require TypeScript 3.0+
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -13,18 +13,12 @@ import { Payload } from \"./payload/Payload\";\nimport { WillNotExecutedPayload } from \"./payload/WillNotExecutedPayload\";\nimport { assertOK } from \"./util/assert\";\n-// Conditional Typing in TS 2.8 >=\n+// TS 2.8+: Conditional Typing\n+// TS 3.0+: Tuple rest Generics\n// Get Arguments of T function and return tuple\n-export type A0<T> = T extends () => any ? T : never;\n-export type A1<T> = T extends (a1: infer R1) => any ? [R1] : [never];\n-export type A2<T> = T extends (a1: infer R1, a2: infer R2) => any ? [R1, R2] : [never, never];\n-export type A3<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3) => any ? [R1, R2, R3] : [never, never, never];\n-export type A4<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4) => any ? [R1, R2, R3, R4] : [never, never, never, never];\n-export type A5<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5) => any ? [R1, R2, R3, R4, R5] : [never, never, never, never, never];\n-export type A6<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5, a6: infer R6) => any ? [R1, R2, R3, R4, R5, R6] : [never, never, never, never, never, never];\n-export type A7<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5, a6: infer R6, a7: infer R7) => any ? [R1, R2, R3, R4, R5, R6, R7] : [never, never, never, never, never, never, never];\n-export type A8<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5, a6: infer R6, a7: infer R7, a8: infer R8) => any ? [R1, R2, R3, R4, R5, R6, R7, R8] : [never, never, never, never, never, never, never, never];\n-export type A9<T> = T extends (a1: infer R1, a2: infer R2, a3: infer R3, a4: infer R4, a5: infer R5, a6: infer R6, a7: infer R7, a8: infer R8, a9: infer R9) => any ? [R1, R2, R3, R4, R5, R6, R7, R8, R9] : [never, never, never, never, never, never, never, never, never];\n+// https://github.com/Microsoft/TypeScript/issues/5453#issuecomment-414768143\n+type Arguments<F extends (...x: any[]) => any> =\n+ F extends (...x: infer A) => any ? A : never;\ninterface InvalidUsage {\ntype: \"InvalidUsage\";\n@@ -150,19 +144,9 @@ https://almin.js.org/docs/warnings/usecase-is-already-released.html\nexport interface UseCaseExecutor<T extends UseCaseLike> extends Dispatcher {\nuseCase: T;\n- executor(executor: (useCase: Pick<T, \"execute\">) => any): Promise<void>;\n+ execute<P extends Arguments<T[\"execute\"]>>(...args: P): Promise<void>;\n- // FIXME: `execute()` pattern without hack\n- execute<P extends A0<T[\"execute\"]>>(this: P extends never ? never : this): Promise<void>;\n- execute<P extends A1<T[\"execute\"]>>(a1: P[0]): Promise<void>;\n- execute<P extends A2<T[\"execute\"]>>(a1: P[0], a2: P[1]): Promise<void>;\n- execute<P extends A3<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2]): Promise<void>;\n- execute<P extends A4<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3]): Promise<void>;\n- execute<P extends A5<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4]): Promise<void>;\n- execute<P extends A6<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5]): Promise<void>;\n- execute<P extends A7<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6]): Promise<void>;\n- execute<P extends A8<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6], a8: P[7]): Promise<void>;\n- execute<P extends A9<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6], a8: P[7], a9: P[8]): Promise<void>;\n+ executor(executor: (useCase: Pick<T, \"execute\">) => any): Promise<void>;\nrelease(): void;\n}\n@@ -249,7 +233,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\nprivate willExecuteUseCase(args?: any[]): void {\n// Add instance to manager\n// It should be removed when it will be completed.\n- UseCaseInstanceMap.set(this.useCase, this);\n+ UseCaseInstanceMap.set(this.useCase, this as UseCaseExecutor<T>);\nconst payload = new WillExecutedPayload({\nargs\n});\n@@ -461,17 +445,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n* However, it has a limitation about argument lengths.\n* For more details, please see <https://github.com/almin/almin/issues/107#issuecomment-384993458>\n*/\n- execute<P extends A0<T[\"execute\"]>>(this: P extends never ? never : this): Promise<void>;\n- execute<P extends A1<T[\"execute\"]>>(a1: P[0]): Promise<void>;\n- execute<P extends A2<T[\"execute\"]>>(a1: P[0], a2: P[1]): Promise<void>;\n- execute<P extends A3<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2]): Promise<void>;\n- execute<P extends A4<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3]): Promise<void>;\n- execute<P extends A5<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4]): Promise<void>;\n- execute<P extends A6<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5]): Promise<void>;\n- execute<P extends A7<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6]): Promise<void>;\n- execute<P extends A8<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6], a8: P[7]): Promise<void>;\n- execute<P extends A9<T[\"execute\"]>>(a1: P[0], a2: P[1], a3: P[2], a4: P[3], a5: P[4], a6: P[5], a7: P[6], a8: P[7], a9: P[8]): Promise<void>;\n- execute(...args: Array<any>): Promise<void> {\n+ execute<P extends Arguments<T[\"execute\"]>>(...args: P): Promise<void> {\nreturn this.executor(useCase => useCase.execute(...args));\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutorFactory.ts", "new_path": "packages/almin/src/UseCaseExecutorFactory.ts", "diff": "-import { UseCaseExecutorImpl } from \"./UseCaseExecutor\";\n+import { UseCaseExecutor, UseCaseExecutorImpl } from \"./UseCaseExecutor\";\nimport { isUseCaseFunction, UseCaseFunction } from \"./FunctionalUseCaseContext\";\nimport { FunctionalUseCase } from \"./FunctionalUseCase\";\nimport { isUseCase, UseCase } from \"./UseCase\";\n@@ -9,8 +9,8 @@ export function createUseCaseExecutor(\nuseCase: UseCaseFunction,\ndispatcher: Dispatcher\n): UseCaseExecutorImpl<FunctionalUseCase>;\n-export function createUseCaseExecutor<T extends UseCase>(useCase: T, dispatcher: Dispatcher): UseCaseExecutorImpl<T>;\n-export function createUseCaseExecutor(useCase: any, dispatcher: Dispatcher): UseCaseExecutorImpl<any> {\n+export function createUseCaseExecutor<T extends UseCase>(useCase: T, dispatcher: Dispatcher): UseCaseExecutor<T>;\n+export function createUseCaseExecutor(useCase: any, dispatcher: Dispatcher): UseCaseExecutor<any> {\n// instance of UseCase\nif (isUseCase(useCase)) {\nreturn new UseCaseExecutorImpl({\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/test/Context-test.ts", "new_path": "packages/almin/test/Context-test.ts", "diff": "@@ -236,7 +236,12 @@ describe(\"Context\", function() {\ndispatcher,\nstore: createStore({ name: \"test\" })\n});\n- const testUseCase = new TestUseCase();\n+\n+ class OneArgumentUseCase extends UseCase {\n+ execute(_oneArgument: string) {}\n+ }\n+\n+ const oneArgumentUseCase = new OneArgumentUseCase();\nconst expectedArguments = \"param\";\n// then\nappContext.events.onWillExecuteEachUseCase((payload, _meta) => {\n@@ -246,7 +251,7 @@ describe(\"Context\", function() {\ndone();\n});\n// when\n- appContext.useCase(testUseCase).execute(expectedArguments);\n+ return appContext.useCase(oneArgumentUseCase).execute(expectedArguments);\n});\n});\ndescribe(\"#onDispatch\", function() {\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/type-test/typing-fixtures/execute-argument.ts", "new_path": "packages/almin/type-test/typing-fixtures/execute-argument.ts", "diff": "@@ -5,6 +5,7 @@ class MyStore extends Store<{}> {\nsuper();\nthis.name = args.name;\n}\n+\ngetState() {\nreturn {};\n}\n@@ -31,7 +32,7 @@ class MyUseCaseOptional extends UseCase {\n}\nclass MyUseCaseDefault extends UseCase {\n- execute(_value: string = \"string\") {}\n+ execute(_value: string = \"default value\") {}\n}\nconst context = new Context({\n@@ -63,13 +64,8 @@ context.useCase(new MyUseCaseObj()).execute({ a: 1, b: 2 });\n// typings:expect-error\ncontext.useCase(new MyUseCaseOptional()).execute(1, 1);\n// typings:expect-error\n-context.useCase(new MyUseCaseDefault()).execute(1);\n-\n-// =====\n-// FIXME: These are should be Error, but current not support\n-// =====\n-// more arguments\n-\ncontext.useCase(new MyUseCaseA()).execute(\"A\", 1, 1);\n// typings:expect-error\ncontext.useCase(new MyUseCaseA()).executor(useCase => useCase.execute(\"A\", 1, 1));\n+// typings:expect-error\n+context.useCase(new MyUseCaseDefault()).execute({ \"incompatible type\": 1 });\n" } ]
TypeScript
MIT License
almin/almin
fix(almin): make `UseCaseExecutor#execute` type complete Require TypeScript 3.0+
19,400
22.08.2018 09:50:31
-32,400
d61936782fb6cd9aa4002915bdf8a21af6c85c38
chore: Update to TypeScript@3
[ { "change_type": "MODIFY", "old_path": "packages/@almin/react-context/package.json", "new_path": "packages/@almin/react-context/package.json", "diff": "\"react\": \"^16.4.0\",\n\"react-dom\": \"^16.4.0\",\n\"rimraf\": \"^2.6.2\",\n- \"ts-node\": \"^6.1.0\",\n- \"ts-node-test-register\": \"^3.0.0\",\n- \"typescript\": \"^2.9.1\"\n+ \"ts-node\": \"^7.0.1\",\n+ \"ts-node-test-register\": \"^4.0.0\",\n+ \"typescript\": \"^3.0.1\"\n},\n\"peerDependencies\": {\n\"react\": \">=16.3.0\"\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/store-test-helper/package.json", "new_path": "packages/@almin/store-test-helper/package.json", "diff": "\"mocha\": \"^5.2.0\",\n\"prettier\": \"^1.13.5\",\n\"rimraf\": \"^2.6.2\",\n- \"ts-node\": \"^6.1.0\",\n- \"ts-node-test-register\": \"^3.0.0\",\n- \"typescript\": \"^2.9.1\"\n+ \"ts-node\": \"^7.0.1\",\n+ \"ts-node-test-register\": \"^4.0.0\",\n+ \"typescript\": \"^3.0.1\"\n},\n\"publishConfig\": {\n\"access\": \"public\"\n" }, { "change_type": "MODIFY", "old_path": "packages/@almin/usecase-bus/package.json", "new_path": "packages/@almin/usecase-bus/package.json", "diff": "\"mocha\": \"^5.2.0\",\n\"prettier\": \"^1.13.5\",\n\"rimraf\": \"^2.6.2\",\n- \"ts-node\": \"^6.1.0\",\n- \"ts-node-test-register\": \"^3.0.0\",\n- \"typescript\": \"^2.9.1\"\n+ \"ts-node\": \"^7.0.1\",\n+ \"ts-node-test-register\": \"^4.0.0\",\n+ \"typescript\": \"^3.0.1\"\n},\n\"peerDependencies\": {\n\"almin\": \">=0.16.0\"\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-logger/package.json", "new_path": "packages/almin-logger/package.json", "diff": "\"power-assert\": \"^1.5.0\",\n\"rimraf\": \"^2.6.2\",\n\"simple-mock\": \"^0.8.0\",\n- \"typescript\": \"~2.9.1\",\n+ \"typescript\": \"~3.0.1\",\n\"webpack\": \"^3.8.1\",\n\"zuul\": \"^3.10.1\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/almin-react-container/package.json", "new_path": "packages/almin-react-container/package.json", "diff": "\"react\": \"^16.4.0\",\n\"react-dom\": \"^16.4.0\",\n\"rimraf\": \"^2.6.2\",\n- \"ts-node\": \"^6.1.0\",\n- \"typescript\": \"~2.9.1\"\n+ \"ts-node\": \"^7.0.1\",\n+ \"typescript\": \"~3.0.1\"\n},\n\"peerDependencies\": {\n\"almin\": \"^0.15.0\",\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/package.json", "new_path": "packages/almin/package.json", "diff": "\"sinon\": \"^4.5.0\",\n\"size-limit\": \"^0.17.0\",\n\"source-map-support\": \"^0.5.5\",\n- \"ts-node\": \"^6.1.0\",\n- \"ts-node-test-register\": \"^3.0.0\",\n- \"typescript\": \"~2.9.1\",\n+ \"ts-node\": \"^7.0.1\",\n+ \"ts-node-test-register\": \"^4.0.0\",\n+ \"typescript\": \"~3.0.1\",\n\"typings-tester\": \"^0.3.1\",\n\"zuul\": \"^3.10.1\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -58,6 +58,7 @@ interface newProxifyUseCaseArgs {\nonDidExecute(result?: any): void;\nonError(error: Error): void;\n+\n}\n/**\n@@ -149,6 +150,8 @@ export interface UseCaseExecutor<T extends UseCaseLike> extends Dispatcher {\nexecutor(executor: (useCase: Pick<T, \"execute\">) => any): Promise<void>;\nrelease(): void;\n+\n+ onRelease(handler: () => void): void;\n}\n/**\n@@ -299,7 +302,8 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n}\n/**\n- * @private like\n+ * Call handler when this UseCaseExecutor will be released\n+ * @param handler\n*/\nonRelease(handler: () => void): void {\nthis.on(\"USECASE_EXECUTOR_RELEASE\", handler);\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "version \"9.4.7\"\nresolved \"https://registry.yarnpkg.com/@types/node/-/node-9.4.7.tgz#57d81cd98719df2c9de118f2d5f3b1120dcd7275\"\n-\"@types/react-dom@16.0.5\", \"@types/react-dom@16.0.6\", \"@types/react-dom@^16.0.6\":\n- version \"16.0.5\"\n- resolved \"https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.0.5.tgz#a757457662e3819409229e8f86795ff37b371f96\"\n+\"@types/prop-types@*\":\n+ version \"15.5.5\"\n+ resolved \"https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.5.5.tgz#17038dd322c2325f5da650a94d5f9974943625e3\"\n+ dependencies:\n+ \"@types/react\" \"*\"\n+\n+\"@types/react-dom@16.0.6\":\n+ version \"16.0.6\"\n+ resolved \"https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.0.6.tgz#f1a65a4e7be8ed5d123f8b3b9eacc913e35a1a3c\"\ndependencies:\n\"@types/node\" \"*\"\n\"@types/react\" \"*\"\n-\"@types/react@*\", \"@types/react@16.3.13\", \"@types/react@16.3.17\", \"@types/react@^16.3.17\":\n+\"@types/react-dom@^16.0.6\":\n+ version \"16.0.7\"\n+ resolved \"https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.0.7.tgz#54d0f867a76b90597e8432030d297982f25c20ba\"\n+ dependencies:\n+ \"@types/node\" \"*\"\n+ \"@types/react\" \"*\"\n+\n+\"@types/react@*\":\nversion \"16.3.13\"\nresolved \"https://registry.yarnpkg.com/@types/react/-/react-16.3.13.tgz#47d466462b774556c1174ea0eda22c0578643362\"\ndependencies:\ncsstype \"^2.2.0\"\n+\"@types/react@16.3.17\":\n+ version \"16.3.17\"\n+ resolved \"https://registry.yarnpkg.com/@types/react/-/react-16.3.17.tgz#d59d1a632570b0713946ed9c2949d994773633c5\"\n+ dependencies:\n+ csstype \"^2.2.0\"\n+\n+\"@types/react@^16.3.17\":\n+ version \"16.4.11\"\n+ resolved \"https://registry.yarnpkg.com/@types/react/-/react-16.4.11.tgz#330f3d864300f71150dc2d125e48644c098f8770\"\n+ dependencies:\n+ \"@types/prop-types\" \"*\"\n+ csstype \"^2.2.0\"\n+\n\"@types/sinon@^4.3.1\":\nversion \"4.3.1\"\nresolved \"https://registry.yarnpkg.com/@types/sinon/-/sinon-4.3.1.tgz#32458f9b166cd44c23844eee4937814276f35199\"\n@@ -1616,6 +1642,10 @@ buffer-from@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.0.0.tgz#4cb8832d23612589b0406e9e2956c17f06fdf531\"\n+buffer-from@^1.1.0:\n+ version \"1.1.1\"\n+ resolved \"https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef\"\n+\nbuffer-xor@^1.0.3:\nversion \"1.0.3\"\nresolved \"https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9\"\n@@ -9286,17 +9316,18 @@ tryer@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/tryer/-/tryer-1.0.0.tgz#027b69fa823225e551cace3ef03b11f6ab37c1d7\"\n-ts-node-test-register@^3.0.0:\n- version \"3.0.0\"\n- resolved \"https://registry.yarnpkg.com/ts-node-test-register/-/ts-node-test-register-3.0.0.tgz#6b0397a7e3153dcfb9bf6cad48bd79a90674fe2a\"\n+ts-node-test-register@^4.0.0:\n+ version \"4.0.0\"\n+ resolved \"https://registry.yarnpkg.com/ts-node-test-register/-/ts-node-test-register-4.0.0.tgz#dcf35a1eb6d0608a799886108311d3654a2b1fb9\"\ndependencies:\nread-pkg \"^3.0.0\"\n-ts-node@^6.1.0:\n- version \"6.1.0\"\n- resolved \"https://registry.yarnpkg.com/ts-node/-/ts-node-6.1.0.tgz#a2c37a11fdb58e60eca887a1269b025cf4d2f8b8\"\n+ts-node@^7.0.1:\n+ version \"7.0.1\"\n+ resolved \"https://registry.yarnpkg.com/ts-node/-/ts-node-7.0.1.tgz#9562dc2d1e6d248d24bc55f773e3f614337d9baf\"\ndependencies:\narrify \"^1.0.0\"\n+ buffer-from \"^1.1.0\"\ndiff \"^3.1.0\"\nmake-error \"^1.1.1\"\nminimist \"^1.2.0\"\n@@ -9355,7 +9386,11 @@ typedarray@^0.0.6, typedarray@~0.0.5:\nversion \"0.0.6\"\nresolved \"https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777\"\n-typescript@^2.9.1, typescript@~2.9.1:\n+typescript@^3.0.1, typescript@~3.0.1:\n+ version \"3.0.1\"\n+ resolved \"https://registry.yarnpkg.com/typescript/-/typescript-3.0.1.tgz#43738f29585d3a87575520a4b93ab6026ef11fdb\"\n+\n+typescript@~2.9.1:\nversion \"2.9.1\"\nresolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.9.1.tgz#fdb19d2c67a15d11995fd15640e373e09ab09961\"\n" } ]
TypeScript
MIT License
almin/almin
chore: Update to TypeScript@3
19,400
24.08.2018 20:04:55
-32,400
e97f03f3e3ce81508ac810ac231bcef19aebab49
chore(deps): Use TypeScript 3.0
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"textlint-rule-alex\": \"^1.0.1\",\n\"textlint-rule-common-misspellings\": \"^1.0.1\",\n\"textlint-rule-no-dead-link\": \"^4.3.0\",\n- \"textlint-rule-prh\": \"^5.0.1\",\n- \"typescript\": \"~2.9.1\"\n+ \"textlint-rule-prh\": \"^5.0.1\"\n},\n\"scripts\": {\n\"precommit\": \"lint-staged\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -9364,10 +9364,6 @@ typescript@^3.0.1, typescript@~3.0.1:\nversion \"3.0.1\"\nresolved \"https://registry.yarnpkg.com/typescript/-/typescript-3.0.1.tgz#43738f29585d3a87575520a4b93ab6026ef11fdb\"\n-typescript@~2.9.1:\n- version \"2.9.1\"\n- resolved \"https://registry.yarnpkg.com/typescript/-/typescript-2.9.1.tgz#fdb19d2c67a15d11995fd15640e373e09ab09961\"\n-\ntypings-tester@^0.3.1:\nversion \"0.3.1\"\nresolved \"https://registry.yarnpkg.com/typings-tester/-/typings-tester-0.3.1.tgz#53bb9784b0ebd7b93192e6fcd908f14501af3878\"\n" } ]
TypeScript
MIT License
almin/almin
chore(deps): Use TypeScript 3.0
19,400
24.08.2018 20:39:53
-32,400
2ea2ed6d39ff67c0af4da25239887b1bf00df5c1
refactor(almin): make `executor()` deprecated
[ { "change_type": "MODIFY", "old_path": "packages/almin/src/UseCaseExecutor.ts", "new_path": "packages/almin/src/UseCaseExecutor.ts", "diff": "@@ -67,7 +67,7 @@ interface newProxifyUseCaseArgs {\n*/\nconst proxifyUseCase = <T extends UseCaseLike>(useCase: T, handlers: newProxifyUseCaseArgs): T => {\nlet isExecuted = false;\n- const execute = (...args: Array<any>): EXECUTING_RESULT => {\n+ const execute = (...args: Arguments<T[\"execute\"]>): EXECUTING_RESULT => {\nif (process.env.NODE_ENV !== \"production\") {\nif (isExecuted) {\nconsole.error(`Warning(UseCase): ${useCase.name}#execute was called more than once.`);\n@@ -310,7 +310,7 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n}\n/**\n- * - **Stability**: Experimental\n+ * - **Stability**: Deprecated(Previously experimental)\n* - This feature is subject to change. It may change or be removed in future versions.\n* - If you inserting in this, please see <https://github.com/almin/almin/issues/193>\n*\n@@ -343,22 +343,24 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n* .executor(useCase => useCase.execute(\"value\"))\n* ```\n*\n- * ### I'm use TypeScript, Should I use `executor`?\n- *\n- * Yes. It is type-safe by default.\n- * In other words, JavaScript User have not benefits.\n- *\n* ### Why executor's result always to be undefined?\n*\n- * UseCaseExecutor always resolve `undefined` data by design.\n+ * `execute()` return a Promise that will resolve `undefined` by design.\n* In CQRS, the command always have returned void type.\n*\n* - http://cqrs.nu/Faq\n*\n- * So, Almin return only command result that is success or failure.\n- * You should not relay on the data of the command result.\n+ * So, `execute()` only return command result that is success or failure.\n+ * You should not relay on the result value of the useCase#execute.\n+ *\n+ * @deprecated Use `execute()` instead of `executor()`\n+ * Almin 0.18+ make `execute` type complete.\n*/\nexecutor(executor: (useCase: Pick<T, \"execute\">) => any): Promise<void> {\n+ // TODO: executor() is duplication function of execute()\n+ // It will be removed in the future.\n+ // Show deprecated waring\n+ console.warn(\"`executor(useCase => useCase.execute(args))` is deprecated. Use `execute(args) insteadof it.\");\nif (typeof executor !== \"function\") {\nconsole.error(\n\"Warning(UseCase): executor argument should be function. But this argument is not function: \",\n@@ -366,9 +368,6 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n);\nreturn Promise.reject(new Error(\"executor(fn) arguments should be function\"));\n}\n- // Notes: proxyfiedUseCase has not timeout\n- // proxiedUseCase will resolve by UseCaseWrapper#execute\n- // For more details, see <UseCaseLifeCycle-test.ts>\nconst proxyfiedUseCase = proxifyUseCase<T>(this.useCase, {\nonWillNotExecute: (args: any[]) => {\nthis.willNotExecuteUseCase(args);\n@@ -383,18 +382,13 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\nthis.useCase.throwError(error);\n}\n});\n- // Note: almin disallow to call `executor(useCase => { setTimeout(() => useCase.execute(), 0}})` asynchronously\n- // You should call UseCase#execute synchronously.\nconst executorResult: EXECUTING_RESULT | undefined = executor(proxyfiedUseCase);\n- // `executorResult` is undefined means that the UseCase#execute never return any value\n- // In JavaScript, no return as undefined value\nconst executedResult: EXECUTING_RESULT =\nexecutorResult !== undefined\n? executorResult\n: {\ntype: \"SuccessExecuteNoReturnValue\"\n};\n- // if does not execute, release and resolve as soon as possible\nif (executedResult.type === \"ShouldNotExecute\") {\nthis.release();\nreturn Promise.resolve();\n@@ -406,15 +400,12 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\ncase \"ErrorInExecute\":\nreturn reject(executedResult.error);\ncase \"SuccessExecuteReturnValue\": {\n- // try to resolve return value\n- // if the return promise is reject, report error from UseCase\nreturn Promise.resolve(executedResult.value).then(resolve, error => {\nthis.useCase.throwError(error);\nreturn reject(error);\n});\n}\ncase \"SuccessExecuteNoReturnValue\":\n- // The UseCase#execute just success without return value\nreturn resolve();\n}\n});\n@@ -437,20 +428,93 @@ export class UseCaseExecutorImpl<T extends UseCaseLike> extends Dispatcher imple\n* This method invoke UseCase's `execute` method and return a promise<void>.\n* The promise will be resolved when the UseCase is completed finished.\n*\n- * ## Notes\n+ * ### Why executor's result always to be undefined?\n*\n- * The `execute(arguments)` is shortcut of `executor(useCase => useCase.execute(arguments)`\n+ * `execute()` return a Promise that will resolve `undefined` by design.\n+ * In CQRS, the command always have returned void type.\n*\n- * ### `execute()` typing for TypeScript\n+ * - http://cqrs.nu/Faq\n+ *\n+ * So, `execute()` only return command result that is success or failure.\n+ * You should not relay on the result value of the useCase#execute.\n*\n- * > Added: Almin 0.17.0 >=\n+ * ## Notes\n+ *\n+ * > Added: Almin 0.17.0+\n*\n* `execute()` support type check in Almin 0.17.0.\n* However, it has a limitation about argument lengths.\n* For more details, please see <https://github.com/almin/almin/issues/107#issuecomment-384993458>\n+ *\n+ * > Added: Almin 0.18.0+\n+ *\n+ * `execute()` support type check completely.\n+ * No more need to use `executor()` for typing.\n+ *\n*/\nexecute<P extends Arguments<T[\"execute\"]>>(...args: P): Promise<void> {\n- return this.executor(useCase => useCase.execute(...args));\n+ // Notes: proxyfiedUseCase has not timeout\n+ // proxiedUseCase will resolve by UseCaseWrapper#execute\n+ // For more details, see <UseCaseLifeCycle-test.ts>\n+ const proxyfiedUseCase = proxifyUseCase<T>(this.useCase, {\n+ onWillNotExecute: (args: any[]) => {\n+ this.willNotExecuteUseCase(args);\n+ },\n+ onWillExecute: (args: any[]) => {\n+ this.willExecuteUseCase(args);\n+ },\n+ onDidExecute: (result?: any) => {\n+ this.didExecuteUseCase(result);\n+ },\n+ onError: (error: Error) => {\n+ this.useCase.throwError(error);\n+ }\n+ });\n+ // Note: almin disallow to call `executor(useCase => { setTimeout(() => useCase.execute(), 0}})` asynchronously\n+ // You should call UseCase#execute synchronously.\n+ const executorResult: EXECUTING_RESULT | undefined = proxyfiedUseCase.execute(...args);\n+ // `executorResult` is undefined means that the UseCase#execute never return any value\n+ // In JavaScript, no return as undefined value\n+ const executedResult: EXECUTING_RESULT =\n+ executorResult !== undefined\n+ ? executorResult\n+ : {\n+ type: \"SuccessExecuteNoReturnValue\"\n+ };\n+ // if does not execute, release and resolve as soon as possible\n+ if (executedResult.type === \"ShouldNotExecute\") {\n+ this.release();\n+ return Promise.resolve();\n+ }\n+ const startingExecutor = new Promise((resolve, reject) => {\n+ switch (executedResult.type) {\n+ case \"InvalidUsage\":\n+ return reject(executedResult.error);\n+ case \"ErrorInExecute\":\n+ return reject(executedResult.error);\n+ case \"SuccessExecuteReturnValue\": {\n+ // try to resolve return value\n+ // if the return promise is reject, report error from UseCase\n+ return Promise.resolve(executedResult.value).then(resolve, error => {\n+ this.useCase.throwError(error);\n+ return reject(error);\n+ });\n+ }\n+ case \"SuccessExecuteNoReturnValue\":\n+ // The UseCase#execute just success without return value\n+ return resolve();\n+ }\n+ });\n+ return startingExecutor\n+ .then(result => {\n+ this.completeUseCase(result);\n+ this.release();\n+ })\n+ .catch(error => {\n+ this.completeUseCase();\n+ this.release();\n+ return Promise.reject(error);\n+ });\n}\n/**\n" } ]
TypeScript
MIT License
almin/almin
refactor(almin): make `executor()` deprecated