@zenky/storefront-vue 0.10.10 → 0.10.12
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/CHANGELOG.md +139 -0
- package/README.md +1 -1
- package/dist/auth/index.d.ts +14 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/cart/index.d.ts +4 -28
- package/dist/cart/index.js +9 -6
- package/dist/chunk-5B2P5W3E.js +20 -0
- package/dist/chunk-5B2P5W3E.js.map +1 -0
- package/dist/{chunk-32SLDGE5.js → chunk-6FVXAF7L.js} +4 -3
- package/dist/chunk-6FVXAF7L.js.map +1 -0
- package/dist/{chunk-4UMDIBW5.js → chunk-EM6H5WFS.js} +19 -110
- package/dist/chunk-EM6H5WFS.js.map +1 -0
- package/dist/chunk-IOYYCA75.js +52 -0
- package/dist/chunk-IOYYCA75.js.map +1 -0
- package/dist/chunk-LUJSF6V7.js +530 -0
- package/dist/chunk-LUJSF6V7.js.map +1 -0
- package/dist/{chunk-GXDTRTUT.js → chunk-RURXGVWW.js} +35 -6
- package/dist/chunk-RURXGVWW.js.map +1 -0
- package/dist/{chunk-XULHV6SS.js → chunk-TE2QPH74.js} +3 -3
- package/dist/{chunk-XULHV6SS.js.map → chunk-TE2QPH74.js.map} +1 -1
- package/dist/chunk-TE42OCFK.js +102 -0
- package/dist/chunk-TE42OCFK.js.map +1 -0
- package/dist/chunk-TIQ7AJLY.js +52 -0
- package/dist/chunk-TIQ7AJLY.js.map +1 -0
- package/dist/{chunk-GILJFP55.js → chunk-VTZYJ6OZ.js} +2 -2
- package/dist/chunk-VTZYJ6OZ.js.map +1 -0
- package/dist/{chunk-46FNHMWC.js → chunk-W43D7JYV.js} +5 -4
- package/dist/chunk-W43D7JYV.js.map +1 -0
- package/dist/{chunk-QZ3S3NN3.js → chunk-WTZXTBF6.js} +3 -47
- package/dist/chunk-WTZXTBF6.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +15 -11
- package/dist/ports/index.d.ts +1 -1
- package/dist/ports/index.js +1 -1
- package/dist/products/index.js +3 -2
- package/dist/promotions/index.js +4 -3
- package/dist/seo/index.js +5 -4
- package/dist/seo/index.js.map +1 -1
- package/dist/stores/index.d.ts +56 -1
- package/dist/stores/index.js +7 -3
- package/dist/types-CXm2F6Hz.d.ts +55 -0
- package/dist/useCheckoutSubmit-C934F26-.d.ts +34 -0
- package/dist/utils/index.d.ts +6 -1
- package/dist/utils/index.js +1 -1
- package/docs/architecture.md +79 -3
- package/package.json +7 -3
- package/dist/chunk-32SLDGE5.js.map +0 -1
- package/dist/chunk-46FNHMWC.js.map +0 -1
- package/dist/chunk-4UMDIBW5.js.map +0 -1
- package/dist/chunk-FXKG5TFQ.js +0 -38
- package/dist/chunk-FXKG5TFQ.js.map +0 -1
- package/dist/chunk-GILJFP55.js.map +0 -1
- package/dist/chunk-GXDTRTUT.js.map +0 -1
- package/dist/chunk-QZ3S3NN3.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/auth/types.ts
|
|
2
|
+
var AUTH_STEP = {
|
|
3
|
+
Method: "method",
|
|
4
|
+
Phone: "phone",
|
|
5
|
+
Channel: "channel",
|
|
6
|
+
Login: "login",
|
|
7
|
+
Register: "register",
|
|
8
|
+
Code: "code",
|
|
9
|
+
RegisterPassword: "register_password",
|
|
10
|
+
Reset: "reset",
|
|
11
|
+
NewPassword: "new_password"
|
|
12
|
+
};
|
|
13
|
+
var CODE_CONTEXT = {
|
|
14
|
+
Register: "register",
|
|
15
|
+
Reset: "reset"
|
|
16
|
+
};
|
|
17
|
+
var CHANNEL_INTENT = {
|
|
18
|
+
Register: "register",
|
|
19
|
+
Resend: "resend",
|
|
20
|
+
DispatchReset: "dispatch_reset"
|
|
21
|
+
};
|
|
22
|
+
var CONFIRMATION_CHANNEL = {
|
|
23
|
+
Sms: "sms",
|
|
24
|
+
Call: "call",
|
|
25
|
+
Telegram: "telegram",
|
|
26
|
+
WhatsApp: "whatsapp"
|
|
27
|
+
};
|
|
28
|
+
var CONFIRMATION_CHANNEL_ORDER = [
|
|
29
|
+
CONFIRMATION_CHANNEL.Telegram,
|
|
30
|
+
CONFIRMATION_CHANNEL.WhatsApp,
|
|
31
|
+
CONFIRMATION_CHANNEL.Sms
|
|
32
|
+
];
|
|
33
|
+
function toConfirmationChannel(method) {
|
|
34
|
+
switch (method) {
|
|
35
|
+
case CONFIRMATION_CHANNEL.Telegram:
|
|
36
|
+
return CONFIRMATION_CHANNEL.Telegram;
|
|
37
|
+
case CONFIRMATION_CHANNEL.WhatsApp:
|
|
38
|
+
return CONFIRMATION_CHANNEL.WhatsApp;
|
|
39
|
+
case CONFIRMATION_CHANNEL.Call:
|
|
40
|
+
return CONFIRMATION_CHANNEL.Call;
|
|
41
|
+
default:
|
|
42
|
+
return CONFIRMATION_CHANNEL.Sms;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function toRequestedMethod(channel) {
|
|
46
|
+
if (!channel || channel === CONFIRMATION_CHANNEL.Call) return void 0;
|
|
47
|
+
return channel;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { AUTH_STEP, CHANNEL_INTENT, CODE_CONTEXT, CONFIRMATION_CHANNEL, CONFIRMATION_CHANNEL_ORDER, toConfirmationChannel, toRequestedMethod };
|
|
51
|
+
//# sourceMappingURL=chunk-TIQ7AJLY.js.map
|
|
52
|
+
//# sourceMappingURL=chunk-TIQ7AJLY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/auth/types.ts"],"names":[],"mappings":";AAEO,IAAM,SAAA,GAAY;AAAA,EACrB,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,OAAA;AAAA,EACP,OAAA,EAAS,SAAA;AAAA,EACT,KAAA,EAAO,OAAA;AAAA,EACP,QAAA,EAAU,UAAA;AAAA,EACV,IAAA,EAAM,MAAA;AAAA,EACN,gBAAA,EAAkB,mBAAA;AAAA,EAClB,KAAA,EAAO,OAAA;AAAA,EACP,WAAA,EAAa;AACjB;AAIO,IAAM,YAAA,GAAe;AAAA,EACxB,QAAA,EAAU,UAAA;AAAA,EACV,KAAA,EAAO;AACX;AAQO,IAAM,cAAA,GAAiB;AAAA,EAC1B,QAAA,EAAU,UAAA;AAAA,EACV,MAAA,EAAQ,QAAA;AAAA,EACR,aAAA,EAAe;AACnB;AAIO,IAAM,oBAAA,GAAuB;AAAA,EAChC,GAAA,EAAK,KAAA;AAAA,EACL,IAAA,EAAM,MAAA;AAAA,EACN,QAAA,EAAU,UAAA;AAAA,EACV,QAAA,EAAU;AACd;AAeO,IAAM,0BAAA,GAAuE;AAAA,EAChF,oBAAA,CAAqB,QAAA;AAAA,EACrB,oBAAA,CAAqB,QAAA;AAAA,EACrB,oBAAA,CAAqB;AACzB;AAEO,SAAS,sBACZ,MAAA,EACmB;AACnB,EAAA,QAAQ,MAAA;AAAQ,IACZ,KAAK,oBAAA,CAAqB,QAAA;AACtB,MAAA,OAAO,oBAAA,CAAqB,QAAA;AAAA,IAChC,KAAK,oBAAA,CAAqB,QAAA;AACtB,MAAA,OAAO,oBAAA,CAAqB,QAAA;AAAA,IAChC,KAAK,oBAAA,CAAqB,IAAA;AACtB,MAAA,OAAO,oBAAA,CAAqB,IAAA;AAAA,IAChC;AACI,MAAA,OAAO,oBAAA,CAAqB,GAAA;AAAA;AAExC;AASO,SAAS,kBACZ,OAAA,EACuC;AACvC,EAAA,IAAI,CAAC,OAAA,IAAW,OAAA,KAAY,oBAAA,CAAqB,MAAM,OAAO,MAAA;AAI9D,EAAA,OAAO,OAAA;AACX","file":"chunk-TIQ7AJLY.js","sourcesContent":["import type { ConfirmationMethod, RequestedConfirmationMethod } from '@zenky/storefront-api'\n\nexport const AUTH_STEP = {\n Method: 'method',\n Phone: 'phone',\n Channel: 'channel',\n Login: 'login',\n Register: 'register',\n Code: 'code',\n RegisterPassword: 'register_password',\n Reset: 'reset',\n NewPassword: 'new_password',\n} as const\n\nexport type AuthStep = (typeof AUTH_STEP)[keyof typeof AUTH_STEP]\n\nexport const CODE_CONTEXT = {\n Register: 'register',\n Reset: 'reset',\n} as const\n\nexport type CodeContext = (typeof CODE_CONTEXT)[keyof typeof CODE_CONTEXT]\n\n/**\n * Какой flow привёл на шаг выбора канала (AUTH_STEP.Channel) — нужно чтобы\n * selectChannel() знал, что вызвать повторно, а goToChannelBack() — куда вернуться.\n */\nexport const CHANNEL_INTENT = {\n Register: 'register',\n Resend: 'resend',\n DispatchReset: 'dispatch_reset',\n} as const\n\nexport type ChannelIntent = (typeof CHANNEL_INTENT)[keyof typeof CHANNEL_INTENT]\n\nexport const CONFIRMATION_CHANNEL = {\n Sms: 'sms',\n Call: 'call',\n Telegram: 'telegram',\n WhatsApp: 'whatsapp',\n} as const\n\nexport type ConfirmationChannel = (typeof CONFIRMATION_CHANNEL)[keyof typeof CONFIRMATION_CHANNEL]\n\n/**\n * `Call` — легаси, response-only (сообщает, что код это последние 4 цифры входящего\n * звонка); никогда не показывается как кнопка и не может быть явно выбран. Всё, что\n * реально можно выбрать/передать в `selectChannel` — этот более узкий тип.\n */\nexport type SelectableConfirmationChannel = Exclude<\n ConfirmationChannel,\n typeof CONFIRMATION_CHANNEL.Call\n>\n\n/** Порядок показа в модалке выбора: Telegram, WhatsApp, SMS — всегда последним. */\nexport const CONFIRMATION_CHANNEL_ORDER: readonly SelectableConfirmationChannel[] = [\n CONFIRMATION_CHANNEL.Telegram,\n CONFIRMATION_CHANNEL.WhatsApp,\n CONFIRMATION_CHANNEL.Sms,\n]\n\nexport function toConfirmationChannel(\n method: ConfirmationMethod | string | null | undefined\n): ConfirmationChannel {\n switch (method) {\n case CONFIRMATION_CHANNEL.Telegram:\n return CONFIRMATION_CHANNEL.Telegram\n case CONFIRMATION_CHANNEL.WhatsApp:\n return CONFIRMATION_CHANNEL.WhatsApp\n case CONFIRMATION_CHANNEL.Call:\n return CONFIRMATION_CHANNEL.Call\n default:\n return CONFIRMATION_CHANNEL.Sms\n }\n}\n\n/**\n * `ConfirmationChannel` шире, чем `RequestedConfirmationMethod` (включает `call` —\n * легаси-значение, которое можно получить в ответе, но нельзя запросить явно). Рантайм-\n * инвариант: сюда `call` попасть не может — `availableChannels` строится из\n * `CONFIRMATION_CHANNEL_ORDER` (Telegram/WhatsApp/Sms, без Call), а канал выбирается\n * только из этого списка.\n */\nexport function toRequestedMethod(\n channel: ConfirmationChannel | null | undefined\n): RequestedConfirmationMethod | undefined {\n if (!channel || channel === CONFIRMATION_CHANNEL.Call) return undefined\n // TS-enum'ы номинальны — string-literal union (наш as-const тип) структурно не\n // совпадает с ними даже после сужения без 'call'. Cast безопасен при\n // задокументированном выше рантайм-инварианте.\n return channel as RequestedConfirmationMethod\n}\n"]}
|
|
@@ -40,5 +40,5 @@ function createMemoryStorage() {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export { KEY_MESSAGE_FORMATTER, NOOP_ACTIVITY_REPORTER, NOOP_NOTIFIER, NOOP_RUM, createMemoryStorage, err, ok };
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-VTZYJ6OZ.js.map
|
|
44
|
+
//# sourceMappingURL=chunk-VTZYJ6OZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ports/index.ts"],"names":[],"mappings":";AAiJO,IAAM,KAAK,CAAI,KAAA,MAAgC,EAAE,EAAA,EAAI,MAAM,KAAA,EAAM;AACjE,IAAM,MAAM,CAAI,KAAA,MAAgC,EAAE,EAAA,EAAI,OAAO,KAAA,EAAM;AA2BnE,IAAM,aAAA,GAA0B;AAAA,EACnC,OAAO,MAAM;AAAA,EAAC,CAAA;AAAA,EACd,SAAS,MAAM;AAAA,EAAC,CAAA;AAAA,EAChB,SAAS,MAAM;AAAA,EAAC,CAAA;AAAA,EAChB,SAAS,MAAM;AAAA,EAAC;AACpB;AAGO,IAAM,qBAAA,GAA0C;AAAA,EACnD,MAAA,EAAQ,CAAC,GAAA,KAAQ;AACrB;AAEO,IAAM,sBAAA,GAA2C;AAAA,EACpD,OAAO,MAAM;AAAA,EAAC,CAAA;AAAA,EACd,KAAK,MAAM;AAAA,EAAC;AAChB;AAEO,IAAM,QAAA,GAAwB;AAAA,EACjC,MAAM,MAAM;AAAA,EAAC,CAAA;AAAA,EACb,SAAS,MAAM;AAAA,EAAC;AACpB;AAGO,SAAS,mBAAA,GAAsC;AAClD,EAAA,MAAM,GAAA,uBAAU,GAAA,EAAoB;AACpC,EAAA,OAAO;AAAA,IACH,KAAK,CAAC,GAAA,KAAQ,GAAA,CAAI,GAAA,CAAI,GAAG,CAAA,IAAK,IAAA;AAAA,IAC9B,GAAA,EAAK,CAAC,GAAA,EAAK,KAAA,KAAU;AACjB,MAAA,GAAA,CAAI,GAAA,CAAI,KAAK,KAAK,CAAA;AAAA,IACtB,CAAA;AAAA,IACA,MAAA,EAAQ,CAAC,GAAA,KAAQ;AACb,MAAA,GAAA,CAAI,OAAO,GAAG,CAAA;AAAA,IAClB;AAAA,GACJ;AACJ","file":"chunk-VTZYJ6OZ.js","sourcesContent":["// Ports — interfaces describing what the core needs from the consumer's runtime.\n// Each frontend (Nuxt / QR menu / template) brings its own adapters.\n// The core does NOT know about useCookie, useRuntimeConfig, vue-router, etc.\n\nimport type { Ref } from 'vue'\n\nimport type { ZenkyIntegrationsSDK } from '@zenky/integrations-sdk'\nimport type { RecommendationsBlock, RemoteCatalog, ZenkyStorefront } from '@zenky/storefront-api'\n\nexport interface StorageOptions {\n /** Time-to-live, in seconds. */\n maxAge?: number\n sameSite?: 'strict' | 'lax' | 'none'\n secure?: boolean\n path?: string\n}\n\n/** Persistent key-value storage (cookies / localStorage / memory). */\nexport interface StorageAdapter {\n get(key: string): string | null\n set(key: string, value: string, options?: StorageOptions): void\n remove(key: string, options?: StorageOptions): void\n}\n\n/** Runtime config. The core doesn't need to know where these values come from. */\nexport interface StorefrontConfig {\n baseUrl: string\n baseAuthUrl: string\n /** Optional sales channel, used for creatives and channels. */\n salesChannelId?: string\n}\n\n/** User-facing notifications (toasts). Implemented on the consumer's side. */\nexport interface Notifier {\n error(message: string): void\n success(message: string): void\n warning(message: string): void\n message(title: string, options?: { description?: string }): void\n}\n\n/** Stable message identifiers emitted by domain logic. Text and locale belong to the consumer. */\nexport type StorefrontMessageKey =\n | 'auth.checkPhoneFailed'\n | 'auth.dispatchResetFailed'\n | 'auth.invalidCode'\n | 'auth.invalidPassword'\n | 'auth.otpUnavailable'\n | 'auth.registerFailed'\n | 'auth.resendCodeFailed'\n | 'auth.resetPasswordFailed'\n | 'cart.added.title'\n | 'cart.bonuses.changed.description'\n | 'cart.bonuses.changed.title'\n | 'cart.customer.saveFailed'\n | 'cart.customer.updateAfterLoginFailed'\n | 'cart.customer.updated'\n | 'cart.customer.updatedWithName'\n | 'cart.payment.updateFailed'\n | 'cart.promocode.applyFailed'\n | 'cart.promocode.removeFailed'\n | 'cart.stock.catalogReloadFailed'\n | 'cart.stock.checkFailed'\n | 'cart.stock.itemsRemoved'\n | 'cart.stock.pricesUpdated'\n | 'cart.updateFailed'\n\nexport type StorefrontMessageParams = Readonly<\n Record<string, string | number | boolean | null | undefined>\n>\n\n/** Converts domain message identifiers into consumer-owned, localized UI copy. */\nexport interface MessageFormatter {\n format(key: StorefrontMessageKey, params?: StorefrontMessageParams): string\n}\n\n/** Activity reporter (busy indicators, long-running operations). */\nexport interface ActivityReporter {\n begin(kind: string): void\n end(kind: string): void\n}\n\n/** Realtime channel: subscribes to events (WebSocket). The core doesn't know about Pusher or any specific transport. */\nexport interface RealtimeChannel {\n bind(event: string, handler: (data?: unknown) => void): void\n}\n\nexport interface RealtimeAdapter {\n subscribe(channelName: string): RealtimeChannel | null\n unsubscribe(channelName: string): void\n isReady: Ref<boolean>\n}\n\nexport interface RealtimePort {\n get(): RealtimeAdapter | null\n}\n\nexport interface EventsPort {\n get(): ZenkyIntegrationsSDK | null\n}\n\n/** Reloads the catalog when the stock changes. The transport (fetch) is implemented on the consumer's side. */\nexport interface CatalogReloader {\n reload(storeId: string, remoteCatalog: RemoteCatalog): Promise<void>\n}\n\n/** RUM performance reporter (performance marks). Implemented by the consumer. */\nexport interface RumReporter {\n mark(name: string): void\n measure(metric: string, startMark: string): void\n}\n\n/** Commerce event identifiers (session/anonymous) — included in the checkout request. */\nexport interface CommerceEventIdentity {\n session_id?: string\n anonymous_id?: string\n}\n\nexport interface CommerceAddedToCartPayload {\n productId: string\n productVariantId: string\n quantity?: number\n unitPrice?: number\n totalPrice?: number\n recommendationsBlock?: RecommendationsBlock\n}\n\nexport interface CommerceRemovedFromCartPayload {\n productId: string\n productVariantId: string\n quantity?: number\n}\n\n/** Commerce event tracking. Implementation, queueing, and transport are handled by the consumer. */\nexport interface CommerceEventsPort {\n trackAddedToCart(orderId: string, payload: CommerceAddedToCartPayload): void\n trackRemovedFromCart(orderId: string, payload: CommerceRemovedFromCartPayload): void\n getIdentity(): CommerceEventIdentity\n}\n\n/**\n * Railway-style result: the compiler won't allow reading `.value` until the\n * consumer has checked `.ok`. Replaces throw at the public boundary.\n */\nexport type Result<T = void, E = unknown> = { ok: true; value: T } | { ok: false; error: E }\n\nexport const ok = <T>(value: T): Result<T, never> => ({ ok: true, value })\nexport const err = <E>(error: E): Result<never, E> => ({ ok: false, error })\n\n/** The full runtime that the consumer assembles and passes to createStorefront(). */\nexport interface StorefrontRuntime {\n /** Zenky SDK client. The consumer creates a single instance and provides it here. */\n sdk: ZenkyStorefront\n storage: StorageAdapter\n /** Reserved consumer configuration. The current core does not read this port. */\n config?: StorefrontConfig\n notifier: Notifier\n /** Localized user-facing copy. The core emits only stable message identifiers. */\n messages: MessageFormatter\n activity: ActivityReporter\n /** Lazy provider for the analytics integration, which may become available after setup. */\n events?: EventsPort | null\n /** Lazy provider for the realtime transport (WebSocket). */\n realtime?: RealtimePort | null\n /** Reloads the catalog when the stock changes. If absent, the reload step is skipped. */\n catalogReloader?: CatalogReloader | null\n /** RUM metrics. If absent, instrumentation is skipped. */\n rum?: RumReporter | null\n /** Commerce event tracking. If absent, tracking is skipped. */\n commerceEvents?: CommerceEventsPort | null\n}\n\n// --- NOOP / in-memory stubs (SSR, tests, defaults) ---\n\nexport const NOOP_NOTIFIER: Notifier = {\n error: () => {},\n success: () => {},\n warning: () => {},\n message: () => {},\n}\n\n/** Useful in headless tests where displaying a localized message is not required. */\nexport const KEY_MESSAGE_FORMATTER: MessageFormatter = {\n format: (key) => key,\n}\n\nexport const NOOP_ACTIVITY_REPORTER: ActivityReporter = {\n begin: () => {},\n end: () => {},\n}\n\nexport const NOOP_RUM: RumReporter = {\n mark: () => {},\n measure: () => {},\n}\n\n/** In-memory storage for SSR/tests, without side effects on real cookies. */\nexport function createMemoryStorage(): StorageAdapter {\n const map = new Map<string, string>()\n return {\n get: (key) => map.get(key) ?? null,\n set: (key, value) => {\n map.set(key, value)\n },\n remove: (key) => {\n map.delete(key)\n },\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { useCartStore, usePromotionsStore } from './chunk-
|
|
2
|
-
import { useRuntime, useAuthStore
|
|
1
|
+
import { useCartStore, usePromotionsStore } from './chunk-TE2QPH74.js';
|
|
2
|
+
import { useRuntime, useAuthStore } from './chunk-WTZXTBF6.js';
|
|
3
|
+
import { useStoreProfileStore } from './chunk-IOYYCA75.js';
|
|
3
4
|
import { ref } from 'vue';
|
|
4
5
|
|
|
5
6
|
var KEY_ORDER_ID = "zenky_order_id";
|
|
@@ -105,5 +106,5 @@ function usePromotionsChecker() {
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
export { useCartCredentials, usePromotionsChecker };
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
109
|
+
//# sourceMappingURL=chunk-W43D7JYV.js.map
|
|
110
|
+
//# sourceMappingURL=chunk-W43D7JYV.js.map
|
|
@@ -0,0 +1 @@
|
|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;AAAA,EACJ;AAEA,EAAA,OAAO,EAAE,aAAA,EAAc;AAC3B","file":"chunk-W43D7JYV.js","sourcesContent":["import { ref, type Ref } from 'vue'\n\nimport type { Order, OrderCredentials } from '@zenky/storefront-api'\n\nimport { useRuntime } from '../ports/runtime'\nimport { useAuthStore } from '../stores/auth'\nimport { useCartStore } from '../stores/cart'\nimport { useStoreProfileStore } from '../stores/store-profile'\n\nconst KEY_ORDER_ID = 'zenky_order_id'\nconst KEY_ORDER_TOKEN = 'zenky_order_token'\nconst WEEK_SECONDS = 60 * 60 * 24 * 7\n\n// App-level enum: OrderStatusKind.Pending = 'pending'.\nconst ORDER_STATUS_PENDING = 'pending'\n\nexport interface CartCredentials {\n orderIdCookie: Ref<string | null>\n orderTokenCookie: Ref<string | null>\n getStoreId: () => string\n getCityId: () => string\n getApiToken: () => string | undefined\n buildCredentials: (orderId: string, orderToken: string) => OrderCredentials\n getCredentials: () => OrderCredentials\n persistCredentials: (savedOrder: Order) => void\n clearPersistedCredentials: () => void\n isOrderActive: (order: Order) => boolean\n}\n\n/**\n * Manages order credentials. Order id/token persistence goes through the `storage`\n * port (the core doesn't know about useCookie). The refs are initialized from\n * storage; persisting writes to both.\n */\nexport function useCartCredentials(): CartCredentials {\n const { storage } = useRuntime()\n const cartStore = useCartStore()\n const authStore = useAuthStore()\n const profileStore = useStoreProfileStore()\n\n const orderIdRef = ref<string | null>(storage.get(KEY_ORDER_ID))\n const orderTokenRef = ref<string | null>(storage.get(KEY_ORDER_TOKEN))\n\n function getStoreId(): string {\n if (!profileStore.store) {\n throw new Error('Store is not initialized.')\n }\n\n return profileStore.store.id\n }\n\n function getCityId(): string {\n if (!profileStore.city) {\n throw new Error('City is not initialized.')\n }\n\n return profileStore.city.id\n }\n\n function getApiToken(): string | undefined {\n return authStore.apiToken\n }\n\n function buildCredentials(orderId: string, orderToken: string): OrderCredentials {\n const credentials: OrderCredentials = {\n id: orderId,\n token: orderToken,\n }\n\n const apiToken = getApiToken()\n\n if (apiToken) {\n credentials.api_token = apiToken\n }\n\n return credentials\n }\n\n function getCredentials(): OrderCredentials {\n if (!cartStore.credentials) {\n throw new Error('Cart has no credentials.')\n }\n\n return buildCredentials(cartStore.credentials.id, cartStore.credentials.token)\n }\n\n function persistCredentials(savedOrder: Order): void {\n orderIdRef.value = savedOrder.id\n orderTokenRef.value = savedOrder.token\n storage.set(KEY_ORDER_ID, savedOrder.id, { maxAge: WEEK_SECONDS })\n storage.set(KEY_ORDER_TOKEN, savedOrder.token, { maxAge: WEEK_SECONDS })\n }\n\n function clearPersistedCredentials(): void {\n orderIdRef.value = null\n orderTokenRef.value = null\n storage.remove(KEY_ORDER_ID)\n storage.remove(KEY_ORDER_TOKEN)\n }\n\n function isOrderActive(existingOrder: Order): boolean {\n if (!existingOrder.status) return true\n\n return String(existingOrder.status.kind) === ORDER_STATUS_PENDING\n }\n\n return {\n orderIdCookie: orderIdRef,\n orderTokenCookie: orderTokenRef,\n getStoreId,\n getCityId,\n getApiToken,\n buildCredentials,\n getCredentials,\n persistCredentials,\n clearPersistedCredentials,\n isOrderActive,\n }\n}\n","import { useRuntime } from '../ports/runtime'\nimport { useCartCredentials } from '../cart/useCartCredentials'\nimport { useCartStore } from '../stores/cart'\nimport { usePromotionsStore } from '../stores/promotions'\nimport { useStoreProfileStore } from '../stores/store-profile'\n\nexport interface PromotionsChecker {\n dispatchCheck: () => Promise<void>\n}\n\n/** Timeout — if the WS never responds, reset the checking flag. */\nconst WS_RESPONSE_TIMEOUT_MS = 5000\n\n/**\n * Checks promotions. Calls dispatchPromotionsChecker after the cart changes.\n * The result arrives over WebSocket (handled in useOrderChannel).\n *\n * Resolve this synchronously in setup, and call only `dispatchCheck` after an\n * await — like any core composable, see \"Call composables and stores\n * synchronously in setup\" in the README.\n *\n * ```ts\n * const { dispatchCheck } = usePromotionsChecker()\n *\n * async function addGift() {\n * await addVariantToOrder()\n * dispatchCheck()\n * }\n * ```\n */\nexport function usePromotionsChecker(): PromotionsChecker {\n const { sdk, events } = useRuntime()\n const cartStore = useCartStore()\n const profileStore = useStoreProfileStore()\n const promotionsStore = usePromotionsStore()\n const credentials = useCartCredentials()\n\n async function dispatchCheck(): Promise<void> {\n if (!cartStore.hasOrder || promotionsStore.checking) return\n\n const storeId = profileStore.store?.id\n if (!storeId) return\n\n promotionsStore.setChecking(true)\n promotionsStore.clearRewards() // Clear old ones — WS will refill with current ones\n events?.get()?.promotionsCheckerStarted({ order: cartStore.order })\n\n try {\n const creds = credentials.getCredentials()\n await sdk.orders.dispatchPromotionsChecker(storeId, creds)\n\n setTimeout(() => {\n if (promotionsStore.checking) promotionsStore.setChecking(false)\n }, WS_RESPONSE_TIMEOUT_MS)\n } catch (e: unknown) {\n console.error('[promotions] check failed', e)\n promotionsStore.setChecking(false)\n }\n }\n\n return { dispatchCheck }\n}\n"]}
|
|
@@ -39,50 +39,6 @@ function useRuntime() {
|
|
|
39
39
|
}
|
|
40
40
|
return runtime;
|
|
41
41
|
}
|
|
42
|
-
var useStoreProfileStore = defineStore("zenky-store-profile", () => {
|
|
43
|
-
const store = ref(null);
|
|
44
|
-
const city = ref(null);
|
|
45
|
-
const stock = ref(null);
|
|
46
|
-
const categories = ref([]);
|
|
47
|
-
const website = ref(null);
|
|
48
|
-
function initStore(newStore, newCity, newStock) {
|
|
49
|
-
store.value = newStore;
|
|
50
|
-
city.value = newCity;
|
|
51
|
-
stock.value = newStock;
|
|
52
|
-
}
|
|
53
|
-
function setStock(newStock) {
|
|
54
|
-
stock.value = newStock;
|
|
55
|
-
}
|
|
56
|
-
function setCategories(newCategories) {
|
|
57
|
-
categories.value = newCategories;
|
|
58
|
-
}
|
|
59
|
-
function initWebsite(newWebsite) {
|
|
60
|
-
website.value = newWebsite;
|
|
61
|
-
}
|
|
62
|
-
const isReady = computed(() => store.value !== null && city.value !== null);
|
|
63
|
-
const hasStock = computed(() => stock.value !== null);
|
|
64
|
-
const currency = computed(() => store.value?.settings?.currency ?? "RUB");
|
|
65
|
-
const squareLogoUrl = computed(() => {
|
|
66
|
-
const logo = store.value?.square_logo ?? store.value?.logo;
|
|
67
|
-
if (!logo) return null;
|
|
68
|
-
return logo.hd?.url ?? logo.xlarge?.url ?? logo.large?.url ?? logo.medium?.url ?? logo.placeholder?.url ?? null;
|
|
69
|
-
});
|
|
70
|
-
return {
|
|
71
|
-
store,
|
|
72
|
-
city,
|
|
73
|
-
stock,
|
|
74
|
-
categories,
|
|
75
|
-
website,
|
|
76
|
-
initStore,
|
|
77
|
-
setStock,
|
|
78
|
-
setCategories,
|
|
79
|
-
initWebsite,
|
|
80
|
-
isReady,
|
|
81
|
-
hasStock,
|
|
82
|
-
currency,
|
|
83
|
-
squareLogoUrl
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
42
|
var AUTH_TOKEN_KEY = "zenky_auth_token";
|
|
87
43
|
var AUTH_PHONE_KEY = "zenky_auth_phone";
|
|
88
44
|
var YEAR_SECONDS = 60 * 60 * 24 * 365;
|
|
@@ -134,6 +90,6 @@ var useAuthStore = defineStore("zenky-auth", () => {
|
|
|
134
90
|
};
|
|
135
91
|
});
|
|
136
92
|
|
|
137
|
-
export { createStorefront, provideStorefront, useAuthStore, useRuntime
|
|
138
|
-
//# sourceMappingURL=chunk-
|
|
139
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
export { createStorefront, provideStorefront, useAuthStore, useRuntime };
|
|
94
|
+
//# sourceMappingURL=chunk-WTZXTBF6.js.map
|
|
95
|
+
//# sourceMappingURL=chunk-WTZXTBF6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ports/runtime.ts","../src/stores/auth.ts"],"names":[],"mappings":";;;;AAOA,IAAM,WAAA,mBAAc,MAAA,CAAO,GAAA,CAAI,0BAA0B,CAAA;AAMzD,IAAM,cAAA,GAAiB;AAAA,EACnB,KAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA;AACJ,CAAA;AAQA,SAAS,oBAA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A,IAAK,IAAA;AAClD,IAAA,KAAA,CAAM,KAAA,GAAQ,UAAA;AAEd,IAAA,KAAA,CAAM,KAAA,GAAQ,OAAA,CAAQ,GAAA,CAAI,cAAc,CAAA,IAAK,IAAA;AAAA,EACjD;AAEA,EAAA,OAAO;AAAA,IACH,KAAA;AAAA,IACA,KAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACJ;AACJ,CAAC","file":"chunk-WTZXTBF6.js","sourcesContent":["import { inject, provide, type App, type InjectionKey, type Plugin } from 'vue'\n\nimport type { StorefrontRuntime } from './index'\n\n// Composition root. The consumer assembles the runtime (adapters) once and installs\n// the plugin; domain composables read it via useRuntime() instead of calling Nuxt directly.\n\nconst RUNTIME_KEY = Symbol.for('zenky.storefront.runtime') as InjectionKey<StorefrontRuntime>\n\ntype RequiredPort = {\n [K in keyof StorefrontRuntime]-?: undefined extends StorefrontRuntime[K] ? never : K\n}[keyof StorefrontRuntime]\n\nconst REQUIRED_PORTS = [\n 'sdk',\n 'storage',\n 'notifier',\n 'activity',\n 'messages',\n] as const satisfies readonly RequiredPort[]\n\ntype ListedPort = (typeof REQUIRED_PORTS)[number]\ntype UnlistedRequiredPort = Exclude<RequiredPort, ListedPort>\n\nconst _allRequiredPortsListed: UnlistedRequiredPort extends never ? true : never = true\nvoid _allRequiredPortsListed\n\nfunction assertRequiredPorts(runtime: StorefrontRuntime): void {\n const missing = REQUIRED_PORTS.filter((port) => runtime[port] == null)\n if (missing.length > 0) {\n throw new Error(\n `[@zenky/storefront-vue] Runtime is missing required ports: ${missing.join(', ')}. ` +\n 'See the Runtime Ports table in the README.'\n )\n }\n}\n\n/** Vue plugin: app.use(createStorefront(runtime)). */\nexport function createStorefront(runtime: StorefrontRuntime): Plugin {\n assertRequiredPorts(runtime)\n\n return {\n install(app: App) {\n app.provide(RUNTIME_KEY, runtime)\n },\n }\n}\n\n/** Alternative to the plugin — calls provide() inside setup (e.g. for an isolated widget). */\nexport function provideStorefront(runtime: StorefrontRuntime): void {\n assertRequiredPorts(runtime)\n provide(RUNTIME_KEY, runtime)\n}\n\n/** Gives any core composable or store access to the runtime. */\nexport function useRuntime(): StorefrontRuntime {\n const runtime = inject(RUNTIME_KEY)\n if (!runtime) {\n throw new Error(\n '[@zenky/storefront-vue] Runtime was not provided. ' +\n 'Install the plugin with app.use(createStorefront(runtime)).'\n )\n }\n return runtime\n}\n","import { defineStore } from 'pinia'\nimport { computed, ref, type ComputedRef, type Ref } from 'vue'\n\nimport { useRuntime } from '../ports/runtime'\n\n// Keys match the old CookieKey.AuthToken/AuthPhone — so users don't get logged out.\nconst AUTH_TOKEN_KEY = 'zenky_auth_token'\nconst AUTH_PHONE_KEY = 'zenky_auth_phone'\nconst YEAR_SECONDS = 60 * 60 * 24 * 365\n\n// Named return type (the dts rule).\nexport interface AuthStore {\n token: Ref<string | null>\n phone: Ref<string | null>\n countryCode: Ref<string>\n isAuthenticated: ComputedRef<boolean>\n apiToken: ComputedRef<string | undefined>\n initials: ComputedRef<string>\n setToken: (token: string, phone?: string, countryCode?: string) => void\n clearToken: () => void\n initFromCookie: () => void\n}\n\nexport const useAuthStore = defineStore('zenky-auth', (): AuthStore => {\n // The token is only stored and exposed here — it is never written into the SDK.\n // The consumer passes it as a parameter on every call: mutating a shared client\n // during SSR would leak one user's Bearer token into another user's requests.\n const { storage } = useRuntime()\n\n const token = ref<string | null>(null)\n const phone = ref<string | null>(null)\n const countryCode = ref('RU')\n\n const isAuthenticated = computed(() => token.value !== null && token.value !== '')\n\n // The only place that decides which token goes to the SDK. Consumers read this\n // instead of `token` directly: undefined instead of an empty string, otherwise\n // an empty Bearer '' would be sent.\n const apiToken = computed(() =>\n isAuthenticated.value ? (token.value ?? undefined) : undefined\n )\n\n const initials = computed(() => {\n if (!phone.value) return '?'\n return phone.value.replace(/\\D/g, '').slice(-4)\n })\n\n function setToken(nextToken: string, nextPhone?: string, nextCountryCode?: string): void {\n token.value = nextToken\n storage.set(AUTH_TOKEN_KEY, nextToken, { maxAge: YEAR_SECONDS })\n\n if (nextPhone) {\n phone.value = nextPhone\n storage.set(AUTH_PHONE_KEY, nextPhone, { maxAge: YEAR_SECONDS })\n }\n\n if (nextCountryCode) {\n countryCode.value = nextCountryCode\n }\n }\n\n function clearToken(): void {\n token.value = null\n phone.value = null\n storage.remove(AUTH_TOKEN_KEY)\n storage.remove(AUTH_PHONE_KEY)\n }\n\n function initFromCookie(): void {\n const savedToken = storage.get(AUTH_TOKEN_KEY) || null\n token.value = savedToken\n\n phone.value = storage.get(AUTH_PHONE_KEY) || null\n }\n\n return {\n token,\n phone,\n countryCode,\n isAuthenticated,\n apiToken,\n initials,\n setToken,\n clearToken,\n initFromCookie,\n }\n})\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,16 +3,18 @@ export { ActivityReporter, CatalogReloader, CommerceAddedToCartPayload, Commerce
|
|
|
3
3
|
import { Plugin } from 'vue';
|
|
4
4
|
export { Major, Minor, asMajor, asMinor, formatPrice, majorToMinor, minorToMajor, minorToMajorString } from './money/index.js';
|
|
5
5
|
export { FontConfig, PrimaryShades, ThemeColorConfig, ThemeData, buildCssVariableMap, generatePrimaryShades, generateShades, useTheme } from './theme/index.js';
|
|
6
|
-
export { DayScheduleInfo, OperationChain, SocialLink, TodayScheduleInfo, buildQrCodeUrl, createDebounce, createOperationChain, formatAddressCityLast, formatDate, formatDateTime, formatPhoneNational, formatPhoneSpaced, formatScheduleStatus, getApiErrorMessage, getApiFieldErrors, getEmailLink, getPhoneTelLink, getSocialLinks, getTodayInfo, getWebsiteLink, getWeeklySchedule, pluralize, toDateInputValue, todayInTimezone } from './utils/index.js';
|
|
6
|
+
export { DayScheduleInfo, OperationChain, ScheduleRow, SocialLink, TodayScheduleInfo, buildQrCodeUrl, createDebounce, createOperationChain, formatAddressCityLast, formatDate, formatDateTime, formatPhoneNational, formatPhoneSpaced, formatScheduleStatus, getApiErrorMessage, getApiFieldErrors, getEmailLink, getPhoneTelLink, getSocialLinks, getTodayInfo, getWebsiteLink, getWeeklySchedule, groupScheduleDays, pluralize, toDateInputValue, todayInTimezone } from './utils/index.js';
|
|
7
7
|
export { CatalogProductMatch, CategoryWithProducts, OrderCredentials, ProductListParams, ProductVariantOptionListItem, ResolvedPrice, UseProductDetailApi, UseProductListApi, canAddDirectly, findProductInCatalog, formatWeight, getProductWeight, getVariantWeight, resolveVariantPrice, toGrams, usePriceRecalculation, useProductDetail, useProductList, useProductPricing, useProductVariant, useProductVariantModifiers, useProductVariantSelector, useProductsByCategory, useRelatedProducts } from './products/index.js';
|
|
8
8
|
export { GroupedProducts, SubcategoryGroup, collectDescendantIds, findCategoryById, findCategoryByShortId, findRootAncestor, getCategoryPath, getCity, getRemoteCatalog, getStock, groupProductsBySubcategory, useCollections } from './catalog/index.js';
|
|
9
9
|
export { C as CatalogEntity, S as StaticCatalogItem, a as StaticRemoteCatalog, c as catalogItemEntity, i as isRenderableCatalogItem } from './catalogEntity-DgrPsJpf.js';
|
|
10
|
-
export { AttachedCustomerCache, BonusesReconciliation, BonusesReconciliationDeps, CASH_DENOMINATIONS_MAJOR, CachedCustomerView, CartCredentials, CartDependencies, CartErrorScope, CartInitialization, CartItemRequest, CartLineKeyParams, CartMutationComposable, CartOperations, CartQuantities, CartRecalculation, CartRecalculationDeps, CartStockWatcher, CashChangePresetsOptions, CheckoutFlowFlags,
|
|
10
|
+
export { AttachedCustomerCache, BonusesReconciliation, BonusesReconciliationDeps, CASH_DENOMINATIONS_MAJOR, CachedCustomerView, CartCredentials, CartDependencies, CartErrorScope, CartInitialization, CartItemRequest, CartLineKeyParams, CartMutationComposable, CartOperations, CartQuantities, CartRecalculation, CartRecalculationDeps, CartStockWatcher, CashChangePresetsOptions, CheckoutFlowFlags, CustomerAttachComposable, DEFAULT_ROUND_STEPS_MAJOR, MainPaymentRequestParams, MutationKind, MutationOptions, ORDER_EVENTS, ORDER_WITH, OrderBonusesComposable, OrderBonusesDeps, OrderCredentialsLike, OrderDelivery, OrderDeliveryDeps, OrderPromocodeComposable, OrderPromocodeDeps, OrderSettingsComposable, OrderTotal, PaymentSelection, PaymentSelectionComposable, RestrictedAddToCart, RestrictionGate, RestrictionGateProduct, RetryOptions, StorefrontCart, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCartErrorCode, getCartErrorHttpCode, getCartErrorMessage, getCashDenominationsMinor, getDefaultRoundStepsMinor, getValidationErrors, logCartError, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCredentials, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey } from './cart/index.js';
|
|
11
|
+
export { C as CheckoutSubmitComposable, R as RecaptchaPayloadProvider, u as useCheckoutSubmit } from './useCheckoutSubmit-C934F26-.js';
|
|
11
12
|
export { RawSnippetItem, Snippet, SnippetGroup, SnippetLanguage, SnippetPosition, normalizeSnippets } from './snippets/index.js';
|
|
12
13
|
export { SettingValue, Website, WebsitePage, WebsitePageListItem, WebsitePageSeo, WebsitePageType, WebsiteSettingsValues } from './website-settings/index.js';
|
|
13
|
-
export { AppliedBonusesIntent, AuthStore, CartStore, MinPriceViolation, OrderSettingsStore, PromotionsStore, RewardSelection, RewardSelectionContext, StoreProfileStore, useAuthStore, useCartStore, useCatalogStore, useOrderSettingsStore, useProductsStore, usePromotionsStore, useStore, useStoreProfileStore, useStorefrontProfile } from './stores/index.js';
|
|
14
|
+
export { AppliedBonusesIntent, AuthFlowStore, AuthStore, CartStore, MinPriceViolation, OrderSettingsStore, PromotionsStore, RESEND_TIMER_SECONDS, RewardSelection, RewardSelectionContext, StoreProfileStore, useAuthFlowStore, useAuthStore, useCartStore, useCatalogStore, useOrderSettingsStore, useProductsStore, usePromotionsStore, useStore, useStoreProfileStore, useStorefrontProfile } from './stores/index.js';
|
|
14
15
|
import '@zenky/integrations-sdk';
|
|
15
16
|
import '@zenky/storefront-api';
|
|
17
|
+
import './types-CXm2F6Hz.js';
|
|
16
18
|
import 'pinia';
|
|
17
19
|
|
|
18
20
|
/** Vue plugin: app.use(createStorefront(runtime)). */
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
+
export { canAddDirectly, findProductInCatalog, formatWeight, getProductWeight, getVariantWeight, resolveVariantPrice, toGrams, usePriceRecalculation, useProductDetail, useProductList, useProductPricing, useProductVariant, useProductVariantModifiers, useProductVariantSelector, useProductsByCategory, useRelatedProducts } from './chunk-6FVXAF7L.js';
|
|
1
2
|
export { normalizeSnippets } from './chunk-GLQXTMVW.js';
|
|
2
|
-
export { useProductsStore, useStore, useStorefrontProfile } from './chunk-FXKG5TFQ.js';
|
|
3
|
-
export { buildQrCodeUrl, createOperationChain, formatAddressCityLast, formatDate, formatDateTime, formatPhoneNational, formatPhoneSpaced, formatScheduleStatus, getApiErrorMessage, getApiFieldErrors, getEmailLink, getPhoneTelLink, getSocialLinks, getTodayInfo, getWebsiteLink, getWeeklySchedule, pluralize, toDateInputValue, todayInTimezone } from './chunk-GXDTRTUT.js';
|
|
4
3
|
export { buildCssVariableMap, generatePrimaryShades, generateShades, useTheme } from './chunk-BUNI6MGH.js';
|
|
4
|
+
export { buildQrCodeUrl, createOperationChain, formatAddressCityLast, formatDate, formatDateTime, formatPhoneNational, formatPhoneSpaced, formatScheduleStatus, getApiErrorMessage, getApiFieldErrors, getEmailLink, getPhoneTelLink, getSocialLinks, getTodayInfo, getWebsiteLink, getWeeklySchedule, groupScheduleDays, pluralize, toDateInputValue, todayInTimezone } from './chunk-RURXGVWW.js';
|
|
5
|
+
export { createDebounce } from './chunk-XUGXLJZB.js';
|
|
5
6
|
import './chunk-EMGQXBU3.js';
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
export {
|
|
7
|
+
export { RESEND_TIMER_SECONDS, useAuthFlowStore, useProductsStore, useStore, useStorefrontProfile } from './chunk-LUJSF6V7.js';
|
|
8
|
+
import './chunk-5B2P5W3E.js';
|
|
9
|
+
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCashDenominationsMinor, getDefaultRoundStepsMinor, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey } from './chunk-EM6H5WFS.js';
|
|
10
|
+
export { useCartCredentials } from './chunk-W43D7JYV.js';
|
|
11
|
+
import './chunk-5QCUH3FF.js';
|
|
12
|
+
export { getCartErrorCode, getCartErrorHttpCode, getCartErrorMessage, getValidationErrors, logCartError } from './chunk-TE42OCFK.js';
|
|
13
|
+
export { useCartStore, useOrderSettingsStore, usePromotionsStore } from './chunk-TE2QPH74.js';
|
|
14
|
+
export { useCatalogStore } from './chunk-NSOIL7PW.js';
|
|
15
|
+
export { createStorefront, provideStorefront, useAuthStore, useRuntime } from './chunk-WTZXTBF6.js';
|
|
16
|
+
import './chunk-TIQ7AJLY.js';
|
|
17
|
+
export { useStoreProfileStore } from './chunk-IOYYCA75.js';
|
|
9
18
|
export { catalogItemEntity, collectDescendantIds, findCategoryById, findCategoryByShortId, findRootAncestor, getCategoryPath, groupProductsBySubcategory, isRenderableCatalogItem, useCollections } from './chunk-OBNMXLJO.js';
|
|
10
19
|
export { getCity, getRemoteCatalog, getStock } from './chunk-FS2UNPTY.js';
|
|
11
20
|
export { asMajor, asMinor, formatPrice, majorToMinor, minorToMajor, minorToMajorString } from './chunk-2Y6QTHXI.js';
|
|
12
|
-
export { KEY_MESSAGE_FORMATTER, NOOP_ACTIVITY_REPORTER, NOOP_NOTIFIER, NOOP_RUM, createMemoryStorage, err, ok } from './chunk-
|
|
13
|
-
export { canAddDirectly, findProductInCatalog, formatWeight, getProductWeight, getVariantWeight, resolveVariantPrice, toGrams, usePriceRecalculation, useProductDetail, useProductList, useProductPricing, useProductVariant, useProductVariantModifiers, useProductVariantSelector, useProductsByCategory, useRelatedProducts } from './chunk-32SLDGE5.js';
|
|
14
|
-
export { createDebounce } from './chunk-XUGXLJZB.js';
|
|
15
|
-
import './chunk-5QCUH3FF.js';
|
|
16
|
-
export { useCatalogStore } from './chunk-NSOIL7PW.js';
|
|
17
|
-
export { createStorefront, provideStorefront, useAuthStore, useRuntime, useStoreProfileStore } from './chunk-QZ3S3NN3.js';
|
|
21
|
+
export { KEY_MESSAGE_FORMATTER, NOOP_ACTIVITY_REPORTER, NOOP_NOTIFIER, NOOP_RUM, createMemoryStorage, err, ok } from './chunk-VTZYJ6OZ.js';
|
|
18
22
|
//# sourceMappingURL=index.js.map
|
|
19
23
|
//# sourceMappingURL=index.js.map
|
package/dist/ports/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ interface Notifier {
|
|
|
32
32
|
}): void;
|
|
33
33
|
}
|
|
34
34
|
/** Stable message identifiers emitted by domain logic. Text and locale belong to the consumer. */
|
|
35
|
-
type StorefrontMessageKey = 'cart.added.title' | 'cart.bonuses.changed.description' | 'cart.bonuses.changed.title' | 'cart.customer.saveFailed' | 'cart.customer.updateAfterLoginFailed' | 'cart.customer.updated' | 'cart.customer.updatedWithName' | 'cart.payment.updateFailed' | 'cart.promocode.applyFailed' | 'cart.promocode.removeFailed' | 'cart.stock.catalogReloadFailed' | 'cart.stock.checkFailed' | 'cart.stock.itemsRemoved' | 'cart.stock.pricesUpdated' | 'cart.updateFailed';
|
|
35
|
+
type StorefrontMessageKey = 'auth.checkPhoneFailed' | 'auth.dispatchResetFailed' | 'auth.invalidCode' | 'auth.invalidPassword' | 'auth.otpUnavailable' | 'auth.registerFailed' | 'auth.resendCodeFailed' | 'auth.resetPasswordFailed' | 'cart.added.title' | 'cart.bonuses.changed.description' | 'cart.bonuses.changed.title' | 'cart.customer.saveFailed' | 'cart.customer.updateAfterLoginFailed' | 'cart.customer.updated' | 'cart.customer.updatedWithName' | 'cart.payment.updateFailed' | 'cart.promocode.applyFailed' | 'cart.promocode.removeFailed' | 'cart.stock.catalogReloadFailed' | 'cart.stock.checkFailed' | 'cart.stock.itemsRemoved' | 'cart.stock.pricesUpdated' | 'cart.updateFailed';
|
|
36
36
|
type StorefrontMessageParams = Readonly<Record<string, string | number | boolean | null | undefined>>;
|
|
37
37
|
/** Converts domain message identifiers into consumer-owned, localized UI copy. */
|
|
38
38
|
interface MessageFormatter {
|
package/dist/ports/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { KEY_MESSAGE_FORMATTER, NOOP_ACTIVITY_REPORTER, NOOP_NOTIFIER, NOOP_RUM, createMemoryStorage, err, ok } from '../chunk-
|
|
1
|
+
export { KEY_MESSAGE_FORMATTER, NOOP_ACTIVITY_REPORTER, NOOP_NOTIFIER, NOOP_RUM, createMemoryStorage, err, ok } from '../chunk-VTZYJ6OZ.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/products/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { canAddDirectly, findProductInCatalog, formatWeight, getProductWeight, getVariantWeight, resolveVariantPrice, toGrams, usePriceRecalculation, useProductDetail, useProductList, useProductPricing, useProductVariant, useProductVariantModifiers, useProductVariantSelector, useProductsByCategory, useRelatedProducts } from '../chunk-
|
|
1
|
+
export { canAddDirectly, findProductInCatalog, formatWeight, getProductWeight, getVariantWeight, resolveVariantPrice, toGrams, usePriceRecalculation, useProductDetail, useProductList, useProductPricing, useProductVariant, useProductVariantModifiers, useProductVariantSelector, useProductsByCategory, useRelatedProducts } from '../chunk-6FVXAF7L.js';
|
|
2
2
|
import '../chunk-XUGXLJZB.js';
|
|
3
3
|
import '../chunk-5QCUH3FF.js';
|
|
4
4
|
import '../chunk-NSOIL7PW.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-WTZXTBF6.js';
|
|
6
|
+
import '../chunk-IOYYCA75.js';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/promotions/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { usePromotionsChecker } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { usePromotionsChecker } from '../chunk-W43D7JYV.js';
|
|
2
|
+
import '../chunk-TE2QPH74.js';
|
|
3
|
+
import '../chunk-WTZXTBF6.js';
|
|
4
|
+
import '../chunk-IOYYCA75.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/seo/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { resolveVariantPrice } from '../chunk-32SLDGE5.js';
|
|
1
|
+
import { resolveVariantPrice } from '../chunk-6FVXAF7L.js';
|
|
2
|
+
import { getSocialLinks } from '../chunk-RURXGVWW.js';
|
|
4
3
|
import '../chunk-XUGXLJZB.js';
|
|
5
4
|
import '../chunk-5QCUH3FF.js';
|
|
6
5
|
import '../chunk-NSOIL7PW.js';
|
|
7
|
-
import '../chunk-
|
|
6
|
+
import '../chunk-WTZXTBF6.js';
|
|
7
|
+
import '../chunk-IOYYCA75.js';
|
|
8
|
+
import { minorToMajorString } from '../chunk-2Y6QTHXI.js';
|
|
8
9
|
import { ContactType } from '@zenky/storefront-api';
|
|
9
10
|
|
|
10
11
|
// src/seo/utils.ts
|
package/dist/seo/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/seo/utils.ts","../../src/seo/siteOrigin.ts","../../src/seo/productSchema.ts","../../src/seo/listingSchema.ts","../../src/seo/articleSchema.ts","../../src/seo/organizationSchema.ts","../../src/seo/ogTags.ts","../../src/seo/entitySeo.ts"],"names":[],"mappings":";;;;;;;;;;AAKO,SAAS,gBAAgB,KAAA,EAA6B;AACzD,EAAA,OACI,KAAA,CAAM,EAAA,EAAI,GAAA,IACV,KAAA,CAAM,QAAQ,GAAA,IACd,KAAA,CAAM,KAAA,EAAO,GAAA,IACb,KAAA,CAAM,MAAA,EAAQ,GAAA,IACd,KAAA,CAAM,aAAa,GAAA,IACnB,IAAA;AAER;AAMO,SAAS,oBAAoB,KAAA,EAAgD;AAChF,EAAA,IAAI,CAAC,OAAO,OAAO,IAAA;AACnB,EAAA,IAAI,MAAM,WAAA,EAAa;AACnB,IAAA,MAAM,GAAA,GAAM,eAAA,CAAgB,KAAA,CAAM,WAAW,CAAA;AAC7C,IAAA,IAAI,KAAK,OAAO,GAAA;AAAA,EACpB;AACA,EAAA,IAAI,MAAM,IAAA,EAAM;AACZ,IAAA,OAAO,eAAA,CAAgB,MAAM,IAAI,CAAA;AAAA,EACrC;AACA,EAAA,OAAO,IAAA;AACX;AAKO,SAAS,UAAU,IAAA,EAAsB;AAC5C,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,UAAA,EAAY,EAAE,EAAE,IAAA,EAAK;AAC7C;AAMO,SAAS,oBAAA,CACZ,IAAA,EACA,SAAA,GAAY,GAAA,EACC;AACb,EAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,EAAA,MAAM,KAAA,GAAQ,UAAU,IAAI,CAAA;AAC5B,EAAA,IAAI,CAAC,OAAO,OAA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GAAgC;AAAA,MAClC,CAAC,GAAA,CAAI,IAAA,CAAK,SAAS,GAAG,IAAI,IAAA,CAAK,KAAA;AAAA,MAC/B,CAAC,GAAA,CAAI,KAAA,CAAM,SAAS,GAAG,IAAI,KAAA,CAAM;AAAA,KACrC;AAEA,IAAA,KAAA,MAAW,UAAA,IAAc,IAAI,UAAA,EAAY;AACrC,MAAA,KAAA,CAAM,UAAA,CAAW,SAAS,CAAA,GAAI,UAAA,CAAW,KAAA;AAAA,IAC7C;AAEA,IAAA,OAAO,KAAA;AAAA,EACX,CAAC,CAAA;AACL;AAGO,SAAS,mBAAmB,GAAA,EAAuD;AACtF,EAAA,MAAM,OAAiC,EAAC;AAExC,EAAA,IAAI,KAAK,WAAA,EAAa;AAClB,IAAA,IAAA,CAAK,KAAK,EAAE,IAAA,EAAM,eAAe,OAAA,EAAS,GAAA,CAAI,aAAa,CAAA;AAAA,EAC/D;AAEA,EAAA,IAAI,GAAA,EAAK,MAAM,MAAA,EAAQ;AACnB,IAAA,IAAA,CAAK,IAAA,CAAK,GAAG,cAAA,CAAe,GAAA,CAAI,IAAI,CAAC,CAAA;AAAA,EACzC;AAEA,EAAA,OAAO,IAAA;AACX","file":"index.js","sourcesContent":["import type { Media, Store } from '@zenky/storefront-api'\n\n/**\n * Resolves the best available URL from a Media object.\n */\nexport function resolveMediaUrl(media: Media): string | null {\n return (\n media.hd?.url ||\n media.xlarge?.url ||\n media.large?.url ||\n media.medium?.url ||\n media.placeholder?.url ||\n null\n )\n}\n\n/**\n * Resolves store logo URL, preferring square logo over rectangular.\n * Tries all available size variants so CDN assets with only hd/xlarge are found too.\n */\nexport function resolveStoreLogoUrl(store: Store | null | undefined): string | null {\n if (!store) return null\n if (store.square_logo) {\n const url = resolveMediaUrl(store.square_logo)\n if (url) return url\n }\n if (store.logo) {\n return resolveMediaUrl(store.logo)\n }\n return null\n}\n\n/**\n * Strips HTML tags from a string.\n */\nexport function stripHtml(html: string): string {\n return html.replace(/<[^>]*>/g, '').trim()\n}\n\n/**\n * Prepares a string for use as og:description or meta description:\n * strips HTML tags and truncates to maxLength (default 160).\n */\nexport function prepareOgDescription(\n text: string | null | undefined,\n maxLength = 160\n): string | null {\n if (!text) return null\n const plain = stripHtml(text)\n if (!plain) return null\n return plain.length > maxLength ? `${plain.slice(0, maxLength - 3)}...` : plain\n}\n","/**\n * Canonical public origin of the site, from `store.domain`. The fallback (request host)\n * is supplied by the consumer — the core doesn't know about `useRequestURL`.\n */\nexport function resolveSiteOrigin(\n storeDomain: string | null | undefined,\n fallbackOrigin: string\n): string {\n const domain = storeDomain?.trim()\n if (domain) {\n const host = domain.replace(/^https?:\\/\\//, '').replace(/\\/+$/, '')\n return `https://${host}`\n }\n return fallbackOrigin\n}\n","import type { Product, ProductVariant } from '@zenky/storefront-api'\n\nimport { minorToMajorString } from '../money'\nimport { resolveVariantPrice } from '../products'\nimport { resolveMediaUrl } from './utils'\n\nfunction isProductInStock(variants: ProductVariant[]): boolean {\n if (!variants.length) return false\n return variants.some((variant) => {\n const remainders = variant.remainders\n if (!remainders?.length) return true\n return remainders.some((remainder) => remainder.quantity > 0)\n })\n}\n\n/**\n * JSON-LD schema.org/Product. Google uses it for Rich Results (price, availability,\n * rating in search listings).\n * Returns an array of 0 or 1 objects — the consumer wraps it in a `<script ld+json>` tag.\n * Spec: https://schema.org/Product\n */\nexport function buildProductSchema(product: Product, currency: string): Record<string, unknown>[] {\n const variants = product.variants ?? []\n\n const firstVariant = variants[0]\n let offerBlock: Record<string, unknown> | undefined\n\n if (firstVariant) {\n const resolved = resolveVariantPrice(firstVariant)\n\n offerBlock = {\n '@type': 'Offer',\n price: minorToMajorString(resolved.price, currency),\n priceCurrency: currency,\n availability: isProductInStock(variants)\n ? 'https://schema.org/InStock'\n : 'https://schema.org/OutOfStock',\n ...(firstVariant.sku ? { sku: firstVariant.sku } : {}),\n }\n }\n\n const images = (product.images ?? []).map(resolveMediaUrl).filter((url): url is string => !!url)\n\n const schema: Record<string, unknown> = {\n '@context': 'https://schema.org',\n '@type': 'Product',\n name: product.name,\n }\n\n if (product.description) schema.description = product.description\n if (images.length) schema.image = images\n if (offerBlock) schema.offers = offerBlock\n\n return [schema]\n}\n","import type { NestedCategory, Product, ProductsCollection } from '@zenky/storefront-api'\n\nimport { resolveMediaUrl } from './utils'\nimport type { BreadcrumbItem } from './types'\n\n/**\n * JSON-LD for a product listing page: BreadcrumbList + ItemList (first 10 products).\n * Returns an array of 0-2 JSON-LD objects. Category and collection pages differ only\n * in the list name, so both go through here.\n * Spec: https://schema.org/ItemList · https://schema.org/BreadcrumbList\n */\nfunction buildListingSchemas(\n name: string | null,\n products: Product[],\n breadcrumbs: BreadcrumbItem[],\n origin: string\n): Record<string, unknown>[] {\n const schemas: Record<string, unknown>[] = []\n\n if (breadcrumbs.length) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'BreadcrumbList',\n itemListElement: breadcrumbs.map((crumb, index) => ({\n '@type': 'ListItem',\n position: index + 1,\n name: crumb.label,\n ...(crumb.to ? { item: `${origin}${crumb.to}` } : {}),\n })),\n })\n }\n\n const items = products.slice(0, 10)\n if (items.length) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'ItemList',\n name,\n numberOfItems: items.length,\n itemListElement: items.map((product, index) => {\n const url = `${origin}/products/${product.short_id}/${product.slug || product.short_id}`\n const firstImage = product.images?.[0]\n const image = firstImage ? resolveMediaUrl(firstImage) : null\n\n const item: Record<string, unknown> = {\n '@type': 'ListItem',\n position: index + 1,\n url,\n name: product.name,\n }\n\n if (image) item.image = image\n\n return item\n }),\n })\n }\n\n return schemas\n}\n\n/** JSON-LD for a category page. */\nexport function buildCategorySchemas(\n category: NestedCategory,\n products: Product[],\n breadcrumbs: BreadcrumbItem[],\n origin: string\n): Record<string, unknown>[] {\n return buildListingSchemas(category.name, products, breadcrumbs, origin)\n}\n\n/** JSON-LD for a products collection page. */\nexport function buildCollectionSchemas(\n collection: ProductsCollection,\n products: Product[],\n breadcrumbs: BreadcrumbItem[],\n origin: string\n): Record<string, unknown>[] {\n return buildListingSchemas(collection.name, products, breadcrumbs, origin)\n}\n","import type { Article, Media, OfferArticle } from '@zenky/storefront-api'\n\nimport { prepareOgDescription, resolveMediaUrl } from './utils'\n\nfunction articleSchema(\n type: 'Article' | 'BlogPosting',\n opts: {\n title: string | null | undefined\n intro: string | null | undefined\n cover: Media | null | undefined\n storeName: string\n origin: string\n }\n): Record<string, unknown> {\n const schema: Record<string, unknown> = {\n '@context': 'https://schema.org',\n '@type': type,\n headline: opts.title ?? '',\n author: {\n '@type': 'Organization',\n name: opts.storeName,\n url: opts.origin,\n },\n }\n\n const description = prepareOgDescription(opts.intro)\n if (description) schema.description = description\n\n const image = opts.cover ? resolveMediaUrl(opts.cover) : null\n if (image) schema.image = image\n\n return schema\n}\n\n/**\n * JSON-LD schema.org/Article for the offer page's editorial copy.\n * Spec: https://schema.org/Article\n */\nexport function buildOfferArticleSchema(\n article: OfferArticle,\n storeName: string,\n origin: string\n): Record<string, unknown>[] {\n if (!article.title) return []\n\n return [\n articleSchema('Article', {\n title: article.title,\n intro: article.intro,\n cover: article.cover,\n storeName,\n origin,\n }),\n ]\n}\n\n/**\n * JSON-LD schema.org/BlogPosting for a blog article — enables Google Rich Results.\n * Spec: https://schema.org/BlogPosting\n */\nexport function buildBlogPostSchema(\n article: Article,\n storeName: string,\n origin: string\n): Record<string, unknown>[] {\n const schema = articleSchema('BlogPosting', {\n title: article.title,\n intro: article.intro,\n cover: article.cover,\n storeName,\n origin,\n })\n\n if (article.updated_at) {\n schema.dateModified = article.updated_at\n // No separate datePublished field is available — reuse updated_at.\n schema.datePublished = article.updated_at\n }\n\n return [schema]\n}\n","import { ContactType } from '@zenky/storefront-api'\n\nimport type { Schedule, Store } from '@zenky/storefront-api'\n\nimport { getSocialLinks } from '../utils'\n\n/** Schedule.days key → schema.org DayOfWeek. */\nconst SCHEMA_DAY: Record<string, string> = {\n monday: 'Monday',\n tuesday: 'Tuesday',\n wednesday: 'Wednesday',\n thursday: 'Thursday',\n friday: 'Friday',\n saturday: 'Saturday',\n sunday: 'Sunday',\n}\n\n/**\n * Schedule (per-day `hours` string like \"10:00-22:00\") → array of schema.org/OpeningHoursSpecification.\n * Days without a recognizable interval (day off / 24 hours / empty) are skipped.\n */\nfunction buildOpeningHours(schedule: Schedule | null | undefined): Record<string, unknown>[] {\n if (!schedule) return []\n\n const result: Record<string, unknown>[] = []\n for (const key of Object.keys(SCHEMA_DAY)) {\n const day = schedule.days[key as keyof typeof schedule.days]\n const match = day?.hours?.match(/(\\d{1,2}:\\d{2}).*?(\\d{1,2}:\\d{2})/)\n if (!match) continue\n\n result.push({\n '@type': 'OpeningHoursSpecification',\n dayOfWeek: SCHEMA_DAY[key],\n opens: match[1],\n closes: match[2],\n })\n }\n\n return result\n}\n\n/**\n * JSON-LD schema.org/Organization (or LocalBusiness if there's a physical location)\n * for the homepage. Feeds Google's Knowledge Panel. All data comes from the\n * already-loaded profile.\n * Spec: https://schema.org/Organization · https://schema.org/LocalBusiness\n */\nexport function buildOrganizationSchema(store: Store, origin: string): Record<string, unknown>[] {\n const logoUrl =\n store.square_logo?.medium?.url ||\n store.square_logo?.large?.url ||\n store.logo?.medium?.url ||\n store.logo?.large?.url ||\n null\n\n const phones = (store.phones ?? []).map((p) => p.number).filter((n): n is string => !!n)\n const email = store.links?.find((c) => c.type === ContactType.Email)?.value ?? null\n const socialLinks = getSocialLinks(store.links ?? []).map((l) => l.url)\n\n const city = (store.cities ?? []).find((c) => c.is_default) ?? store.cities?.[0] ?? null\n const stock = city?.stocks?.find((st) => st.address) ?? city?.stocks?.[0] ?? null\n\n const streetAddress = stock?.address ?? null\n const geo = stock?.coordinates ?? city?.coordinates ?? null\n const openingHours = buildOpeningHours(stock?.schedule ?? city?.schedule)\n\n const isLocalBusiness = Boolean(streetAddress || geo || openingHours.length)\n\n const schema: Record<string, unknown> = {\n '@context': 'https://schema.org',\n '@type': isLocalBusiness ? 'LocalBusiness' : 'Organization',\n name: store.name,\n url: origin,\n }\n\n if (logoUrl) {\n schema.logo = logoUrl\n schema.image = logoUrl\n }\n\n if (phones.length) schema.telephone = phones.length === 1 ? phones[0] : phones\n if (email) schema.email = email\n if (socialLinks.length) schema.sameAs = socialLinks\n\n if (streetAddress || city?.name) {\n schema.address = {\n '@type': 'PostalAddress',\n ...(streetAddress ? { streetAddress } : {}),\n ...(city?.name ? { addressLocality: city.name } : {}),\n addressCountry: 'RU',\n }\n }\n\n if (geo) {\n schema.geo = {\n '@type': 'GeoCoordinates',\n latitude: geo.latitude,\n longitude: geo.longitude,\n }\n }\n\n if (openingHours.length) schema.openingHoursSpecification = openingHours\n\n return [schema]\n}\n","/** Already-resolved OG/Twitter tag values (with the consumer's defaults applied). */\nexport interface OgTagsInput {\n title: string | null\n description?: string | null\n image?: string | null\n type?: string\n url?: string | null\n}\n\n/** Framework-neutral OG + Twitter meta records. The consumer controls head priority. */\nexport function buildOgTags(input: OgTagsInput): Record<string, string>[] {\n const tags: Record<string, string>[] = []\n\n if (input.title) {\n tags.push({ property: 'og:title', content: input.title })\n tags.push({ name: 'twitter:title', content: input.title })\n }\n\n if (input.description) {\n tags.push({ property: 'og:description', content: input.description })\n tags.push({ name: 'twitter:description', content: input.description })\n }\n\n if (input.image) {\n tags.push({ property: 'og:image', content: input.image })\n tags.push({ name: 'twitter:image', content: input.image })\n }\n\n tags.push({ property: 'og:type', content: input.type ?? 'website' })\n\n if (input.url) {\n tags.push({ property: 'og:url', content: input.url })\n }\n\n return tags\n}\n","import type { Seo, SeoMetaTag } from '@zenky/storefront-api'\n\n/** SDK `Seo.meta` tags mapped to framework-neutral head meta records. */\nexport function mapSeoMetaTags(tags: SeoMetaTag[]): Record<string, string>[] {\n return tags.map((tag) => {\n const attrs: Record<string, string> = {\n [tag.name.attribute]: tag.name.value,\n [tag.value.attribute]: tag.value.value,\n }\n\n for (const additional of tag.additional) {\n attrs[additional.attribute] = additional.value\n }\n\n return attrs\n })\n}\n\n/** Meta tags from a `Seo` entity (description + `Seo.meta` mapping). The consumer resolves the title. */\nexport function buildEntitySeoMeta(seo: Seo | null | undefined): Record<string, string>[] {\n const tags: Record<string, string>[] = []\n\n if (seo?.description) {\n tags.push({ name: 'description', content: seo.description })\n }\n\n if (seo?.meta?.length) {\n tags.push(...mapSeoMetaTags(seo.meta))\n }\n\n return tags\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/seo/utils.ts","../../src/seo/siteOrigin.ts","../../src/seo/productSchema.ts","../../src/seo/listingSchema.ts","../../src/seo/articleSchema.ts","../../src/seo/organizationSchema.ts","../../src/seo/ogTags.ts","../../src/seo/entitySeo.ts"],"names":[],"mappings":";;;;;;;;;;;AAKO,SAAS,gBAAgB,KAAA,EAA6B;AACzD,EAAA,OACI,KAAA,CAAM,EAAA,EAAI,GAAA,IACV,KAAA,CAAM,QAAQ,GAAA,IACd,KAAA,CAAM,KAAA,EAAO,GAAA,IACb,KAAA,CAAM,MAAA,EAAQ,GAAA,IACd,KAAA,CAAM,aAAa,GAAA,IACnB,IAAA;AAER;AAMO,SAAS,oBAAoB,KAAA,EAAgD;AAChF,EAAA,IAAI,CAAC,OAAO,OAAO,IAAA;AACnB,EAAA,IAAI,MAAM,WAAA,EAAa;AACnB,IAAA,MAAM,GAAA,GAAM,eAAA,CAAgB,KAAA,CAAM,WAAW,CAAA;AAC7C,IAAA,IAAI,KAAK,OAAO,GAAA;AAAA,EACpB;AACA,EAAA,IAAI,MAAM,IAAA,EAAM;AACZ,IAAA,OAAO,eAAA,CAAgB,MAAM,IAAI,CAAA;AAAA,EACrC;AACA,EAAA,OAAO,IAAA;AACX;AAKO,SAAS,UAAU,IAAA,EAAsB;AAC5C,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,UAAA,EAAY,EAAE,EAAE,IAAA,EAAK;AAC7C;AAMO,SAAS,oBAAA,CACZ,IAAA,EACA,SAAA,GAAY,GAAA,EACC;AACb,EAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,EA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A,OAAO,IAAA,CAAK,GAAA,CAAI,CAAC,GAAA,KAAQ;AACrB,IAAA,MAAM,KAAA,GAAgC;AAAA,MAClC,CAAC,GAAA,CAAI,IAAA,CAAK,SAAS,GAAG,IAAI,IAAA,CAAK,KAAA;AAAA,MAC/B,CAAC,GAAA,CAAI,KAAA,CAAM,SAAS,GAAG,IAAI,KAAA,CAAM;AAAA,KACrC;AAEA,IAAA,KAAA,MAAW,UAAA,IAAc,IAAI,UAAA,EAAY;AACrC,MAAA,KAAA,CAAM,UAAA,CAAW,SAAS,CAAA,GAAI,UAAA,CAAW,KAAA;AAAA,IAC7C;AAEA,IAAA,OAAO,KAAA;AAAA,EACX,CAAC,CAAA;AACL;AAGO,SAAS,mBAAmB,GAAA,EAAuD;AACtF,EAAA,MAAM,OAAiC,EAAC;AAExC,EAAA,IAAI,KAAK,WAAA,EAAa;AAClB,IAAA,IAAA,CAAK,KAAK,EAAE,IAAA,EAAM,eAAe,OAAA,EAAS,GAAA,CAAI,aAAa,CAAA;AAAA,EAC/D;AAEA,EAAA,IAAI,GAAA,EAAK,MAAM,MAAA,EAAQ;AACnB,IAAA,IAAA,CAAK,IAAA,CAAK,GAAG,cAAA,CAAe,GAAA,CAAI,IAAI,CAAC,CAAA;AAAA,EACzC;AAEA,EAAA,OAAO,IAAA;AACX","file":"index.js","sourcesContent":["import type { Media, Store } from '@zenky/storefront-api'\n\n/**\n * Resolves the best available URL from a Media object.\n */\nexport function resolveMediaUrl(media: Media): string | null {\n return (\n media.hd?.url ||\n media.xlarge?.url ||\n media.large?.url ||\n media.medium?.url ||\n media.placeholder?.url ||\n null\n )\n}\n\n/**\n * Resolves store logo URL, preferring square logo over rectangular.\n * Tries all available size variants so CDN assets with only hd/xlarge are found too.\n */\nexport function resolveStoreLogoUrl(store: Store | null | undefined): string | null {\n if (!store) return null\n if (store.square_logo) {\n const url = resolveMediaUrl(store.square_logo)\n if (url) return url\n }\n if (store.logo) {\n return resolveMediaUrl(store.logo)\n }\n return null\n}\n\n/**\n * Strips HTML tags from a string.\n */\nexport function stripHtml(html: string): string {\n return html.replace(/<[^>]*>/g, '').trim()\n}\n\n/**\n * Prepares a string for use as og:description or meta description:\n * strips HTML tags and truncates to maxLength (default 160).\n */\nexport function prepareOgDescription(\n text: string | null | undefined,\n maxLength = 160\n): string | null {\n if (!text) return null\n const plain = stripHtml(text)\n if (!plain) return null\n return plain.length > maxLength ? `${plain.slice(0, maxLength - 3)}...` : plain\n}\n","/**\n * Canonical public origin of the site, from `store.domain`. The fallback (request host)\n * is supplied by the consumer — the core doesn't know about `useRequestURL`.\n */\nexport function resolveSiteOrigin(\n storeDomain: string | null | undefined,\n fallbackOrigin: string\n): string {\n const domain = storeDomain?.trim()\n if (domain) {\n const host = domain.replace(/^https?:\\/\\//, '').replace(/\\/+$/, '')\n return `https://${host}`\n }\n return fallbackOrigin\n}\n","import type { Product, ProductVariant } from '@zenky/storefront-api'\n\nimport { minorToMajorString } from '../money'\nimport { resolveVariantPrice } from '../products'\nimport { resolveMediaUrl } from './utils'\n\nfunction isProductInStock(variants: ProductVariant[]): boolean {\n if (!variants.length) return false\n return variants.some((variant) => {\n const remainders = variant.remainders\n if (!remainders?.length) return true\n return remainders.some((remainder) => remainder.quantity > 0)\n })\n}\n\n/**\n * JSON-LD schema.org/Product. Google uses it for Rich Results (price, availability,\n * rating in search listings).\n * Returns an array of 0 or 1 objects — the consumer wraps it in a `<script ld+json>` tag.\n * Spec: https://schema.org/Product\n */\nexport function buildProductSchema(product: Product, currency: string): Record<string, unknown>[] {\n const variants = product.variants ?? []\n\n const firstVariant = variants[0]\n let offerBlock: Record<string, unknown> | undefined\n\n if (firstVariant) {\n const resolved = resolveVariantPrice(firstVariant)\n\n offerBlock = {\n '@type': 'Offer',\n price: minorToMajorString(resolved.price, currency),\n priceCurrency: currency,\n availability: isProductInStock(variants)\n ? 'https://schema.org/InStock'\n : 'https://schema.org/OutOfStock',\n ...(firstVariant.sku ? { sku: firstVariant.sku } : {}),\n }\n }\n\n const images = (product.images ?? []).map(resolveMediaUrl).filter((url): url is string => !!url)\n\n const schema: Record<string, unknown> = {\n '@context': 'https://schema.org',\n '@type': 'Product',\n name: product.name,\n }\n\n if (product.description) schema.description = product.description\n if (images.length) schema.image = images\n if (offerBlock) schema.offers = offerBlock\n\n return [schema]\n}\n","import type { NestedCategory, Product, ProductsCollection } from '@zenky/storefront-api'\n\nimport { resolveMediaUrl } from './utils'\nimport type { BreadcrumbItem } from './types'\n\n/**\n * JSON-LD for a product listing page: BreadcrumbList + ItemList (first 10 products).\n * Returns an array of 0-2 JSON-LD objects. Category and collection pages differ only\n * in the list name, so both go through here.\n * Spec: https://schema.org/ItemList · https://schema.org/BreadcrumbList\n */\nfunction buildListingSchemas(\n name: string | null,\n products: Product[],\n breadcrumbs: BreadcrumbItem[],\n origin: string\n): Record<string, unknown>[] {\n const schemas: Record<string, unknown>[] = []\n\n if (breadcrumbs.length) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'BreadcrumbList',\n itemListElement: breadcrumbs.map((crumb, index) => ({\n '@type': 'ListItem',\n position: index + 1,\n name: crumb.label,\n ...(crumb.to ? { item: `${origin}${crumb.to}` } : {}),\n })),\n })\n }\n\n const items = products.slice(0, 10)\n if (items.length) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'ItemList',\n name,\n numberOfItems: items.length,\n itemListElement: items.map((product, index) => {\n const url = `${origin}/products/${product.short_id}/${product.slug || product.short_id}`\n const firstImage = product.images?.[0]\n const image = firstImage ? resolveMediaUrl(firstImage) : null\n\n const item: Record<string, unknown> = {\n '@type': 'ListItem',\n position: index + 1,\n url,\n name: product.name,\n }\n\n if (image) item.image = image\n\n return item\n }),\n })\n }\n\n return schemas\n}\n\n/** JSON-LD for a category page. */\nexport function buildCategorySchemas(\n category: NestedCategory,\n products: Product[],\n breadcrumbs: BreadcrumbItem[],\n origin: string\n): Record<string, unknown>[] {\n return buildListingSchemas(category.name, products, breadcrumbs, origin)\n}\n\n/** JSON-LD for a products collection page. */\nexport function buildCollectionSchemas(\n collection: ProductsCollection,\n products: Product[],\n breadcrumbs: BreadcrumbItem[],\n origin: string\n): Record<string, unknown>[] {\n return buildListingSchemas(collection.name, products, breadcrumbs, origin)\n}\n","import type { Article, Media, OfferArticle } from '@zenky/storefront-api'\n\nimport { prepareOgDescription, resolveMediaUrl } from './utils'\n\nfunction articleSchema(\n type: 'Article' | 'BlogPosting',\n opts: {\n title: string | null | undefined\n intro: string | null | undefined\n cover: Media | null | undefined\n storeName: string\n origin: string\n }\n): Record<string, unknown> {\n const schema: Record<string, unknown> = {\n '@context': 'https://schema.org',\n '@type': type,\n headline: opts.title ?? '',\n author: {\n '@type': 'Organization',\n name: opts.storeName,\n url: opts.origin,\n },\n }\n\n const description = prepareOgDescription(opts.intro)\n if (description) schema.description = description\n\n const image = opts.cover ? resolveMediaUrl(opts.cover) : null\n if (image) schema.image = image\n\n return schema\n}\n\n/**\n * JSON-LD schema.org/Article for the offer page's editorial copy.\n * Spec: https://schema.org/Article\n */\nexport function buildOfferArticleSchema(\n article: OfferArticle,\n storeName: string,\n origin: string\n): Record<string, unknown>[] {\n if (!article.title) return []\n\n return [\n articleSchema('Article', {\n title: article.title,\n intro: article.intro,\n cover: article.cover,\n storeName,\n origin,\n }),\n ]\n}\n\n/**\n * JSON-LD schema.org/BlogPosting for a blog article — enables Google Rich Results.\n * Spec: https://schema.org/BlogPosting\n */\nexport function buildBlogPostSchema(\n article: Article,\n storeName: string,\n origin: string\n): Record<string, unknown>[] {\n const schema = articleSchema('BlogPosting', {\n title: article.title,\n intro: article.intro,\n cover: article.cover,\n storeName,\n origin,\n })\n\n if (article.updated_at) {\n schema.dateModified = article.updated_at\n // No separate datePublished field is available — reuse updated_at.\n schema.datePublished = article.updated_at\n }\n\n return [schema]\n}\n","import { ContactType } from '@zenky/storefront-api'\n\nimport type { Schedule, Store } from '@zenky/storefront-api'\n\nimport { getSocialLinks } from '../utils'\n\n/** Schedule.days key → schema.org DayOfWeek. */\nconst SCHEMA_DAY: Record<string, string> = {\n monday: 'Monday',\n tuesday: 'Tuesday',\n wednesday: 'Wednesday',\n thursday: 'Thursday',\n friday: 'Friday',\n saturday: 'Saturday',\n sunday: 'Sunday',\n}\n\n/**\n * Schedule (per-day `hours` string like \"10:00-22:00\") → array of schema.org/OpeningHoursSpecification.\n * Days without a recognizable interval (day off / 24 hours / empty) are skipped.\n */\nfunction buildOpeningHours(schedule: Schedule | null | undefined): Record<string, unknown>[] {\n if (!schedule) return []\n\n const result: Record<string, unknown>[] = []\n for (const key of Object.keys(SCHEMA_DAY)) {\n const day = schedule.days[key as keyof typeof schedule.days]\n const match = day?.hours?.match(/(\\d{1,2}:\\d{2}).*?(\\d{1,2}:\\d{2})/)\n if (!match) continue\n\n result.push({\n '@type': 'OpeningHoursSpecification',\n dayOfWeek: SCHEMA_DAY[key],\n opens: match[1],\n closes: match[2],\n })\n }\n\n return result\n}\n\n/**\n * JSON-LD schema.org/Organization (or LocalBusiness if there's a physical location)\n * for the homepage. Feeds Google's Knowledge Panel. All data comes from the\n * already-loaded profile.\n * Spec: https://schema.org/Organization · https://schema.org/LocalBusiness\n */\nexport function buildOrganizationSchema(store: Store, origin: string): Record<string, unknown>[] {\n const logoUrl =\n store.square_logo?.medium?.url ||\n store.square_logo?.large?.url ||\n store.logo?.medium?.url ||\n store.logo?.large?.url ||\n null\n\n const phones = (store.phones ?? []).map((p) => p.number).filter((n): n is string => !!n)\n const email = store.links?.find((c) => c.type === ContactType.Email)?.value ?? null\n const socialLinks = getSocialLinks(store.links ?? []).map((l) => l.url)\n\n const city = (store.cities ?? []).find((c) => c.is_default) ?? store.cities?.[0] ?? null\n const stock = city?.stocks?.find((st) => st.address) ?? city?.stocks?.[0] ?? null\n\n const streetAddress = stock?.address ?? null\n const geo = stock?.coordinates ?? city?.coordinates ?? null\n const openingHours = buildOpeningHours(stock?.schedule ?? city?.schedule)\n\n const isLocalBusiness = Boolean(streetAddress || geo || openingHours.length)\n\n const schema: Record<string, unknown> = {\n '@context': 'https://schema.org',\n '@type': isLocalBusiness ? 'LocalBusiness' : 'Organization',\n name: store.name,\n url: origin,\n }\n\n if (logoUrl) {\n schema.logo = logoUrl\n schema.image = logoUrl\n }\n\n if (phones.length) schema.telephone = phones.length === 1 ? phones[0] : phones\n if (email) schema.email = email\n if (socialLinks.length) schema.sameAs = socialLinks\n\n if (streetAddress || city?.name) {\n schema.address = {\n '@type': 'PostalAddress',\n ...(streetAddress ? { streetAddress } : {}),\n ...(city?.name ? { addressLocality: city.name } : {}),\n addressCountry: 'RU',\n }\n }\n\n if (geo) {\n schema.geo = {\n '@type': 'GeoCoordinates',\n latitude: geo.latitude,\n longitude: geo.longitude,\n }\n }\n\n if (openingHours.length) schema.openingHoursSpecification = openingHours\n\n return [schema]\n}\n","/** Already-resolved OG/Twitter tag values (with the consumer's defaults applied). */\nexport interface OgTagsInput {\n title: string | null\n description?: string | null\n image?: string | null\n type?: string\n url?: string | null\n}\n\n/** Framework-neutral OG + Twitter meta records. The consumer controls head priority. */\nexport function buildOgTags(input: OgTagsInput): Record<string, string>[] {\n const tags: Record<string, string>[] = []\n\n if (input.title) {\n tags.push({ property: 'og:title', content: input.title })\n tags.push({ name: 'twitter:title', content: input.title })\n }\n\n if (input.description) {\n tags.push({ property: 'og:description', content: input.description })\n tags.push({ name: 'twitter:description', content: input.description })\n }\n\n if (input.image) {\n tags.push({ property: 'og:image', content: input.image })\n tags.push({ name: 'twitter:image', content: input.image })\n }\n\n tags.push({ property: 'og:type', content: input.type ?? 'website' })\n\n if (input.url) {\n tags.push({ property: 'og:url', content: input.url })\n }\n\n return tags\n}\n","import type { Seo, SeoMetaTag } from '@zenky/storefront-api'\n\n/** SDK `Seo.meta` tags mapped to framework-neutral head meta records. */\nexport function mapSeoMetaTags(tags: SeoMetaTag[]): Record<string, string>[] {\n return tags.map((tag) => {\n const attrs: Record<string, string> = {\n [tag.name.attribute]: tag.name.value,\n [tag.value.attribute]: tag.value.value,\n }\n\n for (const additional of tag.additional) {\n attrs[additional.attribute] = additional.value\n }\n\n return attrs\n })\n}\n\n/** Meta tags from a `Seo` entity (description + `Seo.meta` mapping). The consumer resolves the title. */\nexport function buildEntitySeoMeta(seo: Seo | null | undefined): Record<string, string>[] {\n const tags: Record<string, string>[] = []\n\n if (seo?.description) {\n tags.push({ name: 'description', content: seo.description })\n }\n\n if (seo?.meta?.length) {\n tags.push(...mapSeoMetaTags(seo.meta))\n }\n\n return tags\n}\n"]}
|
package/dist/stores/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { S as StaticCatalogItem } from '../catalogEntity-DgrPsJpf.js';
|
|
|
5
5
|
import * as _zenky_storefront_api from '@zenky/storefront-api';
|
|
6
6
|
import { Product, Store, City, Stock, NestedCategory, DeliveryMethod, Order, OrderDeliveryMethod, OrderSettings, OrderCheckoutTotal, PaymentMethod, OrderPaymentTransaction, OrderProductVariant, OrderPaymentMethod } from '@zenky/storefront-api';
|
|
7
7
|
import { Website } from '../website-settings/index.js';
|
|
8
|
+
import { a as AuthStep, f as CodeContext, g as ConfirmationChannel, e as ChannelIntent, S as SelectableConfirmationChannel } from '../types-CXm2F6Hz.js';
|
|
9
|
+
import { R as RecaptchaPayloadProvider } from '../useCheckoutSubmit-C934F26-.js';
|
|
8
10
|
import '@zenky/integrations-sdk';
|
|
9
11
|
import '../snippets/index.js';
|
|
10
12
|
|
|
@@ -57,6 +59,59 @@ interface AuthStore {
|
|
|
57
59
|
}
|
|
58
60
|
declare const useAuthStore: pinia.StoreDefinition<"zenky-auth", Pick<AuthStore, "token" | "phone" | "countryCode">, Pick<AuthStore, "isAuthenticated" | "apiToken" | "initials">, Pick<AuthStore, "setToken" | "clearToken" | "initFromCookie">>;
|
|
59
61
|
|
|
62
|
+
declare const RESEND_TIMER_SECONDS = 60;
|
|
63
|
+
|
|
64
|
+
interface AuthFlowStore {
|
|
65
|
+
currentStep: Ref<AuthStep>;
|
|
66
|
+
phone: Ref<string>;
|
|
67
|
+
countryCode: Ref<string>;
|
|
68
|
+
loading: Ref<boolean>;
|
|
69
|
+
error: Ref<string | null>;
|
|
70
|
+
fieldErrors: Ref<Record<string, string[]>>;
|
|
71
|
+
codeContext: Ref<CodeContext>;
|
|
72
|
+
confirmationMethod: Ref<ConfirmationChannel | null>;
|
|
73
|
+
/** Какой flow привёл на AUTH_STEP.Channel — публичное, часть $state (SSR-гидратируется). */
|
|
74
|
+
channelIntent: Ref<ChannelIntent | null>;
|
|
75
|
+
/**
|
|
76
|
+
* Канал, на котором последний раз получили `auth.otp_request.failed`. UI может
|
|
77
|
+
* скрыть/задизейблить эту кнопку на повторном показе Channel — бэк уже отказал,
|
|
78
|
+
* выбор того же канала снова даст ту же ошибку.
|
|
79
|
+
*/
|
|
80
|
+
lastFailedChannel: Ref<SelectableConfirmationChannel | null>;
|
|
81
|
+
resetCode: Ref<string>;
|
|
82
|
+
registerCode: Ref<string>;
|
|
83
|
+
resendTimerEndsAt: Ref<number>;
|
|
84
|
+
pendingPassword: Ref<string>;
|
|
85
|
+
availableChannels: ComputedRef<SelectableConfirmationChannel[]>;
|
|
86
|
+
checkPhone: (getRecaptchaPayload: RecaptchaPayloadProvider) => Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* @returns true — токен получен, флоу завершён. false — либо ошибка (см. `error`),
|
|
89
|
+
* либо телефон зарегистрирован, но не подтверждён: код уже отправлен и `currentStep`
|
|
90
|
+
* ушёл на Code/Channel — в этом случае `error` пустой, это не сбой.
|
|
91
|
+
*/
|
|
92
|
+
login: (password: string, getRecaptchaPayload: RecaptchaPayloadProvider) => Promise<boolean>;
|
|
93
|
+
/** @returns true — токен получен (сразу или через login-fallback при 0 каналах), false — код отправлен / ошибка / шаг выбора канала */
|
|
94
|
+
register: (password: string, getRecaptchaPayload: RecaptchaPayloadProvider) => Promise<boolean>;
|
|
95
|
+
confirmRegistration: (code: string, password?: string) => Promise<boolean>;
|
|
96
|
+
resendCode: (getRecaptchaPayload: RecaptchaPayloadProvider) => Promise<number>;
|
|
97
|
+
dispatchReset: (getRecaptchaPayload: RecaptchaPayloadProvider) => Promise<void>;
|
|
98
|
+
resetPassword: (code: string, password: string) => Promise<boolean>;
|
|
99
|
+
selectChannel: (channel: SelectableConfirmationChannel, getRecaptchaPayload: RecaptchaPayloadProvider) => Promise<boolean>;
|
|
100
|
+
/** Сбрасывает выбранный канал перед ручным resend — иначе гейт сработает только один раз. */
|
|
101
|
+
changeChannel: () => void;
|
|
102
|
+
goToChannelBack: () => void;
|
|
103
|
+
goToReset: () => void;
|
|
104
|
+
goToPhone: () => void;
|
|
105
|
+
goToMethod: () => void;
|
|
106
|
+
goToLogin: () => void;
|
|
107
|
+
goToNewPassword: (code: string) => void;
|
|
108
|
+
goToResetCode: () => void;
|
|
109
|
+
goToRegisterPassword: (code: string) => void;
|
|
110
|
+
goToRegisterCode: () => void;
|
|
111
|
+
reset: () => void;
|
|
112
|
+
}
|
|
113
|
+
declare const useAuthFlowStore: pinia.StoreDefinition<"zenky-auth-flow", Pick<AuthFlowStore, "error" | "phone" | "countryCode" | "loading" | "currentStep" | "fieldErrors" | "codeContext" | "confirmationMethod" | "channelIntent" | "lastFailedChannel" | "resetCode" | "registerCode" | "resendTimerEndsAt" | "pendingPassword">, Pick<AuthFlowStore, "availableChannels">, Pick<AuthFlowStore, "login" | "register" | "reset" | "checkPhone" | "confirmRegistration" | "resendCode" | "dispatchReset" | "resetPassword" | "selectChannel" | "changeChannel" | "goToChannelBack" | "goToReset" | "goToPhone" | "goToMethod" | "goToLogin" | "goToNewPassword" | "goToResetCode" | "goToRegisterPassword" | "goToRegisterCode">>;
|
|
114
|
+
|
|
60
115
|
interface OrderSettingsStore {
|
|
61
116
|
deliveryMethod: Ref<DeliveryMethod>;
|
|
62
117
|
onPremiseTable: Ref<string | null>;
|
|
@@ -194,4 +249,4 @@ declare function useStorefrontProfile(): {
|
|
|
194
249
|
hasStock: vue.ComputedRef<boolean>;
|
|
195
250
|
};
|
|
196
251
|
|
|
197
|
-
export { type AppliedBonusesIntent, type AuthStore, type CartStore, type MinPriceViolation, type OrderSettingsStore, type PromotionsStore, type RewardSelection, type RewardSelectionContext, type StoreProfileStore, useAuthStore, useCartStore, useCatalogStore, useOrderSettingsStore, useProductsStore, usePromotionsStore, useStore, useStoreProfileStore, useStorefrontProfile };
|
|
252
|
+
export { type AppliedBonusesIntent, type AuthFlowStore, type AuthStore, type CartStore, type MinPriceViolation, type OrderSettingsStore, type PromotionsStore, RESEND_TIMER_SECONDS, type RewardSelection, type RewardSelectionContext, type StoreProfileStore, useAuthFlowStore, useAuthStore, useCartStore, useCatalogStore, useOrderSettingsStore, useProductsStore, usePromotionsStore, useStore, useStoreProfileStore, useStorefrontProfile };
|
package/dist/stores/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
export { useProductsStore, useStore, useStorefrontProfile } from '../chunk-
|
|
2
|
-
|
|
1
|
+
export { RESEND_TIMER_SECONDS, useAuthFlowStore, useProductsStore, useStore, useStorefrontProfile } from '../chunk-LUJSF6V7.js';
|
|
2
|
+
import '../chunk-5B2P5W3E.js';
|
|
3
|
+
import '../chunk-TE42OCFK.js';
|
|
4
|
+
export { useCartStore, useOrderSettingsStore, usePromotionsStore } from '../chunk-TE2QPH74.js';
|
|
3
5
|
export { useCatalogStore } from '../chunk-NSOIL7PW.js';
|
|
4
|
-
export { useAuthStore
|
|
6
|
+
export { useAuthStore } from '../chunk-WTZXTBF6.js';
|
|
7
|
+
import '../chunk-TIQ7AJLY.js';
|
|
8
|
+
export { useStoreProfileStore } from '../chunk-IOYYCA75.js';
|
|
5
9
|
//# sourceMappingURL=index.js.map
|
|
6
10
|
//# sourceMappingURL=index.js.map
|