axiam-sdk 1.0.0 → 1.1.0

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 (42) hide show
  1. package/README.md +91 -12
  2. package/dist/browser/index.d.cts +1 -1
  3. package/dist/browser/index.d.ts +1 -1
  4. package/dist/{client-yD0eMwHQ.d.cts → client-7ZKtfXW-.d.cts} +640 -14
  5. package/dist/{client-0WJkblDE.d.ts → client-Putxo-yi.d.ts} +640 -14
  6. package/dist/{cookieJar-hWRmZkhe.d.ts → cookieJar-Cw6Zdeec.d.ts} +1 -1
  7. package/dist/{cookieJar-CTD5jOmd.d.cts → cookieJar-DkGcIr-i.d.cts} +1 -1
  8. package/dist/{errors-m0Tue_pE.d.cts → errors-CtP_lviy.d.cts} +15 -1
  9. package/dist/{errors-CmBvsxV0.d.ts → errors-VpViVRSx.d.ts} +15 -1
  10. package/dist/grpc/index.d.cts +3 -3
  11. package/dist/grpc/index.d.ts +3 -3
  12. package/dist/grpc/index.js +572 -14
  13. package/dist/grpc/index.js.map +1 -1
  14. package/dist/grpc/index.mjs +572 -14
  15. package/dist/grpc/index.mjs.map +1 -1
  16. package/dist/index.d.cts +3 -3
  17. package/dist/index.d.ts +3 -3
  18. package/dist/index.js +594 -15
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +592 -16
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/middleware/index.d.cts +3 -3
  23. package/dist/middleware/index.d.ts +3 -3
  24. package/dist/middleware/index.js +26 -3
  25. package/dist/middleware/index.js.map +1 -1
  26. package/dist/middleware/index.mjs +26 -3
  27. package/dist/middleware/index.mjs.map +1 -1
  28. package/dist/node/index.d.cts +3 -3
  29. package/dist/node/index.d.ts +3 -3
  30. package/dist/node/index.js +598 -17
  31. package/dist/node/index.js.map +1 -1
  32. package/dist/node/index.mjs +598 -17
  33. package/dist/node/index.mjs.map +1 -1
  34. package/dist/{oidcState-mQLVn3-A.d.cts → oidcState-Cz6erz0g.d.cts} +24 -3
  35. package/dist/{oidcState-DOSCgnMG.d.ts → oidcState-zGt6VU6v.d.ts} +24 -3
  36. package/dist/rest/index.d.cts +58 -7
  37. package/dist/rest/index.d.ts +58 -7
  38. package/dist/rest/index.js +594 -15
  39. package/dist/rest/index.js.map +1 -1
  40. package/dist/rest/index.mjs +592 -16
  41. package/dist/rest/index.mjs.map +1 -1
  42. package/package.json +1 -1
@@ -1205,6 +1205,12 @@ var SKIP_REFRESH = [
1205
1205
  // regardless of what session state came before it.
1206
1206
  "/api/v1/auth/device",
1207
1207
  "/oauth2/token",
1208
+ // CONTRACT.md §14.2 rule 5 (contract 1.62): a client that fails to
1209
+ // authenticate at the device endpoints is `401 invalid_client`, which is not
1210
+ // an expired session and which refreshing cannot fix. `/oauth2/token` (the
1211
+ // poll) was already here; the authorization endpoint now authenticates the
1212
+ // client too, so its 401 must not enter the §9 guard either.
1213
+ "/oauth2/device_authorization",
1208
1214
  "/oauth2/introspect",
1209
1215
  "/oauth2/revoke"
1210
1216
  ];
@@ -1266,6 +1272,13 @@ function installRefreshInterceptor(axiosInstance, session) {
1266
1272
  }
1267
1273
  );
1268
1274
  }
1275
+ function isOAuth2Endpoint(url) {
1276
+ if (!url) {
1277
+ return false;
1278
+ }
1279
+ const path = url.split(/[?#]/, 1)[0] ?? "";
1280
+ return path.includes("/oauth2/");
1281
+ }
1269
1282
  function installDeviceTokenInterceptor(axiosInstance, session) {
1270
1283
  axiosInstance.interceptors.request.use((config) => {
1271
1284
  const deviceToken = session.deviceAccessToken;
@@ -1275,6 +1288,9 @@ function installDeviceTokenInterceptor(axiosInstance, session) {
1275
1288
  const noCred = session.noCredentialsConfig();
1276
1289
  Object.assign(config, noCred);
1277
1290
  config.headers = config.headers ?? {};
1291
+ if (isOAuth2Endpoint(config.url)) {
1292
+ return config;
1293
+ }
1278
1294
  config.headers["Authorization"] = `Bearer ${deviceToken.expose()}`;
1279
1295
  config.headers["Cookie"] = "";
1280
1296
  return config;
@@ -2233,10 +2249,25 @@ var NotFoundError = class _NotFoundError extends AuthzError {
2233
2249
  var ConflictError = class _ConflictError extends AuthzError {
2234
2250
  /** The registry operation that conflicted. */
2235
2251
  operation;
2236
- constructor(operation, message) {
2252
+ /**
2253
+ * The body's `reason_code`, as the server spelled it (contract 1.62, §36.4),
2254
+ * or `undefined` when the body carries none (a server that predates it, or a
2255
+ * `409` of an operation that does not name one).
2256
+ *
2257
+ * The `409` of every `network` operation says which conflict it is:
2258
+ * `stale_version`, `strands_profile`, `has_children`, `site_gone`,
2259
+ * `duplicate_name`, `duplicate_vlan`, `duplicate_rank`, `profile_exists` or
2260
+ * `other` (§36.3 rule 2). The vocabulary is **open**: a value this SDK does
2261
+ * not know is surfaced verbatim, and a caller branches on this member —
2262
+ * never on `message`, which an SDK must not parse. It is not the `reason` of
2263
+ * an authorization decision (§3), which is a human string.
2264
+ */
2265
+ reasonCode;
2266
+ constructor(operation, message, reasonCode) {
2237
2267
  super(message);
2238
2268
  this.name = "ConflictError";
2239
2269
  this.operation = operation;
2270
+ this.reasonCode = reasonCode;
2240
2271
  Object.setPrototypeOf(this, _ConflictError.prototype);
2241
2272
  }
2242
2273
  };
@@ -2525,6 +2556,14 @@ function omitEmptyTenantScope(body) {
2525
2556
  }
2526
2557
  return body;
2527
2558
  }
2559
+ function omitNullMembers(body, members) {
2560
+ if (!body || typeof body !== "object") return body;
2561
+ const record = body;
2562
+ if (!members.some((m) => m in record && record[m] === null)) return body;
2563
+ const copy = { ...record };
2564
+ for (const m of members) if (copy[m] === null) delete copy[m];
2565
+ return copy;
2566
+ }
2528
2567
  function roleAssignmentInherits(assignment) {
2529
2568
  return assignment.inherit ?? true;
2530
2569
  }
@@ -2997,6 +3036,7 @@ function validate(manifest) {
2997
3036
  const groups = manifest.groups ?? [];
2998
3037
  const users = manifest.users ?? [];
2999
3038
  const serviceAccounts = manifest.serviceAccounts ?? [];
3039
+ const network = manifest.network;
3000
3040
  const resourceKeys = new Set(resources.map((r) => r.key));
3001
3041
  const scopeKeys = new Set(resources.flatMap((r) => (r.scopes ?? []).map((s) => s.key)));
3002
3042
  const permissionKeys = new Set(permissions.map((p) => p.key));
@@ -3010,6 +3050,7 @@ function validate(manifest) {
3010
3050
  duplicates("group", groups.map((g) => g.key), problems);
3011
3051
  duplicates("user", users.map((u) => u.key), problems);
3012
3052
  duplicates("service account", serviceAccounts.map((s) => s.key), problems);
3053
+ if (network !== void 0) validateNetwork(network, problems);
3013
3054
  for (const resource of resources) {
3014
3055
  if (resource.parent && !resourceKeys.has(resource.parent)) {
3015
3056
  problems.push(
@@ -3089,6 +3130,46 @@ function validate(manifest) {
3089
3130
  }
3090
3131
  }
3091
3132
  var q = (s) => JSON.stringify(s);
3133
+ function validateNetwork(network, problems) {
3134
+ if (Array.isArray(network.policy)) {
3135
+ problems.push("network declares more than one policy; the tenant has exactly one");
3136
+ }
3137
+ const segments = network.segments ?? [];
3138
+ const profiles = network.profiles ?? [];
3139
+ duplicates("network segment", segments.map((s) => s.key), problems);
3140
+ const naturalKeys = /* @__PURE__ */ new Set();
3141
+ for (const segment of segments) {
3142
+ const natural = `${segment.site}/${segment.kind}/${segment.name}`;
3143
+ if (naturalKeys.has(natural)) {
3144
+ problems.push(
3145
+ `network segment ${q(natural)} (site, kind, name) is declared more than once`
3146
+ );
3147
+ }
3148
+ naturalKeys.add(natural);
3149
+ const seenFilters = /* @__PURE__ */ new Set();
3150
+ for (const filter of segment.filterIds ?? []) {
3151
+ if (seenFilters.has(filter)) {
3152
+ problems.push(
3153
+ `network segment ${q(segment.key)} lists Filter-Id ${q(filter)} more than once in filterIds`
3154
+ );
3155
+ }
3156
+ seenFilters.add(filter);
3157
+ }
3158
+ }
3159
+ const segmentKeys = new Set(segments.map((s) => s.key));
3160
+ const profiled = /* @__PURE__ */ new Set();
3161
+ for (const profile of profiles) {
3162
+ if (!segmentKeys.has(profile.segment)) {
3163
+ problems.push(
3164
+ `network profile names segment ${q(profile.segment)}, which no network segment declares`
3165
+ );
3166
+ }
3167
+ if (profiled.has(profile.segment)) {
3168
+ problems.push(`network segment ${q(profile.segment)} has more than one profile in the manifest`);
3169
+ }
3170
+ profiled.add(profile.segment);
3171
+ }
3172
+ }
3092
3173
  function duplicates(kind, keys, problems) {
3093
3174
  const seen = /* @__PURE__ */ new Set();
3094
3175
  for (const key of keys) {
@@ -3134,7 +3215,9 @@ var emptyResolved = () => ({
3134
3215
  roles: /* @__PURE__ */ new Map(),
3135
3216
  groups: /* @__PURE__ */ new Map(),
3136
3217
  users: /* @__PURE__ */ new Map(),
3137
- serviceAccounts: /* @__PURE__ */ new Map()
3218
+ serviceAccounts: /* @__PURE__ */ new Map(),
3219
+ segments: /* @__PURE__ */ new Map(),
3220
+ segmentVersions: /* @__PURE__ */ new Map()
3138
3221
  });
3139
3222
  var ManifestApi = class {
3140
3223
  #client;
@@ -3167,6 +3250,23 @@ var ManifestApi = class {
3167
3250
  async #read(manifest) {
3168
3251
  const c = this.#client;
3169
3252
  const start = { limit: PLAN_PAGE };
3253
+ if (manifest.network !== void 0 && !hasShapeSections(manifest)) {
3254
+ return {
3255
+ resources: [],
3256
+ scopes: /* @__PURE__ */ new Map(),
3257
+ permissions: [],
3258
+ roles: [],
3259
+ groups: [],
3260
+ users: [],
3261
+ serviceAccounts: [],
3262
+ roleGrants: /* @__PURE__ */ new Map(),
3263
+ roleUserBindings: /* @__PURE__ */ new Map(),
3264
+ roleGroupBindings: /* @__PURE__ */ new Map(),
3265
+ roleServiceAccountBindings: /* @__PURE__ */ new Map(),
3266
+ groupMembers: /* @__PURE__ */ new Map(),
3267
+ network: await this.#readNetwork(manifest.network, start)
3268
+ };
3269
+ }
3170
3270
  const resources = await c.resources.listAll(start);
3171
3271
  const permissions = await c.permissions.listAll(start);
3172
3272
  const roles = await c.roles.listAll(start);
@@ -3222,9 +3322,29 @@ var ManifestApi = class {
3222
3322
  roleUserBindings,
3223
3323
  roleGroupBindings,
3224
3324
  roleServiceAccountBindings,
3225
- groupMembers
3325
+ groupMembers,
3326
+ network: manifest.network ? await this.#readNetwork(manifest.network, start) : void 0
3226
3327
  };
3227
3328
  }
3329
+ /**
3330
+ * §27.6.2 item 3: `get_policy`, `list_segments` and `list_profiles`, each
3331
+ * list walked to exhaustion, and nothing else — `plan` issues `GET`s only.
3332
+ * A section that states no policy does not read it; one that states no
3333
+ * profile does not list them.
3334
+ */
3335
+ async #readNetwork(spec, start) {
3336
+ const c = this.#client;
3337
+ const policy = spec.policy ? await c.network.getPolicy() : void 0;
3338
+ const wantSegments = (spec.segments ?? []).length > 0 || (spec.profiles ?? []).length > 0;
3339
+ const segments = wantSegments ? await c.network.listSegmentsAll(void 0, start) : [];
3340
+ const profiles = /* @__PURE__ */ new Map();
3341
+ if ((spec.profiles ?? []).length) {
3342
+ for (const profile of await c.network.listProfilesAll(start)) {
3343
+ profiles.set(profile.segment_id, profile);
3344
+ }
3345
+ }
3346
+ return { policy, segments, profiles };
3347
+ }
3228
3348
  // -------------------------------------------------------------------
3229
3349
  // Plan
3230
3350
  // -------------------------------------------------------------------
@@ -3495,8 +3615,97 @@ var ManifestApi = class {
3495
3615
  push
3496
3616
  );
3497
3617
  }
3618
+ if (manifest.network && snapshot.network) {
3619
+ this.#networkSteps(manifest.network, snapshot.network, resolved, push);
3620
+ }
3498
3621
  return out;
3499
3622
  }
3623
+ /**
3624
+ * §27.6.2 — the `network` section: the policy, then the segments, then the
3625
+ * profiles, a profile after its segment (item 2). Every comparison is with
3626
+ * the value **as the read returns it** (item 3): a profile's effective
3627
+ * (clamped) `session_timeout_secs`, a segment's `filter_ids` as a set.
3628
+ * Silence is not an assertion (rule 3): a member left off never drifts, and
3629
+ * the `Update` body carries the read's value for it (item 4).
3630
+ */
3631
+ #networkSteps(spec, read, resolved, push) {
3632
+ if (spec.policy) {
3633
+ const current = read.policy;
3634
+ const drifted = current.session_timeout_max_secs !== spec.policy.sessionTimeoutMaxSecs;
3635
+ push(
3636
+ drifted ? "update" : "no-change",
3637
+ "network-policy",
3638
+ "network.policy",
3639
+ "network policy (Session-Timeout cap)",
3640
+ drifted ? {
3641
+ kind: "update-network-policy",
3642
+ body: {
3643
+ session_timeout_max_secs: spec.policy.sessionTimeoutMaxSecs,
3644
+ version: current.version
3645
+ }
3646
+ } : { kind: "noop" }
3647
+ );
3648
+ }
3649
+ const segments = spec.segments ?? [];
3650
+ for (const segment of segments) {
3651
+ const found = read.segments.find(
3652
+ (r) => r.site_key === segment.site && r.kind === segment.kind && r.name === segment.name
3653
+ );
3654
+ const summary = `network segment ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
3655
+ if (!found) {
3656
+ push("create", "network-segment", segment.key, summary, {
3657
+ kind: "create-network-segment",
3658
+ key: segment.key,
3659
+ body: segmentCreateBody(segment)
3660
+ });
3661
+ continue;
3662
+ }
3663
+ resolved.segments.set(segment.key, found.id);
3664
+ resolved.segmentVersions.set(segment.key, found.version);
3665
+ const drifted = segmentDrifted(segment, found);
3666
+ push(
3667
+ drifted ? "update" : "no-change",
3668
+ "network-segment",
3669
+ segment.key,
3670
+ summary,
3671
+ drifted ? {
3672
+ kind: "update-network-segment",
3673
+ key: segment.key,
3674
+ id: found.id,
3675
+ body: segmentReplaceBody(segment, found)
3676
+ } : { kind: "noop" }
3677
+ );
3678
+ }
3679
+ const bySegment = new Map((spec.profiles ?? []).map((p) => [p.segment, p]));
3680
+ for (const segment of segments) {
3681
+ const profile = bySegment.get(segment.key);
3682
+ if (!profile) continue;
3683
+ const segmentId = resolved.segments.get(segment.key);
3684
+ const found = segmentId ? read.profiles.get(segmentId) : void 0;
3685
+ const summary = `network profile of ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
3686
+ if (!found) {
3687
+ push("create", "network-profile", segment.key, summary, {
3688
+ kind: "create-network-profile",
3689
+ segment: segment.key,
3690
+ profile: profileCreateInput(profile)
3691
+ });
3692
+ continue;
3693
+ }
3694
+ const drifted = profileDrifted(profile, found);
3695
+ push(
3696
+ drifted ? "update" : "no-change",
3697
+ "network-profile",
3698
+ segment.key,
3699
+ summary,
3700
+ drifted ? {
3701
+ kind: "update-network-profile",
3702
+ segment: segment.key,
3703
+ version: found.version,
3704
+ profile: profileReplaceInput(profile, found)
3705
+ } : { kind: "noop" }
3706
+ );
3707
+ }
3708
+ }
3500
3709
  /**
3501
3710
  * §27.6.1 item 2 — one subject's `roles[]` against the server's existing
3502
3711
  * bindings for it. Shared by groups, users and service accounts: the
@@ -3564,9 +3773,14 @@ var ManifestApi = class {
3564
3773
  }
3565
3774
  } catch (err) {
3566
3775
  stopped = true;
3776
+ const reasonCode = err instanceof ConflictError ? err.reasonCode : void 0;
3567
3777
  out.push({
3568
3778
  action,
3569
- outcome: { status: "failed", message: err instanceof Error ? err.message : String(err) }
3779
+ outcome: {
3780
+ status: "failed",
3781
+ message: err instanceof Error ? err.message : String(err),
3782
+ ...reasonCode === void 0 ? {} : { reasonCode }
3783
+ }
3570
3784
  });
3571
3785
  }
3572
3786
  }
@@ -3673,6 +3887,34 @@ var ManifestApi = class {
3673
3887
  description: step.description
3674
3888
  });
3675
3889
  return void 0;
3890
+ case "update-network-policy":
3891
+ await c.network.replacePolicy(step.body);
3892
+ return void 0;
3893
+ case "create-network-segment": {
3894
+ const created = await c.network.createSegment(step.body);
3895
+ resolved.segments.set(step.key, created.id);
3896
+ resolved.segmentVersions.set(step.key, created.version);
3897
+ return void 0;
3898
+ }
3899
+ case "update-network-segment": {
3900
+ const replaced = await c.network.replaceSegment(step.id, step.body);
3901
+ resolved.segmentVersions.set(step.key, replaced.version);
3902
+ return void 0;
3903
+ }
3904
+ case "create-network-profile":
3905
+ await c.network.createProfile({
3906
+ segment_id: lookup(resolved.segments, step.segment, "network segment"),
3907
+ segment_version: lookupVersion(resolved.segmentVersions, step.segment),
3908
+ profile: step.profile
3909
+ });
3910
+ return void 0;
3911
+ case "update-network-profile":
3912
+ await c.network.replaceProfile(lookup(resolved.segments, step.segment, "network segment"), {
3913
+ version: step.version,
3914
+ segment_version: lookupVersion(resolved.segmentVersions, step.segment),
3915
+ profile: step.profile
3916
+ });
3917
+ return void 0;
3676
3918
  case "assign-role":
3677
3919
  await this.#assign(step, resolved);
3678
3920
  return void 0;
@@ -3810,6 +4052,94 @@ function lookup(map, key, kind) {
3810
4052
  }
3811
4053
  return id;
3812
4054
  }
4055
+ function hasShapeSections(manifest) {
4056
+ return [
4057
+ manifest.resources,
4058
+ manifest.permissions,
4059
+ manifest.roles,
4060
+ manifest.groups,
4061
+ manifest.users,
4062
+ manifest.serviceAccounts
4063
+ ].some((section) => (section ?? []).length > 0);
4064
+ }
4065
+ function lookupVersion(map, key) {
4066
+ const version = map.get(key);
4067
+ if (version === void 0) {
4068
+ throw new NetworkError(
4069
+ `internal: network segment key ${JSON.stringify(key)} has no version; its segment write did not run`
4070
+ );
4071
+ }
4072
+ return version;
4073
+ }
4074
+ function sameSet(a, b) {
4075
+ if (a.length !== b.length) return false;
4076
+ const left = new Set(a);
4077
+ return left.size === new Set(b).size && b.every((name) => left.has(name));
4078
+ }
4079
+ function sameOptional(stated, read) {
4080
+ return (stated ?? null) === (read ?? null);
4081
+ }
4082
+ function segmentCreateBody(spec) {
4083
+ const body = {
4084
+ kind: spec.kind,
4085
+ site_key: spec.site,
4086
+ name: spec.name,
4087
+ vlan_id: spec.vlanId
4088
+ };
4089
+ if (spec.filterIds !== void 0) body.filter_ids = [...spec.filterIds];
4090
+ if (spec.rank !== void 0 && spec.rank !== null) body.rank = spec.rank;
4091
+ if (spec.enabled !== void 0) body.enabled = spec.enabled;
4092
+ return body;
4093
+ }
4094
+ function segmentDrifted(spec, read) {
4095
+ if (spec.vlanId !== read.vlan_id) return true;
4096
+ if (spec.rank !== void 0 && !sameOptional(spec.rank, read.rank)) return true;
4097
+ if (spec.enabled !== void 0 && spec.enabled !== read.enabled) return true;
4098
+ if (spec.filterIds !== void 0 && !sameSet(spec.filterIds, read.filter_ids)) return true;
4099
+ return false;
4100
+ }
4101
+ function segmentReplaceBody(spec, read) {
4102
+ const body = {
4103
+ version: read.version,
4104
+ vlan_id: spec.vlanId,
4105
+ filter_ids: [...spec.filterIds ?? read.filter_ids],
4106
+ enabled: spec.enabled ?? read.enabled
4107
+ };
4108
+ const rank = spec.rank === void 0 ? read.rank : spec.rank;
4109
+ if (rank !== void 0 && rank !== null) body.rank = rank;
4110
+ return body;
4111
+ }
4112
+ function profileCreateInput(spec) {
4113
+ const profile = { session_timeout_secs: spec.sessionTimeoutSecs };
4114
+ if (spec.terminationAction != null) profile.termination_action = spec.terminationAction;
4115
+ if (spec.idleTimeoutSecs != null) profile.idle_timeout_secs = spec.idleTimeoutSecs;
4116
+ if (spec.filterId != null) profile.filter_id = spec.filterId;
4117
+ if (spec.serviceType != null) profile.service_type = spec.serviceType;
4118
+ return profile;
4119
+ }
4120
+ function profileDrifted(spec, read) {
4121
+ if (spec.sessionTimeoutSecs !== read.session_timeout_secs) return true;
4122
+ if (spec.terminationAction !== void 0 && spec.terminationAction !== null && spec.terminationAction !== read.termination_action) return true;
4123
+ if (spec.idleTimeoutSecs !== void 0 && !sameOptional(spec.idleTimeoutSecs, read.idle_timeout_secs)) return true;
4124
+ if (spec.filterId !== void 0 && !sameOptional(spec.filterId, read.filter_id)) return true;
4125
+ if (spec.serviceType !== void 0 && !sameOptional(spec.serviceType, read.service_type)) return true;
4126
+ return false;
4127
+ }
4128
+ function profileReplaceInput(spec, read) {
4129
+ const profile = {
4130
+ dictionary: read.dictionary,
4131
+ session_timeout_secs: spec.sessionTimeoutSecs
4132
+ };
4133
+ const termination = spec.terminationAction === void 0 ? read.termination_action : spec.terminationAction;
4134
+ if (termination != null) profile.termination_action = termination;
4135
+ const idle = spec.idleTimeoutSecs === void 0 ? read.idle_timeout_secs : spec.idleTimeoutSecs;
4136
+ if (idle != null) profile.idle_timeout_secs = idle;
4137
+ const filter = spec.filterId === void 0 ? read.filter_id : spec.filterId;
4138
+ if (filter != null) profile.filter_id = filter;
4139
+ const serviceType = spec.serviceType === void 0 ? read.service_type : spec.serviceType;
4140
+ if (serviceType != null) profile.service_type = serviceType;
4141
+ return profile;
4142
+ }
3813
4143
  function bindingOf(assignment) {
3814
4144
  return {
3815
4145
  resourceId: assignment.resource_id ?? void 0,
@@ -3927,7 +4257,12 @@ function mapManagementError(operation, err) {
3927
4257
  );
3928
4258
  }
3929
4259
  if (status === 409) {
3930
- return new ConflictError(operation, `${operation}: conflict${detail}`);
4260
+ const code = body?.reason_code;
4261
+ return new ConflictError(
4262
+ operation,
4263
+ `${operation}: conflict${detail}`,
4264
+ typeof code === "string" ? code : void 0
4265
+ );
3931
4266
  }
3932
4267
  if (status === 400 || status === 422) {
3933
4268
  return new ValidationError(
@@ -3937,7 +4272,7 @@ function mapManagementError(operation, err) {
3937
4272
  parseFieldErrors(body)
3938
4273
  );
3939
4274
  }
3940
- return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err });
4275
+ return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err, body });
3941
4276
  }
3942
4277
  function describe(body) {
3943
4278
  if (typeof body === "string" && body) return `: ${body}`;
@@ -5231,7 +5566,7 @@ var CertificatesApi = class {
5231
5566
  method: "POST",
5232
5567
  pathTemplate: "/api/v1/certificates",
5233
5568
  path: "/api/v1/certificates",
5234
- body
5569
+ body: omitNullMembers(body, ["user_id"])
5235
5570
  });
5236
5571
  return generatedCertificateFromWire(wire);
5237
5572
  }
@@ -5248,7 +5583,7 @@ var CertificatesApi = class {
5248
5583
  method: "POST",
5249
5584
  pathTemplate: "/api/v1/certificates/sign-csr",
5250
5585
  path: "/api/v1/certificates/sign-csr",
5251
- body
5586
+ body: omitNullMembers(body, ["user_id"])
5252
5587
  });
5253
5588
  return wire;
5254
5589
  }
@@ -6642,7 +6977,7 @@ var SsfApi = class _SsfApi {
6642
6977
  method: "POST",
6643
6978
  pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams",
6644
6979
  path: `/api/v1/tenants/${tenantId}/ssf/streams`,
6645
- body: ssfStreamInputToWire(body)
6980
+ body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
6646
6981
  });
6647
6982
  return scrubSsfStream(wire);
6648
6983
  }
@@ -6665,8 +7000,19 @@ var SsfApi = class _SsfApi {
6665
7000
  * update moves `endpoint_url` to another scheme, host or port while a header
6666
7001
  * is stored: then it must carry `authorization_header` again or
6667
7002
  * `clear_authorization_header: true`, else `400` (§32.3 rule 5). Start from
6668
- * `ssfStreamInputFrom(await ssf.getStream(id))`. An update overtaken by the
6669
- * receiver's own write is `409`: read the stream again.
7003
+ * `ssfStreamInputWith(await ssf.getStream(id), changes)`, which sends the
7004
+ * `events_requested` and `expected_updated_at` it read and cuts
7005
+ * `events_requested` to a lowered `events_allowed` (or from the plain
7006
+ * converter `ssfStreamInputFrom`, where the cut is yours). An update
7007
+ * overtaken by the receiver's own write is `409`: read the stream again.
7008
+ * **`events_requested` has three meanings on an update** (§32.2, contract
7009
+ * 1.62): **absent resets** the stream to every event of `events_allowed` —
7010
+ * widening what the receiver narrowed; **`[]` is stored as the receiver's
7011
+ * "none"** and the stream carries nothing; **a list is stored as given** and
7012
+ * refused (`400`) if any entry is outside `events_allowed`. A raw API client
7013
+ * is bound by the same meaning: an `events_requested` left out of the `PUT`
7014
+ * resets the stream. `expected_updated_at` is the `updated_at` you read, as
7015
+ * the server's own string; an assigned `null` is "none" and is not sent.
6670
7016
  *
6671
7017
  * **This is a replacement, not a patch** (§27.4 rule 5). Only the required
6672
7018
  * members must be set, but what you do not carry over from a prior read is
@@ -6684,7 +7030,7 @@ var SsfApi = class _SsfApi {
6684
7030
  method: "PUT",
6685
7031
  pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams/{stream_id}",
6686
7032
  path: `/api/v1/tenants/${tenantId}/ssf/streams/${encodeURIComponent(streamId)}`,
6687
- body: ssfStreamInputToWire(body)
7033
+ body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
6688
7034
  });
6689
7035
  return scrubSsfStream(wire);
6690
7036
  }
@@ -6752,7 +7098,7 @@ var ScimTargetsApi = class {
6752
7098
  method: "POST",
6753
7099
  pathTemplate: "/api/v1/scim-targets",
6754
7100
  path: "/api/v1/scim-targets",
6755
- body: scimTargetInputToWire(body)
7101
+ body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
6756
7102
  });
6757
7103
  return scrubScimTargetResponse(wire);
6758
7104
  }
@@ -6799,7 +7145,7 @@ var ScimTargetsApi = class {
6799
7145
  method: "PUT",
6800
7146
  pathTemplate: "/api/v1/scim-targets/{id}",
6801
7147
  path: `/api/v1/scim-targets/${encodeURIComponent(id)}`,
6802
- body: scimTargetInputToWire(body)
7148
+ body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
6803
7149
  });
6804
7150
  return scrubScimTargetResponse(wire);
6805
7151
  }
@@ -6843,6 +7189,215 @@ var ScimTargetsApi = class {
6843
7189
  }
6844
7190
  };
6845
7191
 
7192
+ // src/management/ops/network.ts
7193
+ var NetworkApi = class {
7194
+ #client;
7195
+ #scope;
7196
+ /** @internal — reached through `client.<namespace>`, never constructed directly. */
7197
+ constructor(client, scope = {}) {
7198
+ this.#client = client;
7199
+ this.#scope = scope;
7200
+ }
7201
+ /** `GET /api/v1/network/segments` */
7202
+ async listSegments(site, page = {}) {
7203
+ const wire = await sendManagement(this.#client, {
7204
+ operation: "network.list_segments",
7205
+ method: "GET",
7206
+ pathTemplate: "/api/v1/network/segments",
7207
+ path: "/api/v1/network/segments",
7208
+ query: { ...pageQuery(page), "site": site }
7209
+ });
7210
+ return wire;
7211
+ }
7212
+ /**
7213
+ * Walk `network.list_segments` to exhaustion, concatenating every page.
7214
+ *
7215
+ * The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
7216
+ * if `total` disagrees, so a misreporting server costs one wasted request
7217
+ * rather than an unbounded loop.
7218
+ */
7219
+ listSegmentsAll(site, start = {}) {
7220
+ return collectPages(start, (p) => this.listSegments(site, p));
7221
+ }
7222
+ /**
7223
+ * `POST /api/v1/network/segments`
7224
+ *
7225
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7226
+ * issued exactly once, including the ones that look idempotent.
7227
+ */
7228
+ async createSegment(body) {
7229
+ const wire = await sendManagement(this.#client, {
7230
+ operation: "network.create_segment",
7231
+ method: "POST",
7232
+ pathTemplate: "/api/v1/network/segments",
7233
+ path: "/api/v1/network/segments",
7234
+ body
7235
+ });
7236
+ return wire;
7237
+ }
7238
+ /** `GET /api/v1/network/segments/{id}` */
7239
+ async getSegment(id) {
7240
+ const wire = await sendManagement(this.#client, {
7241
+ operation: "network.get_segment",
7242
+ method: "GET",
7243
+ pathTemplate: "/api/v1/network/segments/{id}",
7244
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`
7245
+ });
7246
+ return wire;
7247
+ }
7248
+ /**
7249
+ * `PUT /api/v1/network/segments/{id}`
7250
+ *
7251
+ * **This is a replacement, not a patch** (§27.4 rule 5). Only the required
7252
+ * members must be set, but what you do not carry over from a prior read is
7253
+ * not preserved: an optional member left out is overwritten with its
7254
+ * default, not kept (except where noted above). Read first, change the field
7255
+ * you mean, send the whole thing back.
7256
+ *
7257
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7258
+ * issued exactly once, including the ones that look idempotent.
7259
+ */
7260
+ async replaceSegment(id, body) {
7261
+ const wire = await sendManagement(this.#client, {
7262
+ operation: "network.replace_segment",
7263
+ method: "PUT",
7264
+ pathTemplate: "/api/v1/network/segments/{id}",
7265
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
7266
+ body
7267
+ });
7268
+ return wire;
7269
+ }
7270
+ /**
7271
+ * `DELETE /api/v1/network/segments/{id}`
7272
+ *
7273
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7274
+ * issued exactly once, including the ones that look idempotent.
7275
+ */
7276
+ async deleteSegment(id, version) {
7277
+ await sendManagement(this.#client, {
7278
+ operation: "network.delete_segment",
7279
+ method: "DELETE",
7280
+ pathTemplate: "/api/v1/network/segments/{id}",
7281
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
7282
+ query: { "version": String(version) }
7283
+ });
7284
+ }
7285
+ /** `GET /api/v1/network/profiles` */
7286
+ async listProfiles(page = {}) {
7287
+ const wire = await sendManagement(this.#client, {
7288
+ operation: "network.list_profiles",
7289
+ method: "GET",
7290
+ pathTemplate: "/api/v1/network/profiles",
7291
+ path: "/api/v1/network/profiles",
7292
+ query: { ...pageQuery(page) }
7293
+ });
7294
+ return wire;
7295
+ }
7296
+ /**
7297
+ * Walk `network.list_profiles` to exhaustion, concatenating every page.
7298
+ *
7299
+ * The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
7300
+ * if `total` disagrees, so a misreporting server costs one wasted request
7301
+ * rather than an unbounded loop.
7302
+ */
7303
+ listProfilesAll(start = {}) {
7304
+ return collectPages(start, (p) => this.listProfiles(p));
7305
+ }
7306
+ /**
7307
+ * `POST /api/v1/network/profiles`
7308
+ *
7309
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7310
+ * issued exactly once, including the ones that look idempotent.
7311
+ */
7312
+ async createProfile(body) {
7313
+ const wire = await sendManagement(this.#client, {
7314
+ operation: "network.create_profile",
7315
+ method: "POST",
7316
+ pathTemplate: "/api/v1/network/profiles",
7317
+ path: "/api/v1/network/profiles",
7318
+ body
7319
+ });
7320
+ return wire;
7321
+ }
7322
+ /** `GET /api/v1/network/profiles/{segment_id}` */
7323
+ async getProfile(segmentId) {
7324
+ const wire = await sendManagement(this.#client, {
7325
+ operation: "network.get_profile",
7326
+ method: "GET",
7327
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
7328
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`
7329
+ });
7330
+ return wire;
7331
+ }
7332
+ /**
7333
+ * `PUT /api/v1/network/profiles/{segment_id}`
7334
+ *
7335
+ * **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
7336
+ * body is required, and what you do not carry over from a prior read is not
7337
+ * preserved — it is overwritten. Read first, change the field you mean, send
7338
+ * the whole thing back.
7339
+ *
7340
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7341
+ * issued exactly once, including the ones that look idempotent.
7342
+ */
7343
+ async replaceProfile(segmentId, body) {
7344
+ const wire = await sendManagement(this.#client, {
7345
+ operation: "network.replace_profile",
7346
+ method: "PUT",
7347
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
7348
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
7349
+ body
7350
+ });
7351
+ return wire;
7352
+ }
7353
+ /**
7354
+ * `DELETE /api/v1/network/profiles/{segment_id}`
7355
+ *
7356
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7357
+ * issued exactly once, including the ones that look idempotent.
7358
+ */
7359
+ async deleteProfile(segmentId, version) {
7360
+ await sendManagement(this.#client, {
7361
+ operation: "network.delete_profile",
7362
+ method: "DELETE",
7363
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
7364
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
7365
+ query: { "version": String(version) }
7366
+ });
7367
+ }
7368
+ /** `GET /api/v1/network/policy` */
7369
+ async getPolicy() {
7370
+ const wire = await sendManagement(this.#client, {
7371
+ operation: "network.get_policy",
7372
+ method: "GET",
7373
+ pathTemplate: "/api/v1/network/policy",
7374
+ path: "/api/v1/network/policy"
7375
+ });
7376
+ return wire;
7377
+ }
7378
+ /**
7379
+ * `PUT /api/v1/network/policy`
7380
+ *
7381
+ * **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
7382
+ * body is required, and what you do not carry over from a prior read is not
7383
+ * preserved — it is overwritten. Read first, change the field you mean, send
7384
+ * the whole thing back.
7385
+ *
7386
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7387
+ * issued exactly once, including the ones that look idempotent.
7388
+ */
7389
+ async replacePolicy(body) {
7390
+ const wire = await sendManagement(this.#client, {
7391
+ operation: "network.replace_policy",
7392
+ method: "PUT",
7393
+ pathTemplate: "/api/v1/network/policy",
7394
+ path: "/api/v1/network/policy",
7395
+ body
7396
+ });
7397
+ return wire;
7398
+ }
7399
+ };
7400
+
6846
7401
  // src/management/ops/settings.ts
6847
7402
  var SettingsApi = class _SettingsApi {
6848
7403
  #client;
@@ -7467,6 +8022,9 @@ function managementNamespaces(client) {
7467
8022
  get scimTargets() {
7468
8023
  return new ScimTargetsApi(client);
7469
8024
  },
8025
+ get network() {
8026
+ return new NetworkApi(client);
8027
+ },
7470
8028
  get settings() {
7471
8029
  return new SettingsApi(client);
7472
8030
  },