@transcend-io/cli 4.116.1 → 4.117.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/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.116.1",
5
+ "version": "4.117.0",
6
6
  "homepage": "https://github.com/transcend-io/cli",
7
7
  "repository": {
8
8
  "type": "git",
@@ -61,7 +61,7 @@
61
61
  "@transcend-io/handlebars-utils": "^1.0.1",
62
62
  "@transcend-io/internationalization": "^1.6.0",
63
63
  "@transcend-io/persisted-state": "^1.0.2",
64
- "@transcend-io/privacy-types": "^4.54.1",
64
+ "@transcend-io/privacy-types": "^4.56.0",
65
65
  "@transcend-io/secret-value": "^1.1.1",
66
66
  "@transcend-io/type-utils": "^1.1.1",
67
67
  "bluebird": "^3.7.2",
@@ -1,17 +0,0 @@
1
- import { GraphQLClient } from 'graphql-request';
2
- export interface PromptTemplate {
3
- /** ID of prompts */
4
- id: string;
5
- /** The title of the prompt template. */
6
- title: string;
7
- /** The content of the prompt template. */
8
- content: string;
9
- }
10
- /**
11
- * Fetch all PromptTemplates in the organization
12
- *
13
- * @param client - GraphQL client
14
- * @returns All PromptTemplates in the organization
15
- */
16
- export declare function fetchAllPromptTemplates(client: GraphQLClient): Promise<PromptTemplate[]>;
17
- //# sourceMappingURL=fetchPromptTemplates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetchPromptTemplates.d.ts","sourceRoot":"","sources":["../../src/graphql/fetchPromptTemplates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;CACjB;AAID;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,cAAc,EAAE,CAAC,CA0B3B"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchAllPromptTemplates = void 0;
4
- const gqls_1 = require("./gqls");
5
- const makeGraphQLRequest_1 = require("./makeGraphQLRequest");
6
- const PAGE_SIZE = 20;
7
- /**
8
- * Fetch all PromptTemplates in the organization
9
- *
10
- * @param client - GraphQL client
11
- * @returns All PromptTemplates in the organization
12
- */
13
- async function fetchAllPromptTemplates(client) {
14
- const promptTemplates = [];
15
- let offset = 0;
16
- // Whether to continue looping
17
- let shouldContinue = false;
18
- do {
19
- const { promptTemplates: { nodes },
20
- // eslint-disable-next-line no-await-in-loop
21
- } = await (0, makeGraphQLRequest_1.makeGraphQLRequest)(client, gqls_1.PROMPT_TEMPLATES, {
22
- first: PAGE_SIZE,
23
- offset,
24
- });
25
- promptTemplates.push(...nodes);
26
- offset += PAGE_SIZE;
27
- shouldContinue = nodes.length === PAGE_SIZE;
28
- } while (shouldContinue);
29
- return promptTemplates.sort((a, b) => a.title.localeCompare(b.title));
30
- }
31
- exports.fetchAllPromptTemplates = fetchAllPromptTemplates;
32
- //# sourceMappingURL=fetchPromptTemplates.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetchPromptTemplates.js","sourceRoot":"","sources":["../../src/graphql/fetchPromptTemplates.ts"],"names":[],"mappings":";;;AACA,iCAA0C;AAC1C,6DAA0D;AAW1D,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;;;GAKG;AACI,KAAK,UAAU,uBAAuB,CAC3C,MAAqB;IAErB,MAAM,eAAe,GAAqB,EAAE,CAAC;IAC7C,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,8BAA8B;IAC9B,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,GAAG;QACD,MAAM,EACJ,eAAe,EAAE,EAAE,KAAK,EAAE;QAC1B,4CAA4C;UAC7C,GAAG,MAAM,IAAA,uCAAkB,EAMzB,MAAM,EAAE,uBAAgB,EAAE;YAC3B,KAAK,EAAE,SAAS;YAChB,MAAM;SACP,CAAC,CAAC;QACH,eAAe,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAC/B,MAAM,IAAI,SAAS,CAAC;QACpB,cAAc,GAAG,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC;KAC7C,QAAQ,cAAc,EAAE;IAEzB,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACxE,CAAC;AA5BD,0DA4BC"}
@@ -1,32 +0,0 @@
1
- import { PromptTemplateInput } from '../codecs';
2
- import { GraphQLClient } from 'graphql-request';
3
- /**
4
- * Create a new prompt template
5
- *
6
- * @param client - GraphQL client
7
- * @param input - Prompt input
8
- * @returns Prompt template ID
9
- */
10
- export declare function createPromptTemplate(client: GraphQLClient, input: {
11
- /** Title of prompt template */
12
- title: string;
13
- /** Prompt content */
14
- content: string;
15
- }): Promise<string>;
16
- /**
17
- * Update a set of existing prompt templates
18
- *
19
- * @param client - GraphQL client
20
- * @param input - Prompt input
21
- */
22
- export declare function updatePromptTemplates(client: GraphQLClient, input: [PromptTemplateInput, string][]): Promise<void>;
23
- /**
24
- * Sync the prompt templates
25
- *
26
- * @param client - GraphQL client
27
- * @param promptTemplates - PromptTemplates
28
- * @param concurrency - Concurrency
29
- * @returns True if synced successfully
30
- */
31
- export declare function syncPromptTemplates(client: GraphQLClient, promptTemplates: PromptTemplateInput[], concurrency?: number): Promise<boolean>;
32
- //# sourceMappingURL=syncPromptTemplates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncPromptTemplates.d.ts","sourceRoot":"","sources":["../../src/graphql/syncPromptTemplates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE;IACL,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CAAC,MAAM,CAAC,CAmBjB;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,CAAC,mBAAmB,EAAE,MAAM,CAAC,EAAE,GACrC,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,eAAe,EAAE,mBAAmB,EAAE,EACtC,WAAW,SAAK,GACf,OAAO,CAAC,OAAO,CAAC,CA4ElB"}
@@ -1,102 +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.syncPromptTemplates = exports.updatePromptTemplates = exports.createPromptTemplate = void 0;
7
- const colors_1 = __importDefault(require("colors"));
8
- const gqls_1 = require("./gqls");
9
- const makeGraphQLRequest_1 = require("./makeGraphQLRequest");
10
- const bluebird_1 = require("bluebird");
11
- const fetchPromptTemplates_1 = require("./fetchPromptTemplates");
12
- const keyBy_1 = __importDefault(require("lodash/keyBy"));
13
- const logger_1 = require("../logger");
14
- /**
15
- * Create a new prompt template
16
- *
17
- * @param client - GraphQL client
18
- * @param input - Prompt input
19
- * @returns Prompt template ID
20
- */
21
- async function createPromptTemplate(client, input) {
22
- const { createPromptTemplate: { promptTemplate }, } = await (0, makeGraphQLRequest_1.makeGraphQLRequest)(client, gqls_1.CREATE_PROMPT_TEMPLATE, {
23
- input,
24
- });
25
- logger_1.logger.info(colors_1.default.green(`Successfully created prompt template "${input.title}"!`));
26
- return promptTemplate.id;
27
- }
28
- exports.createPromptTemplate = createPromptTemplate;
29
- /**
30
- * Update a set of existing prompt templates
31
- *
32
- * @param client - GraphQL client
33
- * @param input - Prompt input
34
- */
35
- async function updatePromptTemplates(client, input) {
36
- await (0, makeGraphQLRequest_1.makeGraphQLRequest)(client, gqls_1.UPDATE_PROMPT_TEMPLATES, {
37
- input: {
38
- promptTemplates: input.map(([input, id]) => ({
39
- ...input,
40
- id,
41
- })),
42
- },
43
- });
44
- logger_1.logger.info(colors_1.default.green(`Successfully updated ${input.length} prompt templates!`));
45
- }
46
- exports.updatePromptTemplates = updatePromptTemplates;
47
- /**
48
- * Sync the prompt templates
49
- *
50
- * @param client - GraphQL client
51
- * @param promptTemplates - PromptTemplates
52
- * @param concurrency - Concurrency
53
- * @returns True if synced successfully
54
- */
55
- async function syncPromptTemplates(client, promptTemplates, concurrency = 20) {
56
- let encounteredError = false;
57
- logger_1.logger.info(colors_1.default.magenta(`Syncing "${promptTemplates.length}" prompt templates...`));
58
- // Index existing prompt templates
59
- const existing = await (0, fetchPromptTemplates_1.fetchAllPromptTemplates)(client);
60
- const promptTemplateByTitle = (0, keyBy_1.default)(existing, 'title');
61
- // Determine which promptTemplates are new vs existing
62
- const mapPromptTemplatesToExisting = promptTemplates.map((promptInput) => {
63
- var _a;
64
- return [
65
- promptInput,
66
- (_a = promptTemplateByTitle[promptInput.title]) === null || _a === void 0 ? void 0 : _a.id,
67
- ];
68
- });
69
- // Create the new promptTemplates
70
- const newPromptTemplates = mapPromptTemplatesToExisting
71
- .filter(([, existing]) => !existing)
72
- .map(([promptInput]) => promptInput);
73
- try {
74
- logger_1.logger.info(colors_1.default.magenta(`Creating "${newPromptTemplates.length}" new prompt templates...`));
75
- await (0, bluebird_1.map)(newPromptTemplates, async (prompt) => {
76
- await createPromptTemplate(client, prompt);
77
- }, {
78
- concurrency,
79
- });
80
- logger_1.logger.info(colors_1.default.green(`Successfully synced ${newPromptTemplates.length} prompt templates!`));
81
- }
82
- catch (err) {
83
- encounteredError = true;
84
- logger_1.logger.info(colors_1.default.red(`Failed to create prompt templates! - ${err.message}`));
85
- }
86
- // Update existing promptTemplates
87
- const existingPromptTemplates = mapPromptTemplatesToExisting.filter((x) => !!x[1]);
88
- try {
89
- logger_1.logger.info(colors_1.default.magenta(`Updating "${existingPromptTemplates.length}" prompt templates...`));
90
- await updatePromptTemplates(client, existingPromptTemplates);
91
- logger_1.logger.info(colors_1.default.green(`Successfully updated "${existingPromptTemplates.length}" prompt templates!`));
92
- }
93
- catch (err) {
94
- encounteredError = true;
95
- logger_1.logger.info(colors_1.default.red(`Failed to create prompt templates! - ${err.message}`));
96
- }
97
- logger_1.logger.info(colors_1.default.green(`Synced "${promptTemplates.length}" prompt templates!`));
98
- // Return true upon success
99
- return !encounteredError;
100
- }
101
- exports.syncPromptTemplates = syncPromptTemplates;
102
- //# sourceMappingURL=syncPromptTemplates.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncPromptTemplates.js","sourceRoot":"","sources":["../../src/graphql/syncPromptTemplates.ts"],"names":[],"mappings":";;;;;;AACA,oDAA4B;AAE5B,iCAAyE;AACzE,6DAA0D;AAC1D,uCAA+B;AAC/B,iEAAiE;AACjE,yDAAiC;AACjC,sCAAmC;AAEnC;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CACxC,MAAqB,EACrB,KAKC;IAED,MAAM,EACJ,oBAAoB,EAAE,EAAE,cAAc,EAAE,GACzC,GAAG,MAAM,IAAA,uCAAkB,EASzB,MAAM,EAAE,6BAAsB,EAAE;QACjC,KAAK;KACN,CAAC,CAAC;IACH,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,KAAK,CAAC,yCAAyC,KAAK,CAAC,KAAK,IAAI,CAAC,CACvE,CAAC;IACF,OAAO,cAAc,CAAC,EAAE,CAAC;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