@uniformdev/cli 20.66.0 → 20.66.1-alpha.4
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.
|
@@ -384,16 +384,82 @@ function readFileToObject(filename) {
|
|
|
384
384
|
return load(file, { filename, json: true });
|
|
385
385
|
}
|
|
386
386
|
async function* paginateAsync(fetchPage, options) {
|
|
387
|
-
const
|
|
387
|
+
const pageSize = options.pageSize ?? 100;
|
|
388
|
+
if (pageSize < 1) {
|
|
389
|
+
throw new Error(`pageSize must be at least 1, got ${pageSize}`);
|
|
390
|
+
}
|
|
388
391
|
let offset = 0;
|
|
389
392
|
let pageData = [];
|
|
390
393
|
do {
|
|
391
|
-
|
|
394
|
+
if (options.verbose) {
|
|
395
|
+
console.log(`Fetching ${options.entityName ?? "items"} batch: offset=${offset}, pageSize=${pageSize}`);
|
|
396
|
+
}
|
|
397
|
+
pageData = await fetchPage(offset, pageSize);
|
|
392
398
|
for (const item of pageData) {
|
|
393
399
|
yield item;
|
|
394
400
|
}
|
|
395
|
-
offset +=
|
|
396
|
-
} while (pageData.length ===
|
|
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
|
+
argv.resolvedBatchSize = resolveEntityBatchSize({
|
|
458
|
+
entityType,
|
|
459
|
+
cliBatchSize: argv.batchSize,
|
|
460
|
+
config: argv.serialization
|
|
461
|
+
});
|
|
462
|
+
});
|
|
397
463
|
}
|
|
398
464
|
var defaultSyncConfiguration = {
|
|
399
465
|
entitiesConfig: {},
|
|
@@ -477,6 +543,9 @@ export {
|
|
|
477
543
|
emitWithFormat,
|
|
478
544
|
readFileToObject,
|
|
479
545
|
paginateAsync,
|
|
546
|
+
isPaginatedSyncEntity,
|
|
547
|
+
getEntityBatchSize,
|
|
548
|
+
withBatchSizeOptions,
|
|
480
549
|
applyDefaultSyncConfiguration,
|
|
481
550
|
getEntityOption,
|
|
482
551
|
getDirectoryOrFilename
|
package/dist/defaultConfig.d.mts
CHANGED
package/dist/defaultConfig.mjs
CHANGED
|
@@ -11,6 +11,7 @@ type EntityConfiguration = {
|
|
|
11
11
|
directory?: string;
|
|
12
12
|
format?: SyncFileFormat;
|
|
13
13
|
disabled?: true;
|
|
14
|
+
batchSize?: number;
|
|
14
15
|
};
|
|
15
16
|
type EntityWithStateConfiguration = EntityConfiguration & Partial<StateArgs>;
|
|
16
17
|
type PublishableEntitiesConfiguration = EntityWithStateConfiguration & {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export { C as CLIConfiguration } from './index-
|
|
2
|
+
export { C as CLIConfiguration } from './index-xrMm6Bjs.mjs';
|