@uniformdev/cli 20.50.2-alpha.109 → 20.50.2-alpha.146

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.
@@ -22,7 +22,7 @@ import { fetch as undiciFetch, ProxyAgent } from "undici";
22
22
  // package.json
23
23
  var package_default = {
24
24
  name: "@uniformdev/cli",
25
- version: "20.66.5",
25
+ version: "20.68.0",
26
26
  description: "Uniform command line interface tool",
27
27
  license: "SEE LICENSE IN LICENSE.txt",
28
28
  main: "./cli.js",
@@ -50,7 +50,6 @@ var package_default = {
50
50
  "@inquirer/prompts": "^7.10.1",
51
51
  "@thi.ng/mime": "^2.2.23",
52
52
  "@uniformdev/assets": "workspace:*",
53
- "@uniformdev/automations-sdk": "workspace:*",
54
53
  "@uniformdev/canvas": "workspace:*",
55
54
  "@uniformdev/context": "workspace:*",
56
55
  "@uniformdev/files": "workspace:*",
@@ -278,16 +277,6 @@ ${e.message}`;
278
277
  }
279
278
  return wrappedFetch;
280
279
  }
281
- function exitOnCliError(error) {
282
- if (error instanceof ApiClientError) {
283
- console.error(error.errorMessage);
284
- } else if (error instanceof Error) {
285
- console.error(error.message);
286
- } else {
287
- console.error(String(error));
288
- }
289
- process.exit(1);
290
- }
291
280
  function withProjectOptions(yargs) {
292
281
  return yargs.option("project", {
293
282
  describe: "Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
@@ -395,16 +384,84 @@ function readFileToObject(filename) {
395
384
  return load(file, { filename, json: true });
396
385
  }
397
386
  async function* paginateAsync(fetchPage, options) {
398
- const perPage = options.pageSize || 100;
387
+ const pageSize = options.pageSize ?? 100;
388
+ if (pageSize < 1) {
389
+ throw new Error(`pageSize must be at least 1, got ${pageSize}`);
390
+ }
399
391
  let offset = 0;
400
392
  let pageData = [];
401
393
  do {
402
- pageData = await fetchPage(offset, perPage);
394
+ if (options.verbose) {
395
+ console.log(`Fetching ${options.entityName ?? "items"} batch: offset=${offset}, pageSize=${pageSize}`);
396
+ }
397
+ pageData = await fetchPage(offset, pageSize);
403
398
  for (const item of pageData) {
404
399
  yield item;
405
400
  }
406
- offset += perPage;
407
- } while (pageData.length === perPage);
401
+ offset += pageSize;
402
+ } while (pageData.length === pageSize);
403
+ }
404
+ var entityBatchSizeDefaults = {
405
+ composition: 100,
406
+ compositionPattern: 100,
407
+ componentPattern: 100,
408
+ entry: 100,
409
+ entryPattern: 100,
410
+ component: 200,
411
+ label: 100,
412
+ asset: 50,
413
+ contentType: 100,
414
+ workflow: 100
415
+ };
416
+ var paginatedEntityTypes = /* @__PURE__ */ new Set([
417
+ "composition",
418
+ "compositionPattern",
419
+ "componentPattern",
420
+ "entry",
421
+ "entryPattern",
422
+ "component",
423
+ "asset",
424
+ "label",
425
+ "contentType",
426
+ "workflow"
427
+ ]);
428
+ function isPaginatedSyncEntity(entityType) {
429
+ return paginatedEntityTypes.has(entityType);
430
+ }
431
+ function getEntityBatchSize(entityType, config) {
432
+ const fromConfig = config.entitiesConfig?.[entityType]?.batchSize;
433
+ if (fromConfig !== void 0) {
434
+ return fromConfig;
435
+ }
436
+ return entityBatchSizeDefaults[entityType];
437
+ }
438
+ function resolveEntityBatchSize({
439
+ entityType,
440
+ cliBatchSize,
441
+ config
442
+ }) {
443
+ if (cliBatchSize !== void 0) {
444
+ return cliBatchSize;
445
+ }
446
+ if (config) {
447
+ return getEntityBatchSize(entityType, config);
448
+ }
449
+ return void 0;
450
+ }
451
+ function withBatchSizeOptions(yargs, entityType) {
452
+ return yargs.option("batchSize", {
453
+ alias: ["b"],
454
+ describe: "Number of items to fetch per API request when reading from Uniform",
455
+ type: "number"
456
+ }).middleware((argv) => {
457
+ const rawSerialization = argv.serialization;
458
+ const config = rawSerialization ? applyDefaultSyncConfiguration({ serialization: rawSerialization }).serialization : void 0;
459
+ argv.resolvedBatchSize = resolveEntityBatchSize({
460
+ entityType,
461
+ cliBatchSize: argv.batchSize,
462
+ config
463
+ });
464
+ });
408
465
  }
409
466
  var defaultSyncConfiguration = {
410
467
  entitiesConfig: {},
@@ -480,7 +537,6 @@ export {
480
537
  withApiOptions,
481
538
  withDebugOptions,
482
539
  nodeFetchProxy,
483
- exitOnCliError,
484
540
  withProjectOptions,
485
541
  withTeamOptions,
486
542
  withFormatOptions,
@@ -489,6 +545,9 @@ export {
489
545
  emitWithFormat,
490
546
  readFileToObject,
491
547
  paginateAsync,
548
+ isPaginatedSyncEntity,
549
+ getEntityBatchSize,
550
+ withBatchSizeOptions,
492
551
  applyDefaultSyncConfiguration,
493
552
  getEntityOption,
494
553
  getDirectoryOrFilename
@@ -1,4 +1,4 @@
1
- import { C as CLIConfiguration, E as EntityTypes } from './index-BurxbjCD.mjs';
1
+ import { C as CLIConfiguration, E as EntityTypes } from './index-DeoTNXj-.mjs';
2
2
 
3
3
  type UniformConfigAllOptions = {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "./chunk-UQFYUBTM.mjs";
1
+ import "./chunk-4FGQETP3.mjs";
2
2
 
3
3
  // src/sync/allSerializableEntitiesConfig.ts
4
4
  var allSerializableEntitiesConfig = {
@@ -15,10 +15,12 @@ type EntityConfiguration = {
15
15
  type EntityWithStateConfiguration = EntityConfiguration & Partial<StateArgs>;
16
16
  type PublishableEntitiesConfiguration = EntityWithStateConfiguration & {
17
17
  publish?: boolean;
18
+ batchSize?: number;
18
19
  };
19
20
  type SerializationEntitiesConfiguration = Record<EntityTypes, {
20
21
  pull?: EntityConfiguration;
21
22
  push?: EntityConfiguration;
23
+ batchSize?: number;
22
24
  } & EntityConfiguration> & {
23
25
  composition?: PublishableEntitiesConfiguration;
24
26
  componentPattern?: PublishableEntitiesConfiguration;
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export { C as CLIConfiguration } from './index-BurxbjCD.mjs';
2
+ export { C as CLIConfiguration } from './index-DeoTNXj-.mjs';