@stepzen/sdk 0.0.0-experimental-20221114-610843f6
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 +30 -0
- package/lib/client-v2.d.ts +50 -0
- package/lib/client-v2.d.ts.map +1 -0
- package/lib/client-v2.js +91 -0
- package/lib/client-v2.js.map +1 -0
- package/lib/client.d.ts +33 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +95 -0
- package/lib/client.js.map +1 -0
- package/lib/commands/account.d.ts +10 -0
- package/lib/commands/account.d.ts.map +1 -0
- package/lib/commands/account.js +39 -0
- package/lib/commands/account.js.map +1 -0
- package/lib/commands/authenticate.d.ts +4 -0
- package/lib/commands/authenticate.d.ts.map +1 -0
- package/lib/commands/authenticate.js +25 -0
- package/lib/commands/authenticate.js.map +1 -0
- package/lib/commands/deploy.d.ts +4 -0
- package/lib/commands/deploy.d.ts.map +1 -0
- package/lib/commands/deploy.js +46 -0
- package/lib/commands/deploy.js.map +1 -0
- package/lib/commands/getPublicAccount.d.ts +7 -0
- package/lib/commands/getPublicAccount.d.ts.map +1 -0
- package/lib/commands/getPublicAccount.js +59 -0
- package/lib/commands/getPublicAccount.js.map +1 -0
- package/lib/commands/list.d.ts +4 -0
- package/lib/commands/list.d.ts.map +1 -0
- package/lib/commands/list.js +29 -0
- package/lib/commands/list.js.map +1 -0
- package/lib/commands/upload.d.ts +4 -0
- package/lib/commands/upload.d.ts.map +1 -0
- package/lib/commands/upload.js +64 -0
- package/lib/commands/upload.js.map +1 -0
- package/lib/commands-v2/account.d.ts +9 -0
- package/lib/commands-v2/account.d.ts.map +1 -0
- package/lib/commands-v2/account.js +68 -0
- package/lib/commands-v2/account.js.map +1 -0
- package/lib/commands-v2/deploy.d.ts +15 -0
- package/lib/commands-v2/deploy.d.ts.map +1 -0
- package/lib/commands-v2/deploy.js +90 -0
- package/lib/commands-v2/deploy.js.map +1 -0
- package/lib/commands-v2/getPublicAccount.d.ts +8 -0
- package/lib/commands-v2/getPublicAccount.d.ts.map +1 -0
- package/lib/commands-v2/getPublicAccount.js +46 -0
- package/lib/commands-v2/getPublicAccount.js.map +1 -0
- package/lib/commands-v2/list.d.ts +12 -0
- package/lib/commands-v2/list.d.ts.map +1 -0
- package/lib/commands-v2/list.js +58 -0
- package/lib/commands-v2/list.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +26 -0
- package/lib/index.js.map +1 -0
- package/lib/init-v2.d.ts +33 -0
- package/lib/init-v2.d.ts.map +1 -0
- package/lib/init-v2.js +33 -0
- package/lib/init-v2.js.map +1 -0
- package/lib/init.d.ts +33 -0
- package/lib/init.d.ts.map +1 -0
- package/lib/init.js +31 -0
- package/lib/init.js.map +1 -0
- package/lib/shared/constants.d.ts +7 -0
- package/lib/shared/constants.d.ts.map +1 -0
- package/lib/shared/constants.js +11 -0
- package/lib/shared/constants.js.map +1 -0
- package/lib/shared/graphql-client.d.ts +38 -0
- package/lib/shared/graphql-client.d.ts.map +1 -0
- package/lib/shared/graphql-client.js +80 -0
- package/lib/shared/graphql-client.js.map +1 -0
- package/lib/shared/payloads.d.ts +10 -0
- package/lib/shared/payloads.d.ts.map +1 -0
- package/lib/shared/payloads.js +123 -0
- package/lib/shared/payloads.js.map +1 -0
- package/lib/shared/request.d.ts +4 -0
- package/lib/shared/request.d.ts.map +1 -0
- package/lib/shared/request.js +25 -0
- package/lib/shared/request.js.map +1 -0
- package/lib/shared/transpiling.d.ts +15 -0
- package/lib/shared/transpiling.d.ts.map +1 -0
- package/lib/shared/transpiling.js +29 -0
- package/lib/shared/transpiling.js.map +1 -0
- package/lib/shared/types.d.ts +194 -0
- package/lib/shared/types.d.ts.map +1 -0
- package/lib/shared/types.js +4 -0
- package/lib/shared/types.js.map +1 -0
- package/lib/shared/validation.d.ts +3 -0
- package/lib/shared/validation.d.ts.map +1 -0
- package/lib/shared/validation.js +47 -0
- package/lib/shared/validation.js.map +1 -0
- package/package.json +52 -0
- package/src/client-v2.ts +120 -0
- package/src/client.ts +133 -0
- package/src/commands/account.ts +54 -0
- package/src/commands/authenticate.ts +30 -0
- package/src/commands/deploy.ts +72 -0
- package/src/commands/getPublicAccount.ts +77 -0
- package/src/commands/list.ts +50 -0
- package/src/commands/upload.ts +91 -0
- package/src/commands-v2/account.ts +98 -0
- package/src/commands-v2/deploy.ts +145 -0
- package/src/commands-v2/getPublicAccount.ts +67 -0
- package/src/commands-v2/list.ts +91 -0
- package/src/index.ts +27 -0
- package/src/init-v2.ts +44 -0
- package/src/init.ts +45 -0
- package/src/shared/constants.ts +9 -0
- package/src/shared/graphql-client.ts +136 -0
- package/src/shared/payloads.ts +153 -0
- package/src/shared/request.ts +28 -0
- package/src/shared/transpiling.ts +49 -0
- package/src/shared/types.ts +235 -0
- package/src/shared/validation.ts +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
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,30 @@
|
|
|
1
|
+
# @stepzen/sdk
|
|
2
|
+
|
|
3
|
+
## Usage
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
const stepzen = require('@stepzen/sdk')
|
|
7
|
+
|
|
8
|
+
const ACCOUNT = '<account>'
|
|
9
|
+
const ADMIN_KEY = '<admin key>'
|
|
10
|
+
|
|
11
|
+
(async () => {
|
|
12
|
+
const client = await stepzen.client({
|
|
13
|
+
account: ACCOUNT,
|
|
14
|
+
adminkey: ADMIN_KEY,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
await client.upload.configurationset('folder/name', '/path/to/config.yaml')
|
|
18
|
+
|
|
19
|
+
await client.upload.schema('folder/name', '/path/to/schema')
|
|
20
|
+
|
|
21
|
+
await client.deploy('folder/name', {
|
|
22
|
+
schema: 'folder/name',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
await client.deploy('folder/name', {
|
|
26
|
+
configurationsets: ['folder/name', 'stepzen/defaults'],
|
|
27
|
+
schema: 'folder/name',
|
|
28
|
+
})
|
|
29
|
+
})()
|
|
30
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { SDKConfigurationV2 } from './shared/types';
|
|
2
|
+
export declare const ensureValidCredentials: (auth: {
|
|
3
|
+
account: string;
|
|
4
|
+
adminKey: string;
|
|
5
|
+
deploymentType: string;
|
|
6
|
+
} | {
|
|
7
|
+
publicAccountToken: string;
|
|
8
|
+
deploymentType: string;
|
|
9
|
+
}, sdkConfig: SDKConfigurationV2) => Promise<import("./shared/types").StepZenCredentialsV2>;
|
|
10
|
+
export declare const createSdkClient: (auth: {
|
|
11
|
+
account: string;
|
|
12
|
+
adminKey: string;
|
|
13
|
+
deploymentType: string;
|
|
14
|
+
} | {
|
|
15
|
+
publicAccountToken: string;
|
|
16
|
+
deploymentType: string;
|
|
17
|
+
}, sdkConfig: SDKConfigurationV2) => Promise<{
|
|
18
|
+
readonly credentials: import("./shared/types").StepZenCredentialsV2;
|
|
19
|
+
/**
|
|
20
|
+
* Create or update a GraphQL endpoint at StepZen.
|
|
21
|
+
* The URL of the endpoint is formed as {StepZen instance URL}/{folder}/{name}/__graphql
|
|
22
|
+
* e.g. https://account.stepzen.net/api/users/__graphql
|
|
23
|
+
*
|
|
24
|
+
* @param folder - folder name (e.g. `api`); will be a part of the endpoint URL
|
|
25
|
+
* @param name - endpoint name (e.g. `users`); will be a part of the endpoint URL
|
|
26
|
+
* @param directory - full path to a GraphQL schema directory (should have `index.graphql` in it)
|
|
27
|
+
* @param config - full path to a config `.yml` file
|
|
28
|
+
* @param public - whether or not to allow public access to the endpoint (`false` by default)
|
|
29
|
+
* @returns details of the created / updated endpoint
|
|
30
|
+
*/
|
|
31
|
+
deploy: ({ folder, name, directory, config, public: _public, }: {
|
|
32
|
+
folder: string;
|
|
33
|
+
name: string;
|
|
34
|
+
directory: string;
|
|
35
|
+
config?: string | undefined;
|
|
36
|
+
public?: boolean | undefined;
|
|
37
|
+
}) => Promise<import("./shared/types").ZenCtlResponseV2<import("./shared/types").StepZenEndpointV2>>;
|
|
38
|
+
list: {
|
|
39
|
+
/**
|
|
40
|
+
* List deployed endpoints.
|
|
41
|
+
*
|
|
42
|
+
* @returns list of deployed endpoints
|
|
43
|
+
*/
|
|
44
|
+
endpoints: () => Promise<import("./shared/types").ZenCtlResponseV2<{
|
|
45
|
+
folderName: string;
|
|
46
|
+
endpointName: string;
|
|
47
|
+
}[]>>;
|
|
48
|
+
};
|
|
49
|
+
}>;
|
|
50
|
+
//# sourceMappingURL=client-v2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-v2.d.ts","sourceRoot":"","sources":["../src/client-v2.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAA;AAEjD,eAAO,MAAM,sBAAsB,SAE7B;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAC,GAC3D;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAC,aAC7C,kBAAkB,2DAkC9B,CAAA;AAED,eAAO,MAAM,eAAe,SAEtB;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAC,GAC3D;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAC,aAC7C,kBAAkB;;IAS3B;;;;;;;;;;;OAWG;;gBAQO,MAAM;cACR,MAAM;mBACD,MAAM;;;;;QAkBjB;;;;WAIG;;;;;;EAWR,CAAA"}
|
package/lib/client-v2.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.createSdkClient = exports.ensureValidCredentials = void 0;
|
|
5
|
+
const account_1 = require("./commands-v2/account");
|
|
6
|
+
const deploy_1 = require("./commands-v2/deploy");
|
|
7
|
+
const list_1 = require("./commands-v2/list");
|
|
8
|
+
const getPublicAccount_1 = require("./commands-v2/getPublicAccount");
|
|
9
|
+
const payloads_1 = require("./shared/payloads");
|
|
10
|
+
const ensureValidCredentials = async (auth, sdkConfig) => {
|
|
11
|
+
let credentials;
|
|
12
|
+
if ('publicAccountToken' in auth) {
|
|
13
|
+
// create an anonymous account and use it to initialize an SDK client instance
|
|
14
|
+
const { data, error } = await (0, getPublicAccount_1.default)({
|
|
15
|
+
token: auth.publicAccountToken,
|
|
16
|
+
deploymentType: auth.deploymentType,
|
|
17
|
+
sdkConfig,
|
|
18
|
+
});
|
|
19
|
+
if (error) {
|
|
20
|
+
throw new Error(`An unexpected error occurred: ${error.message}`);
|
|
21
|
+
}
|
|
22
|
+
credentials = data;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
// use the provided account to initialize an SDK client instance
|
|
26
|
+
const { data, error } = await (0, account_1.default)({
|
|
27
|
+
account: auth.account,
|
|
28
|
+
adminKey: auth.adminKey,
|
|
29
|
+
deploymentType: auth.deploymentType,
|
|
30
|
+
sdkConfig,
|
|
31
|
+
});
|
|
32
|
+
if (error) {
|
|
33
|
+
throw new Error(error.message);
|
|
34
|
+
}
|
|
35
|
+
credentials = data;
|
|
36
|
+
}
|
|
37
|
+
return credentials;
|
|
38
|
+
};
|
|
39
|
+
exports.ensureValidCredentials = ensureValidCredentials;
|
|
40
|
+
const createSdkClient = async (auth, sdkConfig) => {
|
|
41
|
+
const credentials = await (0, exports.ensureValidCredentials)(auth, sdkConfig);
|
|
42
|
+
return {
|
|
43
|
+
get credentials() {
|
|
44
|
+
// always return a copy to avoid accidential modification by the caller
|
|
45
|
+
return { ...credentials };
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Create or update a GraphQL endpoint at StepZen.
|
|
49
|
+
* The URL of the endpoint is formed as {StepZen instance URL}/{folder}/{name}/__graphql
|
|
50
|
+
* e.g. https://account.stepzen.net/api/users/__graphql
|
|
51
|
+
*
|
|
52
|
+
* @param folder - folder name (e.g. `api`); will be a part of the endpoint URL
|
|
53
|
+
* @param name - endpoint name (e.g. `users`); will be a part of the endpoint URL
|
|
54
|
+
* @param directory - full path to a GraphQL schema directory (should have `index.graphql` in it)
|
|
55
|
+
* @param config - full path to a config `.yml` file
|
|
56
|
+
* @param public - whether or not to allow public access to the endpoint (`false` by default)
|
|
57
|
+
* @returns details of the created / updated endpoint
|
|
58
|
+
*/
|
|
59
|
+
deploy: async ({ folder, name, directory, config, public: _public = false, }) => {
|
|
60
|
+
return (0, deploy_1.default)({
|
|
61
|
+
account: credentials.account,
|
|
62
|
+
adminKey: credentials.adminKey,
|
|
63
|
+
deploymentType: credentials.deploymentType,
|
|
64
|
+
endpointName: name,
|
|
65
|
+
endpointType: 'dev',
|
|
66
|
+
folderName: folder,
|
|
67
|
+
public: _public,
|
|
68
|
+
schemaFiles: (0, payloads_1.generateSchemaFilesPayload)(directory),
|
|
69
|
+
configuration: await (0, payloads_1.generateConfigurationPayload)(config),
|
|
70
|
+
sdkConfig,
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
list: {
|
|
74
|
+
/**
|
|
75
|
+
* List deployed endpoints.
|
|
76
|
+
*
|
|
77
|
+
* @returns list of deployed endpoints
|
|
78
|
+
*/
|
|
79
|
+
endpoints: () => {
|
|
80
|
+
return (0, list_1.default)({
|
|
81
|
+
account: credentials.account,
|
|
82
|
+
adminKey: credentials.adminKey,
|
|
83
|
+
deploymentType: credentials.deploymentType,
|
|
84
|
+
sdkConfig,
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
exports.createSdkClient = createSdkClient;
|
|
91
|
+
//# sourceMappingURL=client-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-v2.js","sourceRoot":"","sources":["../src/client-v2.ts"],"names":[],"mappings":";AAAA,8CAA8C;;;AAE9C,mDAA8C;AAC9C,iDAA4C;AAC5C,6CAAiD;AACjD,qEAA6D;AAC7D,gDAG0B;AAGnB,MAAM,sBAAsB,GAAG,KAAK,EACzC,IAEwD,EACxD,SAA6B,EAC7B,EAAE;IACF,IAAI,WAAW,CAAA;IAEf,IAAI,oBAAoB,IAAI,IAAI,EAAE;QAChC,8EAA8E;QAC9E,MAAM,EAAC,IAAI,EAA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cAAc,EAAE,WAAW,CAAC,cAAc;gBAC1C,YAAY,EAAE,IAAI;gBAClB,YAAY,EAAE,KAAK;gBACnB,UAAU,EAAE,MAAM;gBAClB,MAAM,EAAE,OAAO;gBACf,WAAW,EAAE,IAAA,qCAA0B,EAAC,SAAS,CAAC;gBAClD,aAAa,EAAE,MAAM,IAAA,uCAA4B,EAAC,MAAM,CAAC;gBACzD,SAAS;aACV,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,EAAE;YACJ;;;;eAIG;YACH,SAAS,EAAE,GAAG,EAAE;gBACd,OAAO,IAAA,cAAgB,EAAC;oBACtB,OAAO,EAAE,WAAW,CAAC,OAAO;oBAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;oBAC9B,cAAc,EAAE,WAAW,CAAC,cAAc;oBAC1C,SAAS;iBACV,CAAC,CAAA;YACJ,CAAC;SACF;KACF,CAAA;AACH,CAAC,CAAA;AAnEY,QAAA,eAAe,mBAmE3B"}
|
package/lib/client.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AnonymousClientOptions, SDKConfiguration, StepZenAccount } from './shared/types';
|
|
2
|
+
export * from './shared/types';
|
|
3
|
+
export declare const validateCreateClientOptions: (options: StepZenAccount | Required<AnonymousClientOptions>, sdkConfig: SDKConfiguration) => Promise<{
|
|
4
|
+
account: StepZenAccount;
|
|
5
|
+
credentials: import("./shared/types").StepZenCredentials;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const createSdkClient: (options: Required<StepZenAccount | AnonymousClientOptions>, sdkConfig: SDKConfiguration) => Promise<{
|
|
8
|
+
readonly credentials: import("./shared/types").StepZenCredentials;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated use `.credentials` or create a new SDK client instead
|
|
11
|
+
**/
|
|
12
|
+
account: () => Promise<{
|
|
13
|
+
account: string;
|
|
14
|
+
apikey: string;
|
|
15
|
+
} | {
|
|
16
|
+
success: false;
|
|
17
|
+
errors: string[];
|
|
18
|
+
}>;
|
|
19
|
+
deploy: (destination: string, properties: {
|
|
20
|
+
configurationsets?: string[];
|
|
21
|
+
schema: string;
|
|
22
|
+
}) => Promise<import("./shared/types").ZenCtlResponse>;
|
|
23
|
+
list: {
|
|
24
|
+
deployments: () => Promise<import("./shared/types").ZenCtlResponse>;
|
|
25
|
+
configurationsets: () => Promise<import("./shared/types").ZenCtlResponse>;
|
|
26
|
+
schemas: () => Promise<import("./shared/types").ZenCtlResponse>;
|
|
27
|
+
};
|
|
28
|
+
upload: {
|
|
29
|
+
configurationset: (destination: string, file: string) => Promise<import("./shared/types").ZenCtlResponse>;
|
|
30
|
+
schema: (destination: string, directory: string) => Promise<import("./shared/types").ZenCtlResponse>;
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
33
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACf,MAAM,gBAAgB,CAAA;AAKvB,cAAc,gBAAgB,CAAA;AAE9B,eAAO,MAAM,2BAA2B,YAC7B,cAAc,GAAG,SAAS,sBAAsB,CAAC,aAC/C,gBAAgB;;;EAwD5B,CAAA;AAED,eAAO,MAAM,eAAe,YACjB,SAAS,cAAc,GAAG,sBAAsB,CAAC,aAC/C,gBAAgB;;IAYzB;;QAEI;;;;;;;;0BAKW,MAAM,cACP;QACV,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;QAC5B,MAAM,EAAE,MAAM,CAAA;KACf;;;;;;;wCAgBqC,MAAM,QAAQ,MAAM;8BAO9B,MAAM,aAAa,MAAM;;EAS1D,CAAA"}
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2020,2021,2022, StepZen, Inc.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.createSdkClient = exports.validateCreateClientOptions = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const account_1 = require("./commands/account");
|
|
7
|
+
const deploy_1 = require("./commands/deploy");
|
|
8
|
+
const list_1 = require("./commands/list");
|
|
9
|
+
const upload_1 = require("./commands/upload");
|
|
10
|
+
const getPublicAccount_1 = require("./commands/getPublicAccount");
|
|
11
|
+
tslib_1.__exportStar(require("./shared/types"), exports);
|
|
12
|
+
const validateCreateClientOptions = async (options, sdkConfig) => {
|
|
13
|
+
let credentials;
|
|
14
|
+
let account;
|
|
15
|
+
if ('publicAccountToken' in options) {
|
|
16
|
+
// create an anonymous account and use it to initialize an SDK client instance
|
|
17
|
+
const credentialsOrError = await (0, getPublicAccount_1.default)(options, sdkConfig);
|
|
18
|
+
if ('errors' in credentialsOrError) {
|
|
19
|
+
throw new Error(`An unexpected error occurred. ${JSON.stringify(credentialsOrError.errors)}`);
|
|
20
|
+
}
|
|
21
|
+
credentials = credentialsOrError;
|
|
22
|
+
account = {
|
|
23
|
+
...credentialsOrError,
|
|
24
|
+
server: options.server,
|
|
25
|
+
domain: options.domain,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// use the provided account to initialize an SDK client instance
|
|
30
|
+
options.server = options.server.replace('{account}', options.account);
|
|
31
|
+
let accountOrError;
|
|
32
|
+
try {
|
|
33
|
+
accountOrError = await (0, account_1.default)(options, sdkConfig);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error instanceof Error &&
|
|
37
|
+
error.message.includes('Please check your authentication details')) {
|
|
38
|
+
throw new Error('Your credentials are invalid.');
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw new Error(`An unexpected error occurred. ${error}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if ('errors' in accountOrError) {
|
|
45
|
+
throw new Error(`An unexpected error occurred. ${JSON.stringify(accountOrError.errors)}`);
|
|
46
|
+
}
|
|
47
|
+
account = options;
|
|
48
|
+
credentials = {
|
|
49
|
+
account: options.account,
|
|
50
|
+
adminkey: options.adminkey,
|
|
51
|
+
apikey: accountOrError.apikey,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return { account, credentials };
|
|
55
|
+
};
|
|
56
|
+
exports.validateCreateClientOptions = validateCreateClientOptions;
|
|
57
|
+
const createSdkClient = async (options, sdkConfig) => {
|
|
58
|
+
const { account, credentials } = await (0, exports.validateCreateClientOptions)(options, sdkConfig);
|
|
59
|
+
return {
|
|
60
|
+
get credentials() {
|
|
61
|
+
// always return a copy to avoid accidential modification by the caller
|
|
62
|
+
return { ...credentials };
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated use `.credentials` or create a new SDK client instead
|
|
66
|
+
**/
|
|
67
|
+
account: () => {
|
|
68
|
+
return (0, account_1.default)(account, sdkConfig);
|
|
69
|
+
},
|
|
70
|
+
deploy: (destination, properties) => {
|
|
71
|
+
return (0, deploy_1.default)({ destination, ...properties }, account, sdkConfig);
|
|
72
|
+
},
|
|
73
|
+
list: {
|
|
74
|
+
deployments: async () => {
|
|
75
|
+
return (0, list_1.default)({ type: 'deployments' }, account, sdkConfig);
|
|
76
|
+
},
|
|
77
|
+
configurationsets: async () => {
|
|
78
|
+
return (0, list_1.default)({ type: 'configurationsets' }, account, sdkConfig);
|
|
79
|
+
},
|
|
80
|
+
schemas: async () => {
|
|
81
|
+
return (0, list_1.default)({ type: 'schemas' }, account, sdkConfig);
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
upload: {
|
|
85
|
+
configurationset: async (destination, file) => {
|
|
86
|
+
return (0, upload_1.default)({ type: 'configurationset', destination, file }, account, sdkConfig);
|
|
87
|
+
},
|
|
88
|
+
schema: async (destination, directory) => {
|
|
89
|
+
return (0, upload_1.default)({ type: 'schema', destination, directory }, account, sdkConfig);
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
exports.createSdkClient = createSdkClient;
|
|
95
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,8CAA8C;;;;AAE9C,gDAA+C;AAC/C,8CAAsC;AAMtC,0CAAkC;AAClC,8CAAsC;AACtC,kEAA0D;AAE1D,yDAA8B;AAEvB,MAAM,2BAA2B,GAAG,KAAK,EAC9C,OAA0D,EAC1D,SAA2B,EAC3B,EAAE;IACF,IAAI,WAAW,CAAA;IACf,IAAI,OAAO,CAAA;IAEX,IAAI,oBAAoB,IAAI,OAAO,EAAE;QACnC,8EAA8E;QAC9E,MAAM,kBAAkB,GAAG,MAAM,IAAA,0BAAgB,EAAC,OAAO,EAAE,SAAS,CAAC,CAAA;QACrE,IAAI,QAAQ,IAAI,kBAAkB,EAAE;YAClC,MAAM,IAAI,KAAK,CACb,iCAAiC,IAAI,CAAC,SAAS,CAC7C,kBAAkB,CAAC,MAAM,CAC1B,EAAE,CACJ,CAAA;SACF;QAED,WAAW,GAAG,kBAAkB,CAAA;QAChC,OAAO,GAAG;YACR,GAAG,kBAAkB;YACrB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAA;KACF;SAAM;QACL,gEAAgE;QAChE,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;QACrE,IAAI,cAAc,CAAA;QAClB,IAAI;YACF,cAAc,GAAG,MAAM,IAAA,iBAAc,EAAC,OAAO,EAAE,SAAS,CAAC,CAAA;SAC1D;QAAC,OAAO,KAAK,EAAE;YACd,IACE,KAAK,YAAY,KAAK;gBACtB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,0CAA0C,CAAC,EAClE;gBACA,MAAM,IAAI,KA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AC,CAAA;YACxD,CAAC;YACD,iBAAiB,EAAE,KAAK,IAAI,EAAE;gBAC5B,OAAO,IAAA,cAAI,EAAC,EAAC,IAAI,EAAE,mBAAmB,EAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;YAC9D,CAAC;YACD,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,OAAO,IAAA,cAAI,EAAC,EAAC,IAAI,EAAE,SAAS,EAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;YACpD,CAAC;SACF;QACD,MAAM,EAAE;YACN,gBAAgB,EAAE,KAAK,EAAE,WAAmB,EAAE,IAAY,EAAE,EAAE;gBAC5D,OAAO,IAAA,gBAAM,EACX,EAAC,IAAI,EAAE,kBAAkB,EAAE,WAAW,EAAE,IAAI,EAAC,EAC7C,OAAO,EACP,SAAS,CACV,CAAA;YACH,CAAC;YACD,MAAM,EAAE,KAAK,EAAE,WAAmB,EAAE,SAAiB,EAAE,EAAE;gBACvD,OAAO,IAAA,gBAAM,EACX,EAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAC,EACxC,OAAO,EACP,SAAS,CACV,CAAA;YACH,CAAC;SACF;KACF,CAAA;AACH,CAAC,CAAA;AAzDY,QAAA,eAAe,mBAyD3B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
10
|
+
//# sourceMappingURL=account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/commands/account.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,gBAAgB,EAAE,cAAc,EAAC,MAAM,iBAAiB,CAAA;kCAGrD,cAAc,aACZ,gBAAgB;aAEjB,MAAM;YAAU,MAAM;;aAAc,KAAK;YAAU,MAAM,EAAE;;AAJvE,wBA4CC"}
|
|
@@ -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 fetch_1 = require("@stepzen/fetch");
|
|
6
|
+
const constants_1 = require("../shared/constants");
|
|
7
|
+
const request_1 = require("../shared/request");
|
|
8
|
+
exports.default = async (account, sdkConfig) => {
|
|
9
|
+
const headers = (0, request_1.getRequestHeaders)(account, sdkConfig);
|
|
10
|
+
const url = `${account.server}${constants_1.ADMIN_ACCOUNT_URL}`;
|
|
11
|
+
debug('stepzen:headers')(headers);
|
|
12
|
+
const response = await (0, fetch_1.default)(url, {
|
|
13
|
+
headers: headers,
|
|
14
|
+
method: 'POST',
|
|
15
|
+
});
|
|
16
|
+
debug('stepzen:response')(response);
|
|
17
|
+
if (response.status === 401 || response.status === 403) {
|
|
18
|
+
throw new Error('Could not complete the request. Please check your authentication details are correct.');
|
|
19
|
+
}
|
|
20
|
+
if (response.status >= 400) {
|
|
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 {
|
|
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":"","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oot":"","sources":["../../src/commands/authenticate.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,gBAAgB,EAAE,cAAc,EAAC,MAAM,iBAAiB,CAAA;mCAGpD,cAAc,aACb,gBAAgB,KAC1B,QAAQ,OAAO,CAAC;AAHnB,wBAoBC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 fetch_1 = require("@stepzen/fetch");
|
|
6
|
+
const constants_1 = require("../shared/constants");
|
|
7
|
+
const request_1 = require("../shared/request");
|
|
8
|
+
exports.default = async (settings, sdkConfig) => {
|
|
9
|
+
const headers = (0, request_1.getRequestHeaders)(settings, sdkConfig);
|
|
10
|
+
const url = `${settings.server}${constants_1.ADMIN_VERIFY_URL}`;
|
|
11
|
+
debug('stepzen:headers')(headers);
|
|
12
|
+
debug('stepzen:url')(url);
|
|
13
|
+
try {
|
|
14
|
+
const response = await (0, fetch_1.default)(url, {
|
|
15
|
+
headers: headers,
|
|
16
|
+
method: 'POST',
|
|
17
|
+
});
|
|
18
|
+
await response.json();
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
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,0CAAkC;AAElC,mDAAoD;AACpD,+CAAmD;AAGnD,kBAAe,KAAK,EAClB,QAAwB,EACxB,SAA2B,EACT,EAAE;IACpB,MAAM,OAAO,GAAG,IAAA,2BAAiB,EAAC,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,IAAA,eAAK,EAAC,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,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SDKConfiguration, StepZenAccount, StepZenDeploy, ZenCtlResponse } from '../shared/types';
|
|
2
|
+
declare const _default: (details: StepZenDeploy, account: StepZenAccount, sdkConfig: SDKConfiguration) => Promise<ZenCtlResponse>;
|
|
3
|
+
export default _default;
|
|
4
|
+
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,cAAc,EACf,MAAM,iBAAiB,CAAA;kCAGb,aAAa,WACb,cAAc,aACZ,gBAAgB,KAC1B,QAAQ,cAAc,CAAC;AAJ1B,wBAyDC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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 fetch_1 = require("@stepzen/fetch");
|
|
6
|
+
const constants_1 = require("../shared/constants");
|
|
7
|
+
const request_1 = require("../shared/request");
|
|
8
|
+
exports.default = async (details, account, sdkConfig) => {
|
|
9
|
+
const headers = (0, request_1.getRequestHeaders)(account, sdkConfig);
|
|
10
|
+
const payload = {
|
|
11
|
+
schema: `/workspaces/schemas/${details.schema}`,
|
|
12
|
+
};
|
|
13
|
+
if (details.configurationsets) {
|
|
14
|
+
payload.configurationsets = details.configurationsets.map(config => `/workspaces/configurationsets/${config}`);
|
|
15
|
+
}
|
|
16
|
+
debug('stepzen:headers')(headers);
|
|
17
|
+
debug('stepzen:payload')(payload);
|
|
18
|
+
const response = await (0, fetch_1.default)(`${account.server}${constants_1.ADMIN_DEPLOY_URL}/${details.destination}`, {
|
|
19
|
+
body: JSON.stringify(payload),
|
|
20
|
+
headers: headers,
|
|
21
|
+
method: 'POST',
|
|
22
|
+
});
|
|
23
|
+
debug('stepzen:response')(response);
|
|
24
|
+
if (response.status >= 400 && response.status < 500) {
|
|
25
|
+
throw new Error('Could not complete the request. Please check your authentication details are correct.');
|
|
26
|
+
}
|
|
27
|
+
if (response.status >= 500) {
|
|
28
|
+
return {
|
|
29
|
+
errors: [response.statusText],
|
|
30
|
+
success: false,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const text = await response.text();
|
|
34
|
+
let json;
|
|
35
|
+
try {
|
|
36
|
+
json = JSON.parse(text);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return {
|
|
40
|
+
errors: [`An unexpected error occurred.\n\n${text}`],
|
|
41
|
+
success: false,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return json;
|
|
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,0CAAkC;AAElC,mDAAoD;AACpD,+CAAmD;AAQnD,kBAAe,KAAK,EAClB,OAAsB,EACtB,OAAuB,EACvB,SAA2B,EACF,EAAE;IA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EAAE,CAAC,oCAAoC,IAAI,EAAE,CAAC;YACpD,OAAO,EAAE,KAAK;SACf,CAAA;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AnonymousClientOptions, SDKConfiguration, StepZenCredentials } from '../shared/types';
|
|
2
|
+
declare const _default: (options: Required<AnonymousClientOptions>, sdkConfig: SDKConfiguration) => Promise<StepZenCredentials | {
|
|
3
|
+
success: false;
|
|
4
|
+
errors: string[];
|
|
5
|
+
}>;
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=getPublicAccount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPublicAccount.d.ts","sourceRoot":"","sources":["../../src/commands/getPublicAccount.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,iBAAiB,CAAA;kCAGb,SAAS,sBAAsB,CAAC,aAC9B,gBAAgB,KAC1B,QACC,kBAAkB,GAClB;IACE,OAAO,EAAE,KAAK,CAAA;IACd,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,CACJ;AATD,wBAgEC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 fetch_1 = require("@stepzen/fetch");
|
|
6
|
+
const request_1 = require("../shared/request");
|
|
7
|
+
exports.default = async (options, sdkConfig) => {
|
|
8
|
+
const account = process.env.STEPZEN_PUBLIC_ACCOUNT_API_ACCOUNT || 'stepzen';
|
|
9
|
+
const endpoint = process.env.STEPZEN_PUBLIC_ACCOUNT_API_ENDPOINT || 'api/publicaccount';
|
|
10
|
+
const server = options.server
|
|
11
|
+
.replace('{account}', account)
|
|
12
|
+
.replace('.io', '.net');
|
|
13
|
+
const url = new URL(`${server}/${endpoint}/__graphql`);
|
|
14
|
+
// Inlclude the token into the URL so that it is visible in the logs
|
|
15
|
+
// (allows StepZen to do analytics based on the GCP logs).
|
|
16
|
+
url.searchParams.set('token', options.publicAccountToken);
|
|
17
|
+
try {
|
|
18
|
+
debug('stepzen:createAnonymousAccount')(url);
|
|
19
|
+
const response = await (0, fetch_1.default)(url, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers: {
|
|
22
|
+
'Content-Type': 'application/json',
|
|
23
|
+
'User-Agent': (0, request_1.getUserAgent)(sdkConfig),
|
|
24
|
+
},
|
|
25
|
+
body: JSON.stringify({
|
|
26
|
+
query: `query (
|
|
27
|
+
$token: String!
|
|
28
|
+
) {
|
|
29
|
+
getAccountDetails(
|
|
30
|
+
token: $token
|
|
31
|
+
) {
|
|
32
|
+
account: accountName
|
|
33
|
+
adminkey: adminKey
|
|
34
|
+
apikey: apiKey
|
|
35
|
+
}
|
|
36
|
+
}`,
|
|
37
|
+
variables: {
|
|
38
|
+
token: options.publicAccountToken,
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
const json = await response.json();
|
|
43
|
+
debug('stepzen:createAnonymousAccount')(json);
|
|
44
|
+
if (json.errors) {
|
|
45
|
+
return {
|
|
46
|
+
success: false,
|
|
47
|
+
errors: json.errors,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (!json.data?.getAccountDetails) {
|
|
51
|
+
throw new Error('No data returned from the API endpoint.');
|
|
52
|
+
}
|
|
53
|
+
return json.data?.getAccountDetails;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw new Error(`Could not create a public account (${error})`);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=getPublicAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPublicAccount.js","sourceRoot":"","sources":["../../src/commands/getPublicAccount.ts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AE,KAAK;gBACd,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAA;SACF;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;SAC3D;QAED,OAAO,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAA;KACpC;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,sCAAsC,KAAK,GAAG,CAAC,CAAA;KAChE;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SDKConfiguration, StepZenAccount, StepZenList, ZenCtlResponse } from '../shared/types';
|
|
2
|
+
declare const _default: (details: StepZenList, account: StepZenAccount, sdkConfig: SDKConfiguration) => Promise<ZenCtlResponse>;
|
|
3
|
+
export default _default;
|
|
4
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,cAAc,EACf,MAAM,iBAAiB,CAAA;kCAGb,WAAW,WACX,cAAc,aACZ,gBAAgB,KAC1B,QAAQ,cAAc,CAAC;AAJ1B,wBAmCC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 fetch_1 = require("@stepzen/fetch");
|
|
6
|
+
const constants_1 = require("../shared/constants");
|
|
7
|
+
const request_1 = require("../shared/request");
|
|
8
|
+
exports.default = async (details, account, sdkConfig) => {
|
|
9
|
+
const headers = (0, request_1.getRequestHeaders)(account, sdkConfig);
|
|
10
|
+
debug('stepzen:headers')(headers);
|
|
11
|
+
const response = await (0, fetch_1.default)(`${account.server}${constants_1.ADMIN_LIST_URL}/${details.type}`, {
|
|
12
|
+
headers: headers,
|
|
13
|
+
method: 'GET',
|
|
14
|
+
});
|
|
15
|
+
debug('stepzen:response')(response);
|
|
16
|
+
if (response.status >= 400 && response.status < 500) {
|
|
17
|
+
throw new Error('Could not complete the request. Please check your authentication details are correct.');
|
|
18
|
+
}
|
|
19
|
+
const text = await response.text();
|
|
20
|
+
let json;
|
|
21
|
+
try {
|
|
22
|
+
json = JSON.parse(text);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
throw new Error(`An unexpected error occurred.\n\n${text}`);
|
|
26
|
+
}
|
|
27
|
+
return json;
|
|
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,0CAAkC;AAElC,mDAAkD;AAClD,+CAAmD;AAQnD,kBAAe,KAAK,EAClB,OAAoB,EACpB,OAAuB,EACvB,SAA2B,EACF,EAAE;IAC3B,MAAM,OAAO,GAAG,IAAA,2BAAiB,EAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAErD,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAA;IAEjC,MAAM,QAAQ,GAAG,MAAM,IAAA,eAAK,EAC1B,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,MAAM;QACN,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SDKConfiguration, StepZenAccount, StepZenUpload, ZenCtlResponse } from '../shared/types';
|
|
2
|
+
declare const _default: (details: StepZenUpload, account: StepZenAccount, sdkConfig: SDKConfiguration) => Promise<ZenCtlResponse>;
|
|
3
|
+
export default _default;
|
|
4
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/commands/upload.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,cAAc,EACf,MAAM,iBAAiB,CAAA;kCAKb,aAAa,WACb,cAAc,aACZ,gBAAgB,KAC1B,QAAQ,cAAc,CAAC;AAJ1B,wBAyEC"}
|