@treeseed/sdk 0.6.45 → 0.6.47

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.
@@ -139,7 +139,103 @@ export declare function deployProjectPlatform(options: ProjectPlatformActionOpti
139
139
  };
140
140
  railwayResources: {
141
141
  ok: boolean;
142
- checks: any[];
142
+ checks: ({
143
+ type: string;
144
+ service: string;
145
+ serviceName: string;
146
+ environment: string;
147
+ ok: boolean;
148
+ status: string;
149
+ observed: {
150
+ id: any;
151
+ status: string | null;
152
+ createdAt: any;
153
+ volumeMounts: any;
154
+ };
155
+ message: string | undefined;
156
+ } | {
157
+ type: string;
158
+ service: string;
159
+ serviceName: string;
160
+ environment: string;
161
+ ok: boolean;
162
+ status: string;
163
+ message: string;
164
+ observed?: undefined;
165
+ } | {
166
+ type: string;
167
+ service: string;
168
+ serviceName: string;
169
+ serviceId: string;
170
+ projectId: string;
171
+ environment: string;
172
+ environmentId: string;
173
+ instanceId: string | null;
174
+ ok: boolean;
175
+ status: string;
176
+ observed: {
177
+ rootDirectory: string | null;
178
+ startCommand: string | null;
179
+ cronSchedule: string | null;
180
+ sleepApplication: boolean | null;
181
+ runtimeMode: string | null;
182
+ id?: undefined;
183
+ name?: undefined;
184
+ instances?: undefined;
185
+ } | null;
186
+ message: string | undefined;
187
+ volumeName?: undefined;
188
+ mountPath?: undefined;
189
+ } | {
190
+ type: string;
191
+ service: string;
192
+ serviceName: string;
193
+ serviceId: string;
194
+ projectId: string;
195
+ environment: string;
196
+ environmentId: string;
197
+ volumeName: string;
198
+ mountPath: string;
199
+ ok: boolean;
200
+ status: string;
201
+ observed: {
202
+ id: string;
203
+ name: string;
204
+ instances: import("./railway-api.ts").RailwayVolumeInstanceSummary[];
205
+ rootDirectory?: undefined;
206
+ startCommand?: undefined;
207
+ cronSchedule?: undefined;
208
+ sleepApplication?: undefined;
209
+ runtimeMode?: undefined;
210
+ } | null;
211
+ message: string | undefined;
212
+ instanceId?: undefined;
213
+ } | {
214
+ id: string | null;
215
+ projectId: string;
216
+ serviceId: string;
217
+ environmentId: string;
218
+ ok: boolean;
219
+ status: string;
220
+ observed: {
221
+ expression: string | null;
222
+ command: string | null;
223
+ enabled: boolean;
224
+ } | null;
225
+ message: string | undefined;
226
+ service: string;
227
+ projectName: string;
228
+ serviceName: string;
229
+ environment: string;
230
+ expression: string;
231
+ command: string | null;
232
+ enabled: boolean;
233
+ logicalName: string;
234
+ type: string;
235
+ instanceId?: undefined;
236
+ volumeName?: undefined;
237
+ mountPath?: undefined;
238
+ })[];
143
239
  } | {
144
240
  ok: boolean;
145
241
  skipped: boolean;
@@ -325,7 +421,103 @@ export declare function monitorProjectPlatform(options: ProjectPlatformActionOpt
325
421
  };
326
422
  railwayResources: {
327
423
  ok: boolean;
328
- checks: any[];
424
+ checks: ({
425
+ type: string;
426
+ service: string;
427
+ serviceName: string;
428
+ environment: string;
429
+ ok: boolean;
430
+ status: string;
431
+ observed: {
432
+ id: any;
433
+ status: string | null;
434
+ createdAt: any;
435
+ volumeMounts: any;
436
+ };
437
+ message: string | undefined;
438
+ } | {
439
+ type: string;
440
+ service: string;
441
+ serviceName: string;
442
+ environment: string;
443
+ ok: boolean;
444
+ status: string;
445
+ message: string;
446
+ observed?: undefined;
447
+ } | {
448
+ type: string;
449
+ service: string;
450
+ serviceName: string;
451
+ serviceId: string;
452
+ projectId: string;
453
+ environment: string;
454
+ environmentId: string;
455
+ instanceId: string | null;
456
+ ok: boolean;
457
+ status: string;
458
+ observed: {
459
+ rootDirectory: string | null;
460
+ startCommand: string | null;
461
+ cronSchedule: string | null;
462
+ sleepApplication: boolean | null;
463
+ runtimeMode: string | null;
464
+ id?: undefined;
465
+ name?: undefined;
466
+ instances?: undefined;
467
+ } | null;
468
+ message: string | undefined;
469
+ volumeName?: undefined;
470
+ mountPath?: undefined;
471
+ } | {
472
+ type: string;
473
+ service: string;
474
+ serviceName: string;
475
+ serviceId: string;
476
+ projectId: string;
477
+ environment: string;
478
+ environmentId: string;
479
+ volumeName: string;
480
+ mountPath: string;
481
+ ok: boolean;
482
+ status: string;
483
+ observed: {
484
+ id: string;
485
+ name: string;
486
+ instances: import("./railway-api.ts").RailwayVolumeInstanceSummary[];
487
+ rootDirectory?: undefined;
488
+ startCommand?: undefined;
489
+ cronSchedule?: undefined;
490
+ sleepApplication?: undefined;
491
+ runtimeMode?: undefined;
492
+ } | null;
493
+ message: string | undefined;
494
+ instanceId?: undefined;
495
+ } | {
496
+ id: string | null;
497
+ projectId: string;
498
+ serviceId: string;
499
+ environmentId: string;
500
+ ok: boolean;
501
+ status: string;
502
+ observed: {
503
+ expression: string | null;
504
+ command: string | null;
505
+ enabled: boolean;
506
+ } | null;
507
+ message: string | undefined;
508
+ service: string;
509
+ projectName: string;
510
+ serviceName: string;
511
+ environment: string;
512
+ expression: string;
513
+ command: string | null;
514
+ enabled: boolean;
515
+ logicalName: string;
516
+ type: string;
517
+ instanceId?: undefined;
518
+ volumeName?: undefined;
519
+ mountPath?: undefined;
520
+ })[];
329
521
  } | {
330
522
  ok: boolean;
331
523
  skipped: boolean;
@@ -516,7 +708,103 @@ export declare function runProjectPlatformAction(action: ProjectPlatformAction,
516
708
  };
517
709
  railwayResources: {
518
710
  ok: boolean;
519
- checks: any[];
711
+ checks: ({
712
+ type: string;
713
+ service: string;
714
+ serviceName: string;
715
+ environment: string;
716
+ ok: boolean;
717
+ status: string;
718
+ observed: {
719
+ id: any;
720
+ status: string | null;
721
+ createdAt: any;
722
+ volumeMounts: any;
723
+ };
724
+ message: string | undefined;
725
+ } | {
726
+ type: string;
727
+ service: string;
728
+ serviceName: string;
729
+ environment: string;
730
+ ok: boolean;
731
+ status: string;
732
+ message: string;
733
+ observed?: undefined;
734
+ } | {
735
+ type: string;
736
+ service: string;
737
+ serviceName: string;
738
+ serviceId: string;
739
+ projectId: string;
740
+ environment: string;
741
+ environmentId: string;
742
+ instanceId: string | null;
743
+ ok: boolean;
744
+ status: string;
745
+ observed: {
746
+ rootDirectory: string | null;
747
+ startCommand: string | null;
748
+ cronSchedule: string | null;
749
+ sleepApplication: boolean | null;
750
+ runtimeMode: string | null;
751
+ id?: undefined;
752
+ name?: undefined;
753
+ instances?: undefined;
754
+ } | null;
755
+ message: string | undefined;
756
+ volumeName?: undefined;
757
+ mountPath?: undefined;
758
+ } | {
759
+ type: string;
760
+ service: string;
761
+ serviceName: string;
762
+ serviceId: string;
763
+ projectId: string;
764
+ environment: string;
765
+ environmentId: string;
766
+ volumeName: string;
767
+ mountPath: string;
768
+ ok: boolean;
769
+ status: string;
770
+ observed: {
771
+ id: string;
772
+ name: string;
773
+ instances: import("./railway-api.ts").RailwayVolumeInstanceSummary[];
774
+ rootDirectory?: undefined;
775
+ startCommand?: undefined;
776
+ cronSchedule?: undefined;
777
+ sleepApplication?: undefined;
778
+ runtimeMode?: undefined;
779
+ } | null;
780
+ message: string | undefined;
781
+ instanceId?: undefined;
782
+ } | {
783
+ id: string | null;
784
+ projectId: string;
785
+ serviceId: string;
786
+ environmentId: string;
787
+ ok: boolean;
788
+ status: string;
789
+ observed: {
790
+ expression: string | null;
791
+ command: string | null;
792
+ enabled: boolean;
793
+ } | null;
794
+ message: string | undefined;
795
+ service: string;
796
+ projectName: string;
797
+ serviceName: string;
798
+ environment: string;
799
+ expression: string;
800
+ command: string | null;
801
+ enabled: boolean;
802
+ logicalName: string;
803
+ type: string;
804
+ instanceId?: undefined;
805
+ volumeName?: undefined;
806
+ mountPath?: undefined;
807
+ })[];
520
808
  } | {
521
809
  ok: boolean;
522
810
  skipped: boolean;
@@ -663,7 +951,103 @@ export declare function runProjectPlatformAction(action: ProjectPlatformAction,
663
951
  };
664
952
  railwayResources: {
665
953
  ok: boolean;
666
- checks: any[];
954
+ checks: ({
955
+ type: string;
956
+ service: string;
957
+ serviceName: string;
958
+ environment: string;
959
+ ok: boolean;
960
+ status: string;
961
+ observed: {
962
+ id: any;
963
+ status: string | null;
964
+ createdAt: any;
965
+ volumeMounts: any;
966
+ };
967
+ message: string | undefined;
968
+ } | {
969
+ type: string;
970
+ service: string;
971
+ serviceName: string;
972
+ environment: string;
973
+ ok: boolean;
974
+ status: string;
975
+ message: string;
976
+ observed?: undefined;
977
+ } | {
978
+ type: string;
979
+ service: string;
980
+ serviceName: string;
981
+ serviceId: string;
982
+ projectId: string;
983
+ environment: string;
984
+ environmentId: string;
985
+ instanceId: string | null;
986
+ ok: boolean;
987
+ status: string;
988
+ observed: {
989
+ rootDirectory: string | null;
990
+ startCommand: string | null;
991
+ cronSchedule: string | null;
992
+ sleepApplication: boolean | null;
993
+ runtimeMode: string | null;
994
+ id?: undefined;
995
+ name?: undefined;
996
+ instances?: undefined;
997
+ } | null;
998
+ message: string | undefined;
999
+ volumeName?: undefined;
1000
+ mountPath?: undefined;
1001
+ } | {
1002
+ type: string;
1003
+ service: string;
1004
+ serviceName: string;
1005
+ serviceId: string;
1006
+ projectId: string;
1007
+ environment: string;
1008
+ environmentId: string;
1009
+ volumeName: string;
1010
+ mountPath: string;
1011
+ ok: boolean;
1012
+ status: string;
1013
+ observed: {
1014
+ id: string;
1015
+ name: string;
1016
+ instances: import("./railway-api.ts").RailwayVolumeInstanceSummary[];
1017
+ rootDirectory?: undefined;
1018
+ startCommand?: undefined;
1019
+ cronSchedule?: undefined;
1020
+ sleepApplication?: undefined;
1021
+ runtimeMode?: undefined;
1022
+ } | null;
1023
+ message: string | undefined;
1024
+ instanceId?: undefined;
1025
+ } | {
1026
+ id: string | null;
1027
+ projectId: string;
1028
+ serviceId: string;
1029
+ environmentId: string;
1030
+ ok: boolean;
1031
+ status: string;
1032
+ observed: {
1033
+ expression: string | null;
1034
+ command: string | null;
1035
+ enabled: boolean;
1036
+ } | null;
1037
+ message: string | undefined;
1038
+ service: string;
1039
+ projectName: string;
1040
+ serviceName: string;
1041
+ environment: string;
1042
+ expression: string;
1043
+ command: string | null;
1044
+ enabled: boolean;
1045
+ logicalName: string;
1046
+ type: string;
1047
+ instanceId?: undefined;
1048
+ volumeName?: undefined;
1049
+ mountPath?: undefined;
1050
+ })[];
667
1051
  } | {
668
1052
  ok: boolean;
669
1053
  skipped: boolean;
@@ -43,11 +43,57 @@ export declare function waitForRailwayManagedDeploymentsSettled(tenantRoot: any,
43
43
  pollMs?: number | undefined;
44
44
  }): Promise<{
45
45
  ok: boolean;
46
- checks: any;
46
+ checks: ({
47
+ type: string;
48
+ service: string;
49
+ serviceName: string;
50
+ environment: string;
51
+ ok: boolean;
52
+ status: string;
53
+ observed: {
54
+ id: any;
55
+ status: string | null;
56
+ createdAt: any;
57
+ volumeMounts: any;
58
+ };
59
+ message: string | undefined;
60
+ } | {
61
+ type: string;
62
+ service: string;
63
+ serviceName: string;
64
+ environment: string;
65
+ ok: boolean;
66
+ status: string;
67
+ message: string;
68
+ observed?: undefined;
69
+ })[];
47
70
  message?: undefined;
48
71
  } | {
49
72
  ok: boolean;
50
- checks: any;
73
+ checks: ({
74
+ type: string;
75
+ service: string;
76
+ serviceName: string;
77
+ environment: string;
78
+ ok: boolean;
79
+ status: string;
80
+ observed: {
81
+ id: any;
82
+ status: string | null;
83
+ createdAt: any;
84
+ volumeMounts: any;
85
+ };
86
+ message: string | undefined;
87
+ } | {
88
+ type: string;
89
+ service: string;
90
+ serviceName: string;
91
+ environment: string;
92
+ ok: boolean;
93
+ status: string;
94
+ message: string;
95
+ observed?: undefined;
96
+ })[];
51
97
  message: string;
52
98
  }>;
53
99
  export declare function setRailwaySecretVariable({ cwd, service, environment, key, value, env, capture, allowFailure }: {
@@ -327,7 +373,103 @@ export declare function verifyRailwayManagedResources(tenantRoot: any, scope: an
327
373
  settlePollMs?: number | undefined;
328
374
  }): Promise<{
329
375
  ok: boolean;
330
- checks: any[];
376
+ checks: ({
377
+ type: string;
378
+ service: string;
379
+ serviceName: string;
380
+ environment: string;
381
+ ok: boolean;
382
+ status: string;
383
+ observed: {
384
+ id: any;
385
+ status: string | null;
386
+ createdAt: any;
387
+ volumeMounts: any;
388
+ };
389
+ message: string | undefined;
390
+ } | {
391
+ type: string;
392
+ service: string;
393
+ serviceName: string;
394
+ environment: string;
395
+ ok: boolean;
396
+ status: string;
397
+ message: string;
398
+ observed?: undefined;
399
+ } | {
400
+ type: string;
401
+ service: string;
402
+ serviceName: string;
403
+ serviceId: string;
404
+ projectId: string;
405
+ environment: string;
406
+ environmentId: string;
407
+ instanceId: string | null;
408
+ ok: boolean;
409
+ status: string;
410
+ observed: {
411
+ rootDirectory: string | null;
412
+ startCommand: string | null;
413
+ cronSchedule: string | null;
414
+ sleepApplication: boolean | null;
415
+ runtimeMode: string | null;
416
+ id?: undefined;
417
+ name?: undefined;
418
+ instances?: undefined;
419
+ } | null;
420
+ message: string | undefined;
421
+ volumeName?: undefined;
422
+ mountPath?: undefined;
423
+ } | {
424
+ type: string;
425
+ service: string;
426
+ serviceName: string;
427
+ serviceId: string;
428
+ projectId: string;
429
+ environment: string;
430
+ environmentId: string;
431
+ volumeName: string;
432
+ mountPath: string;
433
+ ok: boolean;
434
+ status: string;
435
+ observed: {
436
+ id: string;
437
+ name: string;
438
+ instances: import("./railway-api.ts").RailwayVolumeInstanceSummary[];
439
+ rootDirectory?: undefined;
440
+ startCommand?: undefined;
441
+ cronSchedule?: undefined;
442
+ sleepApplication?: undefined;
443
+ runtimeMode?: undefined;
444
+ } | null;
445
+ message: string | undefined;
446
+ instanceId?: undefined;
447
+ } | {
448
+ id: string | null;
449
+ projectId: string;
450
+ serviceId: string;
451
+ environmentId: string;
452
+ ok: boolean;
453
+ status: string;
454
+ observed: {
455
+ expression: string | null;
456
+ command: string | null;
457
+ enabled: boolean;
458
+ } | null;
459
+ message: string | undefined;
460
+ service: string;
461
+ projectName: string;
462
+ serviceName: string;
463
+ environment: string;
464
+ expression: string;
465
+ command: string | null;
466
+ enabled: boolean;
467
+ logicalName: string;
468
+ type: string;
469
+ instanceId?: undefined;
470
+ volumeName?: undefined;
471
+ mountPath?: undefined;
472
+ })[];
331
473
  }>;
332
474
  export declare function planRailwayServiceDeploy(service: any, { env }?: {
333
475
  env?: NodeJS.ProcessEnv | undefined;
@@ -396,32 +396,72 @@ async function waitForRailwayManagedDeploymentsSettled(tenantRoot, scope, {
396
396
  pollMs = 15e3
397
397
  } = {}) {
398
398
  const deadline = Date.now() + timeoutMs;
399
+ const environment = resolveRailwayEnvironmentForScope(scope);
400
+ const projectId = services.find((service) => typeof service.projectId === "string" && service.projectId.trim())?.projectId ?? null;
401
+ if (projectId) {
402
+ runRailway(["link", "--project", projectId, "--environment", environment, "--json"], {
403
+ cwd: tenantRoot,
404
+ capture: true,
405
+ allowFailure: true,
406
+ env
407
+ });
408
+ }
399
409
  let checks = [];
400
410
  let lastError = null;
401
411
  for (; ; ) {
402
- try {
403
- const result = runRailway(["status", "--json"], {
404
- cwd: tenantRoot,
405
- capture: true,
406
- env
407
- });
408
- const payload = parseRailwayJsonOutput(result.stdout);
409
- checks = collectRailwayDeploymentStatusChecks(payload, scope, services);
410
- lastError = null;
411
- if (checks.every((entry) => entry.ok === true)) {
412
- return { ok: true, checks };
412
+ checks = [];
413
+ lastError = null;
414
+ for (const service of services) {
415
+ try {
416
+ const result = runRailway([
417
+ "deployment",
418
+ "list",
419
+ "--service",
420
+ service.serviceName,
421
+ "--environment",
422
+ environment,
423
+ "--limit",
424
+ "1",
425
+ "--json"
426
+ ], {
427
+ cwd: tenantRoot,
428
+ capture: true,
429
+ env
430
+ });
431
+ const deployments = parseRailwayJsonOutput(result.stdout);
432
+ const latest = Array.isArray(deployments) ? deployments[0] : null;
433
+ const status = String(latest?.status ?? "").trim().toUpperCase();
434
+ const ok = railwayStatusDeploymentSettled(status);
435
+ checks.push({
436
+ type: "deployment-status",
437
+ service: service.key,
438
+ serviceName: service.serviceName,
439
+ environment,
440
+ ok,
441
+ status: status || "missing_deployment",
442
+ observed: {
443
+ id: latest?.id ?? null,
444
+ status: status || null,
445
+ createdAt: latest?.createdAt ?? null,
446
+ volumeMounts: Array.isArray(latest?.meta?.volumeMounts) ? latest.meta.volumeMounts : []
447
+ },
448
+ message: ok ? void 0 : `Railway deployment for ${service.serviceName} is not settled yet; observed ${status || "missing deployment status"}.`
449
+ });
450
+ } catch (error) {
451
+ lastError = error;
452
+ checks.push({
453
+ type: "deployment-status",
454
+ service: service.key,
455
+ serviceName: service.serviceName,
456
+ environment,
457
+ ok: false,
458
+ status: "status_error",
459
+ message: error instanceof Error ? error.message : String(error)
460
+ });
413
461
  }
414
- } catch (error) {
415
- lastError = error;
416
- checks = services.map((service) => ({
417
- type: "deployment-status",
418
- service: service.key,
419
- serviceName: service.serviceName,
420
- environment: resolveRailwayEnvironmentForScope(scope),
421
- ok: false,
422
- status: "status_error",
423
- message: error instanceof Error ? error.message : String(error)
424
- }));
462
+ }
463
+ if (checks.every((entry) => entry.ok === true)) {
464
+ return { ok: true, checks };
425
465
  }
426
466
  if (Date.now() >= deadline) {
427
467
  return {
@@ -968,6 +1008,7 @@ async function verifyRailwayManagedResources(tenantRoot, scope, {
968
1008
  const effectiveEnv = { ...env, RAILWAY_API_TOKEN: effectiveApiToken, TREESEED_RAILWAY_API_URL: effectiveApiUrl };
969
1009
  const services = configuredRailwayServices(tenantRoot, scope);
970
1010
  const checks = [];
1011
+ const deploymentStatusServices = [];
971
1012
  for (const service of services) {
972
1013
  const target = await resolveRailwayScheduleTarget({
973
1014
  projectId: service.projectId,
@@ -994,6 +1035,10 @@ async function verifyRailwayManagedResources(tenantRoot, scope, {
994
1035
  });
995
1036
  continue;
996
1037
  }
1038
+ deploymentStatusServices.push({
1039
+ ...service,
1040
+ projectId: target.project.id
1041
+ });
997
1042
  const instance = await getRailwayServiceInstance({
998
1043
  serviceId: target.service.id,
999
1044
  environmentId: target.environment.id,
@@ -1065,7 +1110,7 @@ async function verifyRailwayManagedResources(tenantRoot, scope, {
1065
1110
  }
1066
1111
  if (settleDeployments) {
1067
1112
  const settled = await waitForRailwayManagedDeploymentsSettled(tenantRoot, scope, {
1068
- services,
1113
+ services: deploymentStatusServices.length > 0 ? deploymentStatusServices : services,
1069
1114
  env: effectiveEnv,
1070
1115
  timeoutMs: settleTimeoutMs,
1071
1116
  pollMs: settlePollMs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/sdk",
3
- "version": "0.6.45",
3
+ "version": "0.6.47",
4
4
  "description": "Shared Treeseed SDK for content-backed and D1-backed object models.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {