arky-sdk 0.3.69 → 0.3.71
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 +131 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +131 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.cts +386 -306
- package/dist/types.d.ts +386 -306
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -687,7 +687,7 @@ var getBlockFromArray = (entry, blockKey, locale = "en") => {
|
|
|
687
687
|
};
|
|
688
688
|
var getImageUrl = (imageBlock, isBlock = true) => {
|
|
689
689
|
if (!imageBlock) return null;
|
|
690
|
-
if (imageBlock.type === "
|
|
690
|
+
if (imageBlock.type === "RELATIONSHIP_MEDIA" && Array.isArray(imageBlock.value)) {
|
|
691
691
|
const mediaValue = imageBlock.value[0];
|
|
692
692
|
if (mediaValue && mediaValue.mimeType) {
|
|
693
693
|
if (mediaValue.resolutions && mediaValue.resolutions.original && mediaValue.resolutions.original.url) {
|
|
@@ -1188,6 +1188,135 @@ var createDatabaseApi = (apiConfig) => {
|
|
|
1188
1188
|
};
|
|
1189
1189
|
};
|
|
1190
1190
|
|
|
1191
|
+
// src/api/featureFlags.ts
|
|
1192
|
+
var createFeatureFlagsApi = (apiConfig) => {
|
|
1193
|
+
return {
|
|
1194
|
+
/**
|
|
1195
|
+
* Create a new feature flag
|
|
1196
|
+
*/
|
|
1197
|
+
async createFlag(params, options) {
|
|
1198
|
+
return apiConfig.httpClient.post(
|
|
1199
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags`,
|
|
1200
|
+
params,
|
|
1201
|
+
options
|
|
1202
|
+
);
|
|
1203
|
+
},
|
|
1204
|
+
/**
|
|
1205
|
+
* Get a feature flag by ID
|
|
1206
|
+
*/
|
|
1207
|
+
async getFlag(params, options) {
|
|
1208
|
+
return apiConfig.httpClient.get(
|
|
1209
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/${params.id}`,
|
|
1210
|
+
options
|
|
1211
|
+
);
|
|
1212
|
+
},
|
|
1213
|
+
/**
|
|
1214
|
+
* List all feature flags for the business
|
|
1215
|
+
*/
|
|
1216
|
+
async getFlags(params, options) {
|
|
1217
|
+
return apiConfig.httpClient.get(
|
|
1218
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags`,
|
|
1219
|
+
{
|
|
1220
|
+
...options,
|
|
1221
|
+
params
|
|
1222
|
+
}
|
|
1223
|
+
);
|
|
1224
|
+
},
|
|
1225
|
+
/**
|
|
1226
|
+
* Update a feature flag
|
|
1227
|
+
*/
|
|
1228
|
+
async updateFlag(params, options) {
|
|
1229
|
+
const { id, ...body } = params;
|
|
1230
|
+
return apiConfig.httpClient.put(
|
|
1231
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/${id}`,
|
|
1232
|
+
body,
|
|
1233
|
+
options
|
|
1234
|
+
);
|
|
1235
|
+
},
|
|
1236
|
+
/**
|
|
1237
|
+
* Delete a feature flag
|
|
1238
|
+
*/
|
|
1239
|
+
async deleteFlag(params, options) {
|
|
1240
|
+
return apiConfig.httpClient.delete(
|
|
1241
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/${params.id}`,
|
|
1242
|
+
options
|
|
1243
|
+
);
|
|
1244
|
+
},
|
|
1245
|
+
/**
|
|
1246
|
+
* Get experiment results for a feature flag
|
|
1247
|
+
*/
|
|
1248
|
+
async getResults(params, options) {
|
|
1249
|
+
return apiConfig.httpClient.get(
|
|
1250
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/${params.id}/results`,
|
|
1251
|
+
options
|
|
1252
|
+
);
|
|
1253
|
+
},
|
|
1254
|
+
/**
|
|
1255
|
+
* Get the variant assignment for the current user
|
|
1256
|
+
* This is the main method for feature flag evaluation
|
|
1257
|
+
*/
|
|
1258
|
+
async getVariant(params, options) {
|
|
1259
|
+
return apiConfig.httpClient.get(
|
|
1260
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/key/${params.flagKey}/variant`,
|
|
1261
|
+
options
|
|
1262
|
+
);
|
|
1263
|
+
},
|
|
1264
|
+
/**
|
|
1265
|
+
* Track a conversion event for A/B testing
|
|
1266
|
+
*/
|
|
1267
|
+
async trackEvent(params, options) {
|
|
1268
|
+
return apiConfig.httpClient.post(
|
|
1269
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/track`,
|
|
1270
|
+
params,
|
|
1271
|
+
options
|
|
1272
|
+
);
|
|
1273
|
+
},
|
|
1274
|
+
// ===== CONVENIENCE METHODS =====
|
|
1275
|
+
/**
|
|
1276
|
+
* Check if a feature is enabled (returns true if variant is not 'control')
|
|
1277
|
+
* Convenience method for simple on/off flags
|
|
1278
|
+
*/
|
|
1279
|
+
async isEnabled(flagKey) {
|
|
1280
|
+
try {
|
|
1281
|
+
const response = await this.getVariant({ flagKey });
|
|
1282
|
+
return response.variantKey !== "control";
|
|
1283
|
+
} catch {
|
|
1284
|
+
return false;
|
|
1285
|
+
}
|
|
1286
|
+
},
|
|
1287
|
+
/**
|
|
1288
|
+
* Get variant with payload, returning a default if flag not found
|
|
1289
|
+
* Useful for getting configuration values from variants
|
|
1290
|
+
*/
|
|
1291
|
+
async getVariantWithDefault(flagKey, defaultValue) {
|
|
1292
|
+
try {
|
|
1293
|
+
const response = await this.getVariant({ flagKey });
|
|
1294
|
+
return {
|
|
1295
|
+
variantKey: response.variantKey,
|
|
1296
|
+
payload: response.payload ?? defaultValue
|
|
1297
|
+
};
|
|
1298
|
+
} catch {
|
|
1299
|
+
return {
|
|
1300
|
+
variantKey: "control",
|
|
1301
|
+
payload: defaultValue
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
},
|
|
1305
|
+
/**
|
|
1306
|
+
* Activate a draft flag
|
|
1307
|
+
*/
|
|
1308
|
+
async activateFlag(id) {
|
|
1309
|
+
return this.updateFlag({ id, status: "ACTIVE" });
|
|
1310
|
+
},
|
|
1311
|
+
/**
|
|
1312
|
+
* Archive an active flag
|
|
1313
|
+
*/
|
|
1314
|
+
async archiveFlag(id) {
|
|
1315
|
+
return this.updateFlag({ id, status: "ARCHIVED" });
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
};
|
|
1319
|
+
|
|
1191
1320
|
// src/utils/currency.ts
|
|
1192
1321
|
function getCurrencySymbol(currency) {
|
|
1193
1322
|
const currencySymbols = {
|
|
@@ -1580,6 +1709,7 @@ function createArkySDK(config) {
|
|
|
1580
1709
|
eshop: createEshopApi(apiConfig),
|
|
1581
1710
|
reservation: createReservationApi(apiConfig),
|
|
1582
1711
|
database: createDatabaseApi(apiConfig),
|
|
1712
|
+
featureFlags: createFeatureFlagsApi(apiConfig),
|
|
1583
1713
|
setBusinessId: (businessId) => {
|
|
1584
1714
|
apiConfig.businessId = businessId;
|
|
1585
1715
|
},
|