@smart-cloud/flow-core 1.0.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/dist/index.cjs +1 -0
- package/dist/index.d.cts +172 -0
- package/dist/index.d.ts +172 -0
- package/dist/index.js +1 -0
- package/package.json +55 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var P=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var m=(e,t)=>()=>(e&&(t=e(e=0)),t);var D=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},Z=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Q(t))!Y.call(e,a)&&a!==n&&P(e,a,{get:()=>t[a],enumerable:!(o=J(t,a))||o.enumerable});return e};var ee=e=>Z(P({},"__esModule",{value:!0}),e);function g(){return globalThis.WpSuite?.plugins?.flow}async function x(e=8e3){let t=g();if(t?.status!=="available"){if(t?.status==="error")throw new Error("Flow failed");await new Promise((n,o)=>{let a=()=>i(n),u=()=>i(()=>o(new Error("Flow failed"))),i=c=>{window.removeEventListener("wpsuite:flow:ready",a),window.removeEventListener("wpsuite:flow:error",u),l&&clearTimeout(l),c()};window.addEventListener("wpsuite:flow:ready",a,{once:!0}),window.addEventListener("wpsuite:flow:error",u,{once:!0});let l=e?window.setTimeout(()=>i(()=>o(new Error("Flow timeout"))),e):0})}}async function _(e=1e4){await x(e);let n=g()?.features?.store;if(!n)throw new Error("Flow store is not available");return n}var B=m(()=>{"use strict"});var y,p,R,U,F,te,ne,ae,oe,re,N,k,V,O,I,v=m(()=>{"use strict";y=require("@smart-cloud/wpsuite-core"),p=require("@wordpress/data"),R=require("aws-amplify/utils");B();typeof WpSuite<"u"?U=WpSuite.siteSettings:U={};F=e=>{let t=e&&typeof e=="object"?e:{},n={};return typeof t.backendTransport=="string"&&(n.backendTransport=t.backendTransport),typeof t.backendApiName=="string"&&(n.backendApiName=t.backendApiName),typeof t.backendBaseUrl=="string"&&(n.backendBaseUrl=t.backendBaseUrl),typeof t.subscriptionType=="string"&&(n.subscriptionType=t.subscriptionType),n},te=async()=>{let e=g();if(!e)throw new Error("Flow plugin is not available");let t=null;return e.settings.customTranslationsUrl&&(t=await fetch(e.settings.customTranslationsUrl+(e.settings.customTranslationsUrl.includes("?")?"&":"?")+"t="+U.lastUpdate).then(n=>n.ok?n.text():null).then(n=>n?JSON.parse(n):null).catch(()=>null)),t??null},ne=async()=>{let e=F(await(0,y.getConfig)("flow")),t=await te();return{config:e,language:void 0,direction:void 0,customTranslations:t,fieldDefaultValues:{}}},ae={setLanguage(e){return!e||e==="system"?R.I18n.setLanguage(""):R.I18n.setLanguage(e),{type:"SET_LANGUAGE",language:e}},setDirection(e){return{type:"SET_DIRECTION",direction:e}},setConfig:e=>({type:"SET_CONFIG",config:e}),setFieldDefaultValue(e,t){return{type:"SET_FIELD_DEFAULT_VALUE",fieldName:e,value:t}},setFieldDefaultValues(e){return{type:"SET_FIELD_DEFAULT_VALUES",values:e}},clearFieldDefaultValues(){return{type:"CLEAR_FIELD_DEFAULT_VALUES"}}},oe={getConfig(e){return e.config},getCustomTranslations(e){return e.customTranslations},getLanguage(e){return e.language},getDirection(e){return e.direction},getState(e){return e},getFieldDefaultValues(e){return e.fieldDefaultValues},getFieldDefaultValue(e,t){return e.fieldDefaultValues[t]}},re={},N=e=>{let t=(0,p.dispatch)(e);return delete t.setConfig,t},k=e=>(0,p.select)(e),V=async e=>{(0,y.getWpSuite)().siteSettings.lastUpdate=Date.now();let t=await(0,y.getConfig)("flow"),n=F(t);(0,p.dispatch)(e).setConfig(n)},O=async()=>{let e=await ne(),t=(0,p.createReduxStore)("smartcloud/flow",{reducer(n=e,o){switch(o.type){case"SET_LANGUAGE":return{...n,language:o.language};case"SET_DIRECTION":return{...n,direction:o.direction};case"SET_SHOW_CHATBOT_PREVIEW":return{...n,showChatbotPreview:o.showChatbotPreview};case"SET_CONFIG":return{...n,config:o.config};case"SET_FIELD_DEFAULT_VALUE":return{...n,fieldDefaultValues:{...n.fieldDefaultValues,[o.fieldName]:o.value}};case"SET_FIELD_DEFAULT_VALUES":return{...n,fieldDefaultValues:{...n.fieldDefaultValues,...o.values}};case"CLEAR_FIELD_DEFAULT_VALUES":return{...n,fieldDefaultValues:{}}}return n},actions:ae,selectors:oe,resolvers:re});return(0,p.register)(t),t},I=(e,t,n)=>{let o;function a(){let i=k(e).getState(),l=t(i);if(l!==o){let c=o;o=l,n(o,c)}}let u=(0,p.subscribe)(a,e);return a(),u}});var f,A=m(()=>{"use strict";f=class extends Error{constructor(n,o){super(n);this.decision=o;this.name="BackendError"}}});var K={};D(K,{decideCapability:()=>ce,resolveBackend:()=>W});async function ie(){let t=await se?.plugins?.flow?.features.store;return k(t).getConfig()??{}}function le(e){let t=e.backendApiName?.trim()||void 0,n=e.backendBaseUrl?.trim()||void 0;return{transport:e.backendTransport??(n?"fetch":t?"gatey":void 0),backendApiName:t,backendBaseUrl:n}}async function W(){let e=await ie(),{transport:t,backendApiName:n,backendBaseUrl:o}=le(e);if(!t)return{available:!1,reason:"No backend configured"};if(t==="fetch")return o?{available:!0,transport:t,baseUrl:o,reason:"Custom fetch backend"}:{available:!1,reason:"backendBaseUrl is missing"};if(!n)return{available:!1,reason:"backendApiName is missing"};let a=globalThis.WpSuite?.plugins?.gatey;return!a?.availability||await a.availability()!=="available"?{available:!1,reason:"Gatey is not available"}:{available:!0,transport:t,apiName:n,reason:"Gatey backend"}}async function ce(){let e=await W(),t=e.available,n={backendAvailable:t,backendTransport:e.transport,backendApiName:e.apiName,backendBaseUrl:e.baseUrl,backendReason:e.reason};return t?{...n,reason:`backend available (${e.reason??"n/a"})`}:{...n,reason:`backend NOT available (${e.reason??"n/a"})`}}var G,se,$=m(()=>{"use strict";G=require("@smart-cloud/wpsuite-core");v();se=(0,G.getWpSuite)()});var z={};D(z,{dispatchBackend:()=>pe,withRecaptchaHeaders:()=>L});async function ue(e){if(e!=="frontend")return;let t=(0,h.getWpSuite)().siteSettings;if(!t?.reCaptchaPublicKey)return;let{execute:n}=await(0,h.getRecaptcha)(t?.useRecaptchaEnterprise||!1);if(typeof n=="function")try{let a=await n(t.reCaptchaPublicKey,{action:"submit"});return typeof a=="string"&&a?a:void 0}catch{return}}async function L(e,t){if(e!=="frontend"||t["X-Recaptcha-Token"]||t["x-recaptcha-token"])return t;let n=await ue(e);return n?{...t,"X-Recaptcha-Token":n}:t}function b(e,t){try{e?.onStatus?.(t)}catch{}}function H(e,t){return`${e==="admin"?"/admin":"/frontend"}${t}`}async function pe(e,t,n,o,a,u={}){if(e.backendTransport==="fetch"){if(!e.backendBaseUrl)throw new f("backendTransport=fetch but backendBaseUrl is missing.",e);return de(e.backendBaseUrl,H(t,n),o,a,u,e,t)}if(!e.backendApiName)throw new f("backendTransport=gatey but backendApiName is missing.",e);return fe(e.backendApiName,H(t,n),o,a,u,e,t)}async function de(e,t,n,o,a,u,i){let l=`${e.replace(/\/+$/,"")}${t}`,c={"content-type":"application/json",...a.headers??{}},E=await L(i,c),T=a.query&&Object.keys(a.query).length>0?"?"+new URLSearchParams(Object.entries(a.query).map(([w,C])=>[w,String(C)])).toString():"";b(a,{context:i,step:"backend:request"}),b(a,{context:i,step:"backend:waiting"});let d=await fetch(l+T,{method:n,headers:E,body:JSON.stringify(o??{}),signal:a.signal,credentials:"omit"});if(b(a,{context:i,step:"backend:response"}),!d.ok){let w=`HTTP ${d.status}`;try{let C=await d.text();C&&(w=`${w}: ${C.substring(0,400)}`)}catch{}throw new f(`Fetch backend call failed: ${w}`,u)}return d.status===204?void 0:(d.headers.get("content-type")||"").includes("application/json")?await d.json():await d.text()}async function fe(e,t,n,o,a,u,i){let l=(0,j.getGateyPlugin)(),c;switch(n.toUpperCase()){case"POST":c=l?.cognito?.post;break;case"GET":c=l?.cognito?.get;break;case"PUT":c=l?.cognito?.put;break;case"PATCH":c=l?.cognito?.patch;break;case"DELETE":c=l?.cognito?.del;break;default:throw new f(`Unsupported HTTP method "${n}" for Gatey backend.`,u)}if(!c)throw new f(`Gatey backend selected, but Gatey.cognito.${n.toLowerCase()} is not available.`,u);let E=await L(i,{...a.headers??{}});b(a,{context:i,step:"backend:request"}),b(a,{context:i,step:"backend:waiting"});let T=c({apiName:e,path:t,options:{body:o,headers:E,retryStrategy:{strategy:"no-retry"}}});a?.signal?.addEventListener?.("abort",()=>{T.cancel()});let d=await T.response;if(d.statusCode===204){b(a,{context:i,step:"backend:response"});return}let S;try{S=await d.body.json()}catch{S=void 0}return b(a,{context:i,step:"backend:response"}),S}var j,h,q=m(()=>{"use strict";j=require("@smart-cloud/gatey-core"),h=require("@smart-cloud/wpsuite-core");A()});var Te={};D(Te,{BackendError:()=>f,LANGUAGE_OPTIONS:()=>ge,TEXT_DOMAIN:()=>r,decideCapability:()=>be,dispatchBackend:()=>ye,getFlowPlugin:()=>g,getStore:()=>_,getStoreDispatch:()=>N,getStoreSelect:()=>k,initializeFlow:()=>ke,observeStore:()=>I,reloadConfig:()=>V,resolveBackend:()=>we,sanitizeFlowConfig:()=>F,waitForFlowReady:()=>x});module.exports=ee(Te);var s=require("@wordpress/i18n"),M=require("@smart-cloud/wpsuite-core");var r="smartcloud-flow";B();v();v();A();var ge=[{label:(0,s.__)("Arabic",r),value:"ar"},{label:(0,s.__)("Chinese",r),value:"zh"},{label:(0,s.__)("Dutch",r),value:"nl"},{label:(0,s.__)("English",r),value:"en"},{label:(0,s.__)("French",r),value:"fr"},{label:(0,s.__)("German",r),value:"de"},{label:(0,s.__)("Hebrew",r),value:"he"},{label:(0,s.__)("Hindi",r),value:"hi"},{label:(0,s.__)("Hungarian",r),value:"hu"},{label:(0,s.__)("Indonesian",r),value:"id"},{label:(0,s.__)("Italian",r),value:"it"},{label:(0,s.__)("Japanese",r),value:"ja"},{label:(0,s.__)("Korean",r),value:"ko"},{label:(0,s.__)("Norwegian",r),value:"no"},{label:(0,s.__)("Polish",r),value:"pl"},{label:(0,s.__)("Portuguese",r),value:"pt"},{label:(0,s.__)("Russian",r),value:"ru"},{label:(0,s.__)("Spanish",r),value:"es"},{label:(0,s.__)("Swedish",r),value:"sv"},{label:(0,s.__)("Thai",r),value:"th"},{label:(0,s.__)("Turkish",r),value:"tr"},{label:(0,s.__)("Ukrainian",r),value:"uk"}],X=Promise.resolve().then(()=>($(),K)),be=async(...e)=>(await X).decideCapability(...e),we=async(...e)=>(await X).resolveBackend(...e),me=Promise.resolve().then(()=>(q(),z)),ye=async(...e)=>(await me).dispatchBackend(...e),ke=()=>{let e=globalThis.WpSuite,t=g();if(!t)throw console.error("Flow plugin is not available"),new Error("Flow plugin is not available");(0,M.attachDefaultPluginRuntime)(t),t.status=t.status??"initializing";let n=O();return t.features={store:n},n.then(()=>{t.status="available",e?.events?.emit("wpsuite:flow:ready",{key:t.key,version:t.version})}).catch(o=>{t.status="error",console.error("Flow plugin failed to initialize:",o),e?.events?.emit("wpsuite:flow:error",{key:t.key,error:String(o)})}),t};0&&(module.exports={BackendError,LANGUAGE_OPTIONS,TEXT_DOMAIN,decideCapability,dispatchBackend,getFlowPlugin,getStore,getStoreDispatch,getStoreSelect,initializeFlow,observeStore,reloadConfig,resolveBackend,sanitizeFlowConfig,waitForFlowReady});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { SubscriptionType, WpSuitePluginBase } from '@smart-cloud/wpsuite-core';
|
|
2
|
+
import { StoreDescriptor } from '@wordpress/data';
|
|
3
|
+
|
|
4
|
+
interface FlowConfig {
|
|
5
|
+
backendTransport?: BackendTransport;
|
|
6
|
+
backendApiName?: string;
|
|
7
|
+
backendBaseUrl?: string;
|
|
8
|
+
subscriptionType?: SubscriptionType;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Ensures we only keep runtime keys that are part of FlowConfig.
|
|
12
|
+
*/
|
|
13
|
+
declare const sanitizeFlowConfig: (input: unknown) => FlowConfig;
|
|
14
|
+
declare const actions: {
|
|
15
|
+
setLanguage(language: string | undefined | null): {
|
|
16
|
+
type: string;
|
|
17
|
+
language: string | null | undefined;
|
|
18
|
+
};
|
|
19
|
+
setDirection(direction: "ltr" | "rtl" | "auto" | undefined | null): {
|
|
20
|
+
type: string;
|
|
21
|
+
direction: "ltr" | "rtl" | "auto" | null | undefined;
|
|
22
|
+
};
|
|
23
|
+
setConfig: (config: FlowConfig) => {
|
|
24
|
+
type: "SET_CONFIG";
|
|
25
|
+
config: FlowConfig;
|
|
26
|
+
};
|
|
27
|
+
setFieldDefaultValue(fieldName: string, value: unknown): {
|
|
28
|
+
type: "SET_FIELD_DEFAULT_VALUE";
|
|
29
|
+
fieldName: string;
|
|
30
|
+
value: unknown;
|
|
31
|
+
};
|
|
32
|
+
setFieldDefaultValues(values: Record<string, unknown>): {
|
|
33
|
+
type: "SET_FIELD_DEFAULT_VALUES";
|
|
34
|
+
values: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
clearFieldDefaultValues(): {
|
|
37
|
+
type: "CLEAR_FIELD_DEFAULT_VALUES";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
interface CustomTranslations {
|
|
41
|
+
[key: string]: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
interface State {
|
|
44
|
+
config: FlowConfig;
|
|
45
|
+
language: string | undefined | null;
|
|
46
|
+
direction: "ltr" | "rtl" | "auto" | undefined | null;
|
|
47
|
+
customTranslations: CustomTranslations | null;
|
|
48
|
+
fieldDefaultValues: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
type Store = StoreDescriptor;
|
|
51
|
+
type StoreSelectors = {
|
|
52
|
+
getConfig(): FlowConfig | null;
|
|
53
|
+
getCustomTranslations(): CustomTranslations | null;
|
|
54
|
+
getLanguage(): string | undefined | null;
|
|
55
|
+
getDirection(): "ltr" | "rtl" | "auto" | undefined | null;
|
|
56
|
+
getState(): State;
|
|
57
|
+
getFieldDefaultValues(): Record<string, unknown>;
|
|
58
|
+
getFieldDefaultValue(fieldName: string): unknown;
|
|
59
|
+
};
|
|
60
|
+
type StoreActions = Omit<typeof actions, "setConfig"> & {
|
|
61
|
+
setConfig?: typeof actions.setConfig;
|
|
62
|
+
setFieldDefaultValue: typeof actions.setFieldDefaultValue;
|
|
63
|
+
setFieldDefaultValues: typeof actions.setFieldDefaultValues;
|
|
64
|
+
clearFieldDefaultValues: typeof actions.clearFieldDefaultValues;
|
|
65
|
+
};
|
|
66
|
+
declare const getStoreDispatch: (store: Store) => Omit<StoreActions, "setConfig">;
|
|
67
|
+
declare const getStoreSelect: (store: Store) => StoreSelectors;
|
|
68
|
+
declare const reloadConfig: (store: Store) => Promise<void>;
|
|
69
|
+
declare const observeStore: (observableStore: Store, selector: (state: State) => boolean | number | string | null | undefined, onChange: (nextValue: boolean | number | string | null | undefined, previousValue: boolean | number | string | null | undefined) => void) => () => void;
|
|
70
|
+
|
|
71
|
+
type ContextKind = "admin" | "frontend";
|
|
72
|
+
type BackendTransport = "gatey" | "fetch";
|
|
73
|
+
type FlowLanguageCode = "ar" | "en" | "zh" | "nl" | "fr" | "de" | "he" | "hi" | "hu" | "id" | "it" | "ja" | "ko" | "no" | "pl" | "pt" | "ru" | "es" | "sv" | "th" | "tr" | "uk";
|
|
74
|
+
/**
|
|
75
|
+
* FlowSettings - general settings stored in WordPress options.
|
|
76
|
+
* This is what users can configure on the General settings tab.
|
|
77
|
+
*/
|
|
78
|
+
interface FlowSettings {
|
|
79
|
+
/** Optional URL to custom translations JSON file. */
|
|
80
|
+
customTranslationsUrl?: string;
|
|
81
|
+
/** Chat optimization: number of seconds a successful reCAPTCHA assessment remains valid. */
|
|
82
|
+
reCaptchaChatTtlSeconds?: number;
|
|
83
|
+
/** Whether to show "Powered by WPSuite Flow" branding in UIs. */
|
|
84
|
+
enablePoweredBy?: boolean;
|
|
85
|
+
/** Whether to enable server-side debug logging for Flow. */
|
|
86
|
+
debugLoggingEnabled?: boolean;
|
|
87
|
+
/** Whether to enable backend sync for form definitions. */
|
|
88
|
+
formsBackendSyncEnabled?: boolean;
|
|
89
|
+
/** Whether to allow permanent deletion of forms (vs archive). */
|
|
90
|
+
formsAllowPermanentDelete?: boolean;
|
|
91
|
+
}
|
|
92
|
+
interface FlowFeatures {
|
|
93
|
+
readonly store: Promise<Store>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* FlowPlugin - the main plugin object exposed at WpSuite.plugins.flow.
|
|
97
|
+
* Note: accountId, siteId, siteKey are in WpSuite.siteSettings, not here.
|
|
98
|
+
*/
|
|
99
|
+
interface Flow {
|
|
100
|
+
features: FlowFeatures;
|
|
101
|
+
settings: FlowSettings;
|
|
102
|
+
nonce: string;
|
|
103
|
+
baseUrl: string;
|
|
104
|
+
restUrl: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* CapabilityDecision - result of backend capability resolution.
|
|
108
|
+
*/
|
|
109
|
+
interface CapabilityDecision {
|
|
110
|
+
backendAvailable: boolean;
|
|
111
|
+
backendTransport?: BackendTransport;
|
|
112
|
+
backendApiName?: string;
|
|
113
|
+
backendBaseUrl?: string;
|
|
114
|
+
backendReason?: string;
|
|
115
|
+
reason: string;
|
|
116
|
+
}
|
|
117
|
+
interface BackendCallOptions {
|
|
118
|
+
signal?: AbortSignal;
|
|
119
|
+
headers?: Record<string, string>;
|
|
120
|
+
query?: Record<string, string | number | boolean>;
|
|
121
|
+
onStatus?: (event: FlowStatusEvent) => void;
|
|
122
|
+
}
|
|
123
|
+
type FlowStatusStep = "decide" | "backend:request" | "backend:waiting" | "backend:response" | "done" | "error";
|
|
124
|
+
interface FlowStatusEvent {
|
|
125
|
+
context: ContextKind;
|
|
126
|
+
step: FlowStatusStep;
|
|
127
|
+
message?: string;
|
|
128
|
+
silent?: boolean;
|
|
129
|
+
}
|
|
130
|
+
declare class BackendError extends Error {
|
|
131
|
+
readonly decision?: unknown | undefined;
|
|
132
|
+
constructor(message: string, decision?: unknown | undefined);
|
|
133
|
+
}
|
|
134
|
+
interface Capabilities {
|
|
135
|
+
decideCapability: () => Promise<CapabilityDecision>;
|
|
136
|
+
resolveBackend: () => Promise<{
|
|
137
|
+
available: boolean;
|
|
138
|
+
transport?: BackendTransport;
|
|
139
|
+
apiName?: string;
|
|
140
|
+
baseUrl?: string;
|
|
141
|
+
reason?: string;
|
|
142
|
+
}>;
|
|
143
|
+
}
|
|
144
|
+
interface Backend<TResponse> {
|
|
145
|
+
dispatchBackend: (decision: CapabilityDecision, context: ContextKind, customPath: string, method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", requestBody: unknown, options: BackendCallOptions) => Promise<TResponse>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare const TEXT_DOMAIN = "smartcloud-flow";
|
|
149
|
+
|
|
150
|
+
type FlowReadyEvent = "wpsuite:flow:ready";
|
|
151
|
+
type FlowErrorEvent = "wpsuite:flow:error";
|
|
152
|
+
type FlowPlugin = WpSuitePluginBase & Flow;
|
|
153
|
+
declare function getFlowPlugin(): FlowPlugin | undefined;
|
|
154
|
+
declare function waitForFlowReady(timeoutMs?: number): Promise<void>;
|
|
155
|
+
declare function getStore(timeoutMs?: number): Promise<Store>;
|
|
156
|
+
|
|
157
|
+
declare const LANGUAGE_OPTIONS: {
|
|
158
|
+
label: string;
|
|
159
|
+
value: FlowLanguageCode;
|
|
160
|
+
}[];
|
|
161
|
+
declare const decideCapability: (...args: Parameters<Capabilities["decideCapability"]>) => Promise<CapabilityDecision>;
|
|
162
|
+
declare const resolveBackend: (...args: Parameters<Capabilities["resolveBackend"]>) => Promise<{
|
|
163
|
+
available: boolean;
|
|
164
|
+
transport?: BackendTransport;
|
|
165
|
+
apiName?: string;
|
|
166
|
+
baseUrl?: string;
|
|
167
|
+
reason?: string;
|
|
168
|
+
}>;
|
|
169
|
+
declare const dispatchBackend: (...args: Parameters<Backend<unknown>["dispatchBackend"]>) => Promise<unknown>;
|
|
170
|
+
declare const initializeFlow: () => FlowPlugin;
|
|
171
|
+
|
|
172
|
+
export { type Backend, type BackendCallOptions, BackendError, type BackendTransport, type Capabilities, type CapabilityDecision, type ContextKind, type CustomTranslations, type Flow, type FlowConfig, type FlowErrorEvent, type FlowFeatures, type FlowLanguageCode, type FlowPlugin, type FlowReadyEvent, type FlowSettings, type FlowStatusEvent, type FlowStatusStep, LANGUAGE_OPTIONS, type State, type Store, TEXT_DOMAIN, decideCapability, dispatchBackend, getFlowPlugin, getStore, getStoreDispatch, getStoreSelect, initializeFlow, observeStore, reloadConfig, resolveBackend, sanitizeFlowConfig, waitForFlowReady };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { SubscriptionType, WpSuitePluginBase } from '@smart-cloud/wpsuite-core';
|
|
2
|
+
import { StoreDescriptor } from '@wordpress/data';
|
|
3
|
+
|
|
4
|
+
interface FlowConfig {
|
|
5
|
+
backendTransport?: BackendTransport;
|
|
6
|
+
backendApiName?: string;
|
|
7
|
+
backendBaseUrl?: string;
|
|
8
|
+
subscriptionType?: SubscriptionType;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Ensures we only keep runtime keys that are part of FlowConfig.
|
|
12
|
+
*/
|
|
13
|
+
declare const sanitizeFlowConfig: (input: unknown) => FlowConfig;
|
|
14
|
+
declare const actions: {
|
|
15
|
+
setLanguage(language: string | undefined | null): {
|
|
16
|
+
type: string;
|
|
17
|
+
language: string | null | undefined;
|
|
18
|
+
};
|
|
19
|
+
setDirection(direction: "ltr" | "rtl" | "auto" | undefined | null): {
|
|
20
|
+
type: string;
|
|
21
|
+
direction: "ltr" | "rtl" | "auto" | null | undefined;
|
|
22
|
+
};
|
|
23
|
+
setConfig: (config: FlowConfig) => {
|
|
24
|
+
type: "SET_CONFIG";
|
|
25
|
+
config: FlowConfig;
|
|
26
|
+
};
|
|
27
|
+
setFieldDefaultValue(fieldName: string, value: unknown): {
|
|
28
|
+
type: "SET_FIELD_DEFAULT_VALUE";
|
|
29
|
+
fieldName: string;
|
|
30
|
+
value: unknown;
|
|
31
|
+
};
|
|
32
|
+
setFieldDefaultValues(values: Record<string, unknown>): {
|
|
33
|
+
type: "SET_FIELD_DEFAULT_VALUES";
|
|
34
|
+
values: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
clearFieldDefaultValues(): {
|
|
37
|
+
type: "CLEAR_FIELD_DEFAULT_VALUES";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
interface CustomTranslations {
|
|
41
|
+
[key: string]: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
interface State {
|
|
44
|
+
config: FlowConfig;
|
|
45
|
+
language: string | undefined | null;
|
|
46
|
+
direction: "ltr" | "rtl" | "auto" | undefined | null;
|
|
47
|
+
customTranslations: CustomTranslations | null;
|
|
48
|
+
fieldDefaultValues: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
type Store = StoreDescriptor;
|
|
51
|
+
type StoreSelectors = {
|
|
52
|
+
getConfig(): FlowConfig | null;
|
|
53
|
+
getCustomTranslations(): CustomTranslations | null;
|
|
54
|
+
getLanguage(): string | undefined | null;
|
|
55
|
+
getDirection(): "ltr" | "rtl" | "auto" | undefined | null;
|
|
56
|
+
getState(): State;
|
|
57
|
+
getFieldDefaultValues(): Record<string, unknown>;
|
|
58
|
+
getFieldDefaultValue(fieldName: string): unknown;
|
|
59
|
+
};
|
|
60
|
+
type StoreActions = Omit<typeof actions, "setConfig"> & {
|
|
61
|
+
setConfig?: typeof actions.setConfig;
|
|
62
|
+
setFieldDefaultValue: typeof actions.setFieldDefaultValue;
|
|
63
|
+
setFieldDefaultValues: typeof actions.setFieldDefaultValues;
|
|
64
|
+
clearFieldDefaultValues: typeof actions.clearFieldDefaultValues;
|
|
65
|
+
};
|
|
66
|
+
declare const getStoreDispatch: (store: Store) => Omit<StoreActions, "setConfig">;
|
|
67
|
+
declare const getStoreSelect: (store: Store) => StoreSelectors;
|
|
68
|
+
declare const reloadConfig: (store: Store) => Promise<void>;
|
|
69
|
+
declare const observeStore: (observableStore: Store, selector: (state: State) => boolean | number | string | null | undefined, onChange: (nextValue: boolean | number | string | null | undefined, previousValue: boolean | number | string | null | undefined) => void) => () => void;
|
|
70
|
+
|
|
71
|
+
type ContextKind = "admin" | "frontend";
|
|
72
|
+
type BackendTransport = "gatey" | "fetch";
|
|
73
|
+
type FlowLanguageCode = "ar" | "en" | "zh" | "nl" | "fr" | "de" | "he" | "hi" | "hu" | "id" | "it" | "ja" | "ko" | "no" | "pl" | "pt" | "ru" | "es" | "sv" | "th" | "tr" | "uk";
|
|
74
|
+
/**
|
|
75
|
+
* FlowSettings - general settings stored in WordPress options.
|
|
76
|
+
* This is what users can configure on the General settings tab.
|
|
77
|
+
*/
|
|
78
|
+
interface FlowSettings {
|
|
79
|
+
/** Optional URL to custom translations JSON file. */
|
|
80
|
+
customTranslationsUrl?: string;
|
|
81
|
+
/** Chat optimization: number of seconds a successful reCAPTCHA assessment remains valid. */
|
|
82
|
+
reCaptchaChatTtlSeconds?: number;
|
|
83
|
+
/** Whether to show "Powered by WPSuite Flow" branding in UIs. */
|
|
84
|
+
enablePoweredBy?: boolean;
|
|
85
|
+
/** Whether to enable server-side debug logging for Flow. */
|
|
86
|
+
debugLoggingEnabled?: boolean;
|
|
87
|
+
/** Whether to enable backend sync for form definitions. */
|
|
88
|
+
formsBackendSyncEnabled?: boolean;
|
|
89
|
+
/** Whether to allow permanent deletion of forms (vs archive). */
|
|
90
|
+
formsAllowPermanentDelete?: boolean;
|
|
91
|
+
}
|
|
92
|
+
interface FlowFeatures {
|
|
93
|
+
readonly store: Promise<Store>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* FlowPlugin - the main plugin object exposed at WpSuite.plugins.flow.
|
|
97
|
+
* Note: accountId, siteId, siteKey are in WpSuite.siteSettings, not here.
|
|
98
|
+
*/
|
|
99
|
+
interface Flow {
|
|
100
|
+
features: FlowFeatures;
|
|
101
|
+
settings: FlowSettings;
|
|
102
|
+
nonce: string;
|
|
103
|
+
baseUrl: string;
|
|
104
|
+
restUrl: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* CapabilityDecision - result of backend capability resolution.
|
|
108
|
+
*/
|
|
109
|
+
interface CapabilityDecision {
|
|
110
|
+
backendAvailable: boolean;
|
|
111
|
+
backendTransport?: BackendTransport;
|
|
112
|
+
backendApiName?: string;
|
|
113
|
+
backendBaseUrl?: string;
|
|
114
|
+
backendReason?: string;
|
|
115
|
+
reason: string;
|
|
116
|
+
}
|
|
117
|
+
interface BackendCallOptions {
|
|
118
|
+
signal?: AbortSignal;
|
|
119
|
+
headers?: Record<string, string>;
|
|
120
|
+
query?: Record<string, string | number | boolean>;
|
|
121
|
+
onStatus?: (event: FlowStatusEvent) => void;
|
|
122
|
+
}
|
|
123
|
+
type FlowStatusStep = "decide" | "backend:request" | "backend:waiting" | "backend:response" | "done" | "error";
|
|
124
|
+
interface FlowStatusEvent {
|
|
125
|
+
context: ContextKind;
|
|
126
|
+
step: FlowStatusStep;
|
|
127
|
+
message?: string;
|
|
128
|
+
silent?: boolean;
|
|
129
|
+
}
|
|
130
|
+
declare class BackendError extends Error {
|
|
131
|
+
readonly decision?: unknown | undefined;
|
|
132
|
+
constructor(message: string, decision?: unknown | undefined);
|
|
133
|
+
}
|
|
134
|
+
interface Capabilities {
|
|
135
|
+
decideCapability: () => Promise<CapabilityDecision>;
|
|
136
|
+
resolveBackend: () => Promise<{
|
|
137
|
+
available: boolean;
|
|
138
|
+
transport?: BackendTransport;
|
|
139
|
+
apiName?: string;
|
|
140
|
+
baseUrl?: string;
|
|
141
|
+
reason?: string;
|
|
142
|
+
}>;
|
|
143
|
+
}
|
|
144
|
+
interface Backend<TResponse> {
|
|
145
|
+
dispatchBackend: (decision: CapabilityDecision, context: ContextKind, customPath: string, method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", requestBody: unknown, options: BackendCallOptions) => Promise<TResponse>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare const TEXT_DOMAIN = "smartcloud-flow";
|
|
149
|
+
|
|
150
|
+
type FlowReadyEvent = "wpsuite:flow:ready";
|
|
151
|
+
type FlowErrorEvent = "wpsuite:flow:error";
|
|
152
|
+
type FlowPlugin = WpSuitePluginBase & Flow;
|
|
153
|
+
declare function getFlowPlugin(): FlowPlugin | undefined;
|
|
154
|
+
declare function waitForFlowReady(timeoutMs?: number): Promise<void>;
|
|
155
|
+
declare function getStore(timeoutMs?: number): Promise<Store>;
|
|
156
|
+
|
|
157
|
+
declare const LANGUAGE_OPTIONS: {
|
|
158
|
+
label: string;
|
|
159
|
+
value: FlowLanguageCode;
|
|
160
|
+
}[];
|
|
161
|
+
declare const decideCapability: (...args: Parameters<Capabilities["decideCapability"]>) => Promise<CapabilityDecision>;
|
|
162
|
+
declare const resolveBackend: (...args: Parameters<Capabilities["resolveBackend"]>) => Promise<{
|
|
163
|
+
available: boolean;
|
|
164
|
+
transport?: BackendTransport;
|
|
165
|
+
apiName?: string;
|
|
166
|
+
baseUrl?: string;
|
|
167
|
+
reason?: string;
|
|
168
|
+
}>;
|
|
169
|
+
declare const dispatchBackend: (...args: Parameters<Backend<unknown>["dispatchBackend"]>) => Promise<unknown>;
|
|
170
|
+
declare const initializeFlow: () => FlowPlugin;
|
|
171
|
+
|
|
172
|
+
export { type Backend, type BackendCallOptions, BackendError, type BackendTransport, type Capabilities, type CapabilityDecision, type ContextKind, type CustomTranslations, type Flow, type FlowConfig, type FlowErrorEvent, type FlowFeatures, type FlowLanguageCode, type FlowPlugin, type FlowReadyEvent, type FlowSettings, type FlowStatusEvent, type FlowStatusStep, LANGUAGE_OPTIONS, type State, type Store, TEXT_DOMAIN, decideCapability, dispatchBackend, getFlowPlugin, getStore, getStoreDispatch, getStoreSelect, initializeFlow, observeStore, reloadConfig, resolveBackend, sanitizeFlowConfig, waitForFlowReady };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var W=Object.defineProperty;var w=(e,t)=>()=>(e&&(t=e(e=0)),t);var D=(e,t)=>{for(var n in t)W(e,n,{get:t[n],enumerable:!0})};function b(){return globalThis.WpSuite?.plugins?.flow}async function x(e=8e3){let t=b();if(t?.status!=="available"){if(t?.status==="error")throw new Error("Flow failed");await new Promise((n,a)=>{let o=()=>i(n),u=()=>i(()=>a(new Error("Flow failed"))),i=c=>{window.removeEventListener("wpsuite:flow:ready",o),window.removeEventListener("wpsuite:flow:error",u),l&&clearTimeout(l),c()};window.addEventListener("wpsuite:flow:ready",o,{once:!0}),window.addEventListener("wpsuite:flow:error",u,{once:!0});let l=e?window.setTimeout(()=>i(()=>a(new Error("Flow timeout"))),e):0})}}async function K(e=1e4){await x(e);let n=b()?.features?.store;if(!n)throw new Error("Flow store is not available");return n}var F=w(()=>{"use strict"});import{getConfig as R,getWpSuite as $}from"@smart-cloud/wpsuite-core";import{createReduxStore as H,dispatch as U,register as j,select as z,subscribe as q}from"@wordpress/data";import{I18n as B}from"aws-amplify/utils";var v,h,M,X,J,Q,Y,Z,T,ee,A,te,S=w(()=>{"use strict";F();typeof WpSuite<"u"?v=WpSuite.siteSettings:v={};h=e=>{let t=e&&typeof e=="object"?e:{},n={};return typeof t.backendTransport=="string"&&(n.backendTransport=t.backendTransport),typeof t.backendApiName=="string"&&(n.backendApiName=t.backendApiName),typeof t.backendBaseUrl=="string"&&(n.backendBaseUrl=t.backendBaseUrl),typeof t.subscriptionType=="string"&&(n.subscriptionType=t.subscriptionType),n},M=async()=>{let e=b();if(!e)throw new Error("Flow plugin is not available");let t=null;return e.settings.customTranslationsUrl&&(t=await fetch(e.settings.customTranslationsUrl+(e.settings.customTranslationsUrl.includes("?")?"&":"?")+"t="+v.lastUpdate).then(n=>n.ok?n.text():null).then(n=>n?JSON.parse(n):null).catch(()=>null)),t??null},X=async()=>{let e=h(await R("flow")),t=await M();return{config:e,language:void 0,direction:void 0,customTranslations:t,fieldDefaultValues:{}}},J={setLanguage(e){return!e||e==="system"?B.setLanguage(""):B.setLanguage(e),{type:"SET_LANGUAGE",language:e}},setDirection(e){return{type:"SET_DIRECTION",direction:e}},setConfig:e=>({type:"SET_CONFIG",config:e}),setFieldDefaultValue(e,t){return{type:"SET_FIELD_DEFAULT_VALUE",fieldName:e,value:t}},setFieldDefaultValues(e){return{type:"SET_FIELD_DEFAULT_VALUES",values:e}},clearFieldDefaultValues(){return{type:"CLEAR_FIELD_DEFAULT_VALUES"}}},Q={getConfig(e){return e.config},getCustomTranslations(e){return e.customTranslations},getLanguage(e){return e.language},getDirection(e){return e.direction},getState(e){return e},getFieldDefaultValues(e){return e.fieldDefaultValues},getFieldDefaultValue(e,t){return e.fieldDefaultValues[t]}},Y={},Z=e=>{let t=U(e);return delete t.setConfig,t},T=e=>z(e),ee=async e=>{$().siteSettings.lastUpdate=Date.now();let t=await R("flow"),n=h(t);U(e).setConfig(n)},A=async()=>{let e=await X(),t=H("smartcloud/flow",{reducer(n=e,a){switch(a.type){case"SET_LANGUAGE":return{...n,language:a.language};case"SET_DIRECTION":return{...n,direction:a.direction};case"SET_SHOW_CHATBOT_PREVIEW":return{...n,showChatbotPreview:a.showChatbotPreview};case"SET_CONFIG":return{...n,config:a.config};case"SET_FIELD_DEFAULT_VALUE":return{...n,fieldDefaultValues:{...n.fieldDefaultValues,[a.fieldName]:a.value}};case"SET_FIELD_DEFAULT_VALUES":return{...n,fieldDefaultValues:{...n.fieldDefaultValues,...a.values}};case"CLEAR_FIELD_DEFAULT_VALUES":return{...n,fieldDefaultValues:{}}}return n},actions:J,selectors:Q,resolvers:Y});return j(t),t},te=(e,t,n)=>{let a;function o(){let i=T(e).getState(),l=t(i);if(l!==a){let c=a;a=l,n(a,c)}}let u=q(o,e);return o(),u}});var d,E=w(()=>{"use strict";d=class extends Error{constructor(n,a){super(n);this.decision=a;this.name="BackendError"}}});var _={};D(_,{decideCapability:()=>se,resolveBackend:()=>L});import{getWpSuite as ne}from"@smart-cloud/wpsuite-core";async function oe(){let t=await ae?.plugins?.flow?.features.store;return T(t).getConfig()??{}}function re(e){let t=e.backendApiName?.trim()||void 0,n=e.backendBaseUrl?.trim()||void 0;return{transport:e.backendTransport??(n?"fetch":t?"gatey":void 0),backendApiName:t,backendBaseUrl:n}}async function L(){let e=await oe(),{transport:t,backendApiName:n,backendBaseUrl:a}=re(e);if(!t)return{available:!1,reason:"No backend configured"};if(t==="fetch")return a?{available:!0,transport:t,baseUrl:a,reason:"Custom fetch backend"}:{available:!1,reason:"backendBaseUrl is missing"};if(!n)return{available:!1,reason:"backendApiName is missing"};let o=globalThis.WpSuite?.plugins?.gatey;return!o?.availability||await o.availability()!=="available"?{available:!1,reason:"Gatey is not available"}:{available:!0,transport:t,apiName:n,reason:"Gatey backend"}}async function se(){let e=await L(),t=e.available,n={backendAvailable:t,backendTransport:e.transport,backendApiName:e.apiName,backendBaseUrl:e.baseUrl,backendReason:e.reason};return t?{...n,reason:`backend available (${e.reason??"n/a"})`}:{...n,reason:`backend NOT available (${e.reason??"n/a"})`}}var ae,N=w(()=>{"use strict";S();ae=ne()});var O={};D(O,{dispatchBackend:()=>pe,withRecaptchaHeaders:()=>P});import{getGateyPlugin as ie}from"@smart-cloud/gatey-core";import{getRecaptcha as le,getWpSuite as ce}from"@smart-cloud/wpsuite-core";async function ue(e){if(e!=="frontend")return;let t=ce().siteSettings;if(!t?.reCaptchaPublicKey)return;let{execute:n}=await le(t?.useRecaptchaEnterprise||!1);if(typeof n=="function")try{let o=await n(t.reCaptchaPublicKey,{action:"submit"});return typeof o=="string"&&o?o:void 0}catch{return}}async function P(e,t){if(e!=="frontend"||t["X-Recaptcha-Token"]||t["x-recaptcha-token"])return t;let n=await ue(e);return n?{...t,"X-Recaptcha-Token":n}:t}function f(e,t){try{e?.onStatus?.(t)}catch{}}function V(e,t){return`${e==="admin"?"/admin":"/frontend"}${t}`}async function pe(e,t,n,a,o,u={}){if(e.backendTransport==="fetch"){if(!e.backendBaseUrl)throw new d("backendTransport=fetch but backendBaseUrl is missing.",e);return de(e.backendBaseUrl,V(t,n),a,o,u,e,t)}if(!e.backendApiName)throw new d("backendTransport=gatey but backendApiName is missing.",e);return fe(e.backendApiName,V(t,n),a,o,u,e,t)}async function de(e,t,n,a,o,u,i){let l=`${e.replace(/\/+$/,"")}${t}`,c={"content-type":"application/json",...o.headers??{}},C=await P(i,c),m=o.query&&Object.keys(o.query).length>0?"?"+new URLSearchParams(Object.entries(o.query).map(([g,k])=>[g,String(k)])).toString():"";f(o,{context:i,step:"backend:request"}),f(o,{context:i,step:"backend:waiting"});let p=await fetch(l+m,{method:n,headers:C,body:JSON.stringify(a??{}),signal:o.signal,credentials:"omit"});if(f(o,{context:i,step:"backend:response"}),!p.ok){let g=`HTTP ${p.status}`;try{let k=await p.text();k&&(g=`${g}: ${k.substring(0,400)}`)}catch{}throw new d(`Fetch backend call failed: ${g}`,u)}return p.status===204?void 0:(p.headers.get("content-type")||"").includes("application/json")?await p.json():await p.text()}async function fe(e,t,n,a,o,u,i){let l=ie(),c;switch(n.toUpperCase()){case"POST":c=l?.cognito?.post;break;case"GET":c=l?.cognito?.get;break;case"PUT":c=l?.cognito?.put;break;case"PATCH":c=l?.cognito?.patch;break;case"DELETE":c=l?.cognito?.del;break;default:throw new d(`Unsupported HTTP method "${n}" for Gatey backend.`,u)}if(!c)throw new d(`Gatey backend selected, but Gatey.cognito.${n.toLowerCase()} is not available.`,u);let C=await P(i,{...o.headers??{}});f(o,{context:i,step:"backend:request"}),f(o,{context:i,step:"backend:waiting"});let m=c({apiName:e,path:t,options:{body:a,headers:C,retryStrategy:{strategy:"no-retry"}}});o?.signal?.addEventListener?.("abort",()=>{m.cancel()});let p=await m.response;if(p.statusCode===204){f(o,{context:i,step:"backend:response"});return}let y;try{y=await p.body.json()}catch{y=void 0}return f(o,{context:i,step:"backend:response"}),y}var I=w(()=>{"use strict";E()});import{__ as s}from"@wordpress/i18n";import{attachDefaultPluginRuntime as ge}from"@smart-cloud/wpsuite-core";var r="smartcloud-flow";F();S();S();E();var Ne=[{label:s("Arabic",r),value:"ar"},{label:s("Chinese",r),value:"zh"},{label:s("Dutch",r),value:"nl"},{label:s("English",r),value:"en"},{label:s("French",r),value:"fr"},{label:s("German",r),value:"de"},{label:s("Hebrew",r),value:"he"},{label:s("Hindi",r),value:"hi"},{label:s("Hungarian",r),value:"hu"},{label:s("Indonesian",r),value:"id"},{label:s("Italian",r),value:"it"},{label:s("Japanese",r),value:"ja"},{label:s("Korean",r),value:"ko"},{label:s("Norwegian",r),value:"no"},{label:s("Polish",r),value:"pl"},{label:s("Portuguese",r),value:"pt"},{label:s("Russian",r),value:"ru"},{label:s("Spanish",r),value:"es"},{label:s("Swedish",r),value:"sv"},{label:s("Thai",r),value:"th"},{label:s("Turkish",r),value:"tr"},{label:s("Ukrainian",r),value:"uk"}],G=Promise.resolve().then(()=>(N(),_)),Ve=async(...e)=>(await G).decideCapability(...e),Oe=async(...e)=>(await G).resolveBackend(...e),be=Promise.resolve().then(()=>(I(),O)),Ie=async(...e)=>(await be).dispatchBackend(...e),Ge=()=>{let e=globalThis.WpSuite,t=b();if(!t)throw console.error("Flow plugin is not available"),new Error("Flow plugin is not available");ge(t),t.status=t.status??"initializing";let n=A();return t.features={store:n},n.then(()=>{t.status="available",e?.events?.emit("wpsuite:flow:ready",{key:t.key,version:t.version})}).catch(a=>{t.status="error",console.error("Flow plugin failed to initialize:",a),e?.events?.emit("wpsuite:flow:error",{key:t.key,error:String(a)})}),t};export{d as BackendError,Ne as LANGUAGE_OPTIONS,r as TEXT_DOMAIN,Ve as decideCapability,Ie as dispatchBackend,b as getFlowPlugin,K as getStore,Z as getStoreDispatch,T as getStoreSelect,Ge as initializeFlow,te as observeStore,ee as reloadConfig,Oe as resolveBackend,h as sanitizeFlowConfig,x as waitForFlowReady};
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@smart-cloud/flow-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Flow Core Package",
|
|
5
|
+
"author": "Smart Cloud Solutions Inc.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup --minify",
|
|
23
|
+
"lint": "eslint 'src/**/*.ts' --report-unused-disable-directives --max-warnings 0",
|
|
24
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
25
|
+
"publish": "WPSUITE_PREMIUM=true tsup --minify && npm publish --access=public"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"registry": "https://registry.npmjs.org/",
|
|
29
|
+
"scope": "@smart-cloud/flow-core"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@smart-cloud/gatey-core": "^2.2.2",
|
|
33
|
+
"@smart-cloud/wpsuite-core": "^2.2.10",
|
|
34
|
+
"aws-amplify": "^6.16.3"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@wordpress/data": "^10.41.0",
|
|
38
|
+
"@wordpress/i18n": "^6.14.0",
|
|
39
|
+
"react": "^18.3.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@eslint/js": "^10.0.1",
|
|
43
|
+
"@types/node": "^25.5.0",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
|
45
|
+
"@typescript-eslint/parser": "^8.57.0",
|
|
46
|
+
"@wordpress/data": "^10.41.0",
|
|
47
|
+
"@wordpress/i18n": "^6.14.0",
|
|
48
|
+
"eslint": "^10.0.3",
|
|
49
|
+
"globals": "^17.4.0",
|
|
50
|
+
"react": "^18.3.1",
|
|
51
|
+
"tsup": "^8.5.1",
|
|
52
|
+
"typescript": "^5.9.3",
|
|
53
|
+
"typescript-eslint": "^8.57.0"
|
|
54
|
+
}
|
|
55
|
+
}
|