@segmentstream/ontology 0.147.0 → 0.148.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.
@@ -292,8 +292,8 @@ export declare const MigrationPlan: Schema.Struct<{
292
292
  readonly target: Schema.declareConstructor<{
293
293
  readonly version: number;
294
294
  readonly roles: readonly {
295
- readonly name: string;
296
295
  readonly description: string;
296
+ readonly name: string;
297
297
  readonly builtIn: boolean;
298
298
  readonly scopes?: readonly {
299
299
  readonly permission: string;
@@ -306,8 +306,8 @@ export declare const MigrationPlan: Schema.Struct<{
306
306
  readonly hash: string;
307
307
  readonly entities: readonly {
308
308
  readonly id: string;
309
- readonly name: string;
310
309
  readonly description: string;
310
+ readonly name: string;
311
311
  readonly label: string;
312
312
  readonly properties: readonly {
313
313
  readonly optional: boolean;
@@ -336,8 +336,8 @@ export declare const MigrationPlan: Schema.Struct<{
336
336
  readonly items?: "number" | "boolean" | "email" | "text" | "url" | "date" | "timestamp" | "select" | "integer" | "json" | "blob" | "list" | undefined;
337
337
  }[];
338
338
  readonly relationships: readonly {
339
- readonly name: string;
340
339
  readonly description: string;
340
+ readonly name: string;
341
341
  readonly to: string;
342
342
  readonly cardinality: "one" | "many";
343
343
  readonly phrase: readonly [string, string];
@@ -355,8 +355,8 @@ export declare const MigrationPlan: Schema.Struct<{
355
355
  readonly unique: boolean;
356
356
  }[];
357
357
  readonly actions: readonly {
358
- readonly name: string;
359
358
  readonly description: string;
359
+ readonly name: string;
360
360
  readonly input: {
361
361
  readonly [x: string]: Schema.Json;
362
362
  };
@@ -385,8 +385,8 @@ export declare const MigrationPlan: Schema.Struct<{
385
385
  readonly currency?: string | undefined;
386
386
  } | undefined;
387
387
  readonly metrics?: readonly {
388
- readonly name: string;
389
388
  readonly description: string;
389
+ readonly name: string;
390
390
  readonly label: string;
391
391
  readonly unit: "number" | "currency" | "ratio" | "percent";
392
392
  readonly format: "decimal" | "currency" | "percent";
@@ -430,8 +430,8 @@ export declare const MigrationPlan: Schema.Struct<{
430
430
  } | undefined;
431
431
  } | undefined;
432
432
  readonly workflows?: readonly {
433
- readonly name: string;
434
433
  readonly description: string;
434
+ readonly name: string;
435
435
  readonly input: {
436
436
  readonly [x: string]: Schema.Json;
437
437
  };
@@ -446,13 +446,13 @@ export declare const MigrationPlan: Schema.Struct<{
446
446
  } | {
447
447
  readonly kind: "action";
448
448
  readonly entity: string;
449
- readonly name: string;
450
449
  readonly description: string;
450
+ readonly name: string;
451
451
  readonly action?: string | undefined;
452
452
  } | {
453
453
  readonly kind: "webhook";
454
- readonly name: string;
455
454
  readonly description: string;
455
+ readonly name: string;
456
456
  readonly connection?: string | undefined;
457
457
  readonly headers?: readonly string[] | undefined;
458
458
  readonly signature?: {
@@ -622,8 +622,8 @@ export declare const MigrationPlan: Schema.Struct<{
622
622
  };
623
623
  }[];
624
624
  readonly actions: readonly {
625
- readonly name: string;
626
625
  readonly description: string;
626
+ readonly name: string;
627
627
  readonly input: {
628
628
  readonly [x: string]: Schema.Json;
629
629
  };
@@ -647,8 +647,8 @@ export declare const MigrationPlan: Schema.Struct<{
647
647
  } | {
648
648
  readonly version: number;
649
649
  readonly roles: readonly {
650
- readonly name: string;
651
650
  readonly description: string;
651
+ readonly name: string;
652
652
  readonly builtIn: boolean;
653
653
  readonly scopes?: readonly {
654
654
  readonly permission: string;
@@ -661,8 +661,8 @@ export declare const MigrationPlan: Schema.Struct<{
661
661
  readonly hash: string;
662
662
  readonly entities: readonly {
663
663
  readonly id: string;
664
- readonly name: string;
665
664
  readonly description: string;
665
+ readonly name: string;
666
666
  readonly label: string;
667
667
  readonly properties: readonly {
668
668
  readonly optional: boolean;
@@ -691,8 +691,8 @@ export declare const MigrationPlan: Schema.Struct<{
691
691
  readonly items?: "number" | "boolean" | "email" | "text" | "url" | "date" | "timestamp" | "select" | "integer" | "json" | "blob" | "list" | undefined;
692
692
  }[];
693
693
  readonly relationships: readonly {
694
- readonly name: string;
695
694
  readonly description: string;
695
+ readonly name: string;
696
696
  readonly to: string;
697
697
  readonly cardinality: "one" | "many";
698
698
  readonly phrase: readonly [string, string];
@@ -710,8 +710,8 @@ export declare const MigrationPlan: Schema.Struct<{
710
710
  readonly unique: boolean;
711
711
  }[];
712
712
  readonly actions: readonly {
713
- readonly name: string;
714
713
  readonly description: string;
714
+ readonly name: string;
715
715
  readonly input: {
716
716
  readonly [x: string]: Schema.Json;
717
717
  };
@@ -740,8 +740,8 @@ export declare const MigrationPlan: Schema.Struct<{
740
740
  readonly currency?: string | undefined;
741
741
  } | undefined;
742
742
  readonly metrics?: readonly {
743
- readonly name: string;
744
743
  readonly description: string;
744
+ readonly name: string;
745
745
  readonly label: string;
746
746
  readonly unit: "number" | "currency" | "ratio" | "percent";
747
747
  readonly format: "decimal" | "currency" | "percent";
@@ -785,8 +785,8 @@ export declare const MigrationPlan: Schema.Struct<{
785
785
  } | undefined;
786
786
  } | undefined;
787
787
  readonly workflows?: readonly {
788
- readonly name: string;
789
788
  readonly description: string;
789
+ readonly name: string;
790
790
  readonly input: {
791
791
  readonly [x: string]: Schema.Json;
792
792
  };
@@ -801,13 +801,13 @@ export declare const MigrationPlan: Schema.Struct<{
801
801
  } | {
802
802
  readonly kind: "action";
803
803
  readonly entity: string;
804
- readonly name: string;
805
804
  readonly description: string;
805
+ readonly name: string;
806
806
  readonly action?: string | undefined;
807
807
  } | {
808
808
  readonly kind: "webhook";
809
- readonly name: string;
810
809
  readonly description: string;
810
+ readonly name: string;
811
811
  readonly connection?: string | undefined;
812
812
  readonly headers?: readonly string[] | undefined;
813
813
  readonly signature?: {
@@ -977,8 +977,8 @@ export declare const MigrationPlan: Schema.Struct<{
977
977
  };
978
978
  }[];
979
979
  readonly actions: readonly {
980
- readonly name: string;
981
980
  readonly description: string;
981
+ readonly name: string;
982
982
  readonly input: {
983
983
  readonly [x: string]: Schema.Json;
984
984
  };
@@ -1002,8 +1002,8 @@ export declare const MigrationPlan: Schema.Struct<{
1002
1002
  }, {
1003
1003
  readonly version: number;
1004
1004
  readonly roles: readonly {
1005
- readonly name: string;
1006
1005
  readonly description: string;
1006
+ readonly name: string;
1007
1007
  readonly built_in: boolean;
1008
1008
  readonly scopes?: readonly {
1009
1009
  readonly permission: string;
@@ -1016,8 +1016,8 @@ export declare const MigrationPlan: Schema.Struct<{
1016
1016
  readonly hash: string;
1017
1017
  readonly entities: readonly {
1018
1018
  readonly id: string;
1019
- readonly name: string;
1020
1019
  readonly description: string;
1020
+ readonly name: string;
1021
1021
  readonly label: string;
1022
1022
  readonly properties: readonly {
1023
1023
  readonly optional: boolean;
@@ -1046,8 +1046,8 @@ export declare const MigrationPlan: Schema.Struct<{
1046
1046
  readonly exclude_from_replication?: boolean | undefined;
1047
1047
  }[];
1048
1048
  readonly relationships: readonly {
1049
- readonly name: string;
1050
1049
  readonly description: string;
1050
+ readonly name: string;
1051
1051
  readonly to: string;
1052
1052
  readonly cardinality: "one" | "many";
1053
1053
  readonly phrase: readonly [string, string];
@@ -1065,8 +1065,8 @@ export declare const MigrationPlan: Schema.Struct<{
1065
1065
  readonly unique: boolean;
1066
1066
  }[];
1067
1067
  readonly actions: readonly {
1068
- readonly name: string;
1069
1068
  readonly description: string;
1069
+ readonly name: string;
1070
1070
  readonly input: {
1071
1071
  readonly [x: string]: Schema.Json;
1072
1072
  };
@@ -1095,8 +1095,8 @@ export declare const MigrationPlan: Schema.Struct<{
1095
1095
  readonly currency?: string | undefined;
1096
1096
  } | undefined;
1097
1097
  readonly metrics?: readonly {
1098
- readonly name: string;
1099
1098
  readonly description: string;
1099
+ readonly name: string;
1100
1100
  readonly label: string;
1101
1101
  readonly unit: "number" | "currency" | "ratio" | "percent";
1102
1102
  readonly format: "decimal" | "currency" | "percent";
@@ -1140,8 +1140,8 @@ export declare const MigrationPlan: Schema.Struct<{
1140
1140
  } | undefined;
1141
1141
  } | undefined;
1142
1142
  readonly workflows?: readonly {
1143
- readonly name: string;
1144
1143
  readonly description: string;
1144
+ readonly name: string;
1145
1145
  readonly input: {
1146
1146
  readonly [x: string]: Schema.Json;
1147
1147
  };
@@ -1158,13 +1158,13 @@ export declare const MigrationPlan: Schema.Struct<{
1158
1158
  } | {
1159
1159
  readonly kind: "action";
1160
1160
  readonly entity: string;
1161
- readonly name: string;
1162
1161
  readonly description: string;
1162
+ readonly name: string;
1163
1163
  readonly action?: string | undefined;
1164
1164
  } | {
1165
1165
  readonly kind: "webhook";
1166
- readonly name: string;
1167
1166
  readonly description: string;
1167
+ readonly name: string;
1168
1168
  readonly connection?: string | undefined;
1169
1169
  readonly headers?: readonly string[] | undefined;
1170
1170
  readonly signature?: {
@@ -1295,8 +1295,8 @@ export declare const MigrationPlan: Schema.Struct<{
1295
1295
  };
1296
1296
  }[];
1297
1297
  readonly actions: readonly {
1298
- readonly name: string;
1299
1298
  readonly description: string;
1299
+ readonly name: string;
1300
1300
  readonly input: {
1301
1301
  readonly [x: string]: Schema.Json;
1302
1302
  };
@@ -1357,8 +1357,8 @@ export declare const MigrationPlan: Schema.Struct<{
1357
1357
  } | {
1358
1358
  readonly version: number;
1359
1359
  readonly roles: readonly {
1360
- readonly name: string;
1361
1360
  readonly description: string;
1361
+ readonly name: string;
1362
1362
  readonly builtIn: boolean;
1363
1363
  readonly scopes?: readonly {
1364
1364
  readonly permission: string;
@@ -1371,8 +1371,8 @@ export declare const MigrationPlan: Schema.Struct<{
1371
1371
  readonly hash: string;
1372
1372
  readonly entities: readonly {
1373
1373
  readonly id: string;
1374
- readonly name: string;
1375
1374
  readonly description: string;
1375
+ readonly name: string;
1376
1376
  readonly label: string;
1377
1377
  readonly properties: readonly {
1378
1378
  readonly optional: boolean;
@@ -1401,8 +1401,8 @@ export declare const MigrationPlan: Schema.Struct<{
1401
1401
  readonly items?: "number" | "boolean" | "email" | "text" | "url" | "date" | "timestamp" | "select" | "integer" | "json" | "blob" | "list" | undefined;
1402
1402
  }[];
1403
1403
  readonly relationships: readonly {
1404
- readonly name: string;
1405
1404
  readonly description: string;
1405
+ readonly name: string;
1406
1406
  readonly to: string;
1407
1407
  readonly cardinality: "one" | "many";
1408
1408
  readonly phrase: readonly [string, string];
@@ -1420,8 +1420,8 @@ export declare const MigrationPlan: Schema.Struct<{
1420
1420
  readonly unique: boolean;
1421
1421
  }[];
1422
1422
  readonly actions: readonly {
1423
- readonly name: string;
1424
1423
  readonly description: string;
1424
+ readonly name: string;
1425
1425
  readonly input: {
1426
1426
  readonly [x: string]: Schema.Json;
1427
1427
  };
@@ -1450,8 +1450,8 @@ export declare const MigrationPlan: Schema.Struct<{
1450
1450
  readonly currency?: string | undefined;
1451
1451
  } | undefined;
1452
1452
  readonly metrics?: readonly {
1453
- readonly name: string;
1454
1453
  readonly description: string;
1454
+ readonly name: string;
1455
1455
  readonly label: string;
1456
1456
  readonly unit: "number" | "currency" | "ratio" | "percent";
1457
1457
  readonly format: "decimal" | "currency" | "percent";
@@ -1495,8 +1495,8 @@ export declare const MigrationPlan: Schema.Struct<{
1495
1495
  } | undefined;
1496
1496
  } | undefined;
1497
1497
  readonly workflows?: readonly {
1498
- readonly name: string;
1499
1498
  readonly description: string;
1499
+ readonly name: string;
1500
1500
  readonly input: {
1501
1501
  readonly [x: string]: Schema.Json;
1502
1502
  };
@@ -1513,13 +1513,13 @@ export declare const MigrationPlan: Schema.Struct<{
1513
1513
  } | {
1514
1514
  readonly kind: "action";
1515
1515
  readonly entity: string;
1516
- readonly name: string;
1517
1516
  readonly description: string;
1517
+ readonly name: string;
1518
1518
  readonly action?: string | undefined;
1519
1519
  } | {
1520
1520
  readonly kind: "webhook";
1521
- readonly name: string;
1522
1521
  readonly description: string;
1522
+ readonly name: string;
1523
1523
  readonly connection?: string | undefined;
1524
1524
  readonly headers?: readonly string[] | undefined;
1525
1525
  readonly signature?: {
@@ -1687,8 +1687,8 @@ export declare const MigrationPlan: Schema.Struct<{
1687
1687
  };
1688
1688
  }[];
1689
1689
  readonly actions: readonly {
1690
- readonly name: string;
1691
1690
  readonly description: string;
1691
+ readonly name: string;
1692
1692
  readonly input: {
1693
1693
  readonly [x: string]: Schema.Json;
1694
1694
  };
@@ -2428,8 +2428,8 @@ export declare const MigrationPlan: Schema.Struct<{
2428
2428
  }>]>], {
2429
2429
  readonly version: number;
2430
2430
  readonly roles: readonly {
2431
- readonly name: string;
2432
2431
  readonly description: string;
2432
+ readonly name: string;
2433
2433
  readonly builtIn: boolean;
2434
2434
  readonly scopes?: readonly {
2435
2435
  readonly permission: string;
@@ -2442,8 +2442,8 @@ export declare const MigrationPlan: Schema.Struct<{
2442
2442
  readonly hash: string;
2443
2443
  readonly entities: readonly {
2444
2444
  readonly id: string;
2445
- readonly name: string;
2446
2445
  readonly description: string;
2446
+ readonly name: string;
2447
2447
  readonly label: string;
2448
2448
  readonly properties: readonly {
2449
2449
  readonly optional: boolean;
@@ -2472,8 +2472,8 @@ export declare const MigrationPlan: Schema.Struct<{
2472
2472
  readonly items?: "number" | "boolean" | "email" | "text" | "url" | "date" | "timestamp" | "select" | "integer" | "json" | "blob" | "list" | undefined;
2473
2473
  }[];
2474
2474
  readonly relationships: readonly {
2475
- readonly name: string;
2476
2475
  readonly description: string;
2476
+ readonly name: string;
2477
2477
  readonly to: string;
2478
2478
  readonly cardinality: "one" | "many";
2479
2479
  readonly phrase: readonly [string, string];
@@ -2491,8 +2491,8 @@ export declare const MigrationPlan: Schema.Struct<{
2491
2491
  readonly unique: boolean;
2492
2492
  }[];
2493
2493
  readonly actions: readonly {
2494
- readonly name: string;
2495
2494
  readonly description: string;
2495
+ readonly name: string;
2496
2496
  readonly input: {
2497
2497
  readonly [x: string]: Schema.Json;
2498
2498
  };
@@ -2521,8 +2521,8 @@ export declare const MigrationPlan: Schema.Struct<{
2521
2521
  readonly currency?: string | undefined;
2522
2522
  } | undefined;
2523
2523
  readonly metrics?: readonly {
2524
- readonly name: string;
2525
2524
  readonly description: string;
2525
+ readonly name: string;
2526
2526
  readonly label: string;
2527
2527
  readonly unit: "number" | "currency" | "ratio" | "percent";
2528
2528
  readonly format: "decimal" | "currency" | "percent";
@@ -2566,8 +2566,8 @@ export declare const MigrationPlan: Schema.Struct<{
2566
2566
  } | undefined;
2567
2567
  } | undefined;
2568
2568
  readonly workflows?: readonly {
2569
- readonly name: string;
2570
2569
  readonly description: string;
2570
+ readonly name: string;
2571
2571
  readonly input: {
2572
2572
  readonly [x: string]: Schema.Json;
2573
2573
  };
@@ -2582,13 +2582,13 @@ export declare const MigrationPlan: Schema.Struct<{
2582
2582
  } | {
2583
2583
  readonly kind: "action";
2584
2584
  readonly entity: string;
2585
- readonly name: string;
2586
2585
  readonly description: string;
2586
+ readonly name: string;
2587
2587
  readonly action?: string | undefined;
2588
2588
  } | {
2589
2589
  readonly kind: "webhook";
2590
- readonly name: string;
2591
2590
  readonly description: string;
2591
+ readonly name: string;
2592
2592
  readonly connection?: string | undefined;
2593
2593
  readonly headers?: readonly string[] | undefined;
2594
2594
  readonly signature?: {
@@ -2758,8 +2758,8 @@ export declare const MigrationPlan: Schema.Struct<{
2758
2758
  };
2759
2759
  }[];
2760
2760
  readonly actions: readonly {
2761
- readonly name: string;
2762
2761
  readonly description: string;
2762
+ readonly name: string;
2763
2763
  readonly input: {
2764
2764
  readonly [x: string]: Schema.Json;
2765
2765
  };
@@ -2783,8 +2783,8 @@ export declare const MigrationPlan: Schema.Struct<{
2783
2783
  } | {
2784
2784
  readonly version: number;
2785
2785
  readonly roles: readonly {
2786
- readonly name: string;
2787
2786
  readonly description: string;
2787
+ readonly name: string;
2788
2788
  readonly builtIn: boolean;
2789
2789
  readonly scopes?: readonly {
2790
2790
  readonly permission: string;
@@ -2797,8 +2797,8 @@ export declare const MigrationPlan: Schema.Struct<{
2797
2797
  readonly hash: string;
2798
2798
  readonly entities: readonly {
2799
2799
  readonly id: string;
2800
- readonly name: string;
2801
2800
  readonly description: string;
2801
+ readonly name: string;
2802
2802
  readonly label: string;
2803
2803
  readonly properties: readonly {
2804
2804
  readonly optional: boolean;
@@ -2827,8 +2827,8 @@ export declare const MigrationPlan: Schema.Struct<{
2827
2827
  readonly items?: "number" | "boolean" | "email" | "text" | "url" | "date" | "timestamp" | "select" | "integer" | "json" | "blob" | "list" | undefined;
2828
2828
  }[];
2829
2829
  readonly relationships: readonly {
2830
- readonly name: string;
2831
2830
  readonly description: string;
2831
+ readonly name: string;
2832
2832
  readonly to: string;
2833
2833
  readonly cardinality: "one" | "many";
2834
2834
  readonly phrase: readonly [string, string];
@@ -2846,8 +2846,8 @@ export declare const MigrationPlan: Schema.Struct<{
2846
2846
  readonly unique: boolean;
2847
2847
  }[];
2848
2848
  readonly actions: readonly {
2849
- readonly name: string;
2850
2849
  readonly description: string;
2850
+ readonly name: string;
2851
2851
  readonly input: {
2852
2852
  readonly [x: string]: Schema.Json;
2853
2853
  };
@@ -2876,8 +2876,8 @@ export declare const MigrationPlan: Schema.Struct<{
2876
2876
  readonly currency?: string | undefined;
2877
2877
  } | undefined;
2878
2878
  readonly metrics?: readonly {
2879
- readonly name: string;
2880
2879
  readonly description: string;
2880
+ readonly name: string;
2881
2881
  readonly label: string;
2882
2882
  readonly unit: "number" | "currency" | "ratio" | "percent";
2883
2883
  readonly format: "decimal" | "currency" | "percent";
@@ -2921,8 +2921,8 @@ export declare const MigrationPlan: Schema.Struct<{
2921
2921
  } | undefined;
2922
2922
  } | undefined;
2923
2923
  readonly workflows?: readonly {
2924
- readonly name: string;
2925
2924
  readonly description: string;
2925
+ readonly name: string;
2926
2926
  readonly input: {
2927
2927
  readonly [x: string]: Schema.Json;
2928
2928
  };
@@ -2937,13 +2937,13 @@ export declare const MigrationPlan: Schema.Struct<{
2937
2937
  } | {
2938
2938
  readonly kind: "action";
2939
2939
  readonly entity: string;
2940
- readonly name: string;
2941
2940
  readonly description: string;
2941
+ readonly name: string;
2942
2942
  readonly action?: string | undefined;
2943
2943
  } | {
2944
2944
  readonly kind: "webhook";
2945
- readonly name: string;
2946
2945
  readonly description: string;
2946
+ readonly name: string;
2947
2947
  readonly connection?: string | undefined;
2948
2948
  readonly headers?: readonly string[] | undefined;
2949
2949
  readonly signature?: {
@@ -3113,8 +3113,8 @@ export declare const MigrationPlan: Schema.Struct<{
3113
3113
  };
3114
3114
  }[];
3115
3115
  readonly actions: readonly {
3116
- readonly name: string;
3117
3116
  readonly description: string;
3117
+ readonly name: string;
3118
3118
  readonly input: {
3119
3119
  readonly [x: string]: Schema.Json;
3120
3120
  };
@@ -596,6 +596,7 @@ function prepare(ontology, sql, action, context, connections, qualified, fileInv
596
596
  resolve: (reference, principal) => resolveFileRecord({ manifest: ontology.manifest, reads, reference, principal }),
597
597
  }), Effect.provideContext(connectionContext(action.connections, transport ?? NO_CONNECTIONS, {
598
598
  readOnly: action.hints?.readOnly === true || action.hints?.connectionsReadOnly === true,
599
+ files,
599
600
  })), Effect.timeoutOrElse({
600
601
  duration: PREPARE_TIMEOUT,
601
602
  orElse: () => Effect.fail(new ConnectionError({
@@ -1,10 +1,17 @@
1
1
  import { Effect, type Scope } from "effect";
2
2
  import { ConnectionError, type ConnectionReply, type ConnectionStreamReply } from "../connection.js";
3
3
  export declare const CONNECTION_STREAM_MEDIA_TYPE = "application/vnd.segmentstream.proxy-stream.v1+ndjson";
4
+ /**
5
+ * The extra time a call that sends a stored file allows backend-next to read it from file
6
+ * storage before the provider request starts; backend-next's read deadline matches it.
7
+ */
8
+ export declare const STORED_FILE_READ_MS = 15000;
4
9
  /** Negotiates once; never retries a provider operation to change response formats. */
5
10
  export declare function openConnectionStream(input: {
6
11
  readonly connection: string;
7
12
  readonly request: (signal: AbortSignal) => Promise<Response>;
8
13
  readonly legacy: (value: unknown) => ConnectionReply;
9
14
  readonly refusal: (status: number, value: unknown, cause?: unknown) => ConnectionError;
15
+ /** Whether backend-next reads the body from file storage first, which takes longer. */
16
+ readonly storedFile?: boolean;
10
17
  }): Effect.Effect<ConnectionStreamReply, ConnectionError, Scope.Scope>;
@@ -5,6 +5,11 @@ const MAX_FRAME_BYTES = 128 * 1024;
5
5
  const MAX_CHUNK_BYTES = 65_536;
6
6
  const MAX_LEGACY_BYTES = 4 * 1024 * 1024;
7
7
  const CALL_TIMEOUT_MS = 40_000;
8
+ /**
9
+ * The extra time a call that sends a stored file allows backend-next to read it from file
10
+ * storage before the provider request starts; backend-next's read deadline matches it.
11
+ */
12
+ export const STORED_FILE_READ_MS = 15_000;
8
13
  function invalid(connection, cause) {
9
14
  return new ConnectionError({
10
15
  connection,
@@ -69,7 +74,10 @@ async function* frames(reader, connection) {
69
74
  export function openConnectionStream(input) {
70
75
  return Effect.gen(function* () {
71
76
  const controller = yield* Effect.acquireRelease(Effect.sync(() => new AbortController()), (controller) => Effect.sync(() => controller.abort()));
72
- const signal = AbortSignal.any([controller.signal, AbortSignal.timeout(CALL_TIMEOUT_MS)]);
77
+ const signal = AbortSignal.any([
78
+ controller.signal,
79
+ AbortSignal.timeout(CALL_TIMEOUT_MS + (input.storedFile === true ? STORED_FILE_READ_MS : 0)),
80
+ ]);
73
81
  const failure = (cause) => {
74
82
  if (cause instanceof ConnectionError) {
75
83
  return cause;
@@ -104,9 +104,59 @@ function collected(connection, reply) {
104
104
  body: new Uint8Array(Buffer.concat(chunks)),
105
105
  })));
106
106
  }
107
- /** Shared admission and wire requests for buffered and streamed responses. */
108
- function transport(fetchImpl, resolve) {
109
- const open = (call) => resolve(call).pipe(Effect.flatMap((selected) => openConnectionStream({
107
+ /**
108
+ * A file's signed byte range, read by this process: the local proxy route takes no file, so a
109
+ * request run with `segmentstream exec` sends it inline, within the 2 MiB body limit.
110
+ */
111
+ function readFileRange(fetchImpl, connection, source) {
112
+ const length = source.end - source.start + 1;
113
+ if (length > MAXIMUM_CONNECTION_BODY_BYTES) {
114
+ return Effect.fail(failure(connection, "invalid_request", "file_inline_too_large"));
115
+ }
116
+ return Effect.tryPromise({
117
+ try: async (signal) => {
118
+ const response = await fetchImpl(source.url, {
119
+ headers: { ...source.headers, range: `bytes=${source.start}-${source.end}` },
120
+ redirect: "error",
121
+ signal,
122
+ });
123
+ const bytes = new Uint8Array(await response.arrayBuffer());
124
+ if (![200, 206].includes(response.status) || bytes.byteLength !== length) {
125
+ throw new Error(`file storage answered ${response.status} with ${bytes.byteLength} bytes`);
126
+ }
127
+ return bytes;
128
+ },
129
+ catch: (cause) => failure(connection, "unavailable", "file_storage_unavailable", undefined, cause),
130
+ });
131
+ }
132
+ /**
133
+ * Shared admission and wire requests for buffered and streamed responses. A deployed service
134
+ * sends a request's `file` as its signed read, which backend-next fetches from the workspace's
135
+ * file storage; `inlineFiles` reads it here instead and sends its bytes.
136
+ */
137
+ function transport(fetchImpl, resolve, options = {}) {
138
+ const payload = (call) => Effect.gen(function* () {
139
+ const source = call.source;
140
+ if (call.file !== undefined && source === undefined) {
141
+ return yield* Effect.fail(failure(call.connection, "invalid_request", "file_storage_unavailable"));
142
+ }
143
+ if (source === undefined) {
144
+ return { body: Buffer.from(call.body).toString("base64") };
145
+ }
146
+ if (options.inlineFiles === true) {
147
+ const bytes = yield* readFileRange(fetchImpl, call.connection, source);
148
+ return { body: Buffer.from(bytes).toString("base64") };
149
+ }
150
+ return {
151
+ file: {
152
+ url: source.url,
153
+ headers: Object.entries(source.headers),
154
+ start: source.start,
155
+ end: source.end,
156
+ },
157
+ };
158
+ });
159
+ const open = (call) => Effect.all([resolve(call), payload(call)]).pipe(Effect.flatMap(([selected, content]) => openConnectionStream({
110
160
  connection: call.connection,
111
161
  request: (signal) => fetchImpl(selected.url, {
112
162
  method: "POST",
@@ -120,13 +170,14 @@ function transport(fetchImpl, resolve) {
120
170
  method: selected.call.method,
121
171
  path: selected.call.path,
122
172
  headers: selected.call.headers,
123
- body: Buffer.from(selected.call.body).toString("base64"),
173
+ ...content,
124
174
  }),
125
175
  redirect: "error",
126
176
  signal,
127
177
  }),
128
178
  legacy: (value) => reply(call.connection, value),
129
179
  refusal: (status, value, cause) => refusal(call.connection, status, value, cause),
180
+ storedFile: "file" in content,
130
181
  })));
131
182
  return {
132
183
  request: (call) => open(call).pipe(Effect.flatMap((reply) => collected(call.connection, reply)), Effect.scoped),
@@ -183,7 +234,7 @@ export function localConnections(context, fetchImpl = fetch) {
183
234
  headers: { "x-segmentstream-connection-grant": context.proxyGrant },
184
235
  call: { ...call, api },
185
236
  });
186
- });
237
+ }, { inlineFiles: true });
187
238
  }
188
239
  function localConnection(value) {
189
240
  if (!isRecord(value) ||
@@ -12,8 +12,8 @@ export declare function normalizeSearch(text: string): string;
12
12
  /** Rank only caller-projected documents; forbidden fields never affect ranking or explanations. */
13
13
  export declare function searchDocuments(documents: ReadonlyArray<SearchDocument>, input: DiscoverInput): {
14
14
  readonly kind: "entity" | "metric" | "action";
15
- readonly name: string;
16
15
  readonly description: string;
16
+ readonly name: string;
17
17
  readonly label: string;
18
18
  readonly ref: string;
19
19
  readonly matched_on: readonly {
@@ -972,19 +972,20 @@ export function workflowsLayer(options) {
972
972
  "ConnectionError",
973
973
  ])),
974
974
  });
975
- const services = Context.make(OntologyReads, reads).pipe(Context.add(Files, backend.blobs?.files?.({
975
+ const files = backend.blobs?.files?.({
976
976
  principal,
977
977
  idempotencyKey: createHash("sha256")
978
978
  .update(`${step.workflowRunId}:${step.stepId}`)
979
979
  .digest("hex"),
980
- }) ?? unavailableFiles), Context.add(OntologyWrites, writes), Context.add(OntologyActions, actions), Context.merge(connectionContext(workflow.declaration.connections, options.connections({
980
+ }) ?? unavailableFiles;
981
+ const services = Context.make(OntologyReads, reads).pipe(Context.add(Files, files), Context.add(OntologyWrites, writes), Context.add(OntologyActions, actions), Context.merge(connectionContext(workflow.declaration.connections, options.connections({
981
982
  identityToken,
982
983
  audit: {
983
984
  action: `workflow.${workflow.manifest.name}`,
984
985
  principalId: principal.id,
985
986
  requestId,
986
987
  },
987
- }))));
988
+ }), { files })));
988
989
  console.info(JSON.stringify({
989
990
  event: "ontology.workflow.step.started",
990
991
  workflow: workflow.manifest.name,