@keystrokehq/hosting 0.1.9 → 0.1.10

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.cjs CHANGED
@@ -645,6 +645,7 @@ const string$1 = (params) => {
645
645
  const integer = /^-?\d+$/;
646
646
  const number$2 = /^-?\d+(?:\.\d+)?$/;
647
647
  const boolean$1 = /^(?:true|false)$/i;
648
+ const _null$2 = /^null$/i;
648
649
  const lowercase = /^[^A-Z]*$/;
649
650
  const uppercase = /^[^a-z]*$/;
650
651
  //#endregion
@@ -1457,6 +1458,22 @@ const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
1457
1458
  return payload;
1458
1459
  };
1459
1460
  });
1461
+ const $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
1462
+ $ZodType.init(inst, def);
1463
+ inst._zod.pattern = _null$2;
1464
+ inst._zod.values = new Set([null]);
1465
+ inst._zod.parse = (payload, _ctx) => {
1466
+ const input = payload.value;
1467
+ if (input === null) return payload;
1468
+ payload.issues.push({
1469
+ expected: "null",
1470
+ code: "invalid_type",
1471
+ input,
1472
+ inst
1473
+ });
1474
+ return payload;
1475
+ };
1476
+ });
1460
1477
  const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
1461
1478
  $ZodType.init(inst, def);
1462
1479
  inst._zod.parse = (payload) => payload;
@@ -2703,6 +2720,13 @@ function _boolean(Class, params) {
2703
2720
  });
2704
2721
  }
2705
2722
  /* @__NO_SIDE_EFFECTS__ */
2723
+ function _null$1(Class, params) {
2724
+ return new Class({
2725
+ type: "null",
2726
+ ...normalizeParams(params)
2727
+ });
2728
+ }
2729
+ /* @__NO_SIDE_EFFECTS__ */
2706
2730
  function _unknown(Class) {
2707
2731
  return new Class({ type: "unknown" });
2708
2732
  }
@@ -3251,6 +3275,13 @@ const numberProcessor = (schema, ctx, _json, _params) => {
3251
3275
  const booleanProcessor = (_schema, _ctx, json, _params) => {
3252
3276
  json.type = "boolean";
3253
3277
  };
3278
+ const nullProcessor = (_schema, ctx, json, _params) => {
3279
+ if (ctx.target === "openapi-3.0") {
3280
+ json.type = "string";
3281
+ json.nullable = true;
3282
+ json.enum = [null];
3283
+ } else json.type = "null";
3284
+ };
3254
3285
  const neverProcessor = (_schema, _ctx, json, _params) => {
3255
3286
  json.not = {};
3256
3287
  };
@@ -3950,6 +3981,14 @@ const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
3950
3981
  function boolean(params) {
3951
3982
  return /* @__PURE__ */ _boolean(ZodBoolean, params);
3952
3983
  }
3984
+ const ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
3985
+ $ZodNull.init(inst, def);
3986
+ ZodType.init(inst, def);
3987
+ inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json, params);
3988
+ });
3989
+ function _null(params) {
3990
+ return /* @__PURE__ */ _null$1(ZodNull, params);
3991
+ }
3953
3992
  const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
3954
3993
  $ZodUnknown.init(inst, def);
3955
3994
  ZodType.init(inst, def);
@@ -6947,6 +6986,14 @@ object({
6947
6986
  uploadUrl: url(),
6948
6987
  storageKey: string().min(1)
6949
6988
  });
6989
+ function isValidIanaTimezone(value) {
6990
+ try {
6991
+ Intl.DateTimeFormat(void 0, { timeZone: value });
6992
+ return true;
6993
+ } catch {
6994
+ return false;
6995
+ }
6996
+ }
6950
6997
  const UserInterfaceThemeSchema = _enum([
6951
6998
  "system",
6952
6999
  "light",
@@ -6966,22 +7013,25 @@ const UserWorkspaceFavoriteSchema = object({
6966
7013
  ]),
6967
7014
  resourceId: string().min(1)
6968
7015
  });
7016
+ const UserSidebarPreferencesSchema = object({
7017
+ navIconVisibility: UserSidebarNavIconVisibilitySchema,
7018
+ footerChatRowVisibility: UserSidebarFooterChatRowVisibilitySchema,
7019
+ hiddenNavItemIds: array(string()),
7020
+ topNavItemOrderIds: array(string()),
7021
+ workspaceNavItemOrderIds: array(string())
7022
+ });
7023
+ const UserTimezoneSchema = string().refine(isValidIanaTimezone, { message: "Invalid IANA timezone" });
6969
7024
  object({
6970
7025
  interfaceTheme: UserInterfaceThemeSchema,
6971
7026
  surfaceContrast: UserSurfaceContrastSchema,
6972
7027
  layoutMode: UserWorkspaceLayoutModeSchema,
6973
7028
  fontSize: UserWorkspaceFontSizeSchema,
6974
- sidebar: object({
6975
- navIconVisibility: UserSidebarNavIconVisibilitySchema,
6976
- footerChatRowVisibility: UserSidebarFooterChatRowVisibilitySchema,
6977
- hiddenNavItemIds: array(string()),
6978
- topNavItemOrderIds: array(string()),
6979
- workspaceNavItemOrderIds: array(string())
6980
- }),
7029
+ sidebar: UserSidebarPreferencesSchema,
6981
7030
  favorites: array(UserWorkspaceFavoriteSchema),
6982
7031
  projectOrderIds: array(string()),
6983
7032
  projectDotColors: record(string(), string()),
6984
- onboardingTabVisible: boolean()
7033
+ onboardingTabVisible: boolean(),
7034
+ timezone: union([UserTimezoneSchema, _null()])
6985
7035
  });
6986
7036
  const UserSidebarPreferencesPatchSchema = object({
6987
7037
  navIconVisibility: UserSidebarNavIconVisibilitySchema.optional(),
@@ -6999,8 +7049,9 @@ object({
6999
7049
  favorites: array(UserWorkspaceFavoriteSchema).optional(),
7000
7050
  projectOrderIds: array(string()).optional(),
7001
7051
  projectDotColors: record(string(), string()).optional(),
7002
- onboardingTabVisible: boolean().optional()
7003
- }).refine((value) => value.interfaceTheme !== void 0 || value.surfaceContrast !== void 0 || value.layoutMode !== void 0 || value.fontSize !== void 0 || value.sidebar !== void 0 || value.favorites !== void 0 || value.projectOrderIds !== void 0 || value.projectDotColors !== void 0 || value.onboardingTabVisible !== void 0, { message: "At least one preference field is required" });
7052
+ onboardingTabVisible: boolean().optional(),
7053
+ timezone: union([UserTimezoneSchema, _null()]).optional()
7054
+ }).refine((value) => value.interfaceTheme !== void 0 || value.surfaceContrast !== void 0 || value.layoutMode !== void 0 || value.fontSize !== void 0 || value.sidebar !== void 0 || value.favorites !== void 0 || value.projectOrderIds !== void 0 || value.projectDotColors !== void 0 || value.onboardingTabVisible !== void 0 || value.timezone !== void 0, { message: "At least one preference field is required" });
7004
7055
  const OrganizationLogoVariantSchema = _enum(["light", "dark"]);
7005
7056
  object({
7006
7057
  customLogoEnabled: boolean(),
@@ -7629,55 +7680,63 @@ function sleep(ms) {
7629
7680
  const MINIO_DOCKER_NETWORK = process.env.MINIO_DOCKER_NETWORK ?? "keystroke";
7630
7681
  function createDockerRuntime(options = {}) {
7631
7682
  const docker = options.docker ?? new dockerode.default();
7632
- return { async start(input) {
7633
- if (input.projects.length === 0) throw new Error("Docker org runtime requires at least one project deploy");
7634
- let launch = resolveRuntimeLaunch(options, input.projects.map((project) => ({
7635
- projectId: project.projectId,
7636
- artifactStorageKey: project.artifactStorageKey
7637
- })), input.database, input.env);
7638
- if (options.workspacesMount) {
7639
- const { hostPath, containerPath } = options.workspacesMount;
7640
- await (0, node_fs_promises.mkdir)(hostPath, { recursive: true });
7641
- launch = {
7642
- ...launch,
7643
- env: {
7644
- ...launch.env,
7645
- KEYSTROKE_WORKSPACES_ROOT: containerPath
7646
- }
7683
+ return {
7684
+ async start(input) {
7685
+ if (input.projects.length === 0) throw new Error("Docker org runtime requires at least one project deploy");
7686
+ let launch = resolveRuntimeLaunch(options, input.projects.map((project) => ({
7687
+ projectId: project.projectId,
7688
+ artifactStorageKey: project.artifactStorageKey
7689
+ })), input.database, input.env);
7690
+ if (options.workspacesMount) {
7691
+ const { hostPath, containerPath } = options.workspacesMount;
7692
+ await (0, node_fs_promises.mkdir)(hostPath, { recursive: true });
7693
+ launch = {
7694
+ ...launch,
7695
+ env: {
7696
+ ...launch.env,
7697
+ KEYSTROKE_WORKSPACES_ROOT: containerPath
7698
+ }
7699
+ };
7700
+ }
7701
+ await ensureImage(docker, launch.image);
7702
+ await removeExistingContainer(docker, input.organizationId);
7703
+ const binds = [...options.workspacesMount ? [`${options.workspacesMount.hostPath}:${options.workspacesMount.containerPath}`] : [], ...options.extraBinds ?? []];
7704
+ const container = await docker.createContainer({
7705
+ Image: launch.image,
7706
+ name: containerName(input.organizationId),
7707
+ Labels: {
7708
+ "keystroke.organization.id": input.organizationId,
7709
+ "keystroke.project.ids": input.projects.map((project) => project.projectId).join(",")
7710
+ },
7711
+ ExposedPorts: { [`${launch.port}/tcp`]: {} },
7712
+ HostConfig: {
7713
+ ExtraHosts: ["host.docker.internal:host-gateway"],
7714
+ PortBindings: { [`${launch.port}/tcp`]: [{ HostPort: "0" }] },
7715
+ ...binds.length > 0 ? { Binds: binds } : {}
7716
+ },
7717
+ NetworkingConfig: { EndpointsConfig: { [MINIO_DOCKER_NETWORK]: {} } },
7718
+ Env: formatDockerEnv(launch.env)
7719
+ });
7720
+ await container.start();
7721
+ const inspect = await container.inspect();
7722
+ const binding = inspect.NetworkSettings.Ports?.[`${launch.port}/tcp`]?.[0];
7723
+ if (!binding?.HostPort) throw new Error("Failed to resolve org container host port");
7724
+ const baseUrl = `http://127.0.0.1:${binding.HostPort}`;
7725
+ await waitForHealth(baseUrl, {
7726
+ fetchImpl: options.fetchImpl,
7727
+ timeoutMs: options.healthTimeoutMs
7728
+ });
7729
+ return {
7730
+ runtimeId: inspect.Id,
7731
+ baseUrl
7647
7732
  };
7733
+ },
7734
+ async destroy(input) {
7735
+ try {
7736
+ await docker.getContainer(input.runtimeId).remove({ force: true });
7737
+ } catch {}
7648
7738
  }
7649
- await ensureImage(docker, launch.image);
7650
- await removeExistingContainer(docker, input.organizationId);
7651
- const container = await docker.createContainer({
7652
- Image: launch.image,
7653
- name: containerName(input.organizationId),
7654
- Labels: {
7655
- "keystroke.organization.id": input.organizationId,
7656
- "keystroke.project.ids": input.projects.map((project) => project.projectId).join(",")
7657
- },
7658
- ExposedPorts: { [`${launch.port}/tcp`]: {} },
7659
- HostConfig: {
7660
- ExtraHosts: ["host.docker.internal:host-gateway"],
7661
- PortBindings: { [`${launch.port}/tcp`]: [{ HostPort: "0" }] },
7662
- ...options.workspacesMount ? { Binds: [`${options.workspacesMount.hostPath}:${options.workspacesMount.containerPath}`] } : {}
7663
- },
7664
- NetworkingConfig: { EndpointsConfig: { [MINIO_DOCKER_NETWORK]: {} } },
7665
- Env: formatDockerEnv(launch.env)
7666
- });
7667
- await container.start();
7668
- const inspect = await container.inspect();
7669
- const binding = inspect.NetworkSettings.Ports?.[`${launch.port}/tcp`]?.[0];
7670
- if (!binding?.HostPort) throw new Error("Failed to resolve org container host port");
7671
- const baseUrl = `http://127.0.0.1:${binding.HostPort}`;
7672
- await waitForHealth(baseUrl, {
7673
- fetchImpl: options.fetchImpl,
7674
- timeoutMs: options.healthTimeoutMs
7675
- });
7676
- return {
7677
- runtimeId: inspect.Id,
7678
- baseUrl
7679
- };
7680
- } };
7739
+ };
7681
7740
  }
7682
7741
  function containerName(organizationId) {
7683
7742
  return `keystroke-org-${organizationId}`;