@botpress/cli 5.6.1 → 6.0.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.
@@ -106,7 +106,7 @@ class TablesPublisher {
106
106
  }
107
107
  await api.client.updateTable({
108
108
  table: existingTable.name,
109
- schema: sdk.transforms.toJSONSchemaLegacy(updatedTableDef.schema),
109
+ schema: sdk.z.transforms.toJSONSchemaLegacy(updatedTableDef.schema),
110
110
  frozen: updatedTableDef.frozen,
111
111
  tags: updatedTableDef.tags,
112
112
  isComputeEnabled: updatedTableDef.isComputeEnabled
@@ -117,7 +117,7 @@ class TablesPublisher {
117
117
  tableName,
118
118
  tableDef
119
119
  }) {
120
- const columns = sdk.transforms.toJSONSchemaLegacy(tableDef.schema).properties;
120
+ const columns = sdk.z.transforms.toJSONSchemaLegacy(tableDef.schema).properties;
121
121
  const validColumns = await Promise.all(
122
122
  Object.entries(columns).map(async ([columnName, columnSchema]) => {
123
123
  const validatedSchema = await schemas.columnSchema.safeParseAsync(columnSchema);
@@ -147,7 +147,7 @@ class TablesPublisher {
147
147
  }) {
148
148
  await api.client.createTable({
149
149
  name: tableName,
150
- schema: sdk.transforms.toJSONSchemaLegacy(tableDef.schema),
150
+ schema: sdk.z.transforms.toJSONSchemaLegacy(tableDef.schema),
151
151
  frozen: tableDef.frozen,
152
152
  tags: tableDef.tags,
153
153
  factor: tableDef.factor,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/tables/tables-publisher.ts"],
4
- "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as apiUtils from '../api'\nimport * as errors from '../errors'\nimport * as logger from '../logger'\nimport * as utils from '../utils'\nimport * as schemas from './schemas'\n\nexport class TablesPublisher {\n private readonly _api: apiUtils.ApiClient\n private readonly _logger: logger.Logger\n private readonly _prompt: utils.prompt.CLIPrompt\n\n public constructor({\n api,\n logger,\n prompt,\n }: {\n api: apiUtils.ApiClient\n logger: logger.Logger\n prompt: utils.prompt.CLIPrompt\n }) {\n this._api = api\n this._logger = logger\n this._prompt = prompt\n }\n\n public async deployTables({ botId, botDefinition }: { botId: string; botDefinition: sdk.BotDefinition }) {\n const api = this._api.switchBot(botId)\n\n this._logger.log('Synchronizing tables...')\n\n const tablesFromBotDef = Object.entries(botDefinition.tables ?? {})\n const listTableResult = await api.safeListTables({})\n\n if (!listTableResult.success) {\n this._logger.warn('Tables API is not available, skipping table deployment.')\n return\n }\n\n const { tables: existingTables } = listTableResult\n for (const [tableName, tableDef] of tablesFromBotDef) {\n const existingTable = existingTables.find((t) => t.name === tableName)\n\n this._logger.log(`Deploying table \"${tableName}\"...`)\n\n if (existingTable) {\n await this._deployExistingTable({ api, existingTable, updatedTableDef: tableDef })\n } else {\n await this._deployNewTable({ api, tableName, tableDef })\n }\n }\n\n for (const existingTable of existingTables) {\n if (!tablesFromBotDef.find(([tableName]) => tableName === existingTable.name)) {\n this._logger.log(\n `Table \"${existingTable.name}\" was previously defined but is not present in your bot definition. ` +\n 'This table will be ignored. ' +\n 'If you wish to delete this table, you may do so from the studio.'\n )\n }\n }\n }\n\n private async _deployExistingTable({\n api,\n existingTable,\n updatedTableDef,\n }: {\n api: apiUtils.ApiClient\n existingTable: Awaited<ReturnType<apiUtils.ApiClient['client']['listTables']>>['tables'][number]\n updatedTableDef: sdk.BotTableDefinition\n }) {\n if (existingTable.frozen) {\n this._logger.warn(`Table \"${existingTable.name}\" is frozen and will not be updated.`)\n return\n }\n\n const existingColumns = existingTable.schema.properties\n const updatedColumns = await this._parseTableColumns({ tableName: existingTable.name, tableDef: updatedTableDef })\n\n for (const [columnName, existingColumn] of Object.entries(existingColumns)) {\n const updatedColumn = updatedColumns[columnName]\n\n if (!updatedColumn) {\n const wishToContinue = await this._warnAndConfirm(\n `Column \"${columnName}\" is missing from the schema of table \"${existingTable.name}\" in your bot definition. ` +\n 'If you are attempting to rename this column, please do so from the studio. ' +\n 'Renaming a column in your bot definition will cause a new column to be created. ' +\n 'If this is not a rename and you wish to proceed, the old column will be kept unchanged. ' +\n 'You can delete columns from the studio if you no longer need them.'\n )\n\n // TODO: ask the user whether this is a rename. If it is a rename, list\n // all other columns and ask which one has the new name, then do\n // the rename operation with client.renameTableColumn()\n\n if (!wishToContinue) {\n return\n }\n }\n\n if (updatedColumn && existingColumn.type !== updatedColumn.type) {\n const wishToContinue = await this._warnAndConfirm(\n 'DATA LOSS WARNING: ' +\n `Type of column \"${columnName}\" has changed from \"${existingColumn.type}\" to \"${updatedColumn.type}\" in table \"${existingTable.name}\". ` +\n 'If you proceed, the value of this column will be reset to NULL for all rows in the table.'\n )\n\n if (!wishToContinue) {\n return\n }\n }\n }\n\n await api.client.updateTable({\n table: existingTable.name,\n schema: sdk.transforms.toJSONSchemaLegacy(updatedTableDef.schema),\n frozen: updatedTableDef.frozen,\n tags: updatedTableDef.tags,\n isComputeEnabled: updatedTableDef.isComputeEnabled,\n })\n\n this._logger.success(`Table \"${existingTable.name}\" has been updated`)\n }\n\n private async _parseTableColumns({\n tableName,\n tableDef,\n }: {\n tableName: string\n tableDef: sdk.BotTableDefinition\n }): Promise<Record<string, sdk.z.infer<typeof schemas.columnSchema>>> {\n const columns = sdk.transforms.toJSONSchemaLegacy(tableDef.schema).properties!\n\n const validColumns = await Promise.all(\n Object.entries(columns).map(async ([columnName, columnSchema]) => {\n const validatedSchema = await schemas.columnSchema.safeParseAsync(columnSchema)\n\n if (!validatedSchema.success) {\n throw new errors.BotpressCLIError(\n `Column \"${columnName}\" in table \"${tableName}\" has an invalid schema: ${validatedSchema.error.message}`\n )\n }\n\n return [columnName, validatedSchema.data] as const\n })\n )\n\n return Object.fromEntries(validColumns)\n }\n\n private async _warnAndConfirm(warningMessage: string, confirmMessage: string = 'Are you sure you want to continue?') {\n this._logger.warn(warningMessage)\n\n const confirm = await this._prompt.confirm(confirmMessage)\n\n if (!confirm) {\n this._logger.log('Aborted')\n return false\n }\n return true\n }\n\n private async _deployNewTable({\n api,\n tableName,\n tableDef,\n }: {\n api: apiUtils.ApiClient\n tableName: string\n tableDef: sdk.BotTableDefinition\n }) {\n await api.client.createTable({\n name: tableName,\n schema: sdk.transforms.toJSONSchemaLegacy(tableDef.schema),\n frozen: tableDef.frozen,\n tags: tableDef.tags,\n factor: tableDef.factor,\n isComputeEnabled: tableDef.isComputeEnabled,\n })\n\n this._logger.success(`Table \"${tableName}\" has been created`)\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AAErB,aAAwB;AAGxB,cAAyB;AAElB,MAAM,gBAAgB;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EAEV,YAAY;AAAA,IACjB;AAAA,IACA,QAAAA;AAAA,IACA;AAAA,EACF,GAIG;AACD,SAAK,OAAO;AACZ,SAAK,UAAUA;AACf,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,MAAa,aAAa,EAAE,OAAO,cAAc,GAAwD;AACvG,UAAM,MAAM,KAAK,KAAK,UAAU,KAAK;AAErC,SAAK,QAAQ,IAAI,yBAAyB;AAE1C,UAAM,mBAAmB,OAAO,QAAQ,cAAc,UAAU,CAAC,CAAC;AAClE,UAAM,kBAAkB,MAAM,IAAI,eAAe,CAAC,CAAC;AAEnD,QAAI,CAAC,gBAAgB,SAAS;AAC5B,WAAK,QAAQ,KAAK,yDAAyD;AAC3E;AAAA,IACF;AAEA,UAAM,EAAE,QAAQ,eAAe,IAAI;AACnC,eAAW,CAAC,WAAW,QAAQ,KAAK,kBAAkB;AACpD,YAAM,gBAAgB,eAAe,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AAErE,WAAK,QAAQ,IAAI,oBAAoB,SAAS,MAAM;AAEpD,UAAI,eAAe;AACjB,cAAM,KAAK,qBAAqB,EAAE,KAAK,eAAe,iBAAiB,SAAS,CAAC;AAAA,MACnF,OAAO;AACL,cAAM,KAAK,gBAAgB,EAAE,KAAK,WAAW,SAA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sdk from '@botpress/sdk'\nimport * as apiUtils from '../api'\nimport * as errors from '../errors'\nimport * as logger from '../logger'\nimport * as utils from '../utils'\nimport * as schemas from './schemas'\n\nexport class TablesPublisher {\n private readonly _api: apiUtils.ApiClient\n private readonly _logger: logger.Logger\n private readonly _prompt: utils.prompt.CLIPrompt\n\n public constructor({\n api,\n logger,\n prompt,\n }: {\n api: apiUtils.ApiClient\n logger: logger.Logger\n prompt: utils.prompt.CLIPrompt\n }) {\n this._api = api\n this._logger = logger\n this._prompt = prompt\n }\n\n public async deployTables({ botId, botDefinition }: { botId: string; botDefinition: sdk.BotDefinition }) {\n const api = this._api.switchBot(botId)\n\n this._logger.log('Synchronizing tables...')\n\n const tablesFromBotDef = Object.entries(botDefinition.tables ?? {})\n const listTableResult = await api.safeListTables({})\n\n if (!listTableResult.success) {\n this._logger.warn('Tables API is not available, skipping table deployment.')\n return\n }\n\n const { tables: existingTables } = listTableResult\n for (const [tableName, tableDef] of tablesFromBotDef) {\n const existingTable = existingTables.find((t) => t.name === tableName)\n\n this._logger.log(`Deploying table \"${tableName}\"...`)\n\n if (existingTable) {\n await this._deployExistingTable({ api, existingTable, updatedTableDef: tableDef })\n } else {\n await this._deployNewTable({ api, tableName, tableDef })\n }\n }\n\n for (const existingTable of existingTables) {\n if (!tablesFromBotDef.find(([tableName]) => tableName === existingTable.name)) {\n this._logger.log(\n `Table \"${existingTable.name}\" was previously defined but is not present in your bot definition. ` +\n 'This table will be ignored. ' +\n 'If you wish to delete this table, you may do so from the studio.'\n )\n }\n }\n }\n\n private async _deployExistingTable({\n api,\n existingTable,\n updatedTableDef,\n }: {\n api: apiUtils.ApiClient\n existingTable: Awaited<ReturnType<apiUtils.ApiClient['client']['listTables']>>['tables'][number]\n updatedTableDef: sdk.BotTableDefinition\n }) {\n if (existingTable.frozen) {\n this._logger.warn(`Table \"${existingTable.name}\" is frozen and will not be updated.`)\n return\n }\n\n const existingColumns = existingTable.schema.properties\n const updatedColumns = await this._parseTableColumns({ tableName: existingTable.name, tableDef: updatedTableDef })\n\n for (const [columnName, existingColumn] of Object.entries(existingColumns)) {\n const updatedColumn = updatedColumns[columnName]\n\n if (!updatedColumn) {\n const wishToContinue = await this._warnAndConfirm(\n `Column \"${columnName}\" is missing from the schema of table \"${existingTable.name}\" in your bot definition. ` +\n 'If you are attempting to rename this column, please do so from the studio. ' +\n 'Renaming a column in your bot definition will cause a new column to be created. ' +\n 'If this is not a rename and you wish to proceed, the old column will be kept unchanged. ' +\n 'You can delete columns from the studio if you no longer need them.'\n )\n\n // TODO: ask the user whether this is a rename. If it is a rename, list\n // all other columns and ask which one has the new name, then do\n // the rename operation with client.renameTableColumn()\n\n if (!wishToContinue) {\n return\n }\n }\n\n if (updatedColumn && existingColumn.type !== updatedColumn.type) {\n const wishToContinue = await this._warnAndConfirm(\n 'DATA LOSS WARNING: ' +\n `Type of column \"${columnName}\" has changed from \"${existingColumn.type}\" to \"${updatedColumn.type}\" in table \"${existingTable.name}\". ` +\n 'If you proceed, the value of this column will be reset to NULL for all rows in the table.'\n )\n\n if (!wishToContinue) {\n return\n }\n }\n }\n\n await api.client.updateTable({\n table: existingTable.name,\n schema: sdk.z.transforms.toJSONSchemaLegacy(updatedTableDef.schema),\n frozen: updatedTableDef.frozen,\n tags: updatedTableDef.tags,\n isComputeEnabled: updatedTableDef.isComputeEnabled,\n })\n\n this._logger.success(`Table \"${existingTable.name}\" has been updated`)\n }\n\n private async _parseTableColumns({\n tableName,\n tableDef,\n }: {\n tableName: string\n tableDef: sdk.BotTableDefinition\n }): Promise<Record<string, sdk.z.infer<typeof schemas.columnSchema>>> {\n const columns = sdk.z.transforms.toJSONSchemaLegacy(tableDef.schema).properties!\n\n const validColumns = await Promise.all(\n Object.entries(columns).map(async ([columnName, columnSchema]) => {\n const validatedSchema = await schemas.columnSchema.safeParseAsync(columnSchema)\n\n if (!validatedSchema.success) {\n throw new errors.BotpressCLIError(\n `Column \"${columnName}\" in table \"${tableName}\" has an invalid schema: ${validatedSchema.error.message}`\n )\n }\n\n return [columnName, validatedSchema.data] as const\n })\n )\n\n return Object.fromEntries(validColumns)\n }\n\n private async _warnAndConfirm(warningMessage: string, confirmMessage: string = 'Are you sure you want to continue?') {\n this._logger.warn(warningMessage)\n\n const confirm = await this._prompt.confirm(confirmMessage)\n\n if (!confirm) {\n this._logger.log('Aborted')\n return false\n }\n return true\n }\n\n private async _deployNewTable({\n api,\n tableName,\n tableDef,\n }: {\n api: apiUtils.ApiClient\n tableName: string\n tableDef: sdk.BotTableDefinition\n }) {\n await api.client.createTable({\n name: tableName,\n schema: sdk.z.transforms.toJSONSchemaLegacy(tableDef.schema),\n frozen: tableDef.frozen,\n tags: tableDef.tags,\n factor: tableDef.factor,\n isComputeEnabled: tableDef.isComputeEnabled,\n })\n\n this._logger.success(`Table \"${tableName}\" has been created`)\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AAErB,aAAwB;AAGxB,cAAyB;AAElB,MAAM,gBAAgB;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EAEV,YAAY;AAAA,IACjB;AAAA,IACA,QAAAA;AAAA,IACA;AAAA,EACF,GAIG;AACD,SAAK,OAAO;AACZ,SAAK,UAAUA;AACf,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,MAAa,aAAa,EAAE,OAAO,cAAc,GAAwD;AACvG,UAAM,MAAM,KAAK,KAAK,UAAU,KAAK;AAErC,SAAK,QAAQ,IAAI,yBAAyB;AAE1C,UAAM,mBAAmB,OAAO,QAAQ,cAAc,UAAU,CAAC,CAAC;AAClE,UAAM,kBAAkB,MAAM,IAAI,eAAe,CAAC,CAAC;AAEnD,QAAI,CAAC,gBAAgB,SAAS;AAC5B,WAAK,QAAQ,KAAK,yDAAyD;AAC3E;AAAA,IACF;AAEA,UAAM,EAAE,QAAQ,eAAe,IAAI;AACnC,eAAW,CAAC,WAAW,QAAQ,KAAK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Y;AAAA,MAC3B,MAAM;AAAA,MACN,QAAQ,IAAI,EAAE,WAAW,mBAAmB,SAAS,MAAM;AAAA,MAC3D,QAAQ,SAAS;AAAA,MACjB,MAAM,SAAS;AAAA,MACf,QAAQ,SAAS;AAAA,MACjB,kBAAkB,SAAS;AAAA,IAC7B,CAAC;AAED,SAAK,QAAQ,QAAQ,UAAU,SAAS,oBAAoB;AAAA,EAC9D;AACF;",
6
6
  "names": ["logger"]
7
7
  }
@@ -5,12 +5,12 @@ type SchemaOptions = {
5
5
  examples?: any[];
6
6
  };
7
7
  type SchemaDefinition = {
8
- schema: sdk.ZuiObjectOrRefSchema;
8
+ schema: sdk.z.ZuiObjectOrRefSchema;
9
9
  ui?: Record<string, SchemaOptions | undefined>;
10
10
  };
11
11
  type MapSchemaOptions = {
12
12
  useLegacyZuiTransformer?: boolean;
13
13
  };
14
- export declare function mapZodToJsonSchema(definition: SchemaDefinition, options: MapSchemaOptions): Promise<ReturnType<typeof sdk.transforms.toJSONSchemaLegacy>>;
14
+ export declare function mapZodToJsonSchema(definition: SchemaDefinition, options: MapSchemaOptions): Promise<ReturnType<typeof sdk.z.transforms.toJSONSchemaLegacy>>;
15
15
  export declare const dereferenceSchema: (schema: JSONSchema7) => Promise<JSONSchema7>;
16
16
  export {};
@@ -38,9 +38,9 @@ const isObjectSchema = (schema) => schema.type === "object";
38
38
  async function mapZodToJsonSchema(definition, options) {
39
39
  let schema;
40
40
  if (options.useLegacyZuiTransformer) {
41
- schema = sdk.transforms.toJSONSchemaLegacy(definition.schema, { target: "jsonSchema7" });
41
+ schema = sdk.z.transforms.toJSONSchemaLegacy(definition.schema, { target: "jsonSchema7" });
42
42
  } else {
43
- schema = sdk.transforms.toJSONSchema(definition.schema);
43
+ schema = sdk.z.transforms.toJSONSchema(definition.schema);
44
44
  }
45
45
  schema = await dereferenceSchema(schema);
46
46
  if (!isObjectSchema(schema) || !definition.ui) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/schema-utils.ts"],
4
- "sourcesContent": ["import { dereference } from '@apidevtools/json-schema-ref-parser'\nimport * as sdk from '@botpress/sdk'\nimport { JSONSchema7 } from 'json-schema'\n\ntype ZuiToJsonSchema = typeof sdk.transforms.toJSONSchemaLegacy\ntype JsonSchema = ReturnType<ZuiToJsonSchema>\n\ntype SchemaOptions = {\n title?: string\n examples?: any[]\n}\n\ntype SchemaDefinition = {\n schema: sdk.ZuiObjectOrRefSchema\n ui?: Record<string, SchemaOptions | undefined>\n}\n\ntype MapSchemaOptions = {\n useLegacyZuiTransformer?: boolean\n}\n\nconst isObjectSchema = (schema: JsonSchema): boolean => schema.type === 'object'\n\nexport async function mapZodToJsonSchema(\n definition: SchemaDefinition,\n options: MapSchemaOptions\n): Promise<ReturnType<typeof sdk.transforms.toJSONSchemaLegacy>> {\n let schema: JSONSchema7\n if (options.useLegacyZuiTransformer) {\n schema = sdk.transforms.toJSONSchemaLegacy(definition.schema, { target: 'jsonSchema7' })\n } else {\n schema = sdk.transforms.toJSONSchema(definition.schema)\n }\n schema = (await dereferenceSchema(schema)) as typeof schema\n\n if (!isObjectSchema(schema) || !definition.ui) {\n return schema\n }\n\n for (const [key, value] of Object.entries(definition.ui ?? {})) {\n const property = schema.properties?.[key]\n\n if (!property) {\n continue\n }\n\n if (!!value?.title) {\n ;(property as any).title = value.title\n }\n\n if (!!value?.examples) {\n ;(property as any).examples = value.examples\n }\n }\n\n return schema\n}\n\nexport const dereferenceSchema = async (schema: JSONSchema7): Promise<JSONSchema7> => {\n return dereference(schema, {\n resolve: {\n external: false,\n file: false,\n http: false,\n },\n })\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAA4B;AAC5B,UAAqB;AAoBrB,MAAM,iBAAiB,CAAC,WAAgC,OAAO,SAAS;AAExE,eAAsB,mBACpB,YACA,SAC+D;AAC/D,MAAI;AACJ,MAAI,QAAQ,yBAAyB;AACnC,aAAS,IAAI,WAAW,mBAAmB,WAAW,QAAQ,EAAE,QAAQ,cAAc,CAAC;AAAA,EACzF,OAAO;AACL,aAAS,IAAI,WAAW,aAAa,WAAW,MAAM;AAAA,EACxD;AACA,WAAU,MAAM,kBAAkB,MAAM;AAExC,MAAI,CAAC,eAAe,MAAM,KAAK,CAAC,WAAW,IAAI;AAC7C,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,MAAM,CAAC,CAAC,GAAG;AAC9D,UAAM,WAAW,OAAO,aAAa,GAAG;AAExC,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,QAAI,CAAC,CAAC,OAAO,OAAO;AAClB;AAAC,MAAC,SAAiB,QAAQ,MAAM;AAAA,IACnC;AAEA,QAAI,CAAC,CAAC,OAAO,UAAU;AACrB;AAAC,MAAC,SAAiB,WAAW,MAAM;AAAA,IACtC;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,oBAAoB,OAAO,WAA8C;AACpF,aAAO,2CAAY,QAAQ;AAAA,IACzB,SAAS;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF,CAAC;AACH;",
4
+ "sourcesContent": ["import { dereference } from '@apidevtools/json-schema-ref-parser'\nimport * as sdk from '@botpress/sdk'\nimport { JSONSchema7 } from 'json-schema'\n\ntype ZuiToJsonSchema = typeof sdk.z.transforms.toJSONSchemaLegacy\ntype JsonSchema = ReturnType<ZuiToJsonSchema>\n\ntype SchemaOptions = {\n title?: string\n examples?: any[]\n}\n\ntype SchemaDefinition = {\n schema: sdk.z.ZuiObjectOrRefSchema\n ui?: Record<string, SchemaOptions | undefined>\n}\n\ntype MapSchemaOptions = {\n useLegacyZuiTransformer?: boolean\n}\n\nconst isObjectSchema = (schema: JsonSchema): boolean => schema.type === 'object'\n\nexport async function mapZodToJsonSchema(\n definition: SchemaDefinition,\n options: MapSchemaOptions\n): Promise<ReturnType<typeof sdk.z.transforms.toJSONSchemaLegacy>> {\n let schema: JSONSchema7\n if (options.useLegacyZuiTransformer) {\n schema = sdk.z.transforms.toJSONSchemaLegacy(definition.schema, { target: 'jsonSchema7' })\n } else {\n schema = sdk.z.transforms.toJSONSchema(definition.schema)\n }\n schema = (await dereferenceSchema(schema)) as typeof schema\n\n if (!isObjectSchema(schema) || !definition.ui) {\n return schema\n }\n\n for (const [key, value] of Object.entries(definition.ui ?? {})) {\n const property = schema.properties?.[key]\n\n if (!property) {\n continue\n }\n\n if (!!value?.title) {\n ;(property as any).title = value.title\n }\n\n if (!!value?.examples) {\n ;(property as any).examples = value.examples\n }\n }\n\n return schema\n}\n\nexport const dereferenceSchema = async (schema: JSONSchema7): Promise<JSONSchema7> => {\n return dereference(schema, {\n resolve: {\n external: false,\n file: false,\n http: false,\n },\n })\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAA4B;AAC5B,UAAqB;AAoBrB,MAAM,iBAAiB,CAAC,WAAgC,OAAO,SAAS;AAExE,eAAsB,mBACpB,YACA,SACiE;AACjE,MAAI;AACJ,MAAI,QAAQ,yBAAyB;AACnC,aAAS,IAAI,EAAE,WAAW,mBAAmB,WAAW,QAAQ,EAAE,QAAQ,cAAc,CAAC;AAAA,EAC3F,OAAO;AACL,aAAS,IAAI,EAAE,WAAW,aAAa,WAAW,MAAM;AAAA,EAC1D;AACA,WAAU,MAAM,kBAAkB,MAAM;AAExC,MAAI,CAAC,eAAe,MAAM,KAAK,CAAC,WAAW,IAAI;AAC7C,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,MAAM,CAAC,CAAC,GAAG;AAC9D,UAAM,WAAW,OAAO,aAAa,GAAG;AAExC,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,QAAI,CAAC,CAAC,OAAO,OAAO;AAClB;AAAC,MAAC,SAAiB,QAAQ,MAAM;AAAA,IACnC;AAEA,QAAI,CAAC,CAAC,OAAO,UAAU;AACrB;AAAC,MAAC,SAAiB,WAAW,MAAM;AAAA,IACtC;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,oBAAoB,OAAO,WAA8C;AACpF,aAAO,2CAAY,QAAQ;AAAA,IACzB,SAAS;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,10 @@
1
1
  import { z } from '@botpress/sdk';
2
2
  export declare const CONFIG_ENV_KEY = "CHILD_PROCESS_CONFIGURATION";
3
3
  export type Config = z.infer<typeof configSchema>;
4
- export declare const configSchema: import("@botpress/sdk").ZodUnion<[import("@botpress/sdk").ZodObject<{
5
- type: import("@botpress/sdk").ZodLiteral<"code">;
6
- code: import("@botpress/sdk").ZodString;
7
- env: import("@botpress/sdk").ZodOptional<import("@botpress/sdk").ZodRecord<import("@botpress/sdk").ZodString, import("@botpress/sdk").ZodString>>;
4
+ export declare const configSchema: z.ZodUnion<[z.ZodObject<{
5
+ type: z.ZodLiteral<"code">;
6
+ code: z.ZodString;
7
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
8
8
  }, "strip", {
9
9
  code: string;
10
10
  type: "code";
@@ -13,10 +13,10 @@ export declare const configSchema: import("@botpress/sdk").ZodUnion<[import("@bo
13
13
  code: string;
14
14
  type: "code";
15
15
  env?: Record<string, string> | undefined;
16
- }>, import("@botpress/sdk").ZodObject<{
17
- type: import("@botpress/sdk").ZodLiteral<"file">;
18
- file: import("@botpress/sdk").ZodString;
19
- env: import("@botpress/sdk").ZodOptional<import("@botpress/sdk").ZodRecord<import("@botpress/sdk").ZodString, import("@botpress/sdk").ZodString>>;
16
+ }>, z.ZodObject<{
17
+ type: z.ZodLiteral<"file">;
18
+ file: z.ZodString;
19
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
20
20
  }, "strip", {
21
21
  type: "file";
22
22
  file: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "5.6.1",
3
+ "version": "6.0.0",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run build:types && pnpm run bundle && pnpm run template:gen",
@@ -28,7 +28,7 @@
28
28
  "@apidevtools/json-schema-ref-parser": "^11.7.0",
29
29
  "@botpress/chat": "0.5.5",
30
30
  "@botpress/client": "1.36.0",
31
- "@botpress/sdk": "5.4.4",
31
+ "@botpress/sdk": "6.0.0",
32
32
  "@bpinternal/const": "^0.1.0",
33
33
  "@bpinternal/tunnel": "^0.1.1",
34
34
  "@bpinternal/verel": "^0.2.0",
@@ -6,7 +6,7 @@
6
6
  "private": true,
7
7
  "dependencies": {
8
8
  "@botpress/client": "1.36.0",
9
- "@botpress/sdk": "5.4.4"
9
+ "@botpress/sdk": "6.0.0"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^22.16.4",
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "1.36.0",
10
- "@botpress/sdk": "5.4.4"
10
+ "@botpress/sdk": "6.0.0"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^22.16.4",
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "private": true,
8
8
  "dependencies": {
9
- "@botpress/sdk": "5.4.4"
9
+ "@botpress/sdk": "6.0.0"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^22.16.4",
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "1.36.0",
10
- "@botpress/sdk": "5.4.4"
10
+ "@botpress/sdk": "6.0.0"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^22.16.4",
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "1.36.0",
10
- "@botpress/sdk": "5.4.4",
10
+ "@botpress/sdk": "6.0.0",
11
11
  "axios": "^1.6.8"
12
12
  },
13
13
  "devDependencies": {