@nocobase/plugin-workflow 2.1.0-beta.2 → 2.1.0-beta.21

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.
Files changed (138) hide show
  1. package/LICENSE +201 -661
  2. package/README.md +79 -10
  3. package/dist/client/214.7e602cfe7a8251b8.js +10 -0
  4. package/dist/client/261.7722d7400942730e.js +10 -0
  5. package/dist/client/67.f904ef4520868b8a.js +10 -0
  6. package/dist/client/964.6251d37b35710747.js +10 -0
  7. package/dist/client/hooks/{useWorkflowFilterActionProps.d.ts → useResourceFilterActionProps.d.ts} +1 -1
  8. package/dist/client/index.js +1 -1
  9. package/dist/client/nodes/create.d.ts +10 -0
  10. package/dist/client/nodes/destroy.d.ts +10 -0
  11. package/dist/client/nodes/index.d.ts +3 -0
  12. package/dist/client/nodes/query.d.ts +18 -2
  13. package/dist/client/nodes/update.d.ts +10 -0
  14. package/dist/client/schemas/collection.d.ts +8 -2
  15. package/dist/client/schemas/executions.d.ts +41 -23
  16. package/dist/client/triggers/collection.d.ts +14 -1
  17. package/dist/client/triggers/index.d.ts +4 -0
  18. package/dist/client/triggers/schedule/constants.d.ts +4 -0
  19. package/dist/client/triggers/schedule/index.d.ts +15 -0
  20. package/dist/common/collections/executions.d.ts +22 -22
  21. package/dist/common/collections/executions.js +12 -0
  22. package/dist/common/collections/jobs.js +7 -0
  23. package/dist/common/collections/workflows.d.ts +22 -9
  24. package/dist/common/collections/workflows.js +9 -1
  25. package/dist/externalVersion.js +15 -13
  26. package/dist/locale/zh-CN.json +4 -1
  27. package/dist/node_modules/cron-parser/lib/parser.js +1 -1
  28. package/dist/node_modules/cron-parser/package.json +1 -1
  29. package/dist/node_modules/joi/dist/joi-browser.min.js +1 -0
  30. package/dist/node_modules/joi/lib/annotate.js +175 -0
  31. package/dist/node_modules/joi/lib/base.js +1069 -0
  32. package/dist/node_modules/joi/lib/cache.js +143 -0
  33. package/dist/node_modules/joi/lib/common.js +216 -0
  34. package/dist/node_modules/joi/lib/compile.js +283 -0
  35. package/dist/node_modules/joi/lib/errors.js +271 -0
  36. package/dist/node_modules/joi/lib/extend.js +312 -0
  37. package/dist/node_modules/joi/lib/index.d.ts +2365 -0
  38. package/dist/node_modules/joi/lib/index.js +1 -0
  39. package/dist/node_modules/joi/lib/manifest.js +476 -0
  40. package/dist/node_modules/joi/lib/messages.js +178 -0
  41. package/dist/node_modules/joi/lib/modify.js +267 -0
  42. package/dist/node_modules/joi/lib/ref.js +414 -0
  43. package/dist/node_modules/joi/lib/schemas.js +302 -0
  44. package/dist/node_modules/joi/lib/state.js +166 -0
  45. package/dist/node_modules/joi/lib/template.js +463 -0
  46. package/dist/node_modules/joi/lib/trace.js +346 -0
  47. package/dist/node_modules/joi/lib/types/alternatives.js +364 -0
  48. package/dist/node_modules/joi/lib/types/any.js +174 -0
  49. package/dist/node_modules/joi/lib/types/array.js +809 -0
  50. package/dist/node_modules/joi/lib/types/binary.js +100 -0
  51. package/dist/node_modules/joi/lib/types/boolean.js +150 -0
  52. package/dist/node_modules/joi/lib/types/date.js +233 -0
  53. package/dist/node_modules/joi/lib/types/function.js +93 -0
  54. package/dist/node_modules/joi/lib/types/keys.js +1067 -0
  55. package/dist/node_modules/joi/lib/types/link.js +168 -0
  56. package/dist/node_modules/joi/lib/types/number.js +363 -0
  57. package/dist/node_modules/joi/lib/types/object.js +22 -0
  58. package/dist/node_modules/joi/lib/types/string.js +850 -0
  59. package/dist/node_modules/joi/lib/types/symbol.js +102 -0
  60. package/dist/node_modules/joi/lib/validator.js +750 -0
  61. package/dist/node_modules/joi/lib/values.js +263 -0
  62. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.d.ts +60 -0
  63. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.js +225 -0
  64. package/dist/node_modules/joi/node_modules/@hapi/topo/package.json +30 -0
  65. package/dist/node_modules/joi/package.json +1 -0
  66. package/dist/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts +5 -0
  67. package/dist/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +10 -0
  68. package/dist/node_modules/lru-cache/dist/commonjs/index.d.ts +1381 -0
  69. package/dist/node_modules/lru-cache/dist/commonjs/index.js +1692 -0
  70. package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +1 -0
  71. package/dist/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.d.ts +5 -0
  72. package/dist/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +4 -0
  73. package/dist/node_modules/lru-cache/dist/esm/browser/index.d.ts +1381 -0
  74. package/dist/node_modules/lru-cache/dist/{mjs → esm/browser}/index.js +537 -179
  75. package/dist/node_modules/lru-cache/dist/esm/browser/index.min.js +2 -0
  76. package/dist/node_modules/lru-cache/dist/esm/diagnostics-channel.d.ts +5 -0
  77. package/dist/node_modules/lru-cache/dist/esm/diagnostics-channel.js +19 -0
  78. package/dist/node_modules/lru-cache/dist/esm/index.d.ts +1381 -0
  79. package/dist/node_modules/lru-cache/dist/{cjs → esm}/index.js +538 -184
  80. package/dist/node_modules/lru-cache/dist/esm/index.min.js +2 -0
  81. package/dist/node_modules/lru-cache/dist/esm/node/diagnostics-channel.d.ts +5 -0
  82. package/dist/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +7 -0
  83. package/dist/node_modules/lru-cache/dist/esm/node/index.d.ts +1381 -0
  84. package/dist/node_modules/lru-cache/dist/esm/node/index.js +1688 -0
  85. package/dist/node_modules/lru-cache/dist/esm/node/index.min.js +2 -0
  86. package/dist/node_modules/lru-cache/package.json +1 -1
  87. package/dist/node_modules/nodejs-snowflake/nodejs_snowflake.js +1 -1
  88. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  89. package/dist/server/Dispatcher.d.ts +3 -2
  90. package/dist/server/Dispatcher.js +74 -61
  91. package/dist/server/Plugin.d.ts +1 -0
  92. package/dist/server/Plugin.js +28 -3
  93. package/dist/server/actions/nodes.d.ts +5 -0
  94. package/dist/server/actions/nodes.js +38 -5
  95. package/dist/server/actions/workflows.d.ts +6 -0
  96. package/dist/server/actions/workflows.js +38 -0
  97. package/dist/server/instructions/ConditionInstruction.d.ts +2 -0
  98. package/dist/server/instructions/ConditionInstruction.js +17 -0
  99. package/dist/server/instructions/CreateInstruction.d.ts +3 -0
  100. package/dist/server/instructions/CreateInstruction.js +25 -0
  101. package/dist/server/instructions/DestroyInstruction.d.ts +3 -0
  102. package/dist/server/instructions/DestroyInstruction.js +25 -0
  103. package/dist/server/instructions/EndInstruction.d.ts +2 -0
  104. package/dist/server/instructions/EndInstruction.js +4 -0
  105. package/dist/server/instructions/MultiConditionsInstruction.d.ts +2 -0
  106. package/dist/server/instructions/MultiConditionsInstruction.js +23 -0
  107. package/dist/server/instructions/OutputInstruction.d.ts +2 -0
  108. package/dist/server/instructions/OutputInstruction.js +14 -0
  109. package/dist/server/instructions/QueryInstruction.d.ts +3 -0
  110. package/dist/server/instructions/QueryInstruction.js +32 -7
  111. package/dist/server/instructions/UpdateInstruction.d.ts +3 -0
  112. package/dist/server/instructions/UpdateInstruction.js +27 -0
  113. package/dist/server/instructions/index.d.ts +15 -2
  114. package/dist/server/instructions/index.js +18 -0
  115. package/dist/server/triggers/CollectionTrigger.d.ts +3 -0
  116. package/dist/server/triggers/CollectionTrigger.js +28 -0
  117. package/dist/server/triggers/ScheduleTrigger/index.d.ts +3 -0
  118. package/dist/server/triggers/ScheduleTrigger/index.js +18 -3
  119. package/dist/server/triggers/index.d.ts +3 -0
  120. package/dist/server/triggers/index.js +18 -0
  121. package/dist/server/utils.d.ts +17 -0
  122. package/dist/server/utils.js +51 -2
  123. package/dist/swagger/index.d.ts +830 -109
  124. package/dist/swagger/index.js +947 -208
  125. package/package.json +6 -5
  126. package/dist/client/27bd65abee87cafa.js +0 -10
  127. package/dist/client/478692c1637f2742.js +0 -10
  128. package/dist/client/c1347b9d21f864d9.js +0 -10
  129. package/dist/client/f39e94207f92e352.js +0 -10
  130. package/dist/node_modules/lru-cache/LICENSE +0 -15
  131. package/dist/node_modules/lru-cache/dist/cjs/index-cjs.d.ts +0 -7
  132. package/dist/node_modules/lru-cache/dist/cjs/index-cjs.js +0 -1
  133. package/dist/node_modules/lru-cache/dist/cjs/index.d.ts +0 -807
  134. package/dist/node_modules/lru-cache/dist/cjs/index.min.js +0 -2
  135. package/dist/node_modules/lru-cache/dist/mjs/index.d.ts +0 -807
  136. package/dist/node_modules/lru-cache/dist/mjs/index.min.js +0 -2
  137. /package/dist/node_modules/lru-cache/dist/{cjs → commonjs}/package.json +0 -0
  138. /package/dist/node_modules/lru-cache/dist/{mjs → esm}/package.json +0 -0
@@ -0,0 +1,2 @@
1
+ import{tracingChannel as j,channel as I}from"node:diagnostics_channel";var S=I("lru-cache:metrics"),W=j("lru-cache");var D=()=>S.hasSubscribers||W.hasSubscribers,G=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,M=new Set,C=typeof process=="object"&&process?process:{},P=(u,e,t,i)=>{typeof C.emitWarning=="function"?C.emitWarning(u,e,t,i):console.error(`[${t}] ${e}: ${u}`)},H=u=>!M.has(u),$=Symbol("type"),F=u=>!!u&&u===Math.floor(u)&&u>0&&isFinite(u),U=u=>F(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?O:null:null,O=class extends Array{constructor(e){super(e),this.fill(0)}},R=class u{heap;length;static#o=!1;static create(e){let t=U(e);if(!t)return[];u.#o=!0;let i=new u(e,t);return u.#o=!1,i}constructor(e,t){if(!u.#o)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},L=class u{#o;#u;#w;#D;#S;#M;#U;#m;get perf(){return this.#m}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#n;#b;#s;#i;#t;#a;#c;#l;#h;#y;#r;#_;#F;#d;#g;#T;#W;#f;#j;static unsafeExposeInternals(e){return{starts:e.#F,ttls:e.#d,autopurgeTimers:e.#g,sizes:e.#_,keyMap:e.#s,keyList:e.#i,valList:e.#t,next:e.#a,prev:e.#c,get head(){return e.#l},get tail(){return e.#h},free:e.#y,isBackgroundFetch:t=>e.#e(t),backgroundFetch:(t,i,s,n)=>e.#P(t,i,s,n),moveToTail:t=>e.#L(t),indexes:t=>e.#A(t),rindexes:t=>e.#z(t),isStale:t=>e.#p(t)}}get max(){return this.#o}get maxSize(){return this.#u}get calculatedSize(){return this.#b}get size(){return this.#n}get fetchMethod(){return this.#M}get memoMethod(){return this.#U}get dispose(){return this.#w}get onInsert(){return this.#D}get disposeAfter(){return this.#S}constructor(e){let{max:t=0,ttl:i,ttlResolution:s=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:r,allowStale:h,dispose:l,onInsert:c,disposeAfter:f,noDisposeOnSet:g,noUpdateTTL:p,maxSize:T=0,maxEntrySize:w=0,sizeCalculation:y,fetchMethod:a,memoMethod:m,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:A,ignoreFetchAbort:z,perf:x}=e;if(x!==void 0&&typeof x?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#m=x??G,t!==0&&!F(t))throw new TypeError("max option must be a nonnegative integer");let v=t?U(t):Array;if(!v)throw new Error("invalid max value: "+t);if(this.#o=t,this.#u=T,this.maxEntrySize=w||this.#u,this.sizeCalculation=y,this.sizeCalculation){if(!this.#u&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(m!==void 0&&typeof m!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#U=m,a!==void 0&&typeof a!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#M=a,this.#W=!!a,this.#s=new Map,this.#i=Array.from({length:t}).fill(void 0),this.#t=Array.from({length:t}).fill(void 0),this.#a=new v(t),this.#c=new v(t),this.#l=0,this.#h=0,this.#y=R.create(t),this.#n=0,this.#b=0,typeof l=="function"&&(this.#w=l),typeof c=="function"&&(this.#D=c),typeof f=="function"?(this.#S=f,this.#r=[]):(this.#S=void 0,this.#r=void 0),this.#T=!!this.#w,this.#j=!!this.#D,this.#f=!!this.#S,this.noDisposeOnSet=!!g,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!d,this.allowStaleOnFetchAbort=!!A,this.ignoreFetchAbort=!!z,this.maxEntrySize!==0){if(this.#u!==0&&!F(this.#u))throw new TypeError("maxSize must be a positive integer if specified");if(!F(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#X()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!r,this.ttlResolution=F(s)||s===0?s:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!F(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#H()}if(this.#o===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#o&&!this.#u){let E="LRU_CACHE_UNBOUNDED";H(E)&&(M.add(E),P("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",E,u))}}getRemainingTTL(e){return this.#s.has(e)?1/0:0}#H(){let e=new O(this.#o),t=new O(this.#o);this.#d=e,this.#F=t;let i=this.ttlAutopurge?Array.from({length:this.#o}):void 0;this.#g=i,this.#N=(r,h,l=this.#m.now())=>{t[r]=h!==0?l:0,e[r]=h,s(r,h)},this.#x=r=>{t[r]=e[r]!==0?this.#m.now():0,s(r,e[r])};let s=this.ttlAutopurge?(r,h)=>{if(i?.[r]&&(clearTimeout(i[r]),i[r]=void 0),h&&h!==0&&i){let l=setTimeout(()=>{this.#p(r)&&this.#v(this.#i[r],"expire")},h+1);l.unref&&l.unref(),i[r]=l}}:()=>{};this.#E=(r,h)=>{if(e[h]){let l=e[h],c=t[h];if(!l||!c)return;r.ttl=l,r.start=c,r.now=n||o();let f=r.now-c;r.remainingTTL=l-f}};let n=0,o=()=>{let r=this.#m.now();if(this.ttlResolution>0){n=r;let h=setTimeout(()=>n=0,this.ttlResolution);h.unref&&h.unref()}return r};this.getRemainingTTL=r=>{let h=this.#s.get(r);if(h===void 0)return 0;let l=e[h],c=t[h];if(!l||!c)return 1/0;let f=(n||o())-c;return l-f},this.#p=r=>{let h=t[r],l=e[r];return!!l&&!!h&&(n||o())-h>l}}#x=()=>{};#E=()=>{};#N=()=>{};#p=()=>!1;#X(){let e=new O(this.#o);this.#b=0,this.#_=e,this.#R=t=>{this.#b-=e[t],e[t]=0},this.#k=(t,i,s,n)=>{if(this.#e(i))return 0;if(!F(s))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(s=n(i,t),!F(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s},this.#I=(t,i,s)=>{if(e[t]=i,this.#u){let n=this.#u-e[t];for(;this.#b>n;)this.#G(!0)}this.#b+=e[t],s&&(s.entrySize=i,s.totalCalculatedSize=this.#b)}}#R=e=>{};#I=(e,t,i)=>{};#k=(e,t,i,s)=>{if(i||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:e=this.allowStale}={}){if(this.#n)for(let t=this.#h;this.#V(t)&&((e||!this.#p(t))&&(yield t),t!==this.#l);)t=this.#c[t]}*#z({allowStale:e=this.allowStale}={}){if(this.#n)for(let t=this.#l;this.#V(t)&&((e||!this.#p(t))&&(yield t),t!==this.#h);)t=this.#a[t]}#V(e){return e!==void 0&&this.#s.get(this.#i[e])===e}*entries(){for(let e of this.#A())this.#t[e]!==void 0&&this.#i[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#i[e],this.#t[e]])}*rentries(){for(let e of this.#z())this.#t[e]!==void 0&&this.#i[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#i[e],this.#t[e]])}*keys(){for(let e of this.#A()){let t=this.#i[e];t!==void 0&&!this.#e(this.#t[e])&&(yield t)}}*rkeys(){for(let e of this.#z()){let t=this.#i[e];t!==void 0&&!this.#e(this.#t[e])&&(yield t)}}*values(){for(let e of this.#A())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}*rvalues(){for(let e of this.#z())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let i of this.#A()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;if(n!==void 0&&e(n,this.#i[i],this))return this.#C(this.#i[i],t)}}forEach(e,t=this){for(let i of this.#A()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;n!==void 0&&e.call(t,n,this.#i[i],this)}}rforEach(e,t=this){for(let i of this.#z()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;n!==void 0&&e.call(t,n,this.#i[i],this)}}purgeStale(){let e=!1;for(let t of this.#z({allowStale:!0}))this.#p(t)&&(this.#v(this.#i[t],"expire"),e=!0);return e}info(e){let t=this.#s.get(e);if(t===void 0)return;let i=this.#t[t],s=this.#e(i)?i.__staleWhileFetching:i;if(s===void 0)return;let n={value:s};if(this.#d&&this.#F){let o=this.#d[t],r=this.#F[t];if(o&&r){let h=o-(this.#m.now()-r);n.ttl=h,n.start=Date.now()}}return this.#_&&(n.size=this.#_[t]),n}dump(){let e=[];for(let t of this.#A({allowStale:!0})){let i=this.#i[t],s=this.#t[t],n=this.#e(s)?s.__staleWhileFetching:s;if(n===void 0||i===void 0)continue;let o={value:n};if(this.#d&&this.#F){o.ttl=this.#d[t];let r=this.#m.now()-this.#F[t];o.start=Math.floor(Date.now()-r)}this.#_&&(o.size=this.#_[t]),e.unshift([i,o])}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let s=Date.now()-i.start;i.start=this.#m.now()-s}this.#O(t,i.value,i)}}set(e,t,i={}){let{status:s=S.hasSubscribers?{}:void 0}=i;i.status=s,s&&(s.op="set",s.key=e,t!==void 0&&(s.value=t));let n=this.#O(e,t,i);return s&&S.hasSubscribers&&S.publish(s),n}#O(e,t,i={}){let{ttl:s=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:r=this.sizeCalculation,status:h}=i;if(t===void 0)return h&&(h.set="deleted"),this.delete(e),this;let{noUpdateTTL:l=this.noUpdateTTL}=i;h&&!this.#e(t)&&(h.value=t);let c=this.#k(e,t,i.size||0,r,h);if(this.maxEntrySize&&c>this.maxEntrySize)return this.#v(e,"set"),h&&(h.set="miss",h.maxEntrySizeExceeded=!0),this;let f=this.#n===0?void 0:this.#s.get(e);if(f===void 0)f=this.#n===0?this.#h:this.#y.length!==0?this.#y.pop():this.#n===this.#o?this.#G(!1):this.#n,this.#i[f]=e,this.#t[f]=t,this.#s.set(e,f),this.#a[this.#h]=f,this.#c[f]=this.#h,this.#h=f,this.#n++,this.#I(f,c,h),h&&(h.set="add"),l=!1,this.#j&&this.#D?.(t,e,"add");else{this.#L(f);let g=this.#t[f];if(t!==g){if(this.#W&&this.#e(g)){g.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=g;p!==void 0&&!o&&(this.#T&&this.#w?.(p,e,"set"),this.#f&&this.#r?.push([p,e,"set"]))}else o||(this.#T&&this.#w?.(g,e,"set"),this.#f&&this.#r?.push([g,e,"set"]));if(this.#R(f),this.#I(f,c,h),this.#t[f]=t,h){h.set="replace";let p=g&&this.#e(g)?g.__staleWhileFetching:g;p!==void 0&&(h.oldValue=p)}}else h&&(h.set="update");this.#j&&this.onInsert?.(t,e,t===g?"update":"replace")}if(s!==0&&!this.#d&&this.#H(),this.#d&&(l||this.#N(f,s,n),h&&this.#E(h,f)),!o&&this.#f&&this.#r){let g=this.#r,p;for(;p=g?.shift();)this.#S?.(...p)}return this}pop(){try{for(;this.#n;){let e=this.#t[this.#l];if(this.#G(!0),this.#e(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#f&&this.#r){let e=this.#r,t;for(;t=e?.shift();)this.#S?.(...t)}}}#G(e){let t=this.#l,i=this.#i[t],s=this.#t[t];return this.#W&&this.#e(s)?s.__abortController.abort(new Error("evicted")):(this.#T||this.#f)&&(this.#T&&this.#w?.(s,i,"evict"),this.#f&&this.#r?.push([s,i,"evict"])),this.#R(t),this.#g?.[t]&&(clearTimeout(this.#g[t]),this.#g[t]=void 0),e&&(this.#i[t]=void 0,this.#t[t]=void 0,this.#y.push(t)),this.#n===1?(this.#l=this.#h=0,this.#y.length=0):this.#l=this.#a[t],this.#s.delete(i),this.#n--,t}has(e,t={}){let{status:i=S.hasSubscribers?{}:void 0}=t;t.status=i,i&&(i.op="has",i.key=e);let s=this.#Y(e,t);return S.hasSubscribers&&S.publish(i),s}#Y(e,t={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:s}=t,n=this.#s.get(e);if(n!==void 0){let o=this.#t[n];if(this.#e(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#p(n))s&&(s.has="stale",this.#E(s,n));else return i&&this.#x(n),s&&(s.has="hit",this.#E(s,n)),!0}else s&&(s.has="miss");return!1}peek(e,t={}){let{status:i=D()?{}:void 0}=t;i&&(i.op="peek",i.key=e),t.status=i;let s=this.#J(e,t);return S.hasSubscribers&&S.publish(i),s}#J(e,t){let{status:i,allowStale:s=this.allowStale}=t,n=this.#s.get(e);if(n===void 0||!s&&this.#p(n)){i&&(i.peek=n===void 0?"miss":"stale");return}let o=this.#t[n],r=this.#e(o)?o.__staleWhileFetching:o;return i&&(r!==void 0?(i.peek="hit",i.value=r):i.peek="miss"),r}#P(e,t,i,s){let n=t===void 0?void 0:this.#t[t];if(this.#e(n))return n;let o=new AbortController,{signal:r}=i;r?.addEventListener("abort",()=>o.abort(r.reason),{signal:o.signal});let h={signal:o.signal,options:i,context:s},l=(w,y=!1)=>{let{aborted:a}=o.signal,m=i.ignoreFetchAbort&&w!==void 0,_=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&w!==void 0);if(i.status&&(a&&!y?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,m&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),a&&!m&&!y)return f(o.signal.reason,_);let b=p,d=this.#t[t];return(d===p||d===void 0&&m&&y)&&(w===void 0?b.__staleWhileFetching!==void 0?this.#t[t]=b.__staleWhileFetching:this.#v(e,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.#O(e,w,h.options))),w},c=w=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=w),f(w,!1)),f=(w,y)=>{let{aborted:a}=o.signal,m=a&&i.allowStaleOnFetchAbort,_=m||i.allowStaleOnFetchRejection,b=_||i.noDeleteOnFetchRejection,d=p;if(this.#t[t]===p&&(!b||!y&&d.__staleWhileFetching===void 0?this.#v(e,"fetch"):m||(this.#t[t]=d.__staleWhileFetching)),_)return i.status&&d.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),d.__staleWhileFetching;if(d.__returned===d)throw w},g=(w,y)=>{let a=this.#M?.(e,n,h);a&&a instanceof Promise&&a.then(m=>w(m===void 0?void 0:m),y),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(w(void 0),i.allowStaleOnFetchAbort&&(w=m=>l(m,!0)))})};i.status&&(i.status.fetchDispatched=!0);let p=new Promise(g).then(l,c),T=Object.assign(p,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return t===void 0?(this.#O(e,T,{...h.options,status:void 0}),t=this.#s.get(e)):this.#t[t]=T,T}#e(e){if(!this.#W)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController}fetch(e,t={}){let i=W.hasSubscribers,{status:s=D()?{}:void 0}=t;t.status=s,s&&t.context&&(s.context=t.context);let n=this.#B(e,t);return s&&D()&&i&&(s.trace=!0,W.tracePromise(()=>n,s).catch(()=>{})),n}async#B(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:r=this.noDisposeOnSet,size:h=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:g=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:T=this.allowStaleOnFetchAbort,context:w,forceRefresh:y=!1,status:a,signal:m}=t;if(a&&(a.op="fetch",a.key=e,y&&(a.forceRefresh=!0)),!this.#W)return a&&(a.fetch="get"),this.#C(e,{allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,status:a});let _={allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:r,size:h,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:g,allowStaleOnFetchAbort:T,ignoreFetchAbort:p,status:a,signal:m},b=this.#s.get(e);if(b===void 0){a&&(a.fetch="miss");let d=this.#P(e,b,_,w);return d.__returned=d}else{let d=this.#t[b];if(this.#e(d)){let E=i&&d.__staleWhileFetching!==void 0;return a&&(a.fetch="inflight",E&&(a.returnedStale=!0)),E?d.__staleWhileFetching:d.__returned=d}let A=this.#p(b);if(!y&&!A)return a&&(a.fetch="hit"),this.#L(b),s&&this.#x(b),a&&this.#E(a,b),d;let z=this.#P(e,b,_,w),v=z.__staleWhileFetching!==void 0&&i;return a&&(a.fetch=A?"stale":"refresh",v&&A&&(a.returnedStale=!0)),v?z.__staleWhileFetching:z.__returned=z}}forceFetch(e,t={}){let i=W.hasSubscribers,{status:s=D()?{}:void 0}=t;t.status=s,s&&t.context&&(s.context=t.context);let n=this.#K(e,t);return s&&D()&&i&&(s.trace=!0,W.tracePromise(()=>n,s).catch(()=>{})),n}async#K(e,t={}){let i=await this.#B(e,t);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(e,t={}){let{status:i=S.hasSubscribers?{}:void 0}=t;t.status=i,i&&(i.op="memo",i.key=e,t.context&&(i.context=t.context));let s=this.#Q(e,t);return i&&(i.value=s),S.hasSubscribers&&S.publish(i),s}#Q(e,t={}){let i=this.#U;if(!i)throw new Error("no memoMethod provided to constructor");let{context:s,status:n,forceRefresh:o,...r}=t;n&&o&&(n.forceRefresh=!0);let h=this.#C(e,r),l=o||h===void 0;if(n&&(n.memo=l?"miss":"hit",l||(n.value=h)),!l)return h;let c=i(e,h,{options:r,context:s});return n&&(n.value=c),this.#O(e,c,r),c}get(e,t={}){let{status:i=S.hasSubscribers?{}:void 0}=t;t.status=i,i&&(i.op="get",i.key=e);let s=this.#C(e,t);return i&&(s!==void 0&&(i.value=s),S.hasSubscribers&&S.publish(i)),s}#C(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=t,r=this.#s.get(e);if(r===void 0){o&&(o.get="miss");return}let h=this.#t[r],l=this.#e(h);return o&&this.#E(o,r),this.#p(r)?l?(o&&(o.get="stale-fetching"),i&&h.__staleWhileFetching!==void 0?(o&&(o.returnedStale=!0),h.__staleWhileFetching):void 0):(n||this.#v(e,"expire"),o&&(o.get="stale"),i?(o&&(o.returnedStale=!0),h):void 0):(o&&(o.get=l?"fetching":"hit"),this.#L(r),s&&this.#x(r),l?h.__staleWhileFetching:h)}#$(e,t){this.#c[t]=e,this.#a[e]=t}#L(e){e!==this.#h&&(e===this.#l?this.#l=this.#a[e]:this.#$(this.#c[e],this.#a[e]),this.#$(this.#h,e),this.#h=e)}delete(e){return this.#v(e,"delete")}#v(e,t){S.hasSubscribers&&S.publish({op:"delete",delete:t,key:e});let i=!1;if(this.#n!==0){let s=this.#s.get(e);if(s!==void 0)if(this.#g?.[s]&&(clearTimeout(this.#g?.[s]),this.#g[s]=void 0),i=!0,this.#n===1)this.#q(t);else{this.#R(s);let n=this.#t[s];if(this.#e(n)?n.__abortController.abort(new Error("deleted")):(this.#T||this.#f)&&(this.#T&&this.#w?.(n,e,t),this.#f&&this.#r?.push([n,e,t])),this.#s.delete(e),this.#i[s]=void 0,this.#t[s]=void 0,s===this.#h)this.#h=this.#c[s];else if(s===this.#l)this.#l=this.#a[s];else{let o=this.#c[s];this.#a[o]=this.#a[s];let r=this.#a[s];this.#c[r]=this.#c[s]}this.#n--,this.#y.push(s)}}if(this.#f&&this.#r?.length){let s=this.#r,n;for(;n=s?.shift();)this.#S?.(...n)}return i}clear(){return this.#q("delete")}#q(e){for(let t of this.#z({allowStale:!0})){let i=this.#t[t];if(this.#e(i))i.__abortController.abort(new Error("deleted"));else{let s=this.#i[t];this.#T&&this.#w?.(i,s,e),this.#f&&this.#r?.push([i,s,e])}}if(this.#s.clear(),this.#t.fill(void 0),this.#i.fill(void 0),this.#d&&this.#F){this.#d.fill(0),this.#F.fill(0);for(let t of this.#g??[])t!==void 0&&clearTimeout(t);this.#g?.fill(void 0)}if(this.#_&&this.#_.fill(0),this.#l=0,this.#h=0,this.#y.length=0,this.#b=0,this.#n=0,this.#f&&this.#r){let t=this.#r,i;for(;i=t?.shift();)this.#S?.(...i)}}};export{L as LRUCache};
2
+ //# sourceMappingURL=index.min.js.map
@@ -1 +1 @@
1
- {"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2026-02-22T12:04:04.046Z"}
1
+ {"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"11.3.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","prepare":"tshy && bash scripts/build.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"tap","snap":"tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig ./.tshy/esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile","lint":"oxlint --fix src test","postsnap":"npm run lint","postlint":"npm run format"},"main":"./dist/commonjs/index.min.js","types":"./dist/commonjs/index.d.ts","tshy":{"esmDialects":["node","browser"],"exports":{"./raw":"./src/index.ts",".":{"import":{"node":{"types":"./dist/esm/node/index.d.ts","default":"./dist/esm/node/index.min.js"},"browser":{"types":"./dist/esm/browser/index.d.ts","default":"./dist/esm/browser/index.min.js"},"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.min.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.min.js"}}},"selfLink":false},"repository":{"type":"git","url":"git+ssh://git@github.com/isaacs/node-lru-cache.git"},"devDependencies":{"benchmark":"^2.1.4","esbuild":"^0.25.9","marked":"^4.2.12","mkdirp":"^3.0.1","oxlint":"^1.58.0","oxlint-tsgolint":"^0.19.0","prettier":"^3.8.1","tap":"^21.6.3","tshy":"^4.1.1","typedoc":"^0.28.18"},"license":"BlueOak-1.0.0","files":["dist"],"engines":{"node":"20 || >=22"},"exports":{"./raw":{"import":{"node":{"types":"./dist/esm/node/index.d.ts","default":"./dist/esm/node/index.js"},"browser":{"types":"./dist/esm/browser/index.d.ts","default":"./dist/esm/browser/index.js"},"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},".":{"import":{"node":{"types":"./dist/esm/node/index.d.ts","default":"./dist/esm/node/index.min.js"},"browser":{"types":"./dist/esm/browser/index.d.ts","default":"./dist/esm/browser/index.min.js"},"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.min.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.min.js"}}},"type":"module","module":"./dist/esm/index.min.js","_lastModified":"2026-04-27T17:02:31.016Z"}
@@ -1 +1 @@
1
- (function(){var e={363:function(e,t,n){let r={};r["__wbindgen_placeholder__"]=e.exports;let o;const{TextDecoder:i,TextEncoder:a}=n(837);let s=new i("utf-8",{ignoreBOM:true,fatal:true});s.decode();let _=null;function getUint8Memory0(){if(_===null||_.buffer!==o.memory.buffer){_=new Uint8Array(o.memory.buffer)}return _}function getStringFromWasm0(e,t){return s.decode(getUint8Memory0().subarray(e,e+t))}const c=new Array(32).fill(undefined);c.push(undefined,null,true,false);let u=c.length;function addHeapObject(e){if(u===c.length)c.push(c.length+1);const t=u;u=c[t];c[t]=e;return t}function getObject(e){return c[e]}function dropObject(e){if(e<36)return;c[e]=u;u=e}function takeObject(e){const t=getObject(e);dropObject(e);return t}let f=0;let d=new a("utf-8");const l=typeof d.encodeInto==="function"?function(e,t){return d.encodeInto(e,t)}:function(e,t){const n=d.encode(e);t.set(n);return{read:e.length,written:n.length}};function passStringToWasm0(e,t,n){if(n===undefined){const n=d.encode(e);const r=t(n.length);getUint8Memory0().subarray(r,r+n.length).set(n);f=n.length;return r}let r=e.length;let o=t(r);const i=getUint8Memory0();let a=0;for(;a<r;a++){const t=e.charCodeAt(a);if(t>127)break;i[o+a]=t}if(a!==r){if(a!==0){e=e.slice(a)}o=n(o,r,r=a+e.length*3);const t=getUint8Memory0().subarray(o+a,o+r);const i=l(e,t);a+=i.written}f=a;return o}let w=null;function getInt32Memory0(){if(w===null||w.buffer!==o.memory.buffer){w=new Int32Array(o.memory.buffer)}return w}function isLikeNone(e){return e===undefined||e===null}const g=new Uint32Array(2);const m=new BigUint64Array(g.buffer);function notDefined(e){return()=>{throw new Error(`${e} is not defined`)}}class Snowflake{static __wrap(e){const t=Object.create(Snowflake.prototype);t.ptr=e;return t}__destroy_into_raw(){const e=this.ptr;this.ptr=0;return e}free(){const e=this.__destroy_into_raw();o.__wbg_snowflake_free(e)}constructor(e){try{const i=o.__wbindgen_add_to_stack_pointer(-16);o.snowflake_new(i,isLikeNone(e)?0:addHeapObject(e));var t=getInt32Memory0()[i/4+0];var n=getInt32Memory0()[i/4+1];var r=getInt32Memory0()[i/4+2];if(r){throw takeObject(n)}return Snowflake.__wrap(t)}finally{o.__wbindgen_add_to_stack_pointer(16)}}getUniqueID(){try{const n=o.__wbindgen_add_to_stack_pointer(-16);o.snowflake_getUniqueID(n,this.ptr);var e=getInt32Memory0()[n/4+0];var t=getInt32Memory0()[n/4+1];g[0]=e;g[1]=t;const r=m[0];return r}finally{o.__wbindgen_add_to_stack_pointer(16)}}idFromTimestamp(e){try{const r=o.__wbindgen_add_to_stack_pointer(-16);o.snowflake_idFromTimestamp(r,this.ptr,e);var t=getInt32Memory0()[r/4+0];var n=getInt32Memory0()[r/4+1];g[0]=t;g[1]=n;const i=m[0];return i}finally{o.__wbindgen_add_to_stack_pointer(16)}}instanceID(){var e=o.snowflake_instanceID(this.ptr);return e}customEpoch(){var e=o.snowflake_customEpoch(this.ptr);return e}static timestampFromID(e,t){m[0]=e;const n=g[0];const r=g[1];var i=o.snowflake_timestampFromID(n,r,t);return i}static instanceIDFromID(e){m[0]=e;const t=g[0];const n=g[1];var r=o.snowflake_instanceIDFromID(t,n);return r}}e.exports.Snowflake=Snowflake;e.exports.__wbindgen_string_new=function(e,t){var n=getStringFromWasm0(e,t);return addHeapObject(n)};e.exports.__wbindgen_object_drop_ref=function(e){takeObject(e)};e.exports.__wbindgen_json_serialize=function(e,t){const n=getObject(t);var r=JSON.stringify(n===undefined?null:n);var i=passStringToWasm0(r,o.__wbindgen_malloc,o.__wbindgen_realloc);var a=f;getInt32Memory0()[e/4+1]=a;getInt32Memory0()[e/4+0]=i};e.exports.__wbg_now_e6c39c10a5e8aec7=function(){var e=Date.now();return e};e.exports.__wbg_random_7b8246250fd79f60=typeof Math.random=="function"?Math.random:notDefined("Math.random");e.exports.__wbindgen_throw=function(e,t){throw new Error(getStringFromWasm0(e,t))};const p=n.ab+"nodejs_snowflake_bg.wasm";const b=n(147).readFileSync(n.ab+"nodejs_snowflake_bg.wasm");const y=new WebAssembly.Module(b);const k=new WebAssembly.Instance(y,r);o=k.exports;e.exports.__wasm=o},147:function(e){"use strict";e.exports=require("fs")},837:function(e){"use strict";e.exports=require("util")}};var t={};function __nccwpck_require__(n){var r=t[n];if(r!==undefined){return r.exports}var o=t[n]={exports:{}};var i=true;try{e[n](o,o.exports,__nccwpck_require__);i=false}finally{if(i)delete t[n]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(363);module.exports=n})();
1
+ (()=>{var e={363:(e,t,n)=>{let r={};r["__wbindgen_placeholder__"]=e.exports;let o;const{TextDecoder:a,TextEncoder:i}=n(837);let s=new a("utf-8",{ignoreBOM:true,fatal:true});s.decode();let _=null;function getUint8Memory0(){if(_===null||_.buffer!==o.memory.buffer){_=new Uint8Array(o.memory.buffer)}return _}function getStringFromWasm0(e,t){return s.decode(getUint8Memory0().subarray(e,e+t))}const c=new Array(32).fill(undefined);c.push(undefined,null,true,false);let u=c.length;function addHeapObject(e){if(u===c.length)c.push(c.length+1);const t=u;u=c[t];c[t]=e;return t}function getObject(e){return c[e]}function dropObject(e){if(e<36)return;c[e]=u;u=e}function takeObject(e){const t=getObject(e);dropObject(e);return t}let f=0;let d=new i("utf-8");const l=typeof d.encodeInto==="function"?function(e,t){return d.encodeInto(e,t)}:function(e,t){const n=d.encode(e);t.set(n);return{read:e.length,written:n.length}};function passStringToWasm0(e,t,n){if(n===undefined){const n=d.encode(e);const r=t(n.length);getUint8Memory0().subarray(r,r+n.length).set(n);f=n.length;return r}let r=e.length;let o=t(r);const a=getUint8Memory0();let i=0;for(;i<r;i++){const t=e.charCodeAt(i);if(t>127)break;a[o+i]=t}if(i!==r){if(i!==0){e=e.slice(i)}o=n(o,r,r=i+e.length*3);const t=getUint8Memory0().subarray(o+i,o+r);const a=l(e,t);i+=a.written}f=i;return o}let w=null;function getInt32Memory0(){if(w===null||w.buffer!==o.memory.buffer){w=new Int32Array(o.memory.buffer)}return w}function isLikeNone(e){return e===undefined||e===null}const g=new Uint32Array(2);const m=new BigUint64Array(g.buffer);function notDefined(e){return()=>{throw new Error(`${e} is not defined`)}}class Snowflake{static __wrap(e){const t=Object.create(Snowflake.prototype);t.ptr=e;return t}__destroy_into_raw(){const e=this.ptr;this.ptr=0;return e}free(){const e=this.__destroy_into_raw();o.__wbg_snowflake_free(e)}constructor(e){try{const a=o.__wbindgen_add_to_stack_pointer(-16);o.snowflake_new(a,isLikeNone(e)?0:addHeapObject(e));var t=getInt32Memory0()[a/4+0];var n=getInt32Memory0()[a/4+1];var r=getInt32Memory0()[a/4+2];if(r){throw takeObject(n)}return Snowflake.__wrap(t)}finally{o.__wbindgen_add_to_stack_pointer(16)}}getUniqueID(){try{const n=o.__wbindgen_add_to_stack_pointer(-16);o.snowflake_getUniqueID(n,this.ptr);var e=getInt32Memory0()[n/4+0];var t=getInt32Memory0()[n/4+1];g[0]=e;g[1]=t;const r=m[0];return r}finally{o.__wbindgen_add_to_stack_pointer(16)}}idFromTimestamp(e){try{const r=o.__wbindgen_add_to_stack_pointer(-16);o.snowflake_idFromTimestamp(r,this.ptr,e);var t=getInt32Memory0()[r/4+0];var n=getInt32Memory0()[r/4+1];g[0]=t;g[1]=n;const a=m[0];return a}finally{o.__wbindgen_add_to_stack_pointer(16)}}instanceID(){var e=o.snowflake_instanceID(this.ptr);return e}customEpoch(){var e=o.snowflake_customEpoch(this.ptr);return e}static timestampFromID(e,t){m[0]=e;const n=g[0];const r=g[1];var a=o.snowflake_timestampFromID(n,r,t);return a}static instanceIDFromID(e){m[0]=e;const t=g[0];const n=g[1];var r=o.snowflake_instanceIDFromID(t,n);return r}}e.exports.Snowflake=Snowflake;e.exports.__wbindgen_string_new=function(e,t){var n=getStringFromWasm0(e,t);return addHeapObject(n)};e.exports.__wbindgen_object_drop_ref=function(e){takeObject(e)};e.exports.__wbindgen_json_serialize=function(e,t){const n=getObject(t);var r=JSON.stringify(n===undefined?null:n);var a=passStringToWasm0(r,o.__wbindgen_malloc,o.__wbindgen_realloc);var i=f;getInt32Memory0()[e/4+1]=i;getInt32Memory0()[e/4+0]=a};e.exports.__wbg_now_e6c39c10a5e8aec7=function(){var e=Date.now();return e};e.exports.__wbg_random_7b8246250fd79f60=typeof Math.random=="function"?Math.random:notDefined("Math.random");e.exports.__wbindgen_throw=function(e,t){throw new Error(getStringFromWasm0(e,t))};const p=n.ab+"nodejs_snowflake_bg.wasm";const b=n(147).readFileSync(n.ab+"nodejs_snowflake_bg.wasm");const y=new WebAssembly.Module(b);const k=new WebAssembly.Instance(y,r);o=k.exports;e.exports.__wasm=o},147:e=>{"use strict";e.exports=require("fs")},837:e=>{"use strict";e.exports=require("util")}};var t={};function __nccwpck_require__(n){var r=t[n];if(r!==undefined){return r.exports}var o=t[n]={exports:{}};var a=true;try{e[n](o,o.exports,__nccwpck_require__);a=false}finally{if(a)delete t[n]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(363);module.exports=n})();
@@ -1 +1 @@
1
- {"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2026-02-22T12:04:03.873Z"}
1
+ {"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2026-04-27T17:02:30.860Z"}
@@ -30,6 +30,7 @@ export default class Dispatcher {
30
30
  private readonly plugin;
31
31
  private ready;
32
32
  private executing;
33
+ private preparing;
33
34
  private pending;
34
35
  private events;
35
36
  private eventsCount;
@@ -39,15 +40,15 @@ export default class Dispatcher {
39
40
  setReady(ready: boolean): void;
40
41
  getEventsCount(): number;
41
42
  trigger(workflow: WorkflowModel, context: object, options?: EventOptions): void | Promise<Processor | null>;
43
+ private prepare;
42
44
  resume(job: any): Promise<void>;
43
45
  start(execution: ExecutionModel): Promise<void>;
44
46
  beforeStop(): Promise<void>;
45
- dispatch(): Promise<void>;
47
+ dispatch(): void;
46
48
  run(pending: Pending): Promise<void>;
47
49
  private triggerSync;
48
50
  private validateEvent;
49
51
  private createExecution;
50
- private prepare;
51
52
  private acquirePendingExecution;
52
53
  private acquireQueueingExecution;
53
54
  private process;
@@ -29,22 +29,22 @@ __export(Dispatcher_exports, {
29
29
  default: () => Dispatcher
30
30
  });
31
31
  module.exports = __toCommonJS(Dispatcher_exports);
32
- var import_crypto = require("crypto");
32
+ var import_node_crypto = require("node:crypto");
33
33
  var import_sequelize = require("sequelize");
34
34
  var import_constants = require("./constants");
35
35
  var import_Plugin = require("./Plugin");
36
36
  class Dispatcher {
37
37
  constructor(plugin) {
38
38
  this.plugin = plugin;
39
- this.prepare = this.prepare.bind(this);
40
39
  }
41
40
  ready = false;
42
41
  executing = null;
42
+ preparing = null;
43
43
  pending = [];
44
44
  events = [];
45
45
  eventsCount = 0;
46
46
  get idle() {
47
- return this.ready && !this.executing && !this.pending.length && !this.events.length;
47
+ return this.ready && !this.executing && !this.preparing && !this.pending.length && !this.events.length;
48
48
  }
49
49
  onQueueExecution = async (event) => {
50
50
  const ExecutionRepo = this.plugin.db.getRepository("executions");
@@ -96,11 +96,55 @@ class Dispatcher {
96
96
  this.eventsCount = this.events.length;
97
97
  logger.info(`new event triggered, now events: ${this.events.length}`);
98
98
  logger.debug(`event data:`, { context });
99
- if (this.events.length > 1) {
100
- logger.info(`new event is pending to be prepared after previous preparation is finished`);
99
+ this.prepare();
100
+ }
101
+ prepare() {
102
+ if (this.preparing) {
101
103
  return;
102
104
  }
103
- setImmediate(this.prepare);
105
+ this.preparing = (async () => {
106
+ try {
107
+ while (this.events.length) {
108
+ if (this.executing && this.plugin.db.options.dialect === "sqlite") {
109
+ await this.executing;
110
+ }
111
+ const event = this.events.shift();
112
+ this.eventsCount = this.events.length;
113
+ if (!event) continue;
114
+ const logger = this.plugin.getLogger(event[0].id);
115
+ logger.info(`preparing execution for event`);
116
+ try {
117
+ const execution = await this.createExecution(...event);
118
+ if (!(execution == null ? void 0 : execution.dispatched)) {
119
+ if (this.plugin.serving() && !this.executing && !this.pending.length) {
120
+ logger.info(`local pending list is empty, adding execution (${execution.id}) to pending list`);
121
+ this.pending.push({ execution });
122
+ } else {
123
+ logger.info(
124
+ `instance is not serving as worker or local pending list is not empty, sending execution (${execution.id}) to queue`
125
+ );
126
+ try {
127
+ await this.plugin.app.eventQueue.publish(this.plugin.channelPendingExecution, {
128
+ executionId: execution.id
129
+ });
130
+ } catch (qErr) {
131
+ logger.error(`publishing execution (${execution.id}) to queue failed:`, { error: qErr });
132
+ }
133
+ }
134
+ }
135
+ } catch (error) {
136
+ logger.error(`failed to create execution:`, { error });
137
+ }
138
+ }
139
+ } finally {
140
+ this.preparing = null;
141
+ if (this.events.length) {
142
+ this.prepare();
143
+ } else {
144
+ this.dispatch();
145
+ }
146
+ }
147
+ })();
104
148
  }
105
149
  async resume(job) {
106
150
  let { execution } = job;
@@ -119,16 +163,26 @@ class Dispatcher {
119
163
  }
120
164
  async beforeStop() {
121
165
  this.ready = false;
122
- if (this.events.length) {
123
- await this.prepare();
124
- }
125
- if (this.executing) {
126
- await this.executing;
166
+ this.plugin.getLogger("dispatcher").info("app is stopping, draining local queues...");
167
+ while (this.preparing || this.executing || this.events.length || this.pending.length) {
168
+ if (this.preparing) {
169
+ await this.preparing;
170
+ }
171
+ if (this.executing) {
172
+ await this.executing;
173
+ }
174
+ if (this.events.length && !this.preparing) {
175
+ this.prepare();
176
+ }
177
+ if (this.pending.length && !this.executing) {
178
+ this.dispatch();
179
+ }
180
+ await new Promise((resolve) => setImmediate(resolve));
127
181
  }
182
+ this.plugin.getLogger("dispatcher").info("local queues drained");
128
183
  }
129
184
  dispatch() {
130
- if (!this.ready) {
131
- this.plugin.getLogger("dispatcher").warn(`app is not ready, new dispatching will be ignored`);
185
+ if (!this.ready && !this.pending.length && !this.events.length) {
132
186
  return;
133
187
  }
134
188
  if (this.executing) {
@@ -136,7 +190,8 @@ class Dispatcher {
136
190
  return;
137
191
  }
138
192
  if (this.events.length) {
139
- return this.prepare();
193
+ this.prepare();
194
+ return;
140
195
  }
141
196
  this.executing = (async () => {
142
197
  let next = null;
@@ -149,13 +204,15 @@ class Dispatcher {
149
204
  this.plugin.getLogger(next[0].workflowId).info(`pending execution (${next[0].id}) ready to process`);
150
205
  }
151
206
  } else {
152
- if (this.plugin.serving()) {
207
+ if (this.ready && this.plugin.serving()) {
153
208
  execution = await this.acquireQueueingExecution();
154
209
  if (execution) {
155
210
  next = [execution];
156
211
  }
157
212
  } else {
158
- this.plugin.getLogger("dispatcher").warn(`${import_Plugin.WORKER_JOB_WORKFLOW_PROCESS} is not serving on this instance, new dispatching will be ignored`);
213
+ this.plugin.getLogger("dispatcher").warn(
214
+ `${import_Plugin.WORKER_JOB_WORKFLOW_PROCESS} is not serving on this instance or app not ready, new dispatching will be ignored`
215
+ );
159
216
  }
160
217
  }
161
218
  if (next) {
@@ -233,7 +290,7 @@ class Dispatcher {
233
290
  {
234
291
  context,
235
292
  key: workflow.key,
236
- eventKey: options.eventKey ?? (0, import_crypto.randomUUID)(),
293
+ eventKey: options.eventKey ?? (0, import_node_crypto.randomUUID)(),
237
294
  stack: options.stack,
238
295
  dispatched: deferred ?? false,
239
296
  status: deferred ? import_constants.EXECUTION_STATUS.STARTED : import_constants.EXECUTION_STATUS.QUEUEING,
@@ -268,50 +325,6 @@ class Dispatcher {
268
325
  execution.workflow = workflow;
269
326
  return execution;
270
327
  }
271
- prepare = async () => {
272
- if (this.executing && this.plugin.db.options.dialect === "sqlite") {
273
- await this.executing;
274
- }
275
- const event = this.events.shift();
276
- this.eventsCount = this.events.length;
277
- if (!event) {
278
- this.plugin.getLogger("dispatcher").info(`events queue is empty, no need to prepare`);
279
- return;
280
- }
281
- const logger = this.plugin.getLogger(event[0].id);
282
- logger.info(`preparing execution for event`);
283
- try {
284
- const execution = await this.createExecution(...event);
285
- if (!(execution == null ? void 0 : execution.dispatched)) {
286
- if (this.plugin.serving() && !this.executing && !this.pending.length) {
287
- logger.info(`local pending list is empty, adding execution (${execution.id}) to pending list`);
288
- this.pending.push({ execution });
289
- } else {
290
- logger.info(
291
- `instance is not serving as worker or local pending list is not empty, sending execution (${execution.id}) to queue`
292
- );
293
- try {
294
- await this.plugin.app.eventQueue.publish(this.plugin.channelPendingExecution, {
295
- executionId: execution.id
296
- });
297
- } catch (qErr) {
298
- logger.error(`publishing execution (${execution.id}) to queue failed:`, { error: qErr });
299
- }
300
- }
301
- }
302
- } catch (error) {
303
- logger.error(`failed to create execution:`, { error });
304
- }
305
- if (this.events.length) {
306
- await this.prepare();
307
- } else {
308
- this.plugin.getLogger("dispatcher").info("no more events need to be prepared, dispatching...");
309
- if (this.executing) {
310
- await this.executing;
311
- }
312
- this.dispatch();
313
- }
314
- };
315
328
  async acquirePendingExecution(execution) {
316
329
  const logger = this.plugin.getLogger(execution.workflowId);
317
330
  const isolationLevel = this.plugin.db.options.dialect === "sqlite" ? [][0] : import_sequelize.Transaction.ISOLATION_LEVELS.REPEATABLE_READ;
@@ -56,6 +56,7 @@ export default class PluginWorkflowServer extends Plugin {
56
56
  }): void;
57
57
  private initTriggers;
58
58
  private initInstructions;
59
+ private registerErrorHandlers;
59
60
  beforeLoad(): Promise<void>;
60
61
  /**
61
62
  * @internal
@@ -42,13 +42,15 @@ __export(Plugin_exports, {
42
42
  module.exports = __toCommonJS(Plugin_exports);
43
43
  var import_path = __toESM(require("path"));
44
44
  var import_nodejs_snowflake = require("nodejs-snowflake");
45
- var import_lru_cache = __toESM(require("lru-cache"));
45
+ var import_lru_cache = require("lru-cache");
46
46
  var import_database = require("@nocobase/database");
47
47
  var import_server = require("@nocobase/server");
48
48
  var import_utils = require("@nocobase/utils");
49
49
  var import_Dispatcher = __toESM(require("./Dispatcher"));
50
50
  var import_Processor = __toESM(require("./Processor"));
51
51
  var import_actions = __toESM(require("./actions"));
52
+ var import_nodes = require("./actions/nodes");
53
+ var import_workflows = require("./actions/workflows");
52
54
  var import_functions = __toESM(require("./functions"));
53
55
  var import_CollectionTrigger = __toESM(require("./triggers/CollectionTrigger"));
54
56
  var import_ScheduleTrigger = __toESM(require("./triggers/ScheduleTrigger"));
@@ -280,6 +282,29 @@ class PluginWorkflowServer extends import_server.Plugin {
280
282
  this.registerInstruction(name, instruction);
281
283
  }
282
284
  }
285
+ registerErrorHandlers() {
286
+ const PluginErrorHandler = this.app.pm.get("error-handler");
287
+ if (PluginErrorHandler == null ? void 0 : PluginErrorHandler.errorHandler) {
288
+ PluginErrorHandler.errorHandler.register(
289
+ (err) => err instanceof import_nodes.NodeValidationError || err.name === "NodeValidationError",
290
+ (err, ctx) => {
291
+ ctx.status = err.status;
292
+ ctx.body = {
293
+ errors: Object.values(err.errors).map((message) => ({ message }))
294
+ };
295
+ }
296
+ );
297
+ PluginErrorHandler.errorHandler.register(
298
+ (err) => err instanceof import_workflows.WorkflowValidationError || err.name === "WorkflowValidationError",
299
+ (err, ctx) => {
300
+ ctx.status = err.status;
301
+ ctx.body = {
302
+ errors: Object.values(err.errors).map((message) => ({ message }))
303
+ };
304
+ }
305
+ );
306
+ }
307
+ }
283
308
  async beforeLoad() {
284
309
  this.db.registerRepositories({
285
310
  WorkflowRepository: import_WorkflowRepository.default
@@ -302,10 +327,11 @@ class PluginWorkflowServer extends import_server.Plugin {
302
327
  this.initTriggers(options.triggers);
303
328
  this.initInstructions(options.instructions);
304
329
  (0, import_functions.default)(this, options.functions);
330
+ this.registerErrorHandlers();
305
331
  this.functions.register("instanceId", () => this.app.instanceId);
306
332
  this.functions.register("epoch", () => 1605024e3);
307
333
  this.functions.register("genSnowflakeId", () => this.app.snowflakeIdGenerator.generate());
308
- this.loggerCache = new import_lru_cache.default({
334
+ this.loggerCache = new import_lru_cache.LRUCache({
309
335
  max: 20,
310
336
  updateAgeOnGet: true,
311
337
  dispose(logger) {
@@ -350,7 +376,6 @@ class PluginWorkflowServer extends import_server.Plugin {
350
376
  actions: ["workflows:list"]
351
377
  });
352
378
  this.app.acl.allow("userWorkflowTasks", "listMine", "loggedIn");
353
- this.app.acl.allow("*", ["trigger"], "loggedIn");
354
379
  db.on("workflows.beforeSave", this.onBeforeSave);
355
380
  db.on("workflows.afterCreate", this.onAfterCreate);
356
381
  db.on("workflows.afterUpdate", this.onAfterUpdate);
@@ -7,6 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { Context } from '@nocobase/actions';
10
+ export declare class NodeValidationError extends Error {
11
+ status: number;
12
+ errors: Record<string, string>;
13
+ constructor(errors: Record<string, string>);
14
+ }
10
15
  export declare function create(context: Context, next: any): Promise<void>;
11
16
  export declare function duplicate(context: Context, next: any): Promise<void>;
12
17
  export declare function destroy(context: Context, next: any): Promise<void>;
@@ -36,6 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var nodes_exports = {};
38
38
  __export(nodes_exports, {
39
+ NodeValidationError: () => NodeValidationError,
39
40
  create: () => create,
40
41
  destroy: () => destroy,
41
42
  destroyBranch: () => destroyBranch,
@@ -48,6 +49,35 @@ module.exports = __toCommonJS(nodes_exports);
48
49
  var import_actions = require("@nocobase/actions");
49
50
  var import_database = require("@nocobase/database");
50
51
  var import__ = __toESM(require(".."));
52
+ class NodeValidationError extends Error {
53
+ status = 400;
54
+ errors;
55
+ constructor(errors) {
56
+ super("Node validation failed");
57
+ this.name = "NodeValidationError";
58
+ this.errors = errors;
59
+ }
60
+ }
61
+ function validateNode(context, workflow, values) {
62
+ const { type, config } = values;
63
+ if (!type) {
64
+ context.throw(400, "Node type is required");
65
+ }
66
+ const workflowPlugin = context.app.pm.get(import__.default);
67
+ const instruction = workflowPlugin.instructions.get(type);
68
+ if (!instruction) {
69
+ context.throw(400, `Node type "${type}" is not registered`);
70
+ }
71
+ if (workflow && typeof instruction.isAvailable === "function" && !instruction.isAvailable(workflow, values)) {
72
+ context.throw(400, `Node type "${type}" is not available in the current workflow`);
73
+ }
74
+ if (config && typeof instruction.validateConfig === "function") {
75
+ const errors = instruction.validateConfig(config);
76
+ if (errors) {
77
+ throw new NodeValidationError(errors);
78
+ }
79
+ }
80
+ }
51
81
  async function create(context, next) {
52
82
  const { db } = context;
53
83
  const repository = import_actions.utils.getRepositoryFromParams(context);
@@ -61,6 +91,7 @@ async function create(context, next) {
61
91
  if (workflow.versionStats.executed > 0) {
62
92
  context.throw(400, "Node could not be created in executed workflow");
63
93
  }
94
+ validateNode(context, workflow, values);
64
95
  const NODES_LIMIT = process.env.WORKFLOW_NODES_LIMIT ? parseInt(process.env.WORKFLOW_NODES_LIMIT, 10) : null;
65
96
  if (NODES_LIMIT) {
66
97
  const nodesCount = await workflow.countNodes({ transaction });
@@ -617,15 +648,18 @@ async function update(context, next) {
617
648
  const { db } = context;
618
649
  const repository = import_actions.utils.getRepositoryFromParams(context);
619
650
  const { filterByTk, values, whitelist, blacklist, filter, updateAssociationValues } = context.action.params;
651
+ const workflowPlugin = context.app.pm.get(import__.default);
620
652
  context.body = await db.sequelize.transaction(async (transaction) => {
621
- const { workflow } = await repository.findOne({
653
+ const instance = await repository.findOne({
622
654
  filterByTk,
623
655
  appends: ["workflow.versionStats.executed"],
624
656
  transaction
625
657
  });
626
- if (workflow.versionStats.executed > 0) {
658
+ if (instance.workflow.versionStats.executed > 0) {
627
659
  context.throw(400, "Nodes in executed workflow could not be reconfigured");
628
660
  }
661
+ const merged = Object.assign({}, instance.get(), values);
662
+ validateNode(context, null, merged);
629
663
  return repository.update({
630
664
  filterByTk,
631
665
  values,
@@ -644,12 +678,10 @@ async function test(context, next) {
644
678
  const { type, config = {} } = values;
645
679
  const plugin = context.app.pm.get(import__.default);
646
680
  const instruction = plugin.instructions.get(type);
647
- if (!instruction) {
648
- context.throw(400, `instruction "${type}" not registered`);
649
- }
650
681
  if (typeof instruction.test !== "function") {
651
682
  context.throw(400, `test method of instruction "${type}" not implemented`);
652
683
  }
684
+ validateNode(context, null, values);
653
685
  try {
654
686
  context.body = await instruction.test(config);
655
687
  } catch (error) {
@@ -659,6 +691,7 @@ async function test(context, next) {
659
691
  }
660
692
  // Annotate the CommonJS export names for ESM import in node:
661
693
  0 && (module.exports = {
694
+ NodeValidationError,
662
695
  create,
663
696
  destroy,
664
697
  destroyBranch,
@@ -7,6 +7,12 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { Context } from '@nocobase/actions';
10
+ export declare class WorkflowValidationError extends Error {
11
+ status: number;
12
+ errors: Record<string, string>;
13
+ constructor(errors: Record<string, string>);
14
+ }
15
+ export declare function create(context: Context, next: any): Promise<void>;
10
16
  export declare function update(context: Context, next: any): Promise<void>;
11
17
  export declare function destroy(context: Context, next: any): Promise<void>;
12
18
  export declare function revision(context: Context, next: any): Promise<void>;
@@ -36,6 +36,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var workflows_exports = {};
38
38
  __export(workflows_exports, {
39
+ WorkflowValidationError: () => WorkflowValidationError,
40
+ create: () => create,
39
41
  destroy: () => destroy,
40
42
  execute: () => execute,
41
43
  revision: () => revision,
@@ -46,7 +48,38 @@ module.exports = __toCommonJS(workflows_exports);
46
48
  var import_actions = __toESM(require("@nocobase/actions"));
47
49
  var import_database = require("@nocobase/database");
48
50
  var import_Plugin = __toESM(require("../Plugin"));
51
+ class WorkflowValidationError extends Error {
52
+ status = 400;
53
+ errors;
54
+ constructor(errors) {
55
+ super("Workflow validation failed");
56
+ this.name = "WorkflowValidationError";
57
+ this.errors = errors;
58
+ }
59
+ }
60
+ function validateWorkflow(context, plugin, { type, config }) {
61
+ if (!type) {
62
+ context.throw(400, "Trigger type is required");
63
+ }
64
+ const trigger = plugin.triggers.get(type);
65
+ if (!trigger) {
66
+ context.throw(400, `Trigger type "${type}" is not registered`);
67
+ }
68
+ if (config && typeof trigger.validateConfig === "function") {
69
+ const errors = trigger.validateConfig(config);
70
+ if (errors) {
71
+ throw new WorkflowValidationError(errors);
72
+ }
73
+ }
74
+ }
75
+ async function create(context, next) {
76
+ const plugin = context.app.pm.get(import_Plugin.default);
77
+ const { values } = context.action.params;
78
+ validateWorkflow(context, plugin, values);
79
+ return import_actions.default.create(context, next);
80
+ }
49
81
  async function update(context, next) {
82
+ const plugin = context.app.pm.get(import_Plugin.default);
50
83
  const repository = import_actions.utils.getRepositoryFromParams(context);
51
84
  const { filterByTk, values } = context.action.params;
52
85
  context.action.mergeParams({
@@ -60,6 +93,9 @@ async function update(context, next) {
60
93
  if (workflow.versionStats.executed > 0) {
61
94
  return context.throw(400, "config of executed workflow can not be updated");
62
95
  }
96
+ const type = values.type ?? workflow.type;
97
+ const config = values.config ?? workflow.config;
98
+ validateWorkflow(context, plugin, { type, config });
63
99
  }
64
100
  return import_actions.default.update(context, next);
65
101
  }
@@ -180,6 +216,8 @@ async function execute(context, next) {
180
216
  }
181
217
  // Annotate the CommonJS export names for ESM import in node:
182
218
  0 && (module.exports = {
219
+ WorkflowValidationError,
220
+ create,
183
221
  destroy,
184
222
  execute,
185
223
  revision,
@@ -6,6 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ import Joi from 'joi';
9
10
  import { Instruction } from '.';
10
11
  import type Processor from '../Processor';
11
12
  import type { FlowNodeModel, JobModel } from '../types';
@@ -15,6 +16,7 @@ export declare const BRANCH_INDEX: {
15
16
  readonly ON_FALSE: 0;
16
17
  };
17
18
  export declare class ConditionInstruction extends Instruction {
19
+ configSchema: Joi.ObjectSchema<any>;
18
20
  run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<{
19
21
  status: 1;
20
22
  result: boolean;