@osaas/client-intercom 0.1.0
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/LICENSE +21 -0
- package/README.md +46 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/system.d.ts +17 -0
- package/lib/system.d.ts.map +1 -0
- package/lib/system.js +88 -0
- package/lib/system.js.map +1 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Eyevinn Technology Open Source Software Center
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @osaas/client-intercom
|
|
2
|
+
|
|
3
|
+
SDK for Open Source Cloud Intercom
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Prerequisites
|
|
8
|
+
|
|
9
|
+
- An account on [Open Source Cloud](www.osaas.io)
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install --save @osaas/client-intercom
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Example code
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
import { Context, Log } from '@osaas/client-core';
|
|
19
|
+
import { IntercomSystem } from '@osaas/client-intercom';
|
|
20
|
+
|
|
21
|
+
async function main() {
|
|
22
|
+
const ctx = new Context();
|
|
23
|
+
try {
|
|
24
|
+
const intercom = new IntercomSystem({ context: ctx, name });
|
|
25
|
+
await intercom.init();
|
|
26
|
+
const p = await intercom.createProduction('myproduction', [
|
|
27
|
+
'line1',
|
|
28
|
+
'line2',
|
|
29
|
+
'line3'
|
|
30
|
+
]);
|
|
31
|
+
console.log(`Production '${p.name}' created with id ${p.productionId}`);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
Log().error(err);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
main();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## About Open Source Cloud
|
|
41
|
+
|
|
42
|
+
Open Source Cloud reduces the barrier to get started with open source without having to host it on your own infrastructure.
|
|
43
|
+
|
|
44
|
+
Start building software solutions based on open and detachable ready-to-run cloud components with Open Source Cloud. Full code transparency, never locked in and a business model that contributes back to the open source community. Offering a wide range of components from media and more to help you build the best solution for you and your users.
|
|
45
|
+
|
|
46
|
+
www.osaas.io
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @module @osaas/client-intercom */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.IntercomSystem = void 0;
|
|
5
|
+
var system_1 = require("./system");
|
|
6
|
+
Object.defineProperty(exports, "IntercomSystem", { enumerable: true, get: function () { return system_1.IntercomSystem; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qCAAqC;;;AAErC,mCAA0C;AAAjC,wGAAA,cAAc,OAAA"}
|
package/lib/system.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Context } from '@osaas/client-core';
|
|
2
|
+
export declare class IntercomSystem {
|
|
3
|
+
private context;
|
|
4
|
+
private name;
|
|
5
|
+
private url?;
|
|
6
|
+
private token?;
|
|
7
|
+
constructor({ context, name }: {
|
|
8
|
+
context: Context;
|
|
9
|
+
name: string;
|
|
10
|
+
});
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
listProductions(): Promise<any>;
|
|
13
|
+
listLinesForProduction(productionId: string): Promise<any>;
|
|
14
|
+
createProduction(name: string, lines: string[]): Promise<any>;
|
|
15
|
+
deleteProduction(productionId: string): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../src/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiC,MAAM,oBAAoB,CAAC;AAI5E,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,GAAG,CAAC,CAAS;IACrB,OAAO,CAAC,KAAK,CAAC,CAAS;gBAEX,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAKpD,IAAI;IAgBJ,eAAe;IAef,sBAAsB,CAAC,YAAY,EAAE,MAAM;IAe3C,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAqB9C,gBAAgB,CAAC,YAAY,EAAE,MAAM;CAanD"}
|
package/lib/system.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntercomSystem = void 0;
|
|
4
|
+
const client_core_1 = require("@osaas/client-core");
|
|
5
|
+
const SERVICE_ID = 'eyevinn-intercom-manager';
|
|
6
|
+
class IntercomSystem {
|
|
7
|
+
context;
|
|
8
|
+
name;
|
|
9
|
+
url;
|
|
10
|
+
token;
|
|
11
|
+
constructor({ context, name }) {
|
|
12
|
+
this.context = context;
|
|
13
|
+
this.name = name;
|
|
14
|
+
}
|
|
15
|
+
async init() {
|
|
16
|
+
this.token = await this.context.getServiceAccessToken(SERVICE_ID);
|
|
17
|
+
const instance = await (0, client_core_1.getInstance)(this.context, SERVICE_ID, this.name, this.token);
|
|
18
|
+
if (!instance) {
|
|
19
|
+
throw new Error(`No Intercom system found with name ${this.name}`);
|
|
20
|
+
}
|
|
21
|
+
this.url = instance.url;
|
|
22
|
+
(0, client_core_1.Log)().debug(instance);
|
|
23
|
+
(0, client_core_1.Log)().debug(`Intercom system ${this.name} found on ${this.url}`);
|
|
24
|
+
}
|
|
25
|
+
async listProductions() {
|
|
26
|
+
if (!this.url) {
|
|
27
|
+
throw new Error('Intercom system not initialized');
|
|
28
|
+
}
|
|
29
|
+
const url = new URL(this.url + '/api/v1/production');
|
|
30
|
+
const productions = await (0, client_core_1.createFetch)(url, {
|
|
31
|
+
method: 'GET',
|
|
32
|
+
headers: {
|
|
33
|
+
Authorization: `Bearer ${this.token}`,
|
|
34
|
+
'Content-Type': 'application/json'
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return productions;
|
|
38
|
+
}
|
|
39
|
+
async listLinesForProduction(productionId) {
|
|
40
|
+
if (!this.url) {
|
|
41
|
+
throw new Error('Intercom system not initialized');
|
|
42
|
+
}
|
|
43
|
+
const url = new URL(this.url + `/api/v1/production/${productionId}/line`);
|
|
44
|
+
const lines = await (0, client_core_1.createFetch)(url, {
|
|
45
|
+
method: 'GET',
|
|
46
|
+
headers: {
|
|
47
|
+
Authorization: `Bearer ${this.token}`,
|
|
48
|
+
'Content-Type': 'application/json'
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return lines;
|
|
52
|
+
}
|
|
53
|
+
async createProduction(name, lines) {
|
|
54
|
+
if (!this.url) {
|
|
55
|
+
throw new Error('Intercom system not initialized');
|
|
56
|
+
}
|
|
57
|
+
const url = new URL(this.url + '/api/v1/production');
|
|
58
|
+
const production = await (0, client_core_1.createFetch)(url, {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: {
|
|
61
|
+
Authorization: `Bearer ${this.token}`,
|
|
62
|
+
'Content-Type': 'application/json'
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify({
|
|
65
|
+
name,
|
|
66
|
+
lines: lines.map((line) => {
|
|
67
|
+
return { name: line };
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
return production;
|
|
72
|
+
}
|
|
73
|
+
async deleteProduction(productionId) {
|
|
74
|
+
if (!this.url) {
|
|
75
|
+
throw new Error('Intercom system not initialized');
|
|
76
|
+
}
|
|
77
|
+
const url = new URL(this.url + `/api/v1/production/${productionId}`);
|
|
78
|
+
const msg = await (0, client_core_1.createFetch)(url, {
|
|
79
|
+
method: 'DELETE',
|
|
80
|
+
headers: {
|
|
81
|
+
Authorization: `Bearer ${this.token}`
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
(0, client_core_1.Log)().info(msg);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.IntercomSystem = IntercomSystem;
|
|
88
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../src/system.ts"],"names":[],"mappings":";;;AAAA,oDAA4E;AAE5E,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAE9C,MAAa,cAAc;IACjB,OAAO,CAAU;IACjB,IAAI,CAAS;IACb,GAAG,CAAU;IACb,KAAK,CAAU;IAEvB,YAAY,EAAE,OAAO,EAAE,IAAI,EAAsC;QAC/D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,IAAI,CAAC,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAClE,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAW,EAChC,IAAI,CAAC,OAAO,EACZ,UAAU,EACV,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,KAAK,CACX,CAAC;QACF,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;SACpE;QACD,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QACxB,IAAA,iBAAG,GAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtB,IAAA,iBAAG,GAAE,CAAC,KAAK,CAAC,mBAAmB,IAAI,CAAC,IAAI,aAAa,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACnE,CAAC;IAEM,KAAK,CAAC,eAAe;QAC1B,IAAI,CAAC,IAAI,CAAC,GAAG,E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EAAE;gBACrC,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,IAAI;gBACJ,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;oBACxB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBACxB,CAAC,CAAC;aACH,CAAC;SACH,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACpB,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,YAAoB;QAChD,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;YACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;SACpD;QACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,sBAAsB,YAAY,EAAE,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,MAAM,IAAA,yBAAW,EAAM,GAAG,EAAE;YACtC,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE;aACtC;SACF,CAAC,CAAC;QACH,IAAA,iBAAG,GAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC;CACF;AA3FD,wCA2FC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@osaas/client-intercom",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Open Source Cloud Client SDK intercom library",
|
|
5
|
+
"author": "Eyevinn Technology <work@eyevinn.se>",
|
|
6
|
+
"homepage": "https://www.osaas.io",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "lib/index.js",
|
|
9
|
+
"types": "lib/index.d.ts",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/Eyevinn/osaas-client-ts.git"
|
|
13
|
+
},
|
|
14
|
+
"directories": {
|
|
15
|
+
"lib": "lib"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"lib"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.json",
|
|
22
|
+
"lint": "eslint .",
|
|
23
|
+
"pretty": "prettier --check --ignore-unknown .",
|
|
24
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
25
|
+
"test": "jest --passWithNoTests"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@osaas/client-core": "^0.8.0",
|
|
29
|
+
"chalk": "4.1.2"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"gitHead": "eac8e0df426571c6f30bd867cbb1bc62387e4da7"
|
|
35
|
+
}
|