@embrace-ai/infra-api-schema-sync 1.0.6 → 1.0.7
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/CHANGELOG.md +7 -0
- package/dist/src/generate-schema-url.d.ts +1 -0
- package/dist/src/generate-schema-url.d.ts.map +1 -1
- package/dist/src/generate-schema-url.js +10 -0
- package/dist/src/generate-schema-url.js.map +1 -1
- package/dist/src/index.js +10 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/update-local-schema.d.ts +12 -0
- package/dist/src/update-local-schema.d.ts.map +1 -0
- package/dist/src/update-local-schema.js +144 -0
- package/dist/src/update-local-schema.js.map +1 -0
- package/dist/src/update-local-schema.test.d.ts +2 -0
- package/dist/src/update-local-schema.test.d.ts.map +1 -0
- package/dist/src/update-local-schema.test.js +143 -0
- package/dist/src/update-local-schema.test.js.map +1 -0
- package/package.json +1 -1
- package/src/generate-schema-url.js +28 -0
- package/src/index.js +16 -0
- package/src/update-local-schema.js +216 -0
- package/src/update-local-schema.test.js +233 -0
- package/templates/workflows/graphql-schema-validate.yml +145 -67
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.7](https://github.com/Embrace-AI/infra-api-schema-sync/compare/v1.0.6...v1.0.7) (2025-10-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **workflow:** add cli to update repo files, add test to veriify behavior ([#24](https://github.com/Embrace-AI/infra-api-schema-sync/issues/24)) ([27e9e53](https://github.com/Embrace-AI/infra-api-schema-sync/commit/27e9e539b6f79bfc7172ca97cc4725872818d4c0))
|
|
9
|
+
|
|
3
10
|
## [1.0.6](https://github.com/Embrace-AI/infra-api-schema-sync/compare/v1.0.5...v1.0.6) (2025-10-14)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -3,6 +3,7 @@ export function buildSchemaUrl({ stage, service, repo }: {
|
|
|
3
3
|
service: string;
|
|
4
4
|
repo: string;
|
|
5
5
|
}): string;
|
|
6
|
+
export function extractServiceFromUrl(url: string): string | null;
|
|
6
7
|
export function generateSchemaUrl(opts: any): string;
|
|
7
8
|
export default generateSchemaUrl;
|
|
8
9
|
//# sourceMappingURL=generate-schema-url.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-schema-url.d.ts","sourceRoot":"","sources":["../../src/generate-schema-url.js"],"names":[],"mappings":"AAYO,yDALJ;IAAwB,KAAK,EAArB,MAAM;IACU,OAAO,EAAvB,MAAM;IACU,IAAI,EAApB,MAAM;CACd,GAAU,MAAM,CAwBlB;
|
|
1
|
+
{"version":3,"file":"generate-schema-url.d.ts","sourceRoot":"","sources":["../../src/generate-schema-url.js"],"names":[],"mappings":"AAYO,yDALJ;IAAwB,KAAK,EAArB,MAAM;IACU,OAAO,EAAvB,MAAM;IACU,IAAI,EAApB,MAAM;CACd,GAAU,MAAM,CAwBlB;AAuGM,2CANI,MAAM,GACJ,MAAM,GAAC,IAAI,CAuBvB;AAKM,qDA2CN"}
|
|
@@ -65,6 +65,16 @@ const extractServiceName = (repo) => {
|
|
|
65
65
|
}
|
|
66
66
|
return serviceName;
|
|
67
67
|
};
|
|
68
|
+
export const extractServiceFromUrl = (url) => {
|
|
69
|
+
const serviceMatch = url.match(/api\.([^.]+)\.(?:pr-\d+\.)?services\./);
|
|
70
|
+
if (serviceMatch) {
|
|
71
|
+
return serviceMatch[1];
|
|
72
|
+
}
|
|
73
|
+
if (url.includes("/v2/graphql/schema")) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
};
|
|
68
78
|
export const generateSchemaUrl = (opts) => {
|
|
69
79
|
try {
|
|
70
80
|
const { stage, service, repo } = opts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-schema-url.js","sourceRoot":"","sources":["../../src/generate-schema-url.js"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C;QAGD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE1B,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,oCAAoC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC;AAGF,eAAe,iBAAiB,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -43,6 +43,16 @@ program
|
|
|
43
43
|
const { default: generateSchemaUrl } = await import("./generate-schema-url.js");
|
|
44
44
|
return generateSchemaUrl(opts);
|
|
45
45
|
});
|
|
46
|
+
program
|
|
47
|
+
.command("update-local-schema")
|
|
48
|
+
.description("Find and update local schema files based on schema URL")
|
|
49
|
+
.requiredOption("--schema-url <url>", "Schema URL to extract service name from")
|
|
50
|
+
.requiredOption("--schema-file <file>", "Path to the new schema file")
|
|
51
|
+
.requiredOption("--output <file>", "JSON output file with update results")
|
|
52
|
+
.action(async (opts) => {
|
|
53
|
+
const { default: updateLocalSchema } = await import("./update-local-schema.js");
|
|
54
|
+
return updateLocalSchema(opts);
|
|
55
|
+
});
|
|
46
56
|
program
|
|
47
57
|
.command("dispatch-update")
|
|
48
58
|
.description("Dispatch schema update events to organization repositories")
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,+BAA+B,CAAC;KAC5C,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,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ACtC,IAAI,CACL;KACA,MAAM,CAAC,WAAW,EAAE,+CAA+C,EAAE,KAAK,CAAC;KAC3E,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrB,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;IACzE,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function updateLocalSchema({ schemaUrl, schemaFile, output }: {
|
|
2
|
+
schemaUrl: string;
|
|
3
|
+
schemaFile: string;
|
|
4
|
+
output: string;
|
|
5
|
+
}): Promise<{
|
|
6
|
+
serviceName: string;
|
|
7
|
+
updatedFiles: string[];
|
|
8
|
+
hasChanges: boolean;
|
|
9
|
+
message: string;
|
|
10
|
+
}>;
|
|
11
|
+
export default updateLocalSchema;
|
|
12
|
+
//# sourceMappingURL=update-local-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-local-schema.d.ts","sourceRoot":"","sources":["../../src/update-local-schema.js"],"names":[],"mappings":"AA8GO,qEAJJ;IAAwB,SAAS,EAAzB,MAAM;IACU,UAAU,EAA1B,MAAM;IACU,MAAM,EAAtB,MAAM;CAChB;;;;;GAuGA"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import fse from "fs-extra";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { extractServiceFromUrl } from "./generate-schema-url.js";
|
|
6
|
+
const findSchemaFiles = (serviceName, rootDir = process.cwd()) => {
|
|
7
|
+
if (!serviceName) {
|
|
8
|
+
console.log("⚠️ No service name provided, skipping schema file search");
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
console.log(`🔍 Searching for schema files in directories matching: ${serviceName}`);
|
|
12
|
+
try {
|
|
13
|
+
const findCommand = `find . -type d -name "*${serviceName}*" -exec find {} -maxdepth 10 -name "schema.graphql" \\; 2>/dev/null || true`;
|
|
14
|
+
const output = execSync(findCommand, {
|
|
15
|
+
cwd: rootDir,
|
|
16
|
+
encoding: "utf8",
|
|
17
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
18
|
+
});
|
|
19
|
+
const files = output
|
|
20
|
+
.split("\n")
|
|
21
|
+
.map((line) => line.trim())
|
|
22
|
+
.filter((line) => line.length > 0)
|
|
23
|
+
.map((line) => line.replace(/^\.\//, ""))
|
|
24
|
+
.filter((file) => !file.includes("node_modules") &&
|
|
25
|
+
!file.includes("/dist/") &&
|
|
26
|
+
!file.includes("/.git/") &&
|
|
27
|
+
!file.includes("/build/") &&
|
|
28
|
+
!file.includes("/coverage/"));
|
|
29
|
+
const uniqueFiles = [...new Set(files)];
|
|
30
|
+
if (uniqueFiles.length > 0) {
|
|
31
|
+
console.log(`✅ Found ${uniqueFiles.length} schema file(s):`);
|
|
32
|
+
uniqueFiles.forEach((file) => console.log(` - ${file}`));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.log(`ℹ️ No schema files found in directories matching: ${serviceName}`);
|
|
36
|
+
}
|
|
37
|
+
return uniqueFiles;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.warn(`⚠️ Error searching for schema files: ${error.message}`);
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const updateSchemaFile = (filePath, newContent) => {
|
|
45
|
+
try {
|
|
46
|
+
let currentContent = "";
|
|
47
|
+
if (fs.existsSync(filePath)) {
|
|
48
|
+
currentContent = fs.readFileSync(filePath, "utf8");
|
|
49
|
+
}
|
|
50
|
+
if (currentContent.trim() === newContent.trim()) {
|
|
51
|
+
console.log(` ℹ️ No changes needed for: ${filePath}`);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const dir = path.dirname(filePath);
|
|
55
|
+
fse.ensureDirSync(dir);
|
|
56
|
+
fs.writeFileSync(filePath, newContent, "utf8");
|
|
57
|
+
console.log(` ✅ Updated: ${filePath}`);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error(` ❌ Failed to update ${filePath}: ${error.message}`);
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export const updateLocalSchema = async ({ schemaUrl, schemaFile, output }) => {
|
|
66
|
+
try {
|
|
67
|
+
console.log("🔧 Starting local schema update process...");
|
|
68
|
+
console.log(`📡 Schema URL: ${schemaUrl}`);
|
|
69
|
+
console.log(`📄 New schema file: ${schemaFile}`);
|
|
70
|
+
const serviceName = extractServiceFromUrl(schemaUrl);
|
|
71
|
+
if (!serviceName) {
|
|
72
|
+
console.log("ℹ️ This is the main embrace API - no service-specific schema files to update");
|
|
73
|
+
const result = {
|
|
74
|
+
serviceName: "embrace",
|
|
75
|
+
updatedFiles: [],
|
|
76
|
+
hasChanges: false,
|
|
77
|
+
message: "Main embrace API - no service-specific schema files to update",
|
|
78
|
+
};
|
|
79
|
+
if (output) {
|
|
80
|
+
fse.ensureDirSync(path.dirname(output));
|
|
81
|
+
fs.writeFileSync(output, JSON.stringify(result, null, 2), "utf8");
|
|
82
|
+
console.log(`📊 Result written to: ${output}`);
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
console.log(`🎯 Service name: ${serviceName}`);
|
|
87
|
+
if (!fs.existsSync(schemaFile)) {
|
|
88
|
+
throw new Error(`Schema file not found: ${schemaFile}`);
|
|
89
|
+
}
|
|
90
|
+
const newSchemaContent = fs.readFileSync(schemaFile, "utf8");
|
|
91
|
+
const schemaFiles = findSchemaFiles(serviceName);
|
|
92
|
+
if (schemaFiles.length === 0) {
|
|
93
|
+
console.log("⚠️ No schema files found to update");
|
|
94
|
+
const result = {
|
|
95
|
+
serviceName,
|
|
96
|
+
updatedFiles: [],
|
|
97
|
+
hasChanges: false,
|
|
98
|
+
message: `No schema files found in directories matching: ${serviceName}`,
|
|
99
|
+
};
|
|
100
|
+
if (output) {
|
|
101
|
+
fse.ensureDirSync(path.dirname(output));
|
|
102
|
+
fs.writeFileSync(output, JSON.stringify(result, null, 2), "utf8");
|
|
103
|
+
console.log(`📊 Result written to: ${output}`);
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
console.log(`\n📝 Updating schema files...`);
|
|
108
|
+
const updatedFiles = [];
|
|
109
|
+
for (const file of schemaFiles) {
|
|
110
|
+
const wasUpdated = updateSchemaFile(file, newSchemaContent);
|
|
111
|
+
if (wasUpdated) {
|
|
112
|
+
updatedFiles.push(file);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const hasChanges = updatedFiles.length > 0;
|
|
116
|
+
console.log("");
|
|
117
|
+
if (hasChanges) {
|
|
118
|
+
console.log(`✅ Successfully updated ${updatedFiles.length} file(s)`);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
console.log(`ℹ️ All schema files are already up to date`);
|
|
122
|
+
}
|
|
123
|
+
const result = {
|
|
124
|
+
serviceName,
|
|
125
|
+
updatedFiles,
|
|
126
|
+
hasChanges,
|
|
127
|
+
message: hasChanges
|
|
128
|
+
? `Updated ${updatedFiles.length} schema file(s)`
|
|
129
|
+
: "All schema files are already up to date",
|
|
130
|
+
};
|
|
131
|
+
if (output) {
|
|
132
|
+
fse.ensureDirSync(path.dirname(output));
|
|
133
|
+
fs.writeFileSync(output, JSON.stringify(result, null, 2), "utf8");
|
|
134
|
+
console.log(`📊 Result written to: ${output}`);
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
console.error(`❌ Failed to update local schema: ${error.message}`);
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
export default updateLocalSchema;
|
|
144
|
+
//# sourceMappingURL=update-local-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-local-schema.js","sourceRoot":"","sources":["../../src/update-local-schema.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAQjE,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE;IAC/D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;QACzE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,CAAC,GAAG,CACT,0DAA0D,WAAW,EAAE,CACxE,CAAC;IAEF,IAAI,CAAC;QAGH,MAAM,WAAW,GAAG,0BAA0B,WAAW,8EAA8E,CAAC;QAExI,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,EAAE;YACnC,GAAG,EAAE,OAAO;YACZ,QAAQ,EAAE,MAAM;YAChB,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;SAC5B,CAAC,CAAC;QAGH,MAAM,KAAK,GAAG,MAAM;aACjB,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;aAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;aACjC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;aACxC,MAAM,CACL,CAAC,IAAI,EAAE,EAAE,CAEP,CAAC,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iB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-local-schema.test.d.ts","sourceRoot":"","sources":["../../src/update-local-schema.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import fse from "fs-extra";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
5
|
+
import { extractServiceFromUrl } from "./generate-schema-url.js";
|
|
6
|
+
import { updateLocalSchema } from "./update-local-schema.js";
|
|
7
|
+
describe("extractServiceFromUrl", () => {
|
|
8
|
+
it("should extract service name from dev service URL", () => {
|
|
9
|
+
const url = "https://api.integrations-plugins.services.dev.embrace.ai/graphql/schema";
|
|
10
|
+
expect(extractServiceFromUrl(url)).toBe("integrations-plugins");
|
|
11
|
+
});
|
|
12
|
+
it("should extract service name from prod service URL", () => {
|
|
13
|
+
const url = "https://api.integrations-plugins.services.embrace.ai/graphql/schema";
|
|
14
|
+
expect(extractServiceFromUrl(url)).toBe("integrations-plugins");
|
|
15
|
+
});
|
|
16
|
+
it("should extract service name from PR service URL", () => {
|
|
17
|
+
const url = "https://api.integrations-plugins.pr-123.services.dev.embrace.ai/graphql/schema";
|
|
18
|
+
expect(extractServiceFromUrl(url)).toBe("integrations-plugins");
|
|
19
|
+
});
|
|
20
|
+
it("should return null for main embrace API dev URL", () => {
|
|
21
|
+
const url = "https://api.dev.embrace.ai/v2/graphql/schema";
|
|
22
|
+
expect(extractServiceFromUrl(url)).toBe(null);
|
|
23
|
+
});
|
|
24
|
+
it("should return null for main embrace API PR URL", () => {
|
|
25
|
+
const url = "https://api.pr-123.dev.embrace.ai/v2/graphql/schema";
|
|
26
|
+
expect(extractServiceFromUrl(url)).toBe(null);
|
|
27
|
+
});
|
|
28
|
+
it("should handle multi-part service names", () => {
|
|
29
|
+
const url = "https://api.orgs-core.services.dev.embrace.ai/graphql/schema";
|
|
30
|
+
expect(extractServiceFromUrl(url)).toBe("orgs-core");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe("updateLocalSchema", () => {
|
|
34
|
+
const testDir = path.join(process.cwd(), "test-temp-schema-update");
|
|
35
|
+
const schemaContent = `
|
|
36
|
+
type Query {
|
|
37
|
+
hello: String
|
|
38
|
+
}
|
|
39
|
+
`.trim();
|
|
40
|
+
const updatedSchemaContent = `
|
|
41
|
+
type Query {
|
|
42
|
+
hello: String
|
|
43
|
+
world: String
|
|
44
|
+
}
|
|
45
|
+
`.trim();
|
|
46
|
+
beforeEach(() => {
|
|
47
|
+
fse.ensureDirSync(testDir);
|
|
48
|
+
});
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
if (fs.existsSync(testDir)) {
|
|
51
|
+
fse.removeSync(testDir);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
it("should find and update schema files in matching directories", async () => {
|
|
55
|
+
const serviceName = "integrations-plugins";
|
|
56
|
+
const schemaDir = path.join(testDir, "packages/core/src/services", serviceName);
|
|
57
|
+
const schemaFile = path.join(schemaDir, "schema.graphql");
|
|
58
|
+
fse.ensureDirSync(schemaDir);
|
|
59
|
+
fs.writeFileSync(schemaFile, schemaContent, "utf8");
|
|
60
|
+
const newSchemaFile = path.join(testDir, "new-schema.graphql");
|
|
61
|
+
fs.writeFileSync(newSchemaFile, updatedSchemaContent, "utf8");
|
|
62
|
+
const outputFile = path.join(testDir, "result.json");
|
|
63
|
+
const result = await updateLocalSchema({
|
|
64
|
+
schemaUrl: `https://api.${serviceName}.services.dev.embrace.ai/graphql/schema`,
|
|
65
|
+
schemaFile: newSchemaFile,
|
|
66
|
+
output: outputFile,
|
|
67
|
+
});
|
|
68
|
+
expect(result.serviceName).toBe(serviceName);
|
|
69
|
+
expect(result.hasChanges).toBe(true);
|
|
70
|
+
expect(result.updatedFiles.length).toBeGreaterThan(0);
|
|
71
|
+
const updatedContent = fs.readFileSync(schemaFile, "utf8");
|
|
72
|
+
expect(updatedContent.trim()).toBe(updatedSchemaContent);
|
|
73
|
+
expect(fs.existsSync(outputFile)).toBe(true);
|
|
74
|
+
const outputData = JSON.parse(fs.readFileSync(outputFile, "utf8"));
|
|
75
|
+
expect(outputData.hasChanges).toBe(true);
|
|
76
|
+
expect(fs.existsSync(schemaFile)).toBe(true);
|
|
77
|
+
expect(fs.existsSync(newSchemaFile)).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
it("should detect when no changes are needed", async () => {
|
|
80
|
+
const serviceName = "integrations-plugins";
|
|
81
|
+
const schemaDir = path.join(testDir, "packages/core/src/services", serviceName);
|
|
82
|
+
const schemaFile = path.join(schemaDir, "schema.graphql");
|
|
83
|
+
fse.ensureDirSync(schemaDir);
|
|
84
|
+
fs.writeFileSync(schemaFile, schemaContent, "utf8");
|
|
85
|
+
const newSchemaFile = path.join(testDir, "new-schema.graphql");
|
|
86
|
+
fs.writeFileSync(newSchemaFile, schemaContent, "utf8");
|
|
87
|
+
const outputFile = path.join(testDir, "result.json");
|
|
88
|
+
const result = await updateLocalSchema({
|
|
89
|
+
schemaUrl: `https://api.${serviceName}.services.dev.embrace.ai/graphql/schema`,
|
|
90
|
+
schemaFile: newSchemaFile,
|
|
91
|
+
output: outputFile,
|
|
92
|
+
});
|
|
93
|
+
expect(result.serviceName).toBe(serviceName);
|
|
94
|
+
expect(result.hasChanges).toBe(false);
|
|
95
|
+
expect(result.updatedFiles.length).toBe(0);
|
|
96
|
+
expect(fs.existsSync(schemaFile)).toBe(true);
|
|
97
|
+
expect(fs.existsSync(newSchemaFile)).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
it("should handle main embrace API (no service name)", async () => {
|
|
100
|
+
const newSchemaFile = path.join(testDir, "new-schema.graphql");
|
|
101
|
+
fs.writeFileSync(newSchemaFile, schemaContent, "utf8");
|
|
102
|
+
const outputFile = path.join(testDir, "result.json");
|
|
103
|
+
const result = await updateLocalSchema({
|
|
104
|
+
schemaUrl: "https://api.dev.embrace.ai/v2/graphql/schema",
|
|
105
|
+
schemaFile: newSchemaFile,
|
|
106
|
+
output: outputFile,
|
|
107
|
+
});
|
|
108
|
+
expect(result.serviceName).toBe("embrace");
|
|
109
|
+
expect(result.hasChanges).toBe(false);
|
|
110
|
+
expect(result.updatedFiles.length).toBe(0);
|
|
111
|
+
expect(fs.existsSync(newSchemaFile)).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
it("should handle multiple schema files in different directories", async () => {
|
|
114
|
+
const serviceName = "integrations-plugins";
|
|
115
|
+
const schemaDir1 = path.join(testDir, "packages/core/src/services", serviceName);
|
|
116
|
+
const schemaFile1 = path.join(schemaDir1, "schema.graphql");
|
|
117
|
+
const schemaDir2 = path.join(testDir, "apps", serviceName, "graphql");
|
|
118
|
+
const schemaFile2 = path.join(schemaDir2, "schema.graphql");
|
|
119
|
+
fse.ensureDirSync(schemaDir1);
|
|
120
|
+
fse.ensureDirSync(schemaDir2);
|
|
121
|
+
fs.writeFileSync(schemaFile1, schemaContent, "utf8");
|
|
122
|
+
fs.writeFileSync(schemaFile2, schemaContent, "utf8");
|
|
123
|
+
const newSchemaFile = path.join(testDir, "new-schema.graphql");
|
|
124
|
+
fs.writeFileSync(newSchemaFile, updatedSchemaContent, "utf8");
|
|
125
|
+
const outputFile = path.join(testDir, "result.json");
|
|
126
|
+
const result = await updateLocalSchema({
|
|
127
|
+
schemaUrl: `https://api.${serviceName}.services.dev.embrace.ai/graphql/schema`,
|
|
128
|
+
schemaFile: newSchemaFile,
|
|
129
|
+
output: outputFile,
|
|
130
|
+
});
|
|
131
|
+
expect(result.serviceName).toBe(serviceName);
|
|
132
|
+
expect(result.hasChanges).toBe(true);
|
|
133
|
+
expect(result.updatedFiles.length).toBeGreaterThanOrEqual(1);
|
|
134
|
+
const updatedContent1 = fs.readFileSync(schemaFile1, "utf8");
|
|
135
|
+
const updatedContent2 = fs.readFileSync(schemaFile2, "utf8");
|
|
136
|
+
expect(updatedContent1.trim()).toBe(updatedSchemaContent);
|
|
137
|
+
expect(updatedContent2.trim()).toBe(updatedSchemaContent);
|
|
138
|
+
expect(fs.existsSync(schemaFile1)).toBe(true);
|
|
139
|
+
expect(fs.existsSync(schemaFile2)).toBe(true);
|
|
140
|
+
expect(fs.existsSync(newSchemaFile)).toBe(true);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
//# sourceMappingURL=update-local-schema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-local-schema.test.js","sourceRoot":"","sources":["../../src/update-local-schema.test.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,GAAG,GACP,yEAAyE,CAAC;QAC5E,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,GAAG,GACP,qEAAqE,CAAC;QACxE,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,GAAG,GACP,gFAAgF,CAAC;QACnF,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC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,CAAC,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;QAG7D,MAAM,eAAe,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC7D,MAAM,eAAe,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC7D,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC1D,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAG1D,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAG9C,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -127,6 +127,34 @@ const extractServiceName = (repo) => {
|
|
|
127
127
|
return serviceName;
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Extract service name from a schema URL (reverse of building URL)
|
|
132
|
+
* @param {string} url - Schema URL
|
|
133
|
+
* @returns {string|null} Service name or null if it's the main embrace API
|
|
134
|
+
* @example
|
|
135
|
+
* extractServiceFromUrl('https://api.integrations-plugins.services.dev.embrace.ai/graphql/schema')
|
|
136
|
+
* // returns 'integrations-plugins'
|
|
137
|
+
*/
|
|
138
|
+
export const extractServiceFromUrl = (url) => {
|
|
139
|
+
// Match patterns like:
|
|
140
|
+
// https://api.integrations-plugins.services.dev.embrace.ai/graphql/schema
|
|
141
|
+
// https://api.integrations-plugins.services.embrace.ai/graphql/schema
|
|
142
|
+
// https://api.integrations-plugins.pr-123.services.dev.embrace.ai/graphql/schema
|
|
143
|
+
const serviceMatch = url.match(/api\.([^.]+)\.(?:pr-\d+\.)?services\./);
|
|
144
|
+
if (serviceMatch) {
|
|
145
|
+
return serviceMatch[1]; // e.g., "integrations-plugins"
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// If it's the main embrace API, return null
|
|
149
|
+
// https://api.dev.embrace.ai/v2/graphql/schema
|
|
150
|
+
// https://api.pr-123.dev.embrace.ai/v2/graphql/schema
|
|
151
|
+
if (url.includes("/v2/graphql/schema")) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return null;
|
|
156
|
+
};
|
|
157
|
+
|
|
130
158
|
/**
|
|
131
159
|
* CLI command handler
|
|
132
160
|
*/
|
package/src/index.js
CHANGED
|
@@ -58,6 +58,22 @@ program
|
|
|
58
58
|
return generateSchemaUrl(opts);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
+
program
|
|
62
|
+
.command("update-local-schema")
|
|
63
|
+
.description("Find and update local schema files based on schema URL")
|
|
64
|
+
.requiredOption(
|
|
65
|
+
"--schema-url <url>",
|
|
66
|
+
"Schema URL to extract service name from",
|
|
67
|
+
)
|
|
68
|
+
.requiredOption("--schema-file <file>", "Path to the new schema file")
|
|
69
|
+
.requiredOption("--output <file>", "JSON output file with update results")
|
|
70
|
+
.action(async (opts) => {
|
|
71
|
+
const { default: updateLocalSchema } = await import(
|
|
72
|
+
"./update-local-schema.js"
|
|
73
|
+
);
|
|
74
|
+
return updateLocalSchema(opts);
|
|
75
|
+
});
|
|
76
|
+
|
|
61
77
|
program
|
|
62
78
|
.command("dispatch-update")
|
|
63
79
|
.description("Dispatch schema update events to organization repositories")
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import fse from "fs-extra";
|
|
4
|
+
import path from "path";
|
|
5
|
+
|
|
6
|
+
import { extractServiceFromUrl } from "./generate-schema-url.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Find all schema.graphql files in directories matching the service name
|
|
10
|
+
* @param {string} serviceName - Service name to search for
|
|
11
|
+
* @param {string} rootDir - Root directory to search from (default: cwd)
|
|
12
|
+
* @returns {string[]} Array of file paths
|
|
13
|
+
*/
|
|
14
|
+
const findSchemaFiles = (serviceName, rootDir = process.cwd()) => {
|
|
15
|
+
if (!serviceName) {
|
|
16
|
+
console.log("⚠️ No service name provided, skipping schema file search");
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
console.log(
|
|
21
|
+
`🔍 Searching for schema files in directories matching: ${serviceName}`,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
// Use find command to search for schema.graphql files in directories containing the service name
|
|
26
|
+
// This is more efficient than using a glob library for deep directory searches
|
|
27
|
+
const findCommand = `find . -type d -name "*${serviceName}*" -exec find {} -maxdepth 10 -name "schema.graphql" \\; 2>/dev/null || true`;
|
|
28
|
+
|
|
29
|
+
const output = execSync(findCommand, {
|
|
30
|
+
cwd: rootDir,
|
|
31
|
+
encoding: "utf8",
|
|
32
|
+
maxBuffer: 10 * 1024 * 1024, // 10MB buffer
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Parse output and clean up paths
|
|
36
|
+
const files = output
|
|
37
|
+
.split("\n")
|
|
38
|
+
.map((line) => line.trim())
|
|
39
|
+
.filter((line) => line.length > 0)
|
|
40
|
+
.map((line) => line.replace(/^\.\//, "")) // Remove leading ./
|
|
41
|
+
.filter(
|
|
42
|
+
(file) =>
|
|
43
|
+
// Exclude node_modules, dist, and other build directories
|
|
44
|
+
!file.includes("node_modules") &&
|
|
45
|
+
!file.includes("/dist/") &&
|
|
46
|
+
!file.includes("/.git/") &&
|
|
47
|
+
!file.includes("/build/") &&
|
|
48
|
+
!file.includes("/coverage/"),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// Remove duplicates
|
|
52
|
+
const uniqueFiles = [...new Set(files)];
|
|
53
|
+
|
|
54
|
+
if (uniqueFiles.length > 0) {
|
|
55
|
+
console.log(`✅ Found ${uniqueFiles.length} schema file(s):`);
|
|
56
|
+
uniqueFiles.forEach((file) => console.log(` - ${file}`));
|
|
57
|
+
} else {
|
|
58
|
+
console.log(
|
|
59
|
+
`ℹ️ No schema files found in directories matching: ${serviceName}`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return uniqueFiles;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.warn(`⚠️ Error searching for schema files: ${error.message}`);
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Update a schema file with new content
|
|
72
|
+
* @param {string} filePath - Path to the schema file
|
|
73
|
+
* @param {string} newContent - New schema content
|
|
74
|
+
* @returns {boolean} True if file was updated (content changed)
|
|
75
|
+
*/
|
|
76
|
+
const updateSchemaFile = (filePath, newContent) => {
|
|
77
|
+
try {
|
|
78
|
+
// Check if file exists and read current content
|
|
79
|
+
let currentContent = "";
|
|
80
|
+
if (fs.existsSync(filePath)) {
|
|
81
|
+
currentContent = fs.readFileSync(filePath, "utf8");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Compare content (trim to ignore trailing whitespace differences)
|
|
85
|
+
if (currentContent.trim() === newContent.trim()) {
|
|
86
|
+
console.log(` ℹ️ No changes needed for: ${filePath}`);
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Ensure directory exists
|
|
91
|
+
const dir = path.dirname(filePath);
|
|
92
|
+
fse.ensureDirSync(dir);
|
|
93
|
+
|
|
94
|
+
// Write new content
|
|
95
|
+
fs.writeFileSync(filePath, newContent, "utf8");
|
|
96
|
+
console.log(` ✅ Updated: ${filePath}`);
|
|
97
|
+
return true;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error(` ❌ Failed to update ${filePath}: ${error.message}`);
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Update local schema files based on schema URL
|
|
106
|
+
* @param {Object} options - Configuration options
|
|
107
|
+
* @param {string} options.schemaUrl - Schema URL to extract service name from
|
|
108
|
+
* @param {string} options.schemaFile - Path to the new schema file
|
|
109
|
+
* @param {string} options.output - JSON output file path
|
|
110
|
+
*/
|
|
111
|
+
export const updateLocalSchema = async ({ schemaUrl, schemaFile, output }) => {
|
|
112
|
+
try {
|
|
113
|
+
console.log("🔧 Starting local schema update process...");
|
|
114
|
+
console.log(`📡 Schema URL: ${schemaUrl}`);
|
|
115
|
+
console.log(`📄 New schema file: ${schemaFile}`);
|
|
116
|
+
|
|
117
|
+
// Extract service name from URL
|
|
118
|
+
const serviceName = extractServiceFromUrl(schemaUrl);
|
|
119
|
+
|
|
120
|
+
if (!serviceName) {
|
|
121
|
+
console.log(
|
|
122
|
+
"ℹ️ This is the main embrace API - no service-specific schema files to update",
|
|
123
|
+
);
|
|
124
|
+
const result = {
|
|
125
|
+
serviceName: "embrace",
|
|
126
|
+
updatedFiles: [],
|
|
127
|
+
hasChanges: false,
|
|
128
|
+
message:
|
|
129
|
+
"Main embrace API - no service-specific schema files to update",
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// Write result to output file
|
|
133
|
+
if (output) {
|
|
134
|
+
fse.ensureDirSync(path.dirname(output));
|
|
135
|
+
fs.writeFileSync(output, JSON.stringify(result, null, 2), "utf8");
|
|
136
|
+
console.log(`📊 Result written to: ${output}`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
console.log(`🎯 Service name: ${serviceName}`);
|
|
143
|
+
|
|
144
|
+
// Read new schema content
|
|
145
|
+
if (!fs.existsSync(schemaFile)) {
|
|
146
|
+
throw new Error(`Schema file not found: ${schemaFile}`);
|
|
147
|
+
}
|
|
148
|
+
const newSchemaContent = fs.readFileSync(schemaFile, "utf8");
|
|
149
|
+
|
|
150
|
+
// Find schema files to update
|
|
151
|
+
const schemaFiles = findSchemaFiles(serviceName);
|
|
152
|
+
|
|
153
|
+
if (schemaFiles.length === 0) {
|
|
154
|
+
console.log("⚠️ No schema files found to update");
|
|
155
|
+
const result = {
|
|
156
|
+
serviceName,
|
|
157
|
+
updatedFiles: [],
|
|
158
|
+
hasChanges: false,
|
|
159
|
+
message: `No schema files found in directories matching: ${serviceName}`,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// Write result to output file
|
|
163
|
+
if (output) {
|
|
164
|
+
fse.ensureDirSync(path.dirname(output));
|
|
165
|
+
fs.writeFileSync(output, JSON.stringify(result, null, 2), "utf8");
|
|
166
|
+
console.log(`📊 Result written to: ${output}`);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Update each schema file
|
|
173
|
+
console.log(`\n📝 Updating schema files...`);
|
|
174
|
+
const updatedFiles = [];
|
|
175
|
+
for (const file of schemaFiles) {
|
|
176
|
+
const wasUpdated = updateSchemaFile(file, newSchemaContent);
|
|
177
|
+
if (wasUpdated) {
|
|
178
|
+
updatedFiles.push(file);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const hasChanges = updatedFiles.length > 0;
|
|
183
|
+
|
|
184
|
+
console.log("");
|
|
185
|
+
if (hasChanges) {
|
|
186
|
+
console.log(`✅ Successfully updated ${updatedFiles.length} file(s)`);
|
|
187
|
+
} else {
|
|
188
|
+
console.log(`ℹ️ All schema files are already up to date`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Prepare result
|
|
192
|
+
const result = {
|
|
193
|
+
serviceName,
|
|
194
|
+
updatedFiles,
|
|
195
|
+
hasChanges,
|
|
196
|
+
message: hasChanges
|
|
197
|
+
? `Updated ${updatedFiles.length} schema file(s)`
|
|
198
|
+
: "All schema files are already up to date",
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// Write result to output file
|
|
202
|
+
if (output) {
|
|
203
|
+
fse.ensureDirSync(path.dirname(output));
|
|
204
|
+
fs.writeFileSync(output, JSON.stringify(result, null, 2), "utf8");
|
|
205
|
+
console.log(`📊 Result written to: ${output}`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return result;
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.error(`❌ Failed to update local schema: ${error.message}`);
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// Default export for CLI
|
|
216
|
+
export default updateLocalSchema;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import fse from "fs-extra";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
import { extractServiceFromUrl } from "./generate-schema-url.js";
|
|
7
|
+
import { updateLocalSchema } from "./update-local-schema.js";
|
|
8
|
+
|
|
9
|
+
describe("extractServiceFromUrl", () => {
|
|
10
|
+
it("should extract service name from dev service URL", () => {
|
|
11
|
+
const url =
|
|
12
|
+
"https://api.integrations-plugins.services.dev.embrace.ai/graphql/schema";
|
|
13
|
+
expect(extractServiceFromUrl(url)).toBe("integrations-plugins");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should extract service name from prod service URL", () => {
|
|
17
|
+
const url =
|
|
18
|
+
"https://api.integrations-plugins.services.embrace.ai/graphql/schema";
|
|
19
|
+
expect(extractServiceFromUrl(url)).toBe("integrations-plugins");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should extract service name from PR service URL", () => {
|
|
23
|
+
const url =
|
|
24
|
+
"https://api.integrations-plugins.pr-123.services.dev.embrace.ai/graphql/schema";
|
|
25
|
+
expect(extractServiceFromUrl(url)).toBe("integrations-plugins");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should return null for main embrace API dev URL", () => {
|
|
29
|
+
const url = "https://api.dev.embrace.ai/v2/graphql/schema";
|
|
30
|
+
expect(extractServiceFromUrl(url)).toBe(null);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should return null for main embrace API PR URL", () => {
|
|
34
|
+
const url = "https://api.pr-123.dev.embrace.ai/v2/graphql/schema";
|
|
35
|
+
expect(extractServiceFromUrl(url)).toBe(null);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should handle multi-part service names", () => {
|
|
39
|
+
const url = "https://api.orgs-core.services.dev.embrace.ai/graphql/schema";
|
|
40
|
+
expect(extractServiceFromUrl(url)).toBe("orgs-core");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("updateLocalSchema", () => {
|
|
45
|
+
const testDir = path.join(process.cwd(), "test-temp-schema-update");
|
|
46
|
+
const schemaContent = `
|
|
47
|
+
type Query {
|
|
48
|
+
hello: String
|
|
49
|
+
}
|
|
50
|
+
`.trim();
|
|
51
|
+
|
|
52
|
+
const updatedSchemaContent = `
|
|
53
|
+
type Query {
|
|
54
|
+
hello: String
|
|
55
|
+
world: String
|
|
56
|
+
}
|
|
57
|
+
`.trim();
|
|
58
|
+
|
|
59
|
+
beforeEach(() => {
|
|
60
|
+
// Create test directory structure
|
|
61
|
+
fse.ensureDirSync(testDir);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
afterEach(() => {
|
|
65
|
+
// Clean up test directory
|
|
66
|
+
if (fs.existsSync(testDir)) {
|
|
67
|
+
fse.removeSync(testDir);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should find and update schema files in matching directories", async () => {
|
|
72
|
+
// Create test structure
|
|
73
|
+
const serviceName = "integrations-plugins";
|
|
74
|
+
const schemaDir = path.join(
|
|
75
|
+
testDir,
|
|
76
|
+
"packages/core/src/services",
|
|
77
|
+
serviceName,
|
|
78
|
+
);
|
|
79
|
+
const schemaFile = path.join(schemaDir, "schema.graphql");
|
|
80
|
+
|
|
81
|
+
fse.ensureDirSync(schemaDir);
|
|
82
|
+
fs.writeFileSync(schemaFile, schemaContent, "utf8");
|
|
83
|
+
|
|
84
|
+
// Create new schema file
|
|
85
|
+
const newSchemaFile = path.join(testDir, "new-schema.graphql");
|
|
86
|
+
fs.writeFileSync(newSchemaFile, updatedSchemaContent, "utf8");
|
|
87
|
+
|
|
88
|
+
// Create output file path
|
|
89
|
+
const outputFile = path.join(testDir, "result.json");
|
|
90
|
+
|
|
91
|
+
// Run update
|
|
92
|
+
const result = await updateLocalSchema({
|
|
93
|
+
schemaUrl: `https://api.${serviceName}.services.dev.embrace.ai/graphql/schema`,
|
|
94
|
+
schemaFile: newSchemaFile,
|
|
95
|
+
output: outputFile,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Verify result
|
|
99
|
+
expect(result.serviceName).toBe(serviceName);
|
|
100
|
+
expect(result.hasChanges).toBe(true);
|
|
101
|
+
expect(result.updatedFiles.length).toBeGreaterThan(0);
|
|
102
|
+
|
|
103
|
+
// Verify file was updated
|
|
104
|
+
const updatedContent = fs.readFileSync(schemaFile, "utf8");
|
|
105
|
+
expect(updatedContent.trim()).toBe(updatedSchemaContent);
|
|
106
|
+
|
|
107
|
+
// Verify output file was created
|
|
108
|
+
expect(fs.existsSync(outputFile)).toBe(true);
|
|
109
|
+
const outputData = JSON.parse(fs.readFileSync(outputFile, "utf8"));
|
|
110
|
+
expect(outputData.hasChanges).toBe(true);
|
|
111
|
+
|
|
112
|
+
// Verify the original schema file still exists (updated in place)
|
|
113
|
+
expect(fs.existsSync(schemaFile)).toBe(true);
|
|
114
|
+
|
|
115
|
+
// Verify the temporary input file still exists (not deleted by function)
|
|
116
|
+
expect(fs.existsSync(newSchemaFile)).toBe(true);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("should detect when no changes are needed", async () => {
|
|
120
|
+
// Create test structure
|
|
121
|
+
const serviceName = "integrations-plugins";
|
|
122
|
+
const schemaDir = path.join(
|
|
123
|
+
testDir,
|
|
124
|
+
"packages/core/src/services",
|
|
125
|
+
serviceName,
|
|
126
|
+
);
|
|
127
|
+
const schemaFile = path.join(schemaDir, "schema.graphql");
|
|
128
|
+
|
|
129
|
+
fse.ensureDirSync(schemaDir);
|
|
130
|
+
fs.writeFileSync(schemaFile, schemaContent, "utf8");
|
|
131
|
+
|
|
132
|
+
// Create new schema file with same content
|
|
133
|
+
const newSchemaFile = path.join(testDir, "new-schema.graphql");
|
|
134
|
+
fs.writeFileSync(newSchemaFile, schemaContent, "utf8");
|
|
135
|
+
|
|
136
|
+
// Create output file path
|
|
137
|
+
const outputFile = path.join(testDir, "result.json");
|
|
138
|
+
|
|
139
|
+
// Run update
|
|
140
|
+
const result = await updateLocalSchema({
|
|
141
|
+
schemaUrl: `https://api.${serviceName}.services.dev.embrace.ai/graphql/schema`,
|
|
142
|
+
schemaFile: newSchemaFile,
|
|
143
|
+
output: outputFile,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Verify result
|
|
147
|
+
expect(result.serviceName).toBe(serviceName);
|
|
148
|
+
expect(result.hasChanges).toBe(false);
|
|
149
|
+
expect(result.updatedFiles.length).toBe(0);
|
|
150
|
+
|
|
151
|
+
// Verify the original schema file still exists (unchanged)
|
|
152
|
+
expect(fs.existsSync(schemaFile)).toBe(true);
|
|
153
|
+
|
|
154
|
+
// Verify the temporary input file still exists (not deleted by function)
|
|
155
|
+
expect(fs.existsSync(newSchemaFile)).toBe(true);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("should handle main embrace API (no service name)", async () => {
|
|
159
|
+
// Create new schema file
|
|
160
|
+
const newSchemaFile = path.join(testDir, "new-schema.graphql");
|
|
161
|
+
fs.writeFileSync(newSchemaFile, schemaContent, "utf8");
|
|
162
|
+
|
|
163
|
+
// Create output file path
|
|
164
|
+
const outputFile = path.join(testDir, "result.json");
|
|
165
|
+
|
|
166
|
+
// Run update with main API URL
|
|
167
|
+
const result = await updateLocalSchema({
|
|
168
|
+
schemaUrl: "https://api.dev.embrace.ai/v2/graphql/schema",
|
|
169
|
+
schemaFile: newSchemaFile,
|
|
170
|
+
output: outputFile,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Verify result
|
|
174
|
+
expect(result.serviceName).toBe("embrace");
|
|
175
|
+
expect(result.hasChanges).toBe(false);
|
|
176
|
+
expect(result.updatedFiles.length).toBe(0);
|
|
177
|
+
|
|
178
|
+
// Verify the temporary input file still exists (not deleted by function)
|
|
179
|
+
expect(fs.existsSync(newSchemaFile)).toBe(true);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("should handle multiple schema files in different directories", async () => {
|
|
183
|
+
// Create test structure with multiple schema files
|
|
184
|
+
const serviceName = "integrations-plugins";
|
|
185
|
+
|
|
186
|
+
const schemaDir1 = path.join(
|
|
187
|
+
testDir,
|
|
188
|
+
"packages/core/src/services",
|
|
189
|
+
serviceName,
|
|
190
|
+
);
|
|
191
|
+
const schemaFile1 = path.join(schemaDir1, "schema.graphql");
|
|
192
|
+
|
|
193
|
+
const schemaDir2 = path.join(testDir, "apps", serviceName, "graphql");
|
|
194
|
+
const schemaFile2 = path.join(schemaDir2, "schema.graphql");
|
|
195
|
+
|
|
196
|
+
fse.ensureDirSync(schemaDir1);
|
|
197
|
+
fse.ensureDirSync(schemaDir2);
|
|
198
|
+
fs.writeFileSync(schemaFile1, schemaContent, "utf8");
|
|
199
|
+
fs.writeFileSync(schemaFile2, schemaContent, "utf8");
|
|
200
|
+
|
|
201
|
+
// Create new schema file
|
|
202
|
+
const newSchemaFile = path.join(testDir, "new-schema.graphql");
|
|
203
|
+
fs.writeFileSync(newSchemaFile, updatedSchemaContent, "utf8");
|
|
204
|
+
|
|
205
|
+
// Create output file path
|
|
206
|
+
const outputFile = path.join(testDir, "result.json");
|
|
207
|
+
|
|
208
|
+
// Run update
|
|
209
|
+
const result = await updateLocalSchema({
|
|
210
|
+
schemaUrl: `https://api.${serviceName}.services.dev.embrace.ai/graphql/schema`,
|
|
211
|
+
schemaFile: newSchemaFile,
|
|
212
|
+
output: outputFile,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Verify result
|
|
216
|
+
expect(result.serviceName).toBe(serviceName);
|
|
217
|
+
expect(result.hasChanges).toBe(true);
|
|
218
|
+
expect(result.updatedFiles.length).toBeGreaterThanOrEqual(1);
|
|
219
|
+
|
|
220
|
+
// Verify both files were updated
|
|
221
|
+
const updatedContent1 = fs.readFileSync(schemaFile1, "utf8");
|
|
222
|
+
const updatedContent2 = fs.readFileSync(schemaFile2, "utf8");
|
|
223
|
+
expect(updatedContent1.trim()).toBe(updatedSchemaContent);
|
|
224
|
+
expect(updatedContent2.trim()).toBe(updatedSchemaContent);
|
|
225
|
+
|
|
226
|
+
// Verify both original schema files still exist (updated in place)
|
|
227
|
+
expect(fs.existsSync(schemaFile1)).toBe(true);
|
|
228
|
+
expect(fs.existsSync(schemaFile2)).toBe(true);
|
|
229
|
+
|
|
230
|
+
// Verify the temporary input file still exists (not deleted by function)
|
|
231
|
+
expect(fs.existsSync(newSchemaFile)).toBe(true);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# .github/workflows/graphql-schema-validate.yml
|
|
2
1
|
name: Validate GraphQL Schema Updates
|
|
3
2
|
|
|
4
3
|
on:
|
|
@@ -7,24 +6,30 @@ on:
|
|
|
7
6
|
workflow_dispatch:
|
|
8
7
|
inputs:
|
|
9
8
|
schema_url:
|
|
10
|
-
description: "
|
|
11
|
-
required:
|
|
12
|
-
|
|
9
|
+
description: "GraphQL schema URL to validate/update"
|
|
10
|
+
required: true
|
|
11
|
+
type: string
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write
|
|
15
|
+
contents: write
|
|
16
|
+
pull-requests: write
|
|
13
17
|
|
|
14
18
|
jobs:
|
|
15
19
|
validate-schema:
|
|
20
|
+
if: ${{ !startsWith(github.repository, 'Embrace-AI/template-') }}
|
|
16
21
|
runs-on: ubuntu-latest
|
|
17
22
|
|
|
18
23
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
24
|
+
- uses: actions/checkout@v5
|
|
20
25
|
|
|
21
26
|
- name: Setup pnpm
|
|
22
27
|
uses: pnpm/action-setup@v4
|
|
23
28
|
|
|
24
29
|
- name: Setup node cache
|
|
25
|
-
uses: actions/setup-node@
|
|
30
|
+
uses: actions/setup-node@v5
|
|
26
31
|
with:
|
|
27
|
-
node-version: 22.
|
|
32
|
+
node-version: 22.19.0
|
|
28
33
|
cache: "pnpm"
|
|
29
34
|
|
|
30
35
|
- name: Setup NPM
|
|
@@ -33,100 +38,171 @@ jobs:
|
|
|
33
38
|
run: pnpm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}"
|
|
34
39
|
|
|
35
40
|
- name: Install GraphQL schema sync tool
|
|
36
|
-
|
|
37
|
-
run: pnpm install -w @embrace-ai/infra-api-schema-sync@latest
|
|
41
|
+
run: pnpm add -g @embrace-ai/infra-api-schema-sync@latest
|
|
38
42
|
|
|
39
43
|
- name: Configure aws credentials
|
|
40
|
-
uses: aws-actions/configure-aws-credentials@
|
|
44
|
+
uses: aws-actions/configure-aws-credentials@v5.0.0
|
|
41
45
|
with:
|
|
42
46
|
role-to-assume: ${{ secrets.AWS_DEPLOY_ROLE_DEV }}
|
|
43
47
|
aws-region: ${{ vars.AWS_REGION }}
|
|
44
48
|
|
|
45
|
-
- name:
|
|
46
|
-
id: schema-url
|
|
49
|
+
- name: Set schema URL and source repo
|
|
50
|
+
id: set-schema-url
|
|
47
51
|
run: |
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
echo "📡 Using schema URL from dispatch event: $SCHEMA_URL"
|
|
52
|
-
elif [ -n "${{ github.event.inputs.schema_url }}" ]; then
|
|
53
|
-
# Use the schema URL from workflow_dispatch input
|
|
54
|
-
SCHEMA_URL="${{ github.event.inputs.schema_url }}"
|
|
55
|
-
echo "🔧 Using schema URL from workflow input: $SCHEMA_URL"
|
|
56
|
-
else
|
|
57
|
-
echo "❌ Error: No schema URL provided"
|
|
58
|
-
exit 1
|
|
52
|
+
SCHEMA_URL="${{ github.event.client_payload.schemaUrl || github.event.inputs.schema_url || '' }}"
|
|
53
|
+
if [ -z "$SCHEMA_URL" ]; then
|
|
54
|
+
echo "❌ schemaUrl not provided via repository_dispatch payload or workflow input"; exit 1
|
|
59
55
|
fi
|
|
60
|
-
echo "
|
|
56
|
+
echo "schema_url=$SCHEMA_URL" >> "$GITHUB_OUTPUT"
|
|
61
57
|
|
|
62
58
|
- name: Display schema update context
|
|
63
59
|
run: |
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
echo "Timestamp: ${{ github.event.client_payload.timestamp }}"
|
|
70
|
-
else
|
|
71
|
-
echo "Event type: ${{ github.event_name }}"
|
|
72
|
-
echo "Schema URL: ${{ steps.schema-url.outputs.url }}"
|
|
73
|
-
fi
|
|
60
|
+
echo "Schema update received from: ${{ github.event.client_payload.sourceRepo }}"
|
|
61
|
+
echo "Schema URL: ${{ steps.set-schema-url.outputs.schema_url }}"
|
|
62
|
+
echo "Source commit: ${{ github.event.client_payload.commit }}"
|
|
63
|
+
echo "Source branch: ${{ github.event.client_payload.branch }}"
|
|
64
|
+
echo "Timestamp: ${{ github.event.client_payload.timestamp }}"
|
|
74
65
|
|
|
75
66
|
- name: Fetch updated schema
|
|
76
|
-
run:
|
|
67
|
+
run: api-tool fetch --url ${{ steps.set-schema-url.outputs.schema_url }} --output new-schema.graphql
|
|
77
68
|
|
|
69
|
+
- name: Update local schema files
|
|
70
|
+
id: update-schema
|
|
71
|
+
run: |
|
|
72
|
+
echo "🔍 Searching for local schema files to update..."
|
|
73
|
+
api-tool update-local-schema \
|
|
74
|
+
--schema-url "${{ steps.set-schema-url.outputs.schema_url }}" \
|
|
75
|
+
--schema-file new-schema.graphql \
|
|
76
|
+
--output schema-update-result.json
|
|
77
|
+
|
|
78
|
+
# Read the results
|
|
79
|
+
if [ -f schema-update-result.json ]; then
|
|
80
|
+
SERVICE_NAME=$(jq -r '.serviceName // "unknown"' schema-update-result.json)
|
|
81
|
+
UPDATED_COUNT=$(jq -r '.updatedFiles | length' schema-update-result.json)
|
|
82
|
+
HAS_CHANGES=$(jq -r '.hasChanges' schema-update-result.json)
|
|
83
|
+
|
|
84
|
+
echo "service_name=$SERVICE_NAME" >> $GITHUB_OUTPUT
|
|
85
|
+
echo "updated_count=$UPDATED_COUNT" >> $GITHUB_OUTPUT
|
|
86
|
+
echo "has_changes=$HAS_CHANGES" >> $GITHUB_OUTPUT
|
|
87
|
+
|
|
88
|
+
if [ "$HAS_CHANGES" = "true" ]; then
|
|
89
|
+
echo "✅ Updated $UPDATED_COUNT schema file(s) for service: $SERVICE_NAME"
|
|
90
|
+
jq -r '.updatedFiles[]' schema-update-result.json | while read file; do
|
|
91
|
+
echo " - $file"
|
|
92
|
+
done
|
|
93
|
+
else
|
|
94
|
+
echo "ℹ️ No changes detected in schema files"
|
|
95
|
+
fi
|
|
96
|
+
else
|
|
97
|
+
echo "has_changes=false" >> $GITHUB_OUTPUT
|
|
98
|
+
echo "⚠️ No schema files found to update"
|
|
99
|
+
fi
|
|
78
100
|
- name: Validate queries against new schema
|
|
79
101
|
id: validate
|
|
80
|
-
run:
|
|
102
|
+
run: api-tool validate --schema new-schema.graphql --queries 'src/**/*.graphql' --output report.json
|
|
81
103
|
|
|
82
104
|
- name: Check for issues
|
|
83
105
|
id: check-issues
|
|
84
106
|
run: |
|
|
85
|
-
if [ -s report.json ] && [ "$(jq 'length' report.json)" -gt 0 ]; then
|
|
107
|
+
if [ -s report.json ] && [ "$(jq '.issues | length' report.json)" -gt 0 ]; then
|
|
86
108
|
echo "has_issues=true" >> $GITHUB_OUTPUT
|
|
87
|
-
echo "issue_count=$(jq 'length' report.json)" >> $GITHUB_OUTPUT
|
|
109
|
+
echo "issue_count=$(jq '.issues | length' report.json)" >> $GITHUB_OUTPUT
|
|
88
110
|
else
|
|
89
111
|
echo "has_issues=false" >> $GITHUB_OUTPUT
|
|
90
112
|
echo "issue_count=0" >> $GITHUB_OUTPUT
|
|
91
113
|
fi
|
|
92
114
|
|
|
93
|
-
- name: Generate summary
|
|
115
|
+
- name: Generate validation summary
|
|
94
116
|
id: gen-summary
|
|
95
|
-
|
|
96
|
-
|
|
117
|
+
run: |
|
|
118
|
+
# Always generate summary, even if no issues (for consistency)
|
|
119
|
+
if [ ! -f report.json ]; then
|
|
120
|
+
echo "[]" > report.json
|
|
121
|
+
fi
|
|
122
|
+
api-tool summarize --report report.json --output GRAPHQL_ISSUES.md
|
|
123
|
+
|
|
124
|
+
# Also generate a summary of updated files
|
|
125
|
+
if [ -f schema-update-result.json ]; then
|
|
126
|
+
echo "## 📝 Updated Schema Files" > SCHEMA_CHANGES.md
|
|
127
|
+
echo "" >> SCHEMA_CHANGES.md
|
|
128
|
+
jq -r '.updatedFiles[]' schema-update-result.json | while read file; do
|
|
129
|
+
echo "- \`$file\`" >> SCHEMA_CHANGES.md
|
|
130
|
+
done
|
|
131
|
+
echo "" >> SCHEMA_CHANGES.md
|
|
132
|
+
fi
|
|
133
|
+
|
|
134
|
+
# Expose summaries as step outputs for later steps (multiline-safe)
|
|
135
|
+
{
|
|
136
|
+
echo 'issues_summary<<EOF'
|
|
137
|
+
cat GRAPHQL_ISSUES.md
|
|
138
|
+
echo EOF
|
|
139
|
+
} >> $GITHUB_OUTPUT
|
|
140
|
+
|
|
141
|
+
{
|
|
142
|
+
echo 'schema_changes<<EOF'
|
|
143
|
+
if [ -f SCHEMA_CHANGES.md ]; then
|
|
144
|
+
cat SCHEMA_CHANGES.md
|
|
145
|
+
else
|
|
146
|
+
echo "- No files updated"
|
|
147
|
+
fi
|
|
148
|
+
echo EOF
|
|
149
|
+
} >> $GITHUB_OUTPUT
|
|
97
150
|
|
|
98
|
-
- name: Commit and create PR
|
|
151
|
+
- name: Commit and create PR
|
|
152
|
+
if: steps.update-schema.outputs.has_changes == 'true'
|
|
153
|
+
id: create-pr
|
|
99
154
|
uses: peter-evans/create-pull-request@v6
|
|
100
155
|
with:
|
|
101
|
-
commit-message: "chore(api): GraphQL schema update${{ github.event_name == 'repository_dispatch' && format(' from {0}', github.event.client_payload.sourceRepo) || '' }}"
|
|
156
|
+
commit-message: "chore(api): Update GraphQL schema for ${{ steps.update-schema.outputs.service_name }}${{ github.event_name == 'repository_dispatch' && format(' from {0}', github.event.client_payload.sourceRepo) || '' }}"
|
|
102
157
|
branch: "graphql/schema-update-${{ github.run_id }}"
|
|
103
|
-
title: "GraphQL Schema Update (${{ steps.check-issues.outputs.issue_count }} issues)"
|
|
158
|
+
title: "GraphQL Schema Update - ${{ steps.update-schema.outputs.service_name }} (${{ steps.check-issues.outputs.issue_count }} issues)"
|
|
104
159
|
body: |
|
|
105
160
|
# GraphQL Schema Update Impact Report
|
|
106
161
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
**
|
|
162
|
+
## Summary
|
|
163
|
+
|
|
164
|
+
**Service:** `${{ steps.update-schema.outputs.service_name }}`
|
|
165
|
+
**Updated Files:** ${{ steps.update-schema.outputs.updated_count }}
|
|
166
|
+
**Validation Issues:** ${{ steps.check-issues.outputs.issue_count }}
|
|
167
|
+
**Status:** ${{ steps.check-issues.outputs.has_issues == 'true' && '⚠️ Action Required' || '✅ Ready to Merge' }}
|
|
113
168
|
|
|
114
169
|
---
|
|
115
|
-
## ${{ steps.check-issues.outputs.has_issues == 'true' && 'Detected Issues' || '🎉 No Issues Found' }}
|
|
116
|
-
${{ steps.check-issues.outputs.has_issues == 'true' && steps.gen-summary.outputs.summary || 'The updated schema is compatible with your existing GraphQL queries' }}
|
|
117
170
|
|
|
118
|
-
##
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
171
|
+
## Schema Files Updated
|
|
172
|
+
|
|
173
|
+
The following schema files have been updated with the latest schema from the source:
|
|
174
|
+
|
|
175
|
+
${{ steps.gen-summary.outputs.schema_changes }}
|
|
123
176
|
|
|
124
|
-
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## ${{ steps.check-issues.outputs.has_issues == 'true' && '⚠️ Validation Issues Found' || '✅ No Validation Issues' }}
|
|
180
|
+
|
|
181
|
+
${{ steps.check-issues.outputs.has_issues == 'true' && 'The following GraphQL queries are incompatible with the updated schema and need to be fixed:\n\n' || 'All existing GraphQL queries are compatible with the updated schema. No changes to queries are required.\n\n' }}${{ steps.gen-summary.outputs.issues_summary }}
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Source Information
|
|
186
|
+
|
|
187
|
+
${{ github.event_name == 'repository_dispatch' && format('- **Schema Source:** {0}', github.event.client_payload.sourceRepo) || '' }}
|
|
188
|
+
- **Schema URL:** ${{ github.event.client_payload.schemaUrl }}
|
|
189
|
+
${{ github.event_name == 'repository_dispatch' && format('- **Source Commit:** {0}', github.event.client_payload.commit) || '' }}
|
|
190
|
+
${{ github.event_name == 'repository_dispatch' && format('- **Source Branch:** {0}', github.event.client_payload.branch) || '' }}
|
|
191
|
+
${{ github.event_name == 'repository_dispatch' && format('- **Update Time:** {0}', github.event.client_payload.timestamp) || '' }}
|
|
192
|
+
- **Trigger:** ${{ github.event_name }}
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## 🚀 Next Steps
|
|
197
|
+
|
|
198
|
+
${{ steps.check-issues.outputs.has_issues == 'true' && '1. ⚠️ **Review the validation issues above**\n2. 🔧 **Update the affected GraphQL queries** to match the new schema\n3. **Test your changes**\n4. **Push your fixes** to this branch\n5. **Merge this PR** once all issues are resolved' || '1. **Review the schema changes** in the Files Changed tab\n2. **Verify the changes** look correct\n3. **Merge this PR** to update your schema' }}
|
|
199
|
+
|
|
200
|
+
- name: Display validation results
|
|
125
201
|
if: github.event_name == 'workflow_dispatch'
|
|
126
202
|
run: |
|
|
127
|
-
echo "##
|
|
203
|
+
echo "## GraphQL Schema Validation Results" >> $GITHUB_STEP_SUMMARY
|
|
128
204
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
129
|
-
echo "**Schema URL:** ${{ steps.schema-url.outputs.
|
|
205
|
+
echo "**Schema URL:** ${{ steps.set-schema-url.outputs.schema_url }}" >> $GITHUB_STEP_SUMMARY
|
|
130
206
|
echo "**Event:** ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
|
|
131
207
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
132
208
|
|
|
@@ -142,12 +218,14 @@ jobs:
|
|
|
142
218
|
echo "The schema is compatible with all existing GraphQL queries." >> $GITHUB_STEP_SUMMARY
|
|
143
219
|
fi
|
|
144
220
|
|
|
145
|
-
- name:
|
|
146
|
-
if: steps.
|
|
221
|
+
- name: No changes needed
|
|
222
|
+
if: steps.update-schema.outputs.has_changes == 'false'
|
|
147
223
|
run: |
|
|
148
|
-
echo "✅
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
224
|
+
echo "✅ Schema is already up to date - no PR needed"
|
|
225
|
+
echo "### ✅ Schema Already Up To Date" >> $GITHUB_STEP_SUMMARY
|
|
226
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
227
|
+
echo "The fetched schema matches the current schema file(s). No changes or action needed." >> $GITHUB_STEP_SUMMARY
|
|
228
|
+
if [ "${{ steps.check-issues.outputs.has_issues }}" = "false" ]; then
|
|
229
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
230
|
+
echo "All existing queries are compatible with the schema." >> $GITHUB_STEP_SUMMARY
|
|
153
231
|
fi
|