@ductape/sdk 0.1.152 → 0.1.153

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.
@@ -398,10 +398,33 @@ export interface IFeatureFunctionsContext {
398
398
  /** Invoke a contract operation without creating a client variable. */
399
399
  invoke<TOutput = unknown>(contract: IPortableFunctionContract, operation: string, input: Record<string, unknown>): Promise<TOutput>;
400
400
  }
401
+ /** Serializable condition produced by ctx.when and consumed by ctx.branch. */
402
+ export interface IFeatureCondition {
403
+ readonly expression: string;
404
+ readonly inverse: string;
405
+ }
406
+ export interface IFeatureConditionContext {
407
+ eq(left: unknown, right: unknown): IFeatureCondition;
408
+ ne(left: unknown, right: unknown): IFeatureCondition;
409
+ gt(left: unknown, right: unknown): IFeatureCondition;
410
+ gte(left: unknown, right: unknown): IFeatureCondition;
411
+ lt(left: unknown, right: unknown): IFeatureCondition;
412
+ lte(left: unknown, right: unknown): IFeatureCondition;
413
+ truthy(value: unknown): IFeatureCondition;
414
+ falsy(value: unknown): IFeatureCondition;
415
+ and(...conditions: IFeatureCondition[]): IFeatureCondition;
416
+ or(...conditions: IFeatureCondition[]): IFeatureCondition;
417
+ }
418
+ export interface IFeatureBranchHandlers {
419
+ then: () => Promise<unknown> | unknown;
420
+ else?: () => Promise<unknown> | unknown;
421
+ }
401
422
  /**
402
423
  * Transform context for data transformations
403
424
  */
404
425
  export interface ITransformContext {
426
+ /** Concatenate values at Feature execution time. */
427
+ concat(...parts: unknown[]): string;
405
428
  /** Get the number of keys in an object */
406
429
  size(obj: Record<string, unknown>): number;
407
430
  /** Get the length of an array or string */
@@ -422,6 +445,12 @@ export interface ITransformContext {
422
445
  join(arr: string[], separator: string): string;
423
446
  /** Get current timestamp */
424
447
  now(): number;
448
+ /** Generate a unique UUID at Feature execution time. */
449
+ uuid(): string;
450
+ /** Replace every occurrence at Feature execution time. */
451
+ replace(str: string, search: string, replacement: string): string;
452
+ /** Extract a substring at Feature execution time. */
453
+ substring(str: string, start: number, end: number): string;
425
454
  /** Format date */
426
455
  formatDate(date: Date | number | string, format: string): string;
427
456
  }
@@ -469,6 +498,15 @@ export interface IFeatureContext<TInput = Record<string, unknown>> {
469
498
  readonly session?: string;
470
499
  /** Step execution */
471
500
  step<T>(tag: string, handler: () => Promise<T>, rollback?: ((result: T) => Promise<void>) | null, options?: IFeatureStepOptions): Promise<T>;
501
+ /** Compile both paths into steps guarded by a portable runtime condition. */
502
+ branch(condition: IFeatureCondition, handlers: IFeatureBranchHandlers): Promise<void>;
503
+ /**
504
+ * Record a deterministic loop. The collection must come from ctx.sampleInput;
505
+ * use a portable function for runtime-sized collection algorithms.
506
+ */
507
+ each<T>(items: readonly T[], handler: (item: T, index: number) => Promise<void> | void): Promise<void>;
508
+ /** Build serializable runtime conditions for ctx.branch. */
509
+ readonly when: IFeatureConditionContext;
472
510
  /** Ductape components */
473
511
  action: IFeatureActionContext;
474
512
  /** Alias for action — preferred name for calling app actions */
@@ -1 +1 @@
1
- {"version":3,"file":"features.types.js","sourceRoot":"","sources":["../../../src/features/types/features.types.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uCAiBqB;AAwyCnB,gGAhzCA,uBAAe,OAgzCA;AACf,wGAhzCA,+BAAuB,OAgzCA;AACvB,8FAhzCA,qBAAa,OAgzCA"}
1
+ {"version":3,"file":"features.types.js","sourceRoot":"","sources":["../../../src/features/types/features.types.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uCAiBqB;AAo1CnB,gGA51CA,uBAAe,OA41CA;AACf,wGA51CA,+BAAuB,OA41CA;AACvB,8FA51CA,qBAAa,OA41CA"}