@eide/foir-cli 0.4.9 → 0.4.11

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.js CHANGED
@@ -4810,21 +4810,30 @@ async function reconcileOperations(client, configId, operations, operationBaseUr
4810
4810
  for (const op of operations) {
4811
4811
  if (!op.key || !op.name) continue;
4812
4812
  manifestKeys.add(op.key);
4813
+ if (op.precondition) {
4814
+ const pre = op.precondition;
4815
+ const isSegment = "segmentKey" in pre && typeof pre.segmentKey === "string";
4816
+ const isExpression = "type" in pre && (pre.type === "condition" || pre.type === "group");
4817
+ if (!isSegment && !isExpression) {
4818
+ console.warn(`\u26A0 operation "${op.key}": precondition has unknown shape \u2014 expected {segmentKey, message} or {type: "condition"|"group", ...}`);
4819
+ }
4820
+ }
4813
4821
  const ex = existingByKey.get(op.key);
4814
4822
  const endpoint = resolveEndpoint(op.endpoint, operationBaseUrl);
4815
4823
  if (ex) {
4824
+ const empty = {};
4816
4825
  await client.operations.updateOperation({
4817
4826
  id: ex.id,
4818
4827
  name: op.name,
4819
4828
  description: op.description,
4820
4829
  endpoint,
4821
4830
  timeoutMs: op.timeoutMs,
4822
- inputSchema: op.inputSchema,
4823
- outputSchema: op.outputSchema,
4824
- streamConfig: op.streamConfig,
4825
- quotas: op.quotas,
4826
- retryPolicy: op.retryPolicy,
4827
- precondition: op.precondition,
4831
+ inputSchema: op.inputSchema ?? empty,
4832
+ outputSchema: op.outputSchema ?? empty,
4833
+ streamConfig: op.streamConfig ?? empty,
4834
+ quotas: op.quotas ?? empty,
4835
+ retryPolicy: op.retryPolicy ?? empty,
4836
+ precondition: op.precondition ?? empty,
4828
4837
  isActive: op.isActive
4829
4838
  });
4830
4839
  summary.operations.updated++;
@@ -52,7 +52,24 @@ interface QuotaRule {
52
52
  condition?: Record<string, unknown>;
53
53
  /** Optional expiry — rule is ignored after this date (ISO 8601). */
54
54
  expiresAt?: string;
55
+ /** Custom message returned when this rule's quota is exhausted (e.g., upgrade CTA). */
56
+ message?: string;
55
57
  }
58
+ /** Segment-based precondition: blocks execution unless the customer belongs to the segment. */
59
+ interface SegmentPrecondition {
60
+ /** Key of the segment the customer must belong to. */
61
+ segmentKey: string;
62
+ /** Error message returned when the precondition fails (e.g., upgrade CTA). */
63
+ message?: string;
64
+ }
65
+ /** Rule-expression precondition: blocks execution unless the expression evaluates to true. */
66
+ interface ExpressionPrecondition {
67
+ /** Expression type — "condition" for a single rule, "group" for AND/OR groups. */
68
+ type: 'condition' | 'group';
69
+ [key: string]: unknown;
70
+ }
71
+ /** A precondition that must be met before an operation can execute. */
72
+ type Precondition = SegmentPrecondition | ExpressionPrecondition;
56
73
  interface ApplyConfigOperationInput {
57
74
  key: string;
58
75
  name: string;
@@ -76,7 +93,7 @@ interface ApplyConfigOperationInput {
76
93
  /** Roles allowed to execute this operation. */
77
94
  allowedRoles?: string[];
78
95
  /** Precondition that must be met before execution (e.g., segment membership). */
79
- precondition?: Record<string, unknown>;
96
+ precondition?: Precondition;
80
97
  }
81
98
  interface ApplyConfigSegmentInput {
82
99
  key: string;
@@ -187,4 +204,4 @@ declare function defineHook(hook: ApplyConfigHookInput): ApplyConfigHookInput;
187
204
  /** Define an editor placement (sidebar or main-editor tab). */
188
205
  declare function definePlacement(placement: ApplyConfigPlacementInput): ApplyConfigPlacementInput;
189
206
 
190
- export { type ApplyConfigApiKeyInput, type ApplyConfigAuthProviderInput, type ApplyConfigHookInput, type ApplyConfigInput, type ApplyConfigModelInput, type ApplyConfigOperationInput, type ApplyConfigPlacementInput, type ApplyConfigScheduleInput, type ApplyConfigSegmentInput, type FieldDefinitionInput, type QuotaRule, defineAuthProvider, defineConfig, defineExtension, defineField, defineHook, defineModel, defineOperation, definePlacement, defineSchedule, defineSegment };
207
+ export { type ApplyConfigApiKeyInput, type ApplyConfigAuthProviderInput, type ApplyConfigHookInput, type ApplyConfigInput, type ApplyConfigModelInput, type ApplyConfigOperationInput, type ApplyConfigPlacementInput, type ApplyConfigScheduleInput, type ApplyConfigSegmentInput, type ExpressionPrecondition, type FieldDefinitionInput, type Precondition, type QuotaRule, type SegmentPrecondition, defineAuthProvider, defineConfig, defineExtension, defineField, defineHook, defineModel, defineOperation, definePlacement, defineSchedule, defineSegment };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eide/foir-cli",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "description": "Universal platform CLI for Foir platform",
5
5
  "type": "module",
6
6
  "publishConfig": {