@smplkit/sdk 3.0.88 → 3.0.90

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
@@ -16661,6 +16661,8 @@ __export(index_exports, {
16661
16661
  Op: () => Op,
16662
16662
  PinoAdapter: () => PinoAdapter,
16663
16663
  Rule: () => Rule,
16664
+ Service: () => Service,
16665
+ ServicesClient: () => ServicesClient,
16664
16666
  SharedWebSocket: () => SharedWebSocket,
16665
16667
  SmplClient: () => SmplClient,
16666
16668
  SmplConflictError: () => SmplConflictError,
@@ -18741,6 +18743,56 @@ var AccountSettings = class {
18741
18743
  return `AccountSettings(${JSON.stringify(this._data)})`;
18742
18744
  }
18743
18745
  };
18746
+ var Service = class {
18747
+ /** Unique slug identifier (e.g. `"user_service"`). */
18748
+ id;
18749
+ /** Human-readable display name. */
18750
+ name;
18751
+ /** When the service was created. */
18752
+ createdAt;
18753
+ /** When the service was last updated. */
18754
+ updatedAt;
18755
+ /** @internal */
18756
+ _client;
18757
+ /** @internal */
18758
+ constructor(client, fields) {
18759
+ this._client = client;
18760
+ this.id = fields.id;
18761
+ this.name = fields.name;
18762
+ this.createdAt = fields.createdAt ?? null;
18763
+ this.updatedAt = fields.updatedAt ?? null;
18764
+ }
18765
+ /** Persist this service to the server (creates if new, updates if existing). */
18766
+ async save() {
18767
+ if (this._client === null) {
18768
+ throw new Error("Service was constructed without a client; cannot save");
18769
+ }
18770
+ if (this.createdAt === null) {
18771
+ const saved = await this._client._create(this);
18772
+ this._apply(saved);
18773
+ } else {
18774
+ const saved = await this._client._update(this);
18775
+ this._apply(saved);
18776
+ }
18777
+ }
18778
+ /** Delete this service from the server. */
18779
+ async delete() {
18780
+ if (this._client === null || this.id === null) {
18781
+ throw new Error("Service was constructed without a client or id; cannot delete");
18782
+ }
18783
+ await this._client.delete(this.id);
18784
+ }
18785
+ /** @internal */
18786
+ _apply(other) {
18787
+ this.id = other.id;
18788
+ this.name = other.name;
18789
+ this.createdAt = other.createdAt;
18790
+ this.updatedAt = other.updatedAt;
18791
+ }
18792
+ toString() {
18793
+ return `Service(id=${this.id}, name=${this.name})`;
18794
+ }
18795
+ };
18744
18796
 
18745
18797
  // src/flags/types.ts
18746
18798
  var Op = /* @__PURE__ */ ((Op2) => {
@@ -20244,11 +20296,26 @@ var HttpConfiguration = class {
20244
20296
  * (`"2xx"`, `"4xx"`). Defaults to `"2xx"`.
20245
20297
  */
20246
20298
  successStatus;
20299
+ /**
20300
+ * Whether to verify the destination's TLS certificate chain. Defaults
20301
+ * to `true`; flip to `false` only for short-lived testing against a
20302
+ * destination that serves an untrusted certificate. Prefer pinning the
20303
+ * CA via {@link caCert} for long-lived self-signed setups.
20304
+ */
20305
+ tlsVerify;
20306
+ /**
20307
+ * Optional PEM-encoded certificate (or bundle) trusted in addition to
20308
+ * the system CA store. Ignored when {@link tlsVerify} is `false`.
20309
+ * `null` (the default) means "use system CAs only".
20310
+ */
20311
+ caCert;
20247
20312
  constructor(fields = {}) {
20248
20313
  this.method = fields.method ?? "POST" /* POST */;
20249
20314
  this.url = fields.url ?? "";
20250
20315
  this.headers = fields.headers ?? [];
20251
20316
  this.successStatus = fields.successStatus ?? "2xx";
20317
+ this.tlsVerify = fields.tlsVerify ?? true;
20318
+ this.caCert = fields.caCert ?? null;
20252
20319
  }
20253
20320
  };
20254
20321
  var Forwarder = class {
@@ -20403,7 +20470,9 @@ function _configurationToWire(config) {
20403
20470
  method: config.method,
20404
20471
  url: config.url,
20405
20472
  headers: config.headers.map((h) => ({ name: h.name, value: h.value })),
20406
- success_status: config.successStatus
20473
+ success_status: config.successStatus,
20474
+ tls_verify: config.tlsVerify,
20475
+ ca_cert: config.caCert
20407
20476
  };
20408
20477
  }
20409
20478
  function _configurationFromWire(raw) {
@@ -20416,7 +20485,9 @@ function _configurationFromWire(raw) {
20416
20485
  method: r.method ?? "POST" /* POST */,
20417
20486
  url: String(r.url ?? ""),
20418
20487
  headers,
20419
- successStatus: String(r.success_status ?? "2xx")
20488
+ successStatus: String(r.success_status ?? "2xx"),
20489
+ tlsVerify: r.tls_verify === void 0 ? true : Boolean(r.tls_verify),
20490
+ caCert: r.ca_cert == null ? null : String(r.ca_cert)
20420
20491
  });
20421
20492
  }
20422
20493
  function _forwarderAttrs(forwarder) {
@@ -20829,6 +20900,15 @@ function envFromResource(resource, client) {
20829
20900
  updatedAt: attrs.updated_at ?? null
20830
20901
  });
20831
20902
  }
20903
+ function svcFromResource(resource, client) {
20904
+ const attrs = resource.attributes ?? {};
20905
+ return new Service(client, {
20906
+ id: resource.id ?? null,
20907
+ name: attrs.name ?? "",
20908
+ createdAt: attrs.created_at ?? null,
20909
+ updatedAt: attrs.updated_at ?? null
20910
+ });
20911
+ }
20832
20912
  function ctFromResource(resource, client) {
20833
20913
  const attrs = resource.attributes ?? {};
20834
20914
  const rawMeta = attrs.attributes;
@@ -20991,6 +21071,126 @@ var EnvironmentsClient = class {
20991
21071
  return envFromResource(data.data, this);
20992
21072
  }
20993
21073
  };
21074
+ var ServicesClient = class {
21075
+ /** @internal */
21076
+ constructor(_http) {
21077
+ this._http = _http;
21078
+ }
21079
+ /**
21080
+ * Construct an unsaved {@link Service}. Call `.save()` to persist.
21081
+ */
21082
+ new(id, options) {
21083
+ return new Service(this, {
21084
+ id,
21085
+ name: options.name,
21086
+ createdAt: null,
21087
+ updatedAt: null
21088
+ });
21089
+ }
21090
+ /**
21091
+ * List services.
21092
+ *
21093
+ * Server defaults are `pageNumber=1`, `pageSize=1000` (capped at 1000).
21094
+ * Omit both to fetch the first page; pass them through to walk further
21095
+ * pages. The wrapper does not loop on the customer's behalf — the
21096
+ * customer chooses how to paginate.
21097
+ */
21098
+ async list(params = {}) {
21099
+ const query = {};
21100
+ if (params.pageNumber !== void 0) query["page[number]"] = params.pageNumber;
21101
+ if (params.pageSize !== void 0) query["page[size]"] = params.pageSize;
21102
+ let data;
21103
+ try {
21104
+ const result = await this._http.GET("/api/v1/services", {
21105
+ params: { query }
21106
+ });
21107
+ if (!result.response.ok) await checkError5(result.response, result.error);
21108
+ data = result.data;
21109
+ } catch (err) {
21110
+ wrapFetchError5(err);
21111
+ }
21112
+ const items = data?.data ?? [];
21113
+ return items.map((r) => svcFromResource(r, this));
21114
+ }
21115
+ async get(id) {
21116
+ let data;
21117
+ try {
21118
+ const result = await this._http.GET("/api/v1/services/{id}", {
21119
+ params: { path: { id } }
21120
+ });
21121
+ if (!result.response.ok) await checkError5(result.response, result.error);
21122
+ data = result.data;
21123
+ } catch (err) {
21124
+ wrapFetchError5(err);
21125
+ }
21126
+ if (!data?.data)
21127
+ throw new SmplNotFoundError(`Service with id ${JSON.stringify(id)} not found`);
21128
+ return svcFromResource(data.data, this);
21129
+ }
21130
+ async delete(id) {
21131
+ try {
21132
+ const result = await this._http.DELETE("/api/v1/services/{id}", {
21133
+ params: { path: { id } }
21134
+ });
21135
+ if (!result.response.ok && result.response.status !== 204) {
21136
+ await checkError5(result.response, result.error);
21137
+ }
21138
+ } catch (err) {
21139
+ wrapFetchError5(err);
21140
+ }
21141
+ }
21142
+ /** @internal */
21143
+ async _create(svc) {
21144
+ if (svc.id === null) {
21145
+ throw new SmplValidationError("Cannot create a Service without an id");
21146
+ }
21147
+ const body = {
21148
+ data: {
21149
+ id: svc.id,
21150
+ type: "service",
21151
+ attributes: {
21152
+ name: svc.name
21153
+ }
21154
+ }
21155
+ };
21156
+ let data;
21157
+ try {
21158
+ const result = await this._http.POST("/api/v1/services", { body });
21159
+ if (!result.response.ok) await checkError5(result.response, result.error);
21160
+ data = result.data;
21161
+ } catch (err) {
21162
+ wrapFetchError5(err);
21163
+ }
21164
+ if (!data?.data) throw new SmplValidationError("Failed to create service");
21165
+ return svcFromResource(data.data, this);
21166
+ }
21167
+ /** @internal */
21168
+ async _update(svc) {
21169
+ if (!svc.id) throw new Error("Cannot update a Service with no id");
21170
+ const body = {
21171
+ data: {
21172
+ id: svc.id,
21173
+ type: "service",
21174
+ attributes: {
21175
+ name: svc.name
21176
+ }
21177
+ }
21178
+ };
21179
+ let data;
21180
+ try {
21181
+ const result = await this._http.PUT("/api/v1/services/{id}", {
21182
+ params: { path: { id: svc.id } },
21183
+ body
21184
+ });
21185
+ if (!result.response.ok) await checkError5(result.response, result.error);
21186
+ data = result.data;
21187
+ } catch (err) {
21188
+ wrapFetchError5(err);
21189
+ }
21190
+ if (!data?.data) throw new SmplValidationError(`Failed to update service ${svc.id}`);
21191
+ return svcFromResource(data.data, this);
21192
+ }
21193
+ };
20994
21194
  var ContextTypesClient = class {
20995
21195
  /** @internal */
20996
21196
  constructor(_http) {
@@ -21341,6 +21541,8 @@ var SmplManagementClient = class {
21341
21541
  contextTypes;
21342
21542
  /** Environment CRUD. */
21343
21543
  environments;
21544
+ /** Service CRUD. */
21545
+ services;
21344
21546
  /** Account-level settings. */
21345
21547
  accountSettings;
21346
21548
  /** Config CRUD (singular — matches runtime `client.config`). */
@@ -21367,6 +21569,7 @@ var SmplManagementClient = class {
21367
21569
  this.contexts = this._contextsRef;
21368
21570
  this.contextTypes = this._contextTypesRef;
21369
21571
  this.environments = this._environmentsRef;
21572
+ this.services = this._servicesRef;
21370
21573
  this.accountSettings = this._accountSettingsRef;
21371
21574
  this.config = this._configRef;
21372
21575
  this.flags = this._flagsRef;
@@ -21383,6 +21586,7 @@ var SmplManagementClient = class {
21383
21586
  _contextsRef;
21384
21587
  _contextTypesRef;
21385
21588
  _environmentsRef;
21589
+ _servicesRef;
21386
21590
  _accountSettingsRef;
21387
21591
  _configRef;
21388
21592
  _flagsRef;
@@ -21431,6 +21635,7 @@ var SmplManagementClient = class {
21431
21635
  });
21432
21636
  this._sharedContextBuffer = new ContextRegistrationBuffer();
21433
21637
  this._environmentsRef = new EnvironmentsClient(this._appHttpRef);
21638
+ this._servicesRef = new ServicesClient(this._appHttpRef);
21434
21639
  this._contextTypesRef = new ContextTypesClient(this._appHttpRef);
21435
21640
  this._contextsRef = new ContextsClient(this._appHttpRef, this._sharedContextBuffer);
21436
21641
  this._accountSettingsRef = new AccountSettingsClient(appBaseUrl, cfg.apiKey);
@@ -23870,6 +24075,8 @@ var PinoAdapter = class {
23870
24075
  Op,
23871
24076
  PinoAdapter,
23872
24077
  Rule,
24078
+ Service,
24079
+ ServicesClient,
23873
24080
  SharedWebSocket,
23874
24081
  SmplClient,
23875
24082
  SmplConflictError,