@kelviq/cli 0.1.1
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 +313 -0
- package/dist/cli-ui/auth-hint.d.ts +6 -0
- package/dist/cli-ui/auth-hint.js +34 -0
- package/dist/cli-ui/auth-hint.js.map +1 -0
- package/dist/cli-ui/hints.d.ts +5 -0
- package/dist/cli-ui/hints.js +19 -0
- package/dist/cli-ui/hints.js.map +1 -0
- package/dist/cli-ui/spinner.d.ts +7 -0
- package/dist/cli-ui/spinner.js +61 -0
- package/dist/cli-ui/spinner.js.map +1 -0
- package/dist/cli-ui/style.d.ts +47 -0
- package/dist/cli-ui/style.js +71 -0
- package/dist/cli-ui/style.js.map +1 -0
- package/dist/cli-ui/tty.d.ts +1 -0
- package/dist/cli-ui/tty.js +13 -0
- package/dist/cli-ui/tty.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +51 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/env.d.ts +34 -0
- package/dist/commands/env.js +52 -0
- package/dist/commands/env.js.map +1 -0
- package/dist/commands/init.d.ts +15 -0
- package/dist/commands/init.js +70 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.d.ts +22 -0
- package/dist/commands/login.js +205 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +13 -0
- package/dist/commands/logout.js +39 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/promote.d.ts +42 -0
- package/dist/commands/promote.js +243 -0
- package/dist/commands/promote.js.map +1 -0
- package/dist/commands/pull.d.ts +31 -0
- package/dist/commands/pull.js +108 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push-shared.d.ts +97 -0
- package/dist/commands/push-shared.js +283 -0
- package/dist/commands/push-shared.js.map +1 -0
- package/dist/commands/push.d.ts +42 -0
- package/dist/commands/push.js +268 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/config-format/builders.d.ts +10 -0
- package/dist/config-format/builders.js +46 -0
- package/dist/config-format/builders.js.map +1 -0
- package/dist/config-format/index.d.ts +4 -0
- package/dist/config-format/index.js +9 -0
- package/dist/config-format/index.js.map +1 -0
- package/dist/config-format/load.d.ts +23 -0
- package/dist/config-format/load.js +82 -0
- package/dist/config-format/load.js.map +1 -0
- package/dist/config-format/schema.d.ts +423 -0
- package/dist/config-format/schema.js +105 -0
- package/dist/config-format/schema.js.map +1 -0
- package/dist/core/config.d.ts +48 -0
- package/dist/core/config.js +128 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/errors.d.ts +20 -0
- package/dist/core/errors.js +58 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/http.d.ts +39 -0
- package/dist/core/http.js +104 -0
- package/dist/core/http.js.map +1 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/version.js +14 -0
- package/dist/core/version.js.map +1 -0
- package/dist/generated/openapi.json +6635 -0
- package/dist/sync/apply.d.ts +38 -0
- package/dist/sync/apply.js +234 -0
- package/dist/sync/apply.js.map +1 -0
- package/dist/sync/diff.d.ts +186 -0
- package/dist/sync/diff.js +402 -0
- package/dist/sync/diff.js.map +1 -0
- package/dist/sync/fetch-catalog.d.ts +105 -0
- package/dist/sync/fetch-catalog.js +100 -0
- package/dist/sync/fetch-catalog.js.map +1 -0
- package/dist/sync/price-filter.d.ts +37 -0
- package/dist/sync/price-filter.js +195 -0
- package/dist/sync/price-filter.js.map +1 -0
- package/dist/sync/prune.d.ts +77 -0
- package/dist/sync/prune.js +112 -0
- package/dist/sync/prune.js.map +1 -0
- package/dist/sync/publish.d.ts +75 -0
- package/dist/sync/publish.js +126 -0
- package/dist/sync/publish.js.map +1 -0
- package/dist/sync/push-plan-json.d.ts +79 -0
- package/dist/sync/push-plan-json.js +70 -0
- package/dist/sync/push-plan-json.js.map +1 -0
- package/dist/sync/render-plan.d.ts +83 -0
- package/dist/sync/render-plan.js +358 -0
- package/dist/sync/render-plan.js.map +1 -0
- package/dist/sync/serialize.d.ts +18 -0
- package/dist/sync/serialize.js +108 -0
- package/dist/sync/serialize.js.map +1 -0
- package/dist/sync/to-config.d.ts +9 -0
- package/dist/sync/to-config.js +191 -0
- package/dist/sync/to-config.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { KelviqHttpClient } from '../core/http.js';
|
|
2
|
+
import type { PushPlan } from './diff.js';
|
|
3
|
+
export interface ApplyIO {
|
|
4
|
+
stdout: NodeJS.WritableStream;
|
|
5
|
+
}
|
|
6
|
+
export type OperationStatus = 'applied' | 'failed' | 'not-attempted';
|
|
7
|
+
export interface OperationRecord {
|
|
8
|
+
/** Same `kind` tag the source PushPlan op carried (e.g. `'product-create'`, `'entitlement-delete'`). */
|
|
9
|
+
kind: string;
|
|
10
|
+
/** One-line human description naming the identifier (and, for patches, the changed fields) — the same text used for the progress line. */
|
|
11
|
+
description: string;
|
|
12
|
+
status: OperationStatus;
|
|
13
|
+
/** Present only when `status === 'failed'`. */
|
|
14
|
+
error?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Present only for `'plan-create'` / `'plan-patch'` / `'price-bulk-replace'`
|
|
17
|
+
* — the plan identifier the op acted on. CLI plan 009's structured
|
|
18
|
+
* companion to `description`'s free text: `src/sync/publish.ts`'s
|
|
19
|
+
* `publishSetFromApplyResult` reads this field (filtered to
|
|
20
|
+
* `status === 'applied'`) to compute the publish set, rather than
|
|
21
|
+
* regex-parsing the human-readable description.
|
|
22
|
+
*/
|
|
23
|
+
planIdentifier?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ApplyResult {
|
|
26
|
+
/** Every operation the plan contained, in execution order, whether or not it was attempted. */
|
|
27
|
+
operations: OperationRecord[];
|
|
28
|
+
/** True iff every operation applied (vacuously true for a plan with zero operations). */
|
|
29
|
+
ok: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Applies every operation in `plan`, in DESIGN-push.md §8's fixed order,
|
|
33
|
+
* against `http`. Stops attempting further operations after the first
|
|
34
|
+
* failure but still records every remaining operation as `not-attempted` —
|
|
35
|
+
* see the module comment. Never throws: an unexpected error from a single
|
|
36
|
+
* operation is captured as that operation's `error` rather than escaping.
|
|
37
|
+
*/
|
|
38
|
+
export declare function applyPushPlan(http: KelviqHttpClient, plan: PushPlan, io: ApplyIO): Promise<ApplyResult>;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { authHintLine, isAuthStatus } from '../cli-ui/auth-hint.js';
|
|
2
|
+
import { style } from '../cli-ui/style.js';
|
|
3
|
+
function isPlainObject(value) {
|
|
4
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
function isPendingProductIdentifier(value) {
|
|
7
|
+
return isPlainObject(value) && typeof value.pendingProductIdentifier === 'string';
|
|
8
|
+
}
|
|
9
|
+
function isPendingFeatureIdentifier(value) {
|
|
10
|
+
return isPlainObject(value) && typeof value.pendingFeatureIdentifier === 'string';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolves every `chargeCatalogPrice[].feature` pending placeholder inside an
|
|
14
|
+
* already-filtered price body against `featureIdByIdentifier` (built from
|
|
15
|
+
* this run's own feature-create responses — see `applyPushPlan`). Any other
|
|
16
|
+
* shape (a real UUID string, `null`, or an absent key — see
|
|
17
|
+
* src/sync/price-filter.ts's `FilterPriceResult`) passes through unchanged.
|
|
18
|
+
* A pending reference that still can't resolve here (its feature's create
|
|
19
|
+
* either failed or never ran) is a bug reaching the wire — reported as an
|
|
20
|
+
* error, never sent.
|
|
21
|
+
*/
|
|
22
|
+
function resolvePendingFeaturesInPrices(prices, featureIdByIdentifier) {
|
|
23
|
+
const resolved = [];
|
|
24
|
+
for (const price of prices) {
|
|
25
|
+
const chargeCatalogPrice = price.chargeCatalogPrice;
|
|
26
|
+
if (!Array.isArray(chargeCatalogPrice)) {
|
|
27
|
+
resolved.push(price);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const resolvedCharges = [];
|
|
31
|
+
for (const entry of chargeCatalogPrice) {
|
|
32
|
+
if (!isPlainObject(entry) || !('feature' in entry)) {
|
|
33
|
+
resolvedCharges.push(entry);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const featureValue = entry.feature;
|
|
37
|
+
if (isPendingFeatureIdentifier(featureValue)) {
|
|
38
|
+
const uuid = featureIdByIdentifier.get(featureValue.pendingFeatureIdentifier);
|
|
39
|
+
if (!uuid) {
|
|
40
|
+
return {
|
|
41
|
+
prices: [],
|
|
42
|
+
error: `Internal error: pending feature reference "${featureValue.pendingFeatureIdentifier}" inside a price bulk-replace body was never resolved (its create either failed or was skipped) — refusing to send an unfilled placeholder.`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
resolvedCharges.push({ ...entry, feature: uuid });
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
resolvedCharges.push(entry);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
resolved.push({ ...price, chargeCatalogPrice: resolvedCharges });
|
|
52
|
+
}
|
|
53
|
+
return { prices: resolved };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Applies every operation in `plan`, in DESIGN-push.md §8's fixed order,
|
|
57
|
+
* against `http`. Stops attempting further operations after the first
|
|
58
|
+
* failure but still records every remaining operation as `not-attempted` —
|
|
59
|
+
* see the module comment. Never throws: an unexpected error from a single
|
|
60
|
+
* operation is captured as that operation's `error` rather than escaping.
|
|
61
|
+
*/
|
|
62
|
+
export async function applyPushPlan(http, plan, io) {
|
|
63
|
+
const operations = [];
|
|
64
|
+
const productIdByIdentifier = new Map();
|
|
65
|
+
const featureIdByIdentifier = new Map();
|
|
66
|
+
let failed = false;
|
|
67
|
+
const write = (s) => io.stdout.write(s);
|
|
68
|
+
async function run(kind, description, exec, planIdentifier) {
|
|
69
|
+
const withPlan = (record) => planIdentifier !== undefined ? { ...record, planIdentifier } : record;
|
|
70
|
+
if (failed) {
|
|
71
|
+
operations.push(withPlan({ kind, description, status: 'not-attempted' }));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
write(`-> ${description}\n`);
|
|
75
|
+
let outcome;
|
|
76
|
+
try {
|
|
77
|
+
outcome = await exec();
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
outcome = { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
81
|
+
}
|
|
82
|
+
if (outcome.ok) {
|
|
83
|
+
operations.push(withPlan({ kind, description, status: 'applied' }));
|
|
84
|
+
write(` ${style.ok('ok')}\n`);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const error = outcome.error ?? 'unknown error';
|
|
88
|
+
operations.push(withPlan({ kind, description, status: 'failed', error }));
|
|
89
|
+
write(` ${style.fail(`FAILED: ${error}`)}\n`);
|
|
90
|
+
// CLI plan 014 Step 5: actionable hint right after the failure line —
|
|
91
|
+
// `outcome.httpStatus` is only ever set here, in this module, from the
|
|
92
|
+
// raw `KelviqAPIError` before it collapses to `Outcome.error`'s plain
|
|
93
|
+
// string (see `Outcome`'s own comment).
|
|
94
|
+
if (isAuthStatus(outcome.httpStatus))
|
|
95
|
+
write(` ${authHintLine()}\n`);
|
|
96
|
+
failed = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// --- Products: creates then patches ---
|
|
100
|
+
for (const op of plan.products.create) {
|
|
101
|
+
await run('product-create', `create product "${op.identifier}"`, async () => {
|
|
102
|
+
const result = await http.request({ method: 'POST', path: '/catalog/products/', body: op.body, auth: 'server' });
|
|
103
|
+
if (!result.ok)
|
|
104
|
+
return { ok: false, error: result.error.message, httpStatus: result.error.httpStatus };
|
|
105
|
+
if (!result.data.id)
|
|
106
|
+
return { ok: false, error: `Product "${op.identifier}" create response carried no usable id.` };
|
|
107
|
+
productIdByIdentifier.set(op.identifier, result.data.id);
|
|
108
|
+
return { ok: true };
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
for (const op of plan.products.patch) {
|
|
112
|
+
await run('product-patch', `update product "${op.identifier}" (${Object.keys(op.body).join(', ')})`, async () => {
|
|
113
|
+
const result = await http.request({ method: 'PATCH', path: `/catalog/products/${encodeURIComponent(op.pk)}/`, body: op.body, auth: 'server' });
|
|
114
|
+
return result.ok ? { ok: true } : { ok: false, error: result.error.message, httpStatus: result.error.httpStatus };
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
// --- Features: creates only (no update endpoint exists — DESIGN-push.md §3) ---
|
|
118
|
+
for (const op of plan.features.create) {
|
|
119
|
+
await run('feature-create', `create feature "${op.identifier}"`, async () => {
|
|
120
|
+
const result = await http.request({ method: 'POST', path: '/catalog/features/', body: op.body, auth: 'server' });
|
|
121
|
+
if (!result.ok)
|
|
122
|
+
return { ok: false, error: result.error.message, httpStatus: result.error.httpStatus };
|
|
123
|
+
if (!result.data.id)
|
|
124
|
+
return { ok: false, error: `Feature "${op.identifier}" create response carried no usable id.` };
|
|
125
|
+
featureIdByIdentifier.set(op.identifier, result.data.id);
|
|
126
|
+
return { ok: true };
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// --- Plans: creates then patches ---
|
|
130
|
+
for (const op of plan.plans.create) {
|
|
131
|
+
await run('plan-create', `create plan "${op.identifier}"`, async () => {
|
|
132
|
+
const productRef = op.body.product;
|
|
133
|
+
let productId;
|
|
134
|
+
if (typeof productRef === 'string') {
|
|
135
|
+
productId = productRef;
|
|
136
|
+
}
|
|
137
|
+
else if (isPendingProductIdentifier(productRef)) {
|
|
138
|
+
const resolved = productIdByIdentifier.get(productRef.pendingProductIdentifier);
|
|
139
|
+
if (!resolved) {
|
|
140
|
+
return {
|
|
141
|
+
ok: false,
|
|
142
|
+
error: `Internal error: pending product reference "${productRef.pendingProductIdentifier}" for plan "${op.identifier}" was never resolved (its create either failed or was skipped) — refusing to send an unfilled placeholder.`,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
productId = resolved;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
return { ok: false, error: `Internal error: plan "${op.identifier}" carries an unrecognized product reference shape.` };
|
|
149
|
+
}
|
|
150
|
+
const body = { ...op.body, product: productId };
|
|
151
|
+
const result = await http.request({ method: 'POST', path: '/catalog/plans/', body, auth: 'server' });
|
|
152
|
+
return result.ok ? { ok: true } : { ok: false, error: result.error.message, httpStatus: result.error.httpStatus };
|
|
153
|
+
}, op.identifier);
|
|
154
|
+
}
|
|
155
|
+
for (const op of plan.plans.patch) {
|
|
156
|
+
await run('plan-patch', `update plan "${op.identifier}" (${Object.keys(op.body).join(', ')})`, async () => {
|
|
157
|
+
const result = await http.request({ method: 'PATCH', path: `/catalog/plans/${encodeURIComponent(op.identifier)}/`, body: op.body, auth: 'server' });
|
|
158
|
+
return result.ok ? { ok: true } : { ok: false, error: result.error.message, httpStatus: result.error.httpStatus };
|
|
159
|
+
}, op.identifier);
|
|
160
|
+
}
|
|
161
|
+
// --- Entitlements: adds -> updates -> deletes ---
|
|
162
|
+
// POST .../features/ takes a `{ planEntitlements: [...] }` array body
|
|
163
|
+
// (PlanFeaturesCreateRequest) even though PushPlan gives us one
|
|
164
|
+
// EntitlementAddOp per feature — each add is sent as its own request with
|
|
165
|
+
// a single-element array, keeping one PushPlan operation = one HTTP call
|
|
166
|
+
// = one report entry, consistent with every other op kind here.
|
|
167
|
+
for (const op of plan.entitlements.add) {
|
|
168
|
+
await run('entitlement-add', `add entitlement "${op.featureIdentifier}" to plan "${op.planIdentifier}"`, async () => {
|
|
169
|
+
let featureId;
|
|
170
|
+
if (typeof op.feature === 'string') {
|
|
171
|
+
featureId = op.feature;
|
|
172
|
+
}
|
|
173
|
+
else if (isPendingFeatureIdentifier(op.feature)) {
|
|
174
|
+
const resolved = featureIdByIdentifier.get(op.feature.pendingFeatureIdentifier);
|
|
175
|
+
if (!resolved) {
|
|
176
|
+
return {
|
|
177
|
+
ok: false,
|
|
178
|
+
error: `Internal error: pending feature reference "${op.feature.pendingFeatureIdentifier}" for entitlement "${op.featureIdentifier}" on plan "${op.planIdentifier}" was never resolved (its create either failed or was skipped) — refusing to send an unfilled placeholder.`,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
featureId = resolved;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
return { ok: false, error: `Internal error: entitlement "${op.featureIdentifier}" on plan "${op.planIdentifier}" carries an unrecognized feature reference shape.` };
|
|
185
|
+
}
|
|
186
|
+
const body = { planEntitlements: [{ feature: featureId, details: op.details }] };
|
|
187
|
+
const result = await http.request({
|
|
188
|
+
method: 'POST',
|
|
189
|
+
path: `/catalog/plans/${encodeURIComponent(op.planIdentifier)}/features/`,
|
|
190
|
+
body,
|
|
191
|
+
auth: 'server',
|
|
192
|
+
});
|
|
193
|
+
return result.ok ? { ok: true } : { ok: false, error: result.error.message, httpStatus: result.error.httpStatus };
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
for (const op of plan.entitlements.update) {
|
|
197
|
+
await run('entitlement-update', `update entitlement "${op.featureIdentifier}" on plan "${op.planIdentifier}"`, async () => {
|
|
198
|
+
const result = await http.request({
|
|
199
|
+
method: 'PATCH',
|
|
200
|
+
path: `/catalog/plans/${encodeURIComponent(op.planIdentifier)}/features/${encodeURIComponent(op.featureIdentifier)}/`,
|
|
201
|
+
body: { details: op.details },
|
|
202
|
+
auth: 'server',
|
|
203
|
+
});
|
|
204
|
+
return result.ok ? { ok: true } : { ok: false, error: result.error.message, httpStatus: result.error.httpStatus };
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
for (const op of plan.entitlements.delete) {
|
|
208
|
+
await run('entitlement-delete', `delete entitlement "${op.featureIdentifier}" from plan "${op.planIdentifier}"`, async () => {
|
|
209
|
+
const result = await http.request({
|
|
210
|
+
method: 'DELETE',
|
|
211
|
+
path: `/catalog/plans/${encodeURIComponent(op.planIdentifier)}/features/${encodeURIComponent(op.featureIdentifier)}/`,
|
|
212
|
+
auth: 'server',
|
|
213
|
+
});
|
|
214
|
+
return result.ok ? { ok: true } : { ok: false, error: result.error.message, httpStatus: result.error.httpStatus };
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
// --- Prices: bulk replaces (last — every feature this run creates already exists remotely by now) ---
|
|
218
|
+
for (const op of plan.prices.bulkReplace) {
|
|
219
|
+
await run('price-bulk-replace', `replace prices for plan "${op.planIdentifier}"`, async () => {
|
|
220
|
+
const { prices, error } = resolvePendingFeaturesInPrices(op.prices, featureIdByIdentifier);
|
|
221
|
+
if (error)
|
|
222
|
+
return { ok: false, error };
|
|
223
|
+
const result = await http.request({
|
|
224
|
+
method: 'POST',
|
|
225
|
+
path: `/catalog/plans/${encodeURIComponent(op.planIdentifier)}/prices/bulk/`,
|
|
226
|
+
body: { prices },
|
|
227
|
+
auth: 'server',
|
|
228
|
+
});
|
|
229
|
+
return result.ok ? { ok: true } : { ok: false, error: result.error.message, httpStatus: result.error.httpStatus };
|
|
230
|
+
}, op.planIdentifier);
|
|
231
|
+
}
|
|
232
|
+
return { operations, ok: !failed };
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/sync/apply.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AA8C3C,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAc;IAChD,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,wBAAwB,KAAK,QAAQ,CAAC;AACpF,CAAC;AAED,SAAS,0BAA0B,CAA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M,CAAC,WAAmC,EAAE,CAAC;QACjE,MAAM,GAAG,CAAC,oBAAoB,EAAE,4BAA4B,EAAE,CAAC,cAAc,GAAG,EAAE,KAAK,IAAI,EAAE;YAC3F,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,8BAA8B,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;YAC3F,IAAI,KAAK;gBAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC;gBAChC,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,kBAAkB,kBAAkB,CAAC,EAAE,CAAC,cAAc,CAAC,eAAe;gBAC5E,IAAI,EAAE,EAAE,MAAM,EAAE;gBAChB,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACpH,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import type { FeatureType, KelviqConfig, TaxCode } from '../config-format/schema.js';
|
|
2
|
+
import type { RawCatalog } from './fetch-catalog.js';
|
|
3
|
+
import type { FeatureRefValue } from './price-filter.js';
|
|
4
|
+
export type { FeatureRefValue, PendingFeatureRef } from './price-filter.js';
|
|
5
|
+
export interface ProductCreateBody {
|
|
6
|
+
identifier: string;
|
|
7
|
+
name: string;
|
|
8
|
+
taxCode: TaxCode;
|
|
9
|
+
description?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Only changed fields are ever present — see `diffProductFields`. */
|
|
12
|
+
export interface ProductPatchBody {
|
|
13
|
+
name?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
taxCode?: TaxCode;
|
|
16
|
+
}
|
|
17
|
+
export interface FeatureCreateBody {
|
|
18
|
+
identifier: string;
|
|
19
|
+
name: string;
|
|
20
|
+
featureType: FeatureType;
|
|
21
|
+
description?: string;
|
|
22
|
+
featureDetails?: Record<string, unknown>;
|
|
23
|
+
meter?: Record<string, unknown>;
|
|
24
|
+
/** Always present: the `managed-by: kelviq-cli` marker is merged in on every feature create (DESIGN-push.md §6). */
|
|
25
|
+
metadata: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A product reference a `PlanCreateRequest.product` body field will hold:
|
|
29
|
+
* either a resolved UUID, or — when the referenced product doesn't exist
|
|
30
|
+
* remotely yet but this same `desired` config also creates it — a
|
|
31
|
+
* placeholder naming which identifier's create response to read the UUID
|
|
32
|
+
* from. Plan 008 is expected to resolve every `PendingProductRef` against
|
|
33
|
+
* its own product-create results before sending the plan-create request;
|
|
34
|
+
* this module never performs that write itself.
|
|
35
|
+
*/
|
|
36
|
+
export interface PendingProductRef {
|
|
37
|
+
readonly pendingProductIdentifier: string;
|
|
38
|
+
}
|
|
39
|
+
export type ProductRefValue = string | PendingProductRef;
|
|
40
|
+
export interface PlanCreateBody {
|
|
41
|
+
identifier: string;
|
|
42
|
+
name: string;
|
|
43
|
+
product: ProductRefValue;
|
|
44
|
+
description?: string;
|
|
45
|
+
isVisible?: boolean;
|
|
46
|
+
/** Always present: the marker is merged in on every plan create (DESIGN-push.md §6). */
|
|
47
|
+
metadata: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
/** Only changed fields are ever present — see `diffPlanFields`. `metadata`, when present, already carries the re-merged marker. */
|
|
50
|
+
export interface PlanPatchBody {
|
|
51
|
+
name?: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
isVisible?: boolean;
|
|
54
|
+
metadata?: Record<string, unknown>;
|
|
55
|
+
}
|
|
56
|
+
export interface ProductCreateOp {
|
|
57
|
+
kind: 'product-create';
|
|
58
|
+
identifier: string;
|
|
59
|
+
body: ProductCreateBody;
|
|
60
|
+
}
|
|
61
|
+
/** `PATCH /catalog/products/{pk}/` — products are addressed by UUID, not identifier. */
|
|
62
|
+
export interface ProductPatchOp {
|
|
63
|
+
kind: 'product-patch';
|
|
64
|
+
identifier: string;
|
|
65
|
+
pk: string;
|
|
66
|
+
body: ProductPatchBody;
|
|
67
|
+
/**
|
|
68
|
+
* CLI plan 014 (additive, presentation-only): the remote values of exactly
|
|
69
|
+
* the changed fields (same keys as `body`) — what render-plan.ts renders
|
|
70
|
+
* as the "old" side of an old→new patch line. Optional so every
|
|
71
|
+
* hand-constructed `ProductPatchOp` fixture predating this plan still
|
|
72
|
+
* type-checks; `buildPushPlan` always populates it. apply.ts never reads
|
|
73
|
+
* this field.
|
|
74
|
+
*/
|
|
75
|
+
previous?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
export interface FeatureCreateOp {
|
|
78
|
+
kind: 'feature-create';
|
|
79
|
+
identifier: string;
|
|
80
|
+
body: FeatureCreateBody;
|
|
81
|
+
}
|
|
82
|
+
/** A feature present both in config and remotely with drifted fields. Never an operation — DESIGN-push.md §3: features are immutable via the API by platform intent. */
|
|
83
|
+
export interface FeatureDriftEntry {
|
|
84
|
+
identifier: string;
|
|
85
|
+
/** Field names that drifted (`name`/`type`/`description`/`featureDetails`/`meter`/`metadata`). The `managed-by` marker key is excluded from the `metadata` comparison. */
|
|
86
|
+
fields: string[];
|
|
87
|
+
}
|
|
88
|
+
export interface PlanCreateOp {
|
|
89
|
+
kind: 'plan-create';
|
|
90
|
+
identifier: string;
|
|
91
|
+
body: PlanCreateBody;
|
|
92
|
+
}
|
|
93
|
+
/** `PATCH /catalog/plans/{identifier}/` — plans are addressed by identifier, not UUID. */
|
|
94
|
+
export interface PlanPatchOp {
|
|
95
|
+
kind: 'plan-patch';
|
|
96
|
+
identifier: string;
|
|
97
|
+
body: PlanPatchBody;
|
|
98
|
+
/** CLI plan 014 (additive, presentation-only): same contract as `ProductPatchOp.previous` — remote values of exactly the changed fields, `metadata` verbatim (not re-merged with the marker, unlike `body.metadata`). */
|
|
99
|
+
previous?: Record<string, unknown>;
|
|
100
|
+
}
|
|
101
|
+
/** `POST /catalog/plans/{identifier}/features/`. */
|
|
102
|
+
export interface EntitlementAddOp {
|
|
103
|
+
kind: 'entitlement-add';
|
|
104
|
+
planIdentifier: string;
|
|
105
|
+
featureIdentifier: string;
|
|
106
|
+
feature: FeatureRefValue;
|
|
107
|
+
details: Record<string, unknown>;
|
|
108
|
+
}
|
|
109
|
+
/** `PATCH /catalog/plans/{identifier}/features/{feature_id}/` — `feature_id` is the feature's identifier (slug), confirmed against src/generated/openapi.json's path parameter description, not a UUID. */
|
|
110
|
+
export interface EntitlementUpdateOp {
|
|
111
|
+
kind: 'entitlement-update';
|
|
112
|
+
planIdentifier: string;
|
|
113
|
+
featureIdentifier: string;
|
|
114
|
+
details: Record<string, unknown>;
|
|
115
|
+
/** CLI plan 014 (additive, presentation-only): the remote entitlement's own current `details`, before this update — render-plan.ts's old→new line. */
|
|
116
|
+
previousDetails?: Record<string, unknown>;
|
|
117
|
+
}
|
|
118
|
+
/** `DELETE /catalog/plans/{identifier}/features/{feature_id}/` — same identifier-keyed path as the update op. */
|
|
119
|
+
export interface EntitlementDeleteOp {
|
|
120
|
+
kind: 'entitlement-delete';
|
|
121
|
+
planIdentifier: string;
|
|
122
|
+
featureIdentifier: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* `POST /catalog/plans/{identifier}/prices/bulk/` — `prices` is the fully
|
|
126
|
+
* filtered (`filterPriceForRequest`) body. Ready to send verbatim UNLESS a
|
|
127
|
+
* `chargeCatalogPrice[].feature` resolved to a `PendingFeatureRef`
|
|
128
|
+
* (`{ pendingFeatureIdentifier }`) — a feature `desired` creates this same
|
|
129
|
+
* run, not yet assigned a UUID at diff time. Prices execute last in
|
|
130
|
+
* DESIGN-push.md §8's order, so plan 008 fills every such placeholder from
|
|
131
|
+
* its own feature-create results before sending.
|
|
132
|
+
*/
|
|
133
|
+
export interface PriceBulkReplaceOp {
|
|
134
|
+
kind: 'price-bulk-replace';
|
|
135
|
+
planIdentifier: string;
|
|
136
|
+
prices: Array<Record<string, unknown>>;
|
|
137
|
+
/** CLI plan 014 (additive, presentation-only): the remote's own filtered price count before this replace — render-plan.ts's "(N → M prices)" line. */
|
|
138
|
+
remotePriceCount?: number;
|
|
139
|
+
}
|
|
140
|
+
export interface UnmanagedRemoteProduct {
|
|
141
|
+
identifier: string;
|
|
142
|
+
}
|
|
143
|
+
export interface UnmanagedRemoteFeature {
|
|
144
|
+
identifier: string;
|
|
145
|
+
/** Raw remote `metadata['managed-by'] === 'kelviq-cli'` — plan 010's `--prune` gate. */
|
|
146
|
+
managedByMarker: boolean;
|
|
147
|
+
}
|
|
148
|
+
export interface UnmanagedRemotePlan {
|
|
149
|
+
identifier: string;
|
|
150
|
+
/** Raw remote `metadata['managed-by'] === 'kelviq-cli'` — plan 010's `--prune` gate. */
|
|
151
|
+
managedByMarker: boolean;
|
|
152
|
+
}
|
|
153
|
+
export interface PushPlan {
|
|
154
|
+
products: {
|
|
155
|
+
create: ProductCreateOp[];
|
|
156
|
+
patch: ProductPatchOp[];
|
|
157
|
+
};
|
|
158
|
+
features: {
|
|
159
|
+
create: FeatureCreateOp[];
|
|
160
|
+
};
|
|
161
|
+
plans: {
|
|
162
|
+
create: PlanCreateOp[];
|
|
163
|
+
patch: PlanPatchOp[];
|
|
164
|
+
};
|
|
165
|
+
entitlements: {
|
|
166
|
+
add: EntitlementAddOp[];
|
|
167
|
+
update: EntitlementUpdateOp[];
|
|
168
|
+
delete: EntitlementDeleteOp[];
|
|
169
|
+
};
|
|
170
|
+
prices: {
|
|
171
|
+
bulkReplace: PriceBulkReplaceOp[];
|
|
172
|
+
};
|
|
173
|
+
/** Feature drift is a hard error, never an operation — see `FeatureDriftEntry`. */
|
|
174
|
+
featureDrift: FeatureDriftEntry[];
|
|
175
|
+
/** Identifiers present remotely, absent from `desired` — data only; plan 008 warns, plan 010 prunes plans/features (never products — DESIGN-push.md §5). */
|
|
176
|
+
unmanagedRemote: {
|
|
177
|
+
products: UnmanagedRemoteProduct[];
|
|
178
|
+
features: UnmanagedRemoteFeature[];
|
|
179
|
+
plans: UnmanagedRemotePlan[];
|
|
180
|
+
};
|
|
181
|
+
/** Dropped price fields (only for prices an op was actually emitted for), `toConfigDefs` normalization warnings. */
|
|
182
|
+
warnings: string[];
|
|
183
|
+
/** Unresolvable charge features, dangling product/feature references — never silently dropped. */
|
|
184
|
+
errors: string[];
|
|
185
|
+
}
|
|
186
|
+
export declare function buildPushPlan(desired: KelviqConfig, remote: RawCatalog): PushPlan;
|