@farthershore/product 0.0.0 → 0.2.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/README.md +153 -0
- package/dist/bin.js +457 -75
- package/dist/codegen.js +23 -0
- package/dist/index.js +418 -70
- package/dist/types/business.d.ts +35 -10
- package/dist/types/index.d.ts +2 -1
- package/dist/types/ir-types.d.ts +25 -0
- package/dist/types/resource-graph.d.ts +36 -0
- package/package.json +1 -1
package/dist/codegen.js
CHANGED
|
@@ -25,6 +25,9 @@ var TOP_LEVEL_HANDLED = /* @__PURE__ */ new Set([
|
|
|
25
25
|
"billing",
|
|
26
26
|
"frontend",
|
|
27
27
|
"migrations",
|
|
28
|
+
"policies",
|
|
29
|
+
"customer_context",
|
|
30
|
+
"resources",
|
|
28
31
|
"plans"
|
|
29
32
|
]);
|
|
30
33
|
var PLAN_HANDLED_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -68,6 +71,14 @@ function generateManifestSource(ir) {
|
|
|
68
71
|
lines.push(`business.meter(${lit(key)}, ${lit(rest, 0)});`);
|
|
69
72
|
}
|
|
70
73
|
}
|
|
74
|
+
const resources = product.resources ?? [];
|
|
75
|
+
if (resources.length) {
|
|
76
|
+
lines.push("");
|
|
77
|
+
for (const resource of resources) {
|
|
78
|
+
const { name, ...rest } = resource;
|
|
79
|
+
lines.push(`business.resource(${lit(name)}, ${lit(rest, 0)});`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
71
82
|
if (ir.capabilities.length) {
|
|
72
83
|
lines.push("");
|
|
73
84
|
for (const cap of ir.capabilities) {
|
|
@@ -185,6 +196,11 @@ function businessOptions(product) {
|
|
|
185
196
|
options.upstreamAuth = gateway.upstreamAuth;
|
|
186
197
|
if (product.metering?.billOn4xx !== void 0)
|
|
187
198
|
options.billOn4xx = product.metering.billOn4xx;
|
|
199
|
+
if (product.policies !== void 0)
|
|
200
|
+
options.operatorPolicies = product.policies;
|
|
201
|
+
if (product.customer_context !== void 0) {
|
|
202
|
+
options.customerContext = customerContextOptions(product.customer_context);
|
|
203
|
+
}
|
|
188
204
|
const billing = product.billing;
|
|
189
205
|
if (billing) {
|
|
190
206
|
const handled = {};
|
|
@@ -196,6 +212,13 @@ function businessOptions(product) {
|
|
|
196
212
|
}
|
|
197
213
|
return options;
|
|
198
214
|
}
|
|
215
|
+
function customerContextOptions(context) {
|
|
216
|
+
return {
|
|
217
|
+
...context.identity_requirement !== void 0 ? { identityRequirement: context.identity_requirement } : {},
|
|
218
|
+
...context.context_tokens !== void 0 ? { contextTokens: context.context_tokens } : {},
|
|
219
|
+
...context.portal_auth !== void 0 ? { portalAuth: context.portal_auth } : {}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
199
222
|
function planOptions(plan) {
|
|
200
223
|
const options = { name: plan.name };
|
|
201
224
|
if (plan.description !== void 0) options.description = plan.description;
|