@trigger.dev/platform 1.1.0 → 1.3.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.
package/dist/index.js CHANGED
@@ -46,6 +46,7 @@ var Limits = z.object({
46
46
  queueSizeLimits: QueueSizeLimits.optional(),
47
47
  hasPrivateNetworking: z.boolean().optional(),
48
48
  privateLinkConnectionLimit: z.number().optional(),
49
+ hasSso: z.boolean().optional(),
49
50
  // Duration string (e.g. "30d", "1y"). When set, the org gets a
50
51
  // dedicated S2 stream basin with this retention; when omitted, the
51
52
  // org's streams flow to the shared global basin.
@@ -244,10 +245,6 @@ var UsageResult = z6.object({
244
245
  cents: z6.number()
245
246
  });
246
247
  var Window = z6.enum(["MINUTE", "HOUR", "DAY"]);
247
- var BooleanParam = z6.preprocess(
248
- (val) => val === "true" ? true : false,
249
- z6.boolean()
250
- );
251
248
  var UsageSeriesParams = z6.object({
252
249
  from: z6.coerce.date(),
253
250
  to: z6.coerce.date(),
@@ -288,11 +285,14 @@ var ReportUsageResult = z6.object({
288
285
  balance: z6.number().optional(),
289
286
  usage: z6.number().optional(),
290
287
  overage: z6.number().optional(),
291
- plan: ReportUsagePlan.optional()
288
+ plan: ReportUsagePlan.optional(),
289
+ limitState: z6.literal("grace").optional(),
290
+ reason: z6.enum(["free_tier_exceeded", "billing_limit"]).optional()
292
291
  });
292
+ var MAX_INVOCATION_COST_IN_CENTS = 1e4;
293
293
  var ReportInvocationUsageEvent = z6.object({
294
- organizationId: z6.string(),
295
- costInCents: z6.number(),
294
+ organizationId: z6.string().min(1).max(128),
295
+ costInCents: z6.number().finite().min(0).max(MAX_INVOCATION_COST_IN_CENTS),
296
296
  additionalData: z6.record(z6.string(), z6.any()).optional()
297
297
  });
298
298
  var ReportInvocationUsageResult = z6.discriminatedUnion("success", [
@@ -314,76 +314,165 @@ var BillingAlertDefinition = z7.object({
314
314
  });
315
315
  var BillingAlertsResult = BillingAlertDefinition;
316
316
  var UpdateBillingAlertsRequest = z7.object({
317
- amount: z7.number(),
317
+ amount: z7.number().positive(),
318
318
  emails: z7.array(z7.string()),
319
319
  alertLevels: z7.array(z7.number())
320
320
  });
321
321
 
322
- // src/v3/schemas/registryCredentials.ts
322
+ // src/v3/schemas/billingLimit.ts
323
323
  import { z as z8 } from "zod";
324
- var RegistryCredentialsResponseSchema = z8.object({
325
- username: z8.string(),
326
- password: z8.string(),
327
- expiresAt: z8.string().datetime(),
328
- repositoryUri: z8.string()
324
+ var BillingLimitState = z8.discriminatedUnion("status", [
325
+ z8.object({
326
+ status: z8.literal("ok")
327
+ }),
328
+ z8.object({
329
+ status: z8.literal("grace"),
330
+ hitAt: z8.string(),
331
+ graceEndsAt: z8.string()
332
+ }),
333
+ z8.object({
334
+ status: z8.literal("rejected"),
335
+ hitAt: z8.string(),
336
+ graceEndsAt: z8.string()
337
+ })
338
+ ]);
339
+ var billingLimitConfiguredFields = {
340
+ isConfigured: z8.literal(true),
341
+ cancelInProgressRuns: z8.boolean(),
342
+ limitState: BillingLimitState,
343
+ effectiveAmountCents: z8.number().int().nonnegative().nullable(),
344
+ gracePeriodMs: z8.number().int().nonnegative()
345
+ };
346
+ var BillingLimitUnconfigured = z8.object({
347
+ isConfigured: z8.literal(false),
348
+ gracePeriodMs: z8.number().int().nonnegative()
349
+ });
350
+ var BillingLimitConfiguredNone = z8.object({
351
+ ...billingLimitConfiguredFields,
352
+ mode: z8.literal("none")
353
+ });
354
+ var BillingLimitConfiguredPlan = z8.object({
355
+ ...billingLimitConfiguredFields,
356
+ mode: z8.literal("plan")
357
+ });
358
+ var BillingLimitConfiguredCustom = z8.object({
359
+ ...billingLimitConfiguredFields,
360
+ mode: z8.literal("custom"),
361
+ amountCents: z8.number().int().positive()
362
+ });
363
+ var BillingLimitResult = z8.union([
364
+ BillingLimitUnconfigured,
365
+ BillingLimitConfiguredNone,
366
+ BillingLimitConfiguredPlan,
367
+ BillingLimitConfiguredCustom
368
+ ]);
369
+ var UpdateBillingLimitRequest = z8.discriminatedUnion("mode", [
370
+ z8.object({
371
+ mode: z8.literal("none"),
372
+ cancelInProgressRuns: z8.boolean()
373
+ }),
374
+ z8.object({
375
+ mode: z8.literal("plan"),
376
+ cancelInProgressRuns: z8.boolean()
377
+ }),
378
+ z8.object({
379
+ mode: z8.literal("custom"),
380
+ amountCents: z8.number().int().positive(),
381
+ cancelInProgressRuns: z8.boolean()
382
+ })
383
+ ]);
384
+ var ResolveBillingLimitRequest = z8.discriminatedUnion("action", [
385
+ z8.object({
386
+ action: z8.literal("increase"),
387
+ newAmountCents: z8.number().int().positive(),
388
+ resumeMode: z8.enum(["queue", "new_only"])
389
+ }),
390
+ z8.object({
391
+ action: z8.literal("remove"),
392
+ resumeMode: z8.enum(["queue", "new_only"])
393
+ })
394
+ ]);
395
+ var BillingLimitActiveOrg = z8.object({
396
+ orgId: z8.string(),
397
+ limitState: z8.enum(["grace", "rejected"])
398
+ });
399
+ var BillingLimitsActiveResult = z8.object({
400
+ orgs: z8.array(BillingLimitActiveOrg)
401
+ });
402
+ var BillingLimitPendingResolveOrg = z8.object({
403
+ organizationId: z8.string(),
404
+ resumeMode: z8.enum(["queue", "new_only"]),
405
+ resolvedAt: z8.string()
406
+ });
407
+ var BillingLimitsPendingResolvesResult = z8.object({
408
+ orgs: z8.array(BillingLimitPendingResolveOrg)
329
409
  });
330
410
 
331
- // src/v3/schemas/enqueueBuild.ts
411
+ // src/v3/schemas/registryCredentials.ts
332
412
  import { z as z9 } from "zod";
333
- var EnqueueBuildRequestSchema = z9.object({
334
- deploymentId: z9.string(),
335
- artifactKey: z9.string(),
336
- options: z9.object({
337
- skipPromotion: z9.boolean().optional(),
338
- configFilePath: z9.string().optional()
413
+ var RegistryCredentialsResponseSchema = z9.object({
414
+ username: z9.string(),
415
+ password: z9.string(),
416
+ expiresAt: z9.string().datetime(),
417
+ repositoryUri: z9.string()
418
+ });
419
+
420
+ // src/v3/schemas/enqueueBuild.ts
421
+ import { z as z10 } from "zod";
422
+ var EnqueueBuildRequestSchema = z10.object({
423
+ deploymentId: z10.string(),
424
+ artifactKey: z10.string(),
425
+ options: z10.object({
426
+ skipPromotion: z10.boolean().optional(),
427
+ configFilePath: z10.string().optional()
339
428
  })
340
429
  });
341
- var EnqueueBuildResponseSchema = z9.object({
342
- buildId: z9.string()
430
+ var EnqueueBuildResponseSchema = z10.object({
431
+ buildId: z10.string()
343
432
  });
344
433
 
345
434
  // src/v3/schemas/initialDeployment.ts
346
- import { z as z10 } from "zod";
347
- var TriggerInitialDeploymentRequestSchema = z10.object({
348
- environment: z10.enum(["prod", "staging", "preview"])
435
+ import { z as z11 } from "zod";
436
+ var TriggerInitialDeploymentRequestSchema = z11.object({
437
+ environment: z11.enum(["prod", "staging", "preview"])
349
438
  });
350
- var TriggerInitialDeploymentResponseSchema = z10.object({
351
- ok: z10.boolean()
439
+ var TriggerInitialDeploymentResponseSchema = z11.object({
440
+ ok: z11.boolean()
352
441
  });
353
442
 
354
443
  // src/v3/schemas/privateLink.ts
355
- import { z as z11 } from "zod";
356
- var PrivateLinkConnectionStatus = z11.enum([
444
+ import { z as z12 } from "zod";
445
+ var PrivateLinkConnectionStatus = z12.enum([
357
446
  "PENDING",
358
447
  "PROVISIONING",
359
448
  "ACTIVE",
360
449
  "ERROR",
361
450
  "DELETING"
362
451
  ]);
363
- var PrivateLinkConnection = z11.object({
364
- id: z11.string(),
365
- friendlyId: z11.string(),
366
- name: z11.string(),
367
- organizationId: z11.string(),
368
- endpointServiceName: z11.string(),
369
- targetRegion: z11.string(),
452
+ var PrivateLinkConnection = z12.object({
453
+ id: z12.string(),
454
+ friendlyId: z12.string(),
455
+ name: z12.string(),
456
+ organizationId: z12.string(),
457
+ endpointServiceName: z12.string(),
458
+ targetRegion: z12.string(),
370
459
  status: PrivateLinkConnectionStatus,
371
- statusMessage: z11.string().nullable(),
372
- endpointDnsName: z11.string().nullable(),
373
- endpointIps: z11.array(z11.string()).nullable(),
374
- provisionedAt: z11.string().nullable(),
375
- createdAt: z11.string(),
376
- updatedAt: z11.string()
377
- });
378
- var PrivateLinkConnectionList = z11.object({
379
- connections: z11.array(PrivateLinkConnection)
380
- });
381
- var CreatePrivateLinkConnectionBody = z11.object({
382
- name: z11.string().min(1).max(100).regex(
460
+ statusMessage: z12.string().nullable(),
461
+ endpointDnsName: z12.string().nullable(),
462
+ endpointIps: z12.array(z12.string()).nullable(),
463
+ provisionedAt: z12.string().nullable(),
464
+ createdAt: z12.string(),
465
+ updatedAt: z12.string()
466
+ });
467
+ var PrivateLinkConnectionList = z12.object({
468
+ connections: z12.array(PrivateLinkConnection)
469
+ });
470
+ var CreatePrivateLinkConnectionBody = z12.object({
471
+ name: z12.string().min(1).max(100).regex(
383
472
  /^[a-zA-Z][a-zA-Z0-9 _-]*$/,
384
473
  "Must start with a letter and contain only letters, numbers, spaces, hyphens, or underscores"
385
474
  ),
386
- endpointServiceName: z11.string().regex(
475
+ endpointServiceName: z12.string().regex(
387
476
  /^com\.amazonaws\.vpce\..+\.vpce-svc-.+$/,
388
477
  "Must be a valid VPC Endpoint Service name (com.amazonaws.vpce.<region>.vpce-svc-*)"
389
478
  ),
@@ -391,14 +480,43 @@ var CreatePrivateLinkConnectionBody = z11.object({
391
480
  // this validates the AWS region *format* only; the authoritative check that
392
481
  // the region is actually configured happens server-side against the set of
393
482
  // regions discovered from env vars.
394
- targetRegion: z11.string().regex(/^[a-z]{2}-[a-z]+-\d+$/, "Must be a valid AWS region")
483
+ targetRegion: z12.string().regex(/^[a-z]{2}-[a-z]+-\d+$/, "Must be a valid AWS region")
395
484
  });
396
- var DeletePrivateLinkResult = z11.object({
397
- success: z11.boolean()
485
+ var DeletePrivateLinkResult = z12.object({
486
+ success: z12.boolean()
398
487
  });
399
- var PrivateLinkRegionsResult = z11.object({
400
- availableRegions: z11.array(z11.string()),
401
- activeRegions: z11.array(z11.string())
488
+ var PrivateLinkRegionsResult = z12.object({
489
+ availableRegions: z12.array(z12.string()),
490
+ activeRegions: z12.array(z12.string())
491
+ });
492
+
493
+ // src/v3/schemas/promoCodes.ts
494
+ import { z as z13 } from "zod";
495
+ var ValidatePromoCodeBodySchema = z13.object({
496
+ code: z13.string()
497
+ });
498
+ var ValidatePromoCodeResult = z13.object({
499
+ valid: z13.boolean(),
500
+ amountInCents: z13.number().optional(),
501
+ expiresAt: z13.string().datetime().nullable().optional()
502
+ });
503
+ var ApplyPromoCodeBodySchema = z13.object({
504
+ code: z13.string(),
505
+ userId: z13.string()
506
+ });
507
+ var ApplyPromoCodeResult = z13.object({
508
+ applied: z13.boolean(),
509
+ amountInCents: z13.number().optional(),
510
+ expiresAt: z13.string().datetime().nullable().optional(),
511
+ // Present when applied is false, e.g. "already_redeemed" or "invalid".
512
+ reason: z13.string().optional()
513
+ });
514
+ var PromoCreditsResult = z13.object({
515
+ promoCredits: z13.object({
516
+ grantedCents: z13.number(),
517
+ remainingCents: z13.number(),
518
+ expiresAt: z13.string().datetime().nullable()
519
+ }).nullable()
402
520
  });
403
521
 
404
522
  // src/v3/client/index.ts
@@ -414,10 +532,7 @@ var BillingClient = class {
414
532
  }
415
533
  async usage(orgId, params) {
416
534
  const search = objectToSearchParams(params);
417
- return await this.fetch(
418
- `/api/v1/orgs/${orgId}/usage?${search == null ? void 0 : search.toString()}`,
419
- UsageResult
420
- );
535
+ return await this.fetch(`/api/v1/orgs/${orgId}/usage?${search == null ? void 0 : search.toString()}`, UsageResult);
421
536
  }
422
537
  async usageSeries(orgId, params) {
423
538
  const search = objectToSearchParams(params);
@@ -427,43 +542,52 @@ var BillingClient = class {
427
542
  );
428
543
  }
429
544
  async setPlan(orgId, body) {
430
- return await this.fetch(
431
- `/api/v1/orgs/${orgId}/v3/subscription`,
432
- SubscribeResultSchema,
433
- {
434
- method: "POST",
435
- headers: {
436
- "Content-Type": "application/json"
437
- },
438
- body: JSON.stringify(body)
439
- }
440
- );
545
+ return await this.fetch(`/api/v1/orgs/${orgId}/v3/subscription`, SubscribeResultSchema, {
546
+ method: "POST",
547
+ headers: {
548
+ "Content-Type": "application/json"
549
+ },
550
+ body: JSON.stringify(body)
551
+ });
441
552
  }
442
553
  async setAddOn(orgId, body) {
443
- return await this.fetch(
444
- `/api/v1/orgs/${orgId}/v3/subscription/addon`,
445
- SetAddOnResult,
446
- {
447
- method: "POST",
448
- headers: {
449
- "Content-Type": "application/json"
450
- },
451
- body: JSON.stringify(body)
452
- }
453
- );
554
+ return await this.fetch(`/api/v1/orgs/${orgId}/v3/subscription/addon`, SetAddOnResult, {
555
+ method: "POST",
556
+ headers: {
557
+ "Content-Type": "application/json"
558
+ },
559
+ body: JSON.stringify(body)
560
+ });
561
+ }
562
+ async validatePromoCode(code) {
563
+ return await this.fetch(`/api/v1/promo-codes/validate`, ValidatePromoCodeResult, {
564
+ method: "POST",
565
+ headers: {
566
+ "Content-Type": "application/json"
567
+ },
568
+ body: JSON.stringify({ code })
569
+ });
570
+ }
571
+ async applyPromoCode(orgId, body) {
572
+ return await this.fetch(`/api/v1/orgs/${orgId}/promo/apply`, ApplyPromoCodeResult, {
573
+ method: "POST",
574
+ headers: {
575
+ "Content-Type": "application/json"
576
+ },
577
+ body: JSON.stringify(body)
578
+ });
579
+ }
580
+ async promoCredits(orgId) {
581
+ return await this.fetch(`/api/v1/orgs/${orgId}/promo/credits`, PromoCreditsResult);
454
582
  }
455
583
  async createPortalSession(orgId, body) {
456
- return await this.fetch(
457
- `/api/v1/orgs/${orgId}/v3/subscription/portal`,
458
- CustomerPortalSchema,
459
- {
460
- method: "POST",
461
- headers: {
462
- "Content-Type": "application/json"
463
- },
464
- body: JSON.stringify(body)
465
- }
466
- );
584
+ return await this.fetch(`/api/v1/orgs/${orgId}/v3/subscription/portal`, CustomerPortalSchema, {
585
+ method: "POST",
586
+ headers: {
587
+ "Content-Type": "application/json"
588
+ },
589
+ body: JSON.stringify(body)
590
+ });
467
591
  }
468
592
  /**
469
593
  *
@@ -471,17 +595,13 @@ var BillingClient = class {
471
595
  * @returns details about usage
472
596
  */
473
597
  async reportInvocationUsage(event) {
474
- return await this.fetch(
475
- `/api/v1/usage/ingest/invocation`,
476
- ReportInvocationUsageResult,
477
- {
478
- method: "POST",
479
- headers: {
480
- "Content-Type": "application/json"
481
- },
482
- body: JSON.stringify(event)
483
- }
484
- );
598
+ return await this.fetch(`/api/v1/usage/ingest/invocation`, ReportInvocationUsageResult, {
599
+ method: "POST",
600
+ headers: {
601
+ "Content-Type": "application/json"
602
+ },
603
+ body: JSON.stringify(event)
604
+ });
485
605
  }
486
606
  /**
487
607
  * Generates registry credentials for a project. This is used to push images to a project's container repository.
@@ -529,48 +649,55 @@ var BillingClient = class {
529
649
  * @returns details about usage
530
650
  */
531
651
  async getEntitlement(orgId) {
532
- return await this.fetch(
533
- `/api/v1/orgs/${orgId}/usage/entitlement`,
534
- ReportUsageResult
535
- );
652
+ return await this.fetch(`/api/v1/orgs/${orgId}/usage/entitlement`, ReportUsageResult);
536
653
  }
537
654
  async getBillingAlerts(orgId) {
538
- return await this.fetch(
539
- `/api/v1/orgs/${orgId}/billing-alerts`,
540
- BillingAlertsResult
541
- );
655
+ return await this.fetch(`/api/v1/orgs/${orgId}/billing-alerts`, BillingAlertsResult);
542
656
  }
543
657
  async updateBillingAlerts(orgId, body) {
544
- return await this.fetch(
545
- `/api/v1/orgs/${orgId}/billing-alerts`,
546
- BillingAlertsResult,
547
- {
548
- method: "POST",
549
- headers: {
550
- "Content-Type": "application/json"
551
- },
552
- body: JSON.stringify(body)
553
- }
554
- );
658
+ return await this.fetch(`/api/v1/orgs/${orgId}/billing-alerts`, BillingAlertsResult, {
659
+ method: "POST",
660
+ headers: {
661
+ "Content-Type": "application/json"
662
+ },
663
+ body: JSON.stringify(body)
664
+ });
665
+ }
666
+ async getBillingLimit(orgId) {
667
+ return await this.fetch(`/api/v1/orgs/${orgId}/billing-limit`, BillingLimitResult);
668
+ }
669
+ async updateBillingLimit(orgId, body) {
670
+ return await this.fetch(`/api/v1/orgs/${orgId}/billing-limit`, BillingLimitResult, {
671
+ method: "PUT",
672
+ headers: {
673
+ "Content-Type": "application/json"
674
+ },
675
+ body: JSON.stringify(body)
676
+ });
677
+ }
678
+ async resolveBillingLimit(orgId, body) {
679
+ return await this.fetch(`/api/v1/orgs/${orgId}/billing-limit/resolve`, BillingLimitResult, {
680
+ method: "POST",
681
+ headers: {
682
+ "Content-Type": "application/json"
683
+ },
684
+ body: JSON.stringify(body)
685
+ });
686
+ }
687
+ async getActiveBillingLimits() {
688
+ return await this.fetch(`/api/v1/billing-limits/active`, BillingLimitsActiveResult);
555
689
  }
556
690
  async getPrivateLinks(orgId) {
557
- return await this.fetch(
558
- `/api/v1/orgs/${orgId}/private-connections`,
559
- PrivateLinkConnectionList
560
- );
691
+ return await this.fetch(`/api/v1/orgs/${orgId}/private-connections`, PrivateLinkConnectionList);
561
692
  }
562
693
  async createPrivateLink(orgId, body) {
563
- return await this.fetch(
564
- `/api/v1/orgs/${orgId}/private-connections`,
565
- PrivateLinkConnection,
566
- {
567
- method: "POST",
568
- headers: {
569
- "Content-Type": "application/json"
570
- },
571
- body: JSON.stringify(body)
572
- }
573
- );
694
+ return await this.fetch(`/api/v1/orgs/${orgId}/private-connections`, PrivateLinkConnection, {
695
+ method: "POST",
696
+ headers: {
697
+ "Content-Type": "application/json"
698
+ },
699
+ body: JSON.stringify(body)
700
+ });
574
701
  }
575
702
  async deletePrivateLink(orgId, connectionId) {
576
703
  return await this.fetch(
@@ -736,8 +863,20 @@ export {
736
863
  AddOn,
737
864
  AddOnDefinition,
738
865
  AddOns,
866
+ ApplyPromoCodeBodySchema,
867
+ ApplyPromoCodeResult,
739
868
  BillingAlertsResult,
740
869
  BillingClient,
870
+ BillingLimitActiveOrg,
871
+ BillingLimitConfiguredCustom,
872
+ BillingLimitConfiguredNone,
873
+ BillingLimitConfiguredPlan,
874
+ BillingLimitPendingResolveOrg,
875
+ BillingLimitResult,
876
+ BillingLimitState,
877
+ BillingLimitUnconfigured,
878
+ BillingLimitsActiveResult,
879
+ BillingLimitsPendingResolvesResult,
741
880
  CreatePrivateLinkConnectionBody,
742
881
  CurrentPlan,
743
882
  CustomerPortalRequestBodySchema,
@@ -748,6 +887,7 @@ export {
748
887
  ErrorSchema,
749
888
  FreeConnectRequiredSchema,
750
889
  FreeConnectedSchema,
890
+ MAX_INVOCATION_COST_IN_CENTS,
751
891
  PlanDefinitionSchema,
752
892
  Plans,
753
893
  PlansResult,
@@ -755,12 +895,14 @@ export {
755
895
  PrivateLinkConnectionList,
756
896
  PrivateLinkConnectionStatus,
757
897
  PrivateLinkRegionsResult,
898
+ PromoCreditsResult,
758
899
  RegistryCredentialsResponseSchema,
759
900
  ReportComputeUsageEvent,
760
901
  ReportInvocationUsageEvent,
761
902
  ReportInvocationUsageResult,
762
903
  ReportUsagePlan,
763
904
  ReportUsageResult,
905
+ ResolveBillingLimitRequest,
764
906
  SetAddOnBody,
765
907
  SetAddOnResult,
766
908
  SetPlanBodySchema,
@@ -769,10 +911,13 @@ export {
769
911
  TriggerInitialDeploymentRequestSchema,
770
912
  TriggerInitialDeploymentResponseSchema,
771
913
  UpdateBillingAlertsRequest,
914
+ UpdateBillingLimitRequest,
772
915
  UsageParams,
773
916
  UsageResult,
774
917
  UsageSeriesParams,
775
918
  UsageSeriesResult,
919
+ ValidatePromoCodeBodySchema,
920
+ ValidatePromoCodeResult,
776
921
  defaultMachine,
777
922
  machineDefinition,
778
923
  machines,