@vertesia/cli 0.42.2

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 (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -0
  3. package/bin/app.js +3 -0
  4. package/lib/client.d.ts +4 -0
  5. package/lib/client.d.ts.map +1 -0
  6. package/lib/client.js +21 -0
  7. package/lib/client.js.map +1 -0
  8. package/lib/codegen/CodeBuilder.d.ts +16 -0
  9. package/lib/codegen/CodeBuilder.d.ts.map +1 -0
  10. package/lib/codegen/CodeBuilder.js +115 -0
  11. package/lib/codegen/CodeBuilder.js.map +1 -0
  12. package/lib/codegen/InteractionVersion.d.ts +29 -0
  13. package/lib/codegen/InteractionVersion.d.ts.map +1 -0
  14. package/lib/codegen/InteractionVersion.js +94 -0
  15. package/lib/codegen/InteractionVersion.js.map +1 -0
  16. package/lib/codegen/index.d.ts +3 -0
  17. package/lib/codegen/index.d.ts.map +1 -0
  18. package/lib/codegen/index.js +24 -0
  19. package/lib/codegen/index.js.map +1 -0
  20. package/lib/codegen/template.d.ts +3 -0
  21. package/lib/codegen/template.d.ts.map +1 -0
  22. package/lib/codegen/template.js +28 -0
  23. package/lib/codegen/template.js.map +1 -0
  24. package/lib/codegen/utils.d.ts +2 -0
  25. package/lib/codegen/utils.d.ts.map +1 -0
  26. package/lib/codegen/utils.js +4 -0
  27. package/lib/codegen/utils.js.map +1 -0
  28. package/lib/datagen/index.d.ts +3 -0
  29. package/lib/datagen/index.d.ts.map +1 -0
  30. package/lib/datagen/index.js +47 -0
  31. package/lib/datagen/index.js.map +1 -0
  32. package/lib/envs/index.d.ts +3 -0
  33. package/lib/envs/index.d.ts.map +1 -0
  34. package/lib/envs/index.js +24 -0
  35. package/lib/envs/index.js.map +1 -0
  36. package/lib/index.d.ts +2 -0
  37. package/lib/index.d.ts.map +1 -0
  38. package/lib/index.js +169 -0
  39. package/lib/index.js.map +1 -0
  40. package/lib/interactions/index.d.ts +3 -0
  41. package/lib/interactions/index.d.ts.map +1 -0
  42. package/lib/interactions/index.js +37 -0
  43. package/lib/interactions/index.js.map +1 -0
  44. package/lib/memory/index.d.ts +3 -0
  45. package/lib/memory/index.d.ts.map +1 -0
  46. package/lib/memory/index.js +16 -0
  47. package/lib/memory/index.js.map +1 -0
  48. package/lib/objects/commands.d.ts +14 -0
  49. package/lib/objects/commands.d.ts.map +1 -0
  50. package/lib/objects/commands.js +240 -0
  51. package/lib/objects/commands.js.map +1 -0
  52. package/lib/objects/index.d.ts +3 -0
  53. package/lib/objects/index.d.ts.map +1 -0
  54. package/lib/objects/index.js +37 -0
  55. package/lib/objects/index.js.map +1 -0
  56. package/lib/package.d.ts +8 -0
  57. package/lib/package.d.ts.map +1 -0
  58. package/lib/package.js +54 -0
  59. package/lib/package.js.map +1 -0
  60. package/lib/profiles/commands.d.ts +10 -0
  61. package/lib/profiles/commands.d.ts.map +1 -0
  62. package/lib/profiles/commands.js +167 -0
  63. package/lib/profiles/commands.js.map +1 -0
  64. package/lib/profiles/index.d.ts +57 -0
  65. package/lib/profiles/index.d.ts.map +1 -0
  66. package/lib/profiles/index.js +255 -0
  67. package/lib/profiles/index.js.map +1 -0
  68. package/lib/profiles/server/cors.d.ts +3 -0
  69. package/lib/profiles/server/cors.d.ts.map +1 -0
  70. package/lib/profiles/server/cors.js +18 -0
  71. package/lib/profiles/server/cors.js.map +1 -0
  72. package/lib/profiles/server/index.d.ts +12 -0
  73. package/lib/profiles/server/index.d.ts.map +1 -0
  74. package/lib/profiles/server/index.js +73 -0
  75. package/lib/profiles/server/index.js.map +1 -0
  76. package/lib/profiles/server/server.d.ts +4 -0
  77. package/lib/profiles/server/server.d.ts.map +1 -0
  78. package/lib/profiles/server/server.js +32 -0
  79. package/lib/profiles/server/server.js.map +1 -0
  80. package/lib/projects/index.d.ts +3 -0
  81. package/lib/projects/index.d.ts.map +1 -0
  82. package/lib/projects/index.js +13 -0
  83. package/lib/projects/index.js.map +1 -0
  84. package/lib/run/executor.d.ts +20 -0
  85. package/lib/run/executor.d.ts.map +1 -0
  86. package/lib/run/executor.js +101 -0
  87. package/lib/run/executor.js.map +1 -0
  88. package/lib/run/index.d.ts +3 -0
  89. package/lib/run/index.d.ts.map +1 -0
  90. package/lib/run/index.js +139 -0
  91. package/lib/run/index.js.map +1 -0
  92. package/lib/runs/index.d.ts +3 -0
  93. package/lib/runs/index.d.ts.map +1 -0
  94. package/lib/runs/index.js +48 -0
  95. package/lib/runs/index.js.map +1 -0
  96. package/lib/utils/console.d.ts +38 -0
  97. package/lib/utils/console.d.ts.map +1 -0
  98. package/lib/utils/console.js +191 -0
  99. package/lib/utils/console.js.map +1 -0
  100. package/lib/utils/stdio.d.ts +7 -0
  101. package/lib/utils/stdio.d.ts.map +1 -0
  102. package/lib/utils/stdio.js +35 -0
  103. package/lib/utils/stdio.js.map +1 -0
  104. package/lib/workflows/commands.d.ts +14 -0
  105. package/lib/workflows/commands.d.ts.map +1 -0
  106. package/lib/workflows/commands.js +193 -0
  107. package/lib/workflows/commands.js.map +1 -0
  108. package/lib/workflows/index.d.ts +3 -0
  109. package/lib/workflows/index.d.ts.map +1 -0
  110. package/lib/workflows/index.js +88 -0
  111. package/lib/workflows/index.js.map +1 -0
  112. package/lib/workflows/json-loader.d.ts +3 -0
  113. package/lib/workflows/json-loader.d.ts.map +1 -0
  114. package/lib/workflows/json-loader.js +16 -0
  115. package/lib/workflows/json-loader.js.map +1 -0
  116. package/lib/workflows/ts-loader.d.ts +3 -0
  117. package/lib/workflows/ts-loader.d.ts.map +1 -0
  118. package/lib/workflows/ts-loader.js +94 -0
  119. package/lib/workflows/ts-loader.js.map +1 -0
  120. package/lib/workflows/validation.d.ts +6 -0
  121. package/lib/workflows/validation.d.ts.map +1 -0
  122. package/lib/workflows/validation.js +22 -0
  123. package/lib/workflows/validation.js.map +1 -0
  124. package/package.json +57 -0
  125. package/templates/index.tpl +4 -0
  126. package/templates/interaction.tpl +16 -0
package/lib/index.js ADDED
@@ -0,0 +1,169 @@
1
+ import { setupMemoCommand } from '@becomposable/memory-cli';
2
+ import { Command } from 'commander';
3
+ import runExport from './codegen/index.js';
4
+ import { genTestData } from './datagen/index.js';
5
+ import { listEnvirnments } from './envs/index.js';
6
+ import { listInteractions } from './interactions/index.js';
7
+ import { getPublishMemoryAction } from './memory/index.js';
8
+ import { registerObjectsCommand } from './objects/index.js';
9
+ import { getVersion, upgrade } from './package.js';
10
+ import { createProfile, deleteProfile, listProfiles, showActiveAuthToken, showProfile, tryRrefreshToken, updateCurrentProfile, updateProfile, useProfile } from './profiles/commands.js';
11
+ import { getConfigFile } from './profiles/index.js';
12
+ import { listProjects } from './projects/index.js';
13
+ import runInteraction from './run/index.js';
14
+ import { runHistory } from './runs/index.js';
15
+ import { registerWorkflowsCommand } from './workflows/index.js';
16
+ //warnIfNotLatest();
17
+ const program = new Command();
18
+ program.version(getVersion());
19
+ program.command("upgrade")
20
+ .description("Upgrade to the latest version of the CLI")
21
+ .action(upgrade);
22
+ program.command("projects")
23
+ .description("List the projects you have access to")
24
+ .action(() => {
25
+ listProjects(program);
26
+ });
27
+ const authRoot = program.command("auth")
28
+ .description("Manage authentication");
29
+ authRoot.command("token")
30
+ .description("Show the auth token used by the current selected profile.")
31
+ .action(() => {
32
+ showActiveAuthToken();
33
+ });
34
+ authRoot.command("refresh")
35
+ .description("Refresh the auth token used by the current profile. An alias to 'composable profiles refresh'.")
36
+ .action(() => {
37
+ updateCurrentProfile();
38
+ });
39
+ program.command("envs [envId]")
40
+ .description("List the environments you have access to")
41
+ .action((envId, options) => {
42
+ listEnvirnments(program, envId, options);
43
+ });
44
+ program.command("interactions [interaction]")
45
+ .description("List the interactions available in the current project")
46
+ .action((interactionId, options) => {
47
+ listInteractions(program, interactionId, options);
48
+ });
49
+ program.command("datagen <interaction>")
50
+ .description("Generate test input data, given an interaction ID")
51
+ .option('-e, --env [envId]', 'The environment ID to use to generating the test data')
52
+ .option('-m, --model [model]', 'The model to use to generating the test data. If the selected environment has a default model then this option is optional.')
53
+ .option('-t, --temperature [value]', 'The temperature used to generating the test data.')
54
+ .option('--max-tokens [max-tokens]', 'The maximum number of tokens to generate')
55
+ .option('--top-p [top-p]', 'The top P value to use')
56
+ .option('--top-k [top-k]', 'The top K value to use')
57
+ .option('--presence-penalty [presence-penalty]', 'The presence penalty value to use')
58
+ .option('--frequency-penalty [frequency-penalty]', 'The frequency penalty value to use')
59
+ .option('--stop-sequence [stop-sequence]', 'A comma separated list of sequences to stop the generation')
60
+ .option('--config-mode [config-mode]', 'The configuration mode to use.Possible values are: "run_and_interaction_config", "run_config_only", "interaction_config_only". Optional. If not specified, "run_and_interaction_config" is used.')
61
+ .option('-o, --output [file]', 'A file to save the generated test data. If not specified the data will be printed to stdout.')
62
+ .option('-c, --count [value]', 'The number of data objects to generate', '1')
63
+ .option('--message [value]', 'An optional message')
64
+ .action((interactionId, options) => {
65
+ genTestData(program, interactionId, options);
66
+ });
67
+ program.command("codegen [interactionName]")
68
+ .description("Generate code given an interaction name of for all the interactions in the project if no interaction is specified.")
69
+ .option('--versions [versions]', 'A comma separated list of version selectors to include. A version selector is either a version number or one of the "draft" or "latest" keywords. The default is "draft, latest"', "draft,latest")
70
+ .option('-a, -all', 'When used, all the interaction versions will be exported')
71
+ .option('-d, --dir [file]', 'The output directory if any. Default to "./interactions" if not specified.', './interactions')
72
+ .option('-x, --export <version>', 'The version to export from index.ts. If not specified, the latest version will be exported or if no version is available, the draft version will be exported')
73
+ .action((interactionName, options) => runExport(program, interactionName, options));
74
+ program.command("run <interaction>")
75
+ .description("Run an interaction by full name. The full name is composed by an optional namespace, a required endpoint name and an optional tag or version. Examples: name, namespace:name, namespace:name@version")
76
+ .option('-i, --input [file]', 'The input data if any. If no file path is specified it will read from stdin')
77
+ .option('-o, --output [file]', 'The output file if any. If not specified it will print to stdout')
78
+ .option('-d, --data [json]', 'Inline data as a JSON string. If specified takes precendence over --input')
79
+ .option('-T, --tags [tags]', 'A comma separated list of tags to add to the execution run')
80
+ .option('-t, --temperature [temperature]', 'The temperature to use')
81
+ .option('--max-tokens [max-tokens]', 'The maximum number of tokens to generate')
82
+ .option('--top-p [top-p]', 'The top P value to use')
83
+ .option('--top-k [top-k]', 'The top K value to use')
84
+ .option('--presence-penalty [presence-penalty]', 'The presence penalty value to use')
85
+ .option('--frequency-penalty [frequency-penalty]', 'The frequency penalty value to use')
86
+ .option('--stop-sequence [stop-sequence]', 'A comma separated list of sequences to stop the generation')
87
+ .option('--config-mode [config-mode]', 'The configuration mode to use.Possible values are: "run_and_interaction_config", "run_config_only", "interaction_config_only". Optional. If not specified, "run_and_interaction_config" is used.')
88
+ .option('-m, --model [model]', 'The model to use. Optional.')
89
+ .option('-e, --env [environmentId]', 'The environment Id to use. Optional.')
90
+ .option('-S, --no-stream', 'When used, the output will be printed only when the execution is complete')
91
+ .option('-c, --count [count]', 'The number of times to run the interaction', '1')
92
+ .option('-v, --verbose', 'Only used in no streaming mode. Instead of printing a progress it will print details about each executed run.')
93
+ .option('--jsonl', 'Write output in jsonl. The default is to write the json. Ignored when only one run is executed')
94
+ .option('--data-only', 'Write down only the data returned by the LLM and not the entire execution run. This mode is forced when streaming', false)
95
+ .option('-r, --run-data [level]', 'Override the level of storage for the run data. Possible values are: "standard", "restricted", or "debug". Optional. If not specified, it uses the level defined in Studio.')
96
+ .action((interaction, options) => runInteraction(program, interaction, options));
97
+ program.command("runs [interactionId]")
98
+ .description('Search the run history for specific execution runs')
99
+ .option('-t, --tags [tags]', 'A comma separated list of tags to filter the run history')
100
+ .option('--status [status]', 'A status to filter on')
101
+ .option('-e, --env [environmentId]', 'Filter by environment')
102
+ .option('-m, --model [model]', 'Filter by model')
103
+ .option('-q, --query [query]', 'A lucene query')
104
+ .option('-l, --limit [limit]', 'The maximum number of runs to return in a page', "100")
105
+ .option('-P, --page [page]', 'The page number to return (starting from 0)', "0")
106
+ .option('-f, --format [format]', 'The output format: json, jsonl or csv.', 'json')
107
+ .option("-o, --output [file]", "The output file if any. If not specified it will print to stdout")
108
+ .option("--before [date]", "Filter runs before the given date. The date must be in ISO format")
109
+ .option("--after [date]", "Filter runs after the given date. The date must be in ISO format")
110
+ .action((interactionId, options) => {
111
+ runHistory(program, interactionId, options);
112
+ });
113
+ const memoCmd = program.command("memo");
114
+ setupMemoCommand(memoCmd, getPublishMemoryAction(program));
115
+ const profilesRoot = program.command("profiles")
116
+ .description("Manage configuration profiles")
117
+ .action(() => {
118
+ listProfiles();
119
+ });
120
+ profilesRoot.command('show [name]')
121
+ .description("Show the configured profiles or the profile with the given name")
122
+ .action((name) => {
123
+ showProfile(name);
124
+ });
125
+ profilesRoot.command('use [name]')
126
+ .description("Switch to another configuration profile")
127
+ .action((name) => {
128
+ useProfile(name);
129
+ });
130
+ profilesRoot.command('add [name]')
131
+ .alias('create')
132
+ .option("-t, --target <env>", "The target environment for the profile. Possible values are: local, dev, staging, prod or an URL for custom servers.")
133
+ .description("Create a new configuration profile")
134
+ .action((name, options) => {
135
+ createProfile(name, options?.target);
136
+ });
137
+ profilesRoot.command('edit [name]')
138
+ .alias('update')
139
+ .description("Edit an existing configuration profile")
140
+ .action((name) => {
141
+ updateProfile(name);
142
+ });
143
+ profilesRoot.command('refresh')
144
+ .description("Refresh token for the current configuration profile")
145
+ .action(() => {
146
+ updateCurrentProfile();
147
+ });
148
+ profilesRoot.command('delete <name>')
149
+ .description("delete an existing configuration profile")
150
+ .action((name) => {
151
+ deleteProfile(name);
152
+ });
153
+ profilesRoot.command('file')
154
+ .description("print the configuration file path")
155
+ .action(() => {
156
+ console.log(getConfigFile('profiles.json'));
157
+ });
158
+ registerObjectsCommand(program);
159
+ registerWorkflowsCommand(program);
160
+ program.parseAsync(process.argv).catch(err => {
161
+ console.error(err);
162
+ process.exit(1);
163
+ });
164
+ process.on("unhandledRejection", (err) => {
165
+ if (err.status === 401) { // token expired?
166
+ tryRrefreshToken();
167
+ }
168
+ });
169
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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AAE,EAAE;IAC1C,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC,CAAC,iBAAiB;QACvC,gBAAgB,EAAE,CAAC;IACvB,CAAC;AACL,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function listInteractions(program: Command, interactionId: string | undefined, options: Record<string, any>): Promise<void>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interactions/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,iBAkBjH"}
@@ -0,0 +1,37 @@
1
+ import { InteractionStatus } from "@vertesia/common";
2
+ import colors from "ansi-colors";
3
+ import { getClient } from "../client.js";
4
+ import { textToPascalCase } from "../codegen/utils.js";
5
+ export function listInteractions(program, interactionId, options) {
6
+ const client = getClient(program);
7
+ if (!interactionId) {
8
+ return client.interactions.list().then((interactions) => {
9
+ interactions.map(interaction => {
10
+ console.log(textToPascalCase(interaction.name) + ` [${interaction.id}]`);
11
+ });
12
+ });
13
+ }
14
+ return client.interactions.retrieve(interactionId).then((interaction) => {
15
+ if (interaction.status === InteractionStatus.draft) {
16
+ client.interactions.listVersions(interactionId).then((versions) => {
17
+ printInteraction(interaction, versions, options);
18
+ });
19
+ }
20
+ else {
21
+ printInteraction(interaction, [], options);
22
+ }
23
+ });
24
+ }
25
+ function printInteraction(interaction, versions, _options) {
26
+ console.log(colors.bold(interaction.name) + " [" + interaction.id + "]");
27
+ console.log(colors.bold("Description:"), interaction.description || 'n/a');
28
+ console.log(colors.bold("Class name:"), textToPascalCase(interaction.name));
29
+ console.log(colors.bold("Status:"), interaction.status);
30
+ console.log(colors.bold("Version:"), interaction.version);
31
+ console.log(colors.bold("Tags:"), interaction.tags && interaction.tags.length > 0 ? interaction.tags.join(", ") : "n/a");
32
+ if (interaction.status === InteractionStatus.draft) {
33
+ versions.sort((a, b) => a.version - b.version);
34
+ console.log(colors.bold("Published Versions:"), versions.length > 0 ? versions.map(v => v.version).join(", ") : "n/a");
35
+ }
36
+ }
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interactions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,UAAU,gBAAgB,CAAC,OAAgB,EAAE,aAAiC,EAAE,OAA4B;IAC9G,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE;YACpD,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;gBAC3B,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,WAAW,CAAC,EAAE,GAAG,CAAC,CAAC;YAC7E,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;QACpE,IAAI,WAAW,CAAC,MAAM,KAAK,iBAAiB,CAAC,KAAK,EAAE,CAAC;YACjD,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,aAAa,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AAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC3H,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function getPublishMemoryAction(program: Command): (file: string, name: string) => Promise<string>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,UACrC,MAAM,QAAQ,MAAM,qBAIrC"}
@@ -0,0 +1,16 @@
1
+ import { StreamSource } from "@vertesia/client";
2
+ import { createReadStream } from "fs";
3
+ import { readableToWebStream } from "node-web-stream-adapters";
4
+ import { getClient } from "../client.js";
5
+ export function getPublishMemoryAction(program) {
6
+ return (file, name) => {
7
+ const client = getClient(program);
8
+ return publishMemory(client, file, name);
9
+ };
10
+ }
11
+ async function publishMemory(client, file, name) {
12
+ const stream = readableToWebStream(createReadStream(file));
13
+ const path = await client.files.uploadMemoryPack(new StreamSource(stream, name, "application/gzip"));
14
+ return path;
15
+ }
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACnD,OAAO,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE;QAClC,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QAClC,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC,CAAA;AACL,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,MAAwB,EAAE,IAAY,EAAE,IAAY;IAC7E,MAAM,MAAM,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,YAAY,CAAC,MAAM,EACpE,IAAI,EACJ,kBAAkB,CACrB,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AAChB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { ComposableClient } from "@vertesia/client";
2
+ import { ContentObject } from "@vertesia/common";
3
+ import { Command } from "commander";
4
+ export declare function createObject(program: Command, files: string[], options: Record<string, any>): Promise<void | "No files specified" | ContentObject<any>>;
5
+ export declare function createObjectFromFiles(program: Command, files: string[], options: Record<string, any>): Promise<void>;
6
+ export declare function createObjectFromFile(program: Command, file: string, options: Record<string, any>): Promise<ContentObject<any>>;
7
+ export declare function createObjectFromLocalFile(client: ComposableClient, file: string, options: Record<string, any>): Promise<ContentObject<any>>;
8
+ export declare function updateObject(program: Command, objectId: string, type: string, _options: Record<string, any>): Promise<void>;
9
+ export declare function deleteObject(program: Command, objectId: string, _options: Record<string, any>): Promise<void>;
10
+ export declare function getObject(program: Command, objectId: string, _options: Record<string, any>): Promise<void>;
11
+ export declare function listObjects(program: Command, folderPath: string | undefined, _options: Record<string, any>): Promise<void>;
12
+ export declare function listTypes(program: Command): Promise<any[]>;
13
+ export declare function findTypeValue(types: any[], name: string): any;
14
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/objects/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAgB,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAqD,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkDpC,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,6DA0GjG;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,iBAS1G;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,+BAUtG;AAED,wBAAsB,yBAAyB,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,+BAkBnH;AAUD,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,iBAYjH;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,iBAEnG;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,iBAGhG;AAGD,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,iBAGhH;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,OAAO,kBAS/C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,OAGvD"}
@@ -0,0 +1,240 @@
1
+ import { StreamSource } from "@vertesia/client";
2
+ import enquirer from "enquirer";
3
+ import { createReadStream } from "fs";
4
+ import { readdir, stat } from "fs/promises";
5
+ import { glob } from 'glob';
6
+ import mime from "mime";
7
+ import { createReadableStreamFromReadable } from "node-web-stream-adapters";
8
+ import { basename, join, resolve } from "path";
9
+ import { getClient } from "../client.js";
10
+ const { prompt } = enquirer;
11
+ const AUTOMATIC_TYPE_SELECTION = "AutomaticTypeSelection";
12
+ const TYPE_SELECTION_ERROR = "TypeSelectionError";
13
+ function splitInChunksWithSize(arr, size) {
14
+ if (size < 1) {
15
+ return [];
16
+ }
17
+ const chunks = [];
18
+ const len = arr.length;
19
+ let i = 0;
20
+ while (i < len) {
21
+ chunks.push(arr.slice(i, i + size));
22
+ i += size;
23
+ }
24
+ return chunks;
25
+ }
26
+ function splitInChunks(arr, chunksCount) {
27
+ if (arr.length < 1) {
28
+ return [];
29
+ }
30
+ if (chunksCount <= arr.length) {
31
+ const size = Math.ceil(arr.length / chunksCount);
32
+ return splitInChunksWithSize(arr, size);
33
+ }
34
+ else {
35
+ return [arr];
36
+ }
37
+ }
38
+ async function listFilesInDirectory(dir, recursive = false) {
39
+ return await readdir(dir, {
40
+ withFileTypes: true,
41
+ recursive,
42
+ }).then((ents) => ents.filter(ent => {
43
+ // eclude hidden files and include only file with extensions
44
+ return ent.isFile() && ent.name.lastIndexOf('.') > 0;
45
+ }).map(ent => join(ent.path || '', ent.name)));
46
+ }
47
+ export async function createObject(program, files, options) {
48
+ if (files.length === 0) {
49
+ return "No files specified";
50
+ }
51
+ else if (files.length > 1) {
52
+ const types = await listTypes(program);
53
+ const questions = [];
54
+ if (!options.type) {
55
+ questions.push({
56
+ type: 'select',
57
+ name: 'type',
58
+ message: "Select a Type",
59
+ choices: types,
60
+ limit: 10,
61
+ result() {
62
+ return this.focused.value;
63
+ }
64
+ });
65
+ const response = await prompt(questions);
66
+ options.type = response.type;
67
+ }
68
+ else {
69
+ const searchedType = findTypeValue(types, options.type);
70
+ if (searchedType === TYPE_SELECTION_ERROR) {
71
+ console.error(`${options.type} is not an existing type`);
72
+ process.exit(2);
73
+ }
74
+ options.type = searchedType;
75
+ }
76
+ if (options.type === AUTOMATIC_TYPE_SELECTION) {
77
+ delete options.type;
78
+ }
79
+ return createObjectFromFiles(program, files, options);
80
+ }
81
+ else {
82
+ let file = files[0];
83
+ if (file.indexOf('*') > -1) {
84
+ const files = await glob(file);
85
+ return createObjectFromFiles(program, files, options);
86
+ }
87
+ else if (file.includes("://")) {
88
+ return createObjectFromExternalSource(getClient(program), file, options);
89
+ }
90
+ else {
91
+ file = resolve(file);
92
+ let stats;
93
+ try {
94
+ stats = await stat(file);
95
+ }
96
+ catch (err) {
97
+ if (err.code === 'ENOENT') {
98
+ console.error('No such file or directory: ', file);
99
+ process.exit(2);
100
+ }
101
+ console.error(err);
102
+ process.exit(2);
103
+ }
104
+ const types = await listTypes(program);
105
+ const questions = [];
106
+ if (stats.isFile()) {
107
+ if (!options.type) {
108
+ questions.push({
109
+ type: 'select',
110
+ name: 'type',
111
+ message: "Select a Type",
112
+ choices: types,
113
+ limit: 10,
114
+ result() {
115
+ return this.focused.value;
116
+ }
117
+ });
118
+ const response = await prompt(questions);
119
+ options.type = response.type;
120
+ }
121
+ else {
122
+ const searchedType = findTypeValue(types, options.type);
123
+ if (searchedType === TYPE_SELECTION_ERROR) {
124
+ console.error(`${options.type} is not an existing type`);
125
+ process.exit(2);
126
+ }
127
+ options.type = searchedType;
128
+ }
129
+ if (options.type === AUTOMATIC_TYPE_SELECTION) {
130
+ delete options.type;
131
+ }
132
+ return createObjectFromFile(program, file, options);
133
+ }
134
+ else if (stats.isDirectory()) {
135
+ questions.push({
136
+ type: 'select',
137
+ name: 'type',
138
+ message: "Select a Type (the type will be used for all the files in the directory)",
139
+ choices: types,
140
+ limit: 10,
141
+ result() {
142
+ return this.focused.value;
143
+ }
144
+ });
145
+ const response = await prompt(questions);
146
+ options.type = response.type;
147
+ if (options.type === AUTOMATIC_TYPE_SELECTION) {
148
+ delete options.type;
149
+ }
150
+ const files = await listFilesInDirectory(file, options.recursive || false);
151
+ return createObjectFromFiles(program, files, options);
152
+ }
153
+ }
154
+ }
155
+ }
156
+ export async function createObjectFromFiles(program, files, options) {
157
+ if (!options)
158
+ options = {};
159
+ // split in 10 chunks
160
+ const chunks = splitInChunks(files, 10);
161
+ Promise.all(chunks.map(async (chunk) => {
162
+ for (const file of chunk) {
163
+ await createObjectFromFile(program, file, options);
164
+ }
165
+ }));
166
+ }
167
+ export async function createObjectFromFile(program, file, options) {
168
+ const client = getClient(program);
169
+ let res;
170
+ if (file.startsWith("s3://") || file.startsWith("gs://")) {
171
+ res = await createObjectFromExternalSource(client, file, options);
172
+ }
173
+ else {
174
+ res = await createObjectFromLocalFile(client, file, options);
175
+ }
176
+ console.log('Created object', res.id);
177
+ return res;
178
+ }
179
+ export async function createObjectFromLocalFile(client, file, options) {
180
+ const fileName = basename(file);
181
+ const stream = createReadStream(file);
182
+ const content = new StreamSource(createReadableStreamFromReadable(stream), fileName);
183
+ const mime_type = mime.getType(file);
184
+ if (mime_type) {
185
+ content.type = mime_type;
186
+ }
187
+ const res = await client.objects.create({
188
+ name: options.name || fileName,
189
+ type: options.type,
190
+ location: options.path,
191
+ content: content,
192
+ });
193
+ return res;
194
+ }
195
+ async function createObjectFromExternalSource(client, uri, options) {
196
+ return client.objects.createFromExternalSource(uri, {
197
+ name: options.name,
198
+ type: options.type,
199
+ location: options.path,
200
+ });
201
+ }
202
+ export async function updateObject(program, objectId, type, _options) {
203
+ const types = await listTypes(program);
204
+ var searchedType = findTypeValue(types, type);
205
+ if (searchedType === TYPE_SELECTION_ERROR) {
206
+ console.error(`${type} is not an existing type`);
207
+ process.exit(2);
208
+ }
209
+ if (searchedType === AUTOMATIC_TYPE_SELECTION) {
210
+ searchedType = undefined;
211
+ }
212
+ const payload = { type: searchedType };
213
+ console.log(await getClient(program).objects.update(objectId, payload));
214
+ }
215
+ export async function deleteObject(program, objectId, _options) {
216
+ await getClient(program).objects.delete(objectId);
217
+ }
218
+ export async function getObject(program, objectId, _options) {
219
+ const object = await getClient(program).objects.retrieve(objectId);
220
+ console.log(object);
221
+ }
222
+ //@ts-ignore
223
+ export async function listObjects(program, folderPath, _options) {
224
+ const objects = await getClient(program).objects.list();
225
+ console.log(objects.map(o => `${o.id}\t ${o.name}`).join('\n'));
226
+ }
227
+ export async function listTypes(program) {
228
+ var types = [];
229
+ types.push({ name: AUTOMATIC_TYPE_SELECTION, value: AUTOMATIC_TYPE_SELECTION });
230
+ const platformTypes = await getClient(program).types.list();
231
+ for (const type of platformTypes) {
232
+ types.push({ name: type.name, value: type.id });
233
+ }
234
+ return types;
235
+ }
236
+ export function findTypeValue(types, name) {
237
+ const type = types.find(type => type.name === name || type.id === name);
238
+ return type ? type.value : TYPE_SELECTION_ERROR;
239
+ }
240
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/objects/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGlE,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAiB,gBAAgB,EAAE,MAAM,IAAI,CAAC;AACrD,OAAO,EAA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,aAAa,CAAC,KAAY,EAAE,IAAY;IACpD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;IACxE,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC;AACpD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function registerObjectsCommand(program: Command): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,QAoCtD"}
@@ -0,0 +1,37 @@
1
+ import { createObject, deleteObject, getObject, listObjects, updateObject } from "./commands.js";
2
+ export function registerObjectsCommand(program) {
3
+ const store = program.command("content");
4
+ store.command("post <file...>")
5
+ .description("Post a new object to the store. The file can be a s3 or gs uri to attach external blobs to the created object.")
6
+ .option('--name [name]', 'The name of the object to create. If not specified the file name will be used.')
7
+ .option('--type [type]', 'The type of the object to create. If not specified, one can be selected from the list of existing types.')
8
+ .option('--mime [mime]', 'The mime-type of the file content. If not specified the mime type will be inferred from the file name extension.')
9
+ .option('--path [parentPath]', 'The path of the parent folder where the object is created. If not specified the object will be created in the root of the store.')
10
+ .option('-r, --recursive', 'Recurse directory if the file argument is a directory. The default is to not recurse.')
11
+ .action(async (files, options) => {
12
+ await createObject(program, files, options);
13
+ });
14
+ store.command("update <objectId> <type>")
15
+ .description("Update an existing object type given its ID")
16
+ .action(async (objectId, type, options) => {
17
+ await updateObject(program, objectId, type, options);
18
+ });
19
+ store.command('delete <objectId>')
20
+ .description("Delete an existing object given its ID")
21
+ .action((objectId, options) => {
22
+ deleteObject(program, objectId, options);
23
+ });
24
+ store.command('get <objectId>')
25
+ .description("Get an existing object given its ID")
26
+ .action((objectId, options) => {
27
+ getObject(program, objectId, options);
28
+ });
29
+ store.command('list [folderPath]')
30
+ .description("List the objects inside a folder. If no folder is specified all the obejcts are listed.")
31
+ .option('-l,--limit [limit]', 'Limit the number of objects returned. The default limit is 100. Usefull for pagination.')
32
+ .option('-s,--skip [skip]', 'Skip the number of objects to skip. Default is 0. Usefull for pagination.')
33
+ .action((folderPath, options) => {
34
+ listObjects(program, folderPath, options);
35
+ });
36
+ }
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/objects/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEjG,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IAEnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEzC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC;SAC1B,WAAW,CAAC,gHAAgH,CAAC;SAC7H,MAAM,CAAC,eAAe,EAAE,gFAAgF,CAAC;SACzG,MAAM,CAAC,eAAe,EAAE,0GAA0G,CAAC;SACnI,MAAM,CAAC,eAAe,EAAE,kHAAkH,CAAC;SAC3I,MAAM,CAAC,qBAAqB,EAAE,kIAAkI,CAAC;SACjK,MAAM,CAAC,iBAAiB,EAAE,uFAAuF,CAAC;SAClH,MAAM,CAAC,KAAK,EAAE,KAAe,EAAE,OAA4B,EAAE,EAAE;QAC5D,MAAM,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IACP,KAAK,CAAC,OAAO,CAAC,0BAA0B,CAAC;SACpC,WAAW,CAAC,6CAA6C,CAAC;SAC1D,MAAM,CAAC,KAAK,EAAE,QAAgB,EAAE,IAAY,EAAE,OAA4B,EAAE,EAAE;QAC3E,MAAM,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IACP,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;SAC7B,WAAW,CAAC,wCAAwC,CAAC;SACrD,MAAM,CAAC,CAAC,QAAgB,EAAE,OAA4B,EAAE,EAAE;QACvD,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IACP,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC;SAC1B,WAAW,CAAC,qCAAqC,CAAC;SAClD,MAAM,CAAC,CAAC,QAAgB,EAAE,OAA4B,EAAE,EAAE;QACvD,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IACP,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;SAC7B,WAAW,CAAC,yFAAyF,CAAC;SACtG,MAAM,CAAC,oBAAoB,EAAE,yFAAyF,CAAC;SACvH,MAAM,CAAC,kBAAkB,EAAE,2EAA2E,CAAC;SACvG,MAAM,CAAC,CAAC,UAA8B,EAAE,OAA4B,EAAE,EAAE;QACrE,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,8 @@
1
+ declare const packageDir: string;
2
+ declare function getPackage(): any;
3
+ declare function getVersion(): any;
4
+ declare function getLatestVersion(): Promise<any>;
5
+ export declare function upgrade(): Promise<void>;
6
+ declare function warnIfNotLatest(): Promise<void>;
7
+ export { getLatestVersion, getPackage, getVersion, packageDir, warnIfNotLatest };
8
+ //# sourceMappingURL=package.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../src/package.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,UAAU,QAAmD,CAAC;AAGpE,iBAAS,UAAU,QAKlB;AACD,iBAAS,UAAU,QAElB;AAED,iBAAe,gBAAgB,iBAO9B;AAED,wBAAsB,OAAO,kBAmB5B;AAED,iBAAe,eAAe,kBAM7B;AAED,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC"}