@transcend-io/cli 4.94.0 → 4.96.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/README.md +49 -0
- package/build/ai/TranscendAiPrompt.d.ts +54 -0
- package/build/ai/TranscendAiPrompt.d.ts.map +1 -0
- package/build/ai/TranscendAiPrompt.js +97 -0
- package/build/ai/TranscendAiPrompt.js.map +1 -0
- package/build/ai/createHandlebarsWithHelpers.d.ts +25 -0
- package/build/ai/createHandlebarsWithHelpers.d.ts.map +1 -0
- package/build/ai/createHandlebarsWithHelpers.js +125 -0
- package/build/ai/createHandlebarsWithHelpers.js.map +1 -0
- package/build/ai/index.d.ts +3 -0
- package/build/ai/index.d.ts.map +1 -0
- package/build/ai/index.js +19 -0
- package/build/ai/index.js.map +1 -0
- package/build/cli-create-assessment.d.ts +3 -0
- package/build/cli-create-assessment.d.ts.map +1 -0
- package/build/cli-create-assessment.js +163 -0
- package/build/cli-create-assessment.js.map +1 -0
- package/build/cli-push.js +9 -9
- package/build/cli-push.js.map +1 -1
- package/build/cli-test.d.ts +3 -0
- package/build/cli-test.d.ts.map +1 -0
- package/build/cli-test.js +72 -0
- package/build/cli-test.js.map +1 -0
- package/build/codecs.d.ts +18 -11
- package/build/codecs.d.ts.map +1 -1
- package/build/codecs.js +12 -8
- package/build/codecs.js.map +1 -1
- package/build/cron/pullCronIdentifiersToCsv.d.ts +24 -0
- package/build/cron/pullCronIdentifiersToCsv.d.ts.map +1 -0
- package/build/cron/pullCronIdentifiersToCsv.js +53 -0
- package/build/cron/pullCronIdentifiersToCsv.js.map +1 -0
- package/build/graphql/fetchAllRequests.d.ts +4 -4
- package/build/graphql/fetchAssessments.d.ts +8 -2
- package/build/graphql/fetchAssessments.d.ts.map +1 -1
- package/build/graphql/fetchAssessments.js +3 -1
- package/build/graphql/fetchAssessments.js.map +1 -1
- package/build/graphql/gqls/assessment.d.ts.map +1 -1
- package/build/graphql/gqls/assessment.js +10 -1
- package/build/graphql/gqls/assessment.js.map +1 -1
- package/build/graphql/syncAssessmentTemplates.d.ts +7 -2
- package/build/graphql/syncAssessmentTemplates.d.ts.map +1 -1
- package/build/graphql/syncAssessmentTemplates.js +3 -2
- package/build/graphql/syncAssessmentTemplates.js.map +1 -1
- package/build/graphql/syncAssessments.d.ts +27 -0
- package/build/graphql/syncAssessments.d.ts.map +1 -1
- package/build/graphql/syncAssessments.js +40 -15
- package/build/graphql/syncAssessments.js.map +1 -1
- package/build/graphql/syncConfigurationToTranscend.d.ts +3 -1
- package/build/graphql/syncConfigurationToTranscend.d.ts.map +1 -1
- package/build/graphql/syncConfigurationToTranscend.js +2 -2
- package/build/graphql/syncConfigurationToTranscend.js.map +1 -1
- package/build/graphql/tests/fetchApiKeys.test.d.ts +1 -0
- package/build/graphql/tests/fetchApiKeys.test.d.ts.map +1 -0
- package/build/graphql/tests/fetchApiKeys.test.js +3 -0
- package/build/graphql/tests/fetchApiKeys.test.js.map +1 -0
- package/build/graphql/tests/fetchDataSubjects.test.d.ts +1 -0
- package/build/graphql/tests/fetchDataSubjects.test.d.ts.map +1 -0
- package/build/graphql/tests/fetchDataSubjects.test.js +3 -0
- package/build/graphql/tests/fetchDataSubjects.test.js.map +1 -0
- package/build/graphql/tests/fetchIdentifiers.test.d.ts +1 -0
- package/build/graphql/tests/fetchIdentifiers.test.d.ts.map +1 -0
- package/build/graphql/tests/fetchIdentifiers.test.js +3 -0
- package/build/graphql/tests/fetchIdentifiers.test.js.map +1 -0
- package/build/graphql/tests/syncDataSilos.test.d.ts +1 -0
- package/build/graphql/tests/syncDataSilos.test.d.ts.map +1 -0
- package/build/graphql/tests/syncDataSilos.test.js +3 -0
- package/build/graphql/tests/syncDataSilos.test.js.map +1 -0
- package/build/graphql/tests/syncEnrichers.test.d.ts +1 -0
- package/build/graphql/tests/syncEnrichers.test.d.ts.map +1 -0
- package/build/graphql/tests/syncEnrichers.test.js +3 -0
- package/build/graphql/tests/syncEnrichers.test.js.map +1 -0
- package/build/helpers/compile.d.ts +22 -0
- package/build/helpers/compile.d.ts.map +1 -0
- package/build/helpers/compile.js +37 -0
- package/build/helpers/compile.js.map +1 -0
- package/build/helpers/getHandlebarsVariablesFromTemplate.d.ts +12 -0
- package/build/helpers/getHandlebarsVariablesFromTemplate.d.ts.map +1 -0
- package/build/helpers/getHandlebarsVariablesFromTemplate.js +54 -0
- package/build/helpers/getHandlebarsVariablesFromTemplate.js.map +1 -0
- package/build/helpers/getVariablesFromHandlebarsTemplate.d.ts +10 -0
- package/build/helpers/getVariablesFromHandlebarsTemplate.d.ts.map +1 -0
- package/build/helpers/getVariablesFromHandlebarsTemplate.js +96 -0
- package/build/helpers/getVariablesFromHandlebarsTemplate.js.map +1 -0
- package/build/helpers/inquirer.d.ts +32 -0
- package/build/helpers/inquirer.d.ts.map +1 -0
- package/build/helpers/inquirer.js +64 -0
- package/build/helpers/inquirer.js.map +1 -0
- package/build/helpers/parseVariablesFromString.d.ts +10 -0
- package/build/helpers/parseVariablesFromString.d.ts.map +1 -0
- package/build/helpers/parseVariablesFromString.js +21 -0
- package/build/helpers/parseVariablesFromString.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/logger.js +0 -1
- package/build/logger.js.map +1 -1
- package/build/requests/constants.d.ts +1 -1
- package/build/requests/pullRequestsToCsv.d.ts +32 -0
- package/build/requests/pullRequestsToCsv.d.ts.map +1 -0
- package/build/requests/pullRequestsToCsv.js +86 -0
- package/build/requests/pullRequestsToCsv.js.map +1 -0
- package/build/requests/submitPrivacyRequest.d.ts +4 -4
- package/build/tests/getVariablesFromHandlebars.test.d.ts +2 -0
- package/build/tests/getVariablesFromHandlebars.test.d.ts.map +1 -0
- package/build/tests/getVariablesFromHandlebars.test.js +44 -0
- package/build/tests/getVariablesFromHandlebars.test.js.map +1 -0
- package/build/tsbuildinfo +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -114,6 +114,10 @@
|
|
|
114
114
|
- [Arguments](#arguments-25)
|
|
115
115
|
- [Usage](#usage-26)
|
|
116
116
|
- [Proxy usage](#proxy-usage)
|
|
117
|
+
- [tr-create-assessment](#tr-create-assessment)
|
|
118
|
+
- [Authentication](#authentication-26)
|
|
119
|
+
- [Arguments](#arguments-26)
|
|
120
|
+
- [Usage](#usage-27)
|
|
117
121
|
|
|
118
122
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
119
123
|
|
|
@@ -157,6 +161,7 @@ yarn tr-upload-data-flows-from-csv --auth=$TRANSCEND_API_KEY
|
|
|
157
161
|
yarn tr-upload-cookies-from-csv --auth=$TRANSCEND_API_KEY
|
|
158
162
|
yarn tr-generate-api-keys --auth=$TRANSCEND_API_KEY
|
|
159
163
|
yarn tr-build-xdi-sync-endpoint --auth=$TRANSCEND_API_KEY
|
|
164
|
+
yarn tr-create-assessment --auth=$TRANSCEND_API_KEY
|
|
160
165
|
```
|
|
161
166
|
|
|
162
167
|
or
|
|
@@ -190,6 +195,7 @@ tr-derive-data-silos-from-data-flows-cross-instance --auth=$TRANSCEND_API_KEY
|
|
|
190
195
|
tr-upload-data-flows-from-csv --auth=$TRANSCEND_API_KEY
|
|
191
196
|
tr-generate-api-keys --auth=$TRANSCEND_API_KEY
|
|
192
197
|
tr-build-xdi-sync-endpoint --auth=$TRANSCEND_API_KEY
|
|
198
|
+
tr-create-assessment --auth=$TRANSCEND_API_KEY
|
|
193
199
|
|
|
194
200
|
```
|
|
195
201
|
|
|
@@ -2100,3 +2106,46 @@ yarn tr-build-xdi-sync-endpoint --auth=$TRANSCEND_API_KEY --xdiLocation=https://
|
|
|
2100
2106
|
## Proxy usage
|
|
2101
2107
|
|
|
2102
2108
|
If you are trying to use the cli inside a corporate firewall and need to send traffic through a proxy, you can do so via the `http_proxy` environment variable or the `--httpProxy` flag, with a command like `yarn tr-pull --auth=$TRANSCEND_API_KEY --httpProxy="http://localhost:5051"`.
|
|
2109
|
+
|
|
2110
|
+
### tr-create-assessment
|
|
2111
|
+
|
|
2112
|
+
This command allows for creating a new assessment form an assessment template.
|
|
2113
|
+
|
|
2114
|
+
Assessment templates can be managed here: https://app.transcend.io/assessments/templates
|
|
2115
|
+
|
|
2116
|
+
#### Authentication
|
|
2117
|
+
|
|
2118
|
+
In order to use this cli, you will first need to generate an API key on the Transcend Admin Dashboard (https://app.transcend.io/infrastructure/api-keys) or by using the `yarn tr-generate-api-keys` command above.
|
|
2119
|
+
|
|
2120
|
+
The API key must have the following scopes:
|
|
2121
|
+
|
|
2122
|
+
- "Manage Assessments"
|
|
2123
|
+
|
|
2124
|
+
#### Arguments
|
|
2125
|
+
|
|
2126
|
+
| Argument | Description | Type | Default | Required |
|
|
2127
|
+
| --------- | ---------------------------------------------------------------- | ------ | -------------- | -------- |
|
|
2128
|
+
| auth | The Transcend API key with the scopes necessary for the command. | string | N/A | true |
|
|
2129
|
+
| template | The title of the assessment template | string | N/A - Prompted | false |
|
|
2130
|
+
| title | The title of the new assessment | string | N/A - Prompted | false |
|
|
2131
|
+
| variables | Additional template variables to pre-fill the template | string | N/A - Prompted | false |
|
|
2132
|
+
|
|
2133
|
+
#### Usage
|
|
2134
|
+
|
|
2135
|
+
Create a new assessment, filling out more information by being prompted by the terminal line
|
|
2136
|
+
|
|
2137
|
+
```sh
|
|
2138
|
+
yarn tr-create-assessment --auth=$TRANSCEND_API_KEY
|
|
2139
|
+
```
|
|
2140
|
+
|
|
2141
|
+
Specifying the template and title
|
|
2142
|
+
|
|
2143
|
+
```sh
|
|
2144
|
+
yarn tr-create-assessment --auth=$TRANSCEND_API_KEY --title="Test" --template="[AI Prompt] Product Manager Notes Parsing"
|
|
2145
|
+
```
|
|
2146
|
+
|
|
2147
|
+
Configuring additional variables:
|
|
2148
|
+
|
|
2149
|
+
```sh
|
|
2150
|
+
yarn tr-create-assessment --auth=$TRANSCEND_API_KEY --title="Test" --template="[AI Prompt] Product Manager Notes Parsing" --variables=description:"testt test"
|
|
2151
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ObjByString } from '@transcend-io/type-utils';
|
|
2
|
+
import type handlebars from 'handlebars';
|
|
3
|
+
import { Secret } from '@transcend-io/secret-value';
|
|
4
|
+
import * as t from 'io-ts';
|
|
5
|
+
import { HandlebarsInput } from './createHandlebarsWithHelpers';
|
|
6
|
+
export declare const EXPECTED_ATTRIBUTE_PREFIX = "attribute-";
|
|
7
|
+
/**
|
|
8
|
+
* Define an AI prompt that can be loaded from Transcend
|
|
9
|
+
*/
|
|
10
|
+
export declare class TranscendAiPrompt<TParams extends ObjByString, TOutputCodec extends t.Any> {
|
|
11
|
+
/** Title of prompt */
|
|
12
|
+
title: string;
|
|
13
|
+
/** Codec to validate output response */
|
|
14
|
+
codec: TOutputCodec;
|
|
15
|
+
/** Handlebars compiler */
|
|
16
|
+
handlebars: typeof handlebars;
|
|
17
|
+
/**
|
|
18
|
+
* Constructor
|
|
19
|
+
*
|
|
20
|
+
* @param options - Options
|
|
21
|
+
*/
|
|
22
|
+
constructor({ title, codec, handlebarsOptions, }: {
|
|
23
|
+
/** Title of prompt in transcend */
|
|
24
|
+
title: string;
|
|
25
|
+
/** Codec to validate output shape of the prompt */
|
|
26
|
+
codec: TOutputCodec;
|
|
27
|
+
/** Options for configuring handlebars */
|
|
28
|
+
handlebarsOptions?: HandlebarsInput;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Fetch prompt from Transcend
|
|
32
|
+
*
|
|
33
|
+
* @param options - Additional options
|
|
34
|
+
* @returns A function that can be used to call the prompt
|
|
35
|
+
*/
|
|
36
|
+
fetchPromptFromTranscend({ fillTemplateWithAttributes, transcendUrl, transcendApiKey, requireApproval, }: {
|
|
37
|
+
/** The Transcend API key */
|
|
38
|
+
transcendApiKey: string | Secret<string>;
|
|
39
|
+
/** When true, template in any attribute definitions in the prompt */
|
|
40
|
+
fillTemplateWithAttributes?: boolean;
|
|
41
|
+
/** API of Transcend to call */
|
|
42
|
+
transcendUrl?: string;
|
|
43
|
+
/** When true, throw an error if the prompt is not approved */
|
|
44
|
+
requireApproval?: boolean;
|
|
45
|
+
}): Promise<(params: TParams) => string>;
|
|
46
|
+
/**
|
|
47
|
+
* Validate the shape of the response from AI
|
|
48
|
+
*
|
|
49
|
+
* @param response - AI response as string
|
|
50
|
+
* @returns Parsed content
|
|
51
|
+
*/
|
|
52
|
+
parseAiResponse(response: string): t.TypeOf<TOutputCodec>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=TranscendAiPrompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranscendAiPrompt.d.ts","sourceRoot":"","sources":["../../src/ai/TranscendAiPrompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAK3B,OAAO,EACL,eAAe,EAEhB,MAAM,+BAA+B,CAAC;AAIvC,eAAO,MAAM,yBAAyB,eAAe,CAAC;AAEtD;;GAEG;AACH,qBAAa,iBAAiB,CAC5B,OAAO,SAAS,WAAW,EAC3B,YAAY,SAAS,CAAC,CAAC,GAAG;IAE1B,sBAAsB;IACf,KAAK,EAAE,MAAM,CAAC;IAErB,wCAAwC;IACjC,KAAK,EAAE,YAAY,CAAC;IAE3B,0BAA0B;IACnB,UAAU,EAAE,OAAO,UAAU,CAAC;IAErC;;;;OAIG;gBACS,EACV,KAAK,EACL,KAAK,EACL,iBAAiB,GAClB,EAAE;QACD,mCAAmC;QACnC,KAAK,EAAE,MAAM,CAAC;QACd,mDAAmD;QACnD,KAAK,EAAE,YAAY,CAAC;QACpB,yCAAyC;QACzC,iBAAiB,CAAC,EAAE,eAAe,CAAC;KACrC;IAMD;;;;;OAKG;IACG,wBAAwB,CAAC,EAC7B,0BAAiC,EACjC,YAAoC,EACpC,eAAe,EACf,eAAe,GAChB,EAAE;QACD,4BAA4B;QAC5B,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QACzC,qEAAqE;QACrE,0BAA0B,CAAC,EAAE,OAAO,CAAC;QACrC,+BAA+B;QAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,8DAA8D;QAC9D,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,GAAG,OAAO,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;IAsExC;;;;;OAKG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;CAG1D"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TranscendAiPrompt = exports.EXPECTED_ATTRIBUTE_PREFIX = void 0;
|
|
7
|
+
const type_utils_1 = require("@transcend-io/type-utils");
|
|
8
|
+
const privacy_types_1 = require("@transcend-io/privacy-types");
|
|
9
|
+
const fetchAssessments_1 = require("../graphql/fetchAssessments");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
const graphql_1 = require("../graphql");
|
|
12
|
+
const getVariablesFromHandlebarsTemplate_1 = require("../helpers/getVariablesFromHandlebarsTemplate");
|
|
13
|
+
const createHandlebarsWithHelpers_1 = require("./createHandlebarsWithHelpers");
|
|
14
|
+
const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
15
|
+
const keyBy_1 = __importDefault(require("lodash/keyBy"));
|
|
16
|
+
exports.EXPECTED_ATTRIBUTE_PREFIX = 'attribute-';
|
|
17
|
+
/**
|
|
18
|
+
* Define an AI prompt that can be loaded from Transcend
|
|
19
|
+
*/
|
|
20
|
+
class TranscendAiPrompt {
|
|
21
|
+
/**
|
|
22
|
+
* Constructor
|
|
23
|
+
*
|
|
24
|
+
* @param options - Options
|
|
25
|
+
*/
|
|
26
|
+
constructor({ title, codec, handlebarsOptions, }) {
|
|
27
|
+
this.title = title;
|
|
28
|
+
this.codec = codec;
|
|
29
|
+
this.handlebars = (0, createHandlebarsWithHelpers_1.createHandlebarsWithHelpers)(handlebarsOptions);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Fetch prompt from Transcend
|
|
33
|
+
*
|
|
34
|
+
* @param options - Additional options
|
|
35
|
+
* @returns A function that can be used to call the prompt
|
|
36
|
+
*/
|
|
37
|
+
async fetchPromptFromTranscend({ fillTemplateWithAttributes = true, transcendUrl = constants_1.DEFAULT_TRANSCEND_API, transcendApiKey, requireApproval, }) {
|
|
38
|
+
// construct GraphQL client
|
|
39
|
+
const client = (0, graphql_1.buildTranscendGraphQLClient)(transcendUrl, typeof transcendApiKey === 'string'
|
|
40
|
+
? transcendApiKey
|
|
41
|
+
: transcendApiKey.release());
|
|
42
|
+
// Fetch the assessments
|
|
43
|
+
const assessments = await (0, fetchAssessments_1.fetchAllAssessments)(client, { text: this.title });
|
|
44
|
+
// Ensure assessment exists with specified title
|
|
45
|
+
const assessment = assessments.find((row) => row.title === this.title);
|
|
46
|
+
if (!assessment) {
|
|
47
|
+
throw new Error(`Failed to find assessment with title: "${this.title}"`);
|
|
48
|
+
}
|
|
49
|
+
// Ensure assessment is approved
|
|
50
|
+
if (requireApproval && assessment.status !== privacy_types_1.AssessmentStatus.Approved) {
|
|
51
|
+
throw new Error(`Assessment "${this.title}" cannot be used because its in status: "${assessment.status}"`);
|
|
52
|
+
}
|
|
53
|
+
// Template attributes into the template string
|
|
54
|
+
const extraParams = {};
|
|
55
|
+
if (fillTemplateWithAttributes) {
|
|
56
|
+
// pull out the variables from the handlebar string
|
|
57
|
+
const schema = (0, getVariablesFromHandlebarsTemplate_1.getVariablesFromHandlebarsTemplate)(assessment.content);
|
|
58
|
+
// pull out the attributes to fetch
|
|
59
|
+
const attributeToFetch = Object.keys(schema).filter((key) => key.startsWith(exports.EXPECTED_ATTRIBUTE_PREFIX));
|
|
60
|
+
// Fetch attributes if there are template variables to fill
|
|
61
|
+
if (attributeToFetch.length > 0) {
|
|
62
|
+
// TODO: https://transcend.height.app/T-29886 - only fetch attributes needed
|
|
63
|
+
const attributeKeys = await (0, graphql_1.fetchAllAttributes)(client);
|
|
64
|
+
const attributeKeysAsCamel = attributeKeys.map((key) => ({
|
|
65
|
+
...key,
|
|
66
|
+
camelName: (0, camelCase_1.default)(key.name),
|
|
67
|
+
}));
|
|
68
|
+
const lookupAttributeKey = (0, keyBy_1.default)(attributeKeysAsCamel, 'camelName');
|
|
69
|
+
attributeToFetch.forEach((attributeNameWithPrefix) => {
|
|
70
|
+
const attributeName = attributeNameWithPrefix.replace(exports.EXPECTED_ATTRIBUTE_PREFIX, '');
|
|
71
|
+
const existingAttribute = lookupAttributeKey[attributeName];
|
|
72
|
+
if (!existingAttribute) {
|
|
73
|
+
throw new Error(`Failed to find attribute with name: "${attributeName}"`);
|
|
74
|
+
}
|
|
75
|
+
extraParams[attributeNameWithPrefix] = existingAttribute.values;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Return function that can compile template with attributes
|
|
80
|
+
// and provided parameters
|
|
81
|
+
return (params) => this.handlebars.compile(assessment.content)({
|
|
82
|
+
...extraParams,
|
|
83
|
+
...params,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Validate the shape of the response from AI
|
|
88
|
+
*
|
|
89
|
+
* @param response - AI response as string
|
|
90
|
+
* @returns Parsed content
|
|
91
|
+
*/
|
|
92
|
+
parseAiResponse(response) {
|
|
93
|
+
return (0, type_utils_1.decodeCodec)(this.codec, response);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.TranscendAiPrompt = TranscendAiPrompt;
|
|
97
|
+
//# sourceMappingURL=TranscendAiPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranscendAiPrompt.js","sourceRoot":"","sources":["../../src/ai/TranscendAiPrompt.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAoE;AAEpE,+DAA+D;AAG/D,kEAAkE;AAClE,4CAAqD;AACrD,wCAA6E;AAC7E,sGAAmG;AACnG,+EAGuC;AACvC,iEAAyC;AACzC,yDAAiC;AAEpB,QAAA,yBAAyB,GAAG,YAAY,CAAC;AAEtD;;GAEG;AACH,MAAa,iBAAiB;IAa5B;;;;OAIG;IACH,YAAY,EACV,KAAK,EACL,KAAK,EACL,iBAAiB,GAQlB;QACC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,IAAA,yDAA2B,EAAC,iBAAiB,CAAC,CAAC;IACnE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,wBAAwB,CAAC,EAC7B,0BAA0B,GAAG,IAAI,EACjC,YAAY,GAAG,iCAAqB,EACpC,eAAe,EACf,eAAe,GAUhB;QACC,2BAA2B;QAC3B,MAAM,MAAM,GAAG,IAAA,qCAA2B,EACxC,YAAY,EACZ,OAAO,eAAe,KAAK,QAAQ;YACjC,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,CAC9B,CAAC;QAEF,wBAAwB;QACxB,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAmB,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAE5E,gDAAgD;QAChD,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC;QACvE,I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B,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC;oBAC5D,IAAI,CAAC,iBAAiB,EAAE;wBACtB,MAAM,IAAI,KAAK,CACb,wCAAwC,aAAa,GAAG,CACzD,CAAC;qBACH;oBACD,WAAW,CAAC,uBAAuB,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC;gBAClE,CAAC,CAAC,CAAC;aACJ;SACF;QAED,4DAA4D;QAC5D,0BAA0B;QAC1B,OAAO,CAAC,MAAM,EAAE,EAAE,CAChB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC1C,GAAG,WAAW;YACd,GAAG,MAAM;SACV,CAAC,CAAC;IACP,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,QAAgB;QAC9B,OAAO,IAAA,wBAAW,EAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;CACF;AAtID,8CAsIC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Handlebars from 'handlebars';
|
|
2
|
+
/**
|
|
3
|
+
* Input for creating a handlebars instance
|
|
4
|
+
*/
|
|
5
|
+
export interface HandlebarsInput {
|
|
6
|
+
/** The handlebars templates */
|
|
7
|
+
templates?: {
|
|
8
|
+
/** Name of template */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Content of template */
|
|
11
|
+
content: string;
|
|
12
|
+
}[];
|
|
13
|
+
/** Helper functions to register */
|
|
14
|
+
helpers?: {
|
|
15
|
+
[name in string]: Handlebars.HelperDelegate;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create an instance of handlebars, loading partial templates and adding utilities
|
|
20
|
+
*
|
|
21
|
+
* @param input - Input to define the handlebars instance
|
|
22
|
+
* @returns The instantiated instance of handlebars
|
|
23
|
+
*/
|
|
24
|
+
export declare function createHandlebarsWithHelpers({ templates, helpers, }?: HandlebarsInput): typeof Handlebars;
|
|
25
|
+
//# sourceMappingURL=createHandlebarsWithHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHandlebarsWithHelpers.d.ts","sourceRoot":"","sources":["../../src/ai/createHandlebarsWithHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AAqBpC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,+BAA+B;IAC/B,SAAS,CAAC,EAAE;QACV,uBAAuB;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,0BAA0B;QAC1B,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;IACJ,mCAAmC;IACnC,OAAO,CAAC,EAAE;SAAG,IAAI,IAAI,MAAM,GAAG,UAAU,CAAC,cAAc;KAAE,CAAC;CAC3D;AAgHD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,SAAc,EACd,OAAY,GACb,GAAE,eAAoB,GAAG,OAAO,UAAU,CAc1C"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createHandlebarsWithHelpers = void 0;
|
|
7
|
+
const handlebars_1 = __importDefault(require("handlebars"));
|
|
8
|
+
const change_case_1 = require("change-case");
|
|
9
|
+
const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
10
|
+
const kebabCase_1 = __importDefault(require("lodash/kebabCase"));
|
|
11
|
+
const lowerCase_1 = __importDefault(require("lodash/lowerCase"));
|
|
12
|
+
const lowerFirst_1 = __importDefault(require("lodash/lowerFirst"));
|
|
13
|
+
const startCase_1 = __importDefault(require("lodash/startCase"));
|
|
14
|
+
const upperCase_1 = __importDefault(require("lodash/upperCase"));
|
|
15
|
+
const upperFirst_1 = __importDefault(require("lodash/upperFirst"));
|
|
16
|
+
/**
|
|
17
|
+
* Default helper functions to register
|
|
18
|
+
*/
|
|
19
|
+
const DEFAULT_HELPERS = {
|
|
20
|
+
capitalCase: change_case_1.capitalCase,
|
|
21
|
+
constantCase: change_case_1.constantCase,
|
|
22
|
+
dotCase: change_case_1.dotCase,
|
|
23
|
+
lowerCase: lowerCase_1.default,
|
|
24
|
+
paramCase: kebabCase_1.default,
|
|
25
|
+
upperFirst: upperFirst_1.default,
|
|
26
|
+
camelCase: camelCase_1.default,
|
|
27
|
+
titleCase: startCase_1.default,
|
|
28
|
+
lowerFirst: lowerFirst_1.default,
|
|
29
|
+
headerCase: change_case_1.headerCase,
|
|
30
|
+
upperCase: upperCase_1.default,
|
|
31
|
+
noCase: change_case_1.noCase,
|
|
32
|
+
pascalCase: change_case_1.pascalCase,
|
|
33
|
+
pathCase: change_case_1.pathCase,
|
|
34
|
+
sentenceCase: change_case_1.sentenceCase,
|
|
35
|
+
snakeCase: change_case_1.snakeCase,
|
|
36
|
+
/**
|
|
37
|
+
* Pad with back slashes
|
|
38
|
+
*
|
|
39
|
+
* @param word - The word to pad
|
|
40
|
+
* @returns Slashes the length of the word
|
|
41
|
+
*/
|
|
42
|
+
pad: (word) => '/'.repeat(word.length),
|
|
43
|
+
/**
|
|
44
|
+
* Render if equality is met
|
|
45
|
+
*
|
|
46
|
+
* @param this - This context
|
|
47
|
+
* @param arg1 - First arg
|
|
48
|
+
* @param arg2 - Second arg
|
|
49
|
+
* @param options - Handlebars options
|
|
50
|
+
* @returns The template if args are equal
|
|
51
|
+
*/
|
|
52
|
+
ifEqual: function ifNotEqual(arg1, arg2, options) {
|
|
53
|
+
return arg1 === arg2 ? options.fn(this) : options.inverse(this);
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Render if equality is not met
|
|
57
|
+
*
|
|
58
|
+
* @param this - This context
|
|
59
|
+
* @param arg1 - First arg
|
|
60
|
+
* @param arg2 - Second arg
|
|
61
|
+
* @param options - Handlebars options
|
|
62
|
+
* @returns The template if args are not equal
|
|
63
|
+
*/
|
|
64
|
+
ifNotEqual: function ifNotEqual(arg1, arg2, options) {
|
|
65
|
+
return arg1 !== arg2 ? options.fn(this) : options.inverse(this);
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Uri encode a string
|
|
69
|
+
*
|
|
70
|
+
* @param word - The word to encode
|
|
71
|
+
* @returns The URI encoded word
|
|
72
|
+
*/
|
|
73
|
+
safeString: (word) => encodeURI(word),
|
|
74
|
+
/**
|
|
75
|
+
* Get the length of a list
|
|
76
|
+
*
|
|
77
|
+
* @param list - The list in question
|
|
78
|
+
* @returns The length of the list
|
|
79
|
+
*/
|
|
80
|
+
listLen: (list) => list.length,
|
|
81
|
+
/**
|
|
82
|
+
* Convert a JSON object to string
|
|
83
|
+
*
|
|
84
|
+
* @param obj - The object to convert
|
|
85
|
+
* @returns The object stringified
|
|
86
|
+
*/
|
|
87
|
+
toJSON: (obj) => JSON.stringify(obj, (k, v) => {
|
|
88
|
+
// Necessary, else functions don't get written.
|
|
89
|
+
if (typeof v === 'function') {
|
|
90
|
+
return v.toString();
|
|
91
|
+
}
|
|
92
|
+
return v;
|
|
93
|
+
}, 2),
|
|
94
|
+
/**
|
|
95
|
+
* Compares two string to see if they're sorted
|
|
96
|
+
*
|
|
97
|
+
* @param arg1 - Some string
|
|
98
|
+
* @param arg2 - Some other string to compare against
|
|
99
|
+
* @param options - Handlebar options
|
|
100
|
+
* @returns boolean
|
|
101
|
+
*/
|
|
102
|
+
ifSorted: function ifSorted(arg1, arg2, options) {
|
|
103
|
+
return arg1 <= arg2 ? options.fn(this) : options.inverse(this);
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Create an instance of handlebars, loading partial templates and adding utilities
|
|
108
|
+
*
|
|
109
|
+
* @param input - Input to define the handlebars instance
|
|
110
|
+
* @returns The instantiated instance of handlebars
|
|
111
|
+
*/
|
|
112
|
+
function createHandlebarsWithHelpers({ templates = [], helpers = {}, } = {}) {
|
|
113
|
+
if (templates.length > 0) {
|
|
114
|
+
// Register partials
|
|
115
|
+
templates.forEach(({ name, content }) => handlebars_1.default.registerPartial(name, content));
|
|
116
|
+
}
|
|
117
|
+
// Register helpers
|
|
118
|
+
Object.entries({
|
|
119
|
+
...DEFAULT_HELPERS,
|
|
120
|
+
...helpers,
|
|
121
|
+
}).forEach(([key, func]) => handlebars_1.default.registerHelper(key, func));
|
|
122
|
+
return handlebars_1.default;
|
|
123
|
+
}
|
|
124
|
+
exports.createHandlebarsWithHelpers = createHandlebarsWithHelpers;
|
|
125
|
+
//# sourceMappingURL=createHandlebarsWithHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHandlebarsWithHelpers.js","sourceRoot":"","sources":["../../src/ai/createHandlebarsWithHelpers.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAoC;AACpC,6CAUqB;AACrB,iEAAyC;AACzC,iEAAyC;AACzC,iEAAyC;AACzC,mEAA2C;AAC3C,iEAAyC;AACzC,iEAAyC;AACzC,mEAA2C;AAkB3C;;GAEG;AACH,MAAM,eAAe,GAAG;IACtB,WAAW,EAAX,yBAAW;IACX,YAAY,EAAZ,0BAAY;IACZ,OAAO,EAAP,qBAAO;IACP,SAAS,EAAT,mBAAS;IACT,SAAS,EAAT,mBAAS;IACT,UAAU,EAAV,oBAAU;IACV,SAAS,EAAT,mBAAS;IACT,SAAS,EAAT,mBAAS;IACT,UAAU,EAAV,oBAAU;IACV,UAAU,EAAV,wBAAU;IACV,SAAS,EAAT,mBAAS;IACT,MAAM,EAAN,oBAAM;IACN,UAAU,EAAV,wBAAU;IACV,QAAQ,EAAR,sBAAQ;IACR,YAAY,EAAZ,0BAAY;IACZ,SAAS,EAAT,uBAAS;IACT;;;;;OAKG;IACH,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9C;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AA2B,CAAC,EAC1C,SAAS,GAAG,EAAE,EACd,OAAO,GAAG,EAAE,MACO,EAAE;IACrB,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QACxB,oBAAoB;QACpB,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CACtC,oBAAU,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAC1C,CAAC;KACH;IAED,mBAAmB;IACnB,MAAM,CAAC,OAAO,CAAC;QACb,GAAG,eAAe;QAClB,GAAG,OAAO;KACX,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,oBAAU,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IAClE,OAAO,oBAAU,CAAC;AACpB,CAAC;AAjBD,kEAiBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./TranscendAiPrompt"), exports);
|
|
18
|
+
__exportStar(require("./createHandlebarsWithHelpers"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,gEAA8C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-create-assessment.d.ts","sourceRoot":"","sources":["../src/cli-create-assessment.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const yargs_parser_1 = __importDefault(require("yargs-parser"));
|
|
8
|
+
const colors_1 = __importDefault(require("colors"));
|
|
9
|
+
const logger_1 = require("./logger");
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
const fetchAssessmentTemplates_1 = require("./graphql/fetchAssessmentTemplates");
|
|
12
|
+
const graphql_1 = require("./graphql");
|
|
13
|
+
const getVariablesFromHandlebarsTemplate_1 = require("./helpers/getVariablesFromHandlebarsTemplate");
|
|
14
|
+
const bluebird_1 = require("bluebird");
|
|
15
|
+
const inquirer_1 = require("./helpers/inquirer");
|
|
16
|
+
const parseVariablesFromString_1 = require("./helpers/parseVariablesFromString");
|
|
17
|
+
const syncAssessments_1 = require("./graphql/syncAssessments");
|
|
18
|
+
const ai_1 = require("./ai");
|
|
19
|
+
/**
|
|
20
|
+
* Create a new assessment from an assessment template
|
|
21
|
+
*
|
|
22
|
+
* Requires scopes:
|
|
23
|
+
* - Manage Assessments
|
|
24
|
+
*
|
|
25
|
+
* Dev Usage:
|
|
26
|
+
* yarn ts-node ./src/cli-create-assessment.ts --auth=$TRANSCEND_API_KEY \
|
|
27
|
+
* --template="Product Manager JSON AI Prompt Template
|
|
28
|
+
* --title="Determine Product Line"
|
|
29
|
+
*
|
|
30
|
+
* Standard usage:
|
|
31
|
+
* yarn tr-create-assessment --auth=$TRANSCEND_API_KEY \
|
|
32
|
+
* --template="Product Manager JSON AI Prompt Template
|
|
33
|
+
* --title="Determine Product Line"
|
|
34
|
+
*/
|
|
35
|
+
async function main() {
|
|
36
|
+
// Parse command line arguments
|
|
37
|
+
const {
|
|
38
|
+
/** Transcend Backend URL */
|
|
39
|
+
transcendUrl = constants_1.DEFAULT_TRANSCEND_API,
|
|
40
|
+
/** API key */
|
|
41
|
+
auth,
|
|
42
|
+
/** The name of the assessment template to use */
|
|
43
|
+
template = '',
|
|
44
|
+
/** The title of the new template */
|
|
45
|
+
title = '',
|
|
46
|
+
/** Other variables to template */
|
|
47
|
+
variables = '', } = (0, yargs_parser_1.default)(process.argv.slice(2));
|
|
48
|
+
// Ensure auth is passed
|
|
49
|
+
if (!auth) {
|
|
50
|
+
logger_1.logger.error(colors_1.default.red('A Transcend API key must be provided. You can specify using --auth=$TRANSCEND_API_KEY'));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
// Validate title, if not provided prompt user
|
|
54
|
+
let templateTitle = title;
|
|
55
|
+
if (!templateTitle) {
|
|
56
|
+
templateTitle = await (0, inquirer_1.inquirerConfirmText)({
|
|
57
|
+
message: 'What should be the title of the new template?',
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Validate template
|
|
61
|
+
const client = (0, graphql_1.buildTranscendGraphQLClient)(transcendUrl, auth);
|
|
62
|
+
const assessmentTemplates = await (0, fetchAssessmentTemplates_1.fetchAllAssessmentTemplates)(client);
|
|
63
|
+
const validTitles = assessmentTemplates.map(({ title }) => title);
|
|
64
|
+
// If provided, ensure valid
|
|
65
|
+
if (template && !validTitles.includes(template)) {
|
|
66
|
+
throw new Error(`Invalid template "${template}", expected one of: ${validTitles.join(', ')}`);
|
|
67
|
+
}
|
|
68
|
+
// Prompt user if not provided
|
|
69
|
+
let selectedTemplate = template;
|
|
70
|
+
if (!selectedTemplate) {
|
|
71
|
+
selectedTemplate = await (0, inquirer_1.inquirerAutoComplete)({
|
|
72
|
+
message: 'Select assessment template',
|
|
73
|
+
values: validTitles,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// Get the assessment template
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
78
|
+
const assessmentTemplate = assessmentTemplates.find((template) => template.title === selectedTemplate);
|
|
79
|
+
logger_1.logger.info(colors_1.default.magenta(`\n\n~~~~Formatting template~~~~~\n\n${assessmentTemplate.content}`));
|
|
80
|
+
// Parse out the variables
|
|
81
|
+
const vars = (0, parseVariablesFromString_1.parseVariablesFromString)(variables);
|
|
82
|
+
// Pull the variables out of the template
|
|
83
|
+
const schema = (0, getVariablesFromHandlebarsTemplate_1.getVariablesFromHandlebarsTemplate)(assessmentTemplate.content);
|
|
84
|
+
const results = {};
|
|
85
|
+
await (0, bluebird_1.mapSeries)(Object.entries(schema), async ([variable, type]) => {
|
|
86
|
+
// Format from cli option
|
|
87
|
+
if (vars[variable]) {
|
|
88
|
+
logger_1.logger.info(colors_1.default.white(`[${variable}] Using cli provided variable for "${variable}": ${vars[variable]}`));
|
|
89
|
+
results[variable] =
|
|
90
|
+
type && typeof type === 'object'
|
|
91
|
+
? JSON.parse(vars[variable])
|
|
92
|
+
: vars[variable];
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// Handle Arrays
|
|
96
|
+
if (Array.isArray(type)) {
|
|
97
|
+
const [first] = type;
|
|
98
|
+
const result = [];
|
|
99
|
+
/* eslint-disable no-await-in-loop */
|
|
100
|
+
while (await (0, inquirer_1.inquirerConfirmBoolean)({
|
|
101
|
+
message: `[${variable}[${result.length}]] Add new entry?`,
|
|
102
|
+
})) {
|
|
103
|
+
const datum = {};
|
|
104
|
+
await (0, bluebird_1.mapSeries)(Object.keys(first), async (k) => {
|
|
105
|
+
const data = await (0, inquirer_1.inquirerConfirmText)({
|
|
106
|
+
message: `[${variable}[${result.length}].${k}]:`,
|
|
107
|
+
});
|
|
108
|
+
datum[k] = data;
|
|
109
|
+
});
|
|
110
|
+
result.push(datum);
|
|
111
|
+
}
|
|
112
|
+
/* eslint-enable no-await-in-loop */
|
|
113
|
+
if (result.length > 0) {
|
|
114
|
+
results[variable] = result;
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
// Handle object
|
|
119
|
+
if (type && typeof type === 'object') {
|
|
120
|
+
const shouldRun = await (0, inquirer_1.inquirerConfirmBoolean)({
|
|
121
|
+
message: `[${variable}] Define object?[y/n]`,
|
|
122
|
+
});
|
|
123
|
+
if (shouldRun) {
|
|
124
|
+
const datum = {};
|
|
125
|
+
await (0, bluebird_1.mapSeries)(Object.keys(type), async (k) => {
|
|
126
|
+
const data = await (0, inquirer_1.inquirerConfirmText)({
|
|
127
|
+
message: `[${variable}.${k}]:`,
|
|
128
|
+
});
|
|
129
|
+
datum[k] = data;
|
|
130
|
+
});
|
|
131
|
+
results[variable] = datum;
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// Prompt user
|
|
136
|
+
const result = await (0, inquirer_1.inquirerConfirmText)({
|
|
137
|
+
message: `[${variable}] Fill variable. Type "n" to skip`,
|
|
138
|
+
});
|
|
139
|
+
if (result !== 'n') {
|
|
140
|
+
results[variable] = result;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
// Create new assessment
|
|
144
|
+
const handlebars = (0, ai_1.createHandlebarsWithHelpers)();
|
|
145
|
+
const content = handlebars
|
|
146
|
+
.compile(assessmentTemplate.content)(results)
|
|
147
|
+
// remove empty lines
|
|
148
|
+
.split('\n')
|
|
149
|
+
.filter((x) => x.trim().length > 0)
|
|
150
|
+
.join('\n');
|
|
151
|
+
// Create the assessment
|
|
152
|
+
const assessmentId = await (0, syncAssessments_1.createAssessment)(client, {
|
|
153
|
+
title: templateTitle,
|
|
154
|
+
assessmentTemplateId: assessmentTemplate.id,
|
|
155
|
+
});
|
|
156
|
+
await (0, syncAssessments_1.updateAssessment)(client, {
|
|
157
|
+
id: assessmentId,
|
|
158
|
+
content,
|
|
159
|
+
});
|
|
160
|
+
logger_1.logger.info(colors_1.default.green(`View assessment at https://app.transcend.io/assessments/view/${assessmentId}`));
|
|
161
|
+
}
|
|
162
|
+
main();
|
|
163
|
+
//# sourceMappingURL=cli-create-assessment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-create-assessment.js","sourceRoot":"","sources":["../src/cli-create-assessment.ts"],"names":[],"mappings":";;;;;;AACA,gEAAiC;AACjC,oDAA4B;AAE5B,qCAAkC;AAClC,2CAAoD;AACpD,iFAAiF;AACjF,uCAAwD;AACxD,qGAAkG;AAClG,uCAAqC;AACrC,iDAI4B;AAC5B,iFAA8E;AAC9E,+DAA+E;AAC/E,6BAAmD;AAEnD;;;;;;;;;;;;;;;GAeG;AACH,KAAK,UAAU,IAAI;IACjB,+BAA+B;IAC/B,MAAM;IACJ,4BAA4B;IAC5B,YAAY,GAAG,iCAAqB;IACpC,cAAc;IACd,IAAI;IACJ,iDAAiD;IACjD,QAAQ,GAAG,EAAE;IACb,oCAAoC;IACpC,KAAK,GAAG,EAAE;IACV,kCAAkC;IAClC,SAAS,GAAG,EAAE,GACf,GAAG,IAAA,sBAAK,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAA8B,CAAC;IAE9D,wBAAwB;IACxB,IAAI,CAAC,IAAI,EAAE;QACT,eAAM,CAAC,KAAK,CACV,gBAAM,CAAC,GAAG,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