Skip to content

Commit

Permalink
feat: new fetch state machine (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd authored Sep 15, 2024
2 parents b22ca7e + 3ac5236 commit 676aa0d
Show file tree
Hide file tree
Showing 32 changed files with 896 additions and 557 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"cSpell.words": [
"Alwatr"
"Alwatr",
"jfsm"
]
}
11 changes: 6 additions & 5 deletions packages/context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
},
"repository": {
"type": "git",
"url": "https://github.com/Alwatr/signal",
"directory": "packages/signal"
"url": "https://github.com/Alwatr/flux",
"directory": "packages/context"
},
"homepage": "https://github.com/Alwatr/signal/tree/next/packages/signal#readme",
"homepage": "https://github.com/Alwatr/flux/tree/next/packages/context#readme",
"bugs": {
"url": "https://github.com/Alwatr/signal/issues"
"url": "https://github.com/Alwatr/flux/issues"
},
"prettier": "@alwatr/prettier-config",
"scripts": {
Expand All @@ -56,7 +56,8 @@
"clean": "rm -rfv dist *.tsbuildinfo"
},
"dependencies": {
"@alwatr/logger": "^3.2.13"
"@alwatr/logger": "^3.2.13",
"@alwatr/observable": "workspace:^"
},
"devDependencies": {
"@alwatr/nano-build": "^1.3.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/context/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"composite": true,
},
"include": ["src/**/*.ts"],
"references": [],
"references": [{"path": "../observable"}],
}
124 changes: 124 additions & 0 deletions packages/fetch-state-machine/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.2.6](https://github.com/Alwatr/flux/compare/@alwatr/[email protected]...@alwatr/[email protected]) (2023-12-19)

**Note:** Version bump only for package @alwatr/server-context

## [1.2.5](https://github.com/Alwatr/flux/compare/@alwatr/[email protected]...@alwatr/[email protected]) (2023-12-19)

**Note:** Version bump only for package @alwatr/server-context

## [1.2.4](https://github.com/Alwatr/flux/compare/@alwatr/[email protected]...@alwatr/[email protected]) (2023-11-09)

**Note:** Version bump only for package @alwatr/server-context

## [1.2.3](https://github.com/Alwatr/flux/compare/@alwatr/[email protected]...@alwatr/[email protected]) (2023-11-01)

**Note:** Version bump only for package @alwatr/server-context

## [1.2.2](https://github.com/Alwatr/flux/compare/@alwatr/[email protected]...@alwatr/[email protected]) (2023-10-23)

### Bug Fixes

- **server-context:** compatible with new logger api ([916db77](https://github.com/Alwatr/flux/commit/916db775c4e352d7ca663507f80539eef38b4738)) by @

## [1.2.1](https://github.com/Alwatr/flux/compare/@alwatr/[email protected]...@alwatr/[email protected]) (2023-10-16)

### Bug Fixes

- **server-context:** request options gone in offline requests ([a80b79e](https://github.com/Alwatr/flux/commit/a80b79e3a5969d4bca42a2720a1194bad984599f)) by @AliMD

# 1.2.0 (2023-09-19)

### Bug Fixes

- all new repo path and packages dependencies ([21a6afa](https://github.com/Alwatr/flux/commit/21a6afa0badafe4051617d9a9e3bbfbaabd0c4ad)) by @AliMD
- **server-context:** import issue ([aa76ffe](https://github.com/Alwatr/flux/commit/aa76ffe2f55e5a8dfe2b93ce756caa3311022f7e)) by @AliMD
- ts refrence path ([c2baa44](https://github.com/Alwatr/flux/commit/c2baa44999c72a0015481fc8fea25439329c3f37)) by @AliMD

## [1.1.2](https://github.com/Alwatr/flux/compare/@alwatr/[email protected]...@alwatr/[email protected]) (2023-09-12)

**Note:** Version bump only for package @alwatr/context

## [1.1.1](https://github.com/Alwatr/flux/compare/@alwatr/[email protected]...@alwatr/[email protected]) (2023-09-12)

**Note:** Version bump only for package @alwatr/context

# 1.1.0 (2023-09-12)

### Bug Fixes

- **server-context:** convert some `super` to `this` ([3a79736](https://github.com/Alwatr/flux/commit/3a7973658daf2ee364aced0c7c4880041dfc9a1a))
- **server-context:** export `server-context` to use ([b71c9a5](https://github.com/Alwatr/flux/commit/b71c9a5efa35ac4b5e53fd5cd966277abd7ff592))

### Features

- **server-context:** AlwatrServerContext ([2ca976a](https://github.com/Alwatr/flux/commit/2ca976afd50b3022a264eef880274a9e1496056a))
- **server-context:** dynamic extra state/event type ([1cb6db1](https://github.com/Alwatr/flux/commit/1cb6db1573f9349edecdc7d73e66243cadea40d4))

# 1.0.0 (2023-06-14)

### Bug Fixes

- **server-context:** add `_request` & `_actionRecord` ([5037fec](https://github.com/Alwatr/flux/commit/5037fecf68fc59727c7d66afdc2accce4d78f107))
- **server-context:** arg of `request` in `AlwatrApiRequest` ([d1835eb](https://github.com/Alwatr/flux/commit/d1835eba2ac024d297b439721a57515eca798f32))
- **server-context:** export `api-request` ([b91fe96](https://github.com/Alwatr/flux/commit/b91fe964a14e75aa0d544437e6aa4de1e990272d))
- **server-context:** review and fix runtime issues ([e2f6814](https://github.com/Alwatr/flux/commit/e2f6814a0ad8d2da8f2b76a9c10706234364c3c9))
- **server-context:** tsconfig ([b200a21](https://github.com/Alwatr/flux/commit/b200a2171fe68f04e7dd839c1746160281ff847b))
- **server-request:** review and enhance ([ae3b530](https://github.com/Alwatr/flux/commit/ae3b5301da7a0de76ed1eafbeca62fa34695892f))

### Features

- **api-request:** base on server-request ([8cfd0d9](https://github.com/Alwatr/flux/commit/8cfd0d971e9b06c3859db3bdaac3afb43ed996ab))
- **server-context:** add new module ([01d843c](https://github.com/Alwatr/flux/commit/01d843c4fb6a363dedb6c1fa23d8fa5f87b50cef))

# 0.32.0 (2023-05-27)

### Bug Fixes

- **context:** compatible with new storage api ([5251ff0](https://github.com/Alwatr/flux/commit/5251ff005624720e091cdbc40e6b0142743428cb))

# 0.31.0 (2023-05-08)

### Bug Fixes

- build issues ([e1060bc](https://github.com/Alwatr/flux/commit/e1060bccbfe3c775c32b85e9b8eb601e48b2998c))
- **context:** merge request option issue ([e24e695](https://github.com/Alwatr/flux/commit/e24e695a8c25ab1dcb1c351a3ae0434e921610d0))
- new logger api ([9d83a7d](https://github.com/Alwatr/flux/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
- packages and refs ([eea2382](https://github.com/Alwatr/flux/commit/eea2382e459ccaa3e7b4b329d9c196eda146a08e))

### Features

- **context:** add `requestIfNotComplete` ([580d5c9](https://github.com/Alwatr/flux/commit/580d5c9c74f1c8921b45d402641df9444f438547))
- **context:** awesome server context ([c001c58](https://github.com/Alwatr/flux/commit/c001c58a2b1b4e13fd1c34b5128031fd640a98e1))
- **context:** new package ([98ee43d](https://github.com/Alwatr/flux/commit/98ee43d83b1ad5b3806ec6053c5cac70912000b3))
- **context:** simple context api ([2a1b152](https://github.com/Alwatr/flux/commit/2a1b152380f267a6b173f08bbbe10295325b1fd8))

# [1.0.0](https://github.com/Alwatr/flux/compare/v0.32.0...v1.0.0) (2023-06-14)

**Note:** Version bump only for package @alwatr/context

# [0.32.0](https://github.com/Alwatr/flux/compare/v0.31.0...v0.32.0) (2023-05-27)

### Bug Fixes

- **context:** compatible with new storage api ([5251ff0](https://github.com/Alwatr/flux/commit/5251ff005624720e091cdbc40e6b0142743428cb))

# [0.31.0](https://github.com/Alwatr/flux/compare/v0.30.0...v0.31.0) (2023-05-08)

### Bug Fixes

- build issues ([e1060bc](https://github.com/Alwatr/flux/commit/e1060bccbfe3c775c32b85e9b8eb601e48b2998c))
- **context:** merge request option issue ([e24e695](https://github.com/Alwatr/flux/commit/e24e695a8c25ab1dcb1c351a3ae0434e921610d0))
- new logger api ([9d83a7d](https://github.com/Alwatr/flux/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
- packages and refs ([eea2382](https://github.com/Alwatr/flux/commit/eea2382e459ccaa3e7b4b329d9c196eda146a08e))

### Features

- **context:** add `requestIfNotComplete` ([580d5c9](https://github.com/Alwatr/flux/commit/580d5c9c74f1c8921b45d402641df9444f438547))
- **context:** awesome server context ([c001c58](https://github.com/Alwatr/flux/commit/c001c58a2b1b4e13fd1c34b5128031fd640a98e1))
- **context:** new package ([98ee43d](https://github.com/Alwatr/flux/commit/98ee43d83b1ad5b3806ec6053c5cac70912000b3))
- **context:** simple context api ([2a1b152](https://github.com/Alwatr/flux/commit/2a1b152380f267a6b173f08bbbe10295325b1fd8))
1 change: 1 addition & 0 deletions packages/fetch-state-machine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @alwatr/fetch-state-machine
13 changes: 13 additions & 0 deletions packages/fetch-state-machine/demo/api-request.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {AlwatrApiRequest} from '@alwatr/server-context';

const apiRequest = new AlwatrApiRequest({
name: 'demo.server-request',
});

apiRequest.request({
url: 'https://order.soffit.co/api/v1/publistore/',
});

apiRequest.subscribe(() => {
console.log('serverRequest: %o', {state: apiRequest.state, response: apiRequest.response});
});
11 changes: 11 additions & 0 deletions packages/fetch-state-machine/demo/server-context.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {AlwatrServerContext} from '@alwatr/server-context';

const serverContext = new AlwatrServerContext({
name: 'demo.server_context',
url: 'https://order.soffit.co/api/v1/publistore/',
});

serverContext.request();
serverContext.subscribe(async function StateChaned() {
console.log('serverContext => result', {state: this.state, context: this.context});
});
13 changes: 13 additions & 0 deletions packages/fetch-state-machine/demo/server-request.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {AlwatrServerRequest} from '@alwatr/server-context';

const serverRequest = new AlwatrServerRequest({
name: 'demo.server-request',
});

serverRequest.request({
url: 'http://httpbin.org/uuid',
});

serverRequest.subscribe(async () => {
console.log('serverRequest: %o', {state: serverRequest.state, response: await serverRequest.response?.text()});
});
73 changes: 73 additions & 0 deletions packages/fetch-state-machine/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "@alwatr/fetch-state-machine",
"version": "1.2.6",
"description": "Elegant powerful context manager base on alwatr signal, written in tiny TypeScript, ES module.",
"author": "S. Ali Mihandoost <[email protected]> (https://ali.mihandoost.com)",
"keywords": [
"context",
"fetch-state-machine",
"signal",
"typescript",
"esm",
"alwatr"
],
"type": "module",
"main": "./dist/main.cjs",
"module": "./dist/main.mjs",
"types": "./dist/main.d.ts",
"exports": {
".": {
"types": "./dist/main.d.ts",
"import": "./dist/main.mjs",
"require": "./dist/main.cjs"
}
},
"license": "MIT",
"files": [
"**/*.{js,mjs,cjs,map,d.ts,html,md}",
"!demo/**/*"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/Alwatr/flux",
"directory": "packages/fetch-state-machine"
},
"homepage": "https://github.com/Alwatr/flux/tree/next/packages/fetch-state-machine#readme",
"bugs": {
"url": "https://github.com/Alwatr/flux/issues"
},
"prettier": "@alwatr/prettier-config",
"scripts": {
"b": "yarn run build",
"t": "yarn run test",
"w": "yarn run watch",
"c": "yarn run clean",
"cb": "yarn run clean && yarn run build",
"d": "yarn run build:es && yarn node --enable-source-maps --trace-warnings",
"build": "yarn run build:ts & yarn run build:es",
"build:es": "nano-build --preset=module",
"build:ts": "tsc --build",
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --enable-source-maps --experimental-vm-modules\" jest",
"watch": "yarn run watch:ts & yarn run watch:es",
"watch:es": "yarn run build:es --watch",
"watch:ts": "yarn run build:ts --watch --preserveWatchOutput",
"clean": "rm -rfv dist *.tsbuildinfo"
},
"dependencies": {
"@alwatr/fetch": "^4.0.0",
"@alwatr/fsm": "workspace:^",
"@alwatr/logger": "^3.2.13"
},
"devDependencies": {
"@alwatr/nano-build": "^1.3.9",
"@alwatr/prettier-config": "^1.0.4",
"@alwatr/tsconfig-base": "^1.2.0",
"@alwatr/type-helper": "^1.2.6",
"@types/node": "^22.5.5",
"jest": "^29.7.0",
"typescript": "^5.6.2"
}
}
Loading

0 comments on commit 676aa0d

Please sign in to comment.