xoonya 2.5.0 → 2.7.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.
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const {
6
+ exportIntegrationRegistrySnapshot,
7
+ summarizeIntegrationPromotionWorkflow,
8
+ summarizeIntegrationPromotionWorkflowList,
9
+ summarizeIntegrationPromotionReadiness,
10
+ validateIntegrationRegistration
11
+ } = require("../integrations/registry");
12
+
13
+ function readJson(filePath) {
14
+ return JSON.parse(fs.readFileSync(filePath, "utf8"));
15
+ }
16
+
17
+ function writeJson(payload) {
18
+ process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
19
+ }
20
+
21
+ function resolveExampleRegistration(name) {
22
+ const filename = name === "verifier"
23
+ ? "example-third-party-verifier-registration.record.json"
24
+ : "example-third-party-verifier-registration.record.json";
25
+ return path.resolve(__dirname, "..", "integrations", "examples", filename);
26
+ }
27
+
28
+ function resolveExampleDescriptor(name) {
29
+ const descriptorByExample = {
30
+ verifier: {
31
+ integration_id: "partner.verifier.lattice_notary",
32
+ integration_class: "verification_helper_adapter",
33
+ proof_scope: "profile_verification"
34
+ }
35
+ };
36
+ return descriptorByExample[name] || descriptorByExample.verifier;
37
+ }
38
+
39
+ function parseArgs(argv) {
40
+ const [command, ...rest] = argv;
41
+ const options = {};
42
+ for (let index = 0; index < rest.length; index += 1) {
43
+ const token = rest[index];
44
+ if (!token.startsWith("--")) continue;
45
+ const key = token.slice(2);
46
+ const next = rest[index + 1];
47
+ if (!next || next.startsWith("--")) {
48
+ options[key] = true;
49
+ continue;
50
+ }
51
+ options[key] = next;
52
+ index += 1;
53
+ }
54
+ return {
55
+ command: command || "",
56
+ options
57
+ };
58
+ }
59
+
60
+ function runValidateRegistration(options) {
61
+ const exampleName = options.example === "verifier" ? "verifier" : "verifier";
62
+ const filePath = options.file
63
+ ? path.resolve(process.cwd(), options.file)
64
+ : resolveExampleRegistration(exampleName);
65
+ const registrationRecord = readJson(filePath);
66
+ const descriptor = resolveExampleDescriptor(exampleName);
67
+ const validation = validateIntegrationRegistration(descriptor, registrationRecord);
68
+ writeJson({
69
+ ok: validation.ok,
70
+ file: filePath,
71
+ descriptor,
72
+ errors: validation.errors
73
+ });
74
+ process.exitCode = validation.ok ? 0 : 1;
75
+ }
76
+
77
+ function runExportSnapshot(options) {
78
+ const filters = {
79
+ source: options.source || undefined,
80
+ certification_state: options.certification_state || undefined,
81
+ integration_maturity: options.integration_maturity || undefined,
82
+ registration_state: options.registration_state || undefined,
83
+ proof_scope: options.proof_scope || undefined,
84
+ bundled: options.bundled || undefined
85
+ };
86
+ const snapshot = exportIntegrationRegistrySnapshot(filters);
87
+ writeJson({
88
+ generated_by: "registry_cli",
89
+ filters: snapshot.filters,
90
+ snapshot
91
+ });
92
+ }
93
+
94
+ function runPromotionReadiness(options) {
95
+ const integrationId = options.integration || "partner.verifier.lattice_notary";
96
+ writeJson({
97
+ integration_id: integrationId,
98
+ review: summarizeIntegrationPromotionReadiness(integrationId)
99
+ });
100
+ }
101
+
102
+ function runPromotionWorkflow(options) {
103
+ const integrationId = options.integration || "partner.verifier.lattice_notary";
104
+ writeJson({
105
+ integration_id: integrationId,
106
+ review: summarizeIntegrationPromotionWorkflow(integrationId)
107
+ });
108
+ }
109
+
110
+ function runPromotionWorkflowSummary(options) {
111
+ writeJson({
112
+ review: summarizeIntegrationPromotionWorkflowList({
113
+ source: options.source || undefined,
114
+ registration_state: options.registration_state || undefined,
115
+ proof_scope: options.proof_scope || undefined,
116
+ bundled: options.bundled || undefined
117
+ })
118
+ });
119
+ }
120
+
121
+ function main() {
122
+ const { command, options } = parseArgs(process.argv.slice(2));
123
+ if (command === "validate-registration") {
124
+ runValidateRegistration(options);
125
+ return;
126
+ }
127
+ if (command === "export-snapshot") {
128
+ runExportSnapshot(options);
129
+ return;
130
+ }
131
+ if (command === "promotion-readiness") {
132
+ runPromotionReadiness(options);
133
+ return;
134
+ }
135
+ if (command === "promotion-workflow") {
136
+ runPromotionWorkflow(options);
137
+ return;
138
+ }
139
+ if (command === "promotion-workflow-summary") {
140
+ runPromotionWorkflowSummary(options);
141
+ return;
142
+ }
143
+
144
+ writeJson({
145
+ ok: false,
146
+ usage: [
147
+ "node scripts/registry_cli.js validate-registration [--file <path>] [--example verifier]",
148
+ "node scripts/registry_cli.js export-snapshot [--source <value>] [--registration_state <value>] [--proof_scope <value>]",
149
+ "node scripts/registry_cli.js promotion-readiness [--integration <integration_id>]",
150
+ "node scripts/registry_cli.js promotion-workflow [--integration <integration_id>]",
151
+ "node scripts/registry_cli.js promotion-workflow-summary [--source <value>] [--registration_state <value>] [--proof_scope <value>] [--bundled true|false]"
152
+ ]
153
+ });
154
+ process.exitCode = 1;
155
+ }
156
+
157
+ main();