arky-sdk 0.3.70 → 0.3.72
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 +156 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.js +156 -26
- package/dist/index.js.map +1 -1
- package/dist/types.d.cts +386 -306
- package/dist/types.d.ts +386 -306
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UpdateUserProfileParams, RequestOptions, DeleteUserParams, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, UserSubscribeParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, SubscribeParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, ProcessRefundParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetAvailableSlotsParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams } from './types.cjs';
|
|
1
|
+
import { UpdateUserProfileParams, RequestOptions, DeleteUserParams, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, UserSubscribeParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, SubscribeParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, ProcessRefundParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetAvailableSlotsParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, CreateFeatureFlagParams, FeatureFlag, GetFeatureFlagParams, GetFeatureFlagsParams, UpdateFeatureFlagParams, DeleteFeatureFlagParams, GetFeatureFlagResultsParams, FlagResults, GetVariantParams, GetVariantResponse, TrackEventParams, TrackEventResponse } from './types.cjs';
|
|
2
2
|
export { ApiResponse, Block, Business, EshopCartItem, EshopStoreState, Price, ReservationCartItem, ReservationStoreState } from './types.cjs';
|
|
3
|
-
import { g as getBlockLabel, a as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission,
|
|
3
|
+
import { e as extractBlockValues, g as getBlockLabel, a as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, b as getMarketPrice, c as getPriceAmount, d as formatPayment, h as formatMinor, i as createPaymentForCheckout, j as getCurrencySymbol, v as validatePhoneNumber, k as findTimeZone, s as slugify, l as humanize, m as categorify, n as formatDate, o as getSvgContentForAstro, q as fetchSvgContent, r as injectSvgIntoElement } from './svg-3F_m7296.cjs';
|
|
4
4
|
|
|
5
5
|
interface AuthTokens {
|
|
6
6
|
accessToken: string;
|
|
@@ -44,7 +44,7 @@ interface RunScriptResponse {
|
|
|
44
44
|
message: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
declare const SDK_VERSION = "0.3.
|
|
47
|
+
declare const SDK_VERSION = "0.3.72";
|
|
48
48
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
49
49
|
interface ApiConfig {
|
|
50
50
|
httpClient: any;
|
|
@@ -59,7 +59,7 @@ interface ApiConfig {
|
|
|
59
59
|
declare function createArkySDK(config: HttpClientConfig & {
|
|
60
60
|
market: string;
|
|
61
61
|
locale?: string;
|
|
62
|
-
}): {
|
|
62
|
+
}): Promise<{
|
|
63
63
|
user: {
|
|
64
64
|
updateUser(params: UpdateUserProfileParams, options?: RequestOptions): Promise<any>;
|
|
65
65
|
deleteUser(params: DeleteUserParams, options?: RequestOptions): Promise<any>;
|
|
@@ -182,6 +182,27 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
182
182
|
deleteData(params: DeleteDataParams, options?: RequestOptions): Promise<void>;
|
|
183
183
|
runScript(params: RunScriptParams, options?: RequestOptions): Promise<RunScriptResponse>;
|
|
184
184
|
};
|
|
185
|
+
featureFlags: {
|
|
186
|
+
createFlag(params: CreateFeatureFlagParams, options?: RequestOptions<FeatureFlag>): Promise<FeatureFlag>;
|
|
187
|
+
getFlag(params: GetFeatureFlagParams, options?: RequestOptions<FeatureFlag>): Promise<FeatureFlag>;
|
|
188
|
+
getFlags(params?: GetFeatureFlagsParams, options?: RequestOptions<FeatureFlag[]>): Promise<FeatureFlag[]>;
|
|
189
|
+
updateFlag(params: UpdateFeatureFlagParams, options?: RequestOptions<FeatureFlag>): Promise<FeatureFlag>;
|
|
190
|
+
deleteFlag(params: DeleteFeatureFlagParams, options?: RequestOptions<{
|
|
191
|
+
deleted: boolean;
|
|
192
|
+
}>): Promise<{
|
|
193
|
+
deleted: boolean;
|
|
194
|
+
}>;
|
|
195
|
+
getResults(params: GetFeatureFlagResultsParams, options?: RequestOptions<FlagResults>): Promise<FlagResults>;
|
|
196
|
+
getVariant(params: GetVariantParams, options?: RequestOptions<GetVariantResponse>): Promise<GetVariantResponse>;
|
|
197
|
+
trackEvent(params: TrackEventParams, options?: RequestOptions<TrackEventResponse>): Promise<TrackEventResponse>;
|
|
198
|
+
isEnabled(flagKey: string): Promise<boolean>;
|
|
199
|
+
getVariantWithDefault<T = any>(flagKey: string, defaultValue: T): Promise<{
|
|
200
|
+
variantKey: string;
|
|
201
|
+
payload: T;
|
|
202
|
+
}>;
|
|
203
|
+
activateFlag(id: string): Promise<FeatureFlag>;
|
|
204
|
+
archiveFlag(id: string): Promise<FeatureFlag>;
|
|
205
|
+
};
|
|
185
206
|
setBusinessId: (businessId: string) => void;
|
|
186
207
|
getBusinessId: () => string;
|
|
187
208
|
setMarket: (market: string) => void;
|
|
@@ -191,6 +212,7 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
191
212
|
isAuthenticated: () => boolean;
|
|
192
213
|
logout: () => void;
|
|
193
214
|
setToken: (tokens: AuthTokens) => void;
|
|
215
|
+
extractBlockValues: typeof extractBlockValues;
|
|
194
216
|
utils: {
|
|
195
217
|
getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
|
|
196
218
|
getBlockValue: (entry: any, blockKey: string) => any;
|
|
@@ -225,6 +247,6 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
225
247
|
fetchSvgContent: typeof fetchSvgContent;
|
|
226
248
|
injectSvgIntoElement: typeof injectSvgIntoElement;
|
|
227
249
|
};
|
|
228
|
-
}
|
|
250
|
+
}>;
|
|
229
251
|
|
|
230
252
|
export { type ApiConfig, type HttpClientConfig, SDK_VERSION, SUPPORTED_FRAMEWORKS, createArkySDK };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UpdateUserProfileParams, RequestOptions, DeleteUserParams, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, UserSubscribeParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, SubscribeParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, ProcessRefundParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetAvailableSlotsParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams } from './types.js';
|
|
1
|
+
import { UpdateUserProfileParams, RequestOptions, DeleteUserParams, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, UserSubscribeParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, SubscribeParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, ProcessRefundParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetAvailableSlotsParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, CreateFeatureFlagParams, FeatureFlag, GetFeatureFlagParams, GetFeatureFlagsParams, UpdateFeatureFlagParams, DeleteFeatureFlagParams, GetFeatureFlagResultsParams, FlagResults, GetVariantParams, GetVariantResponse, TrackEventParams, TrackEventResponse } from './types.js';
|
|
2
2
|
export { ApiResponse, Block, Business, EshopCartItem, EshopStoreState, Price, ReservationCartItem, ReservationStoreState } from './types.js';
|
|
3
|
-
import { g as getBlockLabel, a as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission,
|
|
3
|
+
import { e as extractBlockValues, g as getBlockLabel, a as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, b as getMarketPrice, c as getPriceAmount, d as formatPayment, h as formatMinor, i as createPaymentForCheckout, j as getCurrencySymbol, v as validatePhoneNumber, k as findTimeZone, s as slugify, l as humanize, m as categorify, n as formatDate, o as getSvgContentForAstro, q as fetchSvgContent, r as injectSvgIntoElement } from './svg-4hIdMU6f.js';
|
|
4
4
|
|
|
5
5
|
interface AuthTokens {
|
|
6
6
|
accessToken: string;
|
|
@@ -44,7 +44,7 @@ interface RunScriptResponse {
|
|
|
44
44
|
message: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
declare const SDK_VERSION = "0.3.
|
|
47
|
+
declare const SDK_VERSION = "0.3.72";
|
|
48
48
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
49
49
|
interface ApiConfig {
|
|
50
50
|
httpClient: any;
|
|
@@ -59,7 +59,7 @@ interface ApiConfig {
|
|
|
59
59
|
declare function createArkySDK(config: HttpClientConfig & {
|
|
60
60
|
market: string;
|
|
61
61
|
locale?: string;
|
|
62
|
-
}): {
|
|
62
|
+
}): Promise<{
|
|
63
63
|
user: {
|
|
64
64
|
updateUser(params: UpdateUserProfileParams, options?: RequestOptions): Promise<any>;
|
|
65
65
|
deleteUser(params: DeleteUserParams, options?: RequestOptions): Promise<any>;
|
|
@@ -182,6 +182,27 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
182
182
|
deleteData(params: DeleteDataParams, options?: RequestOptions): Promise<void>;
|
|
183
183
|
runScript(params: RunScriptParams, options?: RequestOptions): Promise<RunScriptResponse>;
|
|
184
184
|
};
|
|
185
|
+
featureFlags: {
|
|
186
|
+
createFlag(params: CreateFeatureFlagParams, options?: RequestOptions<FeatureFlag>): Promise<FeatureFlag>;
|
|
187
|
+
getFlag(params: GetFeatureFlagParams, options?: RequestOptions<FeatureFlag>): Promise<FeatureFlag>;
|
|
188
|
+
getFlags(params?: GetFeatureFlagsParams, options?: RequestOptions<FeatureFlag[]>): Promise<FeatureFlag[]>;
|
|
189
|
+
updateFlag(params: UpdateFeatureFlagParams, options?: RequestOptions<FeatureFlag>): Promise<FeatureFlag>;
|
|
190
|
+
deleteFlag(params: DeleteFeatureFlagParams, options?: RequestOptions<{
|
|
191
|
+
deleted: boolean;
|
|
192
|
+
}>): Promise<{
|
|
193
|
+
deleted: boolean;
|
|
194
|
+
}>;
|
|
195
|
+
getResults(params: GetFeatureFlagResultsParams, options?: RequestOptions<FlagResults>): Promise<FlagResults>;
|
|
196
|
+
getVariant(params: GetVariantParams, options?: RequestOptions<GetVariantResponse>): Promise<GetVariantResponse>;
|
|
197
|
+
trackEvent(params: TrackEventParams, options?: RequestOptions<TrackEventResponse>): Promise<TrackEventResponse>;
|
|
198
|
+
isEnabled(flagKey: string): Promise<boolean>;
|
|
199
|
+
getVariantWithDefault<T = any>(flagKey: string, defaultValue: T): Promise<{
|
|
200
|
+
variantKey: string;
|
|
201
|
+
payload: T;
|
|
202
|
+
}>;
|
|
203
|
+
activateFlag(id: string): Promise<FeatureFlag>;
|
|
204
|
+
archiveFlag(id: string): Promise<FeatureFlag>;
|
|
205
|
+
};
|
|
185
206
|
setBusinessId: (businessId: string) => void;
|
|
186
207
|
getBusinessId: () => string;
|
|
187
208
|
setMarket: (market: string) => void;
|
|
@@ -191,6 +212,7 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
191
212
|
isAuthenticated: () => boolean;
|
|
192
213
|
logout: () => void;
|
|
193
214
|
setToken: (tokens: AuthTokens) => void;
|
|
215
|
+
extractBlockValues: typeof extractBlockValues;
|
|
194
216
|
utils: {
|
|
195
217
|
getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
|
|
196
218
|
getBlockValue: (entry: any, blockKey: string) => any;
|
|
@@ -225,6 +247,6 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
225
247
|
fetchSvgContent: typeof fetchSvgContent;
|
|
226
248
|
injectSvgIntoElement: typeof injectSvgIntoElement;
|
|
227
249
|
};
|
|
228
|
-
}
|
|
250
|
+
}>;
|
|
229
251
|
|
|
230
252
|
export { type ApiConfig, type HttpClientConfig, SDK_VERSION, SUPPORTED_FRAMEWORKS, createArkySDK };
|
package/dist/index.js
CHANGED
|
@@ -1186,6 +1186,135 @@ var createDatabaseApi = (apiConfig) => {
|
|
|
1186
1186
|
};
|
|
1187
1187
|
};
|
|
1188
1188
|
|
|
1189
|
+
// src/api/featureFlags.ts
|
|
1190
|
+
var createFeatureFlagsApi = (apiConfig) => {
|
|
1191
|
+
return {
|
|
1192
|
+
/**
|
|
1193
|
+
* Create a new feature flag
|
|
1194
|
+
*/
|
|
1195
|
+
async createFlag(params, options) {
|
|
1196
|
+
return apiConfig.httpClient.post(
|
|
1197
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags`,
|
|
1198
|
+
params,
|
|
1199
|
+
options
|
|
1200
|
+
);
|
|
1201
|
+
},
|
|
1202
|
+
/**
|
|
1203
|
+
* Get a feature flag by ID
|
|
1204
|
+
*/
|
|
1205
|
+
async getFlag(params, options) {
|
|
1206
|
+
return apiConfig.httpClient.get(
|
|
1207
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/${params.id}`,
|
|
1208
|
+
options
|
|
1209
|
+
);
|
|
1210
|
+
},
|
|
1211
|
+
/**
|
|
1212
|
+
* List all feature flags for the business
|
|
1213
|
+
*/
|
|
1214
|
+
async getFlags(params, options) {
|
|
1215
|
+
return apiConfig.httpClient.get(
|
|
1216
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags`,
|
|
1217
|
+
{
|
|
1218
|
+
...options,
|
|
1219
|
+
params
|
|
1220
|
+
}
|
|
1221
|
+
);
|
|
1222
|
+
},
|
|
1223
|
+
/**
|
|
1224
|
+
* Update a feature flag
|
|
1225
|
+
*/
|
|
1226
|
+
async updateFlag(params, options) {
|
|
1227
|
+
const { id, ...body } = params;
|
|
1228
|
+
return apiConfig.httpClient.put(
|
|
1229
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/${id}`,
|
|
1230
|
+
body,
|
|
1231
|
+
options
|
|
1232
|
+
);
|
|
1233
|
+
},
|
|
1234
|
+
/**
|
|
1235
|
+
* Delete a feature flag
|
|
1236
|
+
*/
|
|
1237
|
+
async deleteFlag(params, options) {
|
|
1238
|
+
return apiConfig.httpClient.delete(
|
|
1239
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/${params.id}`,
|
|
1240
|
+
options
|
|
1241
|
+
);
|
|
1242
|
+
},
|
|
1243
|
+
/**
|
|
1244
|
+
* Get experiment results for a feature flag
|
|
1245
|
+
*/
|
|
1246
|
+
async getResults(params, options) {
|
|
1247
|
+
return apiConfig.httpClient.get(
|
|
1248
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/${params.id}/results`,
|
|
1249
|
+
options
|
|
1250
|
+
);
|
|
1251
|
+
},
|
|
1252
|
+
/**
|
|
1253
|
+
* Get the variant assignment for the current user
|
|
1254
|
+
* This is the main method for feature flag evaluation
|
|
1255
|
+
*/
|
|
1256
|
+
async getVariant(params, options) {
|
|
1257
|
+
return apiConfig.httpClient.get(
|
|
1258
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/key/${params.flagKey}/variant`,
|
|
1259
|
+
options
|
|
1260
|
+
);
|
|
1261
|
+
},
|
|
1262
|
+
/**
|
|
1263
|
+
* Track a conversion event for A/B testing
|
|
1264
|
+
*/
|
|
1265
|
+
async trackEvent(params, options) {
|
|
1266
|
+
return apiConfig.httpClient.post(
|
|
1267
|
+
`/v1/businesses/${apiConfig.businessId}/feature-flags/track`,
|
|
1268
|
+
params,
|
|
1269
|
+
options
|
|
1270
|
+
);
|
|
1271
|
+
},
|
|
1272
|
+
// ===== CONVENIENCE METHODS =====
|
|
1273
|
+
/**
|
|
1274
|
+
* Check if a feature is enabled (returns true if variant is not 'control')
|
|
1275
|
+
* Convenience method for simple on/off flags
|
|
1276
|
+
*/
|
|
1277
|
+
async isEnabled(flagKey) {
|
|
1278
|
+
try {
|
|
1279
|
+
const response = await this.getVariant({ flagKey });
|
|
1280
|
+
return response.variantKey !== "control";
|
|
1281
|
+
} catch {
|
|
1282
|
+
return false;
|
|
1283
|
+
}
|
|
1284
|
+
},
|
|
1285
|
+
/**
|
|
1286
|
+
* Get variant with payload, returning a default if flag not found
|
|
1287
|
+
* Useful for getting configuration values from variants
|
|
1288
|
+
*/
|
|
1289
|
+
async getVariantWithDefault(flagKey, defaultValue) {
|
|
1290
|
+
try {
|
|
1291
|
+
const response = await this.getVariant({ flagKey });
|
|
1292
|
+
return {
|
|
1293
|
+
variantKey: response.variantKey,
|
|
1294
|
+
payload: response.payload ?? defaultValue
|
|
1295
|
+
};
|
|
1296
|
+
} catch {
|
|
1297
|
+
return {
|
|
1298
|
+
variantKey: "control",
|
|
1299
|
+
payload: defaultValue
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
},
|
|
1303
|
+
/**
|
|
1304
|
+
* Activate a draft flag
|
|
1305
|
+
*/
|
|
1306
|
+
async activateFlag(id) {
|
|
1307
|
+
return this.updateFlag({ id, status: "ACTIVE" });
|
|
1308
|
+
},
|
|
1309
|
+
/**
|
|
1310
|
+
* Archive an active flag
|
|
1311
|
+
*/
|
|
1312
|
+
async archiveFlag(id) {
|
|
1313
|
+
return this.updateFlag({ id, status: "ARCHIVED" });
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1189
1318
|
// src/utils/currency.ts
|
|
1190
1319
|
function getCurrencySymbol(currency) {
|
|
1191
1320
|
const currencySymbols = {
|
|
@@ -1541,7 +1670,7 @@ async function injectSvgIntoElement(mediaObject, targetElement, className) {
|
|
|
1541
1670
|
}
|
|
1542
1671
|
|
|
1543
1672
|
// src/index.ts
|
|
1544
|
-
var SDK_VERSION = "0.3.
|
|
1673
|
+
var SDK_VERSION = "0.3.72";
|
|
1545
1674
|
var SUPPORTED_FRAMEWORKS = [
|
|
1546
1675
|
"astro",
|
|
1547
1676
|
"react",
|
|
@@ -1549,7 +1678,7 @@ var SUPPORTED_FRAMEWORKS = [
|
|
|
1549
1678
|
"svelte",
|
|
1550
1679
|
"vanilla"
|
|
1551
1680
|
];
|
|
1552
|
-
function createArkySDK(config) {
|
|
1681
|
+
async function createArkySDK(config) {
|
|
1553
1682
|
const locale = config.locale || "en";
|
|
1554
1683
|
console.log(
|
|
1555
1684
|
`[Arky SDK v${SDK_VERSION}] Initializing with market: ${config.market}, businessId: ${config.businessId}, locale: ${locale}`
|
|
@@ -1566,6 +1695,28 @@ function createArkySDK(config) {
|
|
|
1566
1695
|
};
|
|
1567
1696
|
const userApi = createUserApi(apiConfig);
|
|
1568
1697
|
const autoGuest = config.autoGuest !== void 0 ? config.autoGuest : true;
|
|
1698
|
+
if (autoGuest) {
|
|
1699
|
+
try {
|
|
1700
|
+
const tokens = await config.getToken();
|
|
1701
|
+
if (!tokens.accessToken && !tokens.refreshToken) {
|
|
1702
|
+
const result = await httpClient.post("/v1/users/login", {
|
|
1703
|
+
provider: "GUEST"
|
|
1704
|
+
});
|
|
1705
|
+
const token = result.accessToken || result.token || "";
|
|
1706
|
+
if (token) {
|
|
1707
|
+
config.setToken(result);
|
|
1708
|
+
}
|
|
1709
|
+
console.log(
|
|
1710
|
+
"[SDK Init] Created guest token:",
|
|
1711
|
+
token ? "Success" : "Failed"
|
|
1712
|
+
);
|
|
1713
|
+
} else {
|
|
1714
|
+
console.log("[SDK Init] Using existing token from storage");
|
|
1715
|
+
}
|
|
1716
|
+
} catch (error) {
|
|
1717
|
+
console.error("[SDK Init] Failed to initialize auth:", error);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1569
1720
|
const sdk = {
|
|
1570
1721
|
user: userApi,
|
|
1571
1722
|
business: createBusinessApi(apiConfig),
|
|
@@ -1578,6 +1729,7 @@ function createArkySDK(config) {
|
|
|
1578
1729
|
eshop: createEshopApi(apiConfig),
|
|
1579
1730
|
reservation: createReservationApi(apiConfig),
|
|
1580
1731
|
database: createDatabaseApi(apiConfig),
|
|
1732
|
+
featureFlags: createFeatureFlagsApi(apiConfig),
|
|
1581
1733
|
setBusinessId: (businessId) => {
|
|
1582
1734
|
apiConfig.businessId = businessId;
|
|
1583
1735
|
},
|
|
@@ -1593,6 +1745,8 @@ function createArkySDK(config) {
|
|
|
1593
1745
|
isAuthenticated: config.isAuthenticated || (() => false),
|
|
1594
1746
|
logout: config.logout,
|
|
1595
1747
|
setToken: config.setToken,
|
|
1748
|
+
// Top-level block utilities for convenience
|
|
1749
|
+
extractBlockValues,
|
|
1596
1750
|
utils: {
|
|
1597
1751
|
// Block utilities
|
|
1598
1752
|
getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock),
|
|
@@ -1629,30 +1783,6 @@ function createArkySDK(config) {
|
|
|
1629
1783
|
injectSvgIntoElement
|
|
1630
1784
|
}
|
|
1631
1785
|
};
|
|
1632
|
-
if (autoGuest) {
|
|
1633
|
-
Promise.resolve().then(async () => {
|
|
1634
|
-
try {
|
|
1635
|
-
const tokens = await config.getToken();
|
|
1636
|
-
if (!tokens.accessToken && !tokens.refreshToken) {
|
|
1637
|
-
const result = await httpClient.post("/v1/users/login", {
|
|
1638
|
-
provider: "GUEST"
|
|
1639
|
-
});
|
|
1640
|
-
const token = result.accessToken || result.token || "";
|
|
1641
|
-
if (token) {
|
|
1642
|
-
config.setToken(result);
|
|
1643
|
-
}
|
|
1644
|
-
console.log(
|
|
1645
|
-
"[SDK Init] Created guest token:",
|
|
1646
|
-
token ? "Success" : "Failed"
|
|
1647
|
-
);
|
|
1648
|
-
} else {
|
|
1649
|
-
console.log("[SDK Init] Using existing token from storage");
|
|
1650
|
-
}
|
|
1651
|
-
} catch (error) {
|
|
1652
|
-
console.error("[SDK Init] Failed to initialize auth:", error);
|
|
1653
|
-
}
|
|
1654
|
-
});
|
|
1655
|
-
}
|
|
1656
1786
|
return sdk;
|
|
1657
1787
|
}
|
|
1658
1788
|
|