@ts-cloud/core 0.7.93 → 0.7.94

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.
Files changed (2) hide show
  1. package/dist/types.d.ts +160 -3
  2. package/package.json +2 -2
package/dist/types.d.ts CHANGED
@@ -812,6 +812,35 @@ export interface SiteRedirectConfig {
812
812
  /** Append the request path + query to `to`. Default `true`. */
813
813
  preservePath?: boolean;
814
814
  }
815
+ /**
816
+ * A shared path pointed at an explicit location instead of the site's own
817
+ * `shared/` directory.
818
+ *
819
+ * Every site installs under its own base (`/var/www/<slug>-<site>`), so two
820
+ * sites of one project that both list `database/app.sqlite` get two separate
821
+ * databases — each surviving its own deploys, and drifting apart forever.
822
+ * Naming one absolute `target` makes them the same file.
823
+ */
824
+ export interface SharedPathSpec {
825
+ /** Release-relative path that receives the symlink, e.g. `database/app.sqlite`. */
826
+ path: string;
827
+ /**
828
+ * Absolute path the symlink points at. Defaults to `<base>/shared/<path>`,
829
+ * which is what a plain string entry means.
830
+ */
831
+ target?: string;
832
+ /**
833
+ * May this site CREATE the target — placehold it, and seed it from this
834
+ * site's own live release? Default `true`.
835
+ *
836
+ * Set `false` on every site but one when several share a target. Otherwise
837
+ * whichever site happens to deploy first creates the file, and the site that
838
+ * actually holds the data finds the target already there and never seeds it.
839
+ */
840
+ seed?: boolean;
841
+ }
842
+ /** A shared path: a release-relative path, or {@link SharedPathSpec}. */
843
+ export type SharedPathEntry = string | SharedPathSpec;
815
844
  export interface SiteConfig {
816
845
  /**
817
846
  * Directory to deploy.
@@ -983,10 +1012,16 @@ export interface SiteConfig {
983
1012
  * A release is a fresh directory, so anything the app WRITES and must keep
984
1013
  * has to be listed here or the next deploy silently starts it from empty.
985
1014
  *
1015
+ * An entry may instead be a {@link SharedPathSpec} naming an absolute
1016
+ * `target`, which is how SEVERAL sites of one project point at ONE file —
1017
+ * an app and its API sharing a single SQLite database, say. Each site
1018
+ * installs under its own base, so a plain string can only ever give each of
1019
+ * them a database of its own.
1020
+ *
986
1021
  * Honored by both PHP/Laravel sites and server-app sites (`start`).
987
1022
  * @default ['storage', '.env'] for PHP sites; `['.env']` for server-app sites
988
1023
  */
989
- sharedPaths?: string[];
1024
+ sharedPaths?: SharedPathEntry[];
990
1025
  /**
991
1026
  * Number of past releases to retain on the box for rollback.
992
1027
  * @default 4
@@ -1318,7 +1353,7 @@ export interface BucketConfig {
1318
1353
  }
1319
1354
  export interface DatabaseConfig {
1320
1355
  type?: 'rds' | 'dynamodb';
1321
- engine?: 'postgres' | 'mysql' | 'mariadb' | 'singlestore';
1356
+ engine?: 'postgres' | 'mysql' | 'mariadb' | 'singlestore' | 'vitess';
1322
1357
  instanceType?: string;
1323
1358
  /** Database/schema name to create (e.g. `forge`). */
1324
1359
  name?: string;
@@ -1328,7 +1363,7 @@ export interface DatabaseConfig {
1328
1363
  password?: string;
1329
1364
  /** Hostname for a managed/external database (default `127.0.0.1` on-box). */
1330
1365
  host?: string;
1331
- /** Port (defaults: mysql/mariadb/singlestore 3306, postgres 5432). */
1366
+ /** Port (defaults: mysql/mariadb/singlestore 3306, vitess 15306, postgres 5432). */
1332
1367
  port?: number;
1333
1368
  /**
1334
1369
  * Require TLS to the database. Defaults on for managed SingleStore (Helios),
@@ -1342,6 +1377,53 @@ export interface DatabaseConfig {
1342
1377
  * engine.
1343
1378
  */
1344
1379
  users?: DatabaseUserConfig[];
1380
+ /** Control-plane settings, only meaningful when `engine` is `vitess`. */
1381
+ vitess?: VitessControlPlaneConfig;
1382
+ }
1383
+ /**
1384
+ * How to reach a Vitess cluster's control plane.
1385
+ *
1386
+ * The application talks to vtgate over the MySQL protocol, which is enough
1387
+ * for queries and for most observability (`SHOW VITESS_SHARDS`,
1388
+ * `SHOW VITESS_MIGRATIONS`). It is NOT enough to create a keyspace or apply
1389
+ * a VSchema: those are vtctld gRPC operations, so managing them needs the
1390
+ * separate address below plus the `vtctldclient` binary on the box.
1391
+ *
1392
+ * Leaving this unset keeps everything read-only. The dashboard still shows
1393
+ * topology and migrations through vtgate; it just cannot change anything,
1394
+ * which is the right default for a cluster ts-cloud did not build.
1395
+ */
1396
+ export interface VitessControlPlaneConfig {
1397
+ /**
1398
+ * vtctld's gRPC address, e.g. `vtctld.internal:15999`.
1399
+ *
1400
+ * Distinct from the vtgate address in {@link DatabaseConfig.host}: vtgate
1401
+ * routes queries, vtctld administers the cluster. Pointing this at vtgate
1402
+ * fails with a protocol error rather than doing anything useful.
1403
+ */
1404
+ vtctldAddr?: string;
1405
+ /**
1406
+ * Default cell (failure domain) for operations that need one, e.g.
1407
+ * `zone1`. Vitess clusters always have at least one.
1408
+ */
1409
+ cell?: string;
1410
+ /**
1411
+ * `vtctldclient` release to install, e.g. `21.0.0`.
1412
+ *
1413
+ * Pinned rather than tracking latest: vtctldclient talks gRPC to vtctld
1414
+ * and Vitess only supports a bounded version skew between them, so an
1415
+ * unpinned client can start failing the day the cluster is upgraded.
1416
+ */
1417
+ clientVersion?: string;
1418
+ /**
1419
+ * DDL strategy for schema changes applied through the dashboard.
1420
+ *
1421
+ * `vitess` (the default) runs Vitess's own online DDL, which applies
1422
+ * shard by shard without locking the keyspace and is revertible.
1423
+ * `direct` runs the DDL synchronously and WILL lock; it exists for
1424
+ * unsharded keyspaces where that is acceptable and faster.
1425
+ */
1426
+ ddlStrategy?: 'vitess' | 'direct';
1345
1427
  }
1346
1428
  /**
1347
1429
  * An extra database user provisioned on the on-box engine (per-user grants).
@@ -2570,7 +2652,82 @@ export interface ComputePhpConfig {
2570
2652
  * Each entry is `true` (install with defaults) or an object pinning a version.
2571
2653
  * See {@link ComputeConfig.services}.
2572
2654
  */
2655
+ export interface VitessKeyspaceConfig {
2656
+ /** Keyspace name. */
2657
+ name: string;
2658
+ /**
2659
+ * Whether the keyspace is sharded. An unsharded keyspace has one shard
2660
+ * (`0`) and needs no VSchema to be routable, which makes it the right
2661
+ * starting point for an application that has not yet decided how to shard.
2662
+ */
2663
+ sharded?: boolean;
2664
+ }
2665
+ export interface VitessServiceConfig {
2666
+ /**
2667
+ * `combo` for a single-process development stack, `cluster` for real
2668
+ * daemons. Defaults to `cluster`, because a config that provisions
2669
+ * infrastructure should not quietly give you a non-durable one.
2670
+ */
2671
+ mode?: 'combo' | 'cluster';
2672
+ /**
2673
+ * Pantry version spec for `vitess.io`. Omit for the registry's latest.
2674
+ *
2675
+ * **Requires Vitess 20 or newer.** Vitess renamed every daemon flag from
2676
+ * `snake_case` to `kebab-case` in v20 and removed the old spellings in a
2677
+ * later release; the generated systemd units use the current names, so
2678
+ * pinning an older version produces daemons that refuse to start.
2679
+ */
2680
+ version?: string;
2681
+ /** Cell (failure domain) name. Vitess requires at least one. */
2682
+ cell?: string;
2683
+ /** Keyspaces to create at provision time. */
2684
+ keyspaces?: VitessKeyspaceConfig[];
2685
+ /** Override vtgate's MySQL port. Applications connect here. */
2686
+ vtgatePort?: number;
2687
+ /**
2688
+ * Username applications authenticate to vtgate with. Defaults to `vitess`.
2689
+ *
2690
+ * vtgate requires an auth server; there is no unauthenticated cluster mode
2691
+ * worth offering, since its port would otherwise be an open database.
2692
+ */
2693
+ username?: string;
2694
+ /** Password for {@link username}. */
2695
+ password?: string;
2696
+ /**
2697
+ * Address vtgate binds its MySQL port to. Defaults to `127.0.0.1`.
2698
+ *
2699
+ * The single-box model puts the application on this same host, so the
2700
+ * default keeps the database off the network entirely. Set `0.0.0.0` only
2701
+ * when something off-box genuinely needs to connect, and pair it with a
2702
+ * firewall rule.
2703
+ */
2704
+ bindAddress?: string;
2705
+ /**
2706
+ * External topology store, e.g. `http://etcd-a.internal:2379`. When set,
2707
+ * etcd is not installed on the box and the daemons point here instead.
2708
+ */
2709
+ etcdEndpoint?: string;
2710
+ /**
2711
+ * MySQL port for the tablet's managed mysqld. Not something applications
2712
+ * should connect to: writing directly to a tablet's mysqld bypasses Vitess.
2713
+ */
2714
+ mysqlPort?: number;
2715
+ }
2573
2716
  export interface ComputeServicesConfig {
2717
+ /**
2718
+ * Provision Vitess on this box.
2719
+ *
2720
+ * `true` provisions a single-box cluster (etcd, vtctld, vttablet beside a
2721
+ * managed mysqld, vtgate) with default ports. Pass an object for keyspaces,
2722
+ * an external topology store, or `mode: 'combo'` - a single-process
2723
+ * development stack that is NOT durable.
2724
+ *
2725
+ * Single-box by design: spreading tablets across machines needs per-shard
2726
+ * placement and reparent policy, which are operator decisions rather than
2727
+ * provisioner defaults. A sharded keyspace here gets Vitess's routing and
2728
+ * online DDL, not fault tolerance.
2729
+ */
2730
+ vitess?: boolean | VitessServiceConfig;
2574
2731
  mysql?: boolean | {
2575
2732
  version?: string;
2576
2733
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ts-cloud/core",
3
3
  "type": "module",
4
- "version": "0.7.93",
4
+ "version": "0.7.94",
5
5
  "description": "Core CloudFormation generation library for ts-cloud",
6
6
  "author": "Chris Breuer <chris@stacksjs.com>",
7
7
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "typecheck": "tsc --noEmit"
32
32
  },
33
33
  "dependencies": {
34
- "@ts-cloud/aws-types": "0.7.93"
34
+ "@ts-cloud/aws-types": "0.7.94"
35
35
  },
36
36
  "devDependencies": {
37
37
  "typescript": "^7.0.2"