ng2-rest 21.0.59 → 21.0.60

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.
Files changed (47) hide show
  1. package/README.md +131 -131
  2. package/VERIFIED-BUILD-DATA.jsonc +3 -3
  3. package/bin/ng2-rest +0 -0
  4. package/bin/ng2-rest-debug +0 -0
  5. package/bin/ng2-rest-debug-brk +0 -0
  6. package/bin/start.js +36 -36
  7. package/browser/README.md +24 -24
  8. package/browser/fesm2022/ng2-rest-browser.mjs +36 -66
  9. package/browser/fesm2022/ng2-rest-browser.mjs.map +1 -1
  10. package/browser/package.json +1 -1
  11. package/browser-prod/README.md +24 -24
  12. package/browser-prod/fesm2022/ng2-rest-browser-prod.mjs +36 -66
  13. package/browser-prod/fesm2022/ng2-rest-browser-prod.mjs.map +1 -1
  14. package/browser-prod/package.json +1 -1
  15. package/lib/build-info._auto-generated_.d.ts +1 -1
  16. package/lib/build-info._auto-generated_.js +1 -1
  17. package/lib/ng2-rest.d.ts +2 -2
  18. package/lib/ng2-rest.js +33 -66
  19. package/lib/ng2-rest.js.map +1 -1
  20. package/lib/package.json +1 -1
  21. package/lib-esm/app.electron.js +0 -81
  22. package/lib-esm/app.electron.js.map +1 -1
  23. package/lib-esm/app.hosts.d.ts +0 -3
  24. package/lib-esm/app.hosts.js +0 -52
  25. package/lib-esm/app.hosts.js.map +1 -1
  26. package/lib-esm/app.js +0 -317
  27. package/lib-esm/app.js.map +1 -1
  28. package/lib-esm/app.vscode.js +0 -46
  29. package/lib-esm/app.vscode.js.map +1 -1
  30. package/lib-esm/lib/build-info._auto-generated_.d.ts +1 -1
  31. package/lib-esm/lib/build-info._auto-generated_.js +1 -1
  32. package/lib-esm/lib/ng2-rest.js +31 -66
  33. package/lib-esm/lib/ng2-rest.js.map +1 -1
  34. package/lib-prod/build-info._auto-generated_.d.ts +1 -1
  35. package/lib-prod/build-info._auto-generated_.js +1 -1
  36. package/lib-prod/ng2-rest.js +33 -66
  37. package/lib-prod/ng2-rest.js.map +1 -1
  38. package/lib-prod/package.json +1 -1
  39. package/package.json +1 -1
  40. package/websql/README.md +24 -24
  41. package/websql/fesm2022/ng2-rest-websql.mjs +36 -66
  42. package/websql/fesm2022/ng2-rest-websql.mjs.map +1 -1
  43. package/websql/package.json +1 -1
  44. package/websql-prod/README.md +24 -24
  45. package/websql-prod/fesm2022/ng2-rest-websql-prod.mjs +36 -66
  46. package/websql-prod/fesm2022/ng2-rest-websql-prod.mjs.map +1 -1
  47. package/websql-prod/package.json +1 -1
package/README.md CHANGED
@@ -1,131 +1,131 @@
1
-
2
- ## ng2-rest ##
3
-
4
- Robust isomorphic REST framework
5
- - for browser (Angular, React etc.)
6
- - for backend Taon apps/libs (NodeJS/TypeScript)
7
- (part of [taon.dev](https://github.com/darekf77/taon)).
8
-
9
- Features:
10
- - Compatible with Angular (2+) (newest 13,14 also...) , React, Vue , NodeJS (works everywhere)
11
- - Compatible with RxJS operators (exhaustMap, switchMap, request cancelation etc.)
12
- - Based on [axios](https://axios-http.com/) => excellent alternative to Angular's [HttpClient](https://angular.io/api/common/http/HttpClient)
13
- - JSONP api request handling
14
- - Transfer class instance from server to client and back
15
- - Elegant way of dealing with REST api ( *similar to ExpressJS routes definitions* )
16
-
17
- (more documentation soon... )
18
-
19
- To install this package run:
20
-
21
- npm install ng2-rest --save
22
-
23
- Import Resource class:
24
- ```ts
25
- import { Resource } from 'ng2-rest/browser';
26
- ```
27
-
28
- Resource
29
- ========
30
-
31
- Fit you existing API (not only REST) into new fluent objects with **Resource**
32
- class observables. Use power of **async** in new angular templates;
33
-
34
- **template.html**
35
- ```html
36
- Users:
37
- <ul *ngIf="model.allUsers() | async; else loader; let users" >
38
-
39
- <li *ngFor="let user of users">
40
- {{user.id}} {{user.fullName()}}
41
- <br>
42
- <input type="name" [(NgModel)]="user.name" >
43
- <button (click)="model.update(user)" > Update </button>
44
- </li>
45
-
46
- </ul>
47
-
48
- <ng-template #loader> loading users... </ng-template>
49
-
50
- ```
51
- **component.ts**
52
- ```ts
53
- class User {
54
- name: string;
55
- surname: string;
56
- id: number;
57
-
58
- fullName() {
59
- return `Surname: ${this.surname}, Name: ${this.name}`;
60
- }
61
- }
62
-
63
- // Express.js style url endpoint model
64
- // you can ommit "<User>" part is you don't wanna see response interface
65
- // also you can ommit third argument ",User" is you don't wanna
66
- // map response object to User class objects
67
- const rest = Resource.create<User>("http://yourbackend.com/api","users/:id",{'':User} )
68
-
69
- class UserComponent {
70
-
71
- // Prepare your beautiful interface
72
- model = {
73
- allUsers: () => rest.model()
74
- .array
75
- .get()
76
- .observable // Observable resposnse (useful for Angular 2+ html templates)
77
- .pipe( map({ body } => body.json) ) // get all users, body.json => User[]
78
-
79
- userBy: (id) => rest.model({id})
80
- .get() // Promise response by default
81
- .then({ body } => console.log(body.json)) // get user by id, body.json => User
82
-
83
- update: async (user:User) =>{
84
- try {
85
- await rest.model({id:user.id}).put(user) // Promise response by default
86
-
87
- alert('Update sucess')
88
- } catch(e) {
89
- alert(e)
90
- }
91
- }
92
- }
93
-
94
- constructor() { }
95
-
96
- }
97
- ```
98
-
99
- Specification
100
- ============
101
- Example **UrlParams[]** :
102
- `[ { sort: true },{ filter: 'id,5' }, { filter: 'name,test' } ]`
103
-
104
-
105
- | Name | Parameters | Description |
106
- | :---: | --- | ---: |
107
- | **array** | changes response type to array |
108
- | **get** | `model, UrlParams[] ` | get data |
109
- | **post** | `model, UrlParams[] ` | create data |
110
- | **patch** | `model, UrlParams[] ` | change data <br>(effect of changing data may be diffrent with each request) |
111
- | **put** | `model, UrlParams[]` | change data <br>(can be done multiple times with same effect) |
112
- | **head** | `model, UrlParams[]` | check data |
113
- | **delete** | `model, UrlParams[] ` | remove data |
114
- | **jsonp** | `model, UrlParams[] ` | get jsonp data |
115
-
116
-
117
-
118
- # Production mode
119
- ===
120
- Nice things to do in production mode:
121
-
122
- **1. Disable warnings.**
123
-
124
- If you don't wanna see warning, disable it like this:
125
- ```ts
126
- if (environment.production) {
127
- Resource.enableWarnings = false;
128
- }
129
- ```
130
-
131
-
1
+
2
+ ## ng2-rest ##
3
+
4
+ Robust isomorphic REST framework
5
+ - for browser (Angular, React etc.)
6
+ - for backend Taon apps/libs (NodeJS/TypeScript)
7
+ (part of [taon.dev](https://github.com/darekf77/taon)).
8
+
9
+ Features:
10
+ - Compatible with Angular (2+) (newest 13,14 also...) , React, Vue , NodeJS (works everywhere)
11
+ - Compatible with RxJS operators (exhaustMap, switchMap, request cancelation etc.)
12
+ - Based on [axios](https://axios-http.com/) => excellent alternative to Angular's [HttpClient](https://angular.io/api/common/http/HttpClient)
13
+ - JSONP api request handling
14
+ - Transfer class instance from server to client and back
15
+ - Elegant way of dealing with REST api ( *similar to ExpressJS routes definitions* )
16
+
17
+ (more documentation soon... )
18
+
19
+ To install this package run:
20
+
21
+ npm install ng2-rest --save
22
+
23
+ Import Resource class:
24
+ ```ts
25
+ import { Resource } from 'ng2-rest/browser';
26
+ ```
27
+
28
+ Resource
29
+ ========
30
+
31
+ Fit you existing API (not only REST) into new fluent objects with **Resource**
32
+ class observables. Use power of **async** in new angular templates;
33
+
34
+ **template.html**
35
+ ```html
36
+ Users:
37
+ <ul *ngIf="model.allUsers() | async; else loader; let users" >
38
+
39
+ <li *ngFor="let user of users">
40
+ {{user.id}} {{user.fullName()}}
41
+ <br>
42
+ <input type="name" [(NgModel)]="user.name" >
43
+ <button (click)="model.update(user)" > Update </button>
44
+ </li>
45
+
46
+ </ul>
47
+
48
+ <ng-template #loader> loading users... </ng-template>
49
+
50
+ ```
51
+ **component.ts**
52
+ ```ts
53
+ class User {
54
+ name: string;
55
+ surname: string;
56
+ id: number;
57
+
58
+ fullName() {
59
+ return `Surname: ${this.surname}, Name: ${this.name}`;
60
+ }
61
+ }
62
+
63
+ // Express.js style url endpoint model
64
+ // you can ommit "<User>" part is you don't wanna see response interface
65
+ // also you can ommit third argument ",User" is you don't wanna
66
+ // map response object to User class objects
67
+ const rest = Resource.create<User>("http://yourbackend.com/api","users/:id",{'':User} )
68
+
69
+ class UserComponent {
70
+
71
+ // Prepare your beautiful interface
72
+ model = {
73
+ allUsers: () => rest.model()
74
+ .array
75
+ .get()
76
+ .observable // Observable resposnse (useful for Angular 2+ html templates)
77
+ .pipe( map({ body } => body.json) ) // get all users, body.json => User[]
78
+
79
+ userBy: (id) => rest.model({id})
80
+ .get() // Promise response by default
81
+ .then({ body } => console.log(body.json)) // get user by id, body.json => User
82
+
83
+ update: async (user:User) =>{
84
+ try {
85
+ await rest.model({id:user.id}).put(user) // Promise response by default
86
+
87
+ alert('Update sucess')
88
+ } catch(e) {
89
+ alert(e)
90
+ }
91
+ }
92
+ }
93
+
94
+ constructor() { }
95
+
96
+ }
97
+ ```
98
+
99
+ Specification
100
+ ============
101
+ Example **UrlParams[]** :
102
+ `[ { sort: true },{ filter: 'id,5' }, { filter: 'name,test' } ]`
103
+
104
+
105
+ | Name | Parameters | Description |
106
+ | :---: | --- | ---: |
107
+ | **array** | changes response type to array |
108
+ | **get** | `model, UrlParams[] ` | get data |
109
+ | **post** | `model, UrlParams[] ` | create data |
110
+ | **patch** | `model, UrlParams[] ` | change data <br>(effect of changing data may be diffrent with each request) |
111
+ | **put** | `model, UrlParams[]` | change data <br>(can be done multiple times with same effect) |
112
+ | **head** | `model, UrlParams[]` | check data |
113
+ | **delete** | `model, UrlParams[] ` | remove data |
114
+ | **jsonp** | `model, UrlParams[] ` | get jsonp data |
115
+
116
+
117
+
118
+ # Production mode
119
+ ===
120
+ Nice things to do in production mode:
121
+
122
+ **1. Disable warnings.**
123
+
124
+ If you don't wanna see warning, disable it like this:
125
+ ```ts
126
+ if (environment.production) {
127
+ Resource.enableWarnings = false;
128
+ }
129
+ ```
130
+
131
+
@@ -1,5 +1,5 @@
1
1
  {
2
- "commitHash": "9d17ebc4f90a7206e700d0114d220107d6e6f7ea",
3
- "commitName": "release: v21.0.58",
4
- "commitDate": "06-08-2026 18:20:57"
2
+ "commitHash": "ebecda45d758f404c3327b3d8a817a59cd9cf31d",
3
+ "commitName": "feat: apply axios cookie jar when node using credentials",
4
+ "commitDate": "03-09-2026 11:48:44"
5
5
  }
package/bin/ng2-rest CHANGED
File without changes
File without changes
File without changes
package/bin/start.js CHANGED
@@ -1,38 +1,38 @@
1
1
  global.frameworkName = 'ng2-rest';
2
- Error.stackTraceLimit = 100;
3
- global.i0 = {
4
- defineInjectable: function () { }
5
- }
6
- const process= require('process');
7
- global.currentTaonScriptStartDateTime = process.hrtime.bigint();
8
-
9
- process.removeAllListeners('warning');
10
- var argv = process.argv;
11
-
12
- global.hideLog = true;
13
- global.verboseLevel = 0;
14
- var verboseLevel = argv.find(a => a.startsWith('-verbose='));
15
- if (typeof verboseLevel !== 'undefined') {
16
- global.hideLog = false;
17
- verboseLevel = Number(verboseLevel.replace('-verbose=', ''));
18
- if (!isNaN(verboseLevel)) {
19
- global.verboseLevel = verboseLevel;
20
- }
21
- argv = argv.filter(a => !a.startsWith('-verbose='));
22
- }
23
-
24
- if (argv.includes('-verbose')) {
25
- global.hideLog = false;
26
- argv = argv.filter(a => a !== '-verbose');
27
- }
28
-
29
- const fs = require('fs');
30
- const path = require('path');
31
- var pathToCliJS = {
32
- distDev: path.join(__dirname, '../dist/cli.js'),
33
- localOrNPm: path.join(__dirname, '../cli.js')
34
- }
35
- var p = fs.existsSync(pathToCliJS.distDev) ? pathToCliJS.distDev : pathToCliJS.localOrNPm;
36
- global.globalSystemToolMode = true;
37
- var run = require(p).startCli;
2
+ Error.stackTraceLimit = 100;
3
+ global.i0 = {
4
+ defineInjectable: function () { }
5
+ }
6
+ const process= require('process');
7
+ global.currentTaonScriptStartDateTime = process.hrtime.bigint();
8
+
9
+ process.removeAllListeners('warning');
10
+ var argv = process.argv;
11
+
12
+ global.hideLog = true;
13
+ global.verboseLevel = 0;
14
+ var verboseLevel = argv.find(a => a.startsWith('-verbose='));
15
+ if (typeof verboseLevel !== 'undefined') {
16
+ global.hideLog = false;
17
+ verboseLevel = Number(verboseLevel.replace('-verbose=', ''));
18
+ if (!isNaN(verboseLevel)) {
19
+ global.verboseLevel = verboseLevel;
20
+ }
21
+ argv = argv.filter(a => !a.startsWith('-verbose='));
22
+ }
23
+
24
+ if (argv.includes('-verbose')) {
25
+ global.hideLog = false;
26
+ argv = argv.filter(a => a !== '-verbose');
27
+ }
28
+
29
+ const fs = require('fs');
30
+ const path = require('path');
31
+ var pathToCliJS = {
32
+ distDev: path.join(__dirname, '../dist/cli.js'),
33
+ localOrNPm: path.join(__dirname, '../cli.js')
34
+ }
35
+ var p = fs.existsSync(pathToCliJS.distDev) ? pathToCliJS.distDev : pathToCliJS.localOrNPm;
36
+ global.globalSystemToolMode = true;
37
+ var run = require(p).startCli;
38
38
  run(argv,__filename);
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.
@@ -322,72 +322,37 @@ var _a;
322
322
  //#endregion
323
323
  const log = Log.create('ng2-rest', Level.WARN, Level.ERROR);
324
324
  const listenErrorsSrc = new Subject();
325
- //#region cookie
326
- // TODO do it for nodejs
327
- // import { CookieJar } from 'tough-cookie';
328
- // const jar = new CookieJar();
329
- // const rest = Resource.create('http://my-website.pl', 'api/v3/user/:userId', {
330
- // cookieJar: jar,
331
- // });
332
- // await rest.model({ userId: 1 }).get(); // cookies persist across requests
333
- // import type { CookieJar } from 'tough-cookie';
334
- // interface ResourceOptions {
335
- // // ...
336
- // cookieJar?: CookieJar;
337
- // }
338
- // export class CookieJarInterceptor implements TaonAxiosClientInterceptor<any> {
339
- // constructor(private readonly jar: CookieJar) {}
340
- // intercept({ req, next }: TaonClientMiddlewareInterceptOptions<any>) {
341
- // return new Observable<AxiosResponse<any>>(subscriber => {
342
- // const url = req.url || '';
343
- // // 1) attach Cookie header from jar
344
- // this.jar.getCookieString(url, (err, cookieString) => {
345
- // if (err) {
346
- // subscriber.error(err);
347
- // return;
348
- // }
349
- // if (cookieString) {
350
- // req.headers = req.headers || {};
351
- // // axios headers can be plain object or AxiosHeaders
352
- // if (req.headers instanceof AxiosHeaders) {
353
- // req.headers.set('Cookie', cookieString);
354
- // } else {
355
- // (req.headers as any)['Cookie'] = cookieString;
356
- // }
357
- // }
358
- // // 2) proceed
359
- // const sub = next.handle(req).subscribe({
360
- // next: res => {
361
- // // 3) store Set-Cookie back into jar
362
- // const setCookie = (res.headers as any)?.['set-cookie'];
363
- // const cookies: string[] =
364
- // typeof setCookie === 'string'
365
- // ? [setCookie]
366
- // : Array.isArray(setCookie)
367
- // ? setCookie
368
- // : [];
369
- // if (!cookies.length) {
370
- // subscriber.next(res);
371
- // return;
372
- // }
373
- // let pending = cookies.length;
374
- // for (const c of cookies) {
375
- // this.jar.setCookie(c, url, () => {
376
- // pending--;
377
- // if (pending === 0) {
378
- // subscriber.next(res);
379
- // }
380
- // });
381
- // }
382
- // },
383
- // error: e => subscriber.error(e),
384
- // complete: () => subscriber.complete(),
385
- // });
386
- // return () => sub.unsubscribe();
387
- // });
388
- // });
389
- // }
390
- // }
325
+ //#region cookie jar
326
+ /* */
327
+ /* */
328
+ /* */
329
+ /* */
330
+ /* */
331
+ /* */
332
+ /* */
333
+ /* */
334
+ /* */
335
+ /* */
336
+ /* */
337
+ /* */
338
+ /* */
339
+ /* */
340
+ /* */
341
+ /* */
342
+ /* */
343
+ /* */
344
+ /* */
345
+ /* */
346
+ /* */
347
+ /* */
348
+ /* */
349
+ /* */
350
+ /* */
351
+ /* */
352
+ /* */
353
+ /* */
354
+ /* */
355
+ /* */
391
356
  class Cookie {
392
357
  static get Instance() {
393
358
  if (!Cookie.__instance) {
@@ -1067,6 +1032,11 @@ class ResourceResponse {
1067
1032
  //#region resource reponse http strategy
1068
1033
  class ResourceResponseHttp extends ResourceResponse {
1069
1034
  async makeRequest(abortSignal) {
1035
+ /* */
1036
+ /* */
1037
+ /* */
1038
+ /* */
1039
+ /* */
1070
1040
  const url = this.creatUrl(this.urlParams, !!this.axiosOptions?.doNotSerializeParams);
1071
1041
  const method = this.httpMethodName;
1072
1042
  log.d(`Requesting ${method} ${url}`);