apify-cli 1.5.1-beta.1 → 1.5.1-beta.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.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
10
10
 
11
11
  - **generate-schema-types:** Change default output path to src/**generated**/actor/ ([#1104](https://github.com/apify/apify-cli/pull/1104)) ([9b44152](https://github.com/apify/apify-cli/commit/9b441522eae7c23ff0744e1a903b87664c66f36e)) by [@vladfrangu](https://github.com/vladfrangu)
12
12
  - Forward user signals to builds/runs ([#1088](https://github.com/apify/apify-cli/pull/1088)) ([ef4d375](https://github.com/apify/apify-cli/commit/ef4d3755ad725d8ac17b2dbee346391d0f8f547d)) by [@vladfrangu](https://github.com/vladfrangu), closes [#631](https://github.com/apify/apify-cli/issues/631), [#885](https://github.com/apify/apify-cli/issues/885)
13
+ - Support directory path as argument in `generate-schema-types` command ([#1069](https://github.com/apify/apify-cli/pull/1069)) ([a08b242](https://github.com/apify/apify-cli/commit/a08b242101ab82c13bf01162cf586e34169ebd40)) by [@l2ysho](https://github.com/l2ysho), closes [#1033](https://github.com/apify/apify-cli/issues/1033)
13
14
 
14
15
  ### 🐛 Bug Fixes
15
16
 
@@ -1,4 +1,4 @@
1
- import e from"node:process";import t from"chalk";import n from"indent-string";import r from"widest-line";import i from"wrap-ansi";import{inspect as a,parseArgs as s,promisify as c}from"node:util";import{gt as l,gte as u,minVersion as f,satisfies as p}from"semver";import{appendFileSync as m,constants as h,copyFileSync as g,createWriteStream as _,existsSync as v,fstat as y,mkdirSync as b,openSync as x,readFileSync as S,readdirSync as C,realpathSync as w,renameSync as T,rmSync as ee,statSync as te,unlinkSync as ne,writeFileSync as E}from"node:fs";import D,{basename as re,dirname as O,isAbsolute as ie,join as k,relative as ae,resolve as A,sep as oe}from"node:path";import se from"string-width";import ce from"strip-ansi";import{once as le}from"node:events";import{homedir as ue,platform as de}from"node:os";import{ACTOR_ENV_VARS as j,ACTOR_JOB_STATUSES as M,ACTOR_JOB_TERMINAL_STATUSES as fe,ACTOR_NAME as pe,ACTOR_SOURCE_TYPES as me,APIFY_ENV_VARS as N,KEY_VALUE_STORE_KEYS as he,LOCAL_ACTOR_ENV_VARS as ge,LOCAL_STORAGE_SUBDIRS as _e,MAX_MULTIFILE_BYTES as ve,META_ORIGINS as ye,SOURCE_FILE_FORMATS as be}from"@apify/consts";import{jaroWinkler as xe}from"@skyra/jaro-winkler";import Se from"js-levenshtein";import Ce from"ci-info";import{createHmacSignature as we,cryptoRandomObjectId as Te}from"@apify/utilities";import{execSync as Ee,spawn as De}from"node:child_process";import{access as Oe,lstat as ke,mkdir as P,readFile as F,readdir as I,rename as Ae,stat as L,symlink as je,unlink as Me,writeFile as R}from"node:fs/promises";import{get as Ne}from"node:https";import{finished as Pe,pipeline as Fe}from"node:stream/promises";import{DurationFormatter as Ie,Time as Le,TimeTypes as Re}from"@sapphire/duration";import{Timestamp as ze}from"@sapphire/timestamp";import Be from"adm-zip";import Ve from"ajv/dist/2019.js";import{ApifyClient as He,DownloadItemsFormat as z}from"apify-client";import Ue from"archiver";import We,{AxiosHeaders as Ge}from"axios";import Ke from"escape-string-regexp";import qe from"ignore";import{getEncoding as Je}from"istextorbinary";import Ye,{Mime as Xe}from"mime";import Ze from"mime/types/other.js";import Qe from"mime/types/standard.js";import{glob as $e}from"tinyglobby";import{rimraf as et}from"rimraf";import{Result as tt,err as nt,none as B,ok as rt,some as it}from"@sapphire/result";import at from"configparser";import ot from"@inquirer/input";import st from"is-ci";import{execa as ct}from"execa";import lt from"which";import{calculateRunDynamicMemory as ut}from"@apify/actor-memory-expression";import{Separator as dt,createPrompt as ft,isEnterKey as pt,makeTheme as mt,useKeypress as ht,usePrefix as gt,useState as _t}from"@inquirer/core";import{MemoryStorage as vt}from"@crawlee/memory-storage";import{compile as yt}from"json-schema-to-typescript";import{cloneDeep as V}from"es-toolkit";import{validateInputSchema as bt,validateInputUsingValidator as xt}from"@apify/input_schema";import{getDatasetSchemaValidator as St,getKeyValueStoreSchemaValidator as Ct,getOutputSchemaValidator as wt}from"@apify/json_schemas";import Tt from"cli-table3";import Et from"jju";import Dt from"tiged";import Ot from"open";import{fetchManifest as kt,manifestUrl as At,wrapperManifestUrl as jt}from"@apify/actor-templates";import Mt from"computer-name";import Nt from"cors";import Pt from"express";import Ft from"@inquirer/password";import It from"@inquirer/select";import Lt from"node:assert";import{ReadStream as Rt}from"node:tty";import zt from"detect-indent";import{fileURLToPath as Bt}from"node:url";import Vt from"@root/walk";import Ht from"handlebars";function internalLog(e){e.stdoutOutput&&console.log(...e.stdoutOutput),e.stderrOutput&&console.error(...e.stderrOutput)}function simpleLog(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[e.message]})}function error(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.red(`Error:`),e.message]})}function warning(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.yellow.bold(`Warning:`),e.message]})}function success(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.green(`Success:`),e.message]})}function run(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.gray(`Run:`),e.message]})}function info(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.white(`Info:`),e.message]})}function link(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.blue(e.message),e.url]})}function detectInstallMethod(){if(process.env.APIFY_CLI_MARKED_INSTALL_METHOD)return process.env.APIFY_CLI_MARKED_INSTALL_METHOD;if(process.env.APIFY_CLI_BUNDLE)return`bundle`;let e=process.argv[1];if(!e)return warning({message:`Failed to detect install method of CLI, assuming npm`}),`npm`;let t=w(e);return process.env.VOLTA_HOME&&t.includes(process.env.VOLTA_HOME)?`volta`:t.includes(`homebrew/Cellar`)||t.includes(`linuxbrew/Cellar`)?`homebrew`:process.env.PNPM_HOME&&t.includes(process.env.PNPM_HOME)?`pnpm`:process.env.BUN_INSTALL&&t.includes(process.env.BUN_INSTALL)?`bun`:`npm`}function getRuntimeInfo(){return process.versions.bun?{runtime:`bun`,version:process.versions.bun,nodeVersion:process.versions.node}:process.versions.deno?{runtime:`deno`,version:process.versions.deno,nodeVersion:process.versions.node}:{runtime:`node`,version:process.versions.node}}let Ut=null;function useCLIMetadata(){if(Ut)return Ut;let e=detectInstallMethod(),t=getRuntimeInfo();return Ut={version:`1.5.1-beta.1`,hash:`51c3ca42c2810c87276fd6a1efe98e656eaff0fb`,arch:process.env.APIFY_BUNDLE_ARCH??process.arch,platform:process.platform===`win32`?`windows`:process.platform,runtime:t,extraRuntimeData:t.nodeVersion?`(emulating node ${t.nodeVersion})`:``,installMethod:e,get fullVersionString(){return`apify-cli/${this.version} (${this.hash.slice(0,7)}) running on ${this.platform}-${this.arch} with ${this.runtime.runtime}-${t.version}${this.extraRuntimeData?` ${this.extraRuntimeData}`:``}, installed via ${this.installMethod}`},get isBeta(){return this.version.includes(`beta`)||this.version===`0.0.0`}},e===`bundle`&&(Ut.installPath=O(process.execPath)),Ut}let Wt;function getMaxLineWidth(){if(Wt)return Wt;let e=Number(process.env.APIFY_CLI_MAX_LINE_WIDTH);if(!Number.isNaN(e))Wt=e;else if(!process.stdout.isTTY)Wt=80;else{let e=process.stdout.getWindowSize?.()[0]??-1;Wt=e<1?80:e<40?40:e}return Wt}var BaseCommandRenderer=class{command;entrypoint;constructor(e,t){this.entrypoint=e,this.command=t}pushShortDescription(e){let n=this.command.interactive?`${t.yellow(`[INTERACTIVE]`)} `:``;this.command.shortDescription?e.push(`${n}${this.command.shortDescription}`,``):this.command.description&&e.push(`${n}${this.command.description.split(`
1
+ import e from"node:process";import t from"chalk";import n from"indent-string";import r from"widest-line";import i from"wrap-ansi";import{inspect as a,parseArgs as s,promisify as c}from"node:util";import{gt as l,gte as u,minVersion as f,satisfies as p}from"semver";import{appendFileSync as m,constants as h,copyFileSync as g,createWriteStream as _,existsSync as v,fstat as y,mkdirSync as b,openSync as x,readFileSync as S,readdirSync as C,realpathSync as w,renameSync as T,rmSync as ee,statSync as te,unlinkSync as ne,writeFileSync as E}from"node:fs";import D,{basename as re,dirname as O,isAbsolute as ie,join as k,relative as ae,resolve as A,sep as oe}from"node:path";import se from"string-width";import ce from"strip-ansi";import{once as le}from"node:events";import{homedir as ue,platform as de}from"node:os";import{ACTOR_ENV_VARS as j,ACTOR_JOB_STATUSES as M,ACTOR_JOB_TERMINAL_STATUSES as fe,ACTOR_NAME as pe,ACTOR_SOURCE_TYPES as me,APIFY_ENV_VARS as N,KEY_VALUE_STORE_KEYS as he,LOCAL_ACTOR_ENV_VARS as ge,LOCAL_STORAGE_SUBDIRS as _e,MAX_MULTIFILE_BYTES as ve,META_ORIGINS as ye,SOURCE_FILE_FORMATS as be}from"@apify/consts";import{jaroWinkler as xe}from"@skyra/jaro-winkler";import Se from"js-levenshtein";import Ce from"ci-info";import{createHmacSignature as we,cryptoRandomObjectId as Te}from"@apify/utilities";import{execSync as Ee,spawn as De}from"node:child_process";import{access as Oe,lstat as ke,mkdir as P,readFile as F,readdir as I,rename as Ae,stat as L,symlink as je,unlink as Me,writeFile as R}from"node:fs/promises";import{get as Ne}from"node:https";import{finished as Pe,pipeline as Fe}from"node:stream/promises";import{DurationFormatter as Ie,Time as Le,TimeTypes as Re}from"@sapphire/duration";import{Timestamp as ze}from"@sapphire/timestamp";import Be from"adm-zip";import Ve from"ajv/dist/2019.js";import{ApifyClient as He,DownloadItemsFormat as z}from"apify-client";import Ue from"archiver";import We,{AxiosHeaders as Ge}from"axios";import Ke from"escape-string-regexp";import qe from"ignore";import{getEncoding as Je}from"istextorbinary";import Ye,{Mime as Xe}from"mime";import Ze from"mime/types/other.js";import Qe from"mime/types/standard.js";import{glob as $e}from"tinyglobby";import{rimraf as et}from"rimraf";import{Result as tt,err as nt,none as B,ok as rt,some as it}from"@sapphire/result";import at from"configparser";import ot from"@inquirer/input";import st from"is-ci";import{execa as ct}from"execa";import lt from"which";import{calculateRunDynamicMemory as ut}from"@apify/actor-memory-expression";import{Separator as dt,createPrompt as ft,isEnterKey as pt,makeTheme as mt,useKeypress as ht,usePrefix as gt,useState as _t}from"@inquirer/core";import{MemoryStorage as vt}from"@crawlee/memory-storage";import{compile as yt}from"json-schema-to-typescript";import{cloneDeep as V}from"es-toolkit";import{validateInputSchema as bt,validateInputUsingValidator as xt}from"@apify/input_schema";import{getDatasetSchemaValidator as St,getKeyValueStoreSchemaValidator as Ct,getOutputSchemaValidator as wt}from"@apify/json_schemas";import Tt from"cli-table3";import Et from"jju";import Dt from"tiged";import Ot from"open";import{fetchManifest as kt,manifestUrl as At,wrapperManifestUrl as jt}from"@apify/actor-templates";import Mt from"computer-name";import Nt from"cors";import Pt from"express";import Ft from"@inquirer/password";import It from"@inquirer/select";import Lt from"node:assert";import{ReadStream as Rt}from"node:tty";import zt from"detect-indent";import{fileURLToPath as Bt}from"node:url";import Vt from"@root/walk";import Ht from"handlebars";function internalLog(e){e.stdoutOutput&&console.log(...e.stdoutOutput),e.stderrOutput&&console.error(...e.stderrOutput)}function simpleLog(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[e.message]})}function error(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.red(`Error:`),e.message]})}function warning(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.yellow.bold(`Warning:`),e.message]})}function success(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.green(`Success:`),e.message]})}function run(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.gray(`Run:`),e.message]})}function info(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.white(`Info:`),e.message]})}function link(e){internalLog({[e.stdout?`stdoutOutput`:`stderrOutput`]:[t.blue(e.message),e.url]})}function detectInstallMethod(){if(process.env.APIFY_CLI_MARKED_INSTALL_METHOD)return process.env.APIFY_CLI_MARKED_INSTALL_METHOD;if(process.env.APIFY_CLI_BUNDLE)return`bundle`;let e=process.argv[1];if(!e)return warning({message:`Failed to detect install method of CLI, assuming npm`}),`npm`;let t=w(e);return process.env.VOLTA_HOME&&t.includes(process.env.VOLTA_HOME)?`volta`:t.includes(`homebrew/Cellar`)||t.includes(`linuxbrew/Cellar`)?`homebrew`:process.env.PNPM_HOME&&t.includes(process.env.PNPM_HOME)?`pnpm`:process.env.BUN_INSTALL&&t.includes(process.env.BUN_INSTALL)?`bun`:`npm`}function getRuntimeInfo(){return process.versions.bun?{runtime:`bun`,version:process.versions.bun,nodeVersion:process.versions.node}:process.versions.deno?{runtime:`deno`,version:process.versions.deno,nodeVersion:process.versions.node}:{runtime:`node`,version:process.versions.node}}let Ut=null;function useCLIMetadata(){if(Ut)return Ut;let e=detectInstallMethod(),t=getRuntimeInfo();return Ut={version:`1.5.1-beta.2`,hash:`25c2728196d0ed44199228e2049d9333f1985d13`,arch:process.env.APIFY_BUNDLE_ARCH??process.arch,platform:process.platform===`win32`?`windows`:process.platform,runtime:t,extraRuntimeData:t.nodeVersion?`(emulating node ${t.nodeVersion})`:``,installMethod:e,get fullVersionString(){return`apify-cli/${this.version} (${this.hash.slice(0,7)}) running on ${this.platform}-${this.arch} with ${this.runtime.runtime}-${t.version}${this.extraRuntimeData?` ${this.extraRuntimeData}`:``}, installed via ${this.installMethod}`},get isBeta(){return this.version.includes(`beta`)||this.version===`0.0.0`}},e===`bundle`&&(Ut.installPath=O(process.execPath)),Ut}let Wt;function getMaxLineWidth(){if(Wt)return Wt;let e=Number(process.env.APIFY_CLI_MAX_LINE_WIDTH);if(!Number.isNaN(e))Wt=e;else if(!process.stdout.isTTY)Wt=80;else{let e=process.stdout.getWindowSize?.()[0]??-1;Wt=e<1?80:e<40?40:e}return Wt}var BaseCommandRenderer=class{command;entrypoint;constructor(e,t){this.entrypoint=e,this.command=t}pushShortDescription(e){let n=this.command.interactive?`${t.yellow(`[INTERACTIVE]`)} `:``;this.command.shortDescription?e.push(`${n}${this.command.shortDescription}`,``):this.command.description&&e.push(`${n}${this.command.description.split(`
2
2
  `)[0]}`,``)}pushDescription(e){if(!this.command.description)return;e.push(t.bold(`DESCRIPTION`));let r=n(i(this.command.description,getMaxLineWidth()-2,{trim:!1}),2);e.push(r),e.push(``)}pushExamples(e){let{examples:r}=this.command;if(r?.length){e.push(t.bold(`EXAMPLES`));for(let a of r){if(a.description){let r=n(i(a.description,getMaxLineWidth()-4,{trim:!1}).split(`
3
3
  `).map(e=>`# ${e}`).join(`
4
4
  `),2);e.push(t.dim(r))}e.push(` $ ${this.normalizeExampleCommand(a.command)}`),e.push(``)}}}normalizeExampleCommand(e){let t=this.entrypoint.split(` `);if(t.length<2)return e;let n=t[t.length-1],r=`${t.slice(0,-1).join(` `)} `,i=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=e;return a.startsWith(`${n} `)&&(a=`${r}${a}`),a=a.replace(RegExp(`\\|\\s+${i}\\s`,`g`),`| ${r}${n} `),a}pushInteractiveNote(e){if(!this.command.interactive)return;e.push(t.bold(`NOTE`));let r=n(i(this.command.interactiveNote||`This command prompts the user for input. To run non-interactively (e.g. in CI or from an AI agent), pass all required arguments and flags explicitly.`,getMaxLineWidth()-2,{trim:!1}),2);e.push(r),e.push(``)}pushLearnMore(e){this.command.docsUrl&&(e.push(t.bold(`LEARN MORE`)),e.push(` ${this.command.docsUrl}`),e.push(``))}pushNewLineBeforeNewEntryIfLengthIsPastTheLimit({state:e,itemToAdd:t,indentSize:n}){se(e.join(` `).split(`
@@ -63,7 +63,9 @@ Reads the input schema from one of these locations (in priority order):
63
63
  3. .actor/INPUT_SCHEMA.json
64
64
  4. INPUT_SCHEMA.json
65
65
 
66
- Optionally specify custom schema path to use.`;static group=`Actor Runtime`;static examples=[{description:`Generate TypeScript types from the input schema into the default output directory.`,command:`actor generate-schema-types`},{description:`Generate types from a custom schema path.`,command:`actor generate-schema-types ./schemas/my-input.json`},{description:`Mark all generated properties as optional.`,command:`actor generate-schema-types --all-optional`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#actor-generate-schema-types`;static flags={output:Y.string({char:`o`,description:`Directory where the generated files should be outputted. Defaults to src/__generated__/actor/ to stay within the typical tsconfig rootDir.`,required:!1,default:D.join(`src`,`__generated__`,`actor`)}),strict:Y.boolean({description:`Whether generated interfaces should be strict (no index signature [key: string]: unknown).`,required:!1,default:!0}),"all-optional":Y.boolean({description:`Mark all properties as optional in generated types.`,required:!1,default:!1})};static args={path:Z.string({required:!1,description:`Optional path to the input schema file. If not provided, searches default locations.`})};async run(){let t=e.cwd(),{inputSchema:n}=await readAndValidateInputSchema({forcePath:this.args.path,cwd:t,getMessage:e=>e?`Generating types from input schema at ${e}`:`Generating types from input schema embedded in '${U}'`}),r=`input`,i=this.flags.allOptional?clearAllRequired(n):makePropertiesRequired(n),a={bannerComment:`
66
+ Optionally specify a custom schema file path, or a directory path.
67
+ When a directory is provided, all schemas are discovered from it
68
+ just as if the command were run from that directory with no argument.`;static group=`Actor Runtime`;static examples=[{description:`Generate TypeScript types from the input schema into the default output directory.`,command:`actor generate-schema-types`},{description:`Generate types from a custom schema path.`,command:`actor generate-schema-types ./schemas/my-input.json`},{description:`Mark all generated properties as optional.`,command:`actor generate-schema-types --all-optional`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#actor-generate-schema-types`;static flags={output:Y.string({char:`o`,description:`Directory where the generated files should be outputted. Defaults to src/__generated__/actor/ to stay within the typical tsconfig rootDir.`,required:!1,default:D.join(`src`,`__generated__`,`actor`)}),strict:Y.boolean({description:`Whether generated interfaces should be strict (no index signature [key: string]: unknown).`,required:!1,default:!0}),"all-optional":Y.boolean({description:`Mark all properties as optional in generated types.`,required:!1,default:!1})};static args={path:Z.string({required:!1,description:`Optional path to an input schema file or a directory containing Actor schemas. If a directory is given, all schema types are generated from it. If not provided, searches default locations in the current directory.`})};async run(){let t=e.cwd(),n,r=t;if(this.args.path){let e=D.resolve(t,this.args.path);await L(e).then(e=>e.isDirectory()).catch(()=>!1)?r=e:n=e}let{inputSchema:i}=await readAndValidateInputSchema({forcePath:n,cwd:r,getMessage:e=>e?`Generating types from input schema at ${e}`:`Generating types from input schema embedded in '${U}'`}),a=`input`,s=this.flags.allOptional?clearAllRequired(i):makePropertiesRequired(i),c={bannerComment:`
67
69
  // biome-ignore-all lint: generated
68
70
  // biome-ignore-all format: generated
69
71
  /* eslint-disable */
@@ -73,7 +75,7 @@ Optionally specify custom schema path to use.`;static group=`Actor Runtime`;stat
73
75
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
74
76
  * and run apify actor generate-schema-types to regenerate this file.
75
77
  */
76
- `,maxItems:-1,unknownAny:!0,format:!0,additionalProperties:!this.flags.strict,$refOptions:{resolve:{external:!1,file:!1,http:!1}}},s=await yt(stripTitles(i),r,a),c=D.resolve(t,this.flags.output);await P(c,{recursive:!0});let l=D.join(c,`${r}.ts`);if(await R(l,s,`utf-8`),success({message:`Generated types written to ${l}`}),!this.args.path){let n=await Promise.allSettled([this.generateDatasetTypes({cwd:t,outputDir:c,compileOptions:a}),this.generateOutputTypes({cwd:t,outputDir:c,compileOptions:a}),this.generateKvsTypes({cwd:t,outputDir:c,compileOptions:a})]),r=[`Dataset`,`Output`,`Key-Value Store`],i=!1;for(let[e,t]of n.entries())t.status===`rejected`&&(i=!0,error({message:`Failed to generate types for ${r[e]} schema: ${t.reason instanceof Error?t.reason.message:String(t.reason)}`}));i&&(e.exitCode=1)}}async generateDatasetTypes({cwd:e,outputDir:t,compileOptions:n}){let r=readDatasetSchema({cwd:e});if(!r)return;let{datasetSchema:i,datasetSchemaPath:a}=r;info(a?{message:`[experimental] Generating types from Dataset schema at ${a}`}:{message:`[experimental] Generating types from Dataset schema embedded in '${U}'`});let s=prepareFieldsSchemaForCompilation(i);if(!s){warning({message:`Dataset schema has no fields defined, skipping type generation.`});return}let c=`dataset`,l=await yt(stripTitles(this.flags.allOptional?clearAllRequired(s):s),c,n),u=D.join(t,`${c}.ts`);await R(u,l,`utf-8`),success({message:`Generated types written to ${u}`})}async generateOutputTypes({cwd:e,outputDir:t,compileOptions:n}){let r=readOutputSchema({cwd:e});if(!r)return;let{outputSchema:i,outputSchemaPath:a}=r;info(a?{message:`[experimental] Generating types from Output schema at ${a}`}:{message:`[experimental] Generating types from Output schema embedded in '${U}'`});let s=prepareOutputSchemaForCompilation(i);if(!s){warning({message:`Output schema has no properties defined, skipping type generation.`});return}let c=`output`,l=await yt(stripTitles(this.flags.allOptional?clearAllRequired(s):s),c,n),u=D.join(t,`${c}.ts`);await R(u,l,`utf-8`),success({message:`Generated types written to ${u}`})}async generateKvsTypes({cwd:e,outputDir:t,compileOptions:n}){let r=readStorageSchema({cwd:e,key:`keyValueStore`,label:`Key-Value Store`});if(!r)return;let{schema:i,schemaPath:a}=r;info(a?{message:`[experimental] Generating types from Key-Value Store schema at ${a}`}:{message:`[experimental] Generating types from Key-Value Store schema embedded in '${U}'`});let s=prepareKvsCollectionsForCompilation(i);if(s.length===0){warning({message:`Key-Value Store schema has no collections with JSON schemas, skipping type generation.`});return}let c=[];for(let{name:e,schema:t}of s){let r=await yt(stripTitles(this.flags.allOptional?clearAllRequired(t):t),e,{...n,bannerComment:c.length===0?n.bannerComment:``});c.push(r)}let l=D.join(t,`key-value-store.ts`);await R(l,c.join(`
78
+ `,maxItems:-1,unknownAny:!0,format:!0,additionalProperties:!this.flags.strict,$refOptions:{resolve:{external:!1,file:!1,http:!1}}},l=await yt(stripTitles(s),a,c),u=D.resolve(r,this.flags.output);await P(u,{recursive:!0});let f=D.join(u,`${a}.ts`);if(await R(f,l,`utf-8`),success({message:`Generated types written to ${f}`}),!n){let t=await Promise.allSettled([this.generateDatasetTypes({cwd:r,outputDir:u,compileOptions:c}),this.generateOutputTypes({cwd:r,outputDir:u,compileOptions:c}),this.generateKvsTypes({cwd:r,outputDir:u,compileOptions:c})]),n=[`Dataset`,`Output`,`Key-Value Store`],i=!1;for(let[e,r]of t.entries())r.status===`rejected`&&(i=!0,error({message:`Failed to generate types for ${n[e]} schema: ${r.reason instanceof Error?r.reason.message:String(r.reason)}`}));i&&(e.exitCode=1)}}async generateDatasetTypes({cwd:e,outputDir:t,compileOptions:n}){let r=readDatasetSchema({cwd:e});if(!r)return;let{datasetSchema:i,datasetSchemaPath:a}=r;info(a?{message:`[experimental] Generating types from Dataset schema at ${a}`}:{message:`[experimental] Generating types from Dataset schema embedded in '${U}'`});let s=prepareFieldsSchemaForCompilation(i);if(!s){warning({message:`Dataset schema has no fields defined, skipping type generation.`});return}let c=`dataset`,l=await yt(stripTitles(this.flags.allOptional?clearAllRequired(s):s),c,n),u=D.join(t,`${c}.ts`);await R(u,l,`utf-8`),success({message:`Generated types written to ${u}`})}async generateOutputTypes({cwd:e,outputDir:t,compileOptions:n}){let r=readOutputSchema({cwd:e});if(!r)return;let{outputSchema:i,outputSchemaPath:a}=r;info(a?{message:`[experimental] Generating types from Output schema at ${a}`}:{message:`[experimental] Generating types from Output schema embedded in '${U}'`});let s=prepareOutputSchemaForCompilation(i);if(!s){warning({message:`Output schema has no properties defined, skipping type generation.`});return}let c=`output`,l=await yt(stripTitles(this.flags.allOptional?clearAllRequired(s):s),c,n),u=D.join(t,`${c}.ts`);await R(u,l,`utf-8`),success({message:`Generated types written to ${u}`})}async generateKvsTypes({cwd:e,outputDir:t,compileOptions:n}){let r=readStorageSchema({cwd:e,key:`keyValueStore`,label:`Key-Value Store`});if(!r)return;let{schema:i,schemaPath:a}=r;info(a?{message:`[experimental] Generating types from Key-Value Store schema at ${a}`}:{message:`[experimental] Generating types from Key-Value Store schema embedded in '${U}'`});let s=prepareKvsCollectionsForCompilation(i);if(s.length===0){warning({message:`Key-Value Store schema has no collections with JSON schemas, skipping type generation.`});return}let c=[];for(let{name:e,schema:t}of s){let r=await yt(stripTitles(this.flags.allOptional?clearAllRequired(t):t),e,{...n,bannerComment:c.length===0?n.bannerComment:``});c.push(r)}let l=D.join(t,`key-value-store.ts`);await R(l,c.join(`
77
79
  `),`utf-8`),success({message:`Generated types written to ${l}`})}},ActorGetInputCommand=class extends ApifyCommand{static name=`get-input`;static description=`Gets the Actor input value from the default key-value store associated with the Actor run.`;static group=`Actor Runtime`;static examples=[{description:`Print the current Actor input to stdout.`,command:`actor get-input`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#actor-get-input`;async run(){await outputInputFromDefaultStore()}},ActorGetPublicUrlCommand=class extends ApifyCommand{static name=`get-public-url`;static description=`Get an HTTP URL that allows public access to a key-value store item.`;static group=`Actor Runtime`;static examples=[{description:`Get a public URL for the record stored under the given key.`,command:`actor get-public-url OUTPUT`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#actor-get-public-url`;static args={key:Z.string({required:!0,description:`Key of the record in the key-value store.`})};async run(){let{key:e}=this.args;if([void 0,`false`,``].includes(process.env[N.IS_AT_HOME])){error({message:`get-public-url is not yet implemented for local development`}),process.exitCode=255;return}let t=process.env[j.DEFAULT_KEY_VALUE_STORE_ID];if(!t){error({message:`Missing environment variable: ${j.DEFAULT_KEY_VALUE_STORE_ID}. Please set it before running the command.`}),process.exitCode=5;return}let n=await getApifyStorageClient();if(!await n.keyValueStore(t).get()){error({message:`Key-Value store with ID '${t}' was not found. Ensure the store exists and that the correct ID is set in ${j.DEFAULT_KEY_VALUE_STORE_ID}.`}),process.exitCode=250;return}let r=await n.keyValueStore(t).getRecordPublicUrl(e);console.log(r)}},ActorGetValueCommand=class extends ApifyCommand{static name=`get-value`;static description=`Gets a value from the default key-value store associated with the Actor run.`;static group=`Actor Runtime`;static examples=[{description:`Read the record stored under the key "INPUT".`,command:`actor get-value INPUT`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#actor-get-value`;static args={key:Z.string({required:!0,description:`Key of the record in the key-value store.`})};async run(){let{key:e}=this.args;await outputRecordFromDefaultStore(e)}},ActorPushDataCommand=class extends ApifyCommand{static name=`push-data`;static description=`Saves data to Actor's run default dataset.`;static group=`Actor Runtime`;static examples=[{description:`Push a single item as an inline JSON argument.`,command:`actor push-data '{"key":"value"}'`},{description:`Push an array of items by piping from stdin.`,command:`cat ./items.json | actor push-data`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#actor-push-data`;static args={item:Z.string({description:`JSON string with one object or array of objects containing data to be stored in the default dataset.`})};async run(){let{item:e}=this.args,t=e||fn;if(!t){error({message:`No item was provided.`});return}let n=await getApifyStorageClient(),r=getDefaultStorageId(Hn.DATASET),i;try{i=JSON.parse(t.toString(`utf8`))}catch(e){throw Error(`Failed to parse data as JSON string: ${e.message}`)}await n.dataset(r).pushItems(i)}},ActorSetValueCommand=class extends ApifyCommand{static name=`set-value`;static description=`Sets or removes a record in the default key-value store associated with the Actor run.`;static group=`Actor Runtime`;static examples=[{description:`Store a JSON value under the key "OUTPUT".`,command:`actor set-value OUTPUT '{"status":"done"}'`},{description:`Store a file as a text record.`,command:`cat ./report.txt | actor set-value REPORT --contentType text/plain`},{description:`Delete the record stored under the given key.`,command:`actor set-value OUTPUT`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#actor-set-value`;static args={key:Z.string({required:!0,description:`Key of the record in key-value store.`}),value:Z.string({required:!1,description:`Record data, which can be one of the following values:
78
80
  - If empty, the record in the key-value store is deleted.
79
81
  - If no \`contentType\` flag is specified, value is expected to be any JSON string value.
@@ -218,4 +220,4 @@ When no path is provided, validates all schemas found in '${U}':
218
220
  - Dataset schema (from "storages.dataset")
219
221
  - Output schema (from "output")
220
222
  - Key-Value Store schema (from "storages.keyValueStore")`;static group=`Local Actor Development`;static examples=[{description:`Validate the input schema discovered from the default locations.`,command:`apify validate-schema`},{description:`Validate a specific INPUT_SCHEMA.json file.`,command:`apify validate-schema ./my-schema.json`}];static docsUrl=`https://docs.apify.com/cli/docs/reference#apify-validate-schema`;static args={path:Z.string({required:!1,description:`Optional path to your INPUT_SCHEMA.json file. If not provided, validates all schemas in '${U}'.`})};static hiddenAliases=[`vis`];async run(){if(this.args.path){await this.validateInputSchemaAtPath(this.args.path);return}await this.validateAllSchemas()}async validateInputSchemaAtPath(t){await readAndValidateInputSchema({forcePath:t,cwd:e.cwd(),getMessage:e=>`Validating input schema at ${e??t}`}),success({message:`Input schema is valid.`})}async validateAllSchemas(){let t=e.cwd(),n=!1,r=!1;try{let{inputSchema:e,inputSchemaPath:r}=await readInputSchema({cwd:t,throwOnMissing:!0});e&&(n=!0,info({message:`Validating input schema ${r?`at ${r}`:`embedded in '${U}'`}`}),bt(new _n({strict:!1}),e),success({message:`Input schema is valid.`}))}catch(e){n=!0,r=!0,error({message:e.message})}let i=[{label:`Dataset`,read:()=>readStorageSchema({cwd:t,key:`dataset`,label:`Dataset`,throwOnMissing:!0}),validate:validateDatasetSchema},{label:`Output`,read:()=>readStorageSchema({cwd:t,key:`output`,label:`Output`,getRef:e=>e?.output,throwOnMissing:!0}),validate:validateOutputSchema},{label:`Key-Value Store`,read:()=>readStorageSchema({cwd:t,key:`keyValueStore`,label:`Key-Value Store`,throwOnMissing:!0}),validate:validateKvsSchema}];for(let{label:e,read:t,validate:a}of i)try{let r=t();r&&(n=!0,info({message:`Validating ${e} schema ${r.schemaPath?`at ${r.schemaPath}`:`embedded in '${U}'`}`}),a(r.schema),success({message:`${e} schema is valid.`}))}catch(e){n=!0,r=!0,error({message:e.message})}if(!n)throw Error(`No schemas found. Make sure '${U}' exists and defines at least one schema.`);r&&(e.exitCode=5)}};const Lr=[ActorIndexCommand,ActorsIndexCommand,AuthIndexCommand,BuildsIndexCommand,DatasetsIndexCommand,KeyValueStoresIndexCommand,RequestQueuesIndexCommand,RunsIndexCommand,SecretsIndexCommand,TasksIndexCommand,TelemetryIndexCommand,ApiCommand,TopLevelCallCommand,UpgradeCommand,InstallCommand,CreateCommand,EditInputSchemaCommand,InfoCommand,WrapScrapyCommand,InitCommand,LoginCommand,LogoutCommand,TopLevelPullCommand,ToplevelPushCommand,RunCommand,ValidateSchemaCommand,HelpCommand],Rr=[ActorSetValueCommand,ActorPushDataCommand,ActorGetValueCommand,ActorGetPublicUrlCommand,ActorGetInputCommand,ActorChargeCommand,ActorCalculateMemoryCommand,ActorGenerateSchemaTypesCommand,HelpCommand,UpgradeCommand,InstallCommand,TelemetryIndexCommand];export{runCLI as i,Lr as n,processVersionCheck as r,Rr as t};
221
- //# sourceMappingURL=_register-BK4fPBqO.js.map
223
+ //# sourceMappingURL=_register-CVxv0CO9.js.map