Skip to content

Commit

Permalink
feat: request-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Nov 18, 2022
1 parent af8f5a1 commit d7b6d01
Show file tree
Hide file tree
Showing 24 changed files with 1,845 additions and 217 deletions.
11 changes: 11 additions & 0 deletions packages/experimental-preview-types/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
The MIT License (MIT)

Copyright (C) 2017-2022 Ember.js contributors
Portions Copyright (C) 2011-2017 Tilde, Inc. and contributors.
Portions Copyright (C) 2011 LivingSocial Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6 changes: 6 additions & 0 deletions packages/experimental-preview-types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@ember-data/experimental-preview-types
============================================================================

Unstable experimental typescript declarations for [*Ember***Data**](https://github.com/emberjs/data/)

Consumers of this package should expect a high degree of churn in the types involved.
33 changes: 33 additions & 0 deletions packages/experimental-preview-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@ember-data/experimental-preview-types",
"description": "Unstable experimental typescript declarations for EmberData",
"version": "4.9.0-alpha.14",
"private": false,
"license": "MIT",
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com:emberjs/data.git",
"directory": "packages/experimental-preview-types"
},
"homepage": "https://github.com/emberjs/data",
"bugs": "https://github.com/emberjs/data/issues",
"engines": {
"node": "14.* || 16.* || >= 18"
},
"keywords": ["ember-addon"],
"volta": {
"extends": "../../package.json"
},
"dependencies": {},
"exports": {
".": "./src/index.ts",
"./*": "./src/*"
},
"files": [
"src"
],
"scripts": {},
"peerDependencies": {},
"devDependencies": {}
}
31 changes: 31 additions & 0 deletions packages/experimental-preview-types/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Addon } from '@embroider/addon-dev/rollup';
import babel from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';

const addon = new Addon({
srcDir: 'src',
destDir: 'dist',
});

export default {
// This provides defaults that work well alongside `publicEntrypoints` below.
// You can augment this if you need to.
output: addon.output(),

external: [],

plugins: [
// These are the modules that users should be able to import from your
// addon. Anything not listed here may get optimized away.
addon.publicEntrypoints(['index.js', '-private.js']),

nodeResolve({ extensions: ['.ts'] }),
babel({
extensions: ['.ts'],
babelHelpers: 'runtime', // we should consider "external",
}),

// Remove leftover build artifacts when starting a new build.
addon.clean(),
],
};
Empty file.
3 changes: 3 additions & 0 deletions packages/experimental-preview-types/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
* Experimental Preview Types
*/
11 changes: 11 additions & 0 deletions packages/request/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
The MIT License (MIT)

Copyright (C) 2017-2022 Ember.js contributors
Portions Copyright (C) 2011-2017 Tilde, Inc. and contributors.
Portions Copyright (C) 2011 LivingSocial Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 changes: 41 additions & 0 deletions packages/request/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<p align="center">
<img
class="project-logo"
src="./ember-data-logo-dark.svg#gh-dark-mode-only"
alt="EmberData RequestManager"
width="240px"
title="EmberData RequestManager"
/>
<img
class="project-logo"
src="./ember-data-logo-light.svg#gh-light-mode-only"
alt="EmberData RequestManager"
width="240px"
title="EmberData RequestManager"
/>
</p>

<p align="center">⚡️ a simple abstraction over [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) to enable easy management of request/response flows</p>

This package provides [*Ember***Data**](https://github.com/emberjs/data/)'s `RequestManager`, a standalone library that can be integrated with any Javascript application to make fetch happen.

### How It Fits

```mermaid
flowchart LR
A[App] <--> B(RequestManager)
B <--> C(Source)
A <--> D{Store}
D <--> E(Cache)
D <--> B
```

## Usage

A `RequestManager` provides a request/response flow in which configured handlers are successively given the opportunity to handle, modify, or pass-along a request.

```ts
interface RequestManager {
async request<T>(req: RequestInfo): Future<T>;
}
```
34 changes: 34 additions & 0 deletions packages/request/addon-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const path = require('path');

const Funnel = require('broccoli-funnel');

module.exports = {
name: require('./package.json').name,

options: {
babel: {
plugins: [require.resolve('./lib/transform-ext.js')],
},
},

treeForAddon() {
const assetDir = path.join(__dirname, './dist');
return this._super.treeForAddon.call(this, new Funnel(assetDir, { include: ['**/*.js'] }));
},

treeForVendor() {
return;
},
treeForPublic() {
return;
},
treeForStyles() {
return;
},
treeForAddonStyles() {
return;
},
treeForApp() {
return;
},
};
8 changes: 8 additions & 0 deletions packages/request/babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": [
"@babel/plugin-transform-runtime",
["@babel/plugin-transform-typescript", { "allowDeclareFields": true }],
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-class-properties"
]
}
12 changes: 12 additions & 0 deletions packages/request/ember-data-logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d7b6d01

Please sign in to comment.