@sylphx/cli 0.15.0 → 0.15.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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @sylphx/cli
2
2
 
3
+ ## 0.15.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1901](https://github.com/SylphxAI/platform/pull/1901) [`5ad7c51`](https://github.com/SylphxAI/platform/commit/5ad7c51f09a629d54dbaab936dbc065baa5b546f) Thanks [@shtse8](https://github.com/shtse8)! - Fix org management CLI contract coverage and project-session data boundaries.
8
+
9
+ - Updated dependencies []:
10
+ - @sylphx/sdk@0.19.1
11
+
3
12
  ## 0.15.0
4
13
 
5
14
  ### Minor Changes
package/dist/main.js CHANGED
@@ -15,7 +15,7 @@ var init_package = __esm({
15
15
  "package.json"() {
16
16
  package_default = {
17
17
  name: "@sylphx/cli",
18
- version: "0.15.0",
18
+ version: "0.15.1",
19
19
  description: "Sylphx Platform CLI \u2014 deploy and manage your applications from the terminal. 63 commands across deployment, logs, env vars, domains, databases, storage, monitoring, self-service (user), admin (users/quotas/audit/invitations/jwt-keys/project-migrate), and more.",
20
20
  type: "module",
21
21
  homepage: "https://sylphx.com",
@@ -71,7 +71,7 @@ var init_package = __esm({
71
71
  "@effect/cli": "0.75.1",
72
72
  "@effect/platform": "0.96.0",
73
73
  "@effect/platform-bun": "0.89.0",
74
- "@sylphx/sdk": "0.19.0",
74
+ "@sylphx/sdk": "0.19.1",
75
75
  chalk: "^5.3.0",
76
76
  effect: "3.21.0",
77
77
  eventsource: "^2.0.2",
@@ -5840,7 +5840,7 @@ var init_analytics_admin = __esm({
5840
5840
 
5841
5841
  // ../contract/dist/schemas/organization.js
5842
5842
  import { Schema as Schema39 } from "effect";
5843
- var OrgName, OrgSlug, Organization, OrgProjectSummary, MyOrgResponse, OrgMemberRole, UserOrganizationMembership, UserOrganizationsResponse, OrgDetail, OrgSettings, CreateOrgInput, UpdateOrgInput, OrgMember, InviteMemberInput, InviteMemberResult, UpdateMemberRoleInput, UpdateMemberRoleResult, RemoveMemberResult, ListMembersResult, OrgSdkRole, MembershipInfo, OrgInvitation, ProjectSession;
5843
+ var OrgName, OrgSlug, Organization, OrgProjectSummary, MyOrgResponse, OrgMemberRole, UserOrganizationMembership, UserOrganizationsResponse, OrgDetail, OrgSettings, CreateOrgInput, UpdateOrgInput, OrgMember, InviteMemberInput, InviteMemberResult, UpdateMemberRoleInput, UpdateMemberRoleResult, RemoveMemberResult, ListMembersResult, OrgSdkRole, MembershipInfo, OrgInvitation, ProjectSession, OrgAuditEntry, ListOrgAuditResult;
5844
5844
  var init_organization = __esm({
5845
5845
  "../contract/dist/schemas/organization.js"() {
5846
5846
  "use strict";
@@ -5993,6 +5993,21 @@ var init_organization = __esm({
5993
5993
  createdAt: Schema39.String,
5994
5994
  expiresAt: Schema39.String
5995
5995
  });
5996
+ OrgAuditEntry = Schema39.Struct({
5997
+ id: Schema39.String,
5998
+ createdAt: Schema39.String,
5999
+ actorId: Schema39.NullOr(Schema39.String),
6000
+ actorEmail: Schema39.NullOr(Schema39.String),
6001
+ action: Schema39.String,
6002
+ resourceType: Schema39.String,
6003
+ resourceId: Schema39.NullOr(Schema39.String),
6004
+ metadata: Schema39.NullOr(Schema39.Record({ key: Schema39.String, value: Schema39.Unknown })),
6005
+ orgId: Schema39.NullOr(Schema39.String),
6006
+ projectId: Schema39.NullOr(Schema39.String)
6007
+ });
6008
+ ListOrgAuditResult = Schema39.Struct({
6009
+ entries: Schema39.Array(OrgAuditEntry)
6010
+ });
5996
6011
  }
5997
6012
  });
5998
6013
 
@@ -12134,7 +12149,7 @@ var init_organization_team = __esm({
12134
12149
 
12135
12150
  // ../contract/dist/endpoints/organizations.js
12136
12151
  import { Schema as Schema85 } from "effect";
12137
- var OrgPath, OrgSlugPath, OrgMemberPath, ProjectIdPath6, ProjectUpdatePath, ProjectSlugOrIdPath, ProjectUserPath, ProjectSessionPath, ListPaginationQuery, ListSessionsQuery, billingEndpoints, projectsEndpoints, projectUsersEndpoints, teamEndpoints, referralsEndpoints, organizationsEndpoints;
12152
+ var OrgPath, OrgSlugPath, OrgMemberPath, ProjectIdPath6, ProjectUpdatePath, ProjectSlugOrIdPath, ProjectUserPath, ProjectSessionPath, ListPaginationQuery, ListSessionsQuery, ListOrgAuditQuery, billingEndpoints, projectsEndpoints, projectUsersEndpoints, teamEndpoints, referralsEndpoints, organizationsEndpoints;
12138
12153
  var init_organizations = __esm({
12139
12154
  "../contract/dist/endpoints/organizations.js"() {
12140
12155
  "use strict";
@@ -12165,6 +12180,11 @@ var init_organizations = __esm({
12165
12180
  offset: Schema85.optional(Schema85.String),
12166
12181
  environmentId: Schema85.optional(Schema85.String)
12167
12182
  });
12183
+ ListOrgAuditQuery = Schema85.Struct({
12184
+ since: Schema85.optional(Schema85.String),
12185
+ limit: Schema85.optional(Schema85.String),
12186
+ actor: Schema85.optional(Schema85.String)
12187
+ });
12168
12188
  billingEndpoints = {
12169
12189
  getUsage: defineEndpoint({
12170
12190
  method: "GET",
@@ -12582,6 +12602,14 @@ var init_organizations = __esm({
12582
12602
  summary: "Revoke all sessions on a project (admin only)",
12583
12603
  tags: ["organizations"]
12584
12604
  }),
12605
+ listAudit: defineEndpoint({
12606
+ method: "GET",
12607
+ path: "/orgs/audit/logs",
12608
+ query: ListOrgAuditQuery,
12609
+ response: ListOrgAuditResult,
12610
+ summary: "List recent audit log entries visible to the current organization",
12611
+ tags: ["organizations"]
12612
+ }),
12585
12613
  // ── Wave 3F sub-groups ────────────────────────────────────────────
12586
12614
  billing: billingEndpoints,
12587
12615
  projects: projectsEndpoints,
@@ -18401,12 +18429,15 @@ __export(organizations_exports, {
18401
18429
  current: () => current,
18402
18430
  getSettings: () => getSettings2,
18403
18431
  inviteMember: () => inviteMember,
18432
+ listAudit: () => listAudit,
18404
18433
  listMembers: () => listMembers,
18405
18434
  listMemberships: () => listMemberships,
18435
+ listProjectSessions: () => listProjectSessions,
18406
18436
  removeMember: () => removeMember,
18437
+ revokeProjectSession: () => revokeProjectSession,
18407
18438
  updateMemberRole: () => updateMemberRole
18408
18439
  });
18409
- var current, listMemberships, create9, getSettings2, listMembers, inviteMember, removeMember, updateMemberRole;
18440
+ var current, listMemberships, create9, getSettings2, listMembers, inviteMember, removeMember, updateMemberRole, listProjectSessions, revokeProjectSession, listAudit;
18410
18441
  var init_organizations2 = __esm({
18411
18442
  "../management/dist/organizations.js"() {
18412
18443
  "use strict";
@@ -18449,6 +18480,18 @@ var init_organizations2 = __esm({
18449
18480
  body: { role }
18450
18481
  });
18451
18482
  };
18483
+ listProjectSessions = (client, projectId, query) => {
18484
+ const { method, path: path7 } = organizationsEndpoints.listProjectSessions;
18485
+ return request(client, method, interpolatePath(path7, { projectId }), query ? { query } : {});
18486
+ };
18487
+ revokeProjectSession = (client, projectId, sessionId) => {
18488
+ const { method, path: path7 } = organizationsEndpoints.revokeProjectSession;
18489
+ return request(client, method, interpolatePath(path7, { projectId, sessionId }));
18490
+ };
18491
+ listAudit = (client, query) => {
18492
+ const { method, path: path7 } = organizationsEndpoints.listAudit;
18493
+ return request(client, method, path7, query ? { query } : {});
18494
+ };
18452
18495
  }
18453
18496
  });
18454
18497
 
@@ -22201,35 +22244,38 @@ var ApiServiceLive = Layer2.succeed(ApiService, {
22201
22244
  },
22202
22245
  catch: mapApiError("orgs")
22203
22246
  }),
22204
- listOrgSessions: Effect7.tryPromise({
22247
+ listOrgSessions: (projectId) => Effect7.tryPromise({
22205
22248
  try: async () => {
22206
- const res = await authedFetch("/orgs/sessions");
22207
- if (!Array.isArray(res.sessions)) {
22208
- throw new Error("/orgs/sessions response must include sessions[]");
22209
- }
22210
- return res.sessions;
22249
+ const res = await withAuthedSdk((c2) => organizations_exports.listProjectSessions(c2, projectId));
22250
+ return res.sessions.map((s) => ({
22251
+ id: s.id,
22252
+ userId: s.userId,
22253
+ userEmail: s.userEmail ?? "unknown",
22254
+ ipAddress: s.ip && s.ip !== "Unknown" ? s.ip : null,
22255
+ userAgent: null,
22256
+ createdAt: s.createdAt,
22257
+ lastSeenAt: null,
22258
+ expiresAt: s.expiresAt,
22259
+ projectId
22260
+ }));
22211
22261
  },
22212
22262
  catch: mapApiError("orgs")
22213
22263
  }),
22214
- revokeOrgSession: (sessionId) => Effect7.tryPromise({
22215
- try: () => authedFetch(`/orgs/sessions/${encodeURIComponent(sessionId)}`, {
22216
- method: "DELETE"
22217
- }),
22264
+ revokeOrgSession: (projectId, sessionId) => Effect7.tryPromise({
22265
+ try: async () => {
22266
+ await withAuthedSdk((c2) => organizations_exports.revokeProjectSession(c2, projectId, sessionId));
22267
+ },
22218
22268
  catch: mapApiError("orgs")
22219
22269
  }),
22220
22270
  listOrgAudit: (opts) => Effect7.tryPromise({
22221
22271
  try: async () => {
22222
- const params = new URLSearchParams();
22223
- if (opts.since) params.set("since", opts.since);
22224
- if (opts.limit) params.set("limit", String(opts.limit));
22225
- if (opts.actor) params.set("actor", opts.actor);
22226
- const qs = params.toString();
22227
- const res = await authedFetch(
22228
- `/orgs/audit${qs ? `?${qs}` : ""}`
22272
+ const res = await withAuthedSdk(
22273
+ (c2) => organizations_exports.listAudit(c2, {
22274
+ ...opts.since ? { since: opts.since } : {},
22275
+ ...opts.limit ? { limit: String(opts.limit) } : {},
22276
+ ...opts.actor ? { actor: opts.actor } : {}
22277
+ })
22229
22278
  );
22230
- if (!Array.isArray(res.entries)) {
22231
- throw new Error("/orgs/audit response must include entries[]");
22232
- }
22233
22279
  return res.entries;
22234
22280
  },
22235
22281
  catch: mapApiError("orgs")
@@ -34117,40 +34163,53 @@ var orgsBillingEffect = Effect52.gen(function* () {
34117
34163
  }
34118
34164
  yield* Console40.log("");
34119
34165
  });
34120
- var sessionsListEffect = Effect52.gen(function* () {
34121
- yield* requireAuthEffect;
34122
- const api2 = yield* ApiService;
34123
- const sessions = yield* withSpinner("Fetching sessions...", api2.listOrgSessions);
34124
- if (sessions.length === 0) {
34125
- yield* Console40.log(chalk_default.dim("\n No active sessions.\n"));
34126
- return;
34127
- }
34128
- const colEmail = Math.max(5, ...sessions.map((s) => s.userEmail.length));
34129
- const colIp = Math.max(4, ...sessions.map((s) => (s.ipAddress ?? "\u2014").length));
34130
- yield* Console40.log("");
34131
- yield* Console40.log(chalk_default.bold(" Active sessions"));
34132
- yield* Console40.log(chalk_default.dim(` ${"\u2500".repeat(colEmail + colIp + 40)}`));
34133
- yield* Console40.log(
34134
- chalk_default.dim(
34135
- ` ${"EMAIL".padEnd(colEmail)} ${"IP".padEnd(colIp)} ${"LAST SEEN".padEnd(20)} ID`
34136
- )
34137
- );
34138
- yield* Console40.log(chalk_default.dim(` ${"\u2500".repeat(colEmail + colIp + 40)}`));
34139
- for (const s of sessions) {
34140
- const last = s.lastSeenAt ? new Date(s.lastSeenAt).toLocaleString() : "";
34166
+ var sessionsListEffect = sessionsListEffectWith();
34167
+ function sessionsListEffectWith(projectOptions = {}) {
34168
+ return Effect52.gen(function* () {
34169
+ yield* requireAuthEffect;
34170
+ const target = yield* resolveProjectScopeEffect("org sessions list", projectOptions);
34171
+ const api2 = yield* ApiService;
34172
+ const sessions = yield* withSpinner(
34173
+ "Fetching sessions...",
34174
+ api2.listOrgSessions(target.projectId)
34175
+ );
34176
+ if (sessions.length === 0) {
34177
+ yield* Console40.log(chalk_default.dim(`
34178
+ No active sessions for ${target.projectId}.
34179
+ `));
34180
+ return;
34181
+ }
34182
+ const colEmail = Math.max(5, ...sessions.map((s) => s.userEmail.length));
34183
+ const colIp = Math.max(4, ...sessions.map((s) => (s.ipAddress ?? "\u2014").length));
34184
+ yield* Console40.log("");
34185
+ yield* Console40.log(chalk_default.bold(` Active sessions \u2014 ${target.projectId}`));
34186
+ yield* Console40.log(chalk_default.dim(` ${"\u2500".repeat(colEmail + colIp + 40)}`));
34141
34187
  yield* Console40.log(
34142
- ` ${s.userEmail.padEnd(colEmail)} ${(s.ipAddress ?? chalk_default.dim("\u2014")).padEnd(colIp)} ${chalk_default.dim(last.padEnd(20))} ${chalk_default.dim(s.id)}`
34188
+ chalk_default.dim(
34189
+ ` ${"EMAIL".padEnd(colEmail)} ${"IP".padEnd(colIp)} ${"LAST SEEN".padEnd(20)} ID`
34190
+ )
34143
34191
  );
34144
- }
34145
- yield* Console40.log("");
34146
- yield* Console40.log(chalk_default.dim(` ${sessions.length} session${sessions.length !== 1 ? "s" : ""}`));
34147
- yield* Console40.log("");
34148
- });
34149
- function sessionsRevokeEffect(sessionId) {
34192
+ yield* Console40.log(chalk_default.dim(` ${"\u2500".repeat(colEmail + colIp + 40)}`));
34193
+ for (const s of sessions) {
34194
+ const last = s.lastSeenAt ? new Date(s.lastSeenAt).toLocaleString() : "";
34195
+ yield* Console40.log(
34196
+ ` ${s.userEmail.padEnd(colEmail)} ${(s.ipAddress ?? chalk_default.dim("\u2014")).padEnd(colIp)} ${chalk_default.dim(last.padEnd(20))} ${chalk_default.dim(s.id)}`
34197
+ );
34198
+ }
34199
+ yield* Console40.log("");
34200
+ yield* Console40.log(chalk_default.dim(` ${sessions.length} session${sessions.length !== 1 ? "s" : ""}`));
34201
+ yield* Console40.log("");
34202
+ });
34203
+ }
34204
+ function sessionsRevokeEffect(sessionId, projectOptions = {}) {
34150
34205
  return Effect52.gen(function* () {
34151
34206
  yield* requireAuthEffect;
34207
+ const target = yield* resolveProjectScopeEffect("org sessions revoke", projectOptions);
34152
34208
  const api2 = yield* ApiService;
34153
- yield* withSpinner(`Revoking session ${sessionId}...`, api2.revokeOrgSession(sessionId));
34209
+ yield* withSpinner(
34210
+ `Revoking session ${sessionId}...`,
34211
+ api2.revokeOrgSession(target.projectId, sessionId)
34212
+ );
34154
34213
  yield* Console40.log(chalk_default.green(`\u2713 Revoked session ${chalk_default.bold(sessionId)}`));
34155
34214
  });
34156
34215
  }
@@ -34238,16 +34297,36 @@ function makeBillingCommand() {
34238
34297
  );
34239
34298
  }
34240
34299
  function makeSessionsCommand() {
34241
- const sessionsListCmd2 = Command39.make("list", {}, () => sessionsListEffect).pipe(
34242
- Command39.withDescription("List active sessions for all members in the org")
34300
+ const projectOption42 = Options40.text("project").pipe(
34301
+ Options40.withDescription("Project id, slug, name, or ref (defaults to the linked project)"),
34302
+ Options40.optional
34303
+ );
34304
+ const orgOption31 = Options40.text("org").pipe(
34305
+ Options40.withDescription("Organization slug, id, or name for cross-org project access"),
34306
+ Options40.optional
34307
+ );
34308
+ const scopedOptions2 = (input) => ({
34309
+ project: input.project._tag === "Some" ? input.project.value : void 0,
34310
+ org: input.org._tag === "Some" ? input.org.value : void 0
34311
+ });
34312
+ const sessionsListCmd2 = Command39.make(
34313
+ "list",
34314
+ { project: projectOption42, org: orgOption31 },
34315
+ ({ project, org }) => sessionsListEffectWith(scopedOptions2({ project, org }))
34316
+ ).pipe(
34317
+ Command39.withDescription("List active app-user sessions for the linked or explicit project")
34243
34318
  );
34244
34319
  const sessionsRevokeCmd2 = Command39.make(
34245
34320
  "revoke",
34246
- { sessionId: Args25.text({ name: "session-id" }) },
34247
- ({ sessionId }) => sessionsRevokeEffect(sessionId)
34248
- ).pipe(Command39.withDescription("Revoke a single session by id"));
34249
- return Command39.make("sessions", {}, () => sessionsListEffect).pipe(
34250
- Command39.withDescription("Manage active sessions across the org"),
34321
+ { sessionId: Args25.text({ name: "session-id" }), project: projectOption42, org: orgOption31 },
34322
+ ({ sessionId, project, org }) => sessionsRevokeEffect(sessionId, scopedOptions2({ project, org }))
34323
+ ).pipe(Command39.withDescription("Revoke a single app-user session by id"));
34324
+ return Command39.make(
34325
+ "sessions",
34326
+ { project: projectOption42, org: orgOption31 },
34327
+ ({ project, org }) => sessionsListEffectWith(scopedOptions2({ project, org }))
34328
+ ).pipe(
34329
+ Command39.withDescription("Manage active app-user sessions for a project"),
34251
34330
  Command39.withSubcommands([sessionsListCmd2, sessionsRevokeCmd2])
34252
34331
  );
34253
34332
  }