├── .gitignore
├── LICENSE
├── README.md
├── package.json
└── src
├── backand.service.d.ts
├── backand.service.js
├── backand.service.js.map
├── backand.service.ts
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Dependency directory
2 | node_modules/**
3 | bower_components/**
4 |
5 | # web storm ide
6 | .idea/**
7 |
8 |
9 |
10 |
11 | # temp
12 | test/**
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Backand
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | angular2-sdk
2 | ===
3 | > Backand SDK for [Angular.js 2](https://angular.io/).
4 | This is the documentation for Back&'s Angular 2 SDK. This SDK enables you to communicate comfortably and quickly with your Backand app.
5 | It wraps the [vanilla-sdk](https://github.com/backand/vanilla-sdk) to allow you to work with Back& more easily when working on projects based on Angular.js 2.
6 |
7 |
8 | ## Overview
9 | This SDK is an Angular 2 wrapper around our [vanilla-sdk](https://github.com/backand/vanilla-sdk). This provides convenient objects and properties for Angular 2 apps working with Back&. You can refer to the [vanilla-sdk](https://github.com/backand/vanilla-sdk)'s readme for a full API reference. Follow the instructions below to install our Angular 2 SDK!
10 |
11 |
12 | ## Installation
13 | To install the Angular 2 SDK, use the correct command for your dependency management platform:
14 |
15 | | Provider | Command |
16 | | -------- | ------- |
17 | | npm | `$ npm i -S @backand/angular2-sdk` |
18 | | yarn | `$ yarn add @backand/angular2-sdk` |
19 |
20 | ## Import
21 | Use the following import statement to include the Angular2 SDK in your project:
22 |
23 | ```javascript
24 | import { BackandService } from '@backand/angular2-sdk'
25 | ```
26 |
27 |
28 | ## Quick start
29 |
30 | Using the Back& Angular2 SDK requires two steps - configuring access to the BackandService provider, and then actually calling the provider using the [vanilla-sdk](https://github.com/backand/vanilla-sdk) methods.
31 |
32 | #### app.module.ts:
33 | Update `app.module.ts` to include the BackandService as a provider
34 |
35 | ```javascript
36 | @NgModule({
37 | imports: [ ... ],
38 | declarations: [ ... ],
39 | providers: [ BackandService ],
40 | bootstrap: [ AppComponent ]
41 | })
42 | export class AppModule { }
43 | ```
44 |
45 | #### app.component.ts:
46 | Now, call the SDK from `app.component.ts`. The SDK is initialized during `ngOnInit()`, and `getList` is called as a property on `AppComponent`
47 |
48 | ```javascript
49 | @Component({
50 | selector: 'my-app',
51 | template: `
Hello angular2-sdk
52 | {{res}}
`
53 | })
54 | export class AppComponent implements OnInit {
55 | res: string;
56 | constructor(private backand: BackandService) { }
57 | getList(): void {
58 | this.res = 'fetching objects...';
59 | this.backand.object.getList('users').then((res: any) => {
60 | this.res = `${res.data.length} objects fetched`;
61 | console.log(res);
62 | })
63 | }
64 | ngOnInit(): void {
65 | this.backand.init({
66 | appName: 'APP_NAME',
67 | anonymousToken: 'ANONYMOUS_TOKEN'
68 | });
69 | this.getList();
70 | }
71 | }
72 | ```
73 |
74 | Review the full API reference at our [vanilla-sdk's github](https://github.com/backand/vanilla-sdk) to get started with your back end!
75 |
76 | ## Examples
77 | ***To view a demo of the SDK in action, just run `npm start` - [example page](https://github.com/backand/angular2-sdk/blob/master/example/).***
78 |
79 | ***We also offer an example app for Angular 2 - just follow the instructions in our [sample project](https://github.com/backand/angular2-example)***
80 |
81 |
82 | ## License
83 |
84 | [MIT](LICENSE)
85 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@backand/angular2-sdk",
3 | "version": "1.2.13",
4 | "description": "Backand SDK for Angular 2",
5 | "main": "./src/backand.service.js",
6 | "types": "./src/backand.service.d.ts",
7 | "files": [
8 | "src",
9 | "example",
10 | "test",
11 | "tsconfig.json"
12 | ],
13 | "directories": {
14 | "example": "example"
15 | },
16 | "scripts": {
17 | "build": "tsc -p src/",
18 | "test": "npm run build && tsc -p test/ && mocha",
19 | "patch": "npm version patch -m \"Release version %s\"",
20 | "version": "npm i -S -f @backand/vanilla-sdk && npm run build && git add -A",
21 | "postversion": "git push && git push --tags"
22 | },
23 | "author": "Backand",
24 | "license": "MIT",
25 | "dependencies": {
26 | "@angular/core": "^2.4.6",
27 | "@backand/vanilla-sdk": "^1.2.15",
28 | "rxjs": "^5.1.0",
29 | "zone.js": "^0.7.6"
30 | },
31 | "devDependencies": {
32 | "@angular/common": "^2.4.6",
33 | "@angular/compiler": "^2.4.6",
34 | "@angular/platform-browser": "^2.4.6",
35 | "@angular/platform-browser-dynamic": "^2.4.6",
36 | "@types/chai": "^3.4.34",
37 | "@types/mocha": "^2.2.39",
38 | "@types/node": "^7.0.5",
39 | "angular2-template-loader": "^0.6.1",
40 | "awesome-typescript-loader": "^3.0.3",
41 | "chai": "^3.5.0",
42 | "core-js": "^2.4.1",
43 | "file-loader": "^0.10.0",
44 | "mocha": "^3.2.0",
45 | "mocha-loader": "^1.1.0",
46 | "null-loader": "^0.1.1",
47 | "reflect-metadata": "^0.1.9",
48 | "rimraf": "^2.5.4",
49 | "typescript": "^2.1.5"
50 | },
51 | "repository": {
52 | "type": "git",
53 | "url": "git+https://github.com/backand/angular2-sdk.git"
54 | },
55 | "bugs": {
56 | "url": "https://github.com/backand/angular2-sdk/issues"
57 | },
58 | "homepage": "https://github.com/backand/angular2-sdk#readme",
59 | "keywords": [
60 | "Backand",
61 | "backend",
62 | "backend sdk",
63 | "backend js",
64 | "backend javascript",
65 | "angular2-sdk",
66 | "backend angular sdk"
67 | ]
68 | }
69 |
--------------------------------------------------------------------------------
/src/backand.service.d.ts:
--------------------------------------------------------------------------------
1 | export declare class BackandService {
2 | init(config: any): void;
3 | constants: any;
4 | helpers: any;
5 | defaults: any;
6 | object: any;
7 | file: any;
8 | query: any;
9 | user: any;
10 | offline: any;
11 | bulk: any;
12 | fn: any;
13 | invoke: any;
14 | useAnonymousAuth(): any;
15 | signin(username: string, password: string): any;
16 | signup(firstName: string, lastName: string, email: string, password: string, confirmPassword: string, parameters?: any): any;
17 | socialSignin(provider: string): any;
18 | socialSigninWithToken(provider: string, token: string): any;
19 | socialSignup(provider: string, email: string): any;
20 | requestResetPassword(username: string): any;
21 | resetPassword(newPassword: string, resetToken: string): any;
22 | changePassword(oldPassword: string, newPassword: string): any;
23 | signout(): any;
24 | getSocialProviders(): any;
25 | on(eventName: string, callback?: (response?: any) => void): void;
26 | }
27 | export declare class Response {
28 | status: number;
29 | statusText: string;
30 | headers: any;
31 | config: any;
32 | data: any;
33 | }
34 |
--------------------------------------------------------------------------------
/src/backand.service.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
7 | };
8 | Object.defineProperty(exports, "__esModule", { value: true });
9 | var core_1 = require("@angular/core");
10 | var rxjs_1 = require("rxjs");
11 | var backand = require("@backand/vanilla-sdk");
12 | var BackandService = /** @class */ (function () {
13 | function BackandService() {
14 | }
15 | BackandService.prototype.init = function (config) {
16 | var _this = this;
17 | backand.init(config);
18 | if (config.observable) {
19 | Object.keys(backand).forEach(function (key) {
20 | _this[key] = rxjs_1.Observable.fromPromise(backand[key]);
21 | });
22 | }
23 | else {
24 | Object.keys(backand).forEach(function (key) {
25 | _this[key] = backand[key];
26 | });
27 | }
28 | };
29 | // auth
30 | BackandService.prototype.useAnonymousAuth = function () { };
31 | ;
32 | BackandService.prototype.signin = function (username, password) { };
33 | ;
34 | BackandService.prototype.signup = function (firstName, lastName, email, password, confirmPassword, parameters) { };
35 | ;
36 | BackandService.prototype.socialSignin = function (provider) { };
37 | ;
38 | BackandService.prototype.socialSigninWithToken = function (provider, token) { };
39 | ;
40 | BackandService.prototype.socialSignup = function (provider, email) { };
41 | ;
42 | BackandService.prototype.requestResetPassword = function (username) { };
43 | ;
44 | BackandService.prototype.resetPassword = function (newPassword, resetToken) { };
45 | ;
46 | BackandService.prototype.changePassword = function (oldPassword, newPassword) { };
47 | ;
48 | BackandService.prototype.signout = function () { };
49 | ;
50 | BackandService.prototype.getSocialProviders = function () { };
51 | ;
52 | // socket
53 | BackandService.prototype.on = function (eventName, callback) { };
54 | ;
55 | BackandService = __decorate([
56 | core_1.Injectable()
57 | ], BackandService);
58 | return BackandService;
59 | }());
60 | exports.BackandService = BackandService;
61 | var Response = /** @class */ (function () {
62 | function Response() {
63 | }
64 | return Response;
65 | }());
66 | exports.Response = Response;
67 | //# sourceMappingURL=backand.service.js.map
--------------------------------------------------------------------------------
/src/backand.service.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"backand.service.js","sourceRoot":"","sources":["backand.service.ts"],"names":[],"mappings":";;;;;;;;AAAA,sCAA0C;AAC1C,6B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gB,WAAmB,EAAE,WAAmB,IAAQ,CAAC;IAAA,CAAC;IAClE,gCAAO,GAAP,cAAiB,CAAC;IAAA,CAAC;IACnB,2CAAkB,GAAlB,cAA4B,CAAC;IAAA,CAAC;IAC9B,SAAS;IACT,2BAAE,GAAF,UAAI,SAAiB,EAAE,QAAmC,IAAS,CAAC;IAAA,CAAC;IAtC1D,cAAc;QAD1B,iBAAU,EAAE;OACA,cAAc,CAuC1B;IAAD,qBAAC;CAAA,AAvCD,IAuCC;AAvCY,wCAAc;AAyC3B;IAAA;IAMA,CAAC;IAAD,eAAC;AAAD,CAAC,AAND,IAMC;AANY,4BAAQ"}
--------------------------------------------------------------------------------
/src/backand.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core'
2 | import { Observable } from 'rxjs'
3 | import * as backand from '@backand/vanilla-sdk'
4 |
5 | @Injectable()
6 | export class BackandService {
7 | init(config: any): void {
8 | backand.init(config);
9 | if (config.observable) {
10 | Object.keys(backand).forEach(key => {
11 | this[key] = Observable.fromPromise(backand[key]);
12 | });
13 | }
14 | else {
15 | Object.keys(backand).forEach(key => {
16 | this[key] = backand[key];
17 | });
18 | }
19 | }
20 | constants: any;
21 | helpers: any;
22 | defaults: any;
23 | object: any;
24 | file: any;
25 | query: any;
26 | user: any;
27 | offline: any;
28 | bulk: any;
29 | fn: any;
30 | invoke: any;
31 | // auth
32 | useAnonymousAuth (): any {};
33 | signin (username: string, password: string): any {};
34 | signup (firstName: string, lastName: string, email: string, password: string, confirmPassword: string, parameters?: any): any {};
35 | socialSignin (provider: string): any {};
36 | socialSigninWithToken (provider: string, token: string): any {};
37 | socialSignup (provider: string, email: string): any {};
38 | requestResetPassword (username: string): any {};
39 | resetPassword (newPassword: string, resetToken: string): any {};
40 | changePassword (oldPassword: string, newPassword: string): any {};
41 | signout (): any {};
42 | getSocialProviders (): any {};
43 | // socket
44 | on (eventName: string, callback?: (response?: any) => void): void {};
45 | }
46 |
47 | export class Response {
48 | status: number;
49 | statusText: string;
50 | headers: any;
51 | config: any;
52 | data: any;
53 | }
54 |
--------------------------------------------------------------------------------
/src/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "moduleResolution": "node",
6 | "sourceMap": true,
7 | "emitDecoratorMetadata": true,
8 | "experimentalDecorators": true,
9 | "lib": [ "es2015", "dom" ],
10 | "noImplicitAny": true,
11 | "suppressImplicitAnyIndexErrors": true,
12 | "declaration": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------