@stepzen/sdk 0.9.41 → 0.9.44
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/README.md +14 -14
- package/lib/commands/account.d.ts +9 -0
- package/lib/commands/account.js +39 -0
- package/lib/commands/account.js.map +1 -0
- package/lib/commands/authenticate.d.ts +2 -2
- package/lib/commands/authenticate.js +6 -5
- package/lib/commands/authenticate.js.map +1 -0
- package/lib/commands/deploy.d.ts +2 -2
- package/lib/commands/deploy.js +9 -8
- package/lib/commands/deploy.js.map +1 -0
- package/lib/commands/list.d.ts +2 -2
- package/lib/commands/list.js +7 -6
- package/lib/commands/list.js.map +1 -0
- package/lib/commands/upload.d.ts +2 -2
- package/lib/commands/upload.js +13 -12
- package/lib/commands/upload.js.map +1 -0
- package/lib/index.d.ts +22 -5
- package/lib/index.js +72 -35
- package/lib/index.js.map +1 -0
- package/lib/shared/constants.d.ts +1 -0
- package/lib/shared/constants.js +7 -5
- package/lib/shared/constants.js.map +1 -0
- package/lib/shared/payloads.d.ts +1 -1
- package/lib/shared/payloads.js +12 -11
- package/lib/shared/payloads.js.map +1 -0
- package/lib/shared/request.d.ts +2 -2
- package/lib/shared/request.js +13 -7
- package/lib/shared/request.js.map +1 -0
- package/lib/shared/transpiling.js +4 -3
- package/lib/shared/transpiling.js.map +1 -0
- package/lib/shared/types.d.ts +36 -3
- package/lib/shared/types.js +1 -0
- package/lib/shared/types.js.map +1 -0
- package/lib/shared/validation.js +9 -8
- package/lib/shared/validation.js.map +1 -0
- package/package.json +18 -9
- package/src/commands/account.ts +54 -0
- package/src/commands/authenticate.ts +30 -0
- package/src/commands/deploy.ts +72 -0
- package/src/commands/list.ts +50 -0
- package/src/commands/upload.ts +95 -0
- package/src/index.ts +121 -0
- package/src/shared/constants.ts +7 -0
- package/src/shared/payloads.ts +105 -0
- package/src/shared/request.ts +26 -0
- package/src/shared/transpiling.ts +36 -0
- package/src/shared/types.ts +75 -0
- package/src/shared/validation.ts +42 -0
package/README.md
CHANGED
|
@@ -3,28 +3,28 @@
|
|
|
3
3
|
## Usage
|
|
4
4
|
|
|
5
5
|
```js
|
|
6
|
-
const stepzen = require(
|
|
6
|
+
const stepzen = require('@stepzen/sdk')
|
|
7
7
|
|
|
8
|
-
const ACCOUNT =
|
|
9
|
-
const ADMIN_KEY =
|
|
8
|
+
const ACCOUNT = '<account>'
|
|
9
|
+
const ADMIN_KEY = '<admin key>'
|
|
10
10
|
|
|
11
11
|
(async () => {
|
|
12
12
|
const client = await stepzen.client({
|
|
13
13
|
account: ACCOUNT,
|
|
14
14
|
adminkey: ADMIN_KEY,
|
|
15
|
-
})
|
|
15
|
+
})
|
|
16
16
|
|
|
17
|
-
await client.upload.configurationset(
|
|
17
|
+
await client.upload.configurationset('folder/name', '/path/to/config.yaml')
|
|
18
18
|
|
|
19
|
-
await client.upload.schema(
|
|
19
|
+
await client.upload.schema('folder/name', '/path/to/schema')
|
|
20
20
|
|
|
21
|
-
await client.deploy(
|
|
22
|
-
schema:
|
|
23
|
-
})
|
|
21
|
+
await client.deploy('folder/name', {
|
|
22
|
+
schema: 'folder/name',
|
|
23
|
+
})
|
|
24
24
|
|
|
25
|
-
await client.deploy(
|
|
26
|
-
configurationsets: [
|
|
27
|
-
schema:
|
|
28
|
-
})
|
|
29
|
-
})()
|
|
25
|
+
await client.deploy('folder/name', {
|
|
26
|
+
configurationsets: ['folder/name', 'stepzen/defaults'],
|
|
27
|
+
schema: 'folder/name',
|
|
28
|
+
})
|
|
29
|
+
})()
|
|
30
30
|
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SDKConfiguration, StepZenAccount } from '../shared/types';
|
|
2
|
+
declare const _default: (account: StepZenAccount, sdkConfig: SDKConfiguration) => Promise<{
|
|
3
|
+
account: string;
|
|
4
|
+
apikey: string;
|
|
5
|
+
} | {
|
|
6
|
+
success: false;
|
|
7
|
+
errors: string[];
|
|
8
|
+
}>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const debug = require("debug");
|
|
5
|
+
const node_fetch_1 = require("node-fetch");
|
|
6
|
+
const constants_1 = require("../shared/constants");
|
|
7
|
+
const request_1 = require("../shared/request");
|
|
8
|
+
exports.default = async (account, sdkConfig) => {
|
|
9
|
+
const headers = request_1.getRequestHeaders(account, sdkConfig);
|
|
10
|
+
const url = `${account.server}${constants_1.ADMIN_ACCOUNT_URL}`;
|
|
11
|
+
debug('stepzen:headers')(headers);
|
|
12
|
+
const response = await node_fetch_1.default(url, {
|
|
13
|
+
headers: headers,
|
|
14
|
+
method: 'POST',
|
|
15
|
+
});
|
|
16
|
+
debug('stepzen:response')(response);
|
|
17
|
+
if (response.status >= 400 && response.status < 500) {
|
|
18
|
+
throw new Error('Could not complete the request. Please check your authentication details are correct.');
|
|
19
|
+
}
|
|
20
|
+
if (response.status >= 500) {
|
|
21
|
+
return {
|
|
22
|
+
errors: [response.statusText],
|
|
23
|
+
success: false,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const text = await response.text();
|
|
27
|
+
let json;
|
|
28
|
+
try {
|
|
29
|
+
json = JSON.parse(text);
|
|
30
|
+
}
|
|
31
|
+
catch (_a) {
|
|
32
|
+
return {
|
|
33
|
+
errors: [`An unexpected error occurred.\n\n${text}`],
|
|
34
|
+
success: false,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return json;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/commands/account.ts"],"names":[],"mappings":";AAAA,8CAA8C;;AAE9C,+BAA8B;AAC9B,2CAA8B;AAE9B,mDAAqD;AACrD,+CAAmD;AAGnD,kBAAe,KAAK,EAClB,OAAuB,EACvB,SAA2B,EAG3B,EAAE;IACF,MAAM,OAAO,GAAG,2BAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IACrD,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,GAAG,6BAAiB,EAAE,CAAA;IAEnD,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;IAEjC,MAAM,QAAQ,GAAG,MAAM,oBAAK,CAAC,GAAG,EAAE;QAChC,OAAO,EAAE,OAAc;QACvB,MAAM,EAAE,MAAM;KACf,CAAC,CAAA;IAEF,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,CAAA;IAEnC,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;QACnD,MAAM,IAAI,KAAK,CACb,uFAAuF,CACxF,CAAA;KACF;IAED,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE;QAC1B,OAAO;YACL,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC7B,OAAO,EAAE,KAAK;SACf,CAAA;KACF;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAClC,IAAI,IAAI,CAAA;IAER,IAAI;QACF,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;KACxB;IAAC,WAAM;QACN,OAAO;YACL,MAAM,EAAE,CAAC,oCAAoC,IAAI,EAAE,CAAC;YACpD,OAAO,EAAE,KAAK;SACf,CAAA;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { StepZenAccount } from
|
|
2
|
-
declare const _default: (settings: StepZenAccount) => Promise<boolean>;
|
|
1
|
+
import { SDKConfiguration, StepZenAccount } from '../shared/types';
|
|
2
|
+
declare const _default: (settings: StepZenAccount, sdkConfig: SDKConfiguration) => Promise<boolean>;
|
|
3
3
|
export default _default;
|
|
@@ -5,15 +5,15 @@ const debug = require("debug");
|
|
|
5
5
|
const node_fetch_1 = require("node-fetch");
|
|
6
6
|
const constants_1 = require("../shared/constants");
|
|
7
7
|
const request_1 = require("../shared/request");
|
|
8
|
-
exports.default = async (settings) => {
|
|
9
|
-
const headers = request_1.getRequestHeaders(settings);
|
|
8
|
+
exports.default = async (settings, sdkConfig) => {
|
|
9
|
+
const headers = request_1.getRequestHeaders(settings, sdkConfig);
|
|
10
10
|
const url = `${settings.server}${constants_1.ADMIN_VERIFY_URL}`;
|
|
11
|
-
debug(
|
|
12
|
-
debug(
|
|
11
|
+
debug('stepzen:headers')(headers);
|
|
12
|
+
debug('stepzen:url')(url);
|
|
13
13
|
try {
|
|
14
14
|
const response = await node_fetch_1.default(url, {
|
|
15
15
|
headers: headers,
|
|
16
|
-
method:
|
|
16
|
+
method: 'POST',
|
|
17
17
|
});
|
|
18
18
|
await response.json();
|
|
19
19
|
return true;
|
|
@@ -22,3 +22,4 @@ exports.default = async (settings) => {
|
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
+
//# sourceMappingURL=authenticate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../src/commands/authenticate.ts"],"names":[],"mappings":";AAAA,8CAA8C;;AAE9C,+BAA8B;AAC9B,2CAA8B;AAE9B,mDAAoD;AACpD,+CAAmD;AAGnD,kBAAe,KAAK,EAClB,QAAwB,EACxB,SAA2B,EACT,EAAE;IACpB,MAAM,OAAO,GAAG,2BAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;IACtD,MAAM,GAAG,GAAG,GAAG,QAAQ,CAAC,MAAM,GAAG,4BAAgB,EAAE,CAAA;IAEnD,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;IACjC,KAAK,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAA;IAEzB,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,oBAAK,CAAC,GAAG,EAAE;YAChC,OAAO,EAAE,OAAc;YACvB,MAAM,EAAE,MAAM;SACf,CAAC,CAAA;QACF,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QACrB,OAAO,IAAI,CAAA;KACZ;IAAC,WAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC,CAAA"}
|
package/lib/commands/deploy.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { StepZenAccount, StepZenDeploy, ZenCtlResponse } from
|
|
2
|
-
declare const _default: (details: StepZenDeploy, account: StepZenAccount) => Promise<ZenCtlResponse>;
|
|
1
|
+
import { SDKConfiguration, StepZenAccount, StepZenDeploy, ZenCtlResponse } from '../shared/types';
|
|
2
|
+
declare const _default: (details: StepZenDeploy, account: StepZenAccount, sdkConfig: SDKConfiguration) => Promise<ZenCtlResponse>;
|
|
3
3
|
export default _default;
|
package/lib/commands/deploy.js
CHANGED
|
@@ -5,24 +5,24 @@ const debug = require("debug");
|
|
|
5
5
|
const node_fetch_1 = require("node-fetch");
|
|
6
6
|
const constants_1 = require("../shared/constants");
|
|
7
7
|
const request_1 = require("../shared/request");
|
|
8
|
-
exports.default = async (details, account) => {
|
|
9
|
-
const headers = request_1.getRequestHeaders(account);
|
|
8
|
+
exports.default = async (details, account, sdkConfig) => {
|
|
9
|
+
const headers = request_1.getRequestHeaders(account, sdkConfig);
|
|
10
10
|
const payload = {
|
|
11
11
|
schema: `/workspaces/schemas/${details.schema}`,
|
|
12
12
|
};
|
|
13
13
|
if (details.configurationsets) {
|
|
14
|
-
payload.configurationsets = details.configurationsets.map(
|
|
14
|
+
payload.configurationsets = details.configurationsets.map(config => `/workspaces/configurationsets/${config}`);
|
|
15
15
|
}
|
|
16
|
-
debug(
|
|
17
|
-
debug(
|
|
16
|
+
debug('stepzen:headers')(headers);
|
|
17
|
+
debug('stepzen:payload')(payload);
|
|
18
18
|
const response = await node_fetch_1.default(`${account.server}${constants_1.ADMIN_DEPLOY_URL}/${details.destination}`, {
|
|
19
19
|
body: JSON.stringify(payload),
|
|
20
20
|
headers: headers,
|
|
21
|
-
method:
|
|
21
|
+
method: 'POST',
|
|
22
22
|
});
|
|
23
|
-
debug(
|
|
23
|
+
debug('stepzen:response')(response);
|
|
24
24
|
if (response.status >= 400 && response.status < 500) {
|
|
25
|
-
throw new Error(
|
|
25
|
+
throw new Error('Could not complete the request. Please check your authentication details are correct.');
|
|
26
26
|
}
|
|
27
27
|
if (response.status >= 500) {
|
|
28
28
|
return {
|
|
@@ -43,3 +43,4 @@ exports.default = async (details, account) => {
|
|
|
43
43
|
}
|
|
44
44
|
return json;
|
|
45
45
|
};
|
|
46
|
+
//# sourceMappingURL=deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":";AAAA,8CAA8C;;AAE9C,+BAA8B;AAC9B,2CAA8B;AAE9B,mDAAoD;AACpD,+CAAmD;AAQnD,kBAAe,KAAK,EAClB,OAAsB,EACtB,OAAuB,EACvB,SAA2B,EACF,EAAE;IAC3B,MAAM,OAAO,GAAG,2BAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAErD,MAAM,OAAO,GAAQ;QACnB,MAAM,EAAE,uBAAuB,OAAO,CAAC,MAAM,EAAE;KAChD,CAAA;IAED,IAAI,OAAO,CAAC,iBAAiB,EAAE;QAC7B,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG,CACvD,MAAM,CAAC,EAAE,CAAC,iCAAiC,MAAM,EAAE,CACpD,CAAA;KACF;IAED,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;IACjC,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;IAEjC,MAAM,QAAQ,GAAG,MAAM,oBAAK,CAC1B,GAAG,OAAO,CAAC,MAAM,GAAG,4BAAgB,IAAI,OAAO,CAAC,WAAW,EAAE,EAC7D;QACE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAC7B,OAAO,EAAE,OAAc;QACvB,MAAM,EAAE,MAAM;KACf,CACF,CAAA;IAED,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,CAAA;IAEnC,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;QACnD,MAAM,IAAI,KAAK,CACb,uFAAuF,CACxF,CAAA;KACF;IAED,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE;QAC1B,OAAO;YACL,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC7B,OAAO,EAAE,KAAK;SACf,CAAA;KACF;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAClC,IAAI,IAAI,CAAA;IAER,IAAI;QACF,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;KACxB;IAAC,WAAM;QACN,OAAO;YACL,MAAM,EAAE,CAAC,oCAAoC,IAAI,EAAE,CAAC;YACpD,OAAO,EAAE,KAAK;SACf,CAAA;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
package/lib/commands/list.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { StepZenAccount, StepZenList, ZenCtlResponse } from
|
|
2
|
-
declare const _default: (details: StepZenList, account: StepZenAccount) => Promise<ZenCtlResponse>;
|
|
1
|
+
import { SDKConfiguration, StepZenAccount, StepZenList, ZenCtlResponse } from '../shared/types';
|
|
2
|
+
declare const _default: (details: StepZenList, account: StepZenAccount, sdkConfig: SDKConfiguration) => Promise<ZenCtlResponse>;
|
|
3
3
|
export default _default;
|
package/lib/commands/list.js
CHANGED
|
@@ -5,16 +5,16 @@ const debug = require("debug");
|
|
|
5
5
|
const node_fetch_1 = require("node-fetch");
|
|
6
6
|
const constants_1 = require("../shared/constants");
|
|
7
7
|
const request_1 = require("../shared/request");
|
|
8
|
-
exports.default = async (details, account) => {
|
|
9
|
-
const headers = request_1.getRequestHeaders(account);
|
|
10
|
-
debug(
|
|
8
|
+
exports.default = async (details, account, sdkConfig) => {
|
|
9
|
+
const headers = request_1.getRequestHeaders(account, sdkConfig);
|
|
10
|
+
debug('stepzen:headers')(headers);
|
|
11
11
|
const response = await node_fetch_1.default(`${account.server}${constants_1.ADMIN_LIST_URL}/${details.type}`, {
|
|
12
12
|
headers: headers,
|
|
13
|
-
method:
|
|
13
|
+
method: 'GET',
|
|
14
14
|
});
|
|
15
|
-
debug(
|
|
15
|
+
debug('stepzen:response')(response);
|
|
16
16
|
if (response.status >= 400 && response.status < 500) {
|
|
17
|
-
throw new Error(
|
|
17
|
+
throw new Error('Could not complete the request. Please check your authentication details are correct.');
|
|
18
18
|
}
|
|
19
19
|
const text = await response.text();
|
|
20
20
|
let json;
|
|
@@ -26,3 +26,4 @@ exports.default = async (details, account) => {
|
|
|
26
26
|
}
|
|
27
27
|
return json;
|
|
28
28
|
};
|
|
29
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":";AAAA,8CAA8C;;AAE9C,+BAA8B;AAC9B,2CAA8B;AAE9B,mDAAkD;AAClD,+CAAmD;AAQnD,kBAAe,KAAK,EAClB,OAAoB,EACpB,OAAuB,EACvB,SAA2B,EACF,EAAE;IAC3B,MAAM,OAAO,GAAG,2BAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAErD,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;IAEjC,MAAM,QAAQ,GAAG,MAAM,oBAAK,CAC1B,GAAG,OAAO,CAAC,MAAM,GAAG,0BAAc,IAAI,OAAO,CAAC,IAAI,EAAE,EACpD;QACE,OAAO,EAAE,OAAc;QACvB,MAAM,EAAE,KAAK;KACd,CACF,CAAA;IAED,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,CAAA;IAEnC,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;QACnD,MAAM,IAAI,KAAK,CACb,uFAAuF,CACxF,CAAA;KACF;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAClC,IAAI,IAAI,CAAA;IAER,IAAI;QACF,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;KACxB;IAAC,WAAM;QACN,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
package/lib/commands/upload.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { StepZenAccount, StepZenUpload, ZenCtlResponse } from
|
|
2
|
-
declare const _default: (details: StepZenUpload, account: StepZenAccount) => Promise<ZenCtlResponse>;
|
|
1
|
+
import { SDKConfiguration, StepZenAccount, StepZenUpload, ZenCtlResponse } from '../shared/types';
|
|
2
|
+
declare const _default: (details: StepZenUpload, account: StepZenAccount, sdkConfig: SDKConfiguration) => Promise<ZenCtlResponse>;
|
|
3
3
|
export default _default;
|
package/lib/commands/upload.js
CHANGED
|
@@ -8,14 +8,14 @@ const payloads_1 = require("../shared/payloads");
|
|
|
8
8
|
const request_1 = require("../shared/request");
|
|
9
9
|
const transpiling_1 = require("../shared/transpiling");
|
|
10
10
|
const validation_1 = require("../shared/validation");
|
|
11
|
-
exports.default = async (details, account) => {
|
|
12
|
-
const headers = request_1.getRequestHeaders(account);
|
|
11
|
+
exports.default = async (details, account, sdkConfig) => {
|
|
12
|
+
const headers = request_1.getRequestHeaders(account, sdkConfig);
|
|
13
13
|
let payload;
|
|
14
14
|
switch (details.type) {
|
|
15
|
-
case
|
|
15
|
+
case 'configurationset':
|
|
16
16
|
await validation_1.validateConfigurationset(details.file);
|
|
17
17
|
const transpiled = await transpiling_1.transpileConfigurationset(details.file);
|
|
18
|
-
debug(
|
|
18
|
+
debug('stepzen:transpiler')(transpiled);
|
|
19
19
|
if (transpiled) {
|
|
20
20
|
payload = await payloads_1.generateYamlPayload(transpiled);
|
|
21
21
|
}
|
|
@@ -23,31 +23,31 @@ exports.default = async (details, account) => {
|
|
|
23
23
|
payload = await payloads_1.generateYamlPayload(details.file);
|
|
24
24
|
}
|
|
25
25
|
break;
|
|
26
|
-
case
|
|
26
|
+
case 'schema':
|
|
27
27
|
await validation_1.validateSchema(details.directory);
|
|
28
28
|
payload = await payloads_1.generateZipPayload(details.directory, {
|
|
29
29
|
destination: details.destination,
|
|
30
|
-
stitcherName:
|
|
30
|
+
stitcherName: 'index.graphql',
|
|
31
31
|
}, [/.*\.graphql$/i]);
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
|
-
debug(
|
|
35
|
-
debug(
|
|
34
|
+
debug('stepzen:headers')(headers);
|
|
35
|
+
debug('stepzen:payload')(payload);
|
|
36
36
|
const response = await node_fetch_1.default(`${account.server}${constants_1.ADMIN_UPLOAD_URL}/${details.type}/${details.destination}`, {
|
|
37
37
|
body: payload,
|
|
38
38
|
headers: headers,
|
|
39
|
-
method:
|
|
39
|
+
method: 'POST',
|
|
40
40
|
});
|
|
41
|
-
debug(
|
|
41
|
+
debug('stepzen:response')(response);
|
|
42
42
|
if (response.status >= 400 && response.status < 500) {
|
|
43
43
|
return {
|
|
44
|
-
message:
|
|
44
|
+
message: 'Could not complete the request. Please check your authentication details are correct.',
|
|
45
45
|
success: false,
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
if (response.status >= 500) {
|
|
49
49
|
return {
|
|
50
|
-
errors: [
|
|
50
|
+
errors: ['Internal Server Error'],
|
|
51
51
|
message: response.statusText,
|
|
52
52
|
success: false,
|
|
53
53
|
};
|
|
@@ -66,3 +66,4 @@ exports.default = async (details, account) => {
|
|
|
66
66
|
}
|
|
67
67
|
return json;
|
|
68
68
|
};
|
|
69
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../src/commands/upload.ts"],"names":[],"mappings":";AAAA,8CAA8C;;AAE9C,+BAA8B;AAC9B,2CAA8B;AAE9B,mDAAoD;AACpD,iDAA0E;AAC1E,+CAAmD;AAOnD,uDAA+D;AAC/D,qDAA6E;AAE7E,kBAAe,KAAK,EAClB,OAAsB,EACtB,OAAuB,EACvB,SAA2B,EACF,EAAE;IAC3B,MAAM,OAAO,GAAG,2BAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IACrD,IAAI,OAAO,CAAA;IAEX,QAAQ,OAAO,CAAC,IAAI,EAAE;QACpB,KAAK,kBAAkB;YACrB,MAAM,qCAAwB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAC5C,MAAM,UAAU,GAAG,MAAM,uCAAyB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAChE,KAAK,CAAC,oBAAoB,CAAC,CAAC,UAAU,CAAC,CAAA;YACvC,IAAI,UAAU,EAAE;gBACd,OAAO,GAAG,MAAM,8BAAmB,CAAC,UAAU,CAAC,CAAA;aAChD;iBAAM;gBACL,OAAO,GAAG,MAAM,8BAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;aAClD;YACD,MAAK;QAEP,KAAK,QAAQ;YACX,MAAM,2BAAc,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;YACvC,OAAO,GAAG,MAAM,6BAAkB,CAChC,OAAO,CAAC,SAAS,EACjB;gBACE,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,YAAY,EAAE,eAAe;aAC9B,EACD,CAAC,eAAe,CAAC,CAClB,CAAA;YACD,MAAK;KACR;IAED,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from './shared/types';
|
|
2
|
+
export * from './shared/types';
|
|
3
|
+
export declare const init: (sdkConfig: SDKConfiguration) => {
|
|
4
|
+
verify: (account: string, adminkey: string) => Promise<boolean>;
|
|
5
|
+
client: (options: Pick<StepZenAccount, 'account' | 'adminkey'> & Partial<StepZenAccount>) => Promise<{
|
|
6
|
+
account: () => Promise<{
|
|
7
|
+
account: string;
|
|
8
|
+
apikey: string;
|
|
9
|
+
} | {
|
|
10
|
+
success: false;
|
|
11
|
+
errors: string[];
|
|
12
|
+
}>;
|
|
6
13
|
deploy: (destination: string, properties: {
|
|
7
14
|
configurationsets?: string[];
|
|
8
15
|
schema: string;
|
|
@@ -17,4 +24,14 @@ declare const stepzen: {
|
|
|
17
24
|
};
|
|
18
25
|
}>;
|
|
19
26
|
};
|
|
27
|
+
declare type PromisedType<T> = T extends Promise<infer U> ? U : T;
|
|
28
|
+
export declare type SDK = ReturnType<typeof init>;
|
|
29
|
+
export declare type SDKClient = PromisedType<ReturnType<SDK['client']>>;
|
|
30
|
+
/**
|
|
31
|
+
* The default SDK instance that does not know the name of the app using the SDK.
|
|
32
|
+
* It tries to guess the app name from `process.argv`
|
|
33
|
+
*
|
|
34
|
+
* @deprecated use the init({appName: 'my-app/1.2.3'}) method to initialis an SDK instance
|
|
35
|
+
*/
|
|
36
|
+
declare const stepzen: SDK;
|
|
20
37
|
export default stepzen;
|
package/lib/index.js
CHANGED
|
@@ -1,48 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.init = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const account_1 = require("./commands/account");
|
|
4
8
|
const authenticate_1 = require("./commands/authenticate");
|
|
5
9
|
const deploy_1 = require("./commands/deploy");
|
|
6
10
|
const list_1 = require("./commands/list");
|
|
7
11
|
const upload_1 = require("./commands/upload");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
tslib_1.__exportStar(require("./shared/types"), exports);
|
|
13
|
+
const init = (sdkConfig) => {
|
|
14
|
+
const defaults = {
|
|
15
|
+
domain: process.env.STEPZEN_DOMAIN || 'stepzen.io',
|
|
16
|
+
server: process.env.STEPZEN_SERVER_URL || 'https://{account}.stepzen.io',
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
verify: (account, adminkey) => {
|
|
20
|
+
return authenticate_1.default({
|
|
21
|
+
account,
|
|
22
|
+
adminkey,
|
|
23
|
+
server: defaults.server.replace('{account}', account),
|
|
24
|
+
domain: defaults.domain,
|
|
25
|
+
}, sdkConfig);
|
|
26
|
+
},
|
|
27
|
+
client: async (options) => {
|
|
28
|
+
if (!options.account) {
|
|
29
|
+
throw new Error('You must provide an account.');
|
|
30
|
+
}
|
|
31
|
+
if (!options.adminkey) {
|
|
32
|
+
throw new Error('You must provide an admin key.');
|
|
33
|
+
}
|
|
34
|
+
const account = Object.assign(Object.assign({}, defaults), options);
|
|
35
|
+
account.server = account.server.replace('{account}', options.account);
|
|
36
|
+
const authorised = await authenticate_1.default(account, sdkConfig);
|
|
37
|
+
if (!authorised) {
|
|
38
|
+
throw new Error('Your credentials are invalid.');
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
account: () => {
|
|
42
|
+
return account_1.default(account, sdkConfig);
|
|
31
43
|
},
|
|
32
|
-
|
|
33
|
-
return
|
|
44
|
+
deploy: (destination, properties) => {
|
|
45
|
+
return deploy_1.default(Object.assign({ destination }, properties), account, sdkConfig);
|
|
34
46
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
list: {
|
|
48
|
+
configurationsets: async () => {
|
|
49
|
+
return list_1.default({ type: 'configurationsets' }, account, sdkConfig);
|
|
50
|
+
},
|
|
51
|
+
schemas: async () => {
|
|
52
|
+
return list_1.default({ type: 'schemas' }, account, sdkConfig);
|
|
53
|
+
},
|
|
39
54
|
},
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
upload: {
|
|
56
|
+
configurationset: async (destination, file) => {
|
|
57
|
+
return upload_1.default({ type: 'configurationset', destination, file }, account, sdkConfig);
|
|
58
|
+
},
|
|
59
|
+
schema: async (destination, directory) => {
|
|
60
|
+
return upload_1.default({ type: 'schema', destination, directory }, account, sdkConfig);
|
|
61
|
+
},
|
|
42
62
|
},
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
};
|
|
46
66
|
};
|
|
67
|
+
exports.init = init;
|
|
68
|
+
/**
|
|
69
|
+
* The default SDK instance that does not know the name of the app using the SDK.
|
|
70
|
+
* It tries to guess the app name from `process.argv`
|
|
71
|
+
*
|
|
72
|
+
* @deprecated use the init({appName: 'my-app/1.2.3'}) method to initialis an SDK instance
|
|
73
|
+
*/
|
|
74
|
+
const stepzen = exports.init({
|
|
75
|
+
// For legacy apps use the script name (e.g. `index.js` as the app name)
|
|
76
|
+
// Fallback to `node` if this file is imported into an interactive node shell
|
|
77
|
+
appName: path.basename(process.argv[1] || process.argv[0]),
|
|
78
|
+
});
|
|
47
79
|
exports.default = stepzen;
|
|
48
|
-
|
|
80
|
+
// Hack: support both ESM-style imports: `import stepzen from '@stepzen/sdk'`
|
|
81
|
+
// and keep the backwards-compat with CJS-style imports: `const stepzen = require('@stepzen/sdk')`
|
|
82
|
+
// NOTE: if at any point in the future there is a name collision between `stepzen` and ES exports
|
|
83
|
+
// this hack will break
|
|
84
|
+
module.exports = Object.assign(Object.assign({}, module.exports), stepzen);
|
|
85
|
+
//# 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,8CAA8C;;;;AAE9C,6BAA4B;AAC5B,gDAA+C;AAC/C,0DAAkD;AAClD,8CAAsC;AAEtC,0CAAkC;AAClC,8CAAsC;AAEtC,yDAA8B;AAEvB,MAAM,IAAI,GAAG,CAAC,SAA2B,EAAE,EAAE;IAClD,MAAM,QAAQ,GAAG;QACf,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,YAAY;QAClD,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,8BAA8B;KACzE,CAAA;IAED,OAAO;QACL,MAAM,EAAE,CAAC,OAAe,EAAE,QAAgB,EAAE,EAAE;YAC5C,OAAO,sBAAY,CACjB;gBACE,OAAO;gBACP,QAAQ;gBACR,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC;gBACrD,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,EACD,SAAS,CACV,CAAA;QACH,CAAC;QACD,MAAM,EAAE,KAAK,EACX,OACyB,EACzB,EAAE;YACF,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;gBACpB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;aAChD;YAED,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;gBACrB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;aAClD;YAED,MAAM,OAAO,mCACR,QAAQ,GACR,OAAO,CACX,CAAA;YAED,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;YACrE,MAAM,UAAU,GAAG,MAAM,sBAAY,C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IACxB,wEAAwE;IACxE,6EAA6E;IAC7E,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CAC3D,CAAC,CAAA;AAEF,kBAAe,OAAO,CAAA;AAEtB,6EAA6E;AAC7E,kGAAkG;AAClG,iGAAiG;AACjG,uBAAuB;AACvB,MAAM,CAAC,OAAO,mCAAO,MAAM,CAAC,OAAO,GAAK,OAAO,CAAC,CAAA"}
|
package/lib/shared/constants.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = void 0;
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
4
|
+
exports.ADMIN_VERIFY_URL = exports.ADMIN_UPLOAD_URL = exports.ADMIN_LIST_URL = exports.ADMIN_DEPLOY_URL = exports.ADMIN_ACCOUNT_URL = void 0;
|
|
5
|
+
exports.ADMIN_ACCOUNT_URL = '/cli/admin/account';
|
|
6
|
+
exports.ADMIN_DEPLOY_URL = '/cli/admin/deploy';
|
|
7
|
+
exports.ADMIN_LIST_URL = '/cli/admin/list';
|
|
8
|
+
exports.ADMIN_UPLOAD_URL = '/cli/admin/upload';
|
|
9
|
+
exports.ADMIN_VERIFY_URL = '/cli/admin/verify';
|
|
10
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/shared/constants.ts"],"names":[],"mappings":";AAAA,8CAA8C;;;AAEjC,QAAA,iBAAiB,GAAG,oBAAoB,CAAA;AACxC,QAAA,gBAAgB,GAAG,mBAAmB,CAAA;AACtC,QAAA,cAAc,GAAG,iBAAiB,CAAA;AAClC,QAAA,gBAAgB,GAAG,mBAAmB,CAAA;AACtC,QAAA,gBAAgB,GAAG,mBAAmB,CAAA"}
|
package/lib/shared/payloads.d.ts
CHANGED
package/lib/shared/payloads.js
CHANGED
|
@@ -20,12 +20,12 @@ const generateYamlPayload = async (file) => {
|
|
|
20
20
|
reject(new Error(`File does not exist: ${file}`));
|
|
21
21
|
}
|
|
22
22
|
const content = fs.readFileSync(file, 'utf8');
|
|
23
|
-
debug(
|
|
24
|
-
payload.append(
|
|
23
|
+
debug('stepzen:generate-yaml-payload')(content);
|
|
24
|
+
payload.append('yaml', fs.readFileSync(file));
|
|
25
25
|
resolve(payload);
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
|
-
reject(new Error(
|
|
28
|
+
reject(new Error('File not specified'));
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
};
|
|
@@ -45,7 +45,7 @@ const generateZipPayload = async (directory, data, filters) => {
|
|
|
45
45
|
const filepath = path.join(os.tmpdir(), `stepzen-payload-${Date.now()}.zip`);
|
|
46
46
|
const output = fs.createWriteStream(filepath);
|
|
47
47
|
// We're making a zip file
|
|
48
|
-
const archive = archiver(
|
|
48
|
+
const archive = archiver('zip', {
|
|
49
49
|
zlib: { level: 9 },
|
|
50
50
|
});
|
|
51
51
|
// We're piping it to the WriteStream
|
|
@@ -56,25 +56,25 @@ const generateZipPayload = async (directory, data, filters) => {
|
|
|
56
56
|
reject(new Error(`Directory does not exist: ${directory}`));
|
|
57
57
|
}
|
|
58
58
|
// Get all the files in the directory (and all subdirectories).
|
|
59
|
-
const allFiles = glob.sync(
|
|
59
|
+
const allFiles = glob.sync('**', { cwd: directory });
|
|
60
60
|
// Loop through each file, because we want to filter them
|
|
61
61
|
// We add them manually, because when we use glob, it embeds
|
|
62
62
|
// a full path, and we want everything to explicitly
|
|
63
63
|
// start at the root of the archive.
|
|
64
|
-
allFiles.forEach(
|
|
65
|
-
const include = filters.some(
|
|
64
|
+
allFiles.forEach(file => {
|
|
65
|
+
const include = filters.some(filter => file.match(filter));
|
|
66
66
|
if (include) {
|
|
67
|
-
debug(
|
|
67
|
+
debug('stepzen:archive')(file);
|
|
68
68
|
archive.file(path.join(directory, file), { name: file });
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
// Once we're done, append a ReadStream to the tmp file
|
|
73
|
-
output.on(
|
|
73
|
+
output.on('close', () => {
|
|
74
74
|
const stream = fs.createReadStream(filepath);
|
|
75
|
-
payload.append(
|
|
75
|
+
payload.append('zip', stream);
|
|
76
76
|
// Remove the temporary zip
|
|
77
|
-
stream.on(
|
|
77
|
+
stream.on('close', () => {
|
|
78
78
|
fs.unlinkSync(filepath);
|
|
79
79
|
});
|
|
80
80
|
// This is where we return the payload
|
|
@@ -85,3 +85,4 @@ const generateZipPayload = async (directory, data, filters) => {
|
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
87
|
exports.generateZipPayload = generateZipPayload;
|
|
88
|
+
//# sourceMappingURL=payloads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payloads.js","sourceRoot":"","sources":["../../src/shared/payloads.ts"],"names":[],"mappings":";AAAA,8CAA8C;;;AAE9C,0DAA0D;AAE1D,qCAAoC;AACpC,+BAA8B;AAC9B,sCAAqC;AACrC,yBAAwB;AACxB,6BAA4B;AAC5B,yBAAwB;AACxB,6BAA4B;AAK5B,yCAAyC;AACzC,wEAAwE;AACjE,MAAM,mBAAmB,GAAG,KAAK,EACtC,IAAwB,EACF,EAAE;IACxB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,IAAI,QAAQ,EAAE,CAAA;QAE9B,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBAC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ACF,sCAAsC;YACtC,OAAO,CAAC,OAAO,CAAC,CAAA;QAClB,CAAC,CAAC,CAAA;QAEF,gCAAgC;QAChC,OAAO,CAAC,QAAQ,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAhEY,QAAA,kBAAkB,sBAgE9B"}
|
package/lib/shared/request.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StepZenAccount, ZenCtlRequestHeaders } from
|
|
2
|
-
export declare const getRequestHeaders: (
|
|
1
|
+
import { SDKConfiguration, StepZenAccount, ZenCtlRequestHeaders } from './types';
|
|
2
|
+
export declare const getRequestHeaders: (account: StepZenAccount, sdkConfig: SDKConfiguration) => ZenCtlRequestHeaders;
|
package/lib/shared/request.js
CHANGED
|
@@ -3,14 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.getRequestHeaders = void 0;
|
|
5
5
|
const os = require("os");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
6
|
+
const isWsl = require("is-wsl");
|
|
7
|
+
const { version } = require('../../package.json');
|
|
8
|
+
// mimics the logic from @oclif/config
|
|
9
|
+
// https://github.com/oclif/core/blob/d7067d13c7d80c9e0064455c27ac1ebb6ee53fd2/src/config/config.ts#L128
|
|
10
|
+
const arch = os.arch() === 'ia32' ? 'x86' : os.arch();
|
|
11
|
+
const platform = isWsl ? 'wsl' : os.platform();
|
|
12
|
+
const getRequestHeaders = (account, sdkConfig) => {
|
|
13
|
+
const userAgent = `${sdkConfig.appName} stepzen-sdk/${version} (${platform}; ${arch}; node-${process.version})`;
|
|
9
14
|
return {
|
|
10
|
-
authorization: `Apikey ${
|
|
11
|
-
host: `${
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
authorization: `Apikey ${account.adminkey}`,
|
|
16
|
+
host: `${account.account}.${account.domain}`,
|
|
17
|
+
'stepzen-cli-version': version,
|
|
18
|
+
'user-agent': userAgent,
|
|
14
19
|
};
|
|
15
20
|
};
|
|
16
21
|
exports.getRequestHeaders = getRequestHeaders;
|
|
22
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/shared/request.ts"],"names":[],"mappings":";AAAA,8CAA8C;;;AAE9C,yBAAwB;AACxB,gCAA+B;AAG/B,MAAM,EAAC,OAAO,EAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAE/C,sCAAsC;AACtC,wGAAwG;AACxG,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,CAAC,IAAI,EAAU,CAAA;AAC9D,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,CAAC,QAAQ,EAAU,CAAA;AAEhD,MAAM,iBAAiB,GAAG,CAC/B,OAAuB,EACvB,SAA2B,EACL,EAAE;IACxB,MAAM,SAAS,GAAG,GAAG,SAAS,CAAC,OAAO,gBAAgB,OAAO,KAAK,QAAQ,KAAK,IAAI,UAAU,OAAO,CAAC,OAAO,GAAG,CAAA;IAE/G,OAAO;QACL,aAAa,EAAE,UAAU,OAAO,CAAC,QAAQ,EAAE;QAC3C,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE;QAC5C,qBAAqB,EAAE,OAAO;QAC9B,YAAY,EAAE,SAAS;KACxB,CAAA;AACH,CAAC,CAAA;AAZY,QAAA,iBAAiB,qBAY7B"}
|