@osaas/client-core 0.4.0 → 0.5.1
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/lib/context.d.ts +1 -0
- package/lib/context.d.ts.map +1 -1
- package/lib/context.js.map +1 -1
- package/lib/core.d.ts +51 -1
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +66 -8
- package/lib/core.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- package/lib/index.js.map +1 -1
- package/lib/job.d.ts +37 -0
- package/lib/job.d.ts.map +1 -0
- package/lib/job.js +79 -0
- package/lib/job.js.map +1 -0
- package/package.json +3 -2
package/lib/context.d.ts
CHANGED
package/lib/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,UAAU,GAAG,KAAK,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,qBAAa,OAAO;IAClB,OAAO,CAAC,mBAAmB,CAAC,CAAS;IACrC,OAAO,CAAC,WAAW,CAAS;gBAEhB,MAAM,CAAC,EAAE,aAAa;IAalC,sBAAsB;IAItB,cAAc;IAIR,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA8BzD,eAAe,CAAC,SAAS,EAAE,MAAM;CAaxC"}
|
package/lib/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAwBtC,MAAa,OAAO;IACV,mBAAmB,CAAU;IAC7B,WAAW,CAAS;IAE5B,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,EAAE,mBAAmB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE;YACjE,MAAM,IAAI,KAAK,CACb,0IAA0I,CAC3I,CAAC;SACH;QAED,IAAI,CAAC,mBAAmB,GAAG,MAAM,EAAE,mBAAmB;YACpD,CAAC,CAAC,MAAM,CAAC,mBAAmB;YAC5B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,C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AA,mBAAW,EAAgB,UAAU,EAAE;YAC3C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/C,OAAO,EAAE;gBACP,WAAW,EAAE,UAAU,IAAI,CAAC,mBAAmB,EAAE;gBACjD,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AApED,0BAoEC"}
|
package/lib/core.d.ts
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
|
-
import { Context } from './context';
|
|
1
|
+
import { Context, Service } from './context';
|
|
2
|
+
export declare function getService(context: Context, serviceId: string): Promise<Service>;
|
|
3
|
+
/**
|
|
4
|
+
* @typedef ServiceInstance
|
|
5
|
+
* @type object
|
|
6
|
+
* @property {string} name - Service instance name
|
|
7
|
+
* @property {string} url - Service instance URL
|
|
8
|
+
* @property ... - Service specific properties
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Create a new instance of a service in Open Source Cloud
|
|
12
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
13
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
14
|
+
* @param {string} token - Service access token
|
|
15
|
+
* @param {object} body - Service instance options. The options are service specific
|
|
16
|
+
* @returns {ServiceInstance} - Service instance
|
|
17
|
+
* @example
|
|
18
|
+
* import { Context, createInstance } from '@osaas/client-core';
|
|
19
|
+
*
|
|
20
|
+
* const ctx = new Context();
|
|
21
|
+
* const sat = await ctx.getServiceAccessToken('eyevinn-test-adserver');
|
|
22
|
+
* const instance = await createInstance(ctx, 'eyevinn-test-adserver', sat, { name: 'my-instance' });
|
|
23
|
+
* console.log(instance.url);
|
|
24
|
+
*/
|
|
2
25
|
export declare function createInstance(context: Context, serviceId: string, token: string, body: any): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* Remove an instance of a service in Open Source Cloud
|
|
28
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
29
|
+
* @param {string} serviceId - The service identifier
|
|
30
|
+
* @param {string} name - The name of the service instance to remove
|
|
31
|
+
* @param {string} token - Service access token
|
|
32
|
+
* @example
|
|
33
|
+
* import { Context, removeInstance } from '@osaas/client-core';
|
|
34
|
+
* const ctx = new Context();
|
|
35
|
+
* const sat = await ctx.getServiceAccessToken('eyevinn-test-adserver');
|
|
36
|
+
* await removeInstance(ctx, 'eyevinn-test-adserver', 'my-instance', sat);
|
|
37
|
+
*/
|
|
3
38
|
export declare function removeInstance(context: Context, serviceId: string, name: string, token: string): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieve an instance of a service in Open Source Cloud
|
|
41
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
42
|
+
* @param {string} serviceId - The service identifier
|
|
43
|
+
* @param {string} name - The name of the service instance to remove
|
|
44
|
+
* @param {string} token - Service access token
|
|
45
|
+
* @returns {ServiceInstance} - Service instance
|
|
46
|
+
*/
|
|
4
47
|
export declare function getInstance(context: Context, serviceId: string, name: string, token: string): Promise<any>;
|
|
48
|
+
/**
|
|
49
|
+
* List all instances of a service in Open Source Cloud
|
|
50
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
51
|
+
* @param {string} serviceId - The service identifier
|
|
52
|
+
* @param {string} token - Service access token
|
|
53
|
+
* @returns {Array.<ServiceInstance>} - List of instances
|
|
54
|
+
*/
|
|
5
55
|
export declare function listInstances(context: Context, serviceId: string, token: string): Promise<any>;
|
|
6
56
|
//# sourceMappingURL=core.d.ts.map
|
package/lib/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAI7C,wBAAsB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAgBnE;AAED;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,GAAG,CAAC,CAad;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,iBAYd;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,gBAkBd;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,gBAYd"}
|
package/lib/core.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listInstances = exports.getInstance = exports.removeInstance = exports.createInstance = void 0;
|
|
3
|
+
exports.listInstances = exports.getInstance = exports.removeInstance = exports.createInstance = exports.getService = void 0;
|
|
4
4
|
const fetch_1 = require("./fetch");
|
|
5
|
+
const log_1 = require("./log");
|
|
5
6
|
async function getService(context, serviceId) {
|
|
6
7
|
const serviceUrl = new URL(`https://catalog.svc.${context.getEnvironment()}.osaas.io/mysubscriptions`);
|
|
7
8
|
const services = await (0, fetch_1.createFetch)(serviceUrl, {
|
|
@@ -17,6 +18,29 @@ async function getService(context, serviceId) {
|
|
|
17
18
|
}
|
|
18
19
|
return service;
|
|
19
20
|
}
|
|
21
|
+
exports.getService = getService;
|
|
22
|
+
/**
|
|
23
|
+
* @typedef ServiceInstance
|
|
24
|
+
* @type object
|
|
25
|
+
* @property {string} name - Service instance name
|
|
26
|
+
* @property {string} url - Service instance URL
|
|
27
|
+
* @property ... - Service specific properties
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Create a new instance of a service in Open Source Cloud
|
|
31
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
32
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
33
|
+
* @param {string} token - Service access token
|
|
34
|
+
* @param {object} body - Service instance options. The options are service specific
|
|
35
|
+
* @returns {ServiceInstance} - Service instance
|
|
36
|
+
* @example
|
|
37
|
+
* import { Context, createInstance } from '@osaas/client-core';
|
|
38
|
+
*
|
|
39
|
+
* const ctx = new Context();
|
|
40
|
+
* const sat = await ctx.getServiceAccessToken('eyevinn-test-adserver');
|
|
41
|
+
* const instance = await createInstance(ctx, 'eyevinn-test-adserver', sat, { name: 'my-instance' });
|
|
42
|
+
* console.log(instance.url);
|
|
43
|
+
*/
|
|
20
44
|
async function createInstance(context, serviceId, token, body) {
|
|
21
45
|
const service = await getService(context, serviceId);
|
|
22
46
|
const instanceUrl = new URL(service.apiUrl);
|
|
@@ -31,6 +55,18 @@ async function createInstance(context, serviceId, token, body) {
|
|
|
31
55
|
return instance;
|
|
32
56
|
}
|
|
33
57
|
exports.createInstance = createInstance;
|
|
58
|
+
/**
|
|
59
|
+
* Remove an instance of a service in Open Source Cloud
|
|
60
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
61
|
+
* @param {string} serviceId - The service identifier
|
|
62
|
+
* @param {string} name - The name of the service instance to remove
|
|
63
|
+
* @param {string} token - Service access token
|
|
64
|
+
* @example
|
|
65
|
+
* import { Context, removeInstance } from '@osaas/client-core';
|
|
66
|
+
* const ctx = new Context();
|
|
67
|
+
* const sat = await ctx.getServiceAccessToken('eyevinn-test-adserver');
|
|
68
|
+
* await removeInstance(ctx, 'eyevinn-test-adserver', 'my-instance', sat);
|
|
69
|
+
*/
|
|
34
70
|
async function removeInstance(context, serviceId, name, token) {
|
|
35
71
|
const service = await getService(context, serviceId);
|
|
36
72
|
const instanceUrl = new URL(service.apiUrl + '/' + name);
|
|
@@ -43,18 +79,40 @@ async function removeInstance(context, serviceId, name, token) {
|
|
|
43
79
|
});
|
|
44
80
|
}
|
|
45
81
|
exports.removeInstance = removeInstance;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieve an instance of a service in Open Source Cloud
|
|
84
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
85
|
+
* @param {string} serviceId - The service identifier
|
|
86
|
+
* @param {string} name - The name of the service instance to remove
|
|
87
|
+
* @param {string} token - Service access token
|
|
88
|
+
* @returns {ServiceInstance} - Service instance
|
|
89
|
+
*/
|
|
46
90
|
async function getInstance(context, serviceId, name, token) {
|
|
47
91
|
const service = await getService(context, serviceId);
|
|
48
92
|
const instanceUrl = new URL(service.apiUrl + '/' + name);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
93
|
+
try {
|
|
94
|
+
const instance = await (0, fetch_1.createFetch)(instanceUrl, {
|
|
95
|
+
method: 'GET',
|
|
96
|
+
headers: {
|
|
97
|
+
'x-jwt': `Bearer ${token}`,
|
|
98
|
+
'Content-Type': 'application/json'
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return instance;
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
(0, log_1.Log)().debug(err);
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
56
107
|
}
|
|
57
108
|
exports.getInstance = getInstance;
|
|
109
|
+
/**
|
|
110
|
+
* List all instances of a service in Open Source Cloud
|
|
111
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
112
|
+
* @param {string} serviceId - The service identifier
|
|
113
|
+
* @param {string} token - Service access token
|
|
114
|
+
* @returns {Array.<ServiceInstance>} - List of instances
|
|
115
|
+
*/
|
|
58
116
|
async function listInstances(context, serviceId, token) {
|
|
59
117
|
const service = await getService(context, serviceId);
|
|
60
118
|
const instanceUrl = new URL(service.apiUrl);
|
package/lib/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;AACA,mCAAsC;
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;AACA,mCAAsC;AACtC,+BAA4B;AAErB,KAAK,UAAU,UAAU,CAAC,OAAgB,EAAE,SAAiB;IAClE,MAAM,UAAU,GAAG,IAAI,GAAG,CACxB,uBAAuB,OAAO,CAAC,cAAc,EAAE,2BAA2B,CAC3E,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAW,EAAY,UAAU,EAAE;QACxD,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,WAAW,EAAE,UAAU,OAAO,CAAC,sBAAsB,EAAE,EAAE;YACzD,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IACpE,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,WAAW,SAAS,kCAAkC,CAAC,CAAC;KACzE;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAhBD,gCAgBC;AAED;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AACI,KAAK,UAAU,cAAc,CAClC,OAAgB,EAChB,SAAiB,EACjB,KAAa,EACb,IAAS;IAET,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAA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C;QACH,OAAO,QAAQ,CAAC;KACjB;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,SAAG,GAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KAClB;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAtBD,kCAsBC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,aAAa,CACjC,OAAgB,EAChB,SAAiB,EACjB,KAAa;IAEb,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5C,OAAO,MAAM,IAAA,mBAAW,EAAM,WAAW,EAAE;QACzC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,OAAO,EAAE,UAAU,KAAK,EAAE;YAC1B,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC,CAAC;AACL,CAAC;AAfD,sCAeC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { Log } from './log';
|
|
|
2
2
|
export { createFetch } from './fetch';
|
|
3
3
|
export { Context } from './context';
|
|
4
4
|
export { createInstance, removeInstance, getInstance, listInstances } from './core';
|
|
5
|
+
export { createJob, removeJob, getJob, listJobs, waitForJobToComplete } from './job';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACd,MAAM,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACd,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,oBAAoB,EACrB,MAAM,OAAO,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listInstances = exports.getInstance = exports.removeInstance = exports.createInstance = exports.Context = exports.createFetch = exports.Log = void 0;
|
|
3
|
+
exports.waitForJobToComplete = exports.listJobs = exports.getJob = exports.removeJob = exports.createJob = exports.listInstances = exports.getInstance = exports.removeInstance = exports.createInstance = exports.Context = exports.createFetch = exports.Log = void 0;
|
|
4
4
|
var log_1 = require("./log");
|
|
5
5
|
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return log_1.Log; } });
|
|
6
6
|
var fetch_1 = require("./fetch");
|
|
@@ -12,4 +12,10 @@ Object.defineProperty(exports, "createInstance", { enumerable: true, get: functi
|
|
|
12
12
|
Object.defineProperty(exports, "removeInstance", { enumerable: true, get: function () { return core_1.removeInstance; } });
|
|
13
13
|
Object.defineProperty(exports, "getInstance", { enumerable: true, get: function () { return core_1.getInstance; } });
|
|
14
14
|
Object.defineProperty(exports, "listInstances", { enumerable: true, get: function () { return core_1.listInstances; } });
|
|
15
|
+
var job_1 = require("./job");
|
|
16
|
+
Object.defineProperty(exports, "createJob", { enumerable: true, get: function () { return job_1.createJob; } });
|
|
17
|
+
Object.defineProperty(exports, "removeJob", { enumerable: true, get: function () { return job_1.removeJob; } });
|
|
18
|
+
Object.defineProperty(exports, "getJob", { enumerable: true, get: function () { return job_1.getJob; } });
|
|
19
|
+
Object.defineProperty(exports, "listJobs", { enumerable: true, get: function () { return job_1.listJobs; } });
|
|
20
|
+
Object.defineProperty(exports, "waitForJobToComplete", { enumerable: true, get: function () { return job_1.waitForJobToComplete; } });
|
|
15
21
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AACZ,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,+BAKgB;AAJd,sGAAA,cAAc,OAAA;AACd,sGAAA,cAAc,OAAA;AACd,mGAAA,WAAW,OAAA;AACX,qGAAA,aAAa,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AACZ,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,+BAKgB;AAJd,sGAAA,cAAc,OAAA;AACd,sGAAA,cAAc,OAAA;AACd,mGAAA,WAAW,OAAA;AACX,qGAAA,aAAa,OAAA;AAEf,6BAMe;AALb,gGAAA,SAAS,OAAA;AACT,gGAAA,SAAS,OAAA;AACT,6FAAA,MAAM,OAAA;AACN,+FAAA,QAAQ,OAAA;AACR,2GAAA,oBAAoB,OAAA"}
|
package/lib/job.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Context } from './context';
|
|
2
|
+
/**
|
|
3
|
+
* @typedef ServiceJob
|
|
4
|
+
* @type object
|
|
5
|
+
* @property {string} name - Service job name
|
|
6
|
+
* @property ... - Service specific job properties
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Create a new service job in Open Source Cloud
|
|
10
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
11
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
12
|
+
* @param {string} token - Service access token
|
|
13
|
+
* @param {object} body - Service job options. The options are service specific
|
|
14
|
+
* @returns {ServiceJob} - Service job. The job is specific to the service
|
|
15
|
+
* @example
|
|
16
|
+
* import { Context, createJob } from '@osaas/client-core';
|
|
17
|
+
* const serviceAccessToken = await ctx.getServiceAccessToken(
|
|
18
|
+
* 'eyevinn-docker-retransfer'
|
|
19
|
+
* );
|
|
20
|
+
* const job = await createJob(
|
|
21
|
+
* ctx,
|
|
22
|
+
* 'eyevinn-docker-retransfer',
|
|
23
|
+
* serviceAccessToken,
|
|
24
|
+
* {
|
|
25
|
+
* name: 'example',
|
|
26
|
+
* awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
27
|
+
* awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
28
|
+
* cmdLineArgs: 's3://source/myfile.txt s3://dest/'
|
|
29
|
+
* }
|
|
30
|
+
* );
|
|
31
|
+
*/
|
|
32
|
+
export declare function createJob(context: Context, serviceId: string, token: string, body: any): Promise<any>;
|
|
33
|
+
export declare function removeJob(context: Context, serviceId: string, name: string, token: string): Promise<void>;
|
|
34
|
+
export declare function getJob(context: Context, serviceId: string, name: string, token: string): Promise<any>;
|
|
35
|
+
export declare function listJobs(context: Context, serviceId: string, token: string): Promise<any>;
|
|
36
|
+
export declare function waitForJobToComplete(context: Context, serviceId: string, name: string, token: string): Promise<void>;
|
|
37
|
+
//# sourceMappingURL=job.d.ts.map
|
package/lib/job.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,GAAG,CAAC,CAOd;AAED,wBAAsB,SAAS,CAC7B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,iBAOd;AAED,wBAAsB,MAAM,CAC1B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,gBAOd;AAED,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,gBAOd;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,iBASd"}
|
package/lib/job.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitForJobToComplete = exports.listJobs = exports.getJob = exports.removeJob = exports.createJob = void 0;
|
|
4
|
+
const core_1 = require("./core");
|
|
5
|
+
const MAX_ITER = 1000;
|
|
6
|
+
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
7
|
+
/**
|
|
8
|
+
* @typedef ServiceJob
|
|
9
|
+
* @type object
|
|
10
|
+
* @property {string} name - Service job name
|
|
11
|
+
* @property ... - Service specific job properties
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Create a new service job in Open Source Cloud
|
|
15
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
16
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
17
|
+
* @param {string} token - Service access token
|
|
18
|
+
* @param {object} body - Service job options. The options are service specific
|
|
19
|
+
* @returns {ServiceJob} - Service job. The job is specific to the service
|
|
20
|
+
* @example
|
|
21
|
+
* import { Context, createJob } from '@osaas/client-core';
|
|
22
|
+
* const serviceAccessToken = await ctx.getServiceAccessToken(
|
|
23
|
+
* 'eyevinn-docker-retransfer'
|
|
24
|
+
* );
|
|
25
|
+
* const job = await createJob(
|
|
26
|
+
* ctx,
|
|
27
|
+
* 'eyevinn-docker-retransfer',
|
|
28
|
+
* serviceAccessToken,
|
|
29
|
+
* {
|
|
30
|
+
* name: 'example',
|
|
31
|
+
* awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
32
|
+
* awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
33
|
+
* cmdLineArgs: 's3://source/myfile.txt s3://dest/'
|
|
34
|
+
* }
|
|
35
|
+
* );
|
|
36
|
+
*/
|
|
37
|
+
async function createJob(context, serviceId, token, body) {
|
|
38
|
+
const service = await (0, core_1.getService)(context, serviceId);
|
|
39
|
+
if (service.serviceType !== 'job') {
|
|
40
|
+
throw new Error('Service is not a job service');
|
|
41
|
+
}
|
|
42
|
+
return await (0, core_1.createInstance)(context, serviceId, token, body);
|
|
43
|
+
}
|
|
44
|
+
exports.createJob = createJob;
|
|
45
|
+
async function removeJob(context, serviceId, name, token) {
|
|
46
|
+
const service = await (0, core_1.getService)(context, serviceId);
|
|
47
|
+
if (service.serviceType !== 'job') {
|
|
48
|
+
throw new Error('Service is not a job service');
|
|
49
|
+
}
|
|
50
|
+
return await (0, core_1.removeInstance)(context, serviceId, name, token);
|
|
51
|
+
}
|
|
52
|
+
exports.removeJob = removeJob;
|
|
53
|
+
async function getJob(context, serviceId, name, token) {
|
|
54
|
+
const service = await (0, core_1.getService)(context, serviceId);
|
|
55
|
+
if (service.serviceType !== 'job') {
|
|
56
|
+
throw new Error('Service is not a job service');
|
|
57
|
+
}
|
|
58
|
+
return await (0, core_1.getInstance)(context, serviceId, name, token);
|
|
59
|
+
}
|
|
60
|
+
exports.getJob = getJob;
|
|
61
|
+
async function listJobs(context, serviceId, token) {
|
|
62
|
+
const service = await (0, core_1.getService)(context, serviceId);
|
|
63
|
+
if (service.serviceType !== 'job') {
|
|
64
|
+
throw new Error('Service is not a job service');
|
|
65
|
+
}
|
|
66
|
+
return await (0, core_1.listInstances)(context, serviceId, token);
|
|
67
|
+
}
|
|
68
|
+
exports.listJobs = listJobs;
|
|
69
|
+
async function waitForJobToComplete(context, serviceId, name, token) {
|
|
70
|
+
for (const _ of Array(MAX_ITER)) {
|
|
71
|
+
const job = await getJob(context, serviceId, name, token);
|
|
72
|
+
if (job.status === 'Complete') {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
await delay(1000);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.waitForJobToComplete = waitForJobToComplete;
|
|
79
|
+
//# sourceMappingURL=job.js.map
|
package/lib/job.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job.js","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":";;;AACA,iCAMgB;AAEhB,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AAExE;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,KAAK,UAAU,SAAS,CAC7B,OAAgB,EAChB,SAAiB,EACjB,KAAa,EACb,IAAS;IAET,MAAM,OAAO,GAAG,MAAM,IAAA,iBAAU,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAErD,IAAI,OAAO,CAAC,WAAW,KAAK,KAAK,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KACjD;IACD,OAAO,MAAM,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CACxC,OAAgB,EAChB,SAAiB,EACjB,IAAY,EACZ,KAAa;IAEb,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC/B,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC1D,IAAI,GAAG,CAAC,MAAM,KAAK,UAAU,EAAE;YAC7B,MAAM;SACP;QACD,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;KACnB;AACH,CAAC;AAbD,oDAaC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osaas/client-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Open Source Cloud Client SDK core library",
|
|
5
5
|
"author": "Eyevinn Technology <work@eyevinn.se>",
|
|
6
6
|
"homepage": "https://www.osaas.io",
|
|
@@ -25,10 +25,11 @@
|
|
|
25
25
|
"test": "jest"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@osaas/client-core": "^0.4.0",
|
|
28
29
|
"chalk": "4.1.2"
|
|
29
30
|
},
|
|
30
31
|
"publishConfig": {
|
|
31
32
|
"access": "public"
|
|
32
33
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "1cd9bcf9e53033687345cbffa58d61853ade3a1f"
|
|
34
35
|
}
|