@transcend-io/cli 4.95.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/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.js +3 -2
- package/build/cli-create-assessment.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 +12 -7
- package/build/codecs.d.ts.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 +7 -1
- package/build/graphql/gqls/assessment.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.map +1 -1
- package/build/helpers/getVariablesFromHandlebarsTemplate.js +6 -9
- package/build/helpers/getVariablesFromHandlebarsTemplate.js.map +1 -1
- 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/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/tsbuildinfo +1 -1
- package/package.json +5 -2
|
@@ -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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,CAAC,uBAAuB,EAAE,EAAE;oBACnD,MAAM,aAAa,GAAG,uBAAuB,CAAC,OAAO,CACnD,iCAAyB,EACzB,EAAE,CACH,CAAC;oBACF,MAAM,iBAAiB,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,EA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C,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;CACF,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,2BAA2B,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"}
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const handlebars_1 = __importDefault(require("handlebars"));
|
|
8
7
|
const yargs_parser_1 = __importDefault(require("yargs-parser"));
|
|
9
8
|
const colors_1 = __importDefault(require("colors"));
|
|
10
9
|
const logger_1 = require("./logger");
|
|
@@ -16,6 +15,7 @@ const bluebird_1 = require("bluebird");
|
|
|
16
15
|
const inquirer_1 = require("./helpers/inquirer");
|
|
17
16
|
const parseVariablesFromString_1 = require("./helpers/parseVariablesFromString");
|
|
18
17
|
const syncAssessments_1 = require("./graphql/syncAssessments");
|
|
18
|
+
const ai_1 = require("./ai");
|
|
19
19
|
/**
|
|
20
20
|
* Create a new assessment from an assessment template
|
|
21
21
|
*
|
|
@@ -141,7 +141,8 @@ async function main() {
|
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
143
|
// Create new assessment
|
|
144
|
-
const
|
|
144
|
+
const handlebars = (0, ai_1.createHandlebarsWithHelpers)();
|
|
145
|
+
const content = handlebars
|
|
145
146
|
.compile(assessmentTemplate.content)(results)
|
|
146
147
|
// remove empty lines
|
|
147
148
|
.split('\n')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-create-assessment.js","sourceRoot":"","sources":["../src/cli-create-assessment.ts"],"names":[],"mappings":";;;;;;AACA,
|
|
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,CACR,uFAAuF,CACxF,CACF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,8CAA8C;IAC9C,IAAI,aAAa,GAAG,KAAK,CAAC;IAC1B,IAAI,CAAC,aAAa,EAAE;QAClB,aAAa,GAAG,MAAM,IAAA,8BAAmB,EAAC;YACxC,OAAO,EAAE,+CAA+C;SACzD,CAAC,CAAC;KACJ;IAED,oBAAoB;IACpB,MAAM,MAAM,GAAG,IAAA,qCAA2B,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xB,MAAM,YAAY,GAAG,MAAM,IAAA,kCAAgB,EAAC,MAAM,EAAE;QAClD,KAAK,EAAE,aAAa;QACpB,oBAAoB,EAAE,kBAAkB,CAAC,EAAE;KAC5C,CAAC,CAAC;IACH,MAAM,IAAA,kCAAgB,EAAC,MAAM,EAAE;QAC7B,EAAE,EAAE,YAAY;QAChB,OAAO;KACR,CAAC,CAAC;IACH,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,KAAK,CACV,gEAAgE,YAAY,EAAE,CAC/E,CACF,CAAC;AACJ,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-test.d.ts","sourceRoot":"","sources":["../src/cli-test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
const yargs_parser_1 = __importDefault(require("yargs-parser"));
|
|
31
|
+
const t = __importStar(require("io-ts"));
|
|
32
|
+
const colors_1 = __importDefault(require("colors"));
|
|
33
|
+
const logger_1 = require("./logger");
|
|
34
|
+
const constants_1 = require("./constants");
|
|
35
|
+
const ai_1 = require("./ai");
|
|
36
|
+
/**
|
|
37
|
+
* FIXME
|
|
38
|
+
*/
|
|
39
|
+
async function main() {
|
|
40
|
+
// Parse command line arguments
|
|
41
|
+
const { transcendUrl = constants_1.DEFAULT_TRANSCEND_API, auth, title, } = (0, yargs_parser_1.default)(process.argv.slice(2));
|
|
42
|
+
// Ensure auth is passed
|
|
43
|
+
if (!auth) {
|
|
44
|
+
logger_1.logger.error(colors_1.default.red('A Transcend API key must be provided. You can specify using --auth=$TRANSCEND_API_KEY'));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
// Ensure title is passed
|
|
48
|
+
if (!title) {
|
|
49
|
+
logger_1.logger.error(colors_1.default.red('A prompt title must be provided'));
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
const codec = t.type({
|
|
53
|
+
product: t.string,
|
|
54
|
+
clarification: t.union([t.string, t.null]),
|
|
55
|
+
});
|
|
56
|
+
const prompt = new ai_1.TranscendAiPrompt({
|
|
57
|
+
title,
|
|
58
|
+
codec,
|
|
59
|
+
});
|
|
60
|
+
const createPromptString = await prompt.fetchPromptFromTranscend({
|
|
61
|
+
transcendApiKey: auth,
|
|
62
|
+
transcendUrl,
|
|
63
|
+
fillTemplateWithAttributes: true,
|
|
64
|
+
requireApproval: false,
|
|
65
|
+
});
|
|
66
|
+
const template = createPromptString({ slackChannelName: 'my-channel' });
|
|
67
|
+
console.log(template);
|
|
68
|
+
const parsed = prompt.parseAiResponse('{ "product": "test", "clarification": null }');
|
|
69
|
+
console.log(parsed);
|
|
70
|
+
}
|
|
71
|
+
main();
|
|
72
|
+
//# sourceMappingURL=cli-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-test.js","sourceRoot":"","sources":["../src/cli-test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gEAAiC;AACjC,yCAA2B;AAC3B,oDAA4B;AAE5B,qCAAkC;AAClC,2CAAoD;AACpD,6BAAyC;AAEzC;;GAEG;AACH,KAAK,UAAU,IAAI;IACjB,+BAA+B;IAC/B,MAAM,EACJ,YAAY,GAAG,iCAAqB,EACpC,IAAI,EACJ,KAAK,GACN,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,CACR,uFAAuF,CACxF,CACF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,yBAAyB;IACzB,IAAI,CAAC,KAAK,EAAE;QACV,eAAM,CAAC,KAAK,CAAC,gBAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC,CAAC;QAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC;QACnB,OAAO,EAAE,CAAC,CAAC,MAAM;QACjB,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;KAC3C,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,IAAI,sBAAiB,CAMlC;QACA,KAAK;QACL,KAAK;KACN,CAAC,CAAC;IACH,MAAM,kBAAkB,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC;QAC/D,eAAe,EAAE,IAAI;QACrB,YAAY;QACZ,0BAA0B,EAAE,IAAI;QAChC,eAAe,EAAE,KAAK;KACvB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAC,CAAC;IACxE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtB,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CACnC,+CAA+C,CAChD,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/build/codecs.d.ts
CHANGED
|
@@ -98,8 +98,8 @@ export declare const EnricherInput: t.IntersectionC<[t.TypeC<{
|
|
|
98
98
|
* The status that the enricher should transfer to when condition is met.
|
|
99
99
|
*/
|
|
100
100
|
transitionRequestStatus: t.KeyofC<{
|
|
101
|
-
CANCELED: unknown;
|
|
102
101
|
ON_HOLD: unknown;
|
|
102
|
+
CANCELED: unknown;
|
|
103
103
|
}>;
|
|
104
104
|
/**
|
|
105
105
|
* For twilio integration - the phone numbers that can be used to send text codes
|
|
@@ -5577,6 +5577,7 @@ export declare const DataCategoryInput: t.IntersectionC<[t.TypeC<{
|
|
|
5577
5577
|
DEVICE: unknown;
|
|
5578
5578
|
SURVEY: unknown;
|
|
5579
5579
|
NOT_PERSONAL_DATA: unknown;
|
|
5580
|
+
INTEGRATION_IDENTIFIER: unknown;
|
|
5580
5581
|
}>;
|
|
5581
5582
|
}>, t.PartialC<{
|
|
5582
5583
|
/** User-defined name for this sub category */
|
|
@@ -5733,6 +5734,7 @@ export declare const FieldInput: t.IntersectionC<[t.TypeC<{
|
|
|
5733
5734
|
DEVICE: unknown;
|
|
5734
5735
|
SURVEY: unknown;
|
|
5735
5736
|
NOT_PERSONAL_DATA: unknown;
|
|
5737
|
+
INTEGRATION_IDENTIFIER: unknown;
|
|
5736
5738
|
}>;
|
|
5737
5739
|
}>, t.PartialC<{
|
|
5738
5740
|
/** User-defined name for this sub category */
|
|
@@ -5906,6 +5908,7 @@ export declare const DatapointInput: t.IntersectionC<[t.TypeC<{
|
|
|
5906
5908
|
DEVICE: unknown;
|
|
5907
5909
|
SURVEY: unknown;
|
|
5908
5910
|
NOT_PERSONAL_DATA: unknown;
|
|
5911
|
+
INTEGRATION_IDENTIFIER: unknown;
|
|
5909
5912
|
}>;
|
|
5910
5913
|
}>, t.PartialC<{
|
|
5911
5914
|
/** User-defined name for this sub category */
|
|
@@ -27834,6 +27837,7 @@ export declare const ConsentManageExperienceInput: t.IntersectionC<[t.TypeC<{
|
|
|
27834
27837
|
* Browser languages that define this regional experience
|
|
27835
27838
|
*/
|
|
27836
27839
|
browserLanguages: t.ArrayC<t.KeyofC<{
|
|
27840
|
+
no: unknown;
|
|
27837
27841
|
om: unknown;
|
|
27838
27842
|
ab: unknown;
|
|
27839
27843
|
aa: unknown;
|
|
@@ -27982,7 +27986,6 @@ export declare const ConsentManageExperienceInput: t.IntersectionC<[t.TypeC<{
|
|
|
27982
27986
|
mn: unknown;
|
|
27983
27987
|
na: unknown;
|
|
27984
27988
|
ne: unknown;
|
|
27985
|
-
no: unknown;
|
|
27986
27989
|
nb: unknown;
|
|
27987
27990
|
nn: unknown;
|
|
27988
27991
|
"no-NO": unknown;
|
|
@@ -28551,8 +28554,8 @@ export declare const ConsentManagerInput: t.PartialC<{
|
|
|
28551
28554
|
}>;
|
|
28552
28555
|
/** Whether the site owner has signed the IAB agreement */
|
|
28553
28556
|
signedIabAgreement: t.KeyofC<{
|
|
28554
|
-
no: unknown;
|
|
28555
28557
|
yes: unknown;
|
|
28558
|
+
no: unknown;
|
|
28556
28559
|
unknown: unknown;
|
|
28557
28560
|
}>;
|
|
28558
28561
|
/** Whether or not to use the US Privacy API */
|
|
@@ -33996,6 +33999,7 @@ export declare const ConsentManagerInput: t.PartialC<{
|
|
|
33996
33999
|
* Browser languages that define this regional experience
|
|
33997
34000
|
*/
|
|
33998
34001
|
browserLanguages: t.ArrayC<t.KeyofC<{
|
|
34002
|
+
no: unknown;
|
|
33999
34003
|
om: unknown;
|
|
34000
34004
|
ab: unknown;
|
|
34001
34005
|
aa: unknown;
|
|
@@ -34144,7 +34148,6 @@ export declare const ConsentManagerInput: t.PartialC<{
|
|
|
34144
34148
|
mn: unknown;
|
|
34145
34149
|
na: unknown;
|
|
34146
34150
|
ne: unknown;
|
|
34147
|
-
no: unknown;
|
|
34148
34151
|
nb: unknown;
|
|
34149
34152
|
nn: unknown;
|
|
34150
34153
|
"no-NO": unknown;
|
|
@@ -34901,6 +34904,7 @@ export declare const DataSiloInput: t.IntersectionC<[t.TypeC<{
|
|
|
34901
34904
|
DEVICE: unknown;
|
|
34902
34905
|
SURVEY: unknown;
|
|
34903
34906
|
NOT_PERSONAL_DATA: unknown;
|
|
34907
|
+
INTEGRATION_IDENTIFIER: unknown;
|
|
34904
34908
|
}>;
|
|
34905
34909
|
}>, t.PartialC<{
|
|
34906
34910
|
/** User-defined name for this sub category */
|
|
@@ -40433,8 +40437,8 @@ export declare const TranscendInput: t.PartialC<{
|
|
|
40433
40437
|
* The status that the enricher should transfer to when condition is met.
|
|
40434
40438
|
*/
|
|
40435
40439
|
transitionRequestStatus: t.KeyofC<{
|
|
40436
|
-
CANCELED: unknown;
|
|
40437
40440
|
ON_HOLD: unknown;
|
|
40441
|
+
CANCELED: unknown;
|
|
40438
40442
|
}>;
|
|
40439
40443
|
/**
|
|
40440
40444
|
* For twilio integration - the phone numbers that can be used to send text codes
|
|
@@ -62422,6 +62426,7 @@ export declare const TranscendInput: t.PartialC<{
|
|
|
62422
62426
|
DEVICE: unknown;
|
|
62423
62427
|
SURVEY: unknown;
|
|
62424
62428
|
NOT_PERSONAL_DATA: unknown;
|
|
62429
|
+
INTEGRATION_IDENTIFIER: unknown;
|
|
62425
62430
|
}>;
|
|
62426
62431
|
}>, t.PartialC<{
|
|
62427
62432
|
/** User-defined name for this sub category */
|
|
@@ -68026,8 +68031,8 @@ export declare const TranscendInput: t.PartialC<{
|
|
|
68026
68031
|
}>;
|
|
68027
68032
|
/** Whether the site owner has signed the IAB agreement */
|
|
68028
68033
|
signedIabAgreement: t.KeyofC<{
|
|
68029
|
-
no: unknown;
|
|
68030
68034
|
yes: unknown;
|
|
68035
|
+
no: unknown;
|
|
68031
68036
|
unknown: unknown;
|
|
68032
68037
|
}>;
|
|
68033
68038
|
/** Whether or not to use the US Privacy API */
|
|
@@ -73471,6 +73476,7 @@ export declare const TranscendInput: t.PartialC<{
|
|
|
73471
73476
|
* Browser languages that define this regional experience
|
|
73472
73477
|
*/
|
|
73473
73478
|
browserLanguages: t.ArrayC<t.KeyofC<{
|
|
73479
|
+
no: unknown;
|
|
73474
73480
|
om: unknown;
|
|
73475
73481
|
ab: unknown;
|
|
73476
73482
|
aa: unknown;
|
|
@@ -73619,7 +73625,6 @@ export declare const TranscendInput: t.PartialC<{
|
|
|
73619
73625
|
mn: unknown;
|
|
73620
73626
|
na: unknown;
|
|
73621
73627
|
ne: unknown;
|
|
73622
|
-
no: unknown;
|
|
73623
73628
|
nb: unknown;
|
|
73624
73629
|
nn: unknown;
|
|
73625
73630
|
"no-NO": unknown;
|