@odigos/vmagent-api-apollo-client 0.9.0 → 0.10.0
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/generated/dialects.d.ts +11 -0
- package/dist/generated/dialects.js +21 -0
- package/dist/generated/surface.d.ts +5 -0
- package/dist/generated/surface.js +12 -0
- package/dist/generated/v0_10_0/graphql.d.ts +3140 -0
- package/dist/generated/v0_10_0/graphql.js +87 -0
- package/dist/generated/v0_6_0/graphql.d.ts +2802 -0
- package/dist/generated/v0_6_0/graphql.js +81 -0
- package/dist/generated/v0_8_0/graphql.d.ts +2923 -0
- package/dist/generated/v0_8_0/graphql.js +81 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -1
- package/dist/registry.d.ts +6 -0
- package/dist/registry.js +46 -0
- package/package.json +12 -2
- /package/dist/generated/{graphql.d.ts → next/graphql.d.ts} +0 -0
- /package/dist/generated/{graphql.js → next/graphql.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
// Public entrypoint. The version-specific surface (flat latest-dialect exports +
|
|
2
|
+
// per-dialect namespaces) is GENERATED into ./generated/surface by
|
|
3
|
+
// scripts/gen-dialect-manifest.mjs, so this file is static and never needs
|
|
4
|
+
// editing when a snapshot is added.
|
|
5
|
+
//
|
|
6
|
+
// - Flat imports (e.g. `import { GetWorkloadReportsV2Document } from
|
|
7
|
+
// '@odigos/vmagent-api-apollo-client'`) resolve to the latest dialect.
|
|
8
|
+
// - Per-dialect namespaces (`v0_6_0`, `v0_8_0`, `next`, ...) target a specific
|
|
9
|
+
// dialect explicitly.
|
|
10
|
+
export * from "./generated/surface";
|
|
11
|
+
// Dialect registry: the `dialects` map, `resolveDialect`, version constants,
|
|
12
|
+
// and types for picking a dialect per connected VM-agent version.
|
|
13
|
+
export * from "./registry";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { dialects, NEXT_DIALECT, LATEST_DIALECT_VERSION } from "./generated/dialects";
|
|
2
|
+
export { dialects, NEXT_DIALECT, LATEST_DIALECT_VERSION };
|
|
3
|
+
export type DialectVersion = keyof typeof dialects;
|
|
4
|
+
export type Dialect = (typeof dialects)[DialectVersion];
|
|
5
|
+
export declare function resolveDialectVersion(reported: string): DialectVersion;
|
|
6
|
+
export declare function resolveDialect(reported: string): Dialect;
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Dialect registry: resolves which frozen dialect a consumer should use for a
|
|
2
|
+
// connected agent. The package ships every dialect (see codegen.ts); central-ui
|
|
3
|
+
// passes the VM proxy's reported version to resolveDialect() and prints the
|
|
4
|
+
// matching document, so it never selects fields the agent's schema lacks.
|
|
5
|
+
//
|
|
6
|
+
// The `dialects` map and version constants are GENERATED into
|
|
7
|
+
// ./generated/dialects (by scripts/gen-dialect-manifest.mjs, run as part of
|
|
8
|
+
// `npm run codegen`) directly from the graphql/snapshots directory. This file
|
|
9
|
+
// is hand-written and holds only the resolution logic -- it never needs editing
|
|
10
|
+
// when a new snapshot is added.
|
|
11
|
+
import { dialects, NEXT_DIALECT, LATEST_DIALECT_VERSION, } from "./generated/dialects";
|
|
12
|
+
export { dialects, NEXT_DIALECT, LATEST_DIALECT_VERSION };
|
|
13
|
+
function parseVersion(version) {
|
|
14
|
+
const core = version.trim().replace(/^v/i, "").split("-")[0];
|
|
15
|
+
const [major = 0, minor = 0, patch = 0] = core
|
|
16
|
+
.split(".")
|
|
17
|
+
.map((part) => parseInt(part, 10) || 0);
|
|
18
|
+
return [major, minor, patch];
|
|
19
|
+
}
|
|
20
|
+
function compareVersions(a, b) {
|
|
21
|
+
const pa = parseVersion(a);
|
|
22
|
+
const pb = parseVersion(b);
|
|
23
|
+
for (let i = 0; i < 3; i += 1) {
|
|
24
|
+
if (pa[i] !== pb[i])
|
|
25
|
+
return pa[i] - pb[i];
|
|
26
|
+
}
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
const SORTED_VERSIONS = Object.keys(dialects).sort(compareVersions);
|
|
30
|
+
// Resolution: exact match if a snapshot equals the reported version; otherwise
|
|
31
|
+
// the greatest snapshot <= reported (floor). Flooring is the safe choice -- the
|
|
32
|
+
// schema only grows, so an older-or-equal dialect never selects fields the
|
|
33
|
+
// agent is missing. A reported version newer than every snapshot floors to the
|
|
34
|
+
// latest. A reported version older than every snapshot falls back to the
|
|
35
|
+
// lowest known dialect (best effort; nothing safer is available).
|
|
36
|
+
export function resolveDialectVersion(reported) {
|
|
37
|
+
let floor;
|
|
38
|
+
for (const version of SORTED_VERSIONS) {
|
|
39
|
+
if (compareVersions(version, reported) <= 0)
|
|
40
|
+
floor = version;
|
|
41
|
+
}
|
|
42
|
+
return floor ?? SORTED_VERSIONS[0];
|
|
43
|
+
}
|
|
44
|
+
export function resolveDialect(reported) {
|
|
45
|
+
return dialects[resolveDialectVersion(reported)];
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odigos/vmagent-api-apollo-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Generated Apollo TypeScript client for the VM-agent GraphQL API",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,13 +14,23 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
16
|
"require": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./registry": {
|
|
19
|
+
"types": "./dist/registry.d.ts",
|
|
20
|
+
"import": "./dist/registry.js",
|
|
21
|
+
"require": "./dist/registry.js"
|
|
22
|
+
},
|
|
23
|
+
"./next": {
|
|
24
|
+
"types": "./dist/generated/next/graphql.d.ts",
|
|
25
|
+
"import": "./dist/generated/next/graphql.js",
|
|
26
|
+
"require": "./dist/generated/next/graphql.js"
|
|
17
27
|
}
|
|
18
28
|
},
|
|
19
29
|
"publishConfig": {
|
|
20
30
|
"access": "public"
|
|
21
31
|
},
|
|
22
32
|
"scripts": {
|
|
23
|
-
"codegen": "graphql-codegen --config codegen.ts",
|
|
33
|
+
"codegen": "graphql-codegen --config codegen.ts && node scripts/gen-dialect-manifest.mjs",
|
|
24
34
|
"build": "tsc -p tsconfig.json"
|
|
25
35
|
},
|
|
26
36
|
"dependencies": {
|
|
File without changes
|
|
File without changes
|