@miguelmorales13/nestkit 0.25.0 → 0.28.0
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/README.md +5 -0
- package/dist/alerts/alert-on-failure.decorator.d.ts +5 -0
- package/dist/alerts/alert-sinks.d.ts +29 -0
- package/dist/alerts/alerts.module.d.ts +19 -0
- package/dist/alerts/alerts.options.d.ts +1 -0
- package/dist/alerts/alerts.service.d.ts +28 -0
- package/dist/alerts/alerts.types.d.ts +66 -0
- package/dist/alerts/index.cjs +276 -0
- package/dist/alerts/index.d.ts +10 -0
- package/dist/alerts/index.js +276 -0
- package/dist/alerts/logger-with-alerts.d.ts +18 -0
- package/dist/alerts/process-guards.d.ts +21 -0
- package/dist/alerts/runtime.d.ts +4 -0
- package/dist/audit/index.cjs +13 -13
- package/dist/audit/index.js +2 -2
- package/dist/auth/index.cjs +21 -21
- package/dist/auth/index.js +3 -3
- package/dist/auth/oauth/index.cjs +123 -115
- package/dist/auth/oauth/index.js +25 -17
- package/dist/auth/oauth/oauth-provider.d.ts +9 -0
- package/dist/auth/oauth/providers/apple.d.ts +3 -1
- package/dist/bootstrap/apply-defaults.d.ts +9 -0
- package/dist/bootstrap/index.cjs +6 -5
- package/dist/bootstrap/index.js +5 -4
- package/dist/chunk-3TUMVLPJ.js +14 -0
- package/dist/{chunk-PA24P76K.js → chunk-45SW7FBE.js} +1 -1
- package/dist/{chunk-RF75KC63.cjs → chunk-47IYXZHW.cjs} +2 -2
- package/dist/{chunk-TUNDBBQF.js → chunk-4WWOKZIO.js} +4 -4
- package/dist/{chunk-A2DGK4ZL.js → chunk-5LVGCTJ3.js} +1 -1
- package/dist/chunk-A6YGIZCQ.cjs +14 -0
- package/dist/chunk-A7FI6HXV.js +40 -0
- package/dist/chunk-CU4FUIVJ.cjs +8 -0
- package/dist/{chunk-FH5UNWWW.cjs → chunk-D35TBVRO.cjs} +4 -4
- package/dist/{chunk-4MGIQFAJ.js → chunk-D3DDJWUD.js} +5 -0
- package/dist/chunk-DVGPEBUL.js +8 -0
- package/dist/{chunk-VKOPDDCC.js → chunk-ENZ7LQRE.js} +1 -1
- package/dist/{chunk-3AUOOEQO.cjs → chunk-F77X4QUN.cjs} +2 -2
- package/dist/chunk-FBNV5X6C.js +61 -0
- package/dist/{chunk-APUFKA4K.cjs → chunk-FDZQCLLK.cjs} +6 -6
- package/dist/{chunk-DYHSOULW.js → chunk-IGSNB5BX.js} +1 -1
- package/dist/chunk-IVWPA6QH.cjs +90 -0
- package/dist/{chunk-MSTXS3MU.cjs → chunk-JJKGQNGD.cjs} +2 -2
- package/dist/{chunk-FNUZGYUF.cjs → chunk-JRFE7NSO.cjs} +12 -4
- package/dist/{chunk-HVHYZXBB.cjs → chunk-KNU5RN3O.cjs} +3 -3
- package/dist/{chunk-52IOOHNX.cjs → chunk-KQPJCVN3.cjs} +26 -26
- package/dist/chunk-LGFHLAY3.cjs +61 -0
- package/dist/{chunk-2REOCMUD.cjs → chunk-LRX7AMSS.cjs} +6 -1
- package/dist/{chunk-4PFAKLT3.js → chunk-MUWHGBIB.js} +1 -1
- package/dist/{chunk-ZJMLEP5H.js → chunk-NJYLQDB3.js} +1 -1
- package/dist/{chunk-IFNYRZP2.js → chunk-OSRH6KYZ.js} +4 -4
- package/dist/{chunk-6RAPVLJM.js → chunk-OTE77ONL.js} +1 -1
- package/dist/chunk-UDACUMLO.cjs +40 -0
- package/dist/{chunk-UNEVXCFW.js → chunk-UGAAJRPO.js} +10 -2
- package/dist/{chunk-SPTDXUED.cjs → chunk-URLDTS2Q.cjs} +2 -2
- package/dist/{chunk-W2T2VFLC.cjs → chunk-VALDHJOO.cjs} +5 -5
- package/dist/chunk-WFCQDOSN.js +90 -0
- package/dist/consent/consent.interceptor.d.ts +20 -0
- package/dist/consent/consent.module.d.ts +25 -0
- package/dist/consent/consent.options.d.ts +30 -0
- package/dist/consent/consent.port.d.ts +17 -0
- package/dist/consent/consent.service.d.ts +44 -0
- package/dist/consent/guard/index.cjs +13 -0
- package/dist/consent/guard/index.d.ts +31 -0
- package/dist/consent/guard/index.js +13 -0
- package/dist/consent/index.cjs +271 -0
- package/dist/consent/index.d.ts +13 -0
- package/dist/consent/index.js +271 -0
- package/dist/consent/memory.store.d.ts +7 -0
- package/dist/consent/shared/index.cjs +11 -0
- package/dist/consent/shared/index.d.ts +19 -0
- package/dist/consent/shared/index.js +11 -0
- package/dist/consent/typeorm.store.d.ts +22 -0
- package/dist/crud/index.cjs +4 -4
- package/dist/crud/index.js +3 -3
- package/dist/database/postgres/index.cjs +3 -3
- package/dist/database/postgres/index.js +2 -2
- package/dist/database/supabase/index.cjs +3 -3
- package/dist/database/supabase/index.js +2 -2
- package/dist/database/typeorm/index.cjs +2 -2
- package/dist/database/typeorm/index.js +1 -1
- package/dist/devices/device-check.interceptor.d.ts +20 -0
- package/dist/devices/devices.module.d.ts +28 -0
- package/dist/devices/devices.options.d.ts +53 -0
- package/dist/devices/devices.port.d.ts +62 -0
- package/dist/devices/devices.service.d.ts +58 -0
- package/dist/devices/index.cjs +327 -0
- package/dist/devices/index.d.ts +8 -0
- package/dist/devices/index.js +327 -0
- package/dist/devices/memory.store.d.ts +12 -0
- package/dist/email/index.cjs +2 -2
- package/dist/email/index.js +1 -1
- package/dist/email/nodemailer/index.cjs +2 -2
- package/dist/email/nodemailer/index.js +1 -1
- package/dist/email/resend/index.cjs +2 -2
- package/dist/email/resend/index.js +1 -1
- package/dist/entities/index.cjs +1 -1
- package/dist/entities/index.js +1 -1
- package/dist/errors/index.cjs +7 -7
- package/dist/errors/index.js +7 -7
- package/dist/events/buses.d.ts +27 -0
- package/dist/events/events.controller.d.ts +15 -0
- package/dist/events/events.module.d.ts +29 -0
- package/dist/events/events.options.d.ts +50 -0
- package/dist/events/events.service.d.ts +49 -0
- package/dist/events/events.types.d.ts +77 -0
- package/dist/events/index.cjs +557 -0
- package/dist/events/index.d.ts +10 -0
- package/dist/events/index.js +557 -0
- package/dist/events/memory-ticket.store.d.ts +9 -0
- package/dist/google-business/google-business-http.d.ts +41 -0
- package/dist/google-business/google-business.errors.d.ts +75 -0
- package/dist/google-business/google-business.mappers.d.ts +52 -0
- package/dist/google-business/google-business.module.d.ts +26 -0
- package/dist/google-business/google-business.options.d.ts +40 -0
- package/dist/google-business/google-business.ports.d.ts +18 -0
- package/dist/google-business/google-business.service.d.ts +120 -0
- package/dist/google-business/google-business.types.d.ts +155 -0
- package/dist/google-business/index.cjs +1025 -0
- package/dist/google-business/index.d.ts +15 -0
- package/dist/google-business/index.js +1025 -0
- package/dist/google-business/testing/google-simulator.d.ts +61 -0
- package/dist/hardening/body-limits.d.ts +24 -0
- package/dist/hardening/http.types.d.ts +26 -0
- package/dist/hardening/index.cjs +179 -0
- package/dist/hardening/index.d.ts +19 -0
- package/dist/hardening/index.js +179 -0
- package/dist/hardening/memory-rate-limit.store.d.ts +10 -0
- package/dist/hardening/origin-secret.d.ts +29 -0
- package/dist/hardening/rate-limit.decorator.d.ts +8 -0
- package/dist/hardening/rate-limit.guard.d.ts +18 -0
- package/dist/hardening/rate-limit.module.d.ts +23 -0
- package/dist/hardening/rate-limit.options.d.ts +35 -0
- package/dist/hardening/rate-limit.port.d.ts +11 -0
- package/dist/hardening/redis-rate-limit.store.d.ts +23 -0
- package/dist/hardening/trust-proxy.d.ts +22 -0
- package/dist/health/health.controller.d.ts +32 -0
- package/dist/health/health.module.d.ts +15 -0
- package/dist/health/health.options.d.ts +24 -0
- package/dist/health/index.cjs +103 -0
- package/dist/health/index.d.ts +5 -0
- package/dist/health/index.js +103 -0
- package/dist/i18n/index.cjs +3 -3
- package/dist/i18n/index.js +2 -2
- package/dist/idempotency/idempotency.interceptor.d.ts +1 -0
- package/dist/idempotency/idempotency.options.d.ts +15 -0
- package/dist/idempotency/index.cjs +214 -7
- package/dist/idempotency/index.d.ts +5 -0
- package/dist/idempotency/index.js +210 -3
- package/dist/idempotency/no-idempotency.decorator.d.ts +8 -0
- package/dist/idempotency/postgres.store.d.ts +49 -0
- package/dist/idempotency/redis.store.d.ts +59 -0
- package/dist/index.cjs +21 -20
- package/dist/index.js +31 -30
- package/dist/invoicing/index.cjs +2 -2
- package/dist/invoicing/index.js +1 -1
- package/dist/jobs/defer-job.d.ts +10 -0
- package/dist/jobs/index.cjs +318 -0
- package/dist/jobs/index.d.ts +8 -0
- package/dist/jobs/index.js +318 -0
- package/dist/jobs/jobs-admin.controller.d.ts +18 -0
- package/dist/jobs/jobs.module.d.ts +33 -0
- package/dist/jobs/jobs.options.d.ts +62 -0
- package/dist/jobs/jobs.service.d.ts +53 -0
- package/dist/jobs/jobs.sql.d.ts +11 -0
- package/dist/media/index.cjs +14 -14
- package/dist/media/index.js +1 -1
- package/dist/meta/index.cjs +3 -3
- package/dist/meta/index.js +1 -1
- package/dist/notifications/index.cjs +375 -0
- package/dist/notifications/index.d.ts +8 -0
- package/dist/notifications/index.js +375 -0
- package/dist/notifications/memory.stores.d.ts +23 -0
- package/dist/notifications/notifications.controller.d.ts +11 -0
- package/dist/notifications/notifications.module.d.ts +31 -0
- package/dist/notifications/notifications.options.d.ts +33 -0
- package/dist/notifications/notifications.port.d.ts +97 -0
- package/dist/notifications/notifier.service.d.ts +31 -0
- package/dist/payments/index.cjs +7 -7
- package/dist/payments/index.js +1 -1
- package/dist/pinterest/index.cjs +3 -3
- package/dist/pinterest/index.js +1 -1
- package/dist/privacy/anonymizer.d.ts +14 -0
- package/dist/privacy/index.cjs +768 -0
- package/dist/privacy/index.d.ts +13 -0
- package/dist/privacy/index.js +768 -0
- package/dist/privacy/memory.store.d.ts +15 -0
- package/dist/privacy/privacy.module.d.ts +30 -0
- package/dist/privacy/privacy.options.d.ts +43 -0
- package/dist/privacy/privacy.port.d.ts +25 -0
- package/dist/privacy/privacy.service.d.ts +69 -0
- package/dist/privacy/privacy.types.d.ts +125 -0
- package/dist/privacy/sql.d.ts +7 -0
- package/dist/privacy/sql.store.d.ts +21 -0
- package/dist/privacy/zip.d.ts +23 -0
- package/dist/push/index.cjs +13 -13
- package/dist/push/index.js +5 -5
- package/dist/resilience/alert-channels.d.ts +39 -0
- package/dist/resilience/alert-errors.interceptor.d.ts +10 -0
- package/dist/resilience/alert-on-failure.decorator.d.ts +10 -0
- package/dist/resilience/alert.service.d.ts +77 -0
- package/dist/resilience/index.cjs +863 -0
- package/dist/resilience/index.d.ts +18 -0
- package/dist/resilience/index.js +863 -0
- package/dist/resilience/memory-alert-store.d.ts +26 -0
- package/dist/resilience/provider-health.controller.d.ts +14 -0
- package/dist/resilience/provider-unavailable.exception.d.ts +11 -0
- package/dist/resilience/resilience.module.d.ts +34 -0
- package/dist/resilience/resilience.options.d.ts +28 -0
- package/dist/resilience/resilience.types.d.ts +167 -0
- package/dist/resilience/resilient-fetch.d.ts +38 -0
- package/dist/resilience/runtime.d.ts +24 -0
- package/dist/resilience/typeorm/alert.entity.d.ts +21 -0
- package/dist/resilience/typeorm/index.cjs +102 -0
- package/dist/resilience/typeorm/index.d.ts +3 -0
- package/dist/resilience/typeorm/index.js +102 -0
- package/dist/resilience/typeorm/typeorm-alert-store.d.ts +39 -0
- package/dist/resilience/validate-destination.d.ts +63 -0
- package/dist/response/index.cjs +3 -3
- package/dist/response/index.js +2 -2
- package/dist/scheduling/cron-lock.service.d.ts +36 -0
- package/dist/scheduling/cron-unico.decorator.d.ts +27 -0
- package/dist/scheduling/fallback.store.d.ts +34 -0
- package/dist/scheduling/index.cjs +392 -0
- package/dist/scheduling/index.d.ts +18 -0
- package/dist/scheduling/index.js +392 -0
- package/dist/scheduling/lock-store.port.d.ts +19 -0
- package/dist/scheduling/memory.store.d.ts +15 -0
- package/dist/scheduling/redis.module.d.ts +31 -0
- package/dist/scheduling/redis.store.d.ts +24 -0
- package/dist/scheduling/scheduling.module.d.ts +24 -0
- package/dist/scheduling/scheduling.options.d.ts +27 -0
- package/dist/scheduling/sql.store.d.ts +26 -0
- package/dist/secrets/index.cjs +274 -0
- package/dist/secrets/index.d.ts +8 -0
- package/dist/secrets/index.js +274 -0
- package/dist/secrets/secrets.errors.d.ts +6 -0
- package/dist/secrets/secrets.module.d.ts +21 -0
- package/dist/secrets/secrets.options.d.ts +32 -0
- package/dist/secrets/secrets.service.d.ts +54 -0
- package/dist/secrets/secrets.transformer.d.ts +33 -0
- package/dist/security/hash.d.ts +8 -0
- package/dist/security/index.cjs +119 -2
- package/dist/security/index.d.ts +5 -0
- package/dist/security/index.js +119 -2
- package/dist/security/mask.d.ts +22 -0
- package/dist/security/signed-grant.d.ts +30 -0
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.js +1 -1
- package/dist/stripe/index.cjs +7 -7
- package/dist/stripe/index.js +1 -1
- package/dist/telegram/index.cjs +2 -2
- package/dist/telegram/index.js +1 -1
- package/dist/tenancy/app-role.d.ts +24 -0
- package/dist/tenancy/db-helpers.d.ts +12 -0
- package/dist/tenancy/index.cjs +205 -0
- package/dist/tenancy/index.d.ts +14 -0
- package/dist/tenancy/index.js +205 -0
- package/dist/tenancy/pg/index.cjs +34 -0
- package/dist/tenancy/pg/index.d.ts +2 -0
- package/dist/tenancy/pg/index.js +34 -0
- package/dist/tenancy/pg/with-tenant.d.ts +23 -0
- package/dist/tenancy/request-context.d.ts +18 -0
- package/dist/tenancy/rls-guardrail.d.ts +38 -0
- package/dist/tenancy/scope.d.ts +5 -0
- package/dist/tenancy/tenancy.errors.d.ts +5 -0
- package/dist/tenancy/tenancy.middleware.d.ts +8 -0
- package/dist/tenancy/tenancy.module.d.ts +37 -0
- package/dist/tenancy/tenancy.options.d.ts +34 -0
- package/dist/tenancy/typeorm/index.cjs +41 -0
- package/dist/tenancy/typeorm/index.d.ts +2 -0
- package/dist/tenancy/typeorm/index.js +41 -0
- package/dist/tenancy/typeorm/with-tenant.d.ts +23 -0
- package/dist/tiktok/index.cjs +3 -3
- package/dist/tiktok/index.js +1 -1
- package/dist/tracking/index.cjs +3 -3
- package/dist/tracking/index.js +2 -2
- package/dist/umami/index.cjs +4 -4
- package/dist/umami/index.js +1 -1
- package/dist/whatsapp/index.cjs +2 -2
- package/dist/whatsapp/index.js +1 -1
- package/package.json +107 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { EstadoVerificacion, ExcepcionHorario, HorarioRegular, MetodoVerificacion, PerfilNegocio, ResenaGoogle, UbicacionGoogle } from './google-business.types.js';
|
|
2
|
+
interface TimeOfDay {
|
|
3
|
+
hours: number;
|
|
4
|
+
minutes?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseHora(hhmm: string): TimeOfDay;
|
|
7
|
+
export declare function horarioAGoogle(horario: HorarioRegular): {
|
|
8
|
+
periods: unknown[];
|
|
9
|
+
};
|
|
10
|
+
export declare function excepcionesAGoogle(excepciones: ExcepcionHorario[]): {
|
|
11
|
+
specialHourPeriods: unknown[];
|
|
12
|
+
};
|
|
13
|
+
/** Body of `locations.create` (business information v1) from a generic profile. */
|
|
14
|
+
export declare function perfilALocation(perfil: PerfilNegocio): Record<string, unknown>;
|
|
15
|
+
interface GLocation {
|
|
16
|
+
name?: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
websiteUri?: string;
|
|
19
|
+
phoneNumbers?: {
|
|
20
|
+
primaryPhone?: string;
|
|
21
|
+
};
|
|
22
|
+
storefrontAddress?: {
|
|
23
|
+
addressLines?: string[];
|
|
24
|
+
locality?: string;
|
|
25
|
+
administrativeArea?: string;
|
|
26
|
+
postalCode?: string;
|
|
27
|
+
};
|
|
28
|
+
metadata?: {
|
|
29
|
+
placeId?: string;
|
|
30
|
+
mapsUri?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export declare function locationAUbicacion(l: GLocation): UbicacionGoogle;
|
|
34
|
+
export declare const metodoAGoogle: (m: MetodoVerificacion) => string;
|
|
35
|
+
export declare function metodoDeGoogle(m: string | undefined): MetodoVerificacion | undefined;
|
|
36
|
+
export declare function estadoDeGoogle(s: string | undefined): EstadoVerificacion;
|
|
37
|
+
interface GReview {
|
|
38
|
+
name?: string;
|
|
39
|
+
reviewId?: string;
|
|
40
|
+
reviewer?: {
|
|
41
|
+
displayName?: string;
|
|
42
|
+
};
|
|
43
|
+
starRating?: string;
|
|
44
|
+
comment?: string;
|
|
45
|
+
createTime?: string;
|
|
46
|
+
reviewReply?: {
|
|
47
|
+
comment?: string;
|
|
48
|
+
updateTime?: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export declare function reviewAResena(r: GReview): ResenaGoogle;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ClassProvider, type DynamicModule, type ExistingProvider, type FactoryProvider, type ModuleMetadata, type ValueProvider } from '@nestjs/common';
|
|
2
|
+
import { type GoogleBusinessOptions } from './google-business.options.js';
|
|
3
|
+
/** How the host provides its `GoogleBusinessTokenStore` (the `provide` token is filled in here). */
|
|
4
|
+
export type TokenStoreProvider = Omit<ClassProvider, 'provide'> | Omit<ValueProvider, 'provide'> | Omit<ExistingProvider, 'provide'> | Omit<FactoryProvider, 'provide'>;
|
|
5
|
+
export interface GoogleBusinessModuleOptions {
|
|
6
|
+
options: GoogleBusinessOptions;
|
|
7
|
+
/** Defaults to the in-memory store (tests / local only). */
|
|
8
|
+
tokenStore?: TokenStoreProvider;
|
|
9
|
+
imports?: ModuleMetadata['imports'];
|
|
10
|
+
global?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface GoogleBusinessModuleAsyncOptions {
|
|
13
|
+
imports?: ModuleMetadata['imports'];
|
|
14
|
+
inject?: FactoryProvider['inject'];
|
|
15
|
+
useFactory: (...args: any[]) => GoogleBusinessOptions | Promise<GoogleBusinessOptions>;
|
|
16
|
+
tokenStore?: TokenStoreProvider;
|
|
17
|
+
global?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Google Business Profile. Brings no controller: the host owns its routes
|
|
21
|
+
* (connect, callback, locations, reviews…) and calls `GoogleBusinessService`.
|
|
22
|
+
*/
|
|
23
|
+
export declare class GoogleBusinessModule {
|
|
24
|
+
static forRoot(config: GoogleBusinessModuleOptions): DynamicModule;
|
|
25
|
+
static forRootAsync(config: GoogleBusinessModuleAsyncOptions): DynamicModule;
|
|
26
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Minimal fetch shape (the global `fetch` and any resilient wrapper satisfy it). */
|
|
2
|
+
export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
3
|
+
export declare const GOOGLE_BUSINESS_OPTIONS: unique symbol;
|
|
4
|
+
export declare const GOOGLE_BUSINESS_TOKEN_STORE: unique symbol;
|
|
5
|
+
export declare const GOOGLE_BUSINESS_SCOPE = "https://www.googleapis.com/auth/business.manage";
|
|
6
|
+
/** Base URLs, overridable so a test (or a proxy) can point somewhere else. */
|
|
7
|
+
export interface GoogleBusinessUrls {
|
|
8
|
+
authorize: string;
|
|
9
|
+
token: string;
|
|
10
|
+
/** mybusinessaccountmanagement v1 */
|
|
11
|
+
accountManagement: string;
|
|
12
|
+
/** mybusinessbusinessinformation v1 */
|
|
13
|
+
businessInformation: string;
|
|
14
|
+
/** mybusinessverifications v1 */
|
|
15
|
+
verifications: string;
|
|
16
|
+
/** mybusiness v4 (posts, reviews, media) */
|
|
17
|
+
v4: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT_GOOGLE_BUSINESS_URLS: GoogleBusinessUrls;
|
|
20
|
+
export interface GoogleBusinessOptions {
|
|
21
|
+
clientId: string;
|
|
22
|
+
clientSecret: string;
|
|
23
|
+
redirectUri: string;
|
|
24
|
+
/** HMAC key (>= 32 chars) that signs the OAuth `state`. */
|
|
25
|
+
stateSecret: string;
|
|
26
|
+
/** Lifetime of the consent `state`. Default 600. */
|
|
27
|
+
stateTtlSeconds?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Inject the host's resilient fetch (timeouts, alerts…). Default: global `fetch`.
|
|
30
|
+
* It receives absolute URLs and a standard `RequestInit`.
|
|
31
|
+
*/
|
|
32
|
+
fetchImpl?: FetchLike;
|
|
33
|
+
/** Retries for idempotent calls on network errors / 5xx. Default 2. */
|
|
34
|
+
maxRetries?: number;
|
|
35
|
+
/** Base backoff in ms (doubles each retry). Default 300. */
|
|
36
|
+
retryDelayMs?: number;
|
|
37
|
+
/** Clock, for tests. */
|
|
38
|
+
now?: () => Date;
|
|
39
|
+
urls?: Partial<GoogleBusinessUrls>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GoogleTokens } from './google-business.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Where the host keeps Google tokens, one set per `ownerId` (a user, a shop,
|
|
4
|
+
* a tenant — whatever it connects Google for). The host implements it over
|
|
5
|
+
* its own database and SHOULD encrypt `refreshToken` at rest.
|
|
6
|
+
*/
|
|
7
|
+
export interface GoogleBusinessTokenStore {
|
|
8
|
+
save(ownerId: string, tokens: GoogleTokens): Promise<void>;
|
|
9
|
+
get(ownerId: string): Promise<GoogleTokens | null>;
|
|
10
|
+
delete(ownerId: string): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
/** In-memory store for tests and local use. Lost on restart. */
|
|
13
|
+
export declare class MemoryGoogleBusinessTokenStore implements GoogleBusinessTokenStore {
|
|
14
|
+
private readonly tokens;
|
|
15
|
+
save(ownerId: string, tokens: GoogleTokens): Promise<void>;
|
|
16
|
+
get(ownerId: string): Promise<GoogleTokens | null>;
|
|
17
|
+
delete(ownerId: string): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type GoogleBusinessOptions } from './google-business.options.js';
|
|
2
|
+
import type { GoogleBusinessTokenStore } from './google-business.ports.js';
|
|
3
|
+
import type { CuentaGoogle, DatosVerificar, EstadoVerificacionNegocio, ExcepcionHorario, HorarioRegular, OpcionVerificacion, PaginaResenas, PerfilNegocio, PublicacionGoogle, PublicacionInput, ResenaGoogle, ResultadoVincular, UbicacionGoogle } from './google-business.types.js';
|
|
4
|
+
export interface CoincidenciaGoogle {
|
|
5
|
+
/** `googleLocations/ID` */
|
|
6
|
+
name: string;
|
|
7
|
+
titulo: string;
|
|
8
|
+
placeId?: string;
|
|
9
|
+
/** Where the user can ask the current owner for admin rights. */
|
|
10
|
+
urlSolicitarAdmin?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Google Business Profile, host-agnostic. Every method takes the `ownerId`
|
|
14
|
+
* the tokens are stored under; the access token is refreshed transparently.
|
|
15
|
+
*
|
|
16
|
+
* Endpoint used by each method (REST):
|
|
17
|
+
* - consentUrl / exchangeCode / refresh ........ accounts.google.com/o/oauth2/v2/auth · oauth2.googleapis.com/token
|
|
18
|
+
* - listAccounts ............................... mybusinessaccountmanagement v1 GET /accounts
|
|
19
|
+
* - listLocations / getLocation ................ mybusinessbusinessinformation v1 GET /{account}/locations · /{location}
|
|
20
|
+
* - createLocation ............................. mybusinessbusinessinformation v1 POST /{account}/locations?requestId&validateOnly
|
|
21
|
+
* (photos) ................................... mybusiness v4 POST /{account}/{location}/media
|
|
22
|
+
* - buscarCoincidencias ........................ mybusinessbusinessinformation v1 POST /googleLocations:search
|
|
23
|
+
* - vincularExistente / claim .................. business information v1 (GET location / list / search / create)
|
|
24
|
+
* - updateHours ................................ mybusinessbusinessinformation v1 PATCH /{location}?updateMask=regularHours,specialHours
|
|
25
|
+
* - fetchVerificationOptions ................... mybusinessverifications v1 POST /{location}:fetchVerificationOptions
|
|
26
|
+
* - verify / completeVerification .............. mybusinessverifications v1 POST /{location}:verify · /{verification}:complete
|
|
27
|
+
* - getVerificationState ....................... mybusinessverifications v1 GET /{location}/verifications · /{location}/VoiceOfMerchantState
|
|
28
|
+
* - createPost ................................. mybusiness v4 POST /{account}/{location}/localPosts
|
|
29
|
+
* - listReviews / replyToReview ................ mybusiness v4 GET /{account}/{location}/reviews · PUT /{review}/reply
|
|
30
|
+
*/
|
|
31
|
+
export declare class GoogleBusinessService {
|
|
32
|
+
private readonly options;
|
|
33
|
+
private readonly store;
|
|
34
|
+
private readonly http;
|
|
35
|
+
private readonly urls;
|
|
36
|
+
private readonly now;
|
|
37
|
+
constructor(options: GoogleBusinessOptions, store: GoogleBusinessTokenStore);
|
|
38
|
+
/** Consent URL. The signed `state` carries `ownerId` so the callback needs no session. */
|
|
39
|
+
consentUrl(ownerId: string, extra?: {
|
|
40
|
+
returnTo?: string;
|
|
41
|
+
}): {
|
|
42
|
+
url: string;
|
|
43
|
+
state: string;
|
|
44
|
+
expiresAt: Date;
|
|
45
|
+
};
|
|
46
|
+
/** Validates signature and expiry; throws `ESTADO_INVALIDO` otherwise. */
|
|
47
|
+
verifyState(state: string): {
|
|
48
|
+
ownerId: string;
|
|
49
|
+
returnTo?: string;
|
|
50
|
+
};
|
|
51
|
+
/** Callback step: verifies `state`, trades `code` for tokens and stores them. */
|
|
52
|
+
exchangeCode(code: string, state: string): Promise<{
|
|
53
|
+
ownerId: string;
|
|
54
|
+
returnTo?: string;
|
|
55
|
+
}>;
|
|
56
|
+
isConnected(ownerId: string): Promise<boolean>;
|
|
57
|
+
/** Forgets the tokens. */
|
|
58
|
+
disconnect(ownerId: string): Promise<void>;
|
|
59
|
+
/** A valid access token, refreshing 60 s before expiry. */
|
|
60
|
+
getAccessToken(ownerId: string): Promise<string>;
|
|
61
|
+
private refresh;
|
|
62
|
+
/** Runs `fn` with a token; one forced refresh + retry if Google answers 401 mid-flight. */
|
|
63
|
+
private call;
|
|
64
|
+
private api;
|
|
65
|
+
/** mybusinessaccountmanagement v1 `accounts.list`. */
|
|
66
|
+
listAccounts(ownerId: string): Promise<CuentaGoogle[]>;
|
|
67
|
+
/** business information v1 `accounts.locations.list`. */
|
|
68
|
+
listLocations(ownerId: string, accountName: string): Promise<UbicacionGoogle[]>;
|
|
69
|
+
/** business information v1 `locations.get`. */
|
|
70
|
+
getLocation(ownerId: string, locationName: string): Promise<UbicacionGoogle>;
|
|
71
|
+
/**
|
|
72
|
+
* business information v1 `accounts.locations.create`. `requestId` makes the
|
|
73
|
+
* POST idempotent on Google's side, so it is the one POST that retries.
|
|
74
|
+
* Throws `DUPLICADO` (with `details.coincidencias`) when Google already has it.
|
|
75
|
+
*/
|
|
76
|
+
createLocation(ownerId: string, accountName: string, perfil: PerfilNegocio, opts?: {
|
|
77
|
+
requestId?: string;
|
|
78
|
+
validateOnly?: boolean;
|
|
79
|
+
}): Promise<UbicacionGoogle>;
|
|
80
|
+
/** mybusiness v4 `media.create` by URL (Google fetches it). */
|
|
81
|
+
addPhoto(ownerId: string, accountName: string, locationName: string, url: string, categoria?: string): Promise<void>;
|
|
82
|
+
/** business information v1 `googleLocations.search`: places Google already knows that look like this profile. */
|
|
83
|
+
buscarCoincidencias(ownerId: string, perfil: PerfilNegocio): Promise<CoincidenciaGoogle[]>;
|
|
84
|
+
/** Links a location the account already manages (checks it is reachable with these credentials). */
|
|
85
|
+
vincularExistente(ownerId: string, locationName: string): Promise<ResultadoVincular>;
|
|
86
|
+
/**
|
|
87
|
+
* "Make this business mine": reuses a location of the account that matches
|
|
88
|
+
* (same title and phone/website), else creates it. If Google says it exists
|
|
89
|
+
* elsewhere the `DUPLICADO` error lists `coincidencias` with the URL to
|
|
90
|
+
* request admin rights — Google offers no API to take over someone's listing.
|
|
91
|
+
*/
|
|
92
|
+
claim(ownerId: string, accountName: string, perfil: PerfilNegocio): Promise<ResultadoVincular>;
|
|
93
|
+
/** business information v1 `locations.patch` with `updateMask=regularHours[,specialHours]`. */
|
|
94
|
+
updateHours(ownerId: string, locationName: string, horario: HorarioRegular, excepciones?: ExcepcionHorario[]): Promise<void>;
|
|
95
|
+
/** verifications v1 `locations.fetchVerificationOptions`. Empty list or `NO_VERIFICABLE` when Google offers none. */
|
|
96
|
+
fetchVerificationOptions(ownerId: string, locationName: string, idioma?: string): Promise<OpcionVerificacion[]>;
|
|
97
|
+
/** verifications v1 `locations.verify`. Returns the state right after starting. */
|
|
98
|
+
verify(ownerId: string, locationName: string, datos: DatosVerificar): Promise<EstadoVerificacionNegocio>;
|
|
99
|
+
/** verifications v1 `locations.verifications.complete` with the PIN the owner received. */
|
|
100
|
+
completeVerification(ownerId: string, verificacion: string, pin: string): Promise<EstadoVerificacionNegocio>;
|
|
101
|
+
/** verifications v1 `locations.verifications.list` + `locations.getVoiceOfMerchantState`. */
|
|
102
|
+
getVerificationState(ownerId: string, locationName: string): Promise<EstadoVerificacionNegocio>;
|
|
103
|
+
/** mybusiness v4 `accounts.locations.localPosts.create` (STANDARD = novedad, OFFER = oferta). */
|
|
104
|
+
createPost(ownerId: string, accountName: string, locationName: string, input: PublicacionInput): Promise<PublicacionGoogle>;
|
|
105
|
+
/** mybusiness v4 `accounts.locations.reviews.list`. */
|
|
106
|
+
listReviews(ownerId: string, accountName: string, locationName: string, opts?: {
|
|
107
|
+
pageSize?: number;
|
|
108
|
+
pageToken?: string;
|
|
109
|
+
orden?: 'recientes' | 'antiguas';
|
|
110
|
+
}): Promise<PaginaResenas>;
|
|
111
|
+
/** mybusiness v4 `accounts.locations.reviews.updateReply` (PUT is idempotent: replying again replaces). */
|
|
112
|
+
replyToReview(ownerId: string, reviewName: string, comentario: string): Promise<ResenaGoogle['respuesta']>;
|
|
113
|
+
private toTokens;
|
|
114
|
+
private mac;
|
|
115
|
+
private signState;
|
|
116
|
+
}
|
|
117
|
+
/** `123` | `accounts/123` -> `accounts/123`. */
|
|
118
|
+
export declare function accountPath(name: string): string;
|
|
119
|
+
/** `456` | `locations/456` | `accounts/1/locations/456` -> `locations/456`. */
|
|
120
|
+
export declare function locationPath(name: string): string;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/** Generic business profile the host maps its own entity into. No host vocabulary here. */
|
|
2
|
+
export type DiaSemana = 'lunes' | 'martes' | 'miercoles' | 'jueves' | 'viernes' | 'sabado' | 'domingo';
|
|
3
|
+
/** A time range in 24h `HH:MM`. `cierra` earlier than `abre` means past midnight; `24:00` is allowed. */
|
|
4
|
+
export interface Tramo {
|
|
5
|
+
abre: string;
|
|
6
|
+
cierra: string;
|
|
7
|
+
}
|
|
8
|
+
/** Days missing from the map are closed. Several tramos in a day express gaps (e.g. a lunch break). */
|
|
9
|
+
export type HorarioRegular = Partial<Record<DiaSemana, Tramo[]>>;
|
|
10
|
+
export interface ExcepcionHorario {
|
|
11
|
+
/** `YYYY-MM-DD`. */
|
|
12
|
+
fecha: string;
|
|
13
|
+
/** Closed all day (ignores `tramos`). */
|
|
14
|
+
cerrado?: boolean;
|
|
15
|
+
tramos?: Tramo[];
|
|
16
|
+
}
|
|
17
|
+
export interface DireccionNegocio {
|
|
18
|
+
lineas: string[];
|
|
19
|
+
localidad: string;
|
|
20
|
+
region: string;
|
|
21
|
+
codigoPostal: string;
|
|
22
|
+
/** ISO-3166 region code, e.g. `MX`. */
|
|
23
|
+
pais: string;
|
|
24
|
+
}
|
|
25
|
+
/** For businesses that go to the customer and show no storefront. */
|
|
26
|
+
export interface AreaServicio {
|
|
27
|
+
lugares: Array<{
|
|
28
|
+
nombre: string;
|
|
29
|
+
placeId?: string;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
export interface FotoNegocio {
|
|
33
|
+
url: string;
|
|
34
|
+
categoria?: 'PORTADA' | 'LOGO' | 'INTERIOR' | 'EXTERIOR' | 'PRODUCTO' | 'ADICIONAL';
|
|
35
|
+
}
|
|
36
|
+
export interface PerfilNegocio {
|
|
37
|
+
titulo: string;
|
|
38
|
+
/** Google category id, with or without the `categories/` prefix (e.g. `gcid:grocery_store`). */
|
|
39
|
+
categoriaPrincipal: string;
|
|
40
|
+
/** Storefront address. Give this or `areaServicio` (or both). */
|
|
41
|
+
direccion?: DireccionNegocio;
|
|
42
|
+
areaServicio?: AreaServicio;
|
|
43
|
+
telefono?: string;
|
|
44
|
+
sitioWeb?: string;
|
|
45
|
+
horario?: HorarioRegular;
|
|
46
|
+
excepciones?: ExcepcionHorario[];
|
|
47
|
+
fotos?: FotoNegocio[];
|
|
48
|
+
/** BCP-47, default `es`. */
|
|
49
|
+
idioma?: string;
|
|
50
|
+
/** Free code the host uses to recognise the location (Google `storeCode`). */
|
|
51
|
+
codigoExterno?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface GoogleTokens {
|
|
54
|
+
accessToken: string;
|
|
55
|
+
refreshToken: string;
|
|
56
|
+
expiresAt: Date;
|
|
57
|
+
scope?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface CuentaGoogle {
|
|
60
|
+
/** `accounts/123`. */
|
|
61
|
+
name: string;
|
|
62
|
+
nombre: string;
|
|
63
|
+
tipo?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface UbicacionGoogle {
|
|
66
|
+
/** `locations/456` (business information v1 name). */
|
|
67
|
+
name: string;
|
|
68
|
+
titulo: string;
|
|
69
|
+
telefono?: string;
|
|
70
|
+
sitioWeb?: string;
|
|
71
|
+
direccion?: string;
|
|
72
|
+
placeId?: string;
|
|
73
|
+
/** Maps URI, when Google returns it. */
|
|
74
|
+
urlMaps?: string;
|
|
75
|
+
}
|
|
76
|
+
export type MetodoVerificacion = 'llamada' | 'sms' | 'correo' | 'postal' | 'video';
|
|
77
|
+
export type EstadoVerificacion = 'pendiente' | 'en_proceso' | 'verificado' | 'fallido';
|
|
78
|
+
export interface OpcionVerificacion {
|
|
79
|
+
metodo: MetodoVerificacion;
|
|
80
|
+
/** Masked destination Google shows (`•••• 1234`, `m***@dominio.com`, mailing name). */
|
|
81
|
+
destino?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface DatosVerificar {
|
|
84
|
+
metodo: MetodoVerificacion;
|
|
85
|
+
idioma?: string;
|
|
86
|
+
/** Required for `sms` / `llamada` when Google offers a choice of number. */
|
|
87
|
+
telefono?: string;
|
|
88
|
+
/** Required for `correo`. */
|
|
89
|
+
correo?: string;
|
|
90
|
+
/** Contact name printed on the postcard. */
|
|
91
|
+
contactoPostal?: string;
|
|
92
|
+
}
|
|
93
|
+
export interface EstadoVerificacionNegocio {
|
|
94
|
+
estado: EstadoVerificacion;
|
|
95
|
+
metodo?: MetodoVerificacion;
|
|
96
|
+
/** `locations/456/verifications/789` of the verification in flight, if any. */
|
|
97
|
+
verificacion?: string;
|
|
98
|
+
/** The location can already be edited/appear on Maps (Voice of Merchant). */
|
|
99
|
+
puedeEditar: boolean;
|
|
100
|
+
}
|
|
101
|
+
export type TipoPublicacion = 'novedad' | 'oferta';
|
|
102
|
+
export interface PublicacionInput {
|
|
103
|
+
tipo: TipoPublicacion;
|
|
104
|
+
/** Up to 1500 characters (Google limit). */
|
|
105
|
+
resumen: string;
|
|
106
|
+
idioma?: string;
|
|
107
|
+
/** Required by Google for offers. */
|
|
108
|
+
titulo?: string;
|
|
109
|
+
llamadaAccion?: {
|
|
110
|
+
tipo: 'BOOK' | 'ORDER' | 'SHOP' | 'LEARN_MORE' | 'SIGN_UP' | 'CALL';
|
|
111
|
+
url?: string;
|
|
112
|
+
};
|
|
113
|
+
oferta?: {
|
|
114
|
+
codigoCupon?: string;
|
|
115
|
+
urlCanje?: string;
|
|
116
|
+
terminos?: string;
|
|
117
|
+
};
|
|
118
|
+
/** Offers need a validity window. `YYYY-MM-DD`. */
|
|
119
|
+
vigencia?: {
|
|
120
|
+
desde: string;
|
|
121
|
+
hasta: string;
|
|
122
|
+
};
|
|
123
|
+
fotoUrl?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface PublicacionGoogle {
|
|
126
|
+
name: string;
|
|
127
|
+
tipo: TipoPublicacion;
|
|
128
|
+
resumen: string;
|
|
129
|
+
estado?: string;
|
|
130
|
+
urlBusqueda?: string;
|
|
131
|
+
}
|
|
132
|
+
export interface ResenaGoogle {
|
|
133
|
+
/** Full v4 name, `accounts/1/locations/2/reviews/3`. */
|
|
134
|
+
name: string;
|
|
135
|
+
id: string;
|
|
136
|
+
autor: string;
|
|
137
|
+
estrellas: 1 | 2 | 3 | 4 | 5;
|
|
138
|
+
comentario?: string;
|
|
139
|
+
creada: string;
|
|
140
|
+
respuesta?: {
|
|
141
|
+
comentario: string;
|
|
142
|
+
actualizada: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export interface PaginaResenas {
|
|
146
|
+
resenas: ResenaGoogle[];
|
|
147
|
+
promedio?: number;
|
|
148
|
+
total?: number;
|
|
149
|
+
siguientePagina?: string;
|
|
150
|
+
}
|
|
151
|
+
export interface ResultadoVincular {
|
|
152
|
+
ubicacion: UbicacionGoogle;
|
|
153
|
+
/** True when it was created, false when an existing one was linked. */
|
|
154
|
+
creada: boolean;
|
|
155
|
+
}
|