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
@@ -1180,6 +1180,12 @@ var SKIP_REFRESH = [
1180
1180
  // regardless of what session state came before it.
1181
1181
  "/api/v1/auth/device",
1182
1182
  "/oauth2/token",
1183
+ // CONTRACT.md §14.2 rule 5 (contract 1.62): a client that fails to
1184
+ // authenticate at the device endpoints is `401 invalid_client`, which is not
1185
+ // an expired session and which refreshing cannot fix. `/oauth2/token` (the
1186
+ // poll) was already here; the authorization endpoint now authenticates the
1187
+ // client too, so its 401 must not enter the §9 guard either.
1188
+ "/oauth2/device_authorization",
1183
1189
  "/oauth2/introspect",
1184
1190
  "/oauth2/revoke"
1185
1191
  ];
@@ -1241,6 +1247,13 @@ function installRefreshInterceptor(axiosInstance, session) {
1241
1247
  }
1242
1248
  );
1243
1249
  }
1250
+ function isOAuth2Endpoint(url) {
1251
+ if (!url) {
1252
+ return false;
1253
+ }
1254
+ const path = url.split(/[?#]/, 1)[0] ?? "";
1255
+ return path.includes("/oauth2/");
1256
+ }
1244
1257
  function installDeviceTokenInterceptor(axiosInstance, session) {
1245
1258
  axiosInstance.interceptors.request.use((config) => {
1246
1259
  const deviceToken = session.deviceAccessToken;
@@ -1250,6 +1263,9 @@ function installDeviceTokenInterceptor(axiosInstance, session) {
1250
1263
  const noCred = session.noCredentialsConfig();
1251
1264
  Object.assign(config, noCred);
1252
1265
  config.headers = config.headers ?? {};
1266
+ if (isOAuth2Endpoint(config.url)) {
1267
+ return config;
1268
+ }
1253
1269
  config.headers["Authorization"] = `Bearer ${deviceToken.expose()}`;
1254
1270
  config.headers["Cookie"] = "";
1255
1271
  return config;
@@ -2208,10 +2224,25 @@ var NotFoundError = class _NotFoundError extends AuthzError {
2208
2224
  var ConflictError = class _ConflictError extends AuthzError {
2209
2225
  /** The registry operation that conflicted. */
2210
2226
  operation;
2211
- constructor(operation, message) {
2227
+ /**
2228
+ * The body's `reason_code`, as the server spelled it (contract 1.62, §36.4),
2229
+ * or `undefined` when the body carries none (a server that predates it, or a
2230
+ * `409` of an operation that does not name one).
2231
+ *
2232
+ * The `409` of every `network` operation says which conflict it is:
2233
+ * `stale_version`, `strands_profile`, `has_children`, `site_gone`,
2234
+ * `duplicate_name`, `duplicate_vlan`, `duplicate_rank`, `profile_exists` or
2235
+ * `other` (§36.3 rule 2). The vocabulary is **open**: a value this SDK does
2236
+ * not know is surfaced verbatim, and a caller branches on this member —
2237
+ * never on `message`, which an SDK must not parse. It is not the `reason` of
2238
+ * an authorization decision (§3), which is a human string.
2239
+ */
2240
+ reasonCode;
2241
+ constructor(operation, message, reasonCode) {
2212
2242
  super(message);
2213
2243
  this.name = "ConflictError";
2214
2244
  this.operation = operation;
2245
+ this.reasonCode = reasonCode;
2215
2246
  Object.setPrototypeOf(this, _ConflictError.prototype);
2216
2247
  }
2217
2248
  };
@@ -2500,6 +2531,14 @@ function omitEmptyTenantScope(body) {
2500
2531
  }
2501
2532
  return body;
2502
2533
  }
2534
+ function omitNullMembers(body, members) {
2535
+ if (!body || typeof body !== "object") return body;
2536
+ const record = body;
2537
+ if (!members.some((m) => m in record && record[m] === null)) return body;
2538
+ const copy = { ...record };
2539
+ for (const m of members) if (copy[m] === null) delete copy[m];
2540
+ return copy;
2541
+ }
2503
2542
  function roleAssignmentInherits(assignment) {
2504
2543
  return assignment.inherit ?? true;
2505
2544
  }
@@ -2972,6 +3011,7 @@ function validate(manifest) {
2972
3011
  const groups = manifest.groups ?? [];
2973
3012
  const users = manifest.users ?? [];
2974
3013
  const serviceAccounts = manifest.serviceAccounts ?? [];
3014
+ const network = manifest.network;
2975
3015
  const resourceKeys = new Set(resources.map((r) => r.key));
2976
3016
  const scopeKeys = new Set(resources.flatMap((r) => (r.scopes ?? []).map((s) => s.key)));
2977
3017
  const permissionKeys = new Set(permissions.map((p) => p.key));
@@ -2985,6 +3025,7 @@ function validate(manifest) {
2985
3025
  duplicates("group", groups.map((g) => g.key), problems);
2986
3026
  duplicates("user", users.map((u) => u.key), problems);
2987
3027
  duplicates("service account", serviceAccounts.map((s) => s.key), problems);
3028
+ if (network !== void 0) validateNetwork(network, problems);
2988
3029
  for (const resource of resources) {
2989
3030
  if (resource.parent && !resourceKeys.has(resource.parent)) {
2990
3031
  problems.push(
@@ -3064,6 +3105,46 @@ function validate(manifest) {
3064
3105
  }
3065
3106
  }
3066
3107
  var q = (s) => JSON.stringify(s);
3108
+ function validateNetwork(network, problems) {
3109
+ if (Array.isArray(network.policy)) {
3110
+ problems.push("network declares more than one policy; the tenant has exactly one");
3111
+ }
3112
+ const segments = network.segments ?? [];
3113
+ const profiles = network.profiles ?? [];
3114
+ duplicates("network segment", segments.map((s) => s.key), problems);
3115
+ const naturalKeys = /* @__PURE__ */ new Set();
3116
+ for (const segment of segments) {
3117
+ const natural = `${segment.site}/${segment.kind}/${segment.name}`;
3118
+ if (naturalKeys.has(natural)) {
3119
+ problems.push(
3120
+ `network segment ${q(natural)} (site, kind, name) is declared more than once`
3121
+ );
3122
+ }
3123
+ naturalKeys.add(natural);
3124
+ const seenFilters = /* @__PURE__ */ new Set();
3125
+ for (const filter of segment.filterIds ?? []) {
3126
+ if (seenFilters.has(filter)) {
3127
+ problems.push(
3128
+ `network segment ${q(segment.key)} lists Filter-Id ${q(filter)} more than once in filterIds`
3129
+ );
3130
+ }
3131
+ seenFilters.add(filter);
3132
+ }
3133
+ }
3134
+ const segmentKeys = new Set(segments.map((s) => s.key));
3135
+ const profiled = /* @__PURE__ */ new Set();
3136
+ for (const profile of profiles) {
3137
+ if (!segmentKeys.has(profile.segment)) {
3138
+ problems.push(
3139
+ `network profile names segment ${q(profile.segment)}, which no network segment declares`
3140
+ );
3141
+ }
3142
+ if (profiled.has(profile.segment)) {
3143
+ problems.push(`network segment ${q(profile.segment)} has more than one profile in the manifest`);
3144
+ }
3145
+ profiled.add(profile.segment);
3146
+ }
3147
+ }
3067
3148
  function duplicates(kind, keys, problems) {
3068
3149
  const seen = /* @__PURE__ */ new Set();
3069
3150
  for (const key of keys) {
@@ -3109,7 +3190,9 @@ var emptyResolved = () => ({
3109
3190
  roles: /* @__PURE__ */ new Map(),
3110
3191
  groups: /* @__PURE__ */ new Map(),
3111
3192
  users: /* @__PURE__ */ new Map(),
3112
- serviceAccounts: /* @__PURE__ */ new Map()
3193
+ serviceAccounts: /* @__PURE__ */ new Map(),
3194
+ segments: /* @__PURE__ */ new Map(),
3195
+ segmentVersions: /* @__PURE__ */ new Map()
3113
3196
  });
3114
3197
  var ManifestApi = class {
3115
3198
  #client;
@@ -3142,6 +3225,23 @@ var ManifestApi = class {
3142
3225
  async #read(manifest) {
3143
3226
  const c = this.#client;
3144
3227
  const start = { limit: PLAN_PAGE };
3228
+ if (manifest.network !== void 0 && !hasShapeSections(manifest)) {
3229
+ return {
3230
+ resources: [],
3231
+ scopes: /* @__PURE__ */ new Map(),
3232
+ permissions: [],
3233
+ roles: [],
3234
+ groups: [],
3235
+ users: [],
3236
+ serviceAccounts: [],
3237
+ roleGrants: /* @__PURE__ */ new Map(),
3238
+ roleUserBindings: /* @__PURE__ */ new Map(),
3239
+ roleGroupBindings: /* @__PURE__ */ new Map(),
3240
+ roleServiceAccountBindings: /* @__PURE__ */ new Map(),
3241
+ groupMembers: /* @__PURE__ */ new Map(),
3242
+ network: await this.#readNetwork(manifest.network, start)
3243
+ };
3244
+ }
3145
3245
  const resources = await c.resources.listAll(start);
3146
3246
  const permissions = await c.permissions.listAll(start);
3147
3247
  const roles = await c.roles.listAll(start);
@@ -3197,9 +3297,29 @@ var ManifestApi = class {
3197
3297
  roleUserBindings,
3198
3298
  roleGroupBindings,
3199
3299
  roleServiceAccountBindings,
3200
- groupMembers
3300
+ groupMembers,
3301
+ network: manifest.network ? await this.#readNetwork(manifest.network, start) : void 0
3201
3302
  };
3202
3303
  }
3304
+ /**
3305
+ * §27.6.2 item 3: `get_policy`, `list_segments` and `list_profiles`, each
3306
+ * list walked to exhaustion, and nothing else — `plan` issues `GET`s only.
3307
+ * A section that states no policy does not read it; one that states no
3308
+ * profile does not list them.
3309
+ */
3310
+ async #readNetwork(spec, start) {
3311
+ const c = this.#client;
3312
+ const policy = spec.policy ? await c.network.getPolicy() : void 0;
3313
+ const wantSegments = (spec.segments ?? []).length > 0 || (spec.profiles ?? []).length > 0;
3314
+ const segments = wantSegments ? await c.network.listSegmentsAll(void 0, start) : [];
3315
+ const profiles = /* @__PURE__ */ new Map();
3316
+ if ((spec.profiles ?? []).length) {
3317
+ for (const profile of await c.network.listProfilesAll(start)) {
3318
+ profiles.set(profile.segment_id, profile);
3319
+ }
3320
+ }
3321
+ return { policy, segments, profiles };
3322
+ }
3203
3323
  // -------------------------------------------------------------------
3204
3324
  // Plan
3205
3325
  // -------------------------------------------------------------------
@@ -3470,8 +3590,97 @@ var ManifestApi = class {
3470
3590
  push
3471
3591
  );
3472
3592
  }
3593
+ if (manifest.network && snapshot.network) {
3594
+ this.#networkSteps(manifest.network, snapshot.network, resolved, push);
3595
+ }
3473
3596
  return out;
3474
3597
  }
3598
+ /**
3599
+ * §27.6.2 — the `network` section: the policy, then the segments, then the
3600
+ * profiles, a profile after its segment (item 2). Every comparison is with
3601
+ * the value **as the read returns it** (item 3): a profile's effective
3602
+ * (clamped) `session_timeout_secs`, a segment's `filter_ids` as a set.
3603
+ * Silence is not an assertion (rule 3): a member left off never drifts, and
3604
+ * the `Update` body carries the read's value for it (item 4).
3605
+ */
3606
+ #networkSteps(spec, read, resolved, push) {
3607
+ if (spec.policy) {
3608
+ const current = read.policy;
3609
+ const drifted = current.session_timeout_max_secs !== spec.policy.sessionTimeoutMaxSecs;
3610
+ push(
3611
+ drifted ? "update" : "no-change",
3612
+ "network-policy",
3613
+ "network.policy",
3614
+ "network policy (Session-Timeout cap)",
3615
+ drifted ? {
3616
+ kind: "update-network-policy",
3617
+ body: {
3618
+ session_timeout_max_secs: spec.policy.sessionTimeoutMaxSecs,
3619
+ version: current.version
3620
+ }
3621
+ } : { kind: "noop" }
3622
+ );
3623
+ }
3624
+ const segments = spec.segments ?? [];
3625
+ for (const segment of segments) {
3626
+ const found = read.segments.find(
3627
+ (r) => r.site_key === segment.site && r.kind === segment.kind && r.name === segment.name
3628
+ );
3629
+ const summary = `network segment ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
3630
+ if (!found) {
3631
+ push("create", "network-segment", segment.key, summary, {
3632
+ kind: "create-network-segment",
3633
+ key: segment.key,
3634
+ body: segmentCreateBody(segment)
3635
+ });
3636
+ continue;
3637
+ }
3638
+ resolved.segments.set(segment.key, found.id);
3639
+ resolved.segmentVersions.set(segment.key, found.version);
3640
+ const drifted = segmentDrifted(segment, found);
3641
+ push(
3642
+ drifted ? "update" : "no-change",
3643
+ "network-segment",
3644
+ segment.key,
3645
+ summary,
3646
+ drifted ? {
3647
+ kind: "update-network-segment",
3648
+ key: segment.key,
3649
+ id: found.id,
3650
+ body: segmentReplaceBody(segment, found)
3651
+ } : { kind: "noop" }
3652
+ );
3653
+ }
3654
+ const bySegment = new Map((spec.profiles ?? []).map((p) => [p.segment, p]));
3655
+ for (const segment of segments) {
3656
+ const profile = bySegment.get(segment.key);
3657
+ if (!profile) continue;
3658
+ const segmentId = resolved.segments.get(segment.key);
3659
+ const found = segmentId ? read.profiles.get(segmentId) : void 0;
3660
+ const summary = `network profile of ${JSON.stringify(`${segment.site}/${segment.kind}/${segment.name}`)}`;
3661
+ if (!found) {
3662
+ push("create", "network-profile", segment.key, summary, {
3663
+ kind: "create-network-profile",
3664
+ segment: segment.key,
3665
+ profile: profileCreateInput(profile)
3666
+ });
3667
+ continue;
3668
+ }
3669
+ const drifted = profileDrifted(profile, found);
3670
+ push(
3671
+ drifted ? "update" : "no-change",
3672
+ "network-profile",
3673
+ segment.key,
3674
+ summary,
3675
+ drifted ? {
3676
+ kind: "update-network-profile",
3677
+ segment: segment.key,
3678
+ version: found.version,
3679
+ profile: profileReplaceInput(profile, found)
3680
+ } : { kind: "noop" }
3681
+ );
3682
+ }
3683
+ }
3475
3684
  /**
3476
3685
  * §27.6.1 item 2 — one subject's `roles[]` against the server's existing
3477
3686
  * bindings for it. Shared by groups, users and service accounts: the
@@ -3539,9 +3748,14 @@ var ManifestApi = class {
3539
3748
  }
3540
3749
  } catch (err) {
3541
3750
  stopped = true;
3751
+ const reasonCode = err instanceof ConflictError ? err.reasonCode : void 0;
3542
3752
  out.push({
3543
3753
  action,
3544
- outcome: { status: "failed", message: err instanceof Error ? err.message : String(err) }
3754
+ outcome: {
3755
+ status: "failed",
3756
+ message: err instanceof Error ? err.message : String(err),
3757
+ ...reasonCode === void 0 ? {} : { reasonCode }
3758
+ }
3545
3759
  });
3546
3760
  }
3547
3761
  }
@@ -3648,6 +3862,34 @@ var ManifestApi = class {
3648
3862
  description: step.description
3649
3863
  });
3650
3864
  return void 0;
3865
+ case "update-network-policy":
3866
+ await c.network.replacePolicy(step.body);
3867
+ return void 0;
3868
+ case "create-network-segment": {
3869
+ const created = await c.network.createSegment(step.body);
3870
+ resolved.segments.set(step.key, created.id);
3871
+ resolved.segmentVersions.set(step.key, created.version);
3872
+ return void 0;
3873
+ }
3874
+ case "update-network-segment": {
3875
+ const replaced = await c.network.replaceSegment(step.id, step.body);
3876
+ resolved.segmentVersions.set(step.key, replaced.version);
3877
+ return void 0;
3878
+ }
3879
+ case "create-network-profile":
3880
+ await c.network.createProfile({
3881
+ segment_id: lookup(resolved.segments, step.segment, "network segment"),
3882
+ segment_version: lookupVersion(resolved.segmentVersions, step.segment),
3883
+ profile: step.profile
3884
+ });
3885
+ return void 0;
3886
+ case "update-network-profile":
3887
+ await c.network.replaceProfile(lookup(resolved.segments, step.segment, "network segment"), {
3888
+ version: step.version,
3889
+ segment_version: lookupVersion(resolved.segmentVersions, step.segment),
3890
+ profile: step.profile
3891
+ });
3892
+ return void 0;
3651
3893
  case "assign-role":
3652
3894
  await this.#assign(step, resolved);
3653
3895
  return void 0;
@@ -3785,6 +4027,94 @@ function lookup(map, key, kind) {
3785
4027
  }
3786
4028
  return id;
3787
4029
  }
4030
+ function hasShapeSections(manifest) {
4031
+ return [
4032
+ manifest.resources,
4033
+ manifest.permissions,
4034
+ manifest.roles,
4035
+ manifest.groups,
4036
+ manifest.users,
4037
+ manifest.serviceAccounts
4038
+ ].some((section) => (section ?? []).length > 0);
4039
+ }
4040
+ function lookupVersion(map, key) {
4041
+ const version = map.get(key);
4042
+ if (version === void 0) {
4043
+ throw new NetworkError(
4044
+ `internal: network segment key ${JSON.stringify(key)} has no version; its segment write did not run`
4045
+ );
4046
+ }
4047
+ return version;
4048
+ }
4049
+ function sameSet(a, b) {
4050
+ if (a.length !== b.length) return false;
4051
+ const left = new Set(a);
4052
+ return left.size === new Set(b).size && b.every((name) => left.has(name));
4053
+ }
4054
+ function sameOptional(stated, read) {
4055
+ return (stated ?? null) === (read ?? null);
4056
+ }
4057
+ function segmentCreateBody(spec) {
4058
+ const body = {
4059
+ kind: spec.kind,
4060
+ site_key: spec.site,
4061
+ name: spec.name,
4062
+ vlan_id: spec.vlanId
4063
+ };
4064
+ if (spec.filterIds !== void 0) body.filter_ids = [...spec.filterIds];
4065
+ if (spec.rank !== void 0 && spec.rank !== null) body.rank = spec.rank;
4066
+ if (spec.enabled !== void 0) body.enabled = spec.enabled;
4067
+ return body;
4068
+ }
4069
+ function segmentDrifted(spec, read) {
4070
+ if (spec.vlanId !== read.vlan_id) return true;
4071
+ if (spec.rank !== void 0 && !sameOptional(spec.rank, read.rank)) return true;
4072
+ if (spec.enabled !== void 0 && spec.enabled !== read.enabled) return true;
4073
+ if (spec.filterIds !== void 0 && !sameSet(spec.filterIds, read.filter_ids)) return true;
4074
+ return false;
4075
+ }
4076
+ function segmentReplaceBody(spec, read) {
4077
+ const body = {
4078
+ version: read.version,
4079
+ vlan_id: spec.vlanId,
4080
+ filter_ids: [...spec.filterIds ?? read.filter_ids],
4081
+ enabled: spec.enabled ?? read.enabled
4082
+ };
4083
+ const rank = spec.rank === void 0 ? read.rank : spec.rank;
4084
+ if (rank !== void 0 && rank !== null) body.rank = rank;
4085
+ return body;
4086
+ }
4087
+ function profileCreateInput(spec) {
4088
+ const profile = { session_timeout_secs: spec.sessionTimeoutSecs };
4089
+ if (spec.terminationAction != null) profile.termination_action = spec.terminationAction;
4090
+ if (spec.idleTimeoutSecs != null) profile.idle_timeout_secs = spec.idleTimeoutSecs;
4091
+ if (spec.filterId != null) profile.filter_id = spec.filterId;
4092
+ if (spec.serviceType != null) profile.service_type = spec.serviceType;
4093
+ return profile;
4094
+ }
4095
+ function profileDrifted(spec, read) {
4096
+ if (spec.sessionTimeoutSecs !== read.session_timeout_secs) return true;
4097
+ if (spec.terminationAction !== void 0 && spec.terminationAction !== null && spec.terminationAction !== read.termination_action) return true;
4098
+ if (spec.idleTimeoutSecs !== void 0 && !sameOptional(spec.idleTimeoutSecs, read.idle_timeout_secs)) return true;
4099
+ if (spec.filterId !== void 0 && !sameOptional(spec.filterId, read.filter_id)) return true;
4100
+ if (spec.serviceType !== void 0 && !sameOptional(spec.serviceType, read.service_type)) return true;
4101
+ return false;
4102
+ }
4103
+ function profileReplaceInput(spec, read) {
4104
+ const profile = {
4105
+ dictionary: read.dictionary,
4106
+ session_timeout_secs: spec.sessionTimeoutSecs
4107
+ };
4108
+ const termination = spec.terminationAction === void 0 ? read.termination_action : spec.terminationAction;
4109
+ if (termination != null) profile.termination_action = termination;
4110
+ const idle = spec.idleTimeoutSecs === void 0 ? read.idle_timeout_secs : spec.idleTimeoutSecs;
4111
+ if (idle != null) profile.idle_timeout_secs = idle;
4112
+ const filter = spec.filterId === void 0 ? read.filter_id : spec.filterId;
4113
+ if (filter != null) profile.filter_id = filter;
4114
+ const serviceType = spec.serviceType === void 0 ? read.service_type : spec.serviceType;
4115
+ if (serviceType != null) profile.service_type = serviceType;
4116
+ return profile;
4117
+ }
3788
4118
  function bindingOf(assignment) {
3789
4119
  return {
3790
4120
  resourceId: assignment.resource_id ?? void 0,
@@ -3902,7 +4232,12 @@ function mapManagementError(operation, err) {
3902
4232
  );
3903
4233
  }
3904
4234
  if (status === 409) {
3905
- return new ConflictError(operation, `${operation}: conflict${detail}`);
4235
+ const code = body?.reason_code;
4236
+ return new ConflictError(
4237
+ operation,
4238
+ `${operation}: conflict${detail}`,
4239
+ typeof code === "string" ? code : void 0
4240
+ );
3906
4241
  }
3907
4242
  if (status === 400 || status === 422) {
3908
4243
  return new ValidationError(
@@ -3912,7 +4247,7 @@ function mapManagementError(operation, err) {
3912
4247
  parseFieldErrors(body)
3913
4248
  );
3914
4249
  }
3915
- return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err });
4250
+ return mapHttpStatusToError(status, `${operation}${detail}`, { cause: err, body });
3916
4251
  }
3917
4252
  function describe(body) {
3918
4253
  if (typeof body === "string" && body) return `: ${body}`;
@@ -5206,7 +5541,7 @@ var CertificatesApi = class {
5206
5541
  method: "POST",
5207
5542
  pathTemplate: "/api/v1/certificates",
5208
5543
  path: "/api/v1/certificates",
5209
- body
5544
+ body: omitNullMembers(body, ["user_id"])
5210
5545
  });
5211
5546
  return generatedCertificateFromWire(wire);
5212
5547
  }
@@ -5223,7 +5558,7 @@ var CertificatesApi = class {
5223
5558
  method: "POST",
5224
5559
  pathTemplate: "/api/v1/certificates/sign-csr",
5225
5560
  path: "/api/v1/certificates/sign-csr",
5226
- body
5561
+ body: omitNullMembers(body, ["user_id"])
5227
5562
  });
5228
5563
  return wire;
5229
5564
  }
@@ -6617,7 +6952,7 @@ var SsfApi = class _SsfApi {
6617
6952
  method: "POST",
6618
6953
  pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams",
6619
6954
  path: `/api/v1/tenants/${tenantId}/ssf/streams`,
6620
- body: ssfStreamInputToWire(body)
6955
+ body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
6621
6956
  });
6622
6957
  return scrubSsfStream(wire);
6623
6958
  }
@@ -6640,8 +6975,19 @@ var SsfApi = class _SsfApi {
6640
6975
  * update moves `endpoint_url` to another scheme, host or port while a header
6641
6976
  * is stored: then it must carry `authorization_header` again or
6642
6977
  * `clear_authorization_header: true`, else `400` (§32.3 rule 5). Start from
6643
- * `ssfStreamInputFrom(await ssf.getStream(id))`. An update overtaken by the
6644
- * receiver's own write is `409`: read the stream again.
6978
+ * `ssfStreamInputWith(await ssf.getStream(id), changes)`, which sends the
6979
+ * `events_requested` and `expected_updated_at` it read and cuts
6980
+ * `events_requested` to a lowered `events_allowed` (or from the plain
6981
+ * converter `ssfStreamInputFrom`, where the cut is yours). An update
6982
+ * overtaken by the receiver's own write is `409`: read the stream again.
6983
+ * **`events_requested` has three meanings on an update** (§32.2, contract
6984
+ * 1.62): **absent resets** the stream to every event of `events_allowed` —
6985
+ * widening what the receiver narrowed; **`[]` is stored as the receiver's
6986
+ * "none"** and the stream carries nothing; **a list is stored as given** and
6987
+ * refused (`400`) if any entry is outside `events_allowed`. A raw API client
6988
+ * is bound by the same meaning: an `events_requested` left out of the `PUT`
6989
+ * resets the stream. `expected_updated_at` is the `updated_at` you read, as
6990
+ * the server's own string; an assigned `null` is "none" and is not sent.
6645
6991
  *
6646
6992
  * **This is a replacement, not a patch** (§27.4 rule 5). Only the required
6647
6993
  * members must be set, but what you do not carry over from a prior read is
@@ -6659,7 +7005,7 @@ var SsfApi = class _SsfApi {
6659
7005
  method: "PUT",
6660
7006
  pathTemplate: "/api/v1/tenants/{tenant_id}/ssf/streams/{stream_id}",
6661
7007
  path: `/api/v1/tenants/${tenantId}/ssf/streams/${encodeURIComponent(streamId)}`,
6662
- body: ssfStreamInputToWire(body)
7008
+ body: omitNullMembers(ssfStreamInputToWire(body), ["expected_updated_at"])
6663
7009
  });
6664
7010
  return scrubSsfStream(wire);
6665
7011
  }
@@ -6727,7 +7073,7 @@ var ScimTargetsApi = class {
6727
7073
  method: "POST",
6728
7074
  pathTemplate: "/api/v1/scim-targets",
6729
7075
  path: "/api/v1/scim-targets",
6730
- body: scimTargetInputToWire(body)
7076
+ body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
6731
7077
  });
6732
7078
  return scrubScimTargetResponse(wire);
6733
7079
  }
@@ -6774,7 +7120,7 @@ var ScimTargetsApi = class {
6774
7120
  method: "PUT",
6775
7121
  pathTemplate: "/api/v1/scim-targets/{id}",
6776
7122
  path: `/api/v1/scim-targets/${encodeURIComponent(id)}`,
6777
- body: scimTargetInputToWire(body)
7123
+ body: omitNullMembers(scimTargetInputToWire(body), ["expected_updated_at"])
6778
7124
  });
6779
7125
  return scrubScimTargetResponse(wire);
6780
7126
  }
@@ -6818,6 +7164,215 @@ var ScimTargetsApi = class {
6818
7164
  }
6819
7165
  };
6820
7166
 
7167
+ // src/management/ops/network.ts
7168
+ var NetworkApi = class {
7169
+ #client;
7170
+ #scope;
7171
+ /** @internal — reached through `client.<namespace>`, never constructed directly. */
7172
+ constructor(client, scope = {}) {
7173
+ this.#client = client;
7174
+ this.#scope = scope;
7175
+ }
7176
+ /** `GET /api/v1/network/segments` */
7177
+ async listSegments(site, page = {}) {
7178
+ const wire = await sendManagement(this.#client, {
7179
+ operation: "network.list_segments",
7180
+ method: "GET",
7181
+ pathTemplate: "/api/v1/network/segments",
7182
+ path: "/api/v1/network/segments",
7183
+ query: { ...pageQuery(page), "site": site }
7184
+ });
7185
+ return wire;
7186
+ }
7187
+ /**
7188
+ * Walk `network.list_segments` to exhaustion, concatenating every page.
7189
+ *
7190
+ * The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
7191
+ * if `total` disagrees, so a misreporting server costs one wasted request
7192
+ * rather than an unbounded loop.
7193
+ */
7194
+ listSegmentsAll(site, start = {}) {
7195
+ return collectPages(start, (p) => this.listSegments(site, p));
7196
+ }
7197
+ /**
7198
+ * `POST /api/v1/network/segments`
7199
+ *
7200
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7201
+ * issued exactly once, including the ones that look idempotent.
7202
+ */
7203
+ async createSegment(body) {
7204
+ const wire = await sendManagement(this.#client, {
7205
+ operation: "network.create_segment",
7206
+ method: "POST",
7207
+ pathTemplate: "/api/v1/network/segments",
7208
+ path: "/api/v1/network/segments",
7209
+ body
7210
+ });
7211
+ return wire;
7212
+ }
7213
+ /** `GET /api/v1/network/segments/{id}` */
7214
+ async getSegment(id) {
7215
+ const wire = await sendManagement(this.#client, {
7216
+ operation: "network.get_segment",
7217
+ method: "GET",
7218
+ pathTemplate: "/api/v1/network/segments/{id}",
7219
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`
7220
+ });
7221
+ return wire;
7222
+ }
7223
+ /**
7224
+ * `PUT /api/v1/network/segments/{id}`
7225
+ *
7226
+ * **This is a replacement, not a patch** (§27.4 rule 5). Only the required
7227
+ * members must be set, but what you do not carry over from a prior read is
7228
+ * not preserved: an optional member left out is overwritten with its
7229
+ * default, not kept (except where noted above). Read first, change the field
7230
+ * you mean, send the whole thing back.
7231
+ *
7232
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7233
+ * issued exactly once, including the ones that look idempotent.
7234
+ */
7235
+ async replaceSegment(id, body) {
7236
+ const wire = await sendManagement(this.#client, {
7237
+ operation: "network.replace_segment",
7238
+ method: "PUT",
7239
+ pathTemplate: "/api/v1/network/segments/{id}",
7240
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
7241
+ body
7242
+ });
7243
+ return wire;
7244
+ }
7245
+ /**
7246
+ * `DELETE /api/v1/network/segments/{id}`
7247
+ *
7248
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7249
+ * issued exactly once, including the ones that look idempotent.
7250
+ */
7251
+ async deleteSegment(id, version) {
7252
+ await sendManagement(this.#client, {
7253
+ operation: "network.delete_segment",
7254
+ method: "DELETE",
7255
+ pathTemplate: "/api/v1/network/segments/{id}",
7256
+ path: `/api/v1/network/segments/${encodeURIComponent(id)}`,
7257
+ query: { "version": String(version) }
7258
+ });
7259
+ }
7260
+ /** `GET /api/v1/network/profiles` */
7261
+ async listProfiles(page = {}) {
7262
+ const wire = await sendManagement(this.#client, {
7263
+ operation: "network.list_profiles",
7264
+ method: "GET",
7265
+ pathTemplate: "/api/v1/network/profiles",
7266
+ path: "/api/v1/network/profiles",
7267
+ query: { ...pageQuery(page) }
7268
+ });
7269
+ return wire;
7270
+ }
7271
+ /**
7272
+ * Walk `network.list_profiles` to exhaustion, concatenating every page.
7273
+ *
7274
+ * The auto-paging form §27.4 rule 4 requires. It stops on an empty page even
7275
+ * if `total` disagrees, so a misreporting server costs one wasted request
7276
+ * rather than an unbounded loop.
7277
+ */
7278
+ listProfilesAll(start = {}) {
7279
+ return collectPages(start, (p) => this.listProfiles(p));
7280
+ }
7281
+ /**
7282
+ * `POST /api/v1/network/profiles`
7283
+ *
7284
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7285
+ * issued exactly once, including the ones that look idempotent.
7286
+ */
7287
+ async createProfile(body) {
7288
+ const wire = await sendManagement(this.#client, {
7289
+ operation: "network.create_profile",
7290
+ method: "POST",
7291
+ pathTemplate: "/api/v1/network/profiles",
7292
+ path: "/api/v1/network/profiles",
7293
+ body
7294
+ });
7295
+ return wire;
7296
+ }
7297
+ /** `GET /api/v1/network/profiles/{segment_id}` */
7298
+ async getProfile(segmentId) {
7299
+ const wire = await sendManagement(this.#client, {
7300
+ operation: "network.get_profile",
7301
+ method: "GET",
7302
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
7303
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`
7304
+ });
7305
+ return wire;
7306
+ }
7307
+ /**
7308
+ * `PUT /api/v1/network/profiles/{segment_id}`
7309
+ *
7310
+ * **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
7311
+ * body is required, and what you do not carry over from a prior read is not
7312
+ * preserved — it is overwritten. Read first, change the field you mean, send
7313
+ * the whole thing back.
7314
+ *
7315
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7316
+ * issued exactly once, including the ones that look idempotent.
7317
+ */
7318
+ async replaceProfile(segmentId, body) {
7319
+ const wire = await sendManagement(this.#client, {
7320
+ operation: "network.replace_profile",
7321
+ method: "PUT",
7322
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
7323
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
7324
+ body
7325
+ });
7326
+ return wire;
7327
+ }
7328
+ /**
7329
+ * `DELETE /api/v1/network/profiles/{segment_id}`
7330
+ *
7331
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7332
+ * issued exactly once, including the ones that look idempotent.
7333
+ */
7334
+ async deleteProfile(segmentId, version) {
7335
+ await sendManagement(this.#client, {
7336
+ operation: "network.delete_profile",
7337
+ method: "DELETE",
7338
+ pathTemplate: "/api/v1/network/profiles/{segment_id}",
7339
+ path: `/api/v1/network/profiles/${encodeURIComponent(segmentId)}`,
7340
+ query: { "version": String(version) }
7341
+ });
7342
+ }
7343
+ /** `GET /api/v1/network/policy` */
7344
+ async getPolicy() {
7345
+ const wire = await sendManagement(this.#client, {
7346
+ operation: "network.get_policy",
7347
+ method: "GET",
7348
+ pathTemplate: "/api/v1/network/policy",
7349
+ path: "/api/v1/network/policy"
7350
+ });
7351
+ return wire;
7352
+ }
7353
+ /**
7354
+ * `PUT /api/v1/network/policy`
7355
+ *
7356
+ * **This is a replacement, not a patch** (§27.4 rule 5). Every field of the
7357
+ * body is required, and what you do not carry over from a prior read is not
7358
+ * preserved — it is overwritten. Read first, change the field you mean, send
7359
+ * the whole thing back.
7360
+ *
7361
+ * Not retried on failure (§27.4 rule 8): every write on this surface is
7362
+ * issued exactly once, including the ones that look idempotent.
7363
+ */
7364
+ async replacePolicy(body) {
7365
+ const wire = await sendManagement(this.#client, {
7366
+ operation: "network.replace_policy",
7367
+ method: "PUT",
7368
+ pathTemplate: "/api/v1/network/policy",
7369
+ path: "/api/v1/network/policy",
7370
+ body
7371
+ });
7372
+ return wire;
7373
+ }
7374
+ };
7375
+
6821
7376
  // src/management/ops/settings.ts
6822
7377
  var SettingsApi = class _SettingsApi {
6823
7378
  #client;
@@ -7442,6 +7997,9 @@ function managementNamespaces(client) {
7442
7997
  get scimTargets() {
7443
7998
  return new ScimTargetsApi(client);
7444
7999
  },
8000
+ get network() {
8001
+ return new NetworkApi(client);
8002
+ },
7445
8003
  get settings() {
7446
8004
  return new SettingsApi(client);
7447
8005
  },