@smart-cloud/publisher-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.ts +4 -0
- package/dist/index.js +1 -0
- package/dist/runtime.d.ts +10 -0
- package/dist/store.d.ts +24 -0
- package/dist/types.d.ts +18 -0
- package/package.json +52 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var g=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},w=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of P(t))!y.call(e,n)&&n!==r&&g(e,n,{get:()=>t[n],enumerable:!(o=d(t,n))||o.enumerable});return e};var R=e=>w(g({},"__esModule",{value:!0}),e);var U={};C(U,{PLUGIN_KEY:()=>F,createStore:()=>c,getPublisherPlugin:()=>b,getStore:()=>h,getStoreSelect:()=>S,reloadConfig:()=>p,sanitizePublisherConfig:()=>l,waitForPublisherReady:()=>m});module.exports=R(U);var s=require("@smart-cloud/wpsuite-core"),i=require("@wordpress/data");function x(e,t){if(!e||typeof e!="object")return null;let r=e,o=String(r.command??"").trim();if(o!=="publish"&&o!=="crawl"&&o!=="deploy"&&o!=="invalidate"&&o!=="retry-timeouts"&&o!=="url")return null;let n=Number.parseInt(String(r.intervalMinutes??"0"),10);if(!Number.isFinite(n)||n<1)return null;let u=String(r.id??`${o}-${t+1}`).trim();if(!u)return null;let a=String(r.url??"").trim();return o==="url"&&!a?null:{id:u,enabled:r.enabled!==!1,command:o,intervalMinutes:n,...a?{url:a}:{}}}function k(e){let t=e&&typeof e=="object"?e:{},o=(Array.isArray(t.rules)?t.rules:[]).map((n,u)=>x(n,u)).filter(n=>!!n);return{enabled:t.enabled===!0,timezone:String(t.timezone??"UTC").trim()||"UTC",rules:o}}var l=e=>{let t=e&&typeof e=="object"?e:{},r={...t};return r.scheduler=k(t.scheduler),typeof t.subscriptionType=="string"&&(r.subscriptionType=t.subscriptionType),r},T=async()=>({config:l(await(0,s.getConfig)("publisher"))}),v={setConfig:e=>({type:"SET_CONFIG",config:e})},z={getConfig(e){return e.config},getState(e){return e}},A={},S=e=>(0,i.select)(e),p=async e=>{let t=(0,s.getWpSuite)();t?.siteSettings&&(t.siteSettings.lastUpdate=Date.now());let r=await(0,s.getConfig)("publisher"),o=l(r);(0,i.dispatch)(e).setConfig?.(o)},c=async()=>{let e=await T(),t=(0,i.createReduxStore)("smartcloud/publisher",{reducer(r=e,o){return o.type==="SET_CONFIG"?{...r,config:o.config??null}:r},actions:v,selectors:z,resolvers:A});return(0,i.register)(t),t};var b=()=>typeof WpSuite>"u"?null:WpSuite.plugins?.staticPublisher??null,f=null,h=()=>(f||(f=c()),f),m=()=>Promise.resolve();var F="publisher";0&&(module.exports={PLUGIN_KEY,createStore,getPublisherPlugin,getStore,getStoreSelect,reloadConfig,sanitizePublisherConfig,waitForPublisherReady});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createStore, getStoreSelect, reloadConfig, sanitizePublisherConfig, type State, type Store, } from "./store";
|
|
2
|
+
export { getPublisherPlugin, getStore, waitForPublisherReady, type PublisherPlugin, } from "./runtime";
|
|
3
|
+
export type { PublisherJobCommand, PublisherSchedulerConfig, PublisherSchedulerRule, PublisherRemoteConfig, } from "./types";
|
|
4
|
+
export declare const PLUGIN_KEY = "publisher";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getConfig as a,getWpSuite as g}from"@smart-cloud/wpsuite-core";import{createReduxStore as f,dispatch as S,register as p,select as b}from"@wordpress/data";function h(e,t){if(!e||typeof e!="object")return null;let o=e,r=String(o.command??"").trim();if(r!=="publish"&&r!=="crawl"&&r!=="deploy"&&r!=="invalidate"&&r!=="retry-timeouts"&&r!=="url")return null;let n=Number.parseInt(String(o.intervalMinutes??"0"),10);if(!Number.isFinite(n)||n<1)return null;let i=String(o.id??`${r}-${t+1}`).trim();if(!i)return null;let s=String(o.url??"").trim();return r==="url"&&!s?null:{id:i,enabled:o.enabled!==!1,command:r,intervalMinutes:n,...s?{url:s}:{}}}function m(e){let t=e&&typeof e=="object"?e:{},r=(Array.isArray(t.rules)?t.rules:[]).map((n,i)=>h(n,i)).filter(n=>!!n);return{enabled:t.enabled===!0,timezone:String(t.timezone??"UTC").trim()||"UTC",rules:r}}var u=e=>{let t=e&&typeof e=="object"?e:{},o={...t};return o.scheduler=m(t.scheduler),typeof t.subscriptionType=="string"&&(o.subscriptionType=t.subscriptionType),o},d=async()=>({config:u(await a("publisher"))}),P={setConfig:e=>({type:"SET_CONFIG",config:e})},y={getConfig(e){return e.config},getState(e){return e}},C={},w=e=>b(e),R=async e=>{let t=g();t?.siteSettings&&(t.siteSettings.lastUpdate=Date.now());let o=await a("publisher"),r=u(o);S(e).setConfig?.(r)},l=async()=>{let e=await d(),t=f("smartcloud/publisher",{reducer(o=e,r){return r.type==="SET_CONFIG"?{...o,config:r.config??null}:o},actions:P,selectors:y,resolvers:C});return p(t),t};var x=()=>typeof WpSuite>"u"?null:WpSuite.plugins?.staticPublisher??null,c=null,k=()=>(c||(c=l()),c),T=()=>Promise.resolve();var D="publisher";export{D as PLUGIN_KEY,l as createStore,x as getPublisherPlugin,k as getStore,w as getStoreSelect,R as reloadConfig,u as sanitizePublisherConfig,T as waitForPublisherReady};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Store } from "./store";
|
|
2
|
+
export type PublisherPlugin = {
|
|
3
|
+
restUrl?: string;
|
|
4
|
+
nonce?: string;
|
|
5
|
+
settings?: unknown;
|
|
6
|
+
view?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const getPublisherPlugin: () => PublisherPlugin | null;
|
|
9
|
+
export declare const getStore: () => Promise<Store>;
|
|
10
|
+
export declare const waitForPublisherReady: () => Promise<void>;
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type StoreDescriptor } from "@wordpress/data";
|
|
2
|
+
import type { PublisherRemoteConfig } from "./types";
|
|
3
|
+
export declare const sanitizePublisherConfig: (input: unknown) => PublisherRemoteConfig;
|
|
4
|
+
declare const actions: {
|
|
5
|
+
setConfig: (config: PublisherRemoteConfig) => {
|
|
6
|
+
type: "SET_CONFIG";
|
|
7
|
+
config: PublisherRemoteConfig;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export interface State {
|
|
11
|
+
config: PublisherRemoteConfig | null;
|
|
12
|
+
}
|
|
13
|
+
export type Store = StoreDescriptor;
|
|
14
|
+
export type StoreSelectors = {
|
|
15
|
+
getConfig(): PublisherRemoteConfig | null;
|
|
16
|
+
getState(): State;
|
|
17
|
+
};
|
|
18
|
+
export type StoreActions = {
|
|
19
|
+
setConfig?: typeof actions.setConfig;
|
|
20
|
+
};
|
|
21
|
+
export declare const getStoreSelect: (store: Store) => StoreSelectors;
|
|
22
|
+
export declare const reloadConfig: (store: Store) => Promise<void>;
|
|
23
|
+
export declare const createStore: () => Promise<Store>;
|
|
24
|
+
export {};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type PublisherJobCommand = "publish" | "crawl" | "deploy" | "invalidate" | "retry-timeouts" | "url";
|
|
2
|
+
export interface PublisherSchedulerRule {
|
|
3
|
+
id: string;
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
command: PublisherJobCommand;
|
|
6
|
+
intervalMinutes: number;
|
|
7
|
+
url?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface PublisherSchedulerConfig {
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
timezone: string;
|
|
12
|
+
rules: PublisherSchedulerRule[];
|
|
13
|
+
}
|
|
14
|
+
export interface PublisherRemoteConfig {
|
|
15
|
+
scheduler?: PublisherSchedulerConfig;
|
|
16
|
+
subscriptionType?: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@smart-cloud/publisher-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Publisher 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": "yarn build:js && yarn build:types",
|
|
23
|
+
"build:js": "tsup --minify",
|
|
24
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
25
|
+
"lint": "eslint 'src/**/*.ts' --report-unused-disable-directives --max-warnings 0",
|
|
26
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
27
|
+
"publish": "WPSUITE_PREMIUM=true yarn build && npm publish --access=public"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"registry": "https://registry.npmjs.org/",
|
|
31
|
+
"scope": "@smart-cloud/publisher-core"
|
|
32
|
+
},
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@smart-cloud/wpsuite-core": "^2.2.11"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@wordpress/data": "^10.44.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@eslint/js": "^10.0.1",
|
|
42
|
+
"@types/node": "^25.6.0",
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^8.58.2",
|
|
44
|
+
"@typescript-eslint/parser": "^8.58.2",
|
|
45
|
+
"@wordpress/data": "^10.44.0",
|
|
46
|
+
"eslint": "^10.2.1",
|
|
47
|
+
"globals": "^17.5.0",
|
|
48
|
+
"tsup": "^8.5.1",
|
|
49
|
+
"typescript": "^6.0.3",
|
|
50
|
+
"typescript-eslint": "^8.58.2"
|
|
51
|
+
}
|
|
52
|
+
}
|