@uniformdev/cli 20.56.1-alpha.5 → 20.57.1

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 (2) hide show
  1. package/dist/index.mjs +368 -204
  2. package/package.json +10 -10
package/dist/index.mjs CHANGED
@@ -1107,7 +1107,7 @@ import { PostHog } from "posthog-node";
1107
1107
  // package.json
1108
1108
  var package_default = {
1109
1109
  name: "@uniformdev/cli",
1110
- version: "20.56.0",
1110
+ version: "20.57.1",
1111
1111
  description: "Uniform command line interface tool",
1112
1112
  license: "SEE LICENSE IN LICENSE.txt",
1113
1113
  main: "./cli.js",
@@ -1128,7 +1128,7 @@ var package_default = {
1128
1128
  build: "tsc --noEmit && tsup",
1129
1129
  dev: "tsup --watch",
1130
1130
  clean: "rimraf dist",
1131
- test: "jest --maxWorkers=1 --passWithNoTests",
1131
+ test: "vitest run",
1132
1132
  lint: 'eslint "src/**/*.{js,ts,tsx}"',
1133
1133
  format: 'prettier --write "src/**/*.{js,ts,tsx}"'
1134
1134
  },
@@ -3795,7 +3795,156 @@ var ComponentModule = {
3795
3795
  // src/commands/canvas/commands/componentPattern.ts
3796
3796
  import yargs7 from "yargs";
3797
3797
 
3798
+ // src/commands/canvas/util/entityTypeValidation.ts
3799
+ import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE2 } from "@uniformdev/canvas";
3800
+ function getCompositionActualType(composition) {
3801
+ return composition.pattern ? composition.patternType === "component" ? "component-pattern" : "composition-pattern" : "composition";
3802
+ }
3803
+ function getEntryActualType(entry) {
3804
+ return entry.pattern ? "entry-pattern" : "entry";
3805
+ }
3806
+ async function validateCompositionType(client, id, expectedType) {
3807
+ try {
3808
+ const composition = await client.getCompositionById({
3809
+ compositionId: id,
3810
+ skipDataResolution: true,
3811
+ state: CANVAS_DRAFT_STATE2,
3812
+ withPatternType: true
3813
+ });
3814
+ const actualType = getCompositionActualType(composition);
3815
+ return {
3816
+ actualType,
3817
+ isValid: actualType === expectedType,
3818
+ exists: true
3819
+ };
3820
+ } catch (error) {
3821
+ if (error && typeof error === "object" && "statusCode" in error && error.statusCode === 404) {
3822
+ return {
3823
+ actualType: expectedType,
3824
+ isValid: false,
3825
+ exists: false
3826
+ };
3827
+ }
3828
+ throw error;
3829
+ }
3830
+ }
3831
+ async function validateEntryType(client, id, expectedType) {
3832
+ const res = await client.getEntries({
3833
+ offset: 0,
3834
+ limit: 1,
3835
+ entryIDs: [id],
3836
+ skipDataResolution: true,
3837
+ state: CANVAS_DRAFT_STATE2,
3838
+ pattern: expectedType === "entry-pattern" ? true : void 0
3839
+ });
3840
+ if (res.entries.length !== 1) {
3841
+ return {
3842
+ actualType: expectedType,
3843
+ isValid: false,
3844
+ exists: false
3845
+ };
3846
+ }
3847
+ const entry = res.entries[0];
3848
+ const actualType = getEntryActualType(entry);
3849
+ return {
3850
+ actualType,
3851
+ isValid: actualType === expectedType,
3852
+ exists: true
3853
+ };
3854
+ }
3855
+ function getCompositionDisplayNameWithArticle(type) {
3856
+ switch (type) {
3857
+ case "composition":
3858
+ return "a composition";
3859
+ case "composition-pattern":
3860
+ return "a composition pattern";
3861
+ case "component-pattern":
3862
+ return "a component pattern";
3863
+ }
3864
+ }
3865
+ function getEntryDisplayNameWithArticle(type) {
3866
+ return type === "entry" ? "an entry" : "an entry pattern";
3867
+ }
3868
+ function getCompositionDisplayName(type) {
3869
+ switch (type) {
3870
+ case "composition":
3871
+ return "Composition";
3872
+ case "composition-pattern":
3873
+ return "Composition Pattern";
3874
+ case "component-pattern":
3875
+ return "Component Pattern";
3876
+ }
3877
+ }
3878
+ function getEntryDisplayName(type) {
3879
+ return type === "entry" ? "Entry" : "Entry Pattern";
3880
+ }
3881
+ function getCommandVerb(action) {
3882
+ return action === "delete" ? "remove" : action;
3883
+ }
3884
+ function formatCompositionTypeError(id, actualType, expectedType, action) {
3885
+ const actualDisplayName = getCompositionDisplayNameWithArticle(actualType);
3886
+ const expectedDisplayName = getCompositionDisplayNameWithArticle(expectedType);
3887
+ return `Error: The provided ID belongs to ${actualDisplayName}, not ${expectedDisplayName}.
3888
+ To ${action} ${actualDisplayName}, use: uniform canvas ${actualType} ${getCommandVerb(action)} ${id}`;
3889
+ }
3890
+ function formatEntryTypeError(id, actualType, expectedType, action) {
3891
+ const actualDisplayName = getEntryDisplayNameWithArticle(actualType);
3892
+ const expectedDisplayName = getEntryDisplayNameWithArticle(expectedType);
3893
+ return `Error: The provided ID belongs to ${actualDisplayName}, not ${expectedDisplayName}.
3894
+ To ${action} ${actualDisplayName}, use: uniform canvas ${actualType} ${getCommandVerb(action)} ${id}`;
3895
+ }
3896
+
3798
3897
  // src/commands/canvas/commands/composition/get.ts
3898
+ function createCompositionGetHandler(expectedType) {
3899
+ return async ({
3900
+ apiHost,
3901
+ edgeApiHost,
3902
+ apiKey,
3903
+ proxy,
3904
+ id,
3905
+ format,
3906
+ filename,
3907
+ state,
3908
+ project: projectId,
3909
+ resolvePatterns,
3910
+ resolveOverrides,
3911
+ componentIDs,
3912
+ resolveData,
3913
+ diagnostics,
3914
+ resolutionDepth,
3915
+ verbose
3916
+ }) => {
3917
+ const parameters = {
3918
+ compositionId: id,
3919
+ state: convertStateOption(state),
3920
+ skipPatternResolution: !resolvePatterns,
3921
+ skipOverridesResolution: !resolveOverrides,
3922
+ withComponentIDs: componentIDs,
3923
+ skipDataResolution: !resolveData,
3924
+ diagnostics: resolveData ? diagnostics : void 0,
3925
+ resolutionDepth: resolveData ? resolutionDepth : void 0,
3926
+ withPatternType: true
3927
+ };
3928
+ if (verbose) {
3929
+ console.log(`\u{1F41B} get ${expectedType}:`, parameters);
3930
+ }
3931
+ const fetch2 = nodeFetchProxy(proxy, verbose);
3932
+ const client = getCanvasClient({ apiKey, edgeApiHost, apiHost, fetch: fetch2, projectId });
3933
+ const composition = await client.getCompositionById(parameters);
3934
+ const actualType = getCompositionActualType(composition);
3935
+ if (actualType !== expectedType) {
3936
+ console.error(formatCompositionTypeError(id, actualType, expectedType, "get"));
3937
+ process.exit(1);
3938
+ }
3939
+ const {
3940
+ // We fetch pattern type for type validation, but historically we did not include it in the payload so excluding for now
3941
+ patternType,
3942
+ ...rest
3943
+ } = composition;
3944
+ const res = prepCompositionForDisk(rest);
3945
+ emitWithFormat(res, format, filename);
3946
+ };
3947
+ }
3799
3948
  var CompositionGetModule = {
3800
3949
  command: "get <id>",
3801
3950
  describe: "Fetch a composition",
@@ -3807,7 +3956,7 @@ var CompositionGetModule = {
3807
3956
  withDebugOptions(
3808
3957
  yargs43.positional("id", {
3809
3958
  demandOption: true,
3810
- describe: "Composition/pattern public ID to fetch"
3959
+ describe: "Composition public ID to fetch"
3811
3960
  }).option({
3812
3961
  resolvePatterns: {
3813
3962
  type: "boolean",
@@ -3846,48 +3995,14 @@ var CompositionGetModule = {
3846
3995
  )
3847
3996
  )
3848
3997
  ),
3849
- handler: async ({
3850
- apiHost,
3851
- edgeApiHost,
3852
- apiKey,
3853
- proxy,
3854
- id,
3855
- format,
3856
- filename,
3857
- state,
3858
- project: projectId,
3859
- resolvePatterns,
3860
- resolveOverrides,
3861
- componentIDs,
3862
- resolveData,
3863
- diagnostics,
3864
- resolutionDepth,
3865
- verbose
3866
- }) => {
3867
- const parameters = {
3868
- compositionId: id,
3869
- state: convertStateOption(state),
3870
- skipPatternResolution: !resolvePatterns,
3871
- skipOverridesResolution: !resolveOverrides,
3872
- withComponentIDs: componentIDs,
3873
- skipDataResolution: !resolveData,
3874
- diagnostics: resolveData ? diagnostics : void 0,
3875
- resolutionDepth: resolveData ? resolutionDepth : void 0
3876
- };
3877
- if (verbose) {
3878
- console.log(`\u{1F41B} get composition:`, parameters);
3879
- }
3880
- const fetch2 = nodeFetchProxy(proxy, verbose);
3881
- const client = getCanvasClient({ apiKey, edgeApiHost, apiHost, fetch: fetch2, projectId });
3882
- const res = prepCompositionForDisk(await client.getCompositionById(parameters));
3883
- emitWithFormat(res, format, filename);
3884
- }
3998
+ handler: createCompositionGetHandler("composition")
3885
3999
  };
3886
4000
 
3887
4001
  // src/commands/canvas/commands/componentPattern/get.ts
3888
4002
  var ComponentPatternGetModule = {
3889
4003
  ...CompositionGetModule,
3890
- describe: "Fetch a component pattern"
4004
+ describe: "Fetch a component pattern",
4005
+ handler: createCompositionGetHandler("component-pattern")
3891
4006
  };
3892
4007
 
3893
4008
  // src/commands/canvas/commands/composition/list.ts
@@ -4611,6 +4726,37 @@ var ComponentPatternPushModule = {
4611
4726
  };
4612
4727
 
4613
4728
  // src/commands/canvas/commands/composition/remove.ts
4729
+ function createCompositionRemoveHandler(expectedType) {
4730
+ return async ({
4731
+ apiHost,
4732
+ apiKey,
4733
+ proxy,
4734
+ id,
4735
+ project: projectId,
4736
+ verbose,
4737
+ whatIf
4738
+ }) => {
4739
+ if (verbose) {
4740
+ console.log(`\u{1F41B} remove ${expectedType}: (id: ${id})`);
4741
+ }
4742
+ const fetch2 = nodeFetchProxy(proxy, verbose);
4743
+ const client = getCanvasClient({ apiKey, apiHost, fetch: fetch2, projectId });
4744
+ const validation = await validateCompositionType(client, id, expectedType);
4745
+ if (!validation.exists) {
4746
+ console.error(`Error: ${getCompositionDisplayName(expectedType)} with ID "${id}" not found.`);
4747
+ process.exit(1);
4748
+ }
4749
+ if (!validation.isValid) {
4750
+ console.error(formatCompositionTypeError(id, validation.actualType, expectedType, "delete"));
4751
+ process.exit(1);
4752
+ }
4753
+ if (!whatIf) {
4754
+ await client.removeComposition({ compositionId: id });
4755
+ } else {
4756
+ whatIfSimpleLog({ id, displayName: getCompositionDisplayName(expectedType), action: "delete" });
4757
+ }
4758
+ };
4759
+ }
4614
4760
  var CompositionRemoveModule = {
4615
4761
  command: "remove <id>",
4616
4762
  aliases: ["delete", "rm"],
@@ -4621,30 +4767,21 @@ var CompositionRemoveModule = {
4621
4767
  withProjectOptions(
4622
4768
  yargs43.positional("id", {
4623
4769
  demandOption: true,
4624
- describe: "Composition/pattern public ID to delete"
4770
+ describe: "Composition public ID to delete"
4625
4771
  })
4626
4772
  )
4627
4773
  )
4628
4774
  )
4775
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4629
4776
  ),
4630
- handler: async ({ apiHost, apiKey, proxy, id, project: projectId, verbose, whatIf }) => {
4631
- if (verbose) {
4632
- console.log(`\u{1F41B} remove composition: (id: ${id})`);
4633
- }
4634
- const fetch2 = nodeFetchProxy(proxy, verbose);
4635
- const client = getCanvasClient({ apiKey, apiHost, fetch: fetch2, projectId });
4636
- if (!whatIf) {
4637
- await client.removeComposition({ compositionId: id });
4638
- } else {
4639
- whatIfSimpleLog({ id, displayName: `Composition`, action: "delete" });
4640
- }
4641
- }
4777
+ handler: createCompositionRemoveHandler("composition")
4642
4778
  };
4643
4779
 
4644
4780
  // src/commands/canvas/commands/componentPattern/remove.ts
4645
4781
  var ComponentPatternRemoveModule = {
4646
4782
  ...CompositionRemoveModule,
4647
- describe: "Delete a component pattern"
4783
+ describe: "Delete a component pattern",
4784
+ handler: createCompositionRemoveHandler("component-pattern")
4648
4785
  };
4649
4786
 
4650
4787
  // src/commands/canvas/commands/composition/unpublish.ts
@@ -4805,6 +4942,40 @@ var ComponentPatternUnpublishModule = {
4805
4942
  };
4806
4943
 
4807
4944
  // src/commands/canvas/commands/composition/update.ts
4945
+ function createCompositionUpdateHandler(expectedType) {
4946
+ return async ({
4947
+ apiHost,
4948
+ apiKey,
4949
+ proxy,
4950
+ filename,
4951
+ project: projectId,
4952
+ state,
4953
+ verbose,
4954
+ whatIf
4955
+ }) => {
4956
+ if (verbose) {
4957
+ console.log(`\u{1F41B} update ${expectedType}: (filename: ${filename}, state: ${convertStateOption(state)})`);
4958
+ }
4959
+ const fetch2 = nodeFetchProxy(proxy, verbose);
4960
+ const client = getCanvasClient({ apiKey, apiHost, fetch: fetch2, projectId });
4961
+ const file = readFileToObject(filename);
4962
+ const id = file.composition._id;
4963
+ const validation = await validateCompositionType(client, id, expectedType);
4964
+ if (validation.exists && !validation.isValid) {
4965
+ console.error(formatCompositionTypeError(id, validation.actualType, expectedType, "update"));
4966
+ process.exit(1);
4967
+ }
4968
+ if (!whatIf) {
4969
+ await client.updateComposition({ ...file, state: convertStateOption(state) });
4970
+ } else {
4971
+ whatIfSimpleLog({
4972
+ id,
4973
+ displayName: `${getCompositionDisplayName(expectedType)}: ${file.composition._name}`,
4974
+ action: "update"
4975
+ });
4976
+ }
4977
+ };
4978
+ }
4808
4979
  var CompositionUpdateModule = {
4809
4980
  command: "update <filename>",
4810
4981
  aliases: ["put"],
@@ -4823,29 +4994,14 @@ var CompositionUpdateModule = {
4823
4994
  )
4824
4995
  )
4825
4996
  ),
4826
- handler: async ({ apiHost, apiKey, proxy, filename, project: projectId, state, verbose, whatIf }) => {
4827
- if (verbose) {
4828
- console.log(`\u{1F41B} update composition: (filename: ${filename}, state: ${convertStateOption(state)})`);
4829
- }
4830
- const fetch2 = nodeFetchProxy(proxy, verbose);
4831
- const client = getCanvasClient({ apiKey, apiHost, fetch: fetch2, projectId });
4832
- const file = readFileToObject(filename);
4833
- if (!whatIf) {
4834
- await client.updateComposition({ ...file, state: convertStateOption(state) });
4835
- } else {
4836
- whatIfSimpleLog({
4837
- id: file.composition._id,
4838
- displayName: `Composition: ${file.composition._name}`,
4839
- action: "update"
4840
- });
4841
- }
4842
- }
4997
+ handler: createCompositionUpdateHandler("composition")
4843
4998
  };
4844
4999
 
4845
5000
  // src/commands/canvas/commands/componentPattern/update.ts
4846
5001
  var ComponentPatternUpdateModule = {
4847
5002
  ...CompositionUpdateModule,
4848
- describe: "Insert or update a component pattern"
5003
+ describe: "Insert or update a component pattern",
5004
+ handler: createCompositionUpdateHandler("component-pattern")
4849
5005
  };
4850
5006
 
4851
5007
  // src/commands/canvas/commands/componentPattern.ts
@@ -4876,7 +5032,8 @@ import yargs9 from "yargs";
4876
5032
  // src/commands/canvas/commands/compositionPattern/get.ts
4877
5033
  var CompositionPatternGetModule = {
4878
5034
  ...CompositionGetModule,
4879
- describe: "Fetch a composition pattern"
5035
+ describe: "Fetch a composition pattern",
5036
+ handler: createCompositionGetHandler("composition-pattern")
4880
5037
  };
4881
5038
 
4882
5039
  // src/commands/canvas/commands/compositionPattern/list.ts
@@ -5059,7 +5216,8 @@ var CompositionPatternPushModule = {
5059
5216
  // src/commands/canvas/commands/compositionPattern/remove.ts
5060
5217
  var CompositionPatternRemoveModule = {
5061
5218
  ...CompositionRemoveModule,
5062
- describe: "Delete a composition pattern"
5219
+ describe: "Delete a composition pattern",
5220
+ handler: createCompositionRemoveHandler("composition-pattern")
5063
5221
  };
5064
5222
 
5065
5223
  // src/commands/canvas/commands/compositionPattern/unpublish.ts
@@ -5099,7 +5257,8 @@ var CompositionPatternUnpublishModule = {
5099
5257
  // src/commands/canvas/commands/compositionPattern/update.ts
5100
5258
  var CompositionPatternUpdateModule = {
5101
5259
  ...CompositionUpdateModule,
5102
- describe: "Insert or update a composition pattern"
5260
+ describe: "Insert or update a composition pattern",
5261
+ handler: createCompositionUpdateHandler("composition-pattern")
5103
5262
  };
5104
5263
 
5105
5264
  // src/commands/canvas/commands/compositionPattern.ts
@@ -5831,6 +5990,54 @@ var DataTypeModule = {
5831
5990
  import yargs13 from "yargs";
5832
5991
 
5833
5992
  // src/commands/canvas/commands/entry/get.ts
5993
+ function createEntryGetHandler(expectedType) {
5994
+ return async ({
5995
+ apiHost,
5996
+ edgeApiHost,
5997
+ apiKey,
5998
+ proxy,
5999
+ id,
6000
+ format,
6001
+ filename,
6002
+ project: projectId,
6003
+ state,
6004
+ resolveData,
6005
+ diagnostics,
6006
+ resolutionDepth,
6007
+ withComponentIDs,
6008
+ verbose
6009
+ }) => {
6010
+ if (verbose) {
6011
+ console.log(`\u{1F41B} get ${expectedType}: (id: ${id})`);
6012
+ }
6013
+ const fetch2 = nodeFetchProxy(proxy, verbose);
6014
+ const client = getContentClient({ apiKey, apiHost, edgeApiHost, fetch: fetch2, projectId });
6015
+ const res = await client.getEntries({
6016
+ offset: 0,
6017
+ limit: 1,
6018
+ entryIDs: [id],
6019
+ state: convertStateOption(state),
6020
+ skipOverridesResolution: true,
6021
+ skipPatternResolution: true,
6022
+ skipDataResolution: !resolveData,
6023
+ diagnostics: resolveData ? diagnostics : void 0,
6024
+ resolutionDepth: resolveData ? resolutionDepth : void 0,
6025
+ withComponentIDs,
6026
+ pattern: expectedType === "entry-pattern" ? true : void 0
6027
+ });
6028
+ if (res.entries.length !== 1) {
6029
+ console.error(`Error: ${getEntryDisplayName(expectedType)} with ID "${id}" not found.`);
6030
+ process.exit(1);
6031
+ }
6032
+ const entry = res.entries[0];
6033
+ const actualType = getEntryActualType(entry);
6034
+ if (actualType !== expectedType) {
6035
+ console.error(formatEntryTypeError(id, actualType, expectedType, "get"));
6036
+ process.exit(1);
6037
+ }
6038
+ emitWithFormat(entry, format, filename);
6039
+ };
6040
+ }
5834
6041
  var EntryGetModule = {
5835
6042
  command: "get <id>",
5836
6043
  describe: "Get an entry",
@@ -5870,41 +6077,7 @@ var EntryGetModule = {
5870
6077
  )
5871
6078
  )
5872
6079
  ),
5873
- handler: async ({
5874
- apiHost,
5875
- edgeApiHost,
5876
- apiKey,
5877
- proxy,
5878
- id,
5879
- format,
5880
- filename,
5881
- project: projectId,
5882
- state,
5883
- resolveData,
5884
- diagnostics,
5885
- resolutionDepth,
5886
- withComponentIDs,
5887
- verbose
5888
- }) => {
5889
- const fetch2 = nodeFetchProxy(proxy, verbose);
5890
- const client = getContentClient({ apiKey, apiHost, edgeApiHost, fetch: fetch2, projectId });
5891
- const res = await client.getEntries({
5892
- offset: 0,
5893
- limit: 1,
5894
- entryIDs: [id],
5895
- state: convertStateOption(state),
5896
- skipOverridesResolution: true,
5897
- skipPatternResolution: true,
5898
- skipDataResolution: !resolveData,
5899
- diagnostics: resolveData ? diagnostics : void 0,
5900
- resolutionDepth: resolveData ? resolutionDepth : void 0,
5901
- withComponentIDs
5902
- });
5903
- if (res.entries.length !== 1) {
5904
- throw new Error(`Entry with ID ${id} not found`);
5905
- }
5906
- emitWithFormat(res.entries[0], format, filename);
5907
- }
6080
+ handler: createEntryGetHandler("entry")
5908
6081
  };
5909
6082
 
5910
6083
  // src/commands/canvas/commands/entry/list.ts
@@ -6340,6 +6513,37 @@ var EntryPushModule = {
6340
6513
  };
6341
6514
 
6342
6515
  // src/commands/canvas/commands/entry/remove.ts
6516
+ function createEntryRemoveHandler(expectedType) {
6517
+ return async ({
6518
+ apiHost,
6519
+ apiKey,
6520
+ proxy,
6521
+ id,
6522
+ project: projectId,
6523
+ verbose,
6524
+ whatIf
6525
+ }) => {
6526
+ if (verbose) {
6527
+ console.log(`\u{1F41B} remove ${expectedType}: (id: ${id})`);
6528
+ }
6529
+ const fetch2 = nodeFetchProxy(proxy, verbose);
6530
+ const client = getContentClient({ apiKey, apiHost, fetch: fetch2, projectId });
6531
+ const validation = await validateEntryType(client, id, expectedType);
6532
+ if (!validation.exists) {
6533
+ console.error(`Error: ${getEntryDisplayName(expectedType)} with ID "${id}" not found.`);
6534
+ process.exit(1);
6535
+ }
6536
+ if (!validation.isValid) {
6537
+ console.error(formatEntryTypeError(id, validation.actualType, expectedType, "delete"));
6538
+ process.exit(1);
6539
+ }
6540
+ if (!whatIf) {
6541
+ await client.deleteEntry({ entryId: id });
6542
+ } else {
6543
+ whatIfSimpleLog({ id, displayName: getEntryDisplayName(expectedType), action: "delete" });
6544
+ }
6545
+ };
6546
+ }
6343
6547
  var EntryRemoveModule = {
6344
6548
  command: "remove <id>",
6345
6549
  aliases: ["delete", "rm"],
@@ -6353,15 +6557,7 @@ var EntryRemoveModule = {
6353
6557
  )
6354
6558
  )
6355
6559
  ),
6356
- handler: async ({ apiHost, apiKey, proxy, id, project: projectId, verbose, whatIf }) => {
6357
- const fetch2 = nodeFetchProxy(proxy, verbose);
6358
- const client = getContentClient({ apiKey, apiHost, fetch: fetch2, projectId });
6359
- if (!whatIf) {
6360
- await client.deleteEntry({ entryId: id });
6361
- } else {
6362
- whatIfSimpleLog({ id, displayName: `Entry`, action: "delete" });
6363
- }
6364
- }
6560
+ handler: createEntryRemoveHandler("entry")
6365
6561
  };
6366
6562
 
6367
6563
  // src/commands/canvas/commands/entry/unpublish.ts
@@ -6455,22 +6651,8 @@ var EntryUnpublishModule = {
6455
6651
  };
6456
6652
 
6457
6653
  // src/commands/canvas/commands/entry/update.ts
6458
- var EntryUpdateModule = {
6459
- command: "update <filename>",
6460
- aliases: ["put"],
6461
- describe: "Insert or update an entry",
6462
- builder: (yargs43) => withConfiguration(
6463
- withDebugOptions(
6464
- withApiOptions(
6465
- withProjectOptions(
6466
- withStateOptions(
6467
- yargs43.positional("filename", { demandOption: true, describe: "Entry file to put" })
6468
- )
6469
- )
6470
- )
6471
- )
6472
- ),
6473
- handler: async ({
6654
+ function createEntryUpdateHandler(expectedType) {
6655
+ return async ({
6474
6656
  apiHost,
6475
6657
  edgeApiHost,
6476
6658
  apiKey,
@@ -6481,15 +6663,45 @@ var EntryUpdateModule = {
6481
6663
  verbose,
6482
6664
  whatIf
6483
6665
  }) => {
6666
+ if (verbose) {
6667
+ console.log(`\u{1F41B} update ${expectedType}: (filename: ${filename}, state: ${convertStateOption(state)})`);
6668
+ }
6484
6669
  const fetch2 = nodeFetchProxy(proxy, verbose);
6485
6670
  const client = getContentClient({ apiKey, apiHost, edgeApiHost, fetch: fetch2, projectId });
6486
6671
  const file = readFileToObject(filename);
6672
+ const id = file.entry._id;
6673
+ const validation = await validateEntryType(client, id, expectedType);
6674
+ if (validation.exists && !validation.isValid) {
6675
+ console.error(formatEntryTypeError(id, validation.actualType, expectedType, "update"));
6676
+ process.exit(1);
6677
+ }
6487
6678
  if (!whatIf) {
6488
6679
  await client.upsertEntry({ ...file, state: convertStateOption(state) });
6489
6680
  } else {
6490
- whatIfSimpleLog({ id: file.entry._id, displayName: `Entry: ${file.entry._name}`, action: "update" });
6681
+ whatIfSimpleLog({
6682
+ id,
6683
+ displayName: `${getEntryDisplayName(expectedType)}: ${file.entry._name}`,
6684
+ action: "update"
6685
+ });
6491
6686
  }
6492
- }
6687
+ };
6688
+ }
6689
+ var EntryUpdateModule = {
6690
+ command: "update <filename>",
6691
+ aliases: ["put"],
6692
+ describe: "Insert or update an entry",
6693
+ builder: (yargs43) => withConfiguration(
6694
+ withDebugOptions(
6695
+ withApiOptions(
6696
+ withProjectOptions(
6697
+ withStateOptions(
6698
+ yargs43.positional("filename", { demandOption: true, describe: "Entry file to put" })
6699
+ )
6700
+ )
6701
+ )
6702
+ )
6703
+ ),
6704
+ handler: createEntryUpdateHandler("entry")
6493
6705
  };
6494
6706
 
6495
6707
  // src/commands/canvas/commands/entry.ts
@@ -6515,10 +6727,22 @@ var EntryPatternGetModule = {
6515
6727
  withApiOptions(
6516
6728
  withProjectOptions(
6517
6729
  withStateOptions(
6518
- yargs43.positional("id", {
6519
- demandOption: true,
6520
- describe: "Entry pattern public ID to fetch"
6521
- }).option({
6730
+ yargs43.positional("id", { demandOption: true, describe: "Entry pattern public ID to fetch" }).option({
6731
+ resolveData: {
6732
+ type: "boolean",
6733
+ default: false,
6734
+ describe: "Resolve all data resources used by the entry pattern"
6735
+ },
6736
+ diagnostics: {
6737
+ type: "boolean",
6738
+ default: false,
6739
+ describe: "Include diagnostics information when resolving data"
6740
+ },
6741
+ resolutionDepth: {
6742
+ type: "number",
6743
+ default: 1,
6744
+ describe: "Controls how many levels deep content references should be resolved"
6745
+ },
6522
6746
  withComponentIDs: {
6523
6747
  type: "boolean",
6524
6748
  default: false,
@@ -6532,36 +6756,7 @@ var EntryPatternGetModule = {
6532
6756
  )
6533
6757
  )
6534
6758
  ),
6535
- handler: async ({
6536
- apiHost,
6537
- apiKey,
6538
- proxy,
6539
- id,
6540
- format,
6541
- filename,
6542
- project: projectId,
6543
- state,
6544
- withComponentIDs,
6545
- verbose
6546
- }) => {
6547
- const fetch2 = nodeFetchProxy(proxy, verbose);
6548
- const client = getContentClient({ apiKey, apiHost, fetch: fetch2, projectId });
6549
- const res = await client.getEntries({
6550
- offset: 0,
6551
- limit: 1,
6552
- entryIDs: [id],
6553
- state: convertStateOption(state),
6554
- skipOverridesResolution: true,
6555
- skipPatternResolution: true,
6556
- skipDataResolution: true,
6557
- pattern: true,
6558
- withComponentIDs
6559
- });
6560
- if (res.entries.length !== 1) {
6561
- throw new Error(`Entry pattern with ID ${id} not found`);
6562
- }
6563
- emitWithFormat(res.entries[0], format, filename);
6564
- }
6759
+ handler: createEntryGetHandler("entry-pattern")
6565
6760
  };
6566
6761
 
6567
6762
  // src/commands/canvas/commands/entryPattern/list.ts
@@ -6925,15 +7120,7 @@ var EntryPatternRemoveModule = {
6925
7120
  )
6926
7121
  )
6927
7122
  ),
6928
- handler: async ({ apiHost, apiKey, proxy, id, project: projectId, verbose, whatIf }) => {
6929
- const fetch2 = nodeFetchProxy(proxy, verbose);
6930
- const client = getContentClient({ apiKey, apiHost, fetch: fetch2, projectId });
6931
- if (!whatIf) {
6932
- await client.deleteEntry({ entryId: id });
6933
- } else {
6934
- whatIfSimpleLog({ id, displayName: `Entry Pattern`, action: "delete" });
6935
- }
6936
- }
7123
+ handler: createEntryRemoveHandler("entry-pattern")
6937
7124
  };
6938
7125
 
6939
7126
  // src/commands/canvas/commands/entryPattern/unpublish.ts
@@ -7042,30 +7229,7 @@ var EntryPatternUpdateModule = {
7042
7229
  )
7043
7230
  )
7044
7231
  ),
7045
- handler: async ({
7046
- apiHost,
7047
- edgeApiHost,
7048
- apiKey,
7049
- proxy,
7050
- filename,
7051
- project: projectId,
7052
- state,
7053
- verbose,
7054
- whatIf
7055
- }) => {
7056
- const fetch2 = nodeFetchProxy(proxy, verbose);
7057
- const client = getContentClient({ apiKey, apiHost, edgeApiHost, fetch: fetch2, projectId });
7058
- const file = readFileToObject(filename);
7059
- if (!whatIf) {
7060
- await client.upsertEntry({ ...file, state: convertStateOption(state) });
7061
- } else {
7062
- whatIfSimpleLog({
7063
- id: file.entry._id,
7064
- displayName: `Entry Pattern: ${file.entry._name}`,
7065
- action: "update"
7066
- });
7067
- }
7068
- }
7232
+ handler: createEntryUpdateHandler("entry-pattern")
7069
7233
  };
7070
7234
 
7071
7235
  // src/commands/canvas/commands/entryPattern.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "20.56.1-alpha.5+1bce2eca70",
3
+ "version": "20.57.1",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -21,20 +21,20 @@
21
21
  "build": "tsc --noEmit && tsup",
22
22
  "dev": "tsup --watch",
23
23
  "clean": "rimraf dist",
24
- "test": "jest --maxWorkers=1 --passWithNoTests",
24
+ "test": "vitest run",
25
25
  "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
26
26
  "format": "prettier --write \"src/**/*.{js,ts,tsx}\""
27
27
  },
28
28
  "dependencies": {
29
29
  "@inquirer/prompts": "^7.10.1",
30
30
  "@thi.ng/mime": "^2.2.23",
31
- "@uniformdev/assets": "20.56.1-alpha.5+1bce2eca70",
32
- "@uniformdev/canvas": "20.56.1-alpha.5+1bce2eca70",
33
- "@uniformdev/context": "20.56.1-alpha.5+1bce2eca70",
34
- "@uniformdev/files": "20.56.1-alpha.5+1bce2eca70",
35
- "@uniformdev/project-map": "20.56.1-alpha.5+1bce2eca70",
36
- "@uniformdev/redirect": "20.56.1-alpha.5+1bce2eca70",
37
- "@uniformdev/richtext": "20.56.1-alpha.5+1bce2eca70",
31
+ "@uniformdev/assets": "20.57.1",
32
+ "@uniformdev/canvas": "20.57.1",
33
+ "@uniformdev/context": "20.57.1",
34
+ "@uniformdev/files": "20.57.1",
35
+ "@uniformdev/project-map": "20.57.1",
36
+ "@uniformdev/redirect": "20.57.1",
37
+ "@uniformdev/richtext": "20.57.1",
38
38
  "call-bind": "^1.0.2",
39
39
  "colorette": "2.0.20",
40
40
  "cosmiconfig": "9.0.0",
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "1bce2eca70191de304d93909e5cf08740b01fb5a"
84
+ "gitHead": "1e3550de803a5532c1facf22ce6513001c847650"
85
85
  }