@ts-cloud/core 0.2.27 → 0.3.1

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/types.d.ts CHANGED
@@ -159,6 +159,13 @@ export interface EnvironmentConfig {
159
159
  * Example: smaller instances in dev, larger in production
160
160
  */
161
161
  infrastructure?: Partial<InfrastructureConfig>;
162
+ /**
163
+ * Serverless application manifest (Laravel-Vapor-equivalent). Defining this opts
164
+ * the environment into the serverless app deploy pipeline: one codebase deployed
165
+ * as http/queue/cli Lambda functions with assets, hooks, and atomic activation.
166
+ * @see ServerlessAppConfig
167
+ */
168
+ app?: ServerlessAppConfig;
162
169
  }
163
170
  /**
164
171
  * Network/VPC configuration
@@ -867,7 +874,7 @@ export interface SiteConfig {
867
874
  * the nginx vhost points at. Must be one of `compute.php.versions`. Defaults
868
875
  * to `compute.php.default`.
869
876
  */
870
- phpVersion?: string;
877
+ phpVersion?: PhpVersion;
871
878
  /**
872
879
  * Web root relative to the release directory. Defaults to `'public'` for
873
880
  * `laravel`/`statamic`/`wordpress`, and `''` (the release root) for `php`,
@@ -1383,6 +1390,175 @@ export interface FunctionConfig {
1383
1390
  }>;
1384
1391
  environment?: Record<string, string>;
1385
1392
  }
1393
+ /**
1394
+ * Serverless application configuration — the Laravel-Vapor-equivalent manifest.
1395
+ *
1396
+ * One application codebase is deployed as three Lambda functions sharing a single
1397
+ * code artifact:
1398
+ * - **http** fronted by API Gateway v2 (or v1) + an optional custom domain
1399
+ * - **queue** triggered by an SQS event source mapping (one job per invocation)
1400
+ * - **cli** invoked by an EventBridge schedule (`schedule:run`) and on demand
1401
+ * (deploy hooks, migrations, `command`)
1402
+ *
1403
+ * Declared per-environment via {@link EnvironmentConfig.app}. Defining it opts a
1404
+ * project into the serverless application deploy pipeline (`cloud deploy:serverless`).
1405
+ *
1406
+ * @example
1407
+ * environments: {
1408
+ * production: {
1409
+ * type: 'production',
1410
+ * domain: 'app.example.com',
1411
+ * app: {
1412
+ * runtime: 'nodejs20.x',
1413
+ * entry: 'src/server.ts',
1414
+ * memory: 1024,
1415
+ * build: ['bun install', 'bun run build'],
1416
+ * deploy: ['migrate'],
1417
+ * queues: true,
1418
+ * scheduler: 'on',
1419
+ * },
1420
+ * },
1421
+ * }
1422
+ */
1423
+ export interface ServerlessAppConfig {
1424
+ /**
1425
+ * Lambda runtime shared by all three functions.
1426
+ * Use `provided.al2023` for PHP (custom runtime layer) or Bun custom runtimes.
1427
+ * @default 'nodejs20.x'
1428
+ */
1429
+ runtime?: 'nodejs20.x' | 'nodejs22.x' | 'provided.al2023' | (string & {});
1430
+ /**
1431
+ * Application kind. Drives packaging + runtime selection.
1432
+ * - `node` / `bun`: bundle a JS/TS handler artifact
1433
+ * - `php`: build/attach the PHP runtime layer and FPM bridge (Laravel)
1434
+ * @default 'node'
1435
+ */
1436
+ kind?: 'node' | 'bun' | 'php';
1437
+ /**
1438
+ * Entry file (relative to project root) that exports the request handler.
1439
+ * Used when `handlers` is not provided; a single shim re-exports http/queue/cli.
1440
+ * @example 'src/server.ts'
1441
+ */
1442
+ entry?: string;
1443
+ /**
1444
+ * Explicit per-function handlers, overriding the single-`entry` shim.
1445
+ * Values are Lambda handler strings (e.g. `dist/index.http`).
1446
+ */
1447
+ handlers?: {
1448
+ http?: string;
1449
+ queue?: string;
1450
+ cli?: string;
1451
+ };
1452
+ /** HTTP function memory in MB. @default 1024 */
1453
+ memory?: number;
1454
+ /** HTTP request timeout in seconds (API Gateway caps at 29s for v2). @default 28 */
1455
+ timeout?: number;
1456
+ /** Reserved concurrency for the HTTP function. */
1457
+ concurrency?: number;
1458
+ /** API Gateway version: 2 = HTTP API (cheaper, default), 1 = REST API. @default 2 */
1459
+ gatewayVersion?: 1 | 2;
1460
+ /**
1461
+ * Keep-warm count. Sets provisioned concurrency on the HTTP alias, or drives a
1462
+ * scheduled warmer rule. 0/undefined disables warming.
1463
+ */
1464
+ warm?: number;
1465
+ /** CLI function memory in MB. @default 1024 */
1466
+ cliMemory?: number;
1467
+ /** CLI command timeout in seconds (allow room for migrations). @default 900 */
1468
+ cliTimeout?: number;
1469
+ /**
1470
+ * Queue names to process. `true` provisions a single `default` queue; `false`
1471
+ * disables the queue function entirely. Entries may carry a per-queue
1472
+ * concurrency, e.g. `[{ emails: 10 }]`.
1473
+ */
1474
+ queues?: boolean | Array<string | Record<string, number>>;
1475
+ /** Max concurrent queue job executions (SQS event source mapping). @default 1000 */
1476
+ queueConcurrency?: number;
1477
+ /** Queue visibility timeout in seconds. @default 120 */
1478
+ queueTimeout?: number;
1479
+ /** Queue function memory in MB. @default 1024 */
1480
+ queueMemory?: number;
1481
+ /** Max receive count before a message is sent to the DLQ. @default 3 */
1482
+ queueTries?: number;
1483
+ /**
1484
+ * Task scheduler mode:
1485
+ * - `on` EventBridge rule invokes the CLI fn (`schedule:run`) every minute
1486
+ * - `sub-minute` adds a self-rescheduling runner for sub-minute tasks
1487
+ * - `off` no scheduler
1488
+ * @default 'on'
1489
+ */
1490
+ scheduler?: 'off' | 'on' | 'sub-minute';
1491
+ /** Commands run locally before packaging (e.g. `composer install`, `bun run build`). */
1492
+ build?: string[];
1493
+ /**
1494
+ * Commands run remotely after the new code is live, by invoking the CLI function
1495
+ * (e.g. `migrate --force`). A failing hook aborts the deploy and rolls back.
1496
+ */
1497
+ deploy?: string[];
1498
+ /**
1499
+ * Persistent application mode (Laravel Octane / long-lived server) instead of
1500
+ * per-request FPM/handler boot. Lower latency; requires an Octane-safe app.
1501
+ * @default false
1502
+ */
1503
+ octane?: boolean;
1504
+ /**
1505
+ * Deployment package format:
1506
+ * - `zip` ship a ZIP artifact (250 MB unzipped layer+code limit)
1507
+ * - `image` ship a container image to ECR (up to 10 GB) for large apps
1508
+ * @default 'zip'
1509
+ */
1510
+ packaging?: 'zip' | 'image';
1511
+ /** Attach the functions to a VPC (required for ElastiCache / private RDS). */
1512
+ vpc?: {
1513
+ subnets?: string[];
1514
+ securityGroups?: string[];
1515
+ };
1516
+ /** Front the database with an RDS Proxy for Lambda connection pooling. */
1517
+ rdsProxy?: boolean | {
1518
+ name?: string;
1519
+ };
1520
+ /** Ephemeral `/tmp` size in MB (512–10240). @default 512 */
1521
+ tmpStorage?: number;
1522
+ /** Database attachment. */
1523
+ database?: {
1524
+ connection?: 'rds-proxy' | 'aurora-serverless' | 'rds';
1525
+ cluster?: string;
1526
+ };
1527
+ /** Cache attachment. DynamoDB cache table is the zero-NAT default. */
1528
+ cache?: {
1529
+ driver?: 'dynamodb' | 'elasticache';
1530
+ cluster?: string;
1531
+ };
1532
+ /** Application object-storage bucket (Vapor `storage:`). */
1533
+ storage?: {
1534
+ bucket?: string;
1535
+ };
1536
+ /** Managed WAF in front of the HTTP API / CloudFront. */
1537
+ firewall?: WafConfig;
1538
+ /** Custom domain for the app (overrides {@link EnvironmentConfig.domain}). */
1539
+ domain?: string | string[];
1540
+ /** Pre-issued ACM certificate ARN for the custom domain. */
1541
+ certificateArn?: string;
1542
+ /** Local directory whose contents are uploaded to S3/CloudFront as versioned assets. */
1543
+ assets?: string;
1544
+ /** PHP version for the runtime layer. @default '8.3' */
1545
+ phpVersion?: PhpVersion;
1546
+ /** CPU architecture. @default 'x86_64' */
1547
+ architecture?: 'x86_64' | 'arm64';
1548
+ /**
1549
+ * Lambda layer version ARNs attached to all functions. For PHP apps this is
1550
+ * the ts-cloud PHP runtime layer; if omitted, the deployer falls back to the
1551
+ * `TSCLOUD_PHP_LAYER_ARN` environment variable.
1552
+ */
1553
+ layers?: string[];
1554
+ /** Plaintext environment variables injected into all functions. */
1555
+ env?: Record<string, string>;
1556
+ /**
1557
+ * Secret names resolved from Secrets Manager / SSM at deploy time and injected
1558
+ * as environment variables. Array of names, or name→source map.
1559
+ */
1560
+ secrets?: string[] | Record<string, string>;
1561
+ }
1386
1562
  /**
1387
1563
  * Elastic File System (EFS) configuration
1388
1564
  */
@@ -1934,6 +2110,12 @@ export interface ComputeBackupConfig {
1934
2110
  /** S3-compatible endpoint (e.g. Hetzner object storage). Omit for AWS S3. */
1935
2111
  endpoint?: string;
1936
2112
  }
2113
+ /**
2114
+ * A PHP version selector. Known versions provide editor autocomplete; the
2115
+ * `(string & {})` arm keeps it open for versions released after this type was
2116
+ * written (e.g. a future `'8.5'`) without a type error.
2117
+ */
2118
+ export type PhpVersion = '8.1' | '8.2' | '8.3' | '8.4' | (string & {});
1937
2119
  /**
1938
2120
  * PHP-FPM provisioning for a compute box. See {@link ComputeConfig.php}.
1939
2121
  */
@@ -1942,9 +2124,9 @@ export interface ComputePhpConfig {
1942
2124
  * PHP versions to install (e.g. `['8.3', '8.2']`). Each gets its own php-fpm
1943
2125
  * pool/socket so sites can pin different versions. @default ['8.3']
1944
2126
  */
1945
- versions?: string[];
2127
+ versions?: PhpVersion[];
1946
2128
  /** Default PHP version for sites that don't set `phpVersion`. @default first of `versions` */
1947
- default?: string;
2129
+ default?: PhpVersion;
1948
2130
  /**
1949
2131
  * Extra PHP extensions to install beyond the Laravel baseline (mbstring, xml,
1950
2132
  * curl, mysql, pgsql, redis, gd, bcmath, zip, intl). apt package suffixes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-cloud/core",
3
- "version": "0.2.27",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "Core CloudFormation generation library for ts-cloud",
6
6
  "author": "Chris Breuer <chris@stacksjs.com>",
@@ -31,7 +31,7 @@
31
31
  "typecheck": "tsc --noEmit"
32
32
  },
33
33
  "dependencies": {
34
- "@ts-cloud/aws-types": "0.2.27"
34
+ "@ts-cloud/aws-types": "0.3.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "typescript": "^5.9.3"