├── .gitignore
├── .npmignore
├── README.md
├── index.js
├── index.ts
├── odoorpc.service.js
├── odoorpc.service.ts
├── package.json
├── tsconfig.json
├── typings.json
└── typings
├── browser.d.ts
├── globals
├── es6-shim
│ ├── index.d.ts
│ └── typings.json
├── jasmine
│ ├── index.d.ts
│ └── typings.json
└── zone.js
│ ├── index.d.ts
│ └── typings.json
└── index.d.ts
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
3 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | npm-debug.log
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # angular2-odoorpc
2 | OdooRPC for angular2
3 |
4 | Migrate from [https://github.com/akretion/angular-odoo/blob/master/src/components/odoo/jsonRpc-service.js](https://github.com/akretion/angular-odoo/blob/master/src/components/odoo/jsonRpc-service.js)
5 | + Support Basic Authentication
6 |
7 | ## Installation
8 |
9 | `npm install --save angular2-odoo-jsonrpc`
10 |
11 | ## Functions list
12 |
13 | - `login(db, user, pass)`
14 | - `logout(force)`
15 | - `getDbList() // doesn't work with odoo >= 9.0`
16 | - `searchRead(model, domain, fields)`
17 | - `call(model, method, args, kwargs)`
18 |
19 |
20 | ## How to use
21 |
22 | Import `OdooRPCService` into component
23 |
24 | ```typescript
25 | import { Component } from '@angular/core';
26 | import { OdooRPCService } from 'angular2-odoo-jsonrpc';
27 | ```
28 |
29 | Add provider in app component
30 |
31 | ```typescript
32 | @Component({
33 | ...
34 | providers: [OdooRPCService]
35 | })
36 | ```
37 |
38 | Initialize configuration in `constructor` of component
39 |
40 | ```typescript
41 |
42 | export class OdooClientExampleComponent {
43 |
44 | constructor(odooRPC: OdooRPCService){
45 | this.odooRPC.init({
46 | odoo_server: "https://odoo-server-example",
47 | http_auth: "username:password" // optional
48 | });
49 | this.odooRPC.login('db_example', 'username', 'password').then(res => {
50 | console.log('login success');
51 | }).catch( err => {
52 | console.error('login failed', err);
53 | })
54 | }
55 |
56 | ...
57 |
58 | }
59 |
60 | ```
61 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | function __export(m) {
3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4 | }
5 | __export(require("./odoorpc.service"));
6 |
--------------------------------------------------------------------------------
/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./odoorpc.service";
2 |
--------------------------------------------------------------------------------
/odoorpc.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 | var __param = (this && this.__param) || function (paramIndex, decorator) {
9 | return function (target, key) { decorator(target, key, paramIndex); }
10 | };
11 | var core_1 = require("@angular/core");
12 | var http_1 = require("@angular/http");
13 | require("rxjs/add/operator/toPromise");
14 | var Cookies = (function () {
15 | function Cookies() {
16 | this.session_id = null;
17 | }
18 | Cookies.prototype.delete_sessionId = function () {
19 | this.session_id = null;
20 | document.cookie = "session_id=; expires=Wed, 29 Jun 2016 00:00:00 UTC";
21 | };
22 | Cookies.prototype.get_sessionId = function () {
23 | return document
24 | .cookie.split("; ")
25 | .filter(function (x) { return x.indexOf("session_id") === 0; })
26 | .map(function (x) { return x.split("=")[1]; })
27 | .pop() || this.session_id || "";
28 | };
29 | Cookies.prototype.set_sessionId = function (val) {
30 | document.cookie = "session_id=" + val;
31 | this.session_id = val;
32 | };
33 | return Cookies;
34 | }());
35 | var OdooRPCService = (function () {
36 | function OdooRPCService(http) {
37 | this.http = http;
38 | this.uniq_id_counter = 0;
39 | this.shouldManageSessionId = false; // try without first
40 | this.context = JSON.parse(localStorage.getItem("user_context")) || { "lang": "en_US" };
41 | this.cookies = new Cookies();
42 | }
43 | OdooRPCService.prototype.buildRequest = function (url, params) {
44 | this.uniq_id_counter += 1;
45 | if (this.shouldManageSessionId) {
46 | params.session_id = this.cookies.get_sessionId();
47 | }
48 | var json_data = {
49 | jsonrpc: "2.0",
50 | method: "call",
51 | params: params,
52 | };
53 | this.headers = new http_1.Headers({
54 | "Content-Type": "application/json",
55 | "X-Openerp-Session-Id": this.cookies.get_sessionId(),
56 | "Authorization": "Basic " + btoa("" + this.http_auth)
57 | });
58 | return JSON.stringify({
59 | jsonrpc: "2.0",
60 | method: "call",
61 | params: params,
62 | });
63 | };
64 | OdooRPCService.prototype.handleOdooErrors = function (response) {
65 | response = response.json();
66 | if (!response.error) {
67 | return response.result;
68 | }
69 | var error = response.error;
70 | var errorObj = {
71 | title: " ",
72 | message: "",
73 | fullTrace: error
74 | };
75 | if (error.code === 200 && error.message === "Odoo Server Error" && error.data.name === "werkzeug.exceptions.NotFound") {
76 | errorObj.title = "page_not_found";
77 | errorObj.message = "HTTP Error";
78 | }
79 | else if ((error.code === 100 && error.message === "Odoo Session Expired") ||
80 | (error.code === 300 && error.message === "OpenERP WebClient Error" && error.data.debug.match("SessionExpiredException")) // v7
81 | ) {
82 | errorObj.title = "session_expired";
83 | this.cookies.delete_sessionId();
84 | }
85 | else if ((error.message === "Odoo Server Error" && /FATAL: database "(.+)" does not exist/.test(error.data.message))) {
86 | errorObj.title = "database_not_found";
87 | errorObj.message = error.data.message;
88 | }
89 | else if ((error.data.name === "openerp.exceptions.AccessError")) {
90 | errorObj.title = "AccessError";
91 | errorObj.message = error.data.message;
92 | }
93 | else {
94 | var split = ("" + error.data.fault_code).split("\n")[0].split(" -- ");
95 | if (split.length > 1) {
96 | error.type = split.shift();
97 | error.data.fault_code = error.data.fault_code.substr(error.type.length + 4);
98 | }
99 | if (error.code === 200 && error.type) {
100 | errorObj.title = error.type;
101 | errorObj.message = error.data.fault_code.replace(/\n/g, "
");
102 | }
103 | else {
104 | errorObj.title = error.message;
105 | errorObj.message = error.data.debug.replace(/\n/g, "
");
106 | }
107 | }
108 | return Promise.reject(errorObj);
109 | };
110 | OdooRPCService.prototype.handleHttpErrors = function (error) {
111 | return Promise.reject(error.message || error);
112 | };
113 | OdooRPCService.prototype.init = function (configs) {
114 | this.odoo_server = configs.odoo_server;
115 | this.http_auth = configs.http_auth || null;
116 | };
117 | OdooRPCService.prototype.setOdooServer = function (odoo_server) {
118 | this.odoo_server = odoo_server;
119 | };
120 | OdooRPCService.prototype.setHttpAuth = function (http_auth) {
121 | this.http_auth = http_auth;
122 | };
123 | OdooRPCService.prototype.sendRequest = function (url, params) {
124 | var options = this.buildRequest(url, params);
125 | return this.http.post(this.odoo_server + url, options, { headers: this.headers })
126 | .toPromise()
127 | .then(this.handleOdooErrors)
128 | .catch(this.handleHttpErrors);
129 | };
130 | OdooRPCService.prototype.getServerInfo = function () {
131 | return this.sendRequest("/web/webclient/version_info", {});
132 | };
133 | OdooRPCService.prototype.getSessionInfo = function () {
134 | return this.sendRequest("/web/session/get_session_info", {});
135 | };
136 | OdooRPCService.prototype.login = function (db, login, password) {
137 | var params = {
138 | db: db,
139 | login: login,
140 | password: password
141 | };
142 | var $this = this;
143 | return this.sendRequest("/web/session/authenticate", params).then(function (result) {
144 | if (!result.uid) {
145 | $this.cookies.delete_sessionId();
146 | return Promise.reject({
147 | title: "wrong_login",
148 | message: "Username and password don't match",
149 | fullTrace: result
150 | });
151 | }
152 | $this.context = result.user_context;
153 | localStorage.setItem("user_context", JSON.stringify($this.context));
154 | $this.cookies.set_sessionId(result.session_id);
155 | return result;
156 | });
157 | };
158 | OdooRPCService.prototype.isLoggedIn = function (force) {
159 | var _this = this;
160 | if (force === void 0) { force = true; }
161 | if (!force) {
162 | return Promise.resolve(this.cookies.get_sessionId().length > 0);
163 | }
164 | return this.getSessionInfo().then(function (result) {
165 | _this.cookies.set_sessionId(result.session_id);
166 | return !!(result.uid);
167 | });
168 | };
169 | OdooRPCService.prototype.logout = function (force) {
170 | var _this = this;
171 | if (force === void 0) { force = true; }
172 | this.cookies.delete_sessionId();
173 | if (force) {
174 | return this.getSessionInfo().then(function (r) {
175 | if (r.db)
176 | return _this.login(r.db, "", "");
177 | });
178 | }
179 | else {
180 | return Promise.resolve();
181 | }
182 | };
183 | OdooRPCService.prototype.getDbList = function () {
184 | return this.sendRequest("/web/database/get_list", {});
185 | };
186 | OdooRPCService.prototype.searchRead = function (model, domain, fields, limit) {
187 | var params = {
188 | model: model,
189 | domain: domain,
190 | fields: fields,
191 | limit: limit,
192 | context: this.context
193 | };
194 | return this.sendRequest("/web/dataset/search_read", params);
195 | };
196 | OdooRPCService.prototype.updateContext = function (context) {
197 | var _this = this;
198 | localStorage.setItem("user_context", JSON.stringify(context));
199 | var args = [[this.context.uid], context];
200 | this.call("res.users", "write", args, {})
201 | .then(function () { return _this.context = context; })
202 | .catch(function (err) { return _this.context = context; });
203 | };
204 | OdooRPCService.prototype.getContext = function () {
205 | return this.context;
206 | };
207 | OdooRPCService.prototype.call = function (model, method, args, kwargs) {
208 | kwargs = kwargs || {};
209 | kwargs.context = kwargs.context || {};
210 | Object.assign(kwargs.context, this.context);
211 | var params = {
212 | model: model,
213 | method: method,
214 | args: args,
215 | kwargs: kwargs,
216 | };
217 | return this.sendRequest("/web/dataset/call_kw", params);
218 | };
219 | OdooRPCService.prototype.call_workflow = function (model, method, id ) {
220 | var params = {
221 | model: model,
222 | id: parseInt(id),
223 | signal: method,
224 | };
225 | return this.sendRequest("/web/dataset/exec_workflow", params);
226 | };
227 | OdooRPCService = __decorate([
228 | core_1.Injectable(),
229 | __param(0, core_1.Inject(http_1.Http))
230 | ], OdooRPCService);
231 | return OdooRPCService;
232 | }());
233 | exports.OdooRPCService = OdooRPCService;
234 |
--------------------------------------------------------------------------------
/odoorpc.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable, Inject } from "@angular/core";
2 | import { Http, Response, Headers } from "@angular/http";
3 |
4 | import "rxjs/add/operator/toPromise";
5 |
6 | class Cookies { // cookies doesn't work with Android default browser / Ionic
7 |
8 | private session_id: string = null;
9 |
10 | delete_sessionId() {
11 | this.session_id = null;
12 | document.cookie = "session_id=; expires=Wed, 29 Jun 2016 00:00:00 UTC";
13 | }
14 |
15 | get_sessionId() {
16 | return document
17 | .cookie.split("; ")
18 | .filter(x => { return x.indexOf("session_id") === 0; })
19 | .map(x => { return x.split("=")[1]; })
20 | .pop() || this.session_id || "";
21 | }
22 |
23 | set_sessionId(val: string) {
24 | document.cookie = `session_id=${val}`;
25 | this.session_id = val;
26 | }
27 | }
28 |
29 | @Injectable()
30 | export class OdooRPCService {
31 | private odoo_server: string;
32 | private http_auth: string;
33 | private cookies: Cookies;
34 | private uniq_id_counter: number = 0;
35 | private shouldManageSessionId: boolean = false; // try without first
36 | private context: Object = JSON.parse(localStorage.getItem("user_context")) || {"lang": "en_US"};
37 | private headers: Headers;
38 |
39 | constructor(
40 | @Inject(Http) private http: Http) {
41 | this.cookies = new Cookies();
42 | }
43 |
44 | private buildRequest(url: string, params: any) {
45 | this.uniq_id_counter += 1;
46 | if (this.shouldManageSessionId) {
47 | params.session_id = this.cookies.get_sessionId();
48 | }
49 |
50 | let json_data = {
51 | jsonrpc: "2.0",
52 | method: "call",
53 | params: params, // payload
54 | };
55 | this.headers = new Headers({
56 | "Content-Type": "application/json",
57 | "X-Openerp-Session-Id": this.cookies.get_sessionId(),
58 | "Authorization": "Basic " + btoa(`${this.http_auth}`)
59 | });
60 | return JSON.stringify({
61 | jsonrpc: "2.0",
62 | method: "call",
63 | params: params, // payload
64 | });
65 | }
66 |
67 | private handleOdooErrors(response: any) {
68 | response = response.json();
69 | if (!response.error) {
70 | return response.result;
71 | }
72 |
73 | let error = response.error;
74 | let errorObj = {
75 | title: " ",
76 | message: "",
77 | fullTrace: error
78 | };
79 |
80 | if (error.code === 200 && error.message === "Odoo Server Error" && error.data.name === "werkzeug.exceptions.NotFound") {
81 | errorObj.title = "page_not_found";
82 | errorObj.message = "HTTP Error";
83 | } else if ( (error.code === 100 && error.message === "Odoo Session Expired") || // v8
84 | (error.code === 300 && error.message === "OpenERP WebClient Error" && error.data.debug.match("SessionExpiredException")) // v7
85 | ) {
86 | errorObj.title = "session_expired";
87 | this.cookies.delete_sessionId();
88 | } else if ( (error.message === "Odoo Server Error" && /FATAL: database "(.+)" does not exist/.test(error.data.message))) {
89 | errorObj.title = "database_not_found";
90 | errorObj.message = error.data.message;
91 | } else if ( (error.data.name === "openerp.exceptions.AccessError")) {
92 | errorObj.title = "AccessError";
93 | errorObj.message = error.data.message;
94 | } else {
95 | let split = ("" + error.data.fault_code).split("\n")[0].split(" -- ");
96 | if (split.length > 1) {
97 | error.type = split.shift();
98 | error.data.fault_code = error.data.fault_code.substr(error.type.length + 4);
99 | }
100 |
101 | if (error.code === 200 && error.type) {
102 | errorObj.title = error.type;
103 | errorObj.message = error.data.fault_code.replace(/\n/g, "
");
104 | } else {
105 | errorObj.title = error.message;
106 | errorObj.message = error.data.debug.replace(/\n/g, "
");
107 | }
108 | }
109 | return Promise.reject(errorObj);
110 | }
111 |
112 | private handleHttpErrors(error: any) {
113 | return Promise.reject(error.message || error);
114 | }
115 |
116 | public init(configs: any) {
117 | this.odoo_server = configs.odoo_server;
118 | this.http_auth = configs.http_auth || null;
119 | }
120 |
121 | public setOdooServer(odoo_server: string) {
122 | this.odoo_server = odoo_server;
123 | }
124 |
125 | public setHttpAuth(http_auth: string) {
126 | this.http_auth = http_auth;
127 | }
128 |
129 | public sendRequest(url: string, params: Object): Promise {
130 | let options = this.buildRequest(url, params);
131 | return this.http.post(this.odoo_server + url, options, {headers: this.headers})
132 | .toPromise()
133 | .then(this.handleOdooErrors)
134 | .catch(this.handleHttpErrors);
135 | }
136 |
137 | public getServerInfo() {
138 | return this.sendRequest("/web/webclient/version_info", {});
139 | }
140 |
141 | public getSessionInfo() {
142 | return this.sendRequest("/web/session/get_session_info", {});
143 | }
144 |
145 | public login(db: string, login: string, password: string) {
146 | let params = {
147 | db : db,
148 | login : login,
149 | password : password
150 | };
151 | let $this = this;
152 | return this.sendRequest("/web/session/authenticate", params).then(function(result: any) {
153 | if (!result.uid) {
154 | $this.cookies.delete_sessionId();
155 | return Promise.reject({
156 | title: "wrong_login",
157 | message: "Username and password don't match",
158 | fullTrace: result
159 | });
160 | }
161 | $this.context = result.user_context;
162 | localStorage.setItem("user_context", JSON.stringify($this.context));
163 | $this.cookies.set_sessionId(result.session_id);
164 | return result;
165 | });
166 | }
167 |
168 | public isLoggedIn(force: boolean = true) {
169 | if (!force) {
170 | return Promise.resolve(this.cookies.get_sessionId().length > 0);
171 | }
172 | return this.getSessionInfo().then((result: any) => {
173 | this.cookies.set_sessionId(result.session_id);
174 | return !!(result.uid);
175 | });
176 | }
177 |
178 | public logout(force: boolean = true) {
179 | this.cookies.delete_sessionId();
180 | if (force) {
181 | return this.getSessionInfo().then((r: any) => { // get db from sessionInfo
182 | if (r.db)
183 | return this.login(r.db, "", "");
184 | });
185 | }else {
186 | return Promise.resolve();
187 | }
188 | }
189 |
190 | public getDbList() { // only use for odoo < 9.0
191 | return this.sendRequest("/web/database/get_list", {});
192 | }
193 |
194 | public searchRead(model: string, domain: any, fields: any, limit: number) {
195 | let params = {
196 | model: model,
197 | domain: domain,
198 | fields: fields,
199 | limit: limit,
200 | context: this.context
201 | };
202 | return this.sendRequest("/web/dataset/search_read", params);
203 | }
204 |
205 | public updateContext(context: any) {
206 | localStorage.setItem("user_context", JSON.stringify(context));
207 | let args = [[(this.context).uid], context];
208 | this.call("res.users", "write", args, {})
209 | .then(()=>this.context = context)
210 | .catch((err: any) => this.context = context);
211 | }
212 |
213 | public getContext() {
214 | return this.context;
215 | }
216 |
217 | public call(model: string, method: string, args: any, kwargs: any) {
218 |
219 | kwargs = kwargs || {};
220 | kwargs.context = kwargs.context || {};
221 | Object.assign(kwargs.context, this.context);
222 |
223 | let params = {
224 | model: model,
225 | method: method,
226 | args: args,
227 | kwargs: kwargs,
228 | };
229 | return this.sendRequest("/web/dataset/call_kw", params);
230 | }
231 |
232 | public call_workflow(model: string, method: string, id: any) {
233 | let params = {
234 | model: model,
235 | id: parseInt(id),
236 | signal: method,
237 | };
238 | return this.sendRequest("/web/dataset/exec_workflow", params);
239 | }
240 | }
241 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular2-odoo-jsonrpc",
3 | "version": "0.0.7",
4 | "description": "Odoo JsonRPC Service for angular 2",
5 | "main": "odoorpc.service.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/astronaut1712/angular2-odoo-jsonrpc.git"
12 | },
13 | "keywords": [
14 | "odoo",
15 | "angular",
16 | "2",
17 | "jsonrpc",
18 | "angular2"
19 | ],
20 | "author": "Quang ",
21 | "license": "UNLICENSED",
22 | "bugs": {
23 | "url": "https://github.com/astronaut1712/angular2-odoo-jsonrpc/issues"
24 | },
25 | "homepage": "https://github.com/astronaut1712/angular2-odoo-jsonrpc#readme",
26 | "dependencies": {
27 | "@angular/common": "^2.0.0-rc.3",
28 | "@angular/compiler": "^2.0.0-rc.3",
29 | "@angular/core": "^2.0.0-rc.3",
30 | "@angular/http": "^2.0.0-rc.3",
31 | "@angular/platform-browser": "^2.0.0-rc.3",
32 | "rxjs": "^5.0.0-beta.6",
33 | "zone.js": "^0.6.12"
34 | },
35 | "devDependencies": {
36 | "tslint": "^3.13.0",
37 | "typescript": "^1.8.10"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es5",
5 | "noImplicitAny": false,
6 | "sourceMap": false,
7 | "experimentalDecorators": true
8 | },
9 | "exclude": [
10 | "node_modules"
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {},
3 | "devDependencies": {},
4 | "globalDependencies": {
5 | "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c",
6 | "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#dd638012d63e069f2c99d06ef4dcc9616a943ee4",
7 | "zone.js": "github:DefinitelyTyped/DefinitelyTyped/zone.js/zone.js.d.ts#9027703c0bd831319dcdf7f3169f7a468537f448"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/typings/browser.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 |
--------------------------------------------------------------------------------
/typings/globals/es6-shim/index.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by typings
2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4de74cb527395c13ba20b438c3a7a419ad931f1c/es6-shim/es6-shim.d.ts
3 | declare type PropertyKey = string | number | symbol;
4 |
5 | interface IteratorResult {
6 | done: boolean;
7 | value?: T;
8 | }
9 |
10 | interface IterableShim {
11 | /**
12 | * Shim for an ES6 iterable. Not intended for direct use by user code.
13 | */
14 | "_es6-shim iterator_"(): Iterator;
15 | }
16 |
17 | interface Iterator {
18 | next(value?: any): IteratorResult;
19 | return?(value?: any): IteratorResult;
20 | throw?(e?: any): IteratorResult;
21 | }
22 |
23 | interface IterableIteratorShim extends IterableShim, Iterator {
24 | /**
25 | * Shim for an ES6 iterable iterator. Not intended for direct use by user code.
26 | */
27 | "_es6-shim iterator_"(): IterableIteratorShim;
28 | }
29 |
30 | interface StringConstructor {
31 | /**
32 | * Return the String value whose elements are, in order, the elements in the List elements.
33 | * If length is 0, the empty string is returned.
34 | */
35 | fromCodePoint(...codePoints: number[]): string;
36 |
37 | /**
38 | * String.raw is intended for use as a tag function of a Tagged Template String. When called
39 | * as such the first argument will be a well formed template call site object and the rest
40 | * parameter will contain the substitution values.
41 | * @param template A well-formed template string call site representation.
42 | * @param substitutions A set of substitution values.
43 | */
44 | raw(template: TemplateStringsArray, ...substitutions: any[]): string;
45 | }
46 |
47 | interface String {
48 | /**
49 | * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
50 | * value of the UTF-16 encoded code point starting at the string element at position pos in
51 | * the String resulting from converting this object to a String.
52 | * If there is no element at that position, the result is undefined.
53 | * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
54 | */
55 | codePointAt(pos: number): number;
56 |
57 | /**
58 | * Returns true if searchString appears as a substring of the result of converting this
59 | * object to a String, at one or more positions that are
60 | * greater than or equal to position; otherwise, returns false.
61 | * @param searchString search string
62 | * @param position If position is undefined, 0 is assumed, so as to search all of the String.
63 | */
64 | includes(searchString: string, position?: number): boolean;
65 |
66 | /**
67 | * Returns true if the sequence of elements of searchString converted to a String is the
68 | * same as the corresponding elements of this object (converted to a String) starting at
69 | * endPosition – length(this). Otherwise returns false.
70 | */
71 | endsWith(searchString: string, endPosition?: number): boolean;
72 |
73 | /**
74 | * Returns a String value that is made from count copies appended together. If count is 0,
75 | * T is the empty String is returned.
76 | * @param count number of copies to append
77 | */
78 | repeat(count: number): string;
79 |
80 | /**
81 | * Returns true if the sequence of elements of searchString converted to a String is the
82 | * same as the corresponding elements of this object (converted to a String) starting at
83 | * position. Otherwise returns false.
84 | */
85 | startsWith(searchString: string, position?: number): boolean;
86 |
87 | /**
88 | * Returns an HTML anchor element and sets the name attribute to the text value
89 | * @param name
90 | */
91 | anchor(name: string): string;
92 |
93 | /** Returns a HTML element */
94 | big(): string;
95 |
96 | /** Returns a