@varde-flyt/vfac 0.3.1 → 0.3.2
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/vfac.mjs +72 -48
- package/package.json +1 -1
package/dist/vfac.mjs
CHANGED
|
@@ -12673,6 +12673,58 @@ function matches(pattern, value) {
|
|
|
12673
12673
|
}
|
|
12674
12674
|
}
|
|
12675
12675
|
|
|
12676
|
+
// ../product-configuration/dist/resource-api-version.js
|
|
12677
|
+
var RESOURCE_API_VERSION = "resources.vardeflyt.no/v1";
|
|
12678
|
+
var PRODUCT_INSTANCE_KIND = "ProductInstance";
|
|
12679
|
+
|
|
12680
|
+
// ../product-configuration/dist/product-instance-example.js
|
|
12681
|
+
function isSecret(declaration) {
|
|
12682
|
+
return declaration.writeOnly === true || declaration["x-secret"] === true;
|
|
12683
|
+
}
|
|
12684
|
+
function seedConfiguration(configuration) {
|
|
12685
|
+
const properties = configuration?.properties ?? {};
|
|
12686
|
+
const required = new Set(configuration?.required ?? []);
|
|
12687
|
+
const values = {};
|
|
12688
|
+
const open = [];
|
|
12689
|
+
const requiredSecrets = [];
|
|
12690
|
+
for (const [name, declaration] of Object.entries(properties)) {
|
|
12691
|
+
if (isSecret(declaration)) {
|
|
12692
|
+
if (required.has(name))
|
|
12693
|
+
requiredSecrets.push(name);
|
|
12694
|
+
continue;
|
|
12695
|
+
}
|
|
12696
|
+
if (declaration.default !== void 0) {
|
|
12697
|
+
values[name] = declaration.default;
|
|
12698
|
+
continue;
|
|
12699
|
+
}
|
|
12700
|
+
if (required.has(name)) {
|
|
12701
|
+
values[name] = "";
|
|
12702
|
+
open.push({ name, type: declaration.type ?? null });
|
|
12703
|
+
}
|
|
12704
|
+
}
|
|
12705
|
+
return { values, open, requiredSecrets };
|
|
12706
|
+
}
|
|
12707
|
+
function productInstanceExample(input) {
|
|
12708
|
+
return {
|
|
12709
|
+
apiVersion: RESOURCE_API_VERSION,
|
|
12710
|
+
kind: PRODUCT_INSTANCE_KIND,
|
|
12711
|
+
// The key is spread rather than set, so an underivable one is ABSENT from
|
|
12712
|
+
// the document instead of present and empty.
|
|
12713
|
+
metadata: { name: input.name, ...input.key ? { key: input.key } : {} },
|
|
12714
|
+
spec: {
|
|
12715
|
+
productId: input.productId,
|
|
12716
|
+
productVersion: input.productVersion,
|
|
12717
|
+
region: input.region,
|
|
12718
|
+
profile: input.profile,
|
|
12719
|
+
configuration: input.configuration
|
|
12720
|
+
}
|
|
12721
|
+
};
|
|
12722
|
+
}
|
|
12723
|
+
function exampleResourceKey(name) {
|
|
12724
|
+
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^[^a-z]+/, "").replace(/-+$/, "").slice(0, 63);
|
|
12725
|
+
return /^[a-z][a-z0-9-]{1,61}[a-z0-9]$/.test(slug) ? slug : "";
|
|
12726
|
+
}
|
|
12727
|
+
|
|
12676
12728
|
// ../platform-schemas/dist/index.js
|
|
12677
12729
|
var TENANT_KEY_REGEX = /^[a-z][a-z0-9-]{2,23}[a-z0-9]$/;
|
|
12678
12730
|
var RESERVED_TENANT_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -12763,10 +12815,8 @@ var OperationStatusSchema = external_exports.enum([
|
|
|
12763
12815
|
|
|
12764
12816
|
// ../product-contracts/dist/api-version.js
|
|
12765
12817
|
var PRODUCT_API_VERSION = "products.vardeflyt.no/v1";
|
|
12766
|
-
var RESOURCE_API_VERSION = "resources.vardeflyt.no/v1";
|
|
12767
12818
|
var PRODUCT_DEFINITION_KIND = "ProductDefinition";
|
|
12768
12819
|
var DEPLOYMENT_BLUEPRINT_KIND = "DeploymentBlueprint";
|
|
12769
|
-
var PRODUCT_INSTANCE_KIND = "ProductInstance";
|
|
12770
12820
|
var ProductApiVersionSchema = external_exports.literal(PRODUCT_API_VERSION, {
|
|
12771
12821
|
errorMap: () => ({
|
|
12772
12822
|
message: `apiVersion must be "${PRODUCT_API_VERSION}". An unrecognized contract format is refused rather than ignored.`
|
|
@@ -16170,13 +16220,13 @@ async function runGet(parsed) {
|
|
|
16170
16220
|
const declared = Array.isArray(resource["outputDeclarations"]) ? resource["outputDeclarations"] : [];
|
|
16171
16221
|
const declaredNames = declared.map((entry) => entry["key"]).filter((key2) => typeof key2 === "string");
|
|
16172
16222
|
const names = [.../* @__PURE__ */ new Set([...Object.keys(outputs), ...declaredNames])].sort();
|
|
16173
|
-
const
|
|
16223
|
+
const isSecret2 = (name) => declared.find((entry) => entry["key"] === name)?.["secret"] === true;
|
|
16174
16224
|
if (names.length > 0) {
|
|
16175
16225
|
lines.push("", " Outputs");
|
|
16176
16226
|
const width = Math.max(...names.map((name) => name.length));
|
|
16177
16227
|
for (const name of names) {
|
|
16178
16228
|
lines.push(
|
|
16179
|
-
` ${name.padEnd(width)} ${
|
|
16229
|
+
` ${name.padEnd(width)} ${isSecret2(name) ? "[secret]" : String(outputs[name] ?? "")}`
|
|
16180
16230
|
);
|
|
16181
16231
|
const meaning = declared.find((entry) => entry["key"] === name);
|
|
16182
16232
|
const description = meaning?.["description"];
|
|
@@ -16597,7 +16647,7 @@ async function runManifestInit(parsed) {
|
|
|
16597
16647
|
if (!result.ok) return printError(result.error, parsed.flags["output"] === "json");
|
|
16598
16648
|
const product = result.data;
|
|
16599
16649
|
const notes = [];
|
|
16600
|
-
const key = parsed.flags["key"] ??
|
|
16650
|
+
const key = parsed.flags["key"] ?? exampleResourceKey(name);
|
|
16601
16651
|
if (!key) {
|
|
16602
16652
|
notes.push(
|
|
16603
16653
|
"metadata.key \u2014 a stable identity, 3 to 63 characters, lower case. Required before apply"
|
|
@@ -16663,43 +16713,24 @@ Product Deployment as Code v1 cannot express yet. Deploy it from the portal.
|
|
|
16663
16713
|
offered.length === 0 ? `${product.productId} ${product.version} declares no service profile. Ask the publisher.` : `This Product offers several service profiles. Pass --profile <${offered.join("|")}>.`
|
|
16664
16714
|
);
|
|
16665
16715
|
}
|
|
16666
|
-
const
|
|
16667
|
-
const
|
|
16668
|
-
|
|
16669
|
-
for (const [property, declaration] of Object.entries(properties)) {
|
|
16670
|
-
const secret = declaration.writeOnly === true || declaration["x-secret"] === true;
|
|
16671
|
-
if (secret) {
|
|
16672
|
-
if (required.includes(property)) {
|
|
16673
|
-
notes.push(`--secret ${property}=env:VAR \u2014 required, and never written to this file`);
|
|
16674
|
-
}
|
|
16675
|
-
continue;
|
|
16676
|
-
}
|
|
16677
|
-
if (declaration.default !== void 0) {
|
|
16678
|
-
configuration[property] = declaration.default;
|
|
16679
|
-
continue;
|
|
16680
|
-
}
|
|
16681
|
-
if (required.includes(property)) {
|
|
16682
|
-
configuration[property] = "";
|
|
16683
|
-
notes.push(`spec.configuration.${property} \u2014 required${typeOf(declaration)}`);
|
|
16684
|
-
}
|
|
16716
|
+
const seed = seedConfiguration(product.configuration);
|
|
16717
|
+
for (const property of seed.requiredSecrets) {
|
|
16718
|
+
notes.push(`--secret ${property}=env:VAR \u2014 required, and never written to this file`);
|
|
16685
16719
|
}
|
|
16686
|
-
const
|
|
16687
|
-
|
|
16688
|
-
|
|
16689
|
-
|
|
16690
|
-
|
|
16691
|
-
|
|
16692
|
-
|
|
16693
|
-
|
|
16694
|
-
|
|
16695
|
-
|
|
16696
|
-
|
|
16697
|
-
|
|
16698
|
-
|
|
16699
|
-
|
|
16700
|
-
configuration
|
|
16701
|
-
}
|
|
16702
|
-
};
|
|
16720
|
+
for (const setting of seed.open) {
|
|
16721
|
+
notes.push(
|
|
16722
|
+
`spec.configuration.${setting.name} \u2014 required${setting.type ? ` (${setting.type})` : ""}`
|
|
16723
|
+
);
|
|
16724
|
+
}
|
|
16725
|
+
const document = productInstanceExample({
|
|
16726
|
+
name,
|
|
16727
|
+
...key ? { key } : {},
|
|
16728
|
+
productId: product.productId,
|
|
16729
|
+
productVersion: product.version,
|
|
16730
|
+
region,
|
|
16731
|
+
profile,
|
|
16732
|
+
configuration: seed.values
|
|
16733
|
+
});
|
|
16703
16734
|
const checked = ProductInstanceTemplateSchema.safeParse(document);
|
|
16704
16735
|
if (!checked.success) {
|
|
16705
16736
|
const where = checked.error.issues.map((issue) => ` ${issue.path.join(".") || "(document)"}: ${issue.message}`).join("\n");
|
|
@@ -16723,13 +16754,6 @@ function refuse(message) {
|
|
|
16723
16754
|
`);
|
|
16724
16755
|
return 1;
|
|
16725
16756
|
}
|
|
16726
|
-
function typeOf(declaration) {
|
|
16727
|
-
return declaration.type ? ` (${declaration.type})` : "";
|
|
16728
|
-
}
|
|
16729
|
-
function keyFrom(name) {
|
|
16730
|
-
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^[^a-z]+/, "").replace(/-+$/, "").slice(0, 63);
|
|
16731
|
-
return /^[a-z][a-z0-9-]{1,61}[a-z0-9]$/.test(slug) ? slug : "";
|
|
16732
|
-
}
|
|
16733
16757
|
|
|
16734
16758
|
// src/commands/guide.ts
|
|
16735
16759
|
async function runGuide(parsed) {
|