@eide/foir-cli 0.1.39 → 0.1.41

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/cli.js +37 -24
  2. package/package.json +19 -20
package/dist/cli.js CHANGED
@@ -1871,6 +1871,11 @@ export interface FlexibleFieldDef extends BaseFieldDef {
1871
1871
  type: 'flexible';
1872
1872
  }
1873
1873
 
1874
+ /** Field def for inline model types (type is the model's key, e.g. 'seo', 'hero-banner') */
1875
+ export interface InlineModelFieldDef extends BaseFieldDef {
1876
+ type: string;
1877
+ }
1878
+
1874
1879
  export type FieldDef =
1875
1880
  | TextFieldDef
1876
1881
  | NumberFieldDef
@@ -1886,7 +1891,8 @@ export type FieldDef =
1886
1891
  | ReferenceFieldDef
1887
1892
  | ListFieldDef
1888
1893
  | JsonFieldDef
1889
- | FlexibleFieldDef;
1894
+ | FlexibleFieldDef
1895
+ | InlineModelFieldDef;
1890
1896
  `;
1891
1897
  }
1892
1898
 
@@ -5960,7 +5966,13 @@ var COMMANDS = [
5960
5966
  operation: "record",
5961
5967
  operationType: "query",
5962
5968
  positionalArgs: [{ name: "id", graphqlArg: "id" }],
5963
- alternateGet: { operation: "recordByKey", argName: "naturalKey" }
5969
+ alternateGet: { operation: "recordByKey", argName: "naturalKey" },
5970
+ customFlags: [
5971
+ {
5972
+ flag: "--model-key <key>",
5973
+ description: "Model key (required when looking up by natural key)"
5974
+ }
5975
+ ]
5964
5976
  },
5965
5977
  {
5966
5978
  group: "records",
@@ -6010,7 +6022,7 @@ var COMMANDS = [
6010
6022
  successMessage: "Published version",
6011
6023
  customFlags: [
6012
6024
  {
6013
- flag: "--model <key>",
6025
+ flag: "--model-key <key>",
6014
6026
  description: "Model key (use with natural key instead of version ID)"
6015
6027
  }
6016
6028
  ]
@@ -7771,6 +7783,11 @@ function registerDynamicCommands(program2, globalOpts) {
7771
7783
  if (entry.alternateGet && positionals.length > 0 && variables[positionals[0].graphqlArg]) {
7772
7784
  const firstArgValue = String(variables[positionals[0].graphqlArg]);
7773
7785
  if (!isUUID(firstArgValue)) {
7786
+ if (entry.alternateGet.operation === "recordByKey" && !flags.modelKey) {
7787
+ throw new Error(
7788
+ `"${firstArgValue}" is not a UUID. Use --model-key <key> to look up a record by natural key, or pass a record UUID.`
7789
+ );
7790
+ }
7774
7791
  const altEntry = {
7775
7792
  ...entry,
7776
7793
  operation: entry.alternateGet.operation,
@@ -7783,6 +7800,9 @@ function registerDynamicCommands(program2, globalOpts) {
7783
7800
  };
7784
7801
  delete variables[positionals[0].graphqlArg];
7785
7802
  variables[entry.alternateGet.argName] = firstArgValue;
7803
+ if (flags.modelKey) {
7804
+ variables.modelKey = String(flags.modelKey);
7805
+ }
7786
7806
  const queryStr2 = engine.buildQuery(altEntry, variables);
7787
7807
  const result2 = await client.request(
7788
7808
  queryStr2,
@@ -7804,41 +7824,33 @@ function registerDynamicCommands(program2, globalOpts) {
7804
7824
  }
7805
7825
  if (entry.group === "records" && entry.name === "publish" && variables.versionId) {
7806
7826
  const versionIdValue = String(variables.versionId);
7807
- if (flags.model) {
7808
- const lookupQuery = `query RecordByKey($naturalKey: String!) { recordByKey(naturalKey: $naturalKey) { id currentVersion { id } } }`;
7827
+ if (flags.modelKey) {
7828
+ const modelKey = String(flags.modelKey);
7829
+ const lookupQuery = `query RecordByKey($modelKey: String!, $naturalKey: String!) { recordByKey(modelKey: $modelKey, naturalKey: $naturalKey) { id currentVersionId } }`;
7809
7830
  const lookupResult = await client.request(lookupQuery, {
7831
+ modelKey,
7810
7832
  naturalKey: versionIdValue
7811
7833
  });
7812
7834
  const record = lookupResult.recordByKey;
7813
- const currentVersion = record?.currentVersion;
7814
- if (!currentVersion?.id) {
7835
+ if (!record?.currentVersionId) {
7815
7836
  throw new Error(
7816
7837
  `No current version found for record "${versionIdValue}"`
7817
7838
  );
7818
7839
  }
7819
- variables.versionId = currentVersion.id;
7840
+ variables.versionId = record.currentVersionId;
7820
7841
  } else if (!isUUID(versionIdValue)) {
7821
- const lookupQuery = `query RecordByKey($naturalKey: String!) { recordByKey(naturalKey: $naturalKey) { id currentVersion { id } } }`;
7822
- const lookupResult = await client.request(lookupQuery, {
7823
- naturalKey: versionIdValue
7824
- });
7825
- const record = lookupResult.recordByKey;
7826
- const currentVersion = record?.currentVersion;
7827
- if (currentVersion?.id) {
7828
- variables.versionId = currentVersion.id;
7829
- }
7842
+ throw new Error(
7843
+ `"${versionIdValue}" is not a UUID. Use --model-key <key> to resolve a natural key, or pass a version/record UUID directly.`
7844
+ );
7830
7845
  } else {
7831
7846
  try {
7832
- const lookupQuery = `query Record($id: ID!) { record(id: $id) { id recordType currentVersion { id } } }`;
7847
+ const lookupQuery = `query Record($id: ID!) { record(id: $id) { id recordType currentVersionId } }`;
7833
7848
  const lookupResult = await client.request(lookupQuery, {
7834
7849
  id: versionIdValue
7835
7850
  });
7836
7851
  const record = lookupResult.record;
7837
- if (record?.recordType === "record" && record?.currentVersion) {
7838
- const cv = record.currentVersion;
7839
- if (cv.id) {
7840
- variables.versionId = cv.id;
7841
- }
7852
+ if (record?.recordType === "record" && record?.currentVersionId) {
7853
+ variables.versionId = record.currentVersionId;
7842
7854
  }
7843
7855
  } catch {
7844
7856
  }
@@ -7902,7 +7914,8 @@ function registerDynamicCommands(program2, globalOpts) {
7902
7914
  }
7903
7915
  if (flags.publish && entry.group === "records" && entry.name === "create" && responseData) {
7904
7916
  const version2 = responseData.version;
7905
- const versionId = version2?.id;
7917
+ const record = responseData.record;
7918
+ const versionId = version2?.id ?? record?.currentVersionId;
7906
7919
  if (versionId) {
7907
7920
  const publishQuery = `mutation PublishVersion($versionId: ID!) { publishVersion(versionId: $versionId) }`;
7908
7921
  await client.request(publishQuery, { versionId });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eide/foir-cli",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "description": "Universal platform CLI for Foir platform",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -35,21 +35,6 @@
35
35
  "dist",
36
36
  "README.md"
37
37
  ],
38
- "scripts": {
39
- "build": "tsup",
40
- "dev:cli": "tsx src/cli.ts",
41
- "check-types": "tsc --noEmit",
42
- "lint": "eslint src/",
43
- "lint:fix": "eslint src/ --fix",
44
- "test": "vitest run",
45
- "test:watch": "vitest watch",
46
- "codegen": "graphql-codegen --config codegen.ts",
47
- "codegen:watch": "graphql-codegen --config codegen.ts --watch",
48
- "prepublishOnly": "pnpm run build",
49
- "release:patch": "pnpm version patch",
50
- "release:minor": "pnpm version minor",
51
- "release:major": "pnpm version major"
52
- },
53
38
  "keywords": [
54
39
  "foir",
55
40
  "eide",
@@ -73,19 +58,19 @@
73
58
  "prettier": "^3.4.2"
74
59
  },
75
60
  "devDependencies": {
76
- "@foir/platform": "workspace:*",
77
61
  "@graphql-codegen/cli": "^5.0.3",
78
62
  "@graphql-codegen/typed-document-node": "^5.0.12",
79
63
  "@graphql-codegen/typescript": "^4.1.2",
80
64
  "@graphql-codegen/typescript-operations": "^4.4.0",
81
65
  "@graphql-typed-document-node/core": "^3.2.0",
82
66
  "@types/inquirer": "^9.0.7",
83
- "@eide/command-registry": "workspace:*",
84
67
  "@types/node": "^22.5.0",
85
68
  "tsup": "^8.5.1",
86
69
  "tsx": "^4.20.0",
87
70
  "typescript": "5.9.2",
88
- "vitest": "^3.2.4"
71
+ "vitest": "^3.2.4",
72
+ "@eide/command-registry": "0.1.0",
73
+ "@foir/platform": "1.0.0"
89
74
  },
90
75
  "engines": {
91
76
  "node": ">=18.0.0"
@@ -94,5 +79,19 @@
94
79
  "type": "git",
95
80
  "url": "https://github.com/eidebuild/eide.git",
96
81
  "directory": "packages/cli"
82
+ },
83
+ "scripts": {
84
+ "build": "tsup",
85
+ "dev:cli": "tsx src/cli.ts",
86
+ "check-types": "tsc --noEmit",
87
+ "lint": "eslint src/",
88
+ "lint:fix": "eslint src/ --fix",
89
+ "test": "vitest run",
90
+ "test:watch": "vitest watch",
91
+ "codegen": "graphql-codegen --config codegen.ts",
92
+ "codegen:watch": "graphql-codegen --config codegen.ts --watch",
93
+ "release:patch": "pnpm version patch",
94
+ "release:minor": "pnpm version minor",
95
+ "release:major": "pnpm version major"
97
96
  }
98
- }
97
+ }