@transcend-io/cli 4.107.0 → 4.109.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.
Files changed (118) hide show
  1. package/README.md +103 -3
  2. package/build/ai/TranscendPromptManager.d.ts +137 -0
  3. package/build/ai/TranscendPromptManager.d.ts.map +1 -0
  4. package/build/ai/TranscendPromptManager.js +159 -0
  5. package/build/ai/TranscendPromptManager.js.map +1 -0
  6. package/build/ai/index.d.ts +1 -2
  7. package/build/ai/index.d.ts.map +1 -1
  8. package/build/ai/index.js +1 -2
  9. package/build/ai/index.js.map +1 -1
  10. package/build/cli-create-assessment.js +3 -4
  11. package/build/cli-create-assessment.js.map +1 -1
  12. package/build/codecs.d.ts +95 -1
  13. package/build/codecs.d.ts.map +1 -1
  14. package/build/codecs.js +56 -2
  15. package/build/codecs.js.map +1 -1
  16. package/build/constants.d.ts.map +1 -1
  17. package/build/constants.js +8 -0
  18. package/build/constants.js.map +1 -1
  19. package/build/enums.d.ts +5 -1
  20. package/build/enums.d.ts.map +1 -1
  21. package/build/enums.js +4 -0
  22. package/build/enums.js.map +1 -1
  23. package/build/graphql/fetchAllActions.js +1 -1
  24. package/build/graphql/fetchAllActions.js.map +1 -1
  25. package/build/graphql/fetchAllAttributeKeys.js +1 -1
  26. package/build/graphql/fetchAllAttributeKeys.js.map +1 -1
  27. package/build/graphql/fetchAllBusinessEntities.js +1 -1
  28. package/build/graphql/fetchAllBusinessEntities.js.map +1 -1
  29. package/build/graphql/fetchAssessmentTemplates.js +1 -1
  30. package/build/graphql/fetchAssessmentTemplates.js.map +1 -1
  31. package/build/graphql/fetchAssessments.js +1 -1
  32. package/build/graphql/fetchAssessments.js.map +1 -1
  33. package/build/graphql/fetchIdentifiers.js +1 -1
  34. package/build/graphql/fetchIdentifiers.js.map +1 -1
  35. package/build/graphql/fetchPromptGroups.d.ts +22 -0
  36. package/build/graphql/fetchPromptGroups.d.ts.map +1 -0
  37. package/build/graphql/fetchPromptGroups.js +32 -0
  38. package/build/graphql/fetchPromptGroups.js.map +1 -0
  39. package/build/graphql/fetchPromptPartials.d.ts +17 -0
  40. package/build/graphql/fetchPromptPartials.d.ts.map +1 -0
  41. package/build/graphql/fetchPromptPartials.js +32 -0
  42. package/build/graphql/fetchPromptPartials.js.map +1 -0
  43. package/build/graphql/fetchPromptTemplates.d.ts +17 -0
  44. package/build/graphql/fetchPromptTemplates.d.ts.map +1 -0
  45. package/build/graphql/fetchPromptTemplates.js +32 -0
  46. package/build/graphql/fetchPromptTemplates.js.map +1 -0
  47. package/build/graphql/fetchPrompts.d.ts +83 -0
  48. package/build/graphql/fetchPrompts.d.ts.map +1 -0
  49. package/build/graphql/fetchPrompts.js +55 -0
  50. package/build/graphql/fetchPrompts.js.map +1 -0
  51. package/build/graphql/gqls/assessment.js +1 -1
  52. package/build/graphql/gqls/index.d.ts +1 -0
  53. package/build/graphql/gqls/index.d.ts.map +1 -1
  54. package/build/graphql/gqls/index.js +1 -0
  55. package/build/graphql/gqls/index.js.map +1 -1
  56. package/build/graphql/gqls/prompt.d.ts +14 -0
  57. package/build/graphql/gqls/prompt.d.ts.map +1 -0
  58. package/build/graphql/gqls/prompt.js +183 -0
  59. package/build/graphql/gqls/prompt.js.map +1 -0
  60. package/build/graphql/index.d.ts +5 -0
  61. package/build/graphql/index.d.ts.map +1 -1
  62. package/build/graphql/index.js +5 -0
  63. package/build/graphql/index.js.map +1 -1
  64. package/build/graphql/pullTranscendConfiguration.d.ts.map +1 -1
  65. package/build/graphql/pullTranscendConfiguration.js +50 -1
  66. package/build/graphql/pullTranscendConfiguration.js.map +1 -1
  67. package/build/graphql/syncConfigurationToTranscend.d.ts.map +1 -1
  68. package/build/graphql/syncConfigurationToTranscend.js +22 -1
  69. package/build/graphql/syncConfigurationToTranscend.js.map +1 -1
  70. package/build/graphql/syncDataSilos.js +2 -2
  71. package/build/graphql/syncDataSilos.js.map +1 -1
  72. package/build/graphql/syncEnrichers.js +2 -2
  73. package/build/graphql/syncEnrichers.js.map +1 -1
  74. package/build/graphql/syncPromptGroups.d.ts +34 -0
  75. package/build/graphql/syncPromptGroups.d.ts.map +1 -0
  76. package/build/graphql/syncPromptGroups.js +126 -0
  77. package/build/graphql/syncPromptGroups.js.map +1 -0
  78. package/build/graphql/syncPromptPartials.d.ts +32 -0
  79. package/build/graphql/syncPromptPartials.d.ts.map +1 -0
  80. package/build/graphql/syncPromptPartials.js +102 -0
  81. package/build/graphql/syncPromptPartials.js.map +1 -0
  82. package/build/graphql/syncPromptTemplates.d.ts +32 -0
  83. package/build/graphql/syncPromptTemplates.d.ts.map +1 -0
  84. package/build/graphql/syncPromptTemplates.js +102 -0
  85. package/build/graphql/syncPromptTemplates.js.map +1 -0
  86. package/build/graphql/syncPrompts.d.ts +32 -0
  87. package/build/graphql/syncPrompts.d.ts.map +1 -0
  88. package/build/graphql/syncPrompts.js +102 -0
  89. package/build/graphql/syncPrompts.js.map +1 -0
  90. package/build/helpers/index.d.ts +0 -1
  91. package/build/helpers/index.d.ts.map +1 -1
  92. package/build/helpers/index.js +0 -1
  93. package/build/helpers/index.js.map +1 -1
  94. package/build/tests/TranscendPromptManager.test.d.ts +2 -0
  95. package/build/tests/TranscendPromptManager.test.d.ts.map +1 -0
  96. package/build/tests/{TranscendAiPrompt.test.js → TranscendPromptManager.test.js} +25 -13
  97. package/build/tests/TranscendPromptManager.test.js.map +1 -0
  98. package/build/tsbuildinfo +1 -1
  99. package/package.json +3 -5
  100. package/build/ai/TranscendAiPrompt.d.ts +0 -59
  101. package/build/ai/TranscendAiPrompt.d.ts.map +0 -1
  102. package/build/ai/TranscendAiPrompt.js +0 -130
  103. package/build/ai/TranscendAiPrompt.js.map +0 -1
  104. package/build/ai/createHandlebarsWithHelpers.d.ts +0 -25
  105. package/build/ai/createHandlebarsWithHelpers.d.ts.map +0 -1
  106. package/build/ai/createHandlebarsWithHelpers.js +0 -125
  107. package/build/ai/createHandlebarsWithHelpers.js.map +0 -1
  108. package/build/helpers/getVariablesFromHandlebarsTemplate.d.ts +0 -10
  109. package/build/helpers/getVariablesFromHandlebarsTemplate.d.ts.map +0 -1
  110. package/build/helpers/getVariablesFromHandlebarsTemplate.js +0 -108
  111. package/build/helpers/getVariablesFromHandlebarsTemplate.js.map +0 -1
  112. package/build/tests/TranscendAiPrompt.test.d.ts +0 -2
  113. package/build/tests/TranscendAiPrompt.test.d.ts.map +0 -1
  114. package/build/tests/TranscendAiPrompt.test.js.map +0 -1
  115. package/build/tests/getVariablesFromHandlebars.test.d.ts +0 -2
  116. package/build/tests/getVariablesFromHandlebars.test.d.ts.map +0 -1
  117. package/build/tests/getVariablesFromHandlebars.test.js +0 -61
  118. package/build/tests/getVariablesFromHandlebars.test.js.map +0 -1
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Transcend Inc.",
3
3
  "name": "@transcend-io/cli",
4
4
  "description": "Small package containing useful typescript utilities.",
5
- "version": "4.107.0",
5
+ "version": "4.109.0",
6
6
  "homepage": "https://github.com/transcend-io/cli",
7
7
  "repository": {
8
8
  "type": "git",
@@ -58,13 +58,13 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@transcend-io/airgap.js-types": "^10.4.4",
61
+ "@transcend-io/handlebars-utils": "^1.0.1",
61
62
  "@transcend-io/internationalization": "^1.6.0",
62
63
  "@transcend-io/persisted-state": "^1.0.2",
63
- "@transcend-io/privacy-types": "^4.43.0",
64
+ "@transcend-io/privacy-types": "^4.46.0",
64
65
  "@transcend-io/secret-value": "^1.1.1",
65
66
  "@transcend-io/type-utils": "^1.1.1",
66
67
  "bluebird": "^3.7.2",
67
- "change-case": "^4.1.2",
68
68
  "cli-progress": "^3.11.2",
69
69
  "colors": "^1.4.0",
70
70
  "csv-parse": "=4.9.1",
@@ -76,7 +76,6 @@
76
76
  "got": "^11.8.5",
77
77
  "graphql": "^16.6.0",
78
78
  "graphql-request": "^5.0.0",
79
- "handlebars": "^4.7.8",
80
79
  "inquirer": "=7.3.3",
81
80
  "inquirer-autocomplete-prompt": "=1.3.0",
82
81
  "io-ts": "=2.2.16",
@@ -90,7 +89,6 @@
90
89
  "devDependencies": {
91
90
  "@types/bluebird": "^3.5.38",
92
91
  "@types/chai": "^4.3.4",
93
- "@types/change-case": "^2.3.1",
94
92
  "@types/cli-progress": "^3.11.0",
95
93
  "@types/colors": "^1.2.1",
96
94
  "@types/fuzzysearch": "^1.0.0",
@@ -1,59 +0,0 @@
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
- export declare const BUSINESS_ENTITIES_PREFIX = "businessEntities-";
8
- /**
9
- * Define an AI prompt that can be loaded from Transcend
10
- */
11
- export declare class TranscendAiPrompt<TParams extends ObjByString, TOutputCodec extends t.Any> {
12
- /** Title of prompt */
13
- title: string;
14
- /** Codec to validate output response */
15
- codec: TOutputCodec;
16
- /** Handlebars compiler */
17
- handlebars: typeof handlebars;
18
- /** Extract response from this tag */
19
- extractFromTagRegex?: RegExp;
20
- /**
21
- * Constructor
22
- *
23
- * @param options - Options
24
- */
25
- constructor({ title, codec, extractFromTag, handlebarsOptions, }: {
26
- /** Title of prompt in transcend */
27
- title: string;
28
- /** Codec to validate output shape of the prompt */
29
- codec: TOutputCodec;
30
- /** Options for configuring handlebars */
31
- handlebarsOptions?: HandlebarsInput;
32
- /** When provided, the response should be extracted from this tag name e.g. json */
33
- extractFromTag?: string;
34
- });
35
- /**
36
- * Fetch prompt from Transcend
37
- *
38
- * @param options - Additional options
39
- * @returns A function that can be used to call the prompt
40
- */
41
- fetchPromptFromTranscend({ fillTemplateFromInventory, transcendUrl, transcendApiKey, requireApproval, }: {
42
- /** The Transcend API key */
43
- transcendApiKey: string | Secret<string>;
44
- /** When true, template in any attribute definitions in the prompt */
45
- fillTemplateFromInventory?: boolean;
46
- /** API of Transcend to call */
47
- transcendUrl?: string;
48
- /** When true, throw an error if the prompt is not approved */
49
- requireApproval?: boolean;
50
- }): Promise<(params: TParams) => string>;
51
- /**
52
- * Validate the shape of the response from AI
53
- *
54
- * @param response - AI response as string
55
- * @returns Parsed content
56
- */
57
- parseAiResponse(response: string): t.TypeOf<TOutputCodec>;
58
- }
59
- //# sourceMappingURL=TranscendAiPrompt.d.ts.map
@@ -1 +0,0 @@
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;AAS3B,OAAO,EACL,eAAe,EAEhB,MAAM,+BAA+B,CAAC;AAIvC,eAAO,MAAM,yBAAyB,eAAe,CAAC;AACtD,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D;;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,qCAAqC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAEpC;;;;OAIG;gBACS,EACV,KAAK,EACL,KAAK,EACL,cAAc,EACd,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;QACpC,mFAAmF;QACnF,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;IASD;;;;;OAKG;IACG,wBAAwB,CAAC,EAC7B,yBAAgC,EAChC,YAAoC,EACpC,eAAe,EACf,eAAe,GAChB,EAAE;QACD,4BAA4B;QAC5B,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QACzC,qEAAqE;QACrE,yBAAyB,CAAC,EAAE,OAAO,CAAC;QACpC,+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;IA4GxC;;;;;OAKG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;CAM1D"}
@@ -1,130 +0,0 @@
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.BUSINESS_ENTITIES_PREFIX = 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
- exports.BUSINESS_ENTITIES_PREFIX = 'businessEntities-';
18
- /**
19
- * Define an AI prompt that can be loaded from Transcend
20
- */
21
- class TranscendAiPrompt {
22
- /**
23
- * Constructor
24
- *
25
- * @param options - Options
26
- */
27
- constructor({ title, codec, extractFromTag, handlebarsOptions, }) {
28
- this.title = title;
29
- this.codec = codec;
30
- this.handlebars = (0, createHandlebarsWithHelpers_1.createHandlebarsWithHelpers)(handlebarsOptions);
31
- this.extractFromTagRegex = extractFromTag
32
- ? new RegExp(`<${extractFromTag}>([\\s\\S]+?)<\\/${extractFromTag}>`)
33
- : undefined;
34
- }
35
- /**
36
- * Fetch prompt from Transcend
37
- *
38
- * @param options - Additional options
39
- * @returns A function that can be used to call the prompt
40
- */
41
- async fetchPromptFromTranscend({ fillTemplateFromInventory = true, transcendUrl = constants_1.DEFAULT_TRANSCEND_API, transcendApiKey, requireApproval, }) {
42
- // construct GraphQL client
43
- const client = (0, graphql_1.buildTranscendGraphQLClient)(transcendUrl, typeof transcendApiKey === 'string'
44
- ? transcendApiKey
45
- : transcendApiKey.release());
46
- // Fetch the assessments
47
- const assessments = await (0, fetchAssessments_1.fetchAllAssessments)(client, { text: this.title });
48
- // Ensure assessment exists with specified title
49
- const assessment = assessments.find((row) => row.title === this.title);
50
- if (!assessment) {
51
- throw new Error(`Failed to find assessment with title: "${this.title}"`);
52
- }
53
- // Ensure assessment is approved
54
- if (requireApproval && assessment.status !== privacy_types_1.AssessmentStatus.Approved) {
55
- throw new Error(`Assessment "${this.title}" cannot be used because its in status: "${assessment.status}"`);
56
- }
57
- // If assessment is rejected, throw error
58
- if (assessment.status === privacy_types_1.AssessmentStatus.Rejected) {
59
- throw new Error(`Assessment "${this.title}" cannot be used because it's in status: "${assessment.status}"`);
60
- }
61
- // Template attributes into the template string
62
- let extraParams = {};
63
- // Template in attributes
64
- if (fillTemplateFromInventory) {
65
- // pull out the variables from the handlebar string
66
- const schema = (0, getVariablesFromHandlebarsTemplate_1.getVariablesFromHandlebarsTemplate)(assessment.content);
67
- // pull out the attributes to fetch
68
- const attributeToFetch = Object.keys(schema).filter((key) => key.startsWith(exports.EXPECTED_ATTRIBUTE_PREFIX));
69
- // Fetch attributes if there are template variables to fill
70
- if (attributeToFetch.length > 0) {
71
- // TODO: https://transcend.height.app/T-29886 - only fetch attributes needed
72
- const attributeKeys = await (0, graphql_1.fetchAllAttributes)(client);
73
- const attributeKeysAsCamel = attributeKeys.map((key) => ({
74
- ...key,
75
- camelName: (0, camelCase_1.default)(key.name),
76
- }));
77
- const lookupAttributeKey = (0, keyBy_1.default)(attributeKeysAsCamel, 'camelName');
78
- attributeToFetch.forEach((attributeNameWithPrefix) => {
79
- const attributeName = attributeNameWithPrefix.replace(exports.EXPECTED_ATTRIBUTE_PREFIX, '');
80
- const existingAttribute = lookupAttributeKey[attributeName];
81
- if (!existingAttribute) {
82
- throw new Error(`Failed to find attribute with name: "${attributeName}"`);
83
- }
84
- extraParams[attributeNameWithPrefix] = existingAttribute;
85
- });
86
- }
87
- // pull out the attributes to fetch
88
- const businessEntitiesToFetch = Object.keys(schema).filter((key) => key.startsWith(exports.BUSINESS_ENTITIES_PREFIX));
89
- // Fetch business entities if there are template variables to fill
90
- if (businessEntitiesToFetch.length > 0) {
91
- // TODO: https://transcend.height.app/T-29886 - only fetch business needed
92
- // and find a way to template when multiple entities
93
- const businessEntities = await (0, graphql_1.fetchAllBusinessEntities)(client);
94
- const businessEntity = businessEntities[0];
95
- if (businessEntity) {
96
- extraParams = {
97
- ...extraParams,
98
- ...Object.entries(businessEntity).reduce((acc, [key, value]) => Object.assign(acc, { [`businessEntities-${key}`]: value }), {}),
99
- };
100
- extraParams.dataProtectionOfficerName =
101
- businessEntity.dataProtectionOfficerName;
102
- extraParams.dataProtectionOfficerEmail =
103
- businessEntity.dataProtectionOfficerEmail;
104
- }
105
- }
106
- }
107
- // Return function that can compile template with attributes
108
- // and provided parameters
109
- return (params) => this.handlebars.compile(assessment.content)({
110
- // template in currentDate by default
111
- currentDate: new Date().toISOString(),
112
- ...extraParams,
113
- ...params,
114
- });
115
- }
116
- /**
117
- * Validate the shape of the response from AI
118
- *
119
- * @param response - AI response as string
120
- * @returns Parsed content
121
- */
122
- parseAiResponse(response) {
123
- const extracted = this.extractFromTagRegex
124
- ? (this.extractFromTagRegex.exec(response) || [])[1] || response
125
- : response;
126
- return (0, type_utils_1.decodeCodec)(this.codec, extracted);
127
- }
128
- }
129
- exports.TranscendAiPrompt = TranscendAiPrompt;
130
- //# sourceMappingURL=TranscendAiPrompt.js.map
@@ -1 +0,0 @@
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,wCAIoB;AACpB,sGAAmG;AACnG,+EAGuC;AACvC,iEAAyC;AACzC,yDAAiC;AAEpB,QAAA,yBAAyB,GAAG,YAAY,CAAC;AACzC,QAAA,wBAAwB,GAAG,mBAAmB,CAAC;AAE5D;;GAEG;AACH,MAAa,iBAAiB;IAgB5B;;;;OAIG;IACH,YAAY,EACV,KAAK,EACL,KAAK,EACL,cAAc,EACd,iBAAiB,GAUlB;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;QACjE,IAAI,CAAC,mBAAmB,GAAG,cAAc;YACvC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,cAAc,oBAAoB,cAAc,GAAG,CAAC;YACrE,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,wBAAwB,CAAC,EAC7B,yBAAyB,GAAG,IAAI,EAChC,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,eAA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AW;wBACd,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,MAAM,CACtC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CACpB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAoB,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAC5D,EAAE,CACH;qBACF,CAAC;oBACF,WAAW,CAAC,yBAAyB;wBACnC,cAAc,CAAC,yBAAyB,CAAC;oBAC3C,WAAW,CAAC,0BAA0B;wBACpC,cAAc,CAAC,0BAA0B,CAAC;iBAC7C;aACF;SACF;QAED,4DAA4D;QAC5D,0BAA0B;QAC1B,OAAO,CAAC,MAAM,EAAE,EAAE,CAChB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC1C,qCAAqC;YACrC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrC,GAAG,WAAW;YACd,GAAG,MAAM;SACV,CAAC,CAAC;IACP,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,QAAgB;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,mBAAmB;YACxC,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ;YAChE,CAAC,CAAC,QAAQ,CAAC;QACb,OAAO,IAAA,wBAAW,EAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC5C,CAAC;CACF;AAxLD,8CAwLC"}
@@ -1,25 +0,0 @@
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
@@ -1 +0,0 @@
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;AA4GD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,SAAc,EACd,OAAY,GACb,GAAE,eAAoB,GAAG,OAAO,UAAU,CAc1C"}
@@ -1,125 +0,0 @@
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
- }),
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
@@ -1 +0,0 @@
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;IAC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ACrB;QACD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACJ;;;;;;;OAOG;IACH,QAAQ,EAAE,SAAS,QAAQ,CACzB,IAAY,EACZ,IAAY,EACZ,OAAiC;QAEjC,OAAO,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,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"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Get variables from handlebars template
3
- *
4
- * @param template - Template
5
- * @returns Variables
6
- */
7
- export declare function getVariablesFromHandlebarsTemplate(template: string): {
8
- [k in string]: unknown;
9
- };
10
- //# sourceMappingURL=getVariablesFromHandlebarsTemplate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getVariablesFromHandlebarsTemplate.d.ts","sourceRoot":"","sources":["../../src/helpers/getVariablesFromHandlebarsTemplate.ts"],"names":[],"mappings":"AAyEA;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,MAAM,GAAG;KACnE,CAAC,IAAI,MAAM,GAAG,OAAO;CACvB,CAkCA"}
@@ -1,108 +0,0 @@
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.getVariablesFromHandlebarsTemplate = void 0;
7
- const handlebars_1 = __importDefault(require("handlebars"));
8
- /**
9
- * Parse AST for variables
10
- *
11
- * @param statement - Statement to parse
12
- * @returns Variables
13
- */
14
- function parseHandlebarsAst(statement) {
15
- // No variables
16
- if (statement.type === 'ContentStatement') {
17
- return {};
18
- }
19
- if (statement.type === 'PartialStatement') {
20
- const moustacheStatement = statement;
21
- const pathStatement = moustacheStatement.name;
22
- return {
23
- [pathStatement.original]: 'partial',
24
- };
25
- }
26
- // Parse variables from {{ var }}
27
- if (statement.type === 'MustacheStatement') {
28
- const moustacheStatement = statement;
29
- const paramsExpressionList = moustacheStatement.params;
30
- const pathExpression = moustacheStatement.path;
31
- const vars = [
32
- ...paramsExpressionList.map(({ original }) => original),
33
- pathExpression.original,
34
- ].filter((x) => !!x);
35
- return vars.reduce((acc, x) => Object.assign(acc, { [x]: null }), {});
36
- }
37
- // Parse from {{#each}} or {{#with}}
38
- if (statement.type === 'BlockStatement' && statement) {
39
- const moustacheStatement = statement;
40
- const paramsExpressionList = moustacheStatement.params;
41
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
- const program = moustacheStatement.program;
43
- const param = paramsExpressionList[0];
44
- const pathExpression = moustacheStatement.path;
45
- if (param.type === 'SubExpression') {
46
- return program.body
47
- .map(parseHandlebarsAst)
48
- .reduce((acc, obj) => Object.assign(acc, obj), {});
49
- }
50
- if (pathExpression.original === 'each') {
51
- return {
52
- [param.original]: [
53
- program.body
54
- .map(parseHandlebarsAst)
55
- .reduce((acc, obj) => Object.assign(acc, obj), {}),
56
- ],
57
- };
58
- }
59
- return {
60
- [param.original]: program.body
61
- .map(parseHandlebarsAst)
62
- .reduce((acc, obj) => Object.assign(acc, obj), {}),
63
- };
64
- }
65
- throw new Error(`Unknown statement: ${statement.type}`);
66
- }
67
- /**
68
- * Get variables from handlebars template
69
- *
70
- * @param template - Template
71
- * @returns Variables
72
- */
73
- function getVariablesFromHandlebarsTemplate(template) {
74
- const ast = handlebars_1.default.parseWithoutProcessing(template);
75
- const results = ast.body.map(parseHandlebarsAst);
76
- return results.reduce((acc, data) => {
77
- Object.entries(data).forEach(([k, v]) => {
78
- const existing = acc[k];
79
- if (!existing) {
80
- return Object.assign(acc, { [k]: v });
81
- }
82
- if (Array.isArray(existing) && Array.isArray(v)) {
83
- return Object.assign(acc, {
84
- [k]: [
85
- {
86
- ...existing[0],
87
- ...v[0],
88
- },
89
- ],
90
- });
91
- }
92
- if (typeof existing === 'object' && typeof v === 'object') {
93
- return Object.assign(acc, {
94
- [k]: {
95
- ...existing,
96
- ...v,
97
- },
98
- });
99
- }
100
- return Object.assign(acc, {
101
- [k]: v,
102
- });
103
- });
104
- return acc;
105
- }, {});
106
- }
107
- exports.getVariablesFromHandlebarsTemplate = getVariablesFromHandlebarsTemplate;
108
- //# sourceMappingURL=getVariablesFromHandlebarsTemplate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getVariablesFromHandlebarsTemplate.js","sourceRoot":"","sources":["../../src/helpers/getVariablesFromHandlebarsTemplate.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAoC;AAEpC;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,SAA4B;IAGtD,eAAe;IACf,IAAI,SAAS,CAAC,IAAI,KAAK,kBAAkB,EAAE;QACzC,OAAO,EAAE,CAAC;KACX;IAED,IAAI,SAAS,CAAC,IAAI,KAAK,kBAAkB,EAAE;QACzC,MAAM,kBAAkB,GAAG,SAAqC,CAAC;QACjE,MAAM,aAAa,GAAG,kBAAkB,CAAC,IAA8B,CAAC;QACxE,OAAO;Y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CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;aACvC;YACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;gBAC/C,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;oBACxB,CAAC,CAAC,CAAC,EAAE;wBACH;4BACE,GAAG,QAAQ,CAAC,CAAC,CAAC;4BACd,GAAG,CAAC,CAAC,CAAC,CAAC;yBACR;qBACF;iBACF,CAAC,CAAC;aACJ;YACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;gBACzD,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;oBACxB,CAAC,CAAC,CAAC,EAAE;wBACH,GAAG,QAAQ;wBACX,GAAG,CAAC;qBACL;iBACF,CAAC,CAAC;aACJ;YACD,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;gBACxB,CAAC,CAAC,CAAC,EAAE,CAAC;aACP,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AApCD,gFAoCC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TranscendAiPrompt.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TranscendAiPrompt.test.d.ts","sourceRoot":"","sources":["../../src/tests/TranscendAiPrompt.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"TranscendAiPrompt.test.js","sourceRoot":"","sources":["../../src/tests/TranscendAiPrompt.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,yCAA2B;AAC3B,+DAA4D;AAE5D,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,MAAM,QAAQ,GAAG,IAAI,qCAAiB,CAAC;QACrC,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QACxB,cAAc,EAAE,MAAM;KACvB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG;;;;;;;CAOnB,CAAC;IAEA,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC7B,IAAA,aAAM,EAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;YACxD,MAAM;YACN,OAAO;YACP,YAAY;YACZ,QAAQ;YACR,QAAQ;SACT,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG;;;;;;;;;;;GAWlB,CAAC;IAEF,MAAM,SAAS,GAAG,IAAI,qCAAiB,CAAC;QACtC,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACnC,cAAc,EAAE,MAAM;KACvB,CAAC,CAAC;IAEH,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC7B,IAAA,aAAM,EAAC,SAAS,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;YAC1D,KAAK,EAAE,8DAA8D;YACrE,WAAW,EACT,kGAAkG;YACpG,UAAU,EACR,+DAA+D;YACjE,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,YAAY;SACvB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=getVariablesFromHandlebars.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getVariablesFromHandlebars.test.d.ts","sourceRoot":"","sources":["../../src/tests/getVariablesFromHandlebars.test.ts"],"names":[],"mappings":""}
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chai_1 = require("chai");
4
- const getVariablesFromHandlebarsTemplate_1 = require("../helpers/getVariablesFromHandlebarsTemplate");
5
- const TEST_HBS = `
6
- <p>
7
- You are an experienced project manager, constantly juggling a variety of different tasks.
8
- Other employees at your company are very busy.
9
- They quickly record notes in slack of things that they want to look into later.
10
- You are tasked with reviewing those raw notes, and turning them into a structured
11
- form that will make the notes more easily indexable by the employee when they have more time to review the information.
12
- {{{ description }}}. Return a JSON object in the following format:
13
-
14
- ({{#each parameters}}{{ name }} - {{slug}}, {{/each}}clarification).
15
- </p>
16
-
17
- {{> promptPartialTodaysDate }}
18
-
19
- {{> promptPartialTranscendProducts }}
20
-
21
-
22
- {{#with dog}}{{cat}} - {{fish}}{{/with}}
23
-
24
- {{#if (listLen extraContext)}}
25
- {{#each extraContext}}
26
- {{ name }}
27
- {{/each}}
28
- {{/if}}
29
-
30
- <p>
31
- The following rules define each of the input parameters:
32
- <ul>
33
- {{#each parameters}}
34
- <li>{{ name }}: {{{ description }}}</li>
35
- {{/each}}
36
- </ul>
37
- </p>
38
-
39
- {{#with dog}} {{meow}}{{/with}}
40
-
41
- <p>
42
- If any of the parameters are not known, it should be set to null.
43
- If anything is not clear, return a prompt in the clarification key of the response asking for further detail
44
- </p>`;
45
- describe('getVariablesFromHandlebars', () => {
46
- it('should merge together', () => {
47
- (0, chai_1.expect)((0, getVariablesFromHandlebarsTemplate_1.getVariablesFromHandlebarsTemplate)(TEST_HBS)).to.deep.equal({
48
- description: null,
49
- parameters: [{ name: null, slug: null, description: null }],
50
- dog: { cat: null, fish: null, meow: null },
51
- extraContext: [
52
- {
53
- name: null,
54
- },
55
- ],
56
- promptPartialTodaysDate: 'partial',
57
- promptPartialTranscendProducts: 'partial',
58
- });
59
- });
60
- });
61
- //# sourceMappingURL=getVariablesFromHandlebars.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getVariablesFromHandlebars.test.js","sourceRoot":"","sources":["../../src/tests/getVariablesFromHandlebars.test.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAE9B,sGAAmG;AAEnG,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuCZ,CAAC;AAEN,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,IAAA,aAAM,EAAC,IAAA,uEAAkC,EAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;YACjE,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;YAC3D,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;YAC1C,YAAY,EAAE;gBACZ;oBACE,IAAI,EAAE,IAAI;iBACX;aACF;YACD,uBAAuB,EAAE,SAAS;YAClC,8BAA8B,EAAE,SAAS;SAC1C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}