@osaas/client-core 0.11.0 → 0.12.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/lib/index.d.ts CHANGED
@@ -2,8 +2,10 @@
2
2
  export { Log } from './log';
3
3
  export { createFetch, FetchError } from './fetch';
4
4
  export { Context } from './context';
5
+ export { Platform } from './platform';
5
6
  export { createInstance, removeInstance, getInstance, listInstances, getPortsForInstance, getLogsForInstance, instanceValue, valueOrSecret } from './core';
6
7
  export { listSubscriptions, removeSubscription, Subscription } from './admin';
7
8
  export { createJob, removeJob, getJob, listJobs, waitForJobToComplete } from './job';
9
+ export * from './platform/maker';
8
10
  export * from './errors';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACd,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EACL,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,oBAAoB,EACrB,MAAM,OAAO,CAAC;AACf,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACd,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EACL,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,oBAAoB,EACrB,MAAM,OAAO,CAAC;AACf,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC"}
package/lib/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.waitForJobToComplete = exports.listJobs = exports.getJob = exports.removeJob = exports.createJob = exports.removeSubscription = exports.listSubscriptions = exports.valueOrSecret = exports.instanceValue = exports.getLogsForInstance = exports.getPortsForInstance = exports.listInstances = exports.getInstance = exports.removeInstance = exports.createInstance = exports.Context = exports.FetchError = exports.createFetch = exports.Log = void 0;
17
+ exports.waitForJobToComplete = exports.listJobs = exports.getJob = exports.removeJob = exports.createJob = exports.removeSubscription = exports.listSubscriptions = exports.valueOrSecret = exports.instanceValue = exports.getLogsForInstance = exports.getPortsForInstance = exports.listInstances = exports.getInstance = exports.removeInstance = exports.createInstance = exports.Platform = exports.Context = exports.FetchError = exports.createFetch = exports.Log = void 0;
18
18
  /** @module @osaas/client-core */
19
19
  var log_1 = require("./log");
20
20
  Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return log_1.Log; } });
@@ -23,6 +23,8 @@ Object.defineProperty(exports, "createFetch", { enumerable: true, get: function
23
23
  Object.defineProperty(exports, "FetchError", { enumerable: true, get: function () { return fetch_1.FetchError; } });
24
24
  var context_1 = require("./context");
25
25
  Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return context_1.Context; } });
26
+ var platform_1 = require("./platform");
27
+ Object.defineProperty(exports, "Platform", { enumerable: true, get: function () { return platform_1.Platform; } });
26
28
  var core_1 = require("./core");
27
29
  Object.defineProperty(exports, "createInstance", { enumerable: true, get: function () { return core_1.createInstance; } });
28
30
  Object.defineProperty(exports, "removeInstance", { enumerable: true, get: function () { return core_1.removeInstance; } });
@@ -41,5 +43,6 @@ Object.defineProperty(exports, "removeJob", { enumerable: true, get: function ()
41
43
  Object.defineProperty(exports, "getJob", { enumerable: true, get: function () { return job_1.getJob; } });
42
44
  Object.defineProperty(exports, "listJobs", { enumerable: true, get: function () { return job_1.listJobs; } });
43
45
  Object.defineProperty(exports, "waitForJobToComplete", { enumerable: true, get: function () { return job_1.waitForJobToComplete; } });
46
+ __exportStar(require("./platform/maker"), exports);
44
47
  __exportStar(require("./errors"), exports);
45
48
  //# 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,iCAAiC;AACjC,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AACZ,iCAAkD;AAAzC,oGAAA,WAAW,OAAA;AAAE,mGAAA,UAAU,OAAA;AAChC,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,+BASgB;AARd,sGAAA,cAAc,OAAA;AACd,sGAAA,cAAc,OAAA;AACd,mGAAA,WAAW,OAAA;AACX,qGAAA,aAAa,OAAA;AACb,2GAAA,mBAAmB,OAAA;AACnB,0GAAA,kBAAkB,OAAA;AAClB,qGAAA,aAAa,OAAA;AACb,qGAAA,aAAa,OAAA;AAEf,iCAA8E;AAArE,0GAAA,iBAAiB,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAC9C,6BAMe;AALb,gGAAA,SAAS,OAAA;AACT,gGAAA,SAAS,OAAA;AACT,6FAAA,MAAM,OAAA;AACN,+FAAA,QAAQ,OAAA;AACR,2GAAA,oBAAoB,OAAA;AAEtB,2CAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AACZ,iCAAkD;AAAzC,oGAAA,WAAW,OAAA;AAAE,mGAAA,UAAU,OAAA;AAChC,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,+BASgB;AARd,sGAAA,cAAc,OAAA;AACd,sGAAA,cAAc,OAAA;AACd,mGAAA,WAAW,OAAA;AACX,qGAAA,aAAa,OAAA;AACb,2GAAA,mBAAmB,OAAA;AACnB,0GAAA,kBAAkB,OAAA;AAClB,qGAAA,aAAa,OAAA;AACb,qGAAA,aAAa,OAAA;AAEf,iCAA8E;AAArE,0GAAA,iBAAiB,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAC9C,6BAMe;AALb,gGAAA,SAAS,OAAA;AACT,gGAAA,SAAS,OAAA;AACT,6FAAA,MAAM,OAAA;AACN,+FAAA,QAAQ,OAAA;AACR,2GAAA,oBAAoB,OAAA;AAEtB,mDAAiC;AACjC,2CAAyB"}
@@ -0,0 +1,10 @@
1
+ import { Platform } from '../platform';
2
+ export interface Order {
3
+ orderId: string;
4
+ }
5
+ export interface OutputOrder {
6
+ order: Order;
7
+ }
8
+ export declare function getOrderIdByName(platform: Platform, orderName: string): Promise<string | undefined>;
9
+ export declare function remakeOrder(platform: Platform, orderId: string): Promise<string | undefined>;
10
+ //# sourceMappingURL=maker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maker.d.ts","sourceRoot":"","sources":["../../src/platform/maker.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,KAAK,CAAC;CACd;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,+BAwB3E;AAED,wBAAsB,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,+BAwBpE"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.remakeOrder = exports.getOrderIdByName = void 0;
4
+ const errors_1 = require("../errors");
5
+ const fetch_1 = require("../fetch");
6
+ const log_1 = require("../log");
7
+ async function getOrderIdByName(platform, orderName) {
8
+ try {
9
+ const makerUrl = new URL(`https://maker.svc.${platform.getEnvironment()}.osaas.io/maker`);
10
+ makerUrl.searchParams.append('name', orderName);
11
+ const res = await (0, fetch_1.createFetch)(makerUrl, {
12
+ headers: {
13
+ Authorization: `Bearer ${platform.getApiKey()}`,
14
+ 'Content-Type': 'application/json'
15
+ }
16
+ });
17
+ if (res[0]) {
18
+ return res[0].order.orderId;
19
+ }
20
+ return undefined;
21
+ }
22
+ catch (err) {
23
+ (0, log_1.Log)().debug(err);
24
+ if (err instanceof fetch_1.FetchError && err.httpCode === 401) {
25
+ throw new errors_1.UnauthorizedError();
26
+ }
27
+ else if (err instanceof fetch_1.FetchError && err.httpCode === 404) {
28
+ return undefined;
29
+ }
30
+ }
31
+ }
32
+ exports.getOrderIdByName = getOrderIdByName;
33
+ async function remakeOrder(platform, orderId) {
34
+ try {
35
+ const remakerUrl = new URL(`https://maker.svc.${platform.getEnvironment()}.osaas.io/remaker`);
36
+ const res = await (0, fetch_1.createFetch)(remakerUrl, {
37
+ method: 'POST',
38
+ headers: {
39
+ Authorization: `Bearer ${platform.getApiKey()}`,
40
+ 'Content-Type': 'application/json'
41
+ },
42
+ body: JSON.stringify({ orderId })
43
+ });
44
+ (0, log_1.Log)().debug(res);
45
+ return res.orderId;
46
+ }
47
+ catch (err) {
48
+ (0, log_1.Log)().debug(err);
49
+ if (err instanceof fetch_1.FetchError && err.httpCode === 401) {
50
+ throw new errors_1.UnauthorizedError();
51
+ }
52
+ else if (err instanceof fetch_1.FetchError && err.httpCode === 404) {
53
+ return undefined;
54
+ }
55
+ }
56
+ return undefined;
57
+ }
58
+ exports.remakeOrder = remakeOrder;
59
+ //# sourceMappingURL=maker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maker.js","sourceRoot":"","sources":["../../src/platform/maker.ts"],"names":[],"mappings":";;;AAAA,sCAA8C;AAC9C,oCAAmD;AACnD,gCAA6B;AAWtB,KAAK,UAAU,gBAAgB,CAAC,QAAkB,EAAE,SAAiB;IAC1E,IAAI;QACF,MAAM,QAAQ,GAAG,IAAI,GAAG,CACtB,qBAAqB,QAAQ,CAAC,cAAc,EAAE,iBAAiB,CAChE,CAAC;QACF,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,MAAM,IAAA,mBAAW,EAAgB,QAAQ,EAAE;YACrD,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,QAAQ,CAAC,SAAS,EAAE,EAAE;gBAC/C,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QACH,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;YACV,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;SAC7B;QACD,OAAO,SAAS,CAAC;KAClB;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,SAAG,GAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjB,IAAI,GAAG,YAAY,kBAAU,IAAI,GAAG,CAAC,QAAQ,KAAK,GAAG,EAAE;YACrD,MAAM,IAAI,0BAAiB,EAAE,CAAC;SAC/B;aAAM,IAAI,GAAG,YAAY,kBAAU,IAAI,GAAG,CAAC,QAAQ,KAAK,GAAG,EAAE;YAC5D,OAAO,SAAS,CAAC;SAClB;KACF;AACH,CAAC;AAxBD,4CAwBC;AAEM,KAAK,UAAU,WAAW,CAAC,QAAkB,EAAE,OAAe;IACnE,IAAI;QACF,MAAM,UAAU,GAAG,IAAI,GAAG,CACxB,qBAAqB,QAAQ,CAAC,cAAc,EAAE,mBAAmB,CAClE,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,IAAA,mBAAW,EAAsB,UAAU,EAAE;YAC7D,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,QAAQ,CAAC,SAAS,EAAE,EAAE;gBAC/C,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;SAClC,CAAC,CAAC;QACH,IAAA,SAAG,GAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,GAAG,CAAC,OAAO,CAAC;KACpB;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,SAAG,GAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjB,IAAI,GAAG,YAAY,kBAAU,IAAI,GAAG,CAAC,QAAQ,KAAK,GAAG,EAAE;YACrD,MAAM,IAAI,0BAAiB,EAAE,CAAC;SAC/B;aAAM,IAAI,GAAG,YAAY,kBAAU,IAAI,GAAG,CAAC,QAAQ,KAAK,GAAG,EAAE;YAC5D,OAAO,SAAS,CAAC;SAClB;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAxBD,kCAwBC"}
@@ -0,0 +1,12 @@
1
+ export type PlatformConfig = {
2
+ apiKey?: string;
3
+ environment?: string;
4
+ };
5
+ export declare class Platform {
6
+ private apiKey?;
7
+ private environment;
8
+ constructor(config?: PlatformConfig);
9
+ getApiKey(): string | undefined;
10
+ getEnvironment(): string;
11
+ }
12
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,WAAW,CAAS;gBAEhB,MAAM,CAAC,EAAE,cAAc;IAWnC,SAAS;IAIT,cAAc;CAGf"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Platform = void 0;
4
+ class Platform {
5
+ apiKey;
6
+ environment;
7
+ constructor(config) {
8
+ if (!config?.apiKey && !process.env.OSC_API_KEY) {
9
+ throw new Error('Platform API key is required. Please provide it in the config or set the OSC_API_KEY environment variable.');
10
+ }
11
+ this.apiKey = config?.apiKey ? config.apiKey : process.env.OSC_API_KEY;
12
+ this.environment = config?.environment ? config.environment : 'prod';
13
+ }
14
+ getApiKey() {
15
+ return this.apiKey;
16
+ }
17
+ getEnvironment() {
18
+ return this.environment;
19
+ }
20
+ }
21
+ exports.Platform = Platform;
22
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;AAKA,MAAa,QAAQ;IACX,MAAM,CAAU;IAChB,WAAW,CAAS;IAE5B,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;YAC/C,MAAM,IAAI,KAAK,CACb,4GAA4G,CAC7G,CAAC;SACH;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;QACvE,IAAI,CAAC,WAAW,GAAG,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC;IACvE,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAtBD,4BAsBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osaas/client-core",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
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",
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "35a3d4ba3f3abf63046f0c97bdc5b346924138c2"
34
+ "gitHead": "f5a8f8f3b1e0ce49eb00179630863cf4c98b5628"
35
35
  }