ng2-rest 18.0.19 → 18.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -135
- package/assets/shared/shared_folder_info.txt +1 -1
- package/browser/README.md +24 -24
- package/client/README.md +24 -24
- package/index.js +15 -2
- package/index.js.map +1 -1
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/content-type.js +1 -1
- package/lib/content-type.js.map +1 -1
- package/lib/cookie.js +16 -20
- package/lib/cookie.js.map +1 -1
- package/lib/helpers.js +18 -29
- package/lib/helpers.js.map +1 -1
- package/lib/index._auto-generated_.d.ts +1 -0
- package/lib/index._auto-generated_.js.map +1 -1
- package/lib/index.js +22 -9
- package/lib/index.js.map +1 -1
- package/lib/mapping.js +84 -81
- package/lib/mapping.js.map +1 -1
- package/lib/models.js +144 -181
- package/lib/models.js.map +1 -1
- package/lib/other/simple-resource.js +92 -94
- package/lib/other/simple-resource.js.map +1 -1
- package/lib/params.js +69 -70
- package/lib/params.js.map +1 -1
- package/lib/request-cache.js +37 -41
- package/lib/request-cache.js.map +1 -1
- package/lib/resource-service.js +98 -102
- package/lib/resource-service.js.map +1 -1
- package/lib/rest-headers.js +56 -61
- package/lib/rest-headers.js.map +1 -1
- package/lib/rest-request.js +232 -250
- package/lib/rest-request.js.map +1 -1
- package/lib/rest.class.js +101 -116
- package/lib/rest.class.js.map +1 -1
- package/migrations/index.js +15 -2
- package/migrations/index.js.map +1 -1
- package/migrations/migrations_index._auto-generated_.d.ts +1 -0
- package/migrations/migrations_index._auto-generated_.js.map +1 -1
- package/package.json +19 -73
- package/src.d.ts +1 -1
- package/tmp-environment.json +8 -406
- package/websql/README.md +24 -24
- package/browser/package.json +0 -25
- package/taon.jsonc +0 -52
- package/websql/package.json +0 -25
package/README.md
CHANGED
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
## ng2-rest ##
|
|
3
|
-
|
|
4
|
-
Robust isomorphic REST framework for browser (Angular, React etc.) and backend (NodeJS) JavaScript/TypeScript apps.
|
|
5
|
-
|
|
6
|
-
Features:
|
|
7
|
-
- Compatible with Angular (2+) (newest 13,14 also...) , React, Vue , NodeJS (works everywhere)
|
|
8
|
-
- Compatible with RxJS operators (exhaustMap, switchMap, request cancelation etc.)
|
|
9
|
-
- Based on [axios](https://axios-http.com/) => excellent alternative to Angular's [HttpClient](https://angular.io/api/common/http/HttpClient)
|
|
10
|
-
- JSONP api request handling
|
|
11
|
-
- Transfer class instance from server to client and back
|
|
12
|
-
- Elegant way of dealing with REST api ( *similar to ExpressJS routes definitions* )
|
|
13
|
-
|
|
14
|
-
(more documentation soon... )
|
|
15
|
-
|
|
16
|
-
To install this package run:
|
|
17
|
-
|
|
18
|
-
npm install ng2-rest --save
|
|
19
|
-
|
|
20
|
-
Import Resource class:
|
|
21
|
-
```ts
|
|
22
|
-
import { Resource } from 'ng2-rest/browser';
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Resource
|
|
26
|
-
========
|
|
27
|
-
|
|
28
|
-
Fit you existing API (not only REST) into new fluent objects with **Resource**
|
|
29
|
-
class observables. Use power of **async** in new angular templates;
|
|
30
|
-
|
|
31
|
-
**template.html**
|
|
32
|
-
```html
|
|
33
|
-
Users:
|
|
34
|
-
<ul *ngIf="model.allUsers() | async; else loader; let users" >
|
|
35
|
-
|
|
36
|
-
<li *ngFor="let user of users">
|
|
37
|
-
{{user.id}} {{user.fullName()}}
|
|
38
|
-
<br>
|
|
39
|
-
<input type="name" [(NgModel)]="user.name" >
|
|
40
|
-
<button (click)="model.update(user)" > Update </button>
|
|
41
|
-
</li>
|
|
42
|
-
|
|
43
|
-
</ul>
|
|
44
|
-
|
|
45
|
-
<ng-template #loader> loading users... </ng-template>
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
**component.ts**
|
|
49
|
-
```ts
|
|
50
|
-
class User {
|
|
51
|
-
name: string;
|
|
52
|
-
surname: string;
|
|
53
|
-
id: number;
|
|
54
|
-
|
|
55
|
-
fullName() {
|
|
56
|
-
return `Surname: ${this.surname}, Name: ${this.name}`;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Express.js style url endpoint model
|
|
61
|
-
// you can ommit "<User>" part is you don't wanna see response interface
|
|
62
|
-
// also you can ommit third argument ",User" is you don't wanna
|
|
63
|
-
// map response object to User class objects
|
|
64
|
-
const rest = Resource.create<User>("http://yourbackend.com/api","users/:id",{'':User} )
|
|
65
|
-
|
|
66
|
-
class UserComponent {
|
|
67
|
-
|
|
68
|
-
// Prepare your beautiful interface
|
|
69
|
-
model = {
|
|
70
|
-
allUsers: () => rest.model()
|
|
71
|
-
.array
|
|
72
|
-
.get()
|
|
73
|
-
.observable // Observable resposne (useful for Angular 2+ html templates)
|
|
74
|
-
.pipe( map({ body } => body.json) ) // get all users, body.json => User[]
|
|
75
|
-
|
|
76
|
-
userBy: (id) => rest.model({id})
|
|
77
|
-
.get() // Promise response by default
|
|
78
|
-
.then({ body } => console.log(body.json)) // get user by id, body.json => User
|
|
79
|
-
|
|
80
|
-
update: async (user:User) =>{
|
|
81
|
-
try {
|
|
82
|
-
await rest.model({id:user.id}).put(user) // Promise response by default
|
|
83
|
-
|
|
84
|
-
alert('Update sucess')
|
|
85
|
-
} catch(e) {
|
|
86
|
-
alert(e)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
constructor() { }
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Specification
|
|
97
|
-
============
|
|
98
|
-
Example **UrlParams[]** :
|
|
99
|
-
`[ { sort: true },{ filter: 'id,5' }, { filter: 'name,test' } ]`
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
| Name | Parameters | Description |
|
|
103
|
-
| :---: | --- | ---: |
|
|
104
|
-
| **.array.** | get,post,put,head,delete,jsonp | for everything, but with arrays |
|
|
105
|
-
| **get** | `UrlParams[] ` | get model by parameters |
|
|
106
|
-
| **post** | `model, UrlParams[] ` | post object model |
|
|
107
|
-
| **put** | `model, UrlParams[]` | put object model |
|
|
108
|
-
| **head** | `model, UrlParams[]` | get head for model |
|
|
109
|
-
| **delete** | `UrlParams[]` | remove object by params |
|
|
110
|
-
| **jsonp** | `UrlParams[]` | get jsonp data |
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
# Production mode
|
|
115
|
-
===
|
|
116
|
-
Nice things to do in production mode:
|
|
117
|
-
|
|
118
|
-
**1. Disable warnings.**
|
|
119
|
-
|
|
120
|
-
If you don't wanna see warning, disable it like this:
|
|
121
|
-
```ts
|
|
122
|
-
if (environment.production) {
|
|
123
|
-
Resource.enableWarnings = false;
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
# Angular 2+ ngZone
|
|
128
|
-
If you are using Angular 2+ you need to do this in your root **app.component**:
|
|
129
|
-
```ts
|
|
130
|
-
constructor(zone:NgZone) {
|
|
131
|
-
Resource.initAngularNgZone(zone)
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
|
|
1
|
+
|
|
2
|
+
## ng2-rest ##
|
|
3
|
+
|
|
4
|
+
Robust isomorphic REST framework for browser (Angular, React etc.) and backend (NodeJS) JavaScript/TypeScript apps.
|
|
5
|
+
|
|
6
|
+
Features:
|
|
7
|
+
- Compatible with Angular (2+) (newest 13,14 also...) , React, Vue , NodeJS (works everywhere)
|
|
8
|
+
- Compatible with RxJS operators (exhaustMap, switchMap, request cancelation etc.)
|
|
9
|
+
- Based on [axios](https://axios-http.com/) => excellent alternative to Angular's [HttpClient](https://angular.io/api/common/http/HttpClient)
|
|
10
|
+
- JSONP api request handling
|
|
11
|
+
- Transfer class instance from server to client and back
|
|
12
|
+
- Elegant way of dealing with REST api ( *similar to ExpressJS routes definitions* )
|
|
13
|
+
|
|
14
|
+
(more documentation soon... )
|
|
15
|
+
|
|
16
|
+
To install this package run:
|
|
17
|
+
|
|
18
|
+
npm install ng2-rest --save
|
|
19
|
+
|
|
20
|
+
Import Resource class:
|
|
21
|
+
```ts
|
|
22
|
+
import { Resource } from 'ng2-rest/browser';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Resource
|
|
26
|
+
========
|
|
27
|
+
|
|
28
|
+
Fit you existing API (not only REST) into new fluent objects with **Resource**
|
|
29
|
+
class observables. Use power of **async** in new angular templates;
|
|
30
|
+
|
|
31
|
+
**template.html**
|
|
32
|
+
```html
|
|
33
|
+
Users:
|
|
34
|
+
<ul *ngIf="model.allUsers() | async; else loader; let users" >
|
|
35
|
+
|
|
36
|
+
<li *ngFor="let user of users">
|
|
37
|
+
{{user.id}} {{user.fullName()}}
|
|
38
|
+
<br>
|
|
39
|
+
<input type="name" [(NgModel)]="user.name" >
|
|
40
|
+
<button (click)="model.update(user)" > Update </button>
|
|
41
|
+
</li>
|
|
42
|
+
|
|
43
|
+
</ul>
|
|
44
|
+
|
|
45
|
+
<ng-template #loader> loading users... </ng-template>
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
**component.ts**
|
|
49
|
+
```ts
|
|
50
|
+
class User {
|
|
51
|
+
name: string;
|
|
52
|
+
surname: string;
|
|
53
|
+
id: number;
|
|
54
|
+
|
|
55
|
+
fullName() {
|
|
56
|
+
return `Surname: ${this.surname}, Name: ${this.name}`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Express.js style url endpoint model
|
|
61
|
+
// you can ommit "<User>" part is you don't wanna see response interface
|
|
62
|
+
// also you can ommit third argument ",User" is you don't wanna
|
|
63
|
+
// map response object to User class objects
|
|
64
|
+
const rest = Resource.create<User>("http://yourbackend.com/api","users/:id",{'':User} )
|
|
65
|
+
|
|
66
|
+
class UserComponent {
|
|
67
|
+
|
|
68
|
+
// Prepare your beautiful interface
|
|
69
|
+
model = {
|
|
70
|
+
allUsers: () => rest.model()
|
|
71
|
+
.array
|
|
72
|
+
.get()
|
|
73
|
+
.observable // Observable resposne (useful for Angular 2+ html templates)
|
|
74
|
+
.pipe( map({ body } => body.json) ) // get all users, body.json => User[]
|
|
75
|
+
|
|
76
|
+
userBy: (id) => rest.model({id})
|
|
77
|
+
.get() // Promise response by default
|
|
78
|
+
.then({ body } => console.log(body.json)) // get user by id, body.json => User
|
|
79
|
+
|
|
80
|
+
update: async (user:User) =>{
|
|
81
|
+
try {
|
|
82
|
+
await rest.model({id:user.id}).put(user) // Promise response by default
|
|
83
|
+
|
|
84
|
+
alert('Update sucess')
|
|
85
|
+
} catch(e) {
|
|
86
|
+
alert(e)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
constructor() { }
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Specification
|
|
97
|
+
============
|
|
98
|
+
Example **UrlParams[]** :
|
|
99
|
+
`[ { sort: true },{ filter: 'id,5' }, { filter: 'name,test' } ]`
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
| Name | Parameters | Description |
|
|
103
|
+
| :---: | --- | ---: |
|
|
104
|
+
| **.array.** | get,post,put,head,delete,jsonp | for everything, but with arrays |
|
|
105
|
+
| **get** | `UrlParams[] ` | get model by parameters |
|
|
106
|
+
| **post** | `model, UrlParams[] ` | post object model |
|
|
107
|
+
| **put** | `model, UrlParams[]` | put object model |
|
|
108
|
+
| **head** | `model, UrlParams[]` | get head for model |
|
|
109
|
+
| **delete** | `UrlParams[]` | remove object by params |
|
|
110
|
+
| **jsonp** | `UrlParams[]` | get jsonp data |
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# Production mode
|
|
115
|
+
===
|
|
116
|
+
Nice things to do in production mode:
|
|
117
|
+
|
|
118
|
+
**1. Disable warnings.**
|
|
119
|
+
|
|
120
|
+
If you don't wanna see warning, disable it like this:
|
|
121
|
+
```ts
|
|
122
|
+
if (environment.production) {
|
|
123
|
+
Resource.enableWarnings = false;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
# Angular 2+ ngZone
|
|
128
|
+
If you are using Angular 2+ you need to do this in your root **app.component**:
|
|
129
|
+
```ts
|
|
130
|
+
constructor(zone:NgZone) {
|
|
131
|
+
Resource.initAngularNgZone(zone)
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
THIS FILE IS GENERATED. THIS FILE IS GENERATED. THIS FILE IS GENERATED.
|
|
2
2
|
|
|
3
|
-
Assets from this folder are being shipped with this npm package (ng2-rest@18.0.
|
|
3
|
+
Assets from this folder are being shipped with this npm package (ng2-rest@18.0.20)
|
|
4
4
|
created from this project.
|
|
5
5
|
|
|
6
6
|
THIS FILE IS GENERATED.THIS FILE IS GENERATED. THIS FILE IS GENERATED.
|
package/browser/README.md
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# MyLib
|
|
2
|
-
|
|
3
|
-
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.0.
|
|
4
|
-
|
|
5
|
-
## Code scaffolding
|
|
6
|
-
|
|
7
|
-
Run `ng generate component component-name --project my-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project my-lib`.
|
|
8
|
-
> Note: Don't forget to add `--project my-lib` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
-
|
|
10
|
-
## Build
|
|
11
|
-
|
|
12
|
-
Run `ng build my-lib` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
-
|
|
14
|
-
## Publishing
|
|
15
|
-
|
|
16
|
-
After building your library with `ng build my-lib`, go to the dist folder `cd dist/my-lib` and run `npm publish`.
|
|
17
|
-
|
|
18
|
-
## Running unit tests
|
|
19
|
-
|
|
20
|
-
Run `ng test my-lib` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
-
|
|
22
|
-
## Further help
|
|
23
|
-
|
|
24
|
-
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
|
1
|
+
# MyLib
|
|
2
|
+
|
|
3
|
+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Run `ng generate component component-name --project my-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project my-lib`.
|
|
8
|
+
> Note: Don't forget to add `--project my-lib` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
+
|
|
10
|
+
## Build
|
|
11
|
+
|
|
12
|
+
Run `ng build my-lib` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
+
|
|
14
|
+
## Publishing
|
|
15
|
+
|
|
16
|
+
After building your library with `ng build my-lib`, go to the dist folder `cd dist/my-lib` and run `npm publish`.
|
|
17
|
+
|
|
18
|
+
## Running unit tests
|
|
19
|
+
|
|
20
|
+
Run `ng test my-lib` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
+
|
|
22
|
+
## Further help
|
|
23
|
+
|
|
24
|
+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
package/client/README.md
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# MyLib
|
|
2
|
-
|
|
3
|
-
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.0.
|
|
4
|
-
|
|
5
|
-
## Code scaffolding
|
|
6
|
-
|
|
7
|
-
Run `ng generate component component-name --project my-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project my-lib`.
|
|
8
|
-
> Note: Don't forget to add `--project my-lib` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
-
|
|
10
|
-
## Build
|
|
11
|
-
|
|
12
|
-
Run `ng build my-lib` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
-
|
|
14
|
-
## Publishing
|
|
15
|
-
|
|
16
|
-
After building your library with `ng build my-lib`, go to the dist folder `cd dist/my-lib` and run `npm publish`.
|
|
17
|
-
|
|
18
|
-
## Running unit tests
|
|
19
|
-
|
|
20
|
-
Run `ng test my-lib` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
-
|
|
22
|
-
## Further help
|
|
23
|
-
|
|
24
|
-
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
|
1
|
+
# MyLib
|
|
2
|
+
|
|
3
|
+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Run `ng generate component component-name --project my-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project my-lib`.
|
|
8
|
+
> Note: Don't forget to add `--project my-lib` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
+
|
|
10
|
+
## Build
|
|
11
|
+
|
|
12
|
+
Run `ng build my-lib` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
+
|
|
14
|
+
## Publishing
|
|
15
|
+
|
|
16
|
+
After building your library with `ng build my-lib`, go to the dist folder `cd dist/my-lib` and run `npm publish`.
|
|
17
|
+
|
|
18
|
+
## Running unit tests
|
|
19
|
+
|
|
20
|
+
Run `ng test my-lib` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
+
|
|
22
|
+
## Further help
|
|
23
|
+
|
|
24
|
+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
package/index.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./lib"), exports);
|
|
17
|
+
__exportStar(require("./lib"), exports);
|
|
5
18
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":[""],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["/Users/dfilipiak/projects/npm/taon-dev/ng2-rest/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-info._auto-generated_.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AACa,QAAA,wBAAwB,GAAG,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"build-info._auto-generated_.js","sourceRoot":"","sources":["/Users/dfilipiak/projects/npm/taon-dev/ng2-rest/src/lib/build-info._auto-generated_.ts"],"names":[],"mappings":";;;AACa,QAAA,wBAAwB,GAAG,KAAK,CAAC"}
|
package/lib/content-type.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CONTENT_TYPE = void 0;
|
|
4
|
-
|
|
4
|
+
const rest_headers_1 = require("./rest-headers");
|
|
5
5
|
exports.CONTENT_TYPE = {
|
|
6
6
|
APPLICATION_JSON: rest_headers_1.RestHeaders.from({
|
|
7
7
|
'Content-Type': 'application/json',
|
package/lib/content-type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-type.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"content-type.js","sourceRoot":"","sources":["/Users/dfilipiak/projects/npm/taon-dev/ng2-rest/src/lib/content-type.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAGhC,QAAA,YAAY,GAAG;IAC1B,gBAAgB,EAAE,0BAAW,CAAC,IAAI,CAAC;QACjC,cAAc,EAAE,kBAAkB;QAClC,QAAQ,EAAE,kBAAkB;KAC7B,CAAC;IACF,wBAAwB,EAAE,0BAAW,CAAC,IAAI,CAAC;QACzC,cAAc,EAAE,0BAA0B;QAC1C,QAAQ,EAAE,0BAA0B;KACrC,CAAC;CACH,CAAA"}
|
package/lib/cookie.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Cookie = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class Cookie {
|
|
5
|
+
static get Instance() {
|
|
6
|
+
if (!Cookie.__instance) {
|
|
7
|
+
Cookie.__instance = new Cookie();
|
|
8
|
+
}
|
|
9
|
+
return Cookie.__instance;
|
|
10
|
+
}
|
|
11
|
+
static __instance;
|
|
12
|
+
constructor() {
|
|
6
13
|
}
|
|
7
|
-
|
|
8
|
-
get: function () {
|
|
9
|
-
if (!Cookie.__instance) {
|
|
10
|
-
Cookie.__instance = new Cookie();
|
|
11
|
-
}
|
|
12
|
-
return Cookie.__instance;
|
|
13
|
-
},
|
|
14
|
-
enumerable: false,
|
|
15
|
-
configurable: true
|
|
16
|
-
});
|
|
17
|
-
Cookie.prototype.read = function (name) {
|
|
14
|
+
read(name) {
|
|
18
15
|
var result = new RegExp('(?:^|; )' + encodeURIComponent(name) + '=([^;]*)').exec(document.cookie);
|
|
19
16
|
return result ? result[1] : null;
|
|
20
|
-
}
|
|
21
|
-
|
|
17
|
+
}
|
|
18
|
+
write(name, value, days) {
|
|
22
19
|
if (!days) {
|
|
23
20
|
days = 365 * 20;
|
|
24
21
|
}
|
|
@@ -26,11 +23,10 @@ var Cookie = /** @class */ (function () {
|
|
|
26
23
|
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
27
24
|
var expires = "; expires=" + date.toUTCString();
|
|
28
25
|
document.cookie = name + "=" + value + expires + "; path=/";
|
|
29
|
-
}
|
|
30
|
-
|
|
26
|
+
}
|
|
27
|
+
remove(name) {
|
|
31
28
|
this.write(name, "", -1);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
35
31
|
exports.Cookie = Cookie;
|
|
36
32
|
//# sourceMappingURL=cookie.js.map
|
package/lib/cookie.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"cookie.js","sourceRoot":"","sources":["/Users/dfilipiak/projects/npm/taon-dev/ng2-rest/src/lib/cookie.ts"],"names":[],"mappings":";;;AAAA,MAAa,MAAM;IAER,MAAM,KAAK,QAAQ;QACtB,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,CAAC,UAAU,GAAG,IAAI,MAAM,EAAE,CAAC;QACrC,CAAC;QACD,OAAO,MAAM,CAAC,UAAiB,CAAC;IACpC,CAAC;IACO,MAAM,CAAC,UAAU,CAAC;IAE1B;IACA,CAAC;IAED,IAAI,CAAC,IAAY;QACb,IAAI,MAAM,GAAG,IAAI,MAAM,CAAC,UAAU,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAClG,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,IAAY,EAAE,KAAa,EAAE,IAAa;QAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;QACpB,CAAC;QAED,IAAI,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;QAE5D,IAAI,OAAO,GAAG,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEhD,QAAQ,CAAC,MAAM,GAAG,IAAI,GAAG,GAAG,GAAG,KAAK,GAAG,OAAO,GAAG,UAAU,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,IAAY;QACf,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;CAEJ;AAnCD,wBAmCC"}
|
package/lib/helpers.js
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Helpers = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var json10_1 = require("json10");
|
|
4
|
+
const tnp_core_1 = require("tnp-core");
|
|
5
|
+
const mapping_1 = require("./mapping");
|
|
6
|
+
const json10_1 = require("json10");
|
|
8
7
|
// @ts-ignore
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
8
|
+
class Helpers extends tnp_core_1.CoreHelpers {
|
|
9
|
+
static JSON = json10_1.JSON10;
|
|
10
|
+
static get Mapping() {
|
|
11
|
+
return {
|
|
12
|
+
encode(json, mapping) {
|
|
13
|
+
return mapping_1.Mapping.encode(json, mapping);
|
|
14
|
+
},
|
|
15
|
+
decode(json, autodetect = false) {
|
|
16
|
+
return mapping_1.Mapping.decode(json, autodetect);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
13
19
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
encode: function (json, mapping) {
|
|
18
|
-
return mapping_1.Mapping.encode(json, mapping);
|
|
19
|
-
},
|
|
20
|
-
decode: function (json, autodetect) {
|
|
21
|
-
if (autodetect === void 0) { autodetect = false; }
|
|
22
|
-
return mapping_1.Mapping.decode(json, autodetect);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
enumerable: false,
|
|
27
|
-
configurable: true
|
|
28
|
-
});
|
|
29
|
-
Helpers.checkValidUrl = function (url) {
|
|
30
|
-
var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/;
|
|
20
|
+
static checkValidUrl(url) {
|
|
21
|
+
let regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/;
|
|
31
22
|
return regex.test(url);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return Helpers;
|
|
35
|
-
}(tnp_core_1.CoreHelpers));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
36
25
|
exports.Helpers = Helpers;
|
|
37
26
|
//# sourceMappingURL=helpers.js.map
|
package/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":[""],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["/Users/dfilipiak/projects/npm/taon-dev/ng2-rest/src/lib/helpers.ts"],"names":[],"mappings":";;;AACA,uCAAuC;AACvC,uCAAoC;AACpC,mCAAgC;AAEhC,aAAa;AACb,MAAa,OAAQ,SAAQ,sBAAW;IAEtC,MAAM,CAAC,IAAI,GAAG,eAAM,CAAC;IAErB,MAAM,KAAK,OAAO;QAChB,OAAO;YACL,MAAM,CAAe,IAAY,EAAE,OAAwB;gBACzD,OAAO,iBAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACvC,CAAC;YACD,MAAM,CAAC,IAAY,EAAE,UAAU,GAAG,KAAK;gBACrC,OAAO,iBAAO,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;YACzC,CAAC;SACF,CAAA;IACH,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,GAAW;QAC9B,IAAI,KAAK,GAAG,6EAA6E,CAAC;QAC1F,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;;AAlBH,0BAsBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index._auto-generated_.js","sourceRoot":"","sources":[""],"names":[],"mappings":"AAAA,cAAc;AACd,8CAA8C;AAC9C,2BAA2B;AAC3B,uDAAuD;AACvD,2CAA2C"}
|
|
1
|
+
{"version":3,"file":"index._auto-generated_.js","sourceRoot":"","sources":["/Users/dfilipiak/projects/npm/taon-dev/ng2-rest/src/lib/index._auto-generated_.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,8CAA8C;AAC9C,2BAA2B;AAC3B,uDAAuD;AACvD,2CAA2C"}
|
package/lib/index.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.interpolateParamsToUrl = exports.SimpleResource = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
tslib_1.__exportStar(require("./content-type"), exports);
|
|
18
|
+
__exportStar(require("./resource-service"), exports);
|
|
19
|
+
__exportStar(require("./models"), exports);
|
|
20
|
+
__exportStar(require("./mapping"), exports);
|
|
21
|
+
__exportStar(require("./rest.class"), exports);
|
|
22
|
+
__exportStar(require("./rest-headers"), exports);
|
|
23
|
+
__exportStar(require("./helpers"), exports);
|
|
24
|
+
__exportStar(require("./request-cache"), exports);
|
|
25
|
+
__exportStar(require("./content-type"), exports);
|
|
13
26
|
var simple_resource_1 = require("./other/simple-resource");
|
|
14
27
|
Object.defineProperty(exports, "SimpleResource", { enumerable: true, get: function () { return simple_resource_1.SimpleResource; } });
|
|
15
28
|
var params_1 = require("./params");
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":[""],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["/Users/dfilipiak/projects/npm/taon-dev/ng2-rest/src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,2CAAyB;AACzB,4CAA0B;AAC1B,+CAA6B;AAC7B,iDAA+B;AAC/B,4CAA0B;AAC1B,kDAAgC;AAChC,iDAA+B;AAC/B,2DAAyD;AAAhD,iHAAA,cAAc,OAAA;AACvB,mCAAkD;AAAzC,gHAAA,sBAAsB,OAAA"}
|