@lukoweb/apitogo 0.1.98 → 0.1.99
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/cli/cli.js
CHANGED
|
@@ -7525,13 +7525,33 @@ async function listAllGatewayActions(client, projectId, pageSize = 100) {
|
|
|
7525
7525
|
}
|
|
7526
7526
|
return items;
|
|
7527
7527
|
}
|
|
7528
|
+
async function resolveIncludedActionKeysForCreate(client, projectId, includedActionKeys, options) {
|
|
7529
|
+
if (options?.skipDefaultActions) {
|
|
7530
|
+
return includedActionKeys ?? [];
|
|
7531
|
+
}
|
|
7532
|
+
if (includedActionKeys && includedActionKeys.length > 0) {
|
|
7533
|
+
return includedActionKeys;
|
|
7534
|
+
}
|
|
7535
|
+
try {
|
|
7536
|
+
const actions = await listAllGatewayActions(client, projectId);
|
|
7537
|
+
return actions.map((action) => action.actionKey);
|
|
7538
|
+
} catch {
|
|
7539
|
+
return includedActionKeys ?? [];
|
|
7540
|
+
}
|
|
7541
|
+
}
|
|
7528
7542
|
async function handleCreateGatewayPlan(client, config2, args) {
|
|
7529
7543
|
const projectId = resolveProjectId(args.projectId, config2);
|
|
7544
|
+
const includedActionKeys = await resolveIncludedActionKeysForCreate(
|
|
7545
|
+
client,
|
|
7546
|
+
projectId,
|
|
7547
|
+
args.includedActionKeys,
|
|
7548
|
+
{ skipDefaultActions: args.skipDefaultActions }
|
|
7549
|
+
);
|
|
7530
7550
|
const body = {
|
|
7531
7551
|
sku: args.sku,
|
|
7532
7552
|
displayName: args.displayName,
|
|
7533
7553
|
limitsJson: args.limitsJson ?? null,
|
|
7534
|
-
includedActionKeys
|
|
7554
|
+
includedActionKeys,
|
|
7535
7555
|
priceAmount: args.priceAmount,
|
|
7536
7556
|
priceCurrency: args.priceCurrency,
|
|
7537
7557
|
billingPeriod: args.billingPeriod,
|
|
@@ -7725,6 +7745,14 @@ function resolveIncludedActionKeysForUpsert(manifestPlan, existingPlan) {
|
|
|
7725
7745
|
}
|
|
7726
7746
|
return [];
|
|
7727
7747
|
}
|
|
7748
|
+
async function resolveActionKeysOrAllProjectActions(manifestPlan, existingPlan, getAllKeys) {
|
|
7749
|
+
const resolved = resolveIncludedActionKeysForUpsert(manifestPlan, existingPlan);
|
|
7750
|
+
if (resolved.length > 0) {
|
|
7751
|
+
return resolved;
|
|
7752
|
+
}
|
|
7753
|
+
const allKeys = await getAllKeys();
|
|
7754
|
+
return allKeys.length > 0 ? allKeys : resolved;
|
|
7755
|
+
}
|
|
7728
7756
|
var GATEWAY_PLAN_SORT_TEMP_OFFSET = 1e3;
|
|
7729
7757
|
function buildGatewayPlanSortTargetsFromIds(manifestPlans, planIdsBySku, skuById) {
|
|
7730
7758
|
const targets = [];
|
|
@@ -7759,17 +7787,36 @@ async function applyGatewayPlanSortOrders(client, config2, projectId, targets) {
|
|
|
7759
7787
|
}
|
|
7760
7788
|
return results;
|
|
7761
7789
|
}
|
|
7790
|
+
async function listProjectActionKeys(client, projectId) {
|
|
7791
|
+
try {
|
|
7792
|
+
const actions = await listAllGatewayActions(client, projectId);
|
|
7793
|
+
return actions.map((action) => action.actionKey);
|
|
7794
|
+
} catch {
|
|
7795
|
+
return [];
|
|
7796
|
+
}
|
|
7797
|
+
}
|
|
7762
7798
|
async function upsertGatewayPlansFromManifest(client, config2, projectId, plans, options) {
|
|
7763
7799
|
const existing = await client.listGatewayPlans(projectId);
|
|
7764
7800
|
const bySku = new Map(existing.map((plan) => [plan.sku.toLowerCase(), plan]));
|
|
7765
7801
|
const results = [];
|
|
7766
7802
|
const planIdsBySku = /* @__PURE__ */ new Map();
|
|
7803
|
+
let cachedProjectActionKeys;
|
|
7804
|
+
const projectActionKeys = async () => {
|
|
7805
|
+
if (cachedProjectActionKeys === void 0) {
|
|
7806
|
+
cachedProjectActionKeys = await listProjectActionKeys(client, projectId);
|
|
7807
|
+
}
|
|
7808
|
+
return cachedProjectActionKeys;
|
|
7809
|
+
};
|
|
7767
7810
|
for (const [index, inputRaw] of plans.entries()) {
|
|
7768
7811
|
const input3 = normalizePlanForGatewayApi(inputRaw);
|
|
7769
7812
|
const found = bySku.get(input3.sku.toLowerCase());
|
|
7770
7813
|
if (found) {
|
|
7771
7814
|
if (options?.syncActionsOnly) {
|
|
7772
|
-
const actionKeys =
|
|
7815
|
+
const actionKeys = await resolveActionKeysOrAllProjectActions(
|
|
7816
|
+
input3,
|
|
7817
|
+
found,
|
|
7818
|
+
projectActionKeys
|
|
7819
|
+
);
|
|
7773
7820
|
if (actionKeys.length === 0) {
|
|
7774
7821
|
continue;
|
|
7775
7822
|
}
|
|
@@ -7793,7 +7840,11 @@ async function upsertGatewayPlansFromManifest(client, config2, projectId, plans,
|
|
|
7793
7840
|
billingPeriod: input3.billingPeriod ? normalizeBillingPeriod(input3.billingPeriod) : void 0
|
|
7794
7841
|
};
|
|
7795
7842
|
if (!options?.deferActionKeys) {
|
|
7796
|
-
patchArgs.includedActionKeys =
|
|
7843
|
+
patchArgs.includedActionKeys = await resolveActionKeysOrAllProjectActions(
|
|
7844
|
+
input3,
|
|
7845
|
+
found,
|
|
7846
|
+
projectActionKeys
|
|
7847
|
+
);
|
|
7797
7848
|
}
|
|
7798
7849
|
const patchedJson = await handlePatchGatewayPlan(client, config2, patchArgs);
|
|
7799
7850
|
results.push(JSON.parse(patchedJson));
|
|
@@ -7811,7 +7862,8 @@ async function upsertGatewayPlansFromManifest(client, config2, projectId, plans,
|
|
|
7811
7862
|
priceCurrency: input3.priceCurrency ?? "usd",
|
|
7812
7863
|
billingPeriod: normalizeBillingPeriod(input3.billingPeriod),
|
|
7813
7864
|
limitsJson: planLimitsForPlatform(input3),
|
|
7814
|
-
includedActionKeys: options?.deferActionKeys ? [] :
|
|
7865
|
+
includedActionKeys: options?.deferActionKeys ? [] : await resolveActionKeysOrAllProjectActions(input3, void 0, projectActionKeys),
|
|
7866
|
+
skipDefaultActions: true,
|
|
7815
7867
|
sortOrder: index
|
|
7816
7868
|
});
|
|
7817
7869
|
const created = JSON.parse(createdJson);
|
|
@@ -12748,7 +12800,7 @@ import {
|
|
|
12748
12800
|
// package.json
|
|
12749
12801
|
var package_default = {
|
|
12750
12802
|
name: "@lukoweb/apitogo",
|
|
12751
|
-
version: "0.1.
|
|
12803
|
+
version: "0.1.99",
|
|
12752
12804
|
type: "module",
|
|
12753
12805
|
sideEffects: [
|
|
12754
12806
|
"**/*.css",
|
|
@@ -19860,7 +19912,7 @@ function printPlanAddedHint(displayName) {
|
|
|
19860
19912
|
`Plan "${displayName}" added to modules.userPanel.plans.items in apitogo.config.json.`
|
|
19861
19913
|
);
|
|
19862
19914
|
printDiagnosticsToConsole(
|
|
19863
|
-
"
|
|
19915
|
+
"New plans include all API operations by default. Set includedActionKeys to restrict, and configure Stripe before publishing paid plans."
|
|
19864
19916
|
);
|
|
19865
19917
|
printDiagnosticsToConsole(`Docs: ${DOCS}/docs/configuration/plans`);
|
|
19866
19918
|
}
|
|
@@ -28,9 +28,13 @@ export interface ApplyPublicRoutesResult {
|
|
|
28
28
|
export declare function applyGatewayPublicRoutes(client: PlatformApiClient, projectId: string, routes: string[], options?: {
|
|
29
29
|
knownActions?: GatewayActionDto[];
|
|
30
30
|
}): Promise<ApplyPublicRoutesResult>;
|
|
31
|
+
export declare function listAllGatewayActions(client: PlatformApiClient, projectId: string, pageSize?: number): Promise<GatewayActionDto[]>;
|
|
31
32
|
export declare function handleListGatewayPlans(client: PlatformApiClient, config: ApitogoConfig, args: {
|
|
32
33
|
projectId?: string;
|
|
33
34
|
}): Promise<string>;
|
|
35
|
+
export declare function resolveIncludedActionKeysForCreate(client: PlatformApiClient, projectId: string, includedActionKeys: string[] | undefined, options?: {
|
|
36
|
+
skipDefaultActions?: boolean;
|
|
37
|
+
}): Promise<string[]>;
|
|
34
38
|
export declare function handleCreateGatewayPlan(client: PlatformApiClient, config: ApitogoConfig, args: {
|
|
35
39
|
projectId?: string;
|
|
36
40
|
sku: string;
|
|
@@ -41,6 +45,7 @@ export declare function handleCreateGatewayPlan(client: PlatformApiClient, confi
|
|
|
41
45
|
priceCurrency?: string;
|
|
42
46
|
billingPeriod?: string;
|
|
43
47
|
sortOrder?: number;
|
|
48
|
+
skipDefaultActions?: boolean;
|
|
44
49
|
}): Promise<string>;
|
|
45
50
|
export declare function handleGetGatewayPlan(client: PlatformApiClient, config: ApitogoConfig, args: {
|
|
46
51
|
projectId?: string;
|
|
@@ -82,7 +82,8 @@ load.
|
|
|
82
82
|
- **rateLimit** — maximum calls per renewal window (per minute when `renewalPeriodSeconds` is 60).
|
|
83
83
|
- **quota** — longer-window cap (per 30 days when `renewalPeriodDays` is 30).
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
New plans include **all** discovered OpenAPI operations unless you set `includedActionKeys`.
|
|
86
|
+
After OpenAPI is deployed, you can scope a plan to specific operations with
|
|
86
87
|
`includedActionKeys` (for example `get:/orders/{id}`). Edit those fields in
|
|
87
88
|
`apitogo.config.json` — see [Manifest](./manifest.md).
|
|
88
89
|
|