Skip to content

Commit

Permalink
feat: satellite ids
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker committed Feb 16, 2024
1 parent 80cc9a3 commit 9d2fba2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
25 changes: 22 additions & 3 deletions packages/config/src/types/juno.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type {ENCODING_TYPE} from './encoding';
import {JunoConfigMode} from './juno.env';
import type {StorageConfig} from './storage.config';
import {Either} from './utility';

export interface SatelliteAssertions {
/**
Expand All @@ -13,12 +15,29 @@ export interface SatelliteAssertions {
heapMemory?: number | boolean;
}

export interface SatelliteConfig {
export interface SatelliteId {
/**
* The unique identifier (ID) of the satellite where the application will be deployed.
* The unique identifier (ID) of the satellite for this application.
*/
satelliteId: string;
}

export interface SatelliteIds {
/**
* A mapping of satellite identifiers (IDs) to different configurations based on the environment of the application.
*
* This allows the application to use different satellite IDs based on the operating environment, such as production, staging, development, etc.
*
* Example:
* {
* "production": "xo2hm-lqaaa-aaaal-ab3oa-cai",
* "staging": "gl6nx-5maaa-aaaaa-qaaqq-cai"
* }
*/
satellitesIds: Record<JunoConfigMode, string>;
}

export type SatelliteConfig = Either<SatelliteId, SatelliteIds> & {
/**
* Specifies the directory from which to deploy to storage.
* For instance, if `npm run build` outputs files to a `dist` folder, use `source: 'dist'`.
Expand Down Expand Up @@ -59,7 +78,7 @@ export interface SatelliteConfig {
* Optional configurations to override default assertions made by the CLI regarding satellite deployment conditions.
*/
assertions?: SatelliteAssertions;
}
};

export interface OrbiterConfig {
/**
Expand Down
4 changes: 3 additions & 1 deletion packages/config/src/types/juno.env.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export type JunoConfigMode = 'production' | 'development' | string;

export interface JunoConfigEnv {
mode: 'production' | 'development' | string;
mode: JunoConfigMode;
}
8 changes: 8 additions & 0 deletions packages/config/src/types/utility.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Source: https://stackoverflow.com/a/66605669/5404186
export type Only<T, U> = {
[P in keyof T]: T[P];
} & {
[P in keyof U]?: never;
};

export type Either<T, U> = Only<T, U> | Only<U, T>;

0 comments on commit 9d2fba2

Please sign in to comment.