@treeseed/sdk 0.6.47 → 0.6.48

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,103 +139,7 @@ export declare function deployProjectPlatform(options: ProjectPlatformActionOpti
139
139
  };
140
140
  railwayResources: {
141
141
  ok: boolean;
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
- })[];
142
+ checks: any[];
239
143
  } | {
240
144
  ok: boolean;
241
145
  skipped: boolean;
@@ -421,103 +325,7 @@ export declare function monitorProjectPlatform(options: ProjectPlatformActionOpt
421
325
  };
422
326
  railwayResources: {
423
327
  ok: boolean;
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
- })[];
328
+ checks: any[];
521
329
  } | {
522
330
  ok: boolean;
523
331
  skipped: boolean;
@@ -708,103 +516,7 @@ export declare function runProjectPlatformAction(action: ProjectPlatformAction,
708
516
  };
709
517
  railwayResources: {
710
518
  ok: boolean;
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
- })[];
519
+ checks: any[];
808
520
  } | {
809
521
  ok: boolean;
810
522
  skipped: boolean;
@@ -951,103 +663,7 @@ export declare function runProjectPlatformAction(action: ProjectPlatformAction,
951
663
  };
952
664
  railwayResources: {
953
665
  ok: boolean;
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
- })[];
666
+ checks: any[];
1051
667
  } | {
1052
668
  ok: boolean;
1053
669
  skipped: boolean;
@@ -43,57 +43,11 @@ export declare function waitForRailwayManagedDeploymentsSettled(tenantRoot: any,
43
43
  pollMs?: number | undefined;
44
44
  }): Promise<{
45
45
  ok: boolean;
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
- })[];
46
+ checks: any;
70
47
  message?: undefined;
71
48
  } | {
72
49
  ok: boolean;
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
- })[];
50
+ checks: any;
97
51
  message: string;
98
52
  }>;
99
53
  export declare function setRailwaySecretVariable({ cwd, service, environment, key, value, env, capture, allowFailure }: {
@@ -373,103 +327,7 @@ export declare function verifyRailwayManagedResources(tenantRoot: any, scope: an
373
327
  settlePollMs?: number | undefined;
374
328
  }): Promise<{
375
329
  ok: boolean;
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
- })[];
330
+ checks: any[];
473
331
  }>;
474
332
  export declare function planRailwayServiceDeploy(service: any, { env }?: {
475
333
  env?: NodeJS.ProcessEnv | undefined;
@@ -17,6 +17,7 @@ import {
17
17
  listRailwayServices,
18
18
  listRailwayVolumes,
19
19
  normalizeRailwayEnvironmentName,
20
+ railwayGraphqlRequest,
20
21
  resolveRailwayApiToken,
21
22
  resolveRailwayApiUrl,
22
23
  resolveRailwayWorkspace,
@@ -392,73 +393,46 @@ function runRailway(args, { cwd, capture = false, allowFailure = false, input, e
392
393
  async function waitForRailwayManagedDeploymentsSettled(tenantRoot, scope, {
393
394
  services = configuredRailwayServices(tenantRoot, scope),
394
395
  env = process.env,
395
- timeoutMs = 18e4,
396
+ timeoutMs = 6e5,
396
397
  pollMs = 15e3
397
398
  } = {}) {
398
399
  const deadline = Date.now() + timeoutMs;
399
- const environment = resolveRailwayEnvironmentForScope(scope);
400
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
- });
401
+ if (!projectId) {
402
+ return {
403
+ ok: false,
404
+ checks: services.map((service) => ({
405
+ type: "deployment-status",
406
+ service: service.key,
407
+ serviceName: service.serviceName,
408
+ environment: resolveRailwayEnvironmentForScope(scope),
409
+ ok: false,
410
+ status: "missing_project",
411
+ message: `Railway deployment status for ${service.serviceName} cannot be checked without a project id.`
412
+ }))
413
+ };
408
414
  }
409
415
  let checks = [];
410
416
  let lastError = null;
411
417
  for (; ; ) {
412
- checks = [];
413
418
  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
- });
461
- }
419
+ try {
420
+ const statusPayload = await fetchRailwayProjectDeploymentStatus({
421
+ projectId,
422
+ env
423
+ });
424
+ checks = collectRailwayDeploymentStatusChecks(statusPayload, scope, services);
425
+ } catch (error) {
426
+ lastError = error;
427
+ checks = services.map((service) => ({
428
+ type: "deployment-status",
429
+ service: service.key,
430
+ serviceName: service.serviceName,
431
+ environment: resolveRailwayEnvironmentForScope(scope),
432
+ ok: false,
433
+ status: "status_error",
434
+ message: error instanceof Error ? error.message : String(error)
435
+ }));
462
436
  }
463
437
  if (checks.every((entry) => entry.ok === true)) {
464
438
  return { ok: true, checks };
@@ -473,6 +447,48 @@ async function waitForRailwayManagedDeploymentsSettled(tenantRoot, scope, {
473
447
  await sleep(pollMs);
474
448
  }
475
449
  }
450
+ async function fetchRailwayProjectDeploymentStatus({ projectId, env = process.env }) {
451
+ const payload = await railwayGraphqlRequest({
452
+ query: `
453
+ query TreeseedRailwayDeploymentStatus($projectId: String!) {
454
+ project(id: $projectId) {
455
+ id
456
+ environments(first: 50) {
457
+ edges {
458
+ node {
459
+ id
460
+ name
461
+ serviceInstances {
462
+ edges {
463
+ node {
464
+ id
465
+ serviceId
466
+ serviceName
467
+ latestDeployment {
468
+ id
469
+ status
470
+ createdAt
471
+ deploymentStopped
472
+ meta
473
+ instances {
474
+ id
475
+ status
476
+ }
477
+ }
478
+ }
479
+ }
480
+ }
481
+ }
482
+ }
483
+ }
484
+ }
485
+ }
486
+ `.trim(),
487
+ variables: { projectId },
488
+ env
489
+ });
490
+ return payload.data?.project ?? null;
491
+ }
476
492
  function setRailwaySecretVariable({ cwd, service, environment, key, value, env = process.env, capture = false, allowFailure = false }) {
477
493
  const effectiveEnv = buildRailwayCommandEnv({
478
494
  ...process.env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/sdk",
3
- "version": "0.6.47",
3
+ "version": "0.6.48",
4
4
  "description": "Shared Treeseed SDK for content-backed and D1-backed object models.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {