gigadrive 2.5.4 → 2.5.6

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.mjs CHANGED
@@ -9,7 +9,7 @@ import { Effect as Effect27, Layer, LogLevel, Logger } from "effect";
9
9
  // package.json
10
10
  var package_default = {
11
11
  name: "gigadrive",
12
- version: "2.5.4",
12
+ version: "2.5.6",
13
13
  repository: {
14
14
  type: "git",
15
15
  url: "https://github.com/Gigadrive/sdk.git",
@@ -62,7 +62,7 @@ var package_default = {
62
62
  // src/commands/ai/index.ts
63
63
  import { Args, Command, Options } from "@effect/cli";
64
64
  import { FileSystem as FileSystem3 } from "@effect/platform";
65
- import { Console as Console2, Effect as Effect6, Option as Option4 } from "effect";
65
+ import { Console as Console2, Effect as Effect6, Option as Option5 } from "effect";
66
66
 
67
67
  // src/errors.ts
68
68
  import { Schema } from "effect";
@@ -309,7 +309,7 @@ var DeploymentFailedError = class extends Schema.TaggedError()("DeploymentFailed
309
309
 
310
310
  // src/services/api-client.ts
311
311
  import { ApiError, GigadriveClient } from "@gigadrive/sdk";
312
- import { Config as Config2, Effect as Effect4 } from "effect";
312
+ import { Config as Config2, Effect as Effect4, Option as Option3, Redacted } from "effect";
313
313
 
314
314
  // src/services/auth.ts
315
315
  import { Console, Duration, Effect as Effect3, Option as Option2, Schema as Schema5 } from "effect";
@@ -933,6 +933,12 @@ and enter the code:
933
933
 
934
934
  // src/services/api-client.ts
935
935
  var ApiBaseUrl = Config2.string("GIGADRIVE_API_BASE_URL").pipe(Config2.withDefault("https://api.gigadrive.network"));
936
+ var ServiceCredentials = Config2.all({
937
+ bearerToken: Config2.redacted("GIGADRIVE_BEARER_TOKEN").pipe(Config2.option),
938
+ clientId: Config2.string("GIGADRIVE_CLIENT_ID").pipe(Config2.option),
939
+ clientSecret: Config2.redacted("GIGADRIVE_CLIENT_SECRET").pipe(Config2.option),
940
+ refreshToken: Config2.redacted("GIGADRIVE_REFRESH_TOKEN").pipe(Config2.option)
941
+ });
936
942
  var toApiRequestError = (error) => {
937
943
  if (error instanceof ApiError) {
938
944
  return new ApiRequestError({ message: error.message, statusCode: error.status, code: error.code });
@@ -943,8 +949,18 @@ var ApiClientService = class extends Effect4.Service()("ApiClientService", {
943
949
  accessors: true,
944
950
  effect: Effect4.gen(function* () {
945
951
  const baseUrl = yield* ApiBaseUrl;
952
+ const serviceCredentials = yield* ServiceCredentials;
946
953
  const authService = yield* AuthService;
947
- const getClient = Effect4.gen(function* () {
954
+ const hasServiceCredentials = Option3.isSome(serviceCredentials.bearerToken) || Option3.isSome(serviceCredentials.clientId) || Option3.isSome(serviceCredentials.clientSecret) || Option3.isSome(serviceCredentials.refreshToken);
955
+ const getClient = hasServiceCredentials ? Effect4.succeed(
956
+ new GigadriveClient({
957
+ baseUrl,
958
+ bearerToken: Option3.map(serviceCredentials.bearerToken, Redacted.value).pipe(Option3.getOrUndefined),
959
+ clientId: Option3.getOrUndefined(serviceCredentials.clientId),
960
+ clientSecret: Option3.map(serviceCredentials.clientSecret, Redacted.value).pipe(Option3.getOrUndefined),
961
+ refreshToken: Option3.map(serviceCredentials.refreshToken, Redacted.value).pipe(Option3.getOrUndefined)
962
+ })
963
+ ) : Effect4.gen(function* () {
948
964
  const token = yield* authService.getAccessToken;
949
965
  return new GigadriveClient({ bearerToken: token, baseUrl });
950
966
  });
@@ -962,7 +978,7 @@ var ApiClientService = class extends Effect4.Service()("ApiClientService", {
962
978
 
963
979
  // src/services/project-link.ts
964
980
  import { FileSystem as FileSystem2, Path as Path2 } from "@effect/platform";
965
- import { Effect as Effect5, Option as Option3, Schema as Schema6 } from "effect";
981
+ import { Effect as Effect5, Option as Option4, Schema as Schema6 } from "effect";
966
982
  var LINK_DIR = ".gigadrive";
967
983
  var LINK_FILE = "project.json";
968
984
  var ProjectLinkService = class extends Effect5.Service()("ProjectLinkService", {
@@ -975,7 +991,7 @@ var ProjectLinkService = class extends Effect5.Service()("ProjectLinkService", {
975
991
  const load = Effect5.fn("ProjectLinkService.load")(function* (projectFolder) {
976
992
  const file = linkFile(projectFolder);
977
993
  const exists = yield* fs.exists(file).pipe(Effect5.mapError(() => new ProjectLinkReadError({ message: "Failed to check project link existence" })));
978
- if (!exists) return Option3.none();
994
+ if (!exists) return Option4.none();
979
995
  const data = yield* fs.readFileString(file, "utf8").pipe(Effect5.mapError(() => new ProjectLinkReadError({ message: "Failed to read project link file" })));
980
996
  const json = yield* Effect5.try({
981
997
  try: () => JSON.parse(data),
@@ -984,11 +1000,11 @@ var ProjectLinkService = class extends Effect5.Service()("ProjectLinkService", {
984
1000
  const link = yield* Schema6.decodeUnknown(ProjectLink)(json).pipe(
985
1001
  Effect5.mapError(() => new ProjectLinkReadError({ message: `${LINK_DIR}/${LINK_FILE} has an invalid schema` }))
986
1002
  );
987
- return Option3.some(link);
1003
+ return Option4.some(link);
988
1004
  });
989
1005
  const resolve = Effect5.fn("ProjectLinkService.resolve")(function* (projectFolder) {
990
1006
  const link = yield* load(projectFolder);
991
- return yield* Option3.match(link, {
1007
+ return yield* Option4.match(link, {
992
1008
  onNone: () => Effect5.fail(
993
1009
  new ProjectNotLinkedError({
994
1010
  message: 'This directory is not linked to an application. Run "gigadrive link" first.',
@@ -1049,7 +1065,7 @@ var fileOption = Options.text("file").pipe(
1049
1065
  Options.optional
1050
1066
  );
1051
1067
  var resolveOrgId = (org) => Effect6.gen(function* () {
1052
- if (Option4.isSome(org)) return org.value;
1068
+ if (Option5.isSome(org)) return org.value;
1053
1069
  const projectLink = yield* ProjectLinkService;
1054
1070
  const link = yield* projectLink.resolve(process.cwd());
1055
1071
  if (link.organizationId === void 0) {
@@ -1088,7 +1104,7 @@ var readStdin = Effect6.async((resume) => {
1088
1104
  stdin.resume();
1089
1105
  });
1090
1106
  var readJsonInput = (file) => Effect6.gen(function* () {
1091
- const path2 = Option4.getOrUndefined(file);
1107
+ const path2 = Option5.getOrUndefined(file);
1092
1108
  let raw;
1093
1109
  if (path2 === void 0 || path2 === "-") {
1094
1110
  raw = yield* readStdin;
@@ -1117,9 +1133,9 @@ var usageSummaryCommand = Command.make(
1117
1133
  const orgId = yield* resolveOrgId(org);
1118
1134
  const summary = yield* apiClient.request(
1119
1135
  (client) => client.organizations.aiGateway.usage.summary(orgId, {
1120
- applicationId: Option4.getOrUndefined(app),
1121
- from: Option4.getOrUndefined(from),
1122
- to: Option4.getOrUndefined(to)
1136
+ applicationId: Option5.getOrUndefined(app),
1137
+ from: Option5.getOrUndefined(from),
1138
+ to: Option5.getOrUndefined(to)
1123
1139
  })
1124
1140
  );
1125
1141
  yield* Console2.log(JSON.stringify(summary, null, 2));
@@ -1133,9 +1149,9 @@ var usageRequestsCommand = Command.make(
1133
1149
  const orgId = yield* resolveOrgId(org);
1134
1150
  const { items, total } = yield* apiClient.request(
1135
1151
  (client) => client.organizations.aiGateway.usage.requests(orgId, {
1136
- applicationId: Option4.getOrUndefined(app),
1137
- from: Option4.getOrUndefined(from),
1138
- to: Option4.getOrUndefined(to)
1152
+ applicationId: Option5.getOrUndefined(app),
1153
+ from: Option5.getOrUndefined(from),
1154
+ to: Option5.getOrUndefined(to)
1139
1155
  })
1140
1156
  );
1141
1157
  if (items.length === 0) {
@@ -1163,12 +1179,12 @@ var usageExportCommand = Command.make(
1163
1179
  const orgId = yield* resolveOrgId(org);
1164
1180
  const csv = yield* apiClient.request(
1165
1181
  (client) => client.organizations.aiGateway.usage.export(orgId, {
1166
- applicationId: Option4.getOrUndefined(app),
1167
- from: Option4.getOrUndefined(from),
1168
- to: Option4.getOrUndefined(to)
1182
+ applicationId: Option5.getOrUndefined(app),
1183
+ from: Option5.getOrUndefined(from),
1184
+ to: Option5.getOrUndefined(to)
1169
1185
  })
1170
1186
  );
1171
- const outPath = Option4.getOrUndefined(out);
1187
+ const outPath = Option5.getOrUndefined(out);
1172
1188
  if (outPath === void 0) {
1173
1189
  yield* Console2.log(csv);
1174
1190
  } else {
@@ -1222,7 +1238,7 @@ var policiesGetCommand = Command.make(
1222
1238
  const apiClient = yield* ApiClientService;
1223
1239
  const orgId = yield* resolveOrgId(org);
1224
1240
  const policy = yield* apiClient.request(
1225
- (client) => client.organizations.aiGateway.policies.get(orgId, { applicationId: Option4.getOrUndefined(app) })
1241
+ (client) => client.organizations.aiGateway.policies.get(orgId, { applicationId: Option5.getOrUndefined(app) })
1226
1242
  );
1227
1243
  yield* Console2.log(policy === null ? "No policy set." : JSON.stringify(policy, null, 2));
1228
1244
  }).pipe(Effect6.catchTags(governanceErrorHandlers))
@@ -1313,7 +1329,7 @@ var aiCommand = aiBase.pipe(
1313
1329
 
1314
1330
  // src/commands/apps/index.ts
1315
1331
  import { Command as Command2, Options as Options2 } from "@effect/cli";
1316
- import { Console as Console3, Effect as Effect7, Option as Option5 } from "effect";
1332
+ import { Console as Console3, Effect as Effect7, Option as Option6 } from "effect";
1317
1333
  var listOrgOption = Options2.text("org").pipe(
1318
1334
  Options2.withAlias("o"),
1319
1335
  Options2.withDescription("Only list applications belonging to this organization ID"),
@@ -1340,7 +1356,7 @@ var appsListCommand = Command2.make(
1340
1356
  { org: listOrgOption },
1341
1357
  ({ org }) => Effect7.gen(function* () {
1342
1358
  const apiClient = yield* ApiClientService;
1343
- const organizationId = Option5.getOrUndefined(org);
1359
+ const organizationId = Option6.getOrUndefined(org);
1344
1360
  const { items, total } = yield* apiClient.request((client) => client.applications.list({ organizationId }));
1345
1361
  if (items.length === 0) {
1346
1362
  yield* Console3.log("No applications found.");
@@ -1369,8 +1385,8 @@ var appsCreateCommand = Command2.make(
1369
1385
  (client) => client.applications.create({
1370
1386
  organizationId: org,
1371
1387
  name,
1372
- ...Option5.match(slug, { onNone: () => ({}), onSome: (value) => ({ slug: value }) }),
1373
- ...Option5.match(rootDirectory, {
1388
+ ...Option6.match(slug, { onNone: () => ({}), onSome: (value) => ({ slug: value }) }),
1389
+ ...Option6.match(rootDirectory, {
1374
1390
  onNone: () => ({}),
1375
1391
  onSome: (value) => ({ rootDirectory: value })
1376
1392
  })
@@ -1677,7 +1693,7 @@ var debugCommand = debugBase.pipe(Command5.withSubcommands([debugConfigCommand])
1677
1693
 
1678
1694
  // src/commands/deployments/index.ts
1679
1695
  import { Args as Args2, Command as Command6, Options as Options3 } from "@effect/cli";
1680
- import { Console as Console6, Effect as Effect13, Option as Option6 } from "effect";
1696
+ import { Console as Console6, Effect as Effect13, Option as Option7 } from "effect";
1681
1697
  var DEPLOYMENT_STATUSES = ["PENDING", "QUEUED", "STARTING", "BUILDING", "PROVISIONING", "ACTIVE", "FAILED"];
1682
1698
  var appOption2 = Options3.text("app").pipe(
1683
1699
  Options3.withAlias("a"),
@@ -1694,12 +1710,12 @@ var statusOption = Options3.choice("status", DEPLOYMENT_STATUSES).pipe(
1694
1710
  Options3.withDescription("Filter by deployment status"),
1695
1711
  Options3.optional
1696
1712
  );
1697
- var resolveApplicationFilter = (app) => Option6.match(app, {
1713
+ var resolveApplicationFilter = (app) => Option7.match(app, {
1698
1714
  onSome: (id) => Effect13.succeed(id),
1699
1715
  onNone: () => Effect13.gen(function* () {
1700
1716
  const projectLink = yield* ProjectLinkService;
1701
1717
  const link = yield* projectLink.load(process.cwd());
1702
- return Option6.match(link, { onNone: () => void 0, onSome: (l) => l.applicationId });
1718
+ return Option7.match(link, { onNone: () => void 0, onSome: (l) => l.applicationId });
1703
1719
  })
1704
1720
  });
1705
1721
  var deploymentsListCommand = Command6.make(
@@ -1711,8 +1727,8 @@ var deploymentsListCommand = Command6.make(
1711
1727
  const { items, total } = yield* apiClient.request(
1712
1728
  (client) => client.deployments.list({
1713
1729
  applicationId,
1714
- organizationId: Option6.getOrUndefined(org),
1715
- status: Option6.getOrUndefined(status)
1730
+ organizationId: Option7.getOrUndefined(org),
1731
+ status: Option7.getOrUndefined(status)
1716
1732
  })
1717
1733
  );
1718
1734
  if (items.length === 0) {
@@ -1769,11 +1785,11 @@ var deploymentsCommand = deploymentsBase.pipe(
1769
1785
 
1770
1786
  // src/commands/env/index.ts
1771
1787
  import { Args as Args3, Command as Command7, Options as Options4, Prompt } from "@effect/cli";
1772
- import { Console as Console7, Effect as Effect17, Option as Option10 } from "effect";
1788
+ import { Console as Console7, Effect as Effect17, Option as Option11 } from "effect";
1773
1789
 
1774
1790
  // src/services/env-file.ts
1775
1791
  import { FileSystem as FileSystem6, Path as Path5 } from "@effect/platform";
1776
- import { Effect as Effect14, Option as Option7 } from "effect";
1792
+ import { Effect as Effect14, Option as Option8 } from "effect";
1777
1793
 
1778
1794
  // src/lib/dotenv.ts
1779
1795
  var DEFAULT_ENV_HEADER = "# Generated by `gigadrive env pull` \u2014 do not edit by hand.";
@@ -1841,9 +1857,9 @@ var EnvFileService = class extends Effect14.Service()("EnvFileService", {
1841
1857
  });
1842
1858
  const read = Effect14.fn("EnvFileService.read")(function* (filePath) {
1843
1859
  const present = yield* exists(filePath);
1844
- if (!present) return Option7.none();
1860
+ if (!present) return Option8.none();
1845
1861
  const contents = yield* fs.readFileString(filePath, "utf8").pipe(Effect14.mapError(() => new EnvFileReadError({ message: `Failed to read ${filePath}` })));
1846
- return Option7.some(contents);
1862
+ return Option8.some(contents);
1847
1863
  });
1848
1864
  const write = Effect14.fn("EnvFileService.write")(function* (filePath, entries, opts) {
1849
1865
  const dir = pathService.dirname(filePath);
@@ -1866,7 +1882,7 @@ var EnvFileService = class extends Effect14.Service()("EnvFileService", {
1866
1882
  const ensureGitignored = Effect14.fn("EnvFileService.ensureGitignored")(function* (dir, entry) {
1867
1883
  const gitignorePath = pathService.join(dir, ".gitignore");
1868
1884
  const existing = yield* read(gitignorePath);
1869
- const current = Option7.getOrElse(existing, () => "");
1885
+ const current = Option8.getOrElse(existing, () => "");
1870
1886
  const alreadyIgnored = current.split("\n").some((line) => line.trim() === entry);
1871
1887
  if (alreadyIgnored) {
1872
1888
  return false;
@@ -1886,12 +1902,12 @@ var EnvFileService = class extends Effect14.Service()("EnvFileService", {
1886
1902
  };
1887
1903
 
1888
1904
  // src/services/local-credentials.ts
1889
- import { Config as Config3, Effect as Effect16, Option as Option9 } from "effect";
1905
+ import { Config as Config3, Effect as Effect16, Option as Option10 } from "effect";
1890
1906
  import * as os3 from "os";
1891
1907
 
1892
1908
  // src/services/dev-credentials-store.ts
1893
1909
  import { FileSystem as FileSystem7, Path as Path6 } from "@effect/platform";
1894
- import { Effect as Effect15, Option as Option8, Schema as Schema7 } from "effect";
1910
+ import { Effect as Effect15, Option as Option9, Schema as Schema7 } from "effect";
1895
1911
  import * as os2 from "os";
1896
1912
  var DevCredentialsStore = class extends Effect15.Service()("DevCredentialsStore", {
1897
1913
  accessors: true,
@@ -1931,7 +1947,7 @@ var DevCredentialsStore = class extends Effect15.Service()("DevCredentialsStore"
1931
1947
  const get = Effect15.fn("DevCredentialsStore.get")(function* (applicationId) {
1932
1948
  const store = yield* load;
1933
1949
  const entry = store[applicationId];
1934
- return entry ? Option8.some(entry) : Option8.none();
1950
+ return entry ? Option9.some(entry) : Option9.none();
1935
1951
  });
1936
1952
  const set = Effect15.fn("DevCredentialsStore.set")(function* (applicationId, entry) {
1937
1953
  const store = yield* load;
@@ -1970,11 +1986,11 @@ var LocalCredentialsService = class extends Effect16.Service()("LocalCredentials
1970
1986
  const existing = input.existingContent ? parseEnv(input.existingContent) : {};
1971
1987
  const existingClientId = existing["GIGADRIVE_CLIENT_ID"];
1972
1988
  const existingClientSecret = existing["GIGADRIVE_CLIENT_SECRET"];
1973
- const canReuse = !input.rotate && existingClientId !== void 0 && existingClientSecret !== void 0 && Option9.isSome(stored) && stored.value.apiKeyId === existingClientId;
1989
+ const canReuse = !input.rotate && existingClientId !== void 0 && existingClientSecret !== void 0 && Option10.isSome(stored) && stored.value.apiKeyId === existingClientId;
1974
1990
  if (canReuse) {
1975
1991
  return credentialEntries(existingClientId, existingClientSecret, baseUrl);
1976
1992
  }
1977
- if (Option9.isSome(stored)) {
1993
+ if (Option10.isSome(stored)) {
1978
1994
  yield* apiClient.request((client) => client.apiKeys.delete(stored.value.apiKeyId)).pipe(Effect16.catchTag("ApiRequestError", () => Effect16.void));
1979
1995
  }
1980
1996
  const created = yield* apiClient.request(
@@ -2035,11 +2051,11 @@ var rotateOption = Options4.boolean("rotate").pipe(
2035
2051
  Options4.withDescription("Force a fresh API key when provisioning credentials, revoking the previous one")
2036
2052
  );
2037
2053
  var resolveScope = (app, org) => Effect17.gen(function* () {
2038
- if (Option10.isSome(org)) {
2054
+ if (Option11.isSome(org)) {
2039
2055
  return { kind: "organization", id: org.value };
2040
2056
  }
2041
2057
  const projectLink = yield* ProjectLinkService;
2042
- const id = yield* Option10.match(app, {
2058
+ const id = yield* Option11.match(app, {
2043
2059
  onSome: (value) => Effect17.succeed(value),
2044
2060
  onNone: () => projectLink.resolve(process.cwd()).pipe(Effect17.map((link) => link.applicationId))
2045
2061
  });
@@ -2088,7 +2104,7 @@ var envSetCommand = Command7.make(
2088
2104
  const value = keyValue.slice(separator + 1);
2089
2105
  const apiClient = yield* ApiClientService;
2090
2106
  const scope = yield* resolveScope(app, org);
2091
- const environmentId = Option10.getOrUndefined(env);
2107
+ const environmentId = Option11.getOrUndefined(env);
2092
2108
  const created = yield* apiClient.request(
2093
2109
  (client) => scope.kind === "organization" ? client.organizations.envVars.create(scope.id, { key, value, sensitive }) : client.applications.envVars.create(scope.id, { key, value, sensitive, environmentId })
2094
2110
  );
@@ -2150,17 +2166,17 @@ var envPullCommand = Command7.make(
2150
2166
  const apiClient = yield* ApiClientService;
2151
2167
  const projectLink = yield* ProjectLinkService;
2152
2168
  const envFile = yield* EnvFileService;
2153
- const applicationId = yield* Option10.match(app, {
2169
+ const applicationId = yield* Option11.match(app, {
2154
2170
  onSome: (value) => Effect17.succeed(value),
2155
2171
  onNone: () => projectLink.resolve(process.cwd()).pipe(Effect17.map((link) => link.applicationId))
2156
2172
  });
2157
- const target = Option10.getOrElse(file, () => ".env.local");
2158
- const environmentSlug = Option10.getOrUndefined(environment);
2173
+ const target = Option11.getOrElse(file, () => ".env.local");
2174
+ const environmentSlug = Option11.getOrUndefined(environment);
2159
2175
  const { items, omittedSensitive } = yield* apiClient.request(
2160
2176
  (client) => client.applications.envVars.pull(applicationId, environmentSlug ? { environment: environmentSlug } : void 0)
2161
2177
  );
2162
2178
  const existing = yield* envFile.read(target);
2163
- if (Option10.isSome(existing) && !yes) {
2179
+ if (Option11.isSome(existing) && !yes) {
2164
2180
  const overwrite = yield* Prompt.run(
2165
2181
  Prompt.confirm({ message: `${target} already exists. Overwrite?`, initial: false })
2166
2182
  );
@@ -2174,7 +2190,7 @@ var envPullCommand = Command7.make(
2174
2190
  credentialEntries2 = yield* localCredentials.provision({
2175
2191
  applicationId,
2176
2192
  rotate,
2177
- existingContent: Option10.getOrUndefined(existing)
2193
+ existingContent: Option11.getOrUndefined(existing)
2178
2194
  });
2179
2195
  }
2180
2196
  const entries = [...items.map((v) => ({ key: v.key, value: v.value })), ...credentialEntries2];
@@ -2215,7 +2231,7 @@ var envCommand = envBase.pipe(
2215
2231
 
2216
2232
  // src/commands/link/index.ts
2217
2233
  import { Command as Command8, Options as Options5, Prompt as Prompt2 } from "@effect/cli";
2218
- import { Console as Console8, Effect as Effect18, Option as Option11 } from "effect";
2234
+ import { Console as Console8, Effect as Effect18, Option as Option12 } from "effect";
2219
2235
  var appOption4 = Options5.text("app").pipe(
2220
2236
  Options5.withAlias("a"),
2221
2237
  Options5.withDescription("Application ID to link (skips the interactive picker)"),
@@ -2233,7 +2249,7 @@ var linkCommand = Command8.make(
2233
2249
  const apiClient = yield* ApiClientService;
2234
2250
  const projectLink = yield* ProjectLinkService;
2235
2251
  const cwd = process.cwd();
2236
- const organizationId = Option11.getOrUndefined(org);
2252
+ const organizationId = Option12.getOrUndefined(org);
2237
2253
  const { items: apps } = yield* apiClient.request((client) => client.applications.list({ organizationId }));
2238
2254
  if (apps.length === 0) {
2239
2255
  return yield* Effect18.fail(
@@ -2242,7 +2258,7 @@ var linkCommand = Command8.make(
2242
2258
  })
2243
2259
  );
2244
2260
  }
2245
- const explicitAppId = Option11.getOrUndefined(app);
2261
+ const explicitAppId = Option12.getOrUndefined(app);
2246
2262
  let applicationId;
2247
2263
  let linkedOrganizationId;
2248
2264
  if (explicitAppId !== void 0) {
@@ -2351,7 +2367,7 @@ import { Effect as Effect24 } from "effect";
2351
2367
  import { Command as Command11, Options as Options6, Prompt as Prompt3 } from "@effect/cli";
2352
2368
  import { FileSystem as FileSystem9, Path as Path8 } from "@effect/platform";
2353
2369
  import { formatFileSize } from "@gigadrive/commons";
2354
- import { Console as Console11, Duration as Duration2, Effect as Effect23, Option as Option12, Schedule, Stream } from "effect";
2370
+ import { Console as Console11, Duration as Duration2, Effect as Effect23, Option as Option13, Schedule, Stream } from "effect";
2355
2371
  import * as os4 from "os";
2356
2372
  import * as path from "path";
2357
2373
 
@@ -2656,13 +2672,13 @@ var createAndLinkDeploymentApplication = (input) => Effect23.gen(function* () {
2656
2672
  const projectLink = yield* ProjectLinkService;
2657
2673
  const apiClient = yield* ApiClientService;
2658
2674
  const { items: organizations } = yield* apiClient.request((client) => client.organizations.list());
2659
- const availableOrganizations = Option12.match(input.org, {
2675
+ const availableOrganizations = Option13.match(input.org, {
2660
2676
  onNone: () => organizations,
2661
2677
  onSome: (organizationId) => organizations.filter((organization2) => organization2.id === organizationId)
2662
2678
  });
2663
2679
  if (availableOrganizations.length === 0) {
2664
2680
  return yield* new NoOrganizationsFoundError({
2665
- message: Option12.match(input.org, {
2681
+ message: Option13.match(input.org, {
2666
2682
  onNone: () => 'No organization is available for this deployment. Create an organization, then run "gigadrive deploy" again.',
2667
2683
  onSome: (organizationId) => `Organization "${organizationId}" was not found among your organizations.`
2668
2684
  })
@@ -2678,7 +2694,7 @@ var createAndLinkDeploymentApplication = (input) => Effect23.gen(function* () {
2678
2694
  })
2679
2695
  );
2680
2696
  const inferredName = path.basename(input.cwd) || "Application";
2681
- const applicationName = Option12.match(input.name, {
2697
+ const applicationName = Option13.match(input.name, {
2682
2698
  onNone: () => inferredName,
2683
2699
  onSome: (name) => name
2684
2700
  }).trim();
@@ -2698,12 +2714,12 @@ var createAndLinkDeploymentApplication = (input) => Effect23.gen(function* () {
2698
2714
  var resolveLinkedDeploymentApplication = (input) => Effect23.gen(function* () {
2699
2715
  const projectLink = yield* ProjectLinkService;
2700
2716
  const existingLink = yield* projectLink.load(input.cwd);
2701
- return yield* Option12.match(existingLink, {
2717
+ return yield* Option13.match(existingLink, {
2702
2718
  onNone: () => createAndLinkDeploymentApplication(input),
2703
2719
  onSome: (link) => Effect23.succeed(link.applicationId)
2704
2720
  });
2705
2721
  });
2706
- var resolveDeploymentApplication = (input) => Option12.match(input.app, {
2722
+ var resolveDeploymentApplication = (input) => Option13.match(input.app, {
2707
2723
  onNone: () => resolveLinkedDeploymentApplication(input),
2708
2724
  onSome: Effect23.succeed
2709
2725
  });
@@ -2860,7 +2876,7 @@ var platformCommand = platformBase.pipe(Command12.withSubcommands([deployCommand
2860
2876
 
2861
2877
  // src/commands/setup/index.ts
2862
2878
  import { Args as Args4, Command as Command13, Options as Options7, Prompt as Prompt4 } from "@effect/cli";
2863
- import { Console as Console12, Effect as Effect25, Option as Option13 } from "effect";
2879
+ import { Console as Console12, Effect as Effect25, Option as Option14 } from "effect";
2864
2880
  var fileArg2 = Args4.text({ name: "file" }).pipe(
2865
2881
  Args4.withDescription("Output file to write (default: .env.local)"),
2866
2882
  Args4.optional
@@ -2905,15 +2921,15 @@ var setupCommand = Command13.make(
2905
2921
  const cwd = process.cwd();
2906
2922
  const existingLink = yield* projectLink.load(cwd);
2907
2923
  let applicationId;
2908
- if (Option13.isSome(existingLink)) {
2924
+ if (Option14.isSome(existingLink)) {
2909
2925
  applicationId = existingLink.value.applicationId;
2910
- if (Option13.isSome(app) || Option13.isSome(org)) {
2926
+ if (Option14.isSome(app) || Option14.isSome(org)) {
2911
2927
  yield* Console12.log(
2912
2928
  `Note: this directory is already linked to ${applicationId}; ignoring --app/--org. Run "gigadrive unlink" first to target a different application.`
2913
2929
  );
2914
2930
  }
2915
2931
  } else {
2916
- const organizationId = Option13.getOrUndefined(org);
2932
+ const organizationId = Option14.getOrUndefined(org);
2917
2933
  const { items: apps } = yield* apiClient.request((client) => client.applications.list({ organizationId }));
2918
2934
  if (apps.length === 0) {
2919
2935
  return yield* Effect25.fail(
@@ -2922,7 +2938,7 @@ var setupCommand = Command13.make(
2922
2938
  })
2923
2939
  );
2924
2940
  }
2925
- const explicitAppId = Option13.getOrUndefined(app);
2941
+ const explicitAppId = Option14.getOrUndefined(app);
2926
2942
  let chosen;
2927
2943
  if (explicitAppId !== void 0) {
2928
2944
  const match = apps.find((a) => a.id === explicitAppId);
@@ -2948,13 +2964,13 @@ var setupCommand = Command13.make(
2948
2964
  yield* projectLink.save(cwd, { applicationId, organizationId: chosen.organization.id });
2949
2965
  yield* Console12.log(`Linked this directory to application ${applicationId}.`);
2950
2966
  }
2951
- const target = Option13.getOrElse(file, () => ".env.local");
2952
- const environmentSlug = Option13.getOrUndefined(environment);
2967
+ const target = Option14.getOrElse(file, () => ".env.local");
2968
+ const environmentSlug = Option14.getOrUndefined(environment);
2953
2969
  const { items, omittedSensitive } = yield* apiClient.request(
2954
2970
  (client) => client.applications.envVars.pull(applicationId, environmentSlug ? { environment: environmentSlug } : void 0)
2955
2971
  );
2956
2972
  const existing = yield* envFile.read(target);
2957
- if (Option13.isSome(existing) && !yes) {
2973
+ if (Option14.isSome(existing) && !yes) {
2958
2974
  const overwrite = yield* Prompt4.run(
2959
2975
  Prompt4.confirm({ message: `${target} already exists. Overwrite?`, initial: false })
2960
2976
  );
@@ -2965,7 +2981,7 @@ var setupCommand = Command13.make(
2965
2981
  const credentialEntries2 = yield* localCredentials.provision({
2966
2982
  applicationId,
2967
2983
  rotate,
2968
- existingContent: Option13.getOrUndefined(existing)
2984
+ existingContent: Option14.getOrUndefined(existing)
2969
2985
  });
2970
2986
  const entries = [...items.map((v) => ({ key: v.key, value: v.value })), ...credentialEntries2];
2971
2987
  yield* envFile.write(target, entries);