@eide/foir-cli 0.1.39 → 0.1.40
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/dist/cli.js +30 -23
- package/package.json +19 -20
package/dist/cli.js
CHANGED
|
@@ -5960,7 +5960,13 @@ var COMMANDS = [
|
|
|
5960
5960
|
operation: "record",
|
|
5961
5961
|
operationType: "query",
|
|
5962
5962
|
positionalArgs: [{ name: "id", graphqlArg: "id" }],
|
|
5963
|
-
alternateGet: { operation: "recordByKey", argName: "naturalKey" }
|
|
5963
|
+
alternateGet: { operation: "recordByKey", argName: "naturalKey" },
|
|
5964
|
+
customFlags: [
|
|
5965
|
+
{
|
|
5966
|
+
flag: "--model-key <key>",
|
|
5967
|
+
description: "Model key (required when looking up by natural key)"
|
|
5968
|
+
}
|
|
5969
|
+
]
|
|
5964
5970
|
},
|
|
5965
5971
|
{
|
|
5966
5972
|
group: "records",
|
|
@@ -6010,7 +6016,7 @@ var COMMANDS = [
|
|
|
6010
6016
|
successMessage: "Published version",
|
|
6011
6017
|
customFlags: [
|
|
6012
6018
|
{
|
|
6013
|
-
flag: "--model <key>",
|
|
6019
|
+
flag: "--model-key <key>",
|
|
6014
6020
|
description: "Model key (use with natural key instead of version ID)"
|
|
6015
6021
|
}
|
|
6016
6022
|
]
|
|
@@ -7771,6 +7777,11 @@ function registerDynamicCommands(program2, globalOpts) {
|
|
|
7771
7777
|
if (entry.alternateGet && positionals.length > 0 && variables[positionals[0].graphqlArg]) {
|
|
7772
7778
|
const firstArgValue = String(variables[positionals[0].graphqlArg]);
|
|
7773
7779
|
if (!isUUID(firstArgValue)) {
|
|
7780
|
+
if (entry.alternateGet.operation === "recordByKey" && !flags.modelKey) {
|
|
7781
|
+
throw new Error(
|
|
7782
|
+
`"${firstArgValue}" is not a UUID. Use --model-key <key> to look up a record by natural key, or pass a record UUID.`
|
|
7783
|
+
);
|
|
7784
|
+
}
|
|
7774
7785
|
const altEntry = {
|
|
7775
7786
|
...entry,
|
|
7776
7787
|
operation: entry.alternateGet.operation,
|
|
@@ -7783,6 +7794,9 @@ function registerDynamicCommands(program2, globalOpts) {
|
|
|
7783
7794
|
};
|
|
7784
7795
|
delete variables[positionals[0].graphqlArg];
|
|
7785
7796
|
variables[entry.alternateGet.argName] = firstArgValue;
|
|
7797
|
+
if (flags.modelKey) {
|
|
7798
|
+
variables.modelKey = String(flags.modelKey);
|
|
7799
|
+
}
|
|
7786
7800
|
const queryStr2 = engine.buildQuery(altEntry, variables);
|
|
7787
7801
|
const result2 = await client.request(
|
|
7788
7802
|
queryStr2,
|
|
@@ -7804,41 +7818,33 @@ function registerDynamicCommands(program2, globalOpts) {
|
|
|
7804
7818
|
}
|
|
7805
7819
|
if (entry.group === "records" && entry.name === "publish" && variables.versionId) {
|
|
7806
7820
|
const versionIdValue = String(variables.versionId);
|
|
7807
|
-
if (flags.
|
|
7808
|
-
const
|
|
7821
|
+
if (flags.modelKey) {
|
|
7822
|
+
const modelKey = String(flags.modelKey);
|
|
7823
|
+
const lookupQuery = `query RecordByKey($modelKey: String!, $naturalKey: String!) { recordByKey(modelKey: $modelKey, naturalKey: $naturalKey) { id currentVersionId } }`;
|
|
7809
7824
|
const lookupResult = await client.request(lookupQuery, {
|
|
7825
|
+
modelKey,
|
|
7810
7826
|
naturalKey: versionIdValue
|
|
7811
7827
|
});
|
|
7812
7828
|
const record = lookupResult.recordByKey;
|
|
7813
|
-
|
|
7814
|
-
if (!currentVersion?.id) {
|
|
7829
|
+
if (!record?.currentVersionId) {
|
|
7815
7830
|
throw new Error(
|
|
7816
7831
|
`No current version found for record "${versionIdValue}"`
|
|
7817
7832
|
);
|
|
7818
7833
|
}
|
|
7819
|
-
variables.versionId =
|
|
7834
|
+
variables.versionId = record.currentVersionId;
|
|
7820
7835
|
} else if (!isUUID(versionIdValue)) {
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
});
|
|
7825
|
-
const record = lookupResult.recordByKey;
|
|
7826
|
-
const currentVersion = record?.currentVersion;
|
|
7827
|
-
if (currentVersion?.id) {
|
|
7828
|
-
variables.versionId = currentVersion.id;
|
|
7829
|
-
}
|
|
7836
|
+
throw new Error(
|
|
7837
|
+
`"${versionIdValue}" is not a UUID. Use --model-key <key> to resolve a natural key, or pass a version/record UUID directly.`
|
|
7838
|
+
);
|
|
7830
7839
|
} else {
|
|
7831
7840
|
try {
|
|
7832
|
-
const lookupQuery = `query Record($id: ID!) { record(id: $id) { id recordType
|
|
7841
|
+
const lookupQuery = `query Record($id: ID!) { record(id: $id) { id recordType currentVersionId } }`;
|
|
7833
7842
|
const lookupResult = await client.request(lookupQuery, {
|
|
7834
7843
|
id: versionIdValue
|
|
7835
7844
|
});
|
|
7836
7845
|
const record = lookupResult.record;
|
|
7837
|
-
if (record?.recordType === "record" && record?.
|
|
7838
|
-
|
|
7839
|
-
if (cv.id) {
|
|
7840
|
-
variables.versionId = cv.id;
|
|
7841
|
-
}
|
|
7846
|
+
if (record?.recordType === "record" && record?.currentVersionId) {
|
|
7847
|
+
variables.versionId = record.currentVersionId;
|
|
7842
7848
|
}
|
|
7843
7849
|
} catch {
|
|
7844
7850
|
}
|
|
@@ -7902,7 +7908,8 @@ function registerDynamicCommands(program2, globalOpts) {
|
|
|
7902
7908
|
}
|
|
7903
7909
|
if (flags.publish && entry.group === "records" && entry.name === "create" && responseData) {
|
|
7904
7910
|
const version2 = responseData.version;
|
|
7905
|
-
const
|
|
7911
|
+
const record = responseData.record;
|
|
7912
|
+
const versionId = version2?.id ?? record?.currentVersionId;
|
|
7906
7913
|
if (versionId) {
|
|
7907
7914
|
const publishQuery = `mutation PublishVersion($versionId: ID!) { publishVersion(versionId: $versionId) }`;
|
|
7908
7915
|
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.
|
|
3
|
+
"version": "0.1.40",
|
|
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
|
+
}
|