@smplkit/sdk 3.0.88 → 3.0.89
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 +188 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -1
- package/dist/index.d.ts +72 -1
- package/dist/index.js +186 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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) => {
|
|
@@ -20829,6 +20881,15 @@ function envFromResource(resource, client) {
|
|
|
20829
20881
|
updatedAt: attrs.updated_at ?? null
|
|
20830
20882
|
});
|
|
20831
20883
|
}
|
|
20884
|
+
function svcFromResource(resource, client) {
|
|
20885
|
+
const attrs = resource.attributes ?? {};
|
|
20886
|
+
return new Service(client, {
|
|
20887
|
+
id: resource.id ?? null,
|
|
20888
|
+
name: attrs.name ?? "",
|
|
20889
|
+
createdAt: attrs.created_at ?? null,
|
|
20890
|
+
updatedAt: attrs.updated_at ?? null
|
|
20891
|
+
});
|
|
20892
|
+
}
|
|
20832
20893
|
function ctFromResource(resource, client) {
|
|
20833
20894
|
const attrs = resource.attributes ?? {};
|
|
20834
20895
|
const rawMeta = attrs.attributes;
|
|
@@ -20991,6 +21052,126 @@ var EnvironmentsClient = class {
|
|
|
20991
21052
|
return envFromResource(data.data, this);
|
|
20992
21053
|
}
|
|
20993
21054
|
};
|
|
21055
|
+
var ServicesClient = class {
|
|
21056
|
+
/** @internal */
|
|
21057
|
+
constructor(_http) {
|
|
21058
|
+
this._http = _http;
|
|
21059
|
+
}
|
|
21060
|
+
/**
|
|
21061
|
+
* Construct an unsaved {@link Service}. Call `.save()` to persist.
|
|
21062
|
+
*/
|
|
21063
|
+
new(id, options) {
|
|
21064
|
+
return new Service(this, {
|
|
21065
|
+
id,
|
|
21066
|
+
name: options.name,
|
|
21067
|
+
createdAt: null,
|
|
21068
|
+
updatedAt: null
|
|
21069
|
+
});
|
|
21070
|
+
}
|
|
21071
|
+
/**
|
|
21072
|
+
* List services.
|
|
21073
|
+
*
|
|
21074
|
+
* Server defaults are `pageNumber=1`, `pageSize=1000` (capped at 1000).
|
|
21075
|
+
* Omit both to fetch the first page; pass them through to walk further
|
|
21076
|
+
* pages. The wrapper does not loop on the customer's behalf — the
|
|
21077
|
+
* customer chooses how to paginate.
|
|
21078
|
+
*/
|
|
21079
|
+
async list(params = {}) {
|
|
21080
|
+
const query = {};
|
|
21081
|
+
if (params.pageNumber !== void 0) query["page[number]"] = params.pageNumber;
|
|
21082
|
+
if (params.pageSize !== void 0) query["page[size]"] = params.pageSize;
|
|
21083
|
+
let data;
|
|
21084
|
+
try {
|
|
21085
|
+
const result = await this._http.GET("/api/v1/services", {
|
|
21086
|
+
params: { query }
|
|
21087
|
+
});
|
|
21088
|
+
if (!result.response.ok) await checkError5(result.response, result.error);
|
|
21089
|
+
data = result.data;
|
|
21090
|
+
} catch (err) {
|
|
21091
|
+
wrapFetchError5(err);
|
|
21092
|
+
}
|
|
21093
|
+
const items = data?.data ?? [];
|
|
21094
|
+
return items.map((r) => svcFromResource(r, this));
|
|
21095
|
+
}
|
|
21096
|
+
async get(id) {
|
|
21097
|
+
let data;
|
|
21098
|
+
try {
|
|
21099
|
+
const result = await this._http.GET("/api/v1/services/{id}", {
|
|
21100
|
+
params: { path: { id } }
|
|
21101
|
+
});
|
|
21102
|
+
if (!result.response.ok) await checkError5(result.response, result.error);
|
|
21103
|
+
data = result.data;
|
|
21104
|
+
} catch (err) {
|
|
21105
|
+
wrapFetchError5(err);
|
|
21106
|
+
}
|
|
21107
|
+
if (!data?.data)
|
|
21108
|
+
throw new SmplNotFoundError(`Service with id ${JSON.stringify(id)} not found`);
|
|
21109
|
+
return svcFromResource(data.data, this);
|
|
21110
|
+
}
|
|
21111
|
+
async delete(id) {
|
|
21112
|
+
try {
|
|
21113
|
+
const result = await this._http.DELETE("/api/v1/services/{id}", {
|
|
21114
|
+
params: { path: { id } }
|
|
21115
|
+
});
|
|
21116
|
+
if (!result.response.ok && result.response.status !== 204) {
|
|
21117
|
+
await checkError5(result.response, result.error);
|
|
21118
|
+
}
|
|
21119
|
+
} catch (err) {
|
|
21120
|
+
wrapFetchError5(err);
|
|
21121
|
+
}
|
|
21122
|
+
}
|
|
21123
|
+
/** @internal */
|
|
21124
|
+
async _create(svc) {
|
|
21125
|
+
if (svc.id === null) {
|
|
21126
|
+
throw new SmplValidationError("Cannot create a Service without an id");
|
|
21127
|
+
}
|
|
21128
|
+
const body = {
|
|
21129
|
+
data: {
|
|
21130
|
+
id: svc.id,
|
|
21131
|
+
type: "service",
|
|
21132
|
+
attributes: {
|
|
21133
|
+
name: svc.name
|
|
21134
|
+
}
|
|
21135
|
+
}
|
|
21136
|
+
};
|
|
21137
|
+
let data;
|
|
21138
|
+
try {
|
|
21139
|
+
const result = await this._http.POST("/api/v1/services", { body });
|
|
21140
|
+
if (!result.response.ok) await checkError5(result.response, result.error);
|
|
21141
|
+
data = result.data;
|
|
21142
|
+
} catch (err) {
|
|
21143
|
+
wrapFetchError5(err);
|
|
21144
|
+
}
|
|
21145
|
+
if (!data?.data) throw new SmplValidationError("Failed to create service");
|
|
21146
|
+
return svcFromResource(data.data, this);
|
|
21147
|
+
}
|
|
21148
|
+
/** @internal */
|
|
21149
|
+
async _update(svc) {
|
|
21150
|
+
if (!svc.id) throw new Error("Cannot update a Service with no id");
|
|
21151
|
+
const body = {
|
|
21152
|
+
data: {
|
|
21153
|
+
id: svc.id,
|
|
21154
|
+
type: "service",
|
|
21155
|
+
attributes: {
|
|
21156
|
+
name: svc.name
|
|
21157
|
+
}
|
|
21158
|
+
}
|
|
21159
|
+
};
|
|
21160
|
+
let data;
|
|
21161
|
+
try {
|
|
21162
|
+
const result = await this._http.PUT("/api/v1/services/{id}", {
|
|
21163
|
+
params: { path: { id: svc.id } },
|
|
21164
|
+
body
|
|
21165
|
+
});
|
|
21166
|
+
if (!result.response.ok) await checkError5(result.response, result.error);
|
|
21167
|
+
data = result.data;
|
|
21168
|
+
} catch (err) {
|
|
21169
|
+
wrapFetchError5(err);
|
|
21170
|
+
}
|
|
21171
|
+
if (!data?.data) throw new SmplValidationError(`Failed to update service ${svc.id}`);
|
|
21172
|
+
return svcFromResource(data.data, this);
|
|
21173
|
+
}
|
|
21174
|
+
};
|
|
20994
21175
|
var ContextTypesClient = class {
|
|
20995
21176
|
/** @internal */
|
|
20996
21177
|
constructor(_http) {
|
|
@@ -21341,6 +21522,8 @@ var SmplManagementClient = class {
|
|
|
21341
21522
|
contextTypes;
|
|
21342
21523
|
/** Environment CRUD. */
|
|
21343
21524
|
environments;
|
|
21525
|
+
/** Service CRUD. */
|
|
21526
|
+
services;
|
|
21344
21527
|
/** Account-level settings. */
|
|
21345
21528
|
accountSettings;
|
|
21346
21529
|
/** Config CRUD (singular — matches runtime `client.config`). */
|
|
@@ -21367,6 +21550,7 @@ var SmplManagementClient = class {
|
|
|
21367
21550
|
this.contexts = this._contextsRef;
|
|
21368
21551
|
this.contextTypes = this._contextTypesRef;
|
|
21369
21552
|
this.environments = this._environmentsRef;
|
|
21553
|
+
this.services = this._servicesRef;
|
|
21370
21554
|
this.accountSettings = this._accountSettingsRef;
|
|
21371
21555
|
this.config = this._configRef;
|
|
21372
21556
|
this.flags = this._flagsRef;
|
|
@@ -21383,6 +21567,7 @@ var SmplManagementClient = class {
|
|
|
21383
21567
|
_contextsRef;
|
|
21384
21568
|
_contextTypesRef;
|
|
21385
21569
|
_environmentsRef;
|
|
21570
|
+
_servicesRef;
|
|
21386
21571
|
_accountSettingsRef;
|
|
21387
21572
|
_configRef;
|
|
21388
21573
|
_flagsRef;
|
|
@@ -21431,6 +21616,7 @@ var SmplManagementClient = class {
|
|
|
21431
21616
|
});
|
|
21432
21617
|
this._sharedContextBuffer = new ContextRegistrationBuffer();
|
|
21433
21618
|
this._environmentsRef = new EnvironmentsClient(this._appHttpRef);
|
|
21619
|
+
this._servicesRef = new ServicesClient(this._appHttpRef);
|
|
21434
21620
|
this._contextTypesRef = new ContextTypesClient(this._appHttpRef);
|
|
21435
21621
|
this._contextsRef = new ContextsClient(this._appHttpRef, this._sharedContextBuffer);
|
|
21436
21622
|
this._accountSettingsRef = new AccountSettingsClient(appBaseUrl, cfg.apiKey);
|
|
@@ -23870,6 +24056,8 @@ var PinoAdapter = class {
|
|
|
23870
24056
|
Op,
|
|
23871
24057
|
PinoAdapter,
|
|
23872
24058
|
Rule,
|
|
24059
|
+
Service,
|
|
24060
|
+
ServicesClient,
|
|
23873
24061
|
SharedWebSocket,
|
|
23874
24062
|
SmplClient,
|
|
23875
24063
|
SmplConflictError,
|