@powerhousedao/workflow 6.2.3-dev.79 → 6.2.3-dev.80

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 (97) hide show
  1. package/dist/browser/BlockSelector-DFX-DZHl.js.map +1 -1
  2. package/dist/browser/document-models/index.js +2 -2
  3. package/dist/browser/document-models/workflow/index.js +3 -3
  4. package/dist/browser/{document-models-B2IDRvBZ.js → document-models-DUSvG-I2.js} +2 -2
  5. package/dist/browser/{document-models-B2IDRvBZ.js.map → document-models-DUSvG-I2.js.map} +1 -1
  6. package/dist/browser/{editor-B1-_KRbr.js → editor-BhHN0OWh.js} +2 -2
  7. package/dist/browser/{editor-B1-_KRbr.js.map → editor-BhHN0OWh.js.map} +1 -1
  8. package/dist/browser/{editor-DPGuck1V.js → editor-CnW8q20z.js} +8 -8
  9. package/dist/browser/editor-CnW8q20z.js.map +1 -0
  10. package/dist/browser/{editor-DBcq58Fr.js → editor-NLSJ5rWx.js} +10 -7
  11. package/dist/browser/editor-NLSJ5rWx.js.map +1 -0
  12. package/dist/browser/editors/connection-editor/module.js +1 -1
  13. package/dist/browser/editors/workflow-editor/module.js +1 -1
  14. package/dist/browser/editors/workflow-studio/module.js +1 -1
  15. package/dist/browser/index.js +2 -2
  16. package/dist/browser/{module-DFCANOuI.js → module-DxRdnkW2.js} +47 -5
  17. package/dist/browser/module-DxRdnkW2.js.map +1 -0
  18. package/dist/browser/reactor/index.js +2 -2
  19. package/dist/browser/{trigger-text-B2mo1fiB.js → trigger-text-BIeZ9W1H.js} +22 -2
  20. package/dist/browser/trigger-text-BIeZ9W1H.js.map +1 -0
  21. package/dist/browser/{upgrade-manifests-B62uqKVp.js → upgrade-manifests-bahiFXsr.js} +2 -2
  22. package/dist/browser/{upgrade-manifests-B62uqKVp.js.map → upgrade-manifests-bahiFXsr.js.map} +1 -1
  23. package/dist/browser/{workflow-DjTleFFO.js → workflow-DZt1eS1f.js} +4 -3
  24. package/dist/browser/workflow-DZt1eS1f.js.map +1 -0
  25. package/dist/node/BlockSelector-DosVPXzD.mjs.map +1 -1
  26. package/dist/node/document-models/index.mjs +2 -2
  27. package/dist/node/document-models/workflow/index.mjs +3 -3
  28. package/dist/node/{editor-DM9cnkfv.mjs → editor-C3OhQ_xs.mjs} +10 -7
  29. package/dist/node/editor-C3OhQ_xs.mjs.map +1 -0
  30. package/dist/node/{editor-BIpWFiaF.mjs → editor-D4-ZHfHJ.mjs} +2 -2
  31. package/dist/node/{editor-BIpWFiaF.mjs.map → editor-D4-ZHfHJ.mjs.map} +1 -1
  32. package/dist/node/{editor-DF1FOgnC.mjs → editor-D9S3pWvR.mjs} +8 -8
  33. package/dist/node/editor-D9S3pWvR.mjs.map +1 -0
  34. package/dist/node/editors/connection-editor/module.mjs +1 -1
  35. package/dist/node/editors/workflow-editor/module.mjs +1 -1
  36. package/dist/node/editors/workflow-studio/module.mjs +1 -1
  37. package/dist/node/index.mjs +2 -2
  38. package/dist/node/{module-DV3LLvxo.mjs → module-D9Zx5Zow.mjs} +47 -5
  39. package/dist/node/module-D9Zx5Zow.mjs.map +1 -0
  40. package/dist/node/pieces/reactor/descriptor.json +37 -2
  41. package/dist/node/pieces/reactor/index.mjs +1 -1
  42. package/dist/node/pieces/reactor/package.json +2 -2
  43. package/dist/node/{trigger-text-BRqIHmRS.mjs → trigger-text-CmYejeFN.mjs} +22 -2
  44. package/dist/node/trigger-text-CmYejeFN.mjs.map +1 -0
  45. package/dist/node/{upgrade-manifests-CO9zzPnE.mjs → upgrade-manifests-VF8Jt_YR.mjs} +2 -2
  46. package/dist/node/{upgrade-manifests-CO9zzPnE.mjs.map → upgrade-manifests-VF8Jt_YR.mjs.map} +1 -1
  47. package/dist/node/{workflow-BS5m4jtr.mjs → workflow-DqF9VsBQ.mjs} +4 -3
  48. package/dist/node/workflow-DqF9VsBQ.mjs.map +1 -0
  49. package/dist/powerhouse.manifest.json +2 -2
  50. package/dist/style.css +1 -1
  51. package/dist/types/document-models/document-models.d.ts +1 -0
  52. package/dist/types/document-models/document-models.d.ts.map +1 -1
  53. package/dist/types/document-models/workflow/v1/actions.d.ts +1 -0
  54. package/dist/types/document-models/workflow/v1/actions.d.ts.map +1 -1
  55. package/dist/types/document-models/workflow/v1/gen/document-model.d.ts.map +1 -1
  56. package/dist/types/document-models/workflow/v1/gen/document-schema.d.ts +3 -0
  57. package/dist/types/document-models/workflow/v1/gen/document-schema.d.ts.map +1 -1
  58. package/dist/types/document-models/workflow/v1/gen/ph-factories.d.ts.map +1 -1
  59. package/dist/types/document-models/workflow/v1/gen/reducer.d.ts.map +1 -1
  60. package/dist/types/document-models/workflow/v1/gen/schema/types.d.ts +16 -0
  61. package/dist/types/document-models/workflow/v1/gen/schema/types.d.ts.map +1 -1
  62. package/dist/types/document-models/workflow/v1/gen/schema/zod.d.ts +3 -1
  63. package/dist/types/document-models/workflow/v1/gen/schema/zod.d.ts.map +1 -1
  64. package/dist/types/document-models/workflow/v1/gen/utils.d.ts.map +1 -1
  65. package/dist/types/document-models/workflow/v1/gen/workflow/actions.d.ts +6 -2
  66. package/dist/types/document-models/workflow/v1/gen/workflow/actions.d.ts.map +1 -1
  67. package/dist/types/document-models/workflow/v1/gen/workflow/creators.d.ts +3 -2
  68. package/dist/types/document-models/workflow/v1/gen/workflow/creators.d.ts.map +1 -1
  69. package/dist/types/document-models/workflow/v1/gen/workflow/operations.d.ts +2 -1
  70. package/dist/types/document-models/workflow/v1/gen/workflow/operations.d.ts.map +1 -1
  71. package/dist/types/document-models/workflow/v1/module.d.ts +1 -0
  72. package/dist/types/document-models/workflow/v1/module.d.ts.map +1 -1
  73. package/dist/types/document-models/workflow/v1/src/reducers/workflow.d.ts.map +1 -1
  74. package/dist/types/document-models/workflow/v1/tests/managed-by.test.d.ts +2 -0
  75. package/dist/types/document-models/workflow/v1/tests/managed-by.test.d.ts.map +1 -0
  76. package/dist/types/editors/shared/DocumentErrorBoundary.d.ts.map +1 -1
  77. package/dist/types/editors/workflow-editor/document/useWorkflowModel.d.ts.map +1 -1
  78. package/dist/types/editors/workflow-editor/ui/PublishControls.d.ts +4 -0
  79. package/dist/types/editors/workflow-editor/ui/PublishControls.d.ts.map +1 -1
  80. package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts.map +1 -1
  81. package/dist/types/editors/workflow-editor/ui/model.d.ts +5 -0
  82. package/dist/types/editors/workflow-editor/ui/model.d.ts.map +1 -1
  83. package/dist/types/pieces/reactor/index.d.ts.map +1 -1
  84. package/dist/types/pieces/reactor/lib/actions/index-query.d.ts +12 -0
  85. package/dist/types/pieces/reactor/lib/actions/index-query.d.ts.map +1 -0
  86. package/dist/types/pieces/reactor/lib/input-schema.d.ts.map +1 -1
  87. package/package.json +8 -8
  88. package/dist/browser/editor-DBcq58Fr.js.map +0 -1
  89. package/dist/browser/editor-DPGuck1V.js.map +0 -1
  90. package/dist/browser/module-DFCANOuI.js.map +0 -1
  91. package/dist/browser/trigger-text-B2mo1fiB.js.map +0 -1
  92. package/dist/browser/workflow-DjTleFFO.js.map +0 -1
  93. package/dist/node/editor-DF1FOgnC.mjs.map +0 -1
  94. package/dist/node/editor-DM9cnkfv.mjs.map +0 -1
  95. package/dist/node/module-DV3LLvxo.mjs.map +0 -1
  96. package/dist/node/trigger-text-BRqIHmRS.mjs.map +0 -1
  97. package/dist/node/workflow-BS5m4jtr.mjs.map +0 -1
@@ -267,4 +267,4 @@ function i(e){let t=a(e);if(t)throw t;return e}function a(e){if(typeof e==`strin
267
267
  /* c8 ignore next 3 */
268
268
  (0,n.invariant)(!1,`Unexpected type: `+(0,t.inspect)(e))}function T(e,t){let r=(0,s.astFromValue)(e,t);return r??(0,n.invariant)(!1),(0,i.print)((0,c.sortValueNode)(r))}function E(e,t){let n=[],i=[],a=[],o=(0,r.keyMap)(e,({name:e})=>e),s=(0,r.keyMap)(t,({name:e})=>e);for(let t of e){let e=s[t.name];e===void 0?i.push(t):a.push([t,e])}for(let e of t)o[e.name]===void 0&&n.push(e);return{added:n,persisted:a,removed:i}}})),co=/* @__PURE__ */ t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveASTSchemaCoordinate=d,e.resolveSchemaCoordinate=a;var t=Q(),n=Z(),r=mi(),i=$();function a(e,t){return d(e,(0,r.parseSchemaCoordinate)(t))}function o(e,t){let n=t.name.value,r=e.getType(n);if(r!=null)return{kind:`NamedType`,type:r}}function s(e,n){let r=n.name.value,a=e.getType(r);if(!a)throw Error(`Expected ${(0,t.inspect)(r)} to be defined as a type in the schema.`);if(!(0,i.isEnumType)(a)&&!(0,i.isInputObjectType)(a)&&!(0,i.isObjectType)(a)&&!(0,i.isInterfaceType)(a))throw Error(`Expected ${(0,t.inspect)(r)} to be an Enum, Input Object, Object or Interface type.`);if((0,i.isEnumType)(a)){let e=n.memberName.value,t=a.getValue(e);return t==null?void 0:{kind:`EnumValue`,type:a,enumValue:t}}if((0,i.isInputObjectType)(a)){let e=n.memberName.value,t=a.getFields()[e];return t==null?void 0:{kind:`InputField`,type:a,inputField:t}}let o=n.memberName.value,s=a.getFields()[o];if(s!=null)return{kind:`Field`,type:a,field:s}}function c(e,n){let r=n.name.value,a=e.getType(r);if(a==null)throw Error(`Expected ${(0,t.inspect)(r)} to be defined as a type in the schema.`);if(!(0,i.isObjectType)(a)&&!(0,i.isInterfaceType)(a))throw Error(`Expected ${(0,t.inspect)(r)} to be an object type or interface type.`);let o=n.fieldName.value,s=a.getFields()[o];if(s==null)throw Error(`Expected ${(0,t.inspect)(o)} to exist as a field of type ${(0,t.inspect)(r)} in the schema.`);let c=n.argumentName.value,l=s.args.find(e=>e.name===c);if(l!=null)return{kind:`FieldArgument`,type:a,field:s,fieldArgument:l}}function l(e,t){let n=t.name.value,r=e.getDirective(n);if(r)return{kind:`Directive`,directive:r}}function u(e,n){let r=n.name.value,i=e.getDirective(r);if(!i)throw Error(`Expected ${(0,t.inspect)(r)} to be defined as a directive in the schema.`);let{argumentName:{value:a}}=n,o=i.args.find(e=>e.name===a);if(o)return{kind:`DirectiveArgument`,directive:i,directiveArgument:o}}function d(e,t){switch(t.kind){case n.Kind.TYPE_COORDINATE:return o(e,t);case n.Kind.MEMBER_COORDINATE:return s(e,t);case n.Kind.ARGUMENT_COORDINATE:return c(e,t);case n.Kind.DIRECTIVE_COORDINATE:return l(e,t);case n.Kind.DIRECTIVE_ARGUMENT_COORDINATE:return u(e,t)}}})),lo=/* @__PURE__ */ t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BreakingChangeType",{enumerable:!0,get:function(){return x.BreakingChangeType}}),Object.defineProperty(e,"DangerousChangeType",{enumerable:!0,get:function(){return x.DangerousChangeType}}),Object.defineProperty(e,"TypeInfo",{enumerable:!0,get:function(){return m.TypeInfo}}),Object.defineProperty(e,"assertValidName",{enumerable:!0,get:function(){return b.assertValidName}}),Object.defineProperty(e,"astFromValue",{enumerable:!0,get:function(){return p.astFromValue}}),Object.defineProperty(e,"buildASTSchema",{enumerable:!0,get:function(){return o.buildASTSchema}}),Object.defineProperty(e,"buildClientSchema",{enumerable:!0,get:function(){return a.buildClientSchema}}),Object.defineProperty(e,"buildSchema",{enumerable:!0,get:function(){return o.buildSchema}}),Object.defineProperty(e,"coerceInputValue",{enumerable:!0,get:function(){return h.coerceInputValue}}),Object.defineProperty(e,"concatAST",{enumerable:!0,get:function(){return g.concatAST}}),Object.defineProperty(e,"doTypesOverlap",{enumerable:!0,get:function(){return y.doTypesOverlap}}),Object.defineProperty(e,"extendSchema",{enumerable:!0,get:function(){return s.extendSchema}}),Object.defineProperty(e,"findBreakingChanges",{enumerable:!0,get:function(){return x.findBreakingChanges}}),Object.defineProperty(e,"findDangerousChanges",{enumerable:!0,get:function(){return x.findDangerousChanges}}),Object.defineProperty(e,"getIntrospectionQuery",{enumerable:!0,get:function(){return t.getIntrospectionQuery}}),Object.defineProperty(e,"getOperationAST",{enumerable:!0,get:function(){return n.getOperationAST}}),Object.defineProperty(e,"getOperationRootType",{enumerable:!0,get:function(){return r.getOperationRootType}}),Object.defineProperty(e,"introspectionFromSchema",{enumerable:!0,get:function(){return i.introspectionFromSchema}}),Object.defineProperty(e,"isEqualType",{enumerable:!0,get:function(){return y.isEqualType}}),Object.defineProperty(e,"isTypeSubTypeOf",{enumerable:!0,get:function(){return y.isTypeSubTypeOf}}),Object.defineProperty(e,"isValidNameError",{enumerable:!0,get:function(){return b.isValidNameError}}),Object.defineProperty(e,"lexicographicSortSchema",{enumerable:!0,get:function(){return c.lexicographicSortSchema}}),Object.defineProperty(e,"printIntrospectionSchema",{enumerable:!0,get:function(){return l.printIntrospectionSchema}}),Object.defineProperty(e,"printSchema",{enumerable:!0,get:function(){return l.printSchema}}),Object.defineProperty(e,"printType",{enumerable:!0,get:function(){return l.printType}}),Object.defineProperty(e,"resolveASTSchemaCoordinate",{enumerable:!0,get:function(){return S.resolveASTSchemaCoordinate}}),Object.defineProperty(e,"resolveSchemaCoordinate",{enumerable:!0,get:function(){return S.resolveSchemaCoordinate}}),Object.defineProperty(e,"separateOperations",{enumerable:!0,get:function(){return _.separateOperations}}),Object.defineProperty(e,"stripIgnoredCharacters",{enumerable:!0,get:function(){return v.stripIgnoredCharacters}}),Object.defineProperty(e,"typeFromAST",{enumerable:!0,get:function(){return u.typeFromAST}}),Object.defineProperty(e,"valueFromAST",{enumerable:!0,get:function(){return d.valueFromAST}}),Object.defineProperty(e,"valueFromASTUntyped",{enumerable:!0,get:function(){return f.valueFromASTUntyped}}),Object.defineProperty(e,"visitWithTypeInfo",{enumerable:!0,get:function(){return m.visitWithTypeInfo}});var t=Ja(),n=Ya(),r=Xa(),i=Za(),a=Qa(),o=eo(),s=$a(),c=to(),l=no(),u=Ii(),d=ca(),f=Ei(),p=Mi(),m=Li(),h=sa(),g=ro(),_=io(),v=ao(),y=Oi(),b=oo(),x=so(),S=co()})),uo=(/* @__PURE__ */ t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BREAK",{enumerable:!0,get:function(){return i.BREAK}}),Object.defineProperty(e,"BreakingChangeType",{enumerable:!0,get:function(){return c.BreakingChangeType}}),Object.defineProperty(e,"DEFAULT_DEPRECATION_REASON",{enumerable:!0,get:function(){return r.DEFAULT_DEPRECATION_REASON}}),Object.defineProperty(e,"DangerousChangeType",{enumerable:!0,get:function(){return c.DangerousChangeType}}),Object.defineProperty(e,"DirectiveLocation",{enumerable:!0,get:function(){return i.DirectiveLocation}}),Object.defineProperty(e,"ExecutableDefinitionsRule",{enumerable:!0,get:function(){return o.ExecutableDefinitionsRule}}),Object.defineProperty(e,"FieldsOnCorrectTypeRule",{enumerable:!0,get:function(){return o.FieldsOnCorrectTypeRule}}),Object.defineProperty(e,"FragmentsOnCompositeTypesRule",{enumerable:!0,get:function(){return o.FragmentsOnCompositeTypesRule}}),Object.defineProperty(e,"GRAPHQL_MAX_INT",{enumerable:!0,get:function(){return r.GRAPHQL_MAX_INT}}),Object.defineProperty(e,"GRAPHQL_MIN_INT",{enumerable:!0,get:function(){return r.GRAPHQL_MIN_INT}}),Object.defineProperty(e,"GraphQLBoolean",{enumerable:!0,get:function(){return r.GraphQLBoolean}}),Object.defineProperty(e,"GraphQLDeprecatedDirective",{enumerable:!0,get:function(){return r.GraphQLDeprecatedDirective}}),Object.defineProperty(e,"GraphQLDirective",{enumerable:!0,get:function(){return r.GraphQLDirective}}),Object.defineProperty(e,"GraphQLEnumType",{enumerable:!0,get:function(){return r.GraphQLEnumType}}),Object.defineProperty(e,"GraphQLError",{enumerable:!0,get:function(){return s.GraphQLError}}),Object.defineProperty(e,"GraphQLFloat",{enumerable:!0,get:function(){return r.GraphQLFloat}}),Object.defineProperty(e,"GraphQLID",{enumerable:!0,get:function(){return r.GraphQLID}}),Object.defineProperty(e,"GraphQLIncludeDirective",{enumerable:!0,get:function(){return r.GraphQLIncludeDirective}}),Object.defineProperty(e,"GraphQLInputObjectType",{enumerable:!0,get:function(){return r.GraphQLInputObjectType}}),Object.defineProperty(e,"GraphQLInt",{enumerable:!0,get:function(){return r.GraphQLInt}}),Object.defineProperty(e,"GraphQLInterfaceType",{enumerable:!0,get:function(){return r.GraphQLInterfaceType}}),Object.defineProperty(e,"GraphQLList",{enumerable:!0,get:function(){return r.GraphQLList}}),Object.defineProperty(e,"GraphQLNonNull",{enumerable:!0,get:function(){return r.GraphQLNonNull}}),Object.defineProperty(e,"GraphQLObjectType",{enumerable:!0,get:function(){return r.GraphQLObjectType}}),Object.defineProperty(e,"GraphQLOneOfDirective",{enumerable:!0,get:function(){return r.GraphQLOneOfDirective}}),Object.defineProperty(e,"GraphQLScalarType",{enumerable:!0,get:function(){return r.GraphQLScalarType}}),Object.defineProperty(e,"GraphQLSchema",{enumerable:!0,get:function(){return r.GraphQLSchema}}),Object.defineProperty(e,"GraphQLSkipDirective",{enumerable:!0,get:function(){return r.GraphQLSkipDirective}}),Object.defineProperty(e,"GraphQLSpecifiedByDirective",{enumerable:!0,get:function(){return r.GraphQLSpecifiedByDirective}}),Object.defineProperty(e,"GraphQLString",{enumerable:!0,get:function(){return r.GraphQLString}}),Object.defineProperty(e,"GraphQLUnionType",{enumerable:!0,get:function(){return r.GraphQLUnionType}}),Object.defineProperty(e,"Kind",{enumerable:!0,get:function(){return i.Kind}}),Object.defineProperty(e,"KnownArgumentNamesRule",{enumerable:!0,get:function(){return o.KnownArgumentNamesRule}}),Object.defineProperty(e,"KnownDirectivesRule",{enumerable:!0,get:function(){return o.KnownDirectivesRule}}),Object.defineProperty(e,"KnownFragmentNamesRule",{enumerable:!0,get:function(){return o.KnownFragmentNamesRule}}),Object.defineProperty(e,"KnownTypeNamesRule",{enumerable:!0,get:function(){return o.KnownTypeNamesRule}}),Object.defineProperty(e,"Lexer",{enumerable:!0,get:function(){return i.Lexer}}),Object.defineProperty(e,"Location",{enumerable:!0,get:function(){return i.Location}}),Object.defineProperty(e,"LoneAnonymousOperationRule",{enumerable:!0,get:function(){return o.LoneAnonymousOperationRule}}),Object.defineProperty(e,"LoneSchemaDefinitionRule",{enumerable:!0,get:function(){return o.LoneSchemaDefinitionRule}}),Object.defineProperty(e,"MaxIntrospectionDepthRule",{enumerable:!0,get:function(){return o.MaxIntrospectionDepthRule}}),Object.defineProperty(e,"NoDeprecatedCustomRule",{enumerable:!0,get:function(){return o.NoDeprecatedCustomRule}}),Object.defineProperty(e,"NoFragmentCyclesRule",{enumerable:!0,get:function(){return o.NoFragmentCyclesRule}}),Object.defineProperty(e,"NoSchemaIntrospectionCustomRule",{enumerable:!0,get:function(){return o.NoSchemaIntrospectionCustomRule}}),Object.defineProperty(e,"NoUndefinedVariablesRule",{enumerable:!0,get:function(){return o.NoUndefinedVariablesRule}}),Object.defineProperty(e,"NoUnusedFragmentsRule",{enumerable:!0,get:function(){return o.NoUnusedFragmentsRule}}),Object.defineProperty(e,"NoUnusedVariablesRule",{enumerable:!0,get:function(){return o.NoUnusedVariablesRule}}),Object.defineProperty(e,"OperationTypeNode",{enumerable:!0,get:function(){return i.OperationTypeNode}}),Object.defineProperty(e,"OverlappingFieldsCanBeMergedRule",{enumerable:!0,get:function(){return o.OverlappingFieldsCanBeMergedRule}}),Object.defineProperty(e,"PossibleFragmentSpreadsRule",{enumerable:!0,get:function(){return o.PossibleFragmentSpreadsRule}}),Object.defineProperty(e,"PossibleTypeExtensionsRule",{enumerable:!0,get:function(){return o.PossibleTypeExtensionsRule}}),Object.defineProperty(e,"ProvidedRequiredArgumentsRule",{enumerable:!0,get:function(){return o.ProvidedRequiredArgumentsRule}}),Object.defineProperty(e,"ScalarLeafsRule",{enumerable:!0,get:function(){return o.ScalarLeafsRule}}),Object.defineProperty(e,"SchemaMetaFieldDef",{enumerable:!0,get:function(){return r.SchemaMetaFieldDef}}),Object.defineProperty(e,"SingleFieldSubscriptionsRule",{enumerable:!0,get:function(){return o.SingleFieldSubscriptionsRule}}),Object.defineProperty(e,"Source",{enumerable:!0,get:function(){return i.Source}}),Object.defineProperty(e,"Token",{enumerable:!0,get:function(){return i.Token}}),Object.defineProperty(e,"TokenKind",{enumerable:!0,get:function(){return i.TokenKind}}),Object.defineProperty(e,"TypeInfo",{enumerable:!0,get:function(){return c.TypeInfo}}),Object.defineProperty(e,"TypeKind",{enumerable:!0,get:function(){return r.TypeKind}}),Object.defineProperty(e,"TypeMetaFieldDef",{enumerable:!0,get:function(){return r.TypeMetaFieldDef}}),Object.defineProperty(e,"TypeNameMetaFieldDef",{enumerable:!0,get:function(){return r.TypeNameMetaFieldDef}}),Object.defineProperty(e,"UniqueArgumentDefinitionNamesRule",{enumerable:!0,get:function(){return o.UniqueArgumentDefinitionNamesRule}}),Object.defineProperty(e,"UniqueArgumentNamesRule",{enumerable:!0,get:function(){return o.UniqueArgumentNamesRule}}),Object.defineProperty(e,"UniqueDirectiveNamesRule",{enumerable:!0,get:function(){return o.UniqueDirectiveNamesRule}}),Object.defineProperty(e,"UniqueDirectivesPerLocationRule",{enumerable:!0,get:function(){return o.UniqueDirectivesPerLocationRule}}),Object.defineProperty(e,"UniqueEnumValueNamesRule",{enumerable:!0,get:function(){return o.UniqueEnumValueNamesRule}}),Object.defineProperty(e,"UniqueFieldDefinitionNamesRule",{enumerable:!0,get:function(){return o.UniqueFieldDefinitionNamesRule}}),Object.defineProperty(e,"UniqueFragmentNamesRule",{enumerable:!0,get:function(){return o.UniqueFragmentNamesRule}}),Object.defineProperty(e,"UniqueInputFieldNamesRule",{enumerable:!0,get:function(){return o.UniqueInputFieldNamesRule}}),Object.defineProperty(e,"UniqueOperationNamesRule",{enumerable:!0,get:function(){return o.UniqueOperationNamesRule}}),Object.defineProperty(e,"UniqueOperationTypesRule",{enumerable:!0,get:function(){return o.UniqueOperationTypesRule}}),Object.defineProperty(e,"UniqueTypeNamesRule",{enumerable:!0,get:function(){return o.UniqueTypeNamesRule}}),Object.defineProperty(e,"UniqueVariableNamesRule",{enumerable:!0,get:function(){return o.UniqueVariableNamesRule}}),Object.defineProperty(e,"ValidationContext",{enumerable:!0,get:function(){return o.ValidationContext}}),Object.defineProperty(e,"ValuesOfCorrectTypeRule",{enumerable:!0,get:function(){return o.ValuesOfCorrectTypeRule}}),Object.defineProperty(e,"VariablesAreInputTypesRule",{enumerable:!0,get:function(){return o.VariablesAreInputTypesRule}}),Object.defineProperty(e,"VariablesInAllowedPositionRule",{enumerable:!0,get:function(){return o.VariablesInAllowedPositionRule}}),Object.defineProperty(e,"__Directive",{enumerable:!0,get:function(){return r.__Directive}}),Object.defineProperty(e,"__DirectiveLocation",{enumerable:!0,get:function(){return r.__DirectiveLocation}}),Object.defineProperty(e,"__EnumValue",{enumerable:!0,get:function(){return r.__EnumValue}}),Object.defineProperty(e,"__Field",{enumerable:!0,get:function(){return r.__Field}}),Object.defineProperty(e,"__InputValue",{enumerable:!0,get:function(){return r.__InputValue}}),Object.defineProperty(e,"__Schema",{enumerable:!0,get:function(){return r.__Schema}}),Object.defineProperty(e,"__Type",{enumerable:!0,get:function(){return r.__Type}}),Object.defineProperty(e,"__TypeKind",{enumerable:!0,get:function(){return r.__TypeKind}}),Object.defineProperty(e,"assertAbstractType",{enumerable:!0,get:function(){return r.assertAbstractType}}),Object.defineProperty(e,"assertCompositeType",{enumerable:!0,get:function(){return r.assertCompositeType}}),Object.defineProperty(e,"assertDirective",{enumerable:!0,get:function(){return r.assertDirective}}),Object.defineProperty(e,"assertEnumType",{enumerable:!0,get:function(){return r.assertEnumType}}),Object.defineProperty(e,"assertEnumValueName",{enumerable:!0,get:function(){return r.assertEnumValueName}}),Object.defineProperty(e,"assertInputObjectType",{enumerable:!0,get:function(){return r.assertInputObjectType}}),Object.defineProperty(e,"assertInputType",{enumerable:!0,get:function(){return r.assertInputType}}),Object.defineProperty(e,"assertInterfaceType",{enumerable:!0,get:function(){return r.assertInterfaceType}}),Object.defineProperty(e,"assertLeafType",{enumerable:!0,get:function(){return r.assertLeafType}}),Object.defineProperty(e,"assertListType",{enumerable:!0,get:function(){return r.assertListType}}),Object.defineProperty(e,"assertName",{enumerable:!0,get:function(){return r.assertName}}),Object.defineProperty(e,"assertNamedType",{enumerable:!0,get:function(){return r.assertNamedType}}),Object.defineProperty(e,"assertNonNullType",{enumerable:!0,get:function(){return r.assertNonNullType}}),Object.defineProperty(e,"assertNullableType",{enumerable:!0,get:function(){return r.assertNullableType}}),Object.defineProperty(e,"assertObjectType",{enumerable:!0,get:function(){return r.assertObjectType}}),Object.defineProperty(e,"assertOutputType",{enumerable:!0,get:function(){return r.assertOutputType}}),Object.defineProperty(e,"assertScalarType",{enumerable:!0,get:function(){return r.assertScalarType}}),Object.defineProperty(e,"assertSchema",{enumerable:!0,get:function(){return r.assertSchema}}),Object.defineProperty(e,"assertType",{enumerable:!0,get:function(){return r.assertType}}),Object.defineProperty(e,"assertUnionType",{enumerable:!0,get:function(){return r.assertUnionType}}),Object.defineProperty(e,"assertValidName",{enumerable:!0,get:function(){return c.assertValidName}}),Object.defineProperty(e,"assertValidSchema",{enumerable:!0,get:function(){return r.assertValidSchema}}),Object.defineProperty(e,"assertWrappingType",{enumerable:!0,get:function(){return r.assertWrappingType}}),Object.defineProperty(e,"astFromValue",{enumerable:!0,get:function(){return c.astFromValue}}),Object.defineProperty(e,"buildASTSchema",{enumerable:!0,get:function(){return c.buildASTSchema}}),Object.defineProperty(e,"buildClientSchema",{enumerable:!0,get:function(){return c.buildClientSchema}}),Object.defineProperty(e,"buildSchema",{enumerable:!0,get:function(){return c.buildSchema}}),Object.defineProperty(e,"coerceInputValue",{enumerable:!0,get:function(){return c.coerceInputValue}}),Object.defineProperty(e,"concatAST",{enumerable:!0,get:function(){return c.concatAST}}),Object.defineProperty(e,"createSourceEventStream",{enumerable:!0,get:function(){return a.createSourceEventStream}}),Object.defineProperty(e,"defaultFieldResolver",{enumerable:!0,get:function(){return a.defaultFieldResolver}}),Object.defineProperty(e,"defaultTypeResolver",{enumerable:!0,get:function(){return a.defaultTypeResolver}}),Object.defineProperty(e,"doTypesOverlap",{enumerable:!0,get:function(){return c.doTypesOverlap}}),Object.defineProperty(e,"execute",{enumerable:!0,get:function(){return a.execute}}),Object.defineProperty(e,"executeSync",{enumerable:!0,get:function(){return a.executeSync}}),Object.defineProperty(e,"extendSchema",{enumerable:!0,get:function(){return c.extendSchema}}),Object.defineProperty(e,"findBreakingChanges",{enumerable:!0,get:function(){return c.findBreakingChanges}}),Object.defineProperty(e,"findDangerousChanges",{enumerable:!0,get:function(){return c.findDangerousChanges}}),Object.defineProperty(e,"formatError",{enumerable:!0,get:function(){return s.formatError}}),Object.defineProperty(e,"getArgumentValues",{enumerable:!0,get:function(){return a.getArgumentValues}}),Object.defineProperty(e,"getDirectiveValues",{enumerable:!0,get:function(){return a.getDirectiveValues}}),Object.defineProperty(e,"getEnterLeaveForKind",{enumerable:!0,get:function(){return i.getEnterLeaveForKind}}),Object.defineProperty(e,"getIntrospectionQuery",{enumerable:!0,get:function(){return c.getIntrospectionQuery}}),Object.defineProperty(e,"getLocation",{enumerable:!0,get:function(){return i.getLocation}}),Object.defineProperty(e,"getNamedType",{enumerable:!0,get:function(){return r.getNamedType}}),Object.defineProperty(e,"getNullableType",{enumerable:!0,get:function(){return r.getNullableType}}),Object.defineProperty(e,"getOperationAST",{enumerable:!0,get:function(){return c.getOperationAST}}),Object.defineProperty(e,"getOperationRootType",{enumerable:!0,get:function(){return c.getOperationRootType}}),Object.defineProperty(e,"getVariableValues",{enumerable:!0,get:function(){return a.getVariableValues}}),Object.defineProperty(e,"getVisitFn",{enumerable:!0,get:function(){return i.getVisitFn}}),Object.defineProperty(e,"graphql",{enumerable:!0,get:function(){return n.graphql}}),Object.defineProperty(e,"graphqlSync",{enumerable:!0,get:function(){return n.graphqlSync}}),Object.defineProperty(e,"introspectionFromSchema",{enumerable:!0,get:function(){return c.introspectionFromSchema}}),Object.defineProperty(e,"introspectionTypes",{enumerable:!0,get:function(){return r.introspectionTypes}}),Object.defineProperty(e,"isAbstractType",{enumerable:!0,get:function(){return r.isAbstractType}}),Object.defineProperty(e,"isCompositeType",{enumerable:!0,get:function(){return r.isCompositeType}}),Object.defineProperty(e,"isConstValueNode",{enumerable:!0,get:function(){return i.isConstValueNode}}),Object.defineProperty(e,"isDefinitionNode",{enumerable:!0,get:function(){return i.isDefinitionNode}}),Object.defineProperty(e,"isDirective",{enumerable:!0,get:function(){return r.isDirective}}),Object.defineProperty(e,"isEnumType",{enumerable:!0,get:function(){return r.isEnumType}}),Object.defineProperty(e,"isEqualType",{enumerable:!0,get:function(){return c.isEqualType}}),Object.defineProperty(e,"isExecutableDefinitionNode",{enumerable:!0,get:function(){return i.isExecutableDefinitionNode}}),Object.defineProperty(e,"isInputObjectType",{enumerable:!0,get:function(){return r.isInputObjectType}}),Object.defineProperty(e,"isInputType",{enumerable:!0,get:function(){return r.isInputType}}),Object.defineProperty(e,"isInterfaceType",{enumerable:!0,get:function(){return r.isInterfaceType}}),Object.defineProperty(e,"isIntrospectionType",{enumerable:!0,get:function(){return r.isIntrospectionType}}),Object.defineProperty(e,"isLeafType",{enumerable:!0,get:function(){return r.isLeafType}}),Object.defineProperty(e,"isListType",{enumerable:!0,get:function(){return r.isListType}}),Object.defineProperty(e,"isNamedType",{enumerable:!0,get:function(){return r.isNamedType}}),Object.defineProperty(e,"isNonNullType",{enumerable:!0,get:function(){return r.isNonNullType}}),Object.defineProperty(e,"isNullableType",{enumerable:!0,get:function(){return r.isNullableType}}),Object.defineProperty(e,"isObjectType",{enumerable:!0,get:function(){return r.isObjectType}}),Object.defineProperty(e,"isOutputType",{enumerable:!0,get:function(){return r.isOutputType}}),Object.defineProperty(e,"isRequiredArgument",{enumerable:!0,get:function(){return r.isRequiredArgument}}),Object.defineProperty(e,"isRequiredInputField",{enumerable:!0,get:function(){return r.isRequiredInputField}}),Object.defineProperty(e,"isScalarType",{enumerable:!0,get:function(){return r.isScalarType}}),Object.defineProperty(e,"isSchema",{enumerable:!0,get:function(){return r.isSchema}}),Object.defineProperty(e,"isSchemaCoordinateNode",{enumerable:!0,get:function(){return i.isSchemaCoordinateNode}}),Object.defineProperty(e,"isSelectionNode",{enumerable:!0,get:function(){return i.isSelectionNode}}),Object.defineProperty(e,"isSpecifiedDirective",{enumerable:!0,get:function(){return r.isSpecifiedDirective}}),Object.defineProperty(e,"isSpecifiedScalarType",{enumerable:!0,get:function(){return r.isSpecifiedScalarType}}),Object.defineProperty(e,"isType",{enumerable:!0,get:function(){return r.isType}}),Object.defineProperty(e,"isTypeDefinitionNode",{enumerable:!0,get:function(){return i.isTypeDefinitionNode}}),Object.defineProperty(e,"isTypeExtensionNode",{enumerable:!0,get:function(){return i.isTypeExtensionNode}}),Object.defineProperty(e,"isTypeNode",{enumerable:!0,get:function(){return i.isTypeNode}}),Object.defineProperty(e,"isTypeSubTypeOf",{enumerable:!0,get:function(){return c.isTypeSubTypeOf}}),Object.defineProperty(e,"isTypeSystemDefinitionNode",{enumerable:!0,get:function(){return i.isTypeSystemDefinitionNode}}),Object.defineProperty(e,"isTypeSystemExtensionNode",{enumerable:!0,get:function(){return i.isTypeSystemExtensionNode}}),Object.defineProperty(e,"isUnionType",{enumerable:!0,get:function(){return r.isUnionType}}),Object.defineProperty(e,"isValidNameError",{enumerable:!0,get:function(){return c.isValidNameError}}),Object.defineProperty(e,"isValueNode",{enumerable:!0,get:function(){return i.isValueNode}}),Object.defineProperty(e,"isWrappingType",{enumerable:!0,get:function(){return r.isWrappingType}}),Object.defineProperty(e,"lexicographicSortSchema",{enumerable:!0,get:function(){return c.lexicographicSortSchema}}),Object.defineProperty(e,"locatedError",{enumerable:!0,get:function(){return s.locatedError}}),Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return i.parse}}),Object.defineProperty(e,"parseConstValue",{enumerable:!0,get:function(){return i.parseConstValue}}),Object.defineProperty(e,"parseSchemaCoordinate",{enumerable:!0,get:function(){return i.parseSchemaCoordinate}}),Object.defineProperty(e,"parseType",{enumerable:!0,get:function(){return i.parseType}}),Object.defineProperty(e,"parseValue",{enumerable:!0,get:function(){return i.parseValue}}),Object.defineProperty(e,"print",{enumerable:!0,get:function(){return i.print}}),Object.defineProperty(e,"printError",{enumerable:!0,get:function(){return s.printError}}),Object.defineProperty(e,"printIntrospectionSchema",{enumerable:!0,get:function(){return c.printIntrospectionSchema}}),Object.defineProperty(e,"printLocation",{enumerable:!0,get:function(){return i.printLocation}}),Object.defineProperty(e,"printSchema",{enumerable:!0,get:function(){return c.printSchema}}),Object.defineProperty(e,"printSourceLocation",{enumerable:!0,get:function(){return i.printSourceLocation}}),Object.defineProperty(e,"printType",{enumerable:!0,get:function(){return c.printType}}),Object.defineProperty(e,"recommendedRules",{enumerable:!0,get:function(){return o.recommendedRules}}),Object.defineProperty(e,"resolveASTSchemaCoordinate",{enumerable:!0,get:function(){return c.resolveASTSchemaCoordinate}}),Object.defineProperty(e,"resolveObjMapThunk",{enumerable:!0,get:function(){return r.resolveObjMapThunk}}),Object.defineProperty(e,"resolveReadonlyArrayThunk",{enumerable:!0,get:function(){return r.resolveReadonlyArrayThunk}}),Object.defineProperty(e,"resolveSchemaCoordinate",{enumerable:!0,get:function(){return c.resolveSchemaCoordinate}}),Object.defineProperty(e,"responsePathAsArray",{enumerable:!0,get:function(){return a.responsePathAsArray}}),Object.defineProperty(e,"separateOperations",{enumerable:!0,get:function(){return c.separateOperations}}),Object.defineProperty(e,"specifiedDirectives",{enumerable:!0,get:function(){return r.specifiedDirectives}}),Object.defineProperty(e,"specifiedRules",{enumerable:!0,get:function(){return o.specifiedRules}}),Object.defineProperty(e,"specifiedScalarTypes",{enumerable:!0,get:function(){return r.specifiedScalarTypes}}),Object.defineProperty(e,"stripIgnoredCharacters",{enumerable:!0,get:function(){return c.stripIgnoredCharacters}}),Object.defineProperty(e,"subscribe",{enumerable:!0,get:function(){return a.subscribe}}),Object.defineProperty(e,"syntaxError",{enumerable:!0,get:function(){return s.syntaxError}}),Object.defineProperty(e,"typeFromAST",{enumerable:!0,get:function(){return c.typeFromAST}}),Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return o.validate}}),Object.defineProperty(e,"validateSchema",{enumerable:!0,get:function(){return r.validateSchema}}),Object.defineProperty(e,"valueFromAST",{enumerable:!0,get:function(){return c.valueFromAST}}),Object.defineProperty(e,"valueFromASTUntyped",{enumerable:!0,get:function(){return c.valueFromASTUntyped}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return t.version}}),Object.defineProperty(e,"versionInfo",{enumerable:!0,get:function(){return t.versionInfo}}),Object.defineProperty(e,"visit",{enumerable:!0,get:function(){return i.visit}}),Object.defineProperty(e,"visitInParallel",{enumerable:!0,get:function(){return i.visitInParallel}}),Object.defineProperty(e,"visitWithTypeInfo",{enumerable:!0,get:function(){return c.visitWithTypeInfo}});var t=$r(),n=La(),r=Ra(),i=za(),a=Ua(),o=Ka(),s=qa(),c=lo()})))();const fo={String:`text`,ID:`text`,OID:`text`,PHID:`text`,OLabel:`text`,URL:`text`,Date:`text`,DateTime:`text`,EmailAddress:`text`,EthereumAddress:`text`,Currency:`text`,Address:`text`,AttachmentRef:`text`,Int:`integer`,Float:`number`,Amount_Money:`number`,Amount_Percentage:`number`,Amount_Tokens:`number`,Boolean:`boolean`,Amount:`object`,Amount_Crypto:`object`,Amount_Currency:`object`,Amount_Fiat:`object`,Unknown:`json`};var po=class extends Error{constructor(e){super(`Invalid input SDL: ${e}`),this.name=`SdlSyntaxError`}};function mo(e){return e.kind===uo.Kind.NON_NULL_TYPE?{...mo(e.type),required:!0}:e.kind===uo.Kind.LIST_TYPE?{name:mo(e.type).name,list:!0,required:!1}:{name:e.name.value,list:!1,required:!1}}function ho(e){return(e.fields??[]).filter(e=>e.name.value!==`_`).map(e=>{let t=e.description?.value.replace(/\s+/g,` `);return{name:e.name.value,type:mo(e.type),...t?{description:t}:{}}})}function go(e){let t;try{t=(0,uo.parse)(e,{noLocation:!0})}catch(e){throw new po(e instanceof uo.GraphQLError?e.message:String(e))}let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map;for(let e of t.definitions)e.kind===uo.Kind.INPUT_OBJECT_TYPE_DEFINITION?n.set(e.name.value,ho(e)):e.kind===uo.Kind.ENUM_TYPE_DEFINITION&&r.set(e.name.value,(e.values??[]).map(e=>e.name.value));return{inputs:n,enums:r}}const _o=e=>e.replace(/[^A-Za-z0-9]/g,``).toLowerCase();function vo(e,t){let n=`${_o(e)}input`,r=[...t].filter(e=>_o(e)===n);return r.length===1?r[0]:void 0}function yo(e,t){let{inputs:n,enums:r}=go(e),i=vo(t,n.keys()),a=i?n.get(i):void 0;return i&&a?{rootName:i,root:a,inputs:n,enums:r}:null}function bo(e,t){return t.inputs.has(e.name)?`object`:t.enums.has(e.name)?`enum`:fo[e.name]??`unsupported`}function xo(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).toLowerCase().trim();return t.charAt(0).toUpperCase()+t.slice(1)}function So(e,t){let n={displayName:xo(e.name),required:e.type.required,...e.description?{description:e.description}:{}};if(e.type.list)return q.Json({...n,description:e.description??`A JSON list`});switch(bo(e.type,t)){case`text`:return q.ShortText(n);case`integer`:case`number`:return q.ShortText({...n,description:e.description??`A number`});case`boolean`:return q.StaticDropdown({...n,options:{options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]}});case`enum`:return q.StaticDropdown({...n,options:{options:(t.enums.get(e.type.name)??[]).map(e=>({label:xo(e),value:e}))}});case`unsupported`:return q.Json({...n,description:`Type ${e.type.name} is not supported by this form`});default:return q.Json(n)}}function Co(e){let t={};for(let n of e.root)t[n.name]=So(n,e);return t}function wo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const To=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Eo(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?`${t.slice(0,57)}...`:t}function Do(e,t,n){let r=t=>/* @__PURE__ */ Error(`input "${e.name}" (${e.type.name}) expects ${t}; got ${Eo(n)}`);if(e.type.list){if(!Array.isArray(n))throw r(`a list`);return n}switch(t){case`text`:case`enum`:if(typeof n!=`string`)throw r(`text`);return n;case`integer`:case`number`:{let e=typeof n==`number`?n:typeof n==`string`&&To.test(n.trim())?Number(n.trim()):NaN;if(!Number.isFinite(e))throw r(`a number`);if(t===`integer`&&!Number.isInteger(e))throw r(`an integer`);return e}case`boolean`:if(typeof n==`boolean`)return n;if(n===`true`||n===`false`)return n===`true`;throw r(`true or false`);case`object`:if(!wo(n))throw r(`an object`);return n;case`json`:return n;case`unsupported`:throw Error(`input "${e.name}" has type ${e.type.name}, which this piece cannot map`)}}function Oo(e,t){let n=t??{};if(!wo(n))throw Error(`"input" must be an object; got ${Eo(n)}`);let r={};for(let t of e.root){let i=n[t.name];i!=null&&i!==``&&(r[t.name]=Do(t,bo(t.type,e),i))}return r}const ko=[{label:`Exact`,value:`exact`},{label:`Extract from AI output`,value:`extract`}];function Ao(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function jo(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?`${t.slice(0,57)}...`:t}function Mo(e){return e.trim().replace(/^```(?:json)?\s*/i,``).replace(/```$/,``).trim()}function No(e){let t=[],n=0,r=-1,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];if(i){a?a=!1:s===`\\`?a=!0:s===`"`&&(i=!1);continue}if(s===`"`){i=!0;continue}if(s===`{`||s===`[`){n===0&&(r=o),n++;continue}if(s===`}`||s===`]`){if(n===0)continue;n--,n===0&&r>=0&&(t.push(e.slice(r,o+1)),r=-1)}}return t}function Po(e){let t=Mo(e);try{return JSON.parse(t)}catch{}let n=No(t);for(let e=n.length-1;e>=0;e--)try{return JSON.parse(n[e])}catch{}throw SyntaxError(`no JSON value found`)}const Fo=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,Io=/(?<![A-Za-z0-9_-])[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])/;function Lo(e){let t=Fo.exec(e)??Io.exec(e);return t?t[0]:e.trim().replace(/^["'`]+|["'`]+$/g,``).trim()||void 0}const Ro=`set "Parse" to "Extract from AI output" to read one out of text`;var zo=class e{block;mode;extractedFrom={};constructor(e,t){this.block=e,this.mode=t}static of(t,n){if(n==null||n===``)return new e(t,`exact`);if(n!==`exact`&&n!==`extract`)throw Error(`${t}: "parse" must be "exact" or "extract"`);return new e(t,n)}get extract(){return this.mode===`extract`}documentId(e,t){if(e!=null&&e!==``){if(typeof e!=`string`)throw Error(`${this.block}: "${t}" must be a document id; got ${jo(e)}`);if(this.extract){let n=Lo(e);return n!==void 0&&n!==e&&(this.extractedFrom[t]=e),n}if(!/^[^\s"'`]+$/.test(e))throw Error(`${this.block}: "${t}" is not a document id: ${jo(e)}; ${Ro}`);return e}}json(e,t){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch(e){if(!this.extract){let n=e instanceof Error?e.message:String(e);throw Error(`${this.block}: "${t}" is not valid JSON (${n}); ${Ro}`,{cause:e})}}try{let n=Po(e);return this.extractedFrom[t]=e,n}catch{throw Error(`${this.block}: "${t}" holds no JSON value`)}}output(){return Object.keys(this.extractedFrom).length?{extractedFrom:this.extractedFrom}:{}}};function Bo(e,t,n){return e.map((e,r)=>{if(!Ao(e)||typeof e.type!=`string`)throw Error(`${t.block}: ${n}[${r}] needs a string "type"`);if(e.scope!==void 0&&typeof e.scope!=`string`)throw Error(`${t.block}: ${n}[${r}].scope must be a string`);return{type:e.type,input:e.input,scope:e.scope}})}function Vo(e,t,n=`actions`){if(e==null||e===``)return{actions:[]};let r=t.json(e,n);if(Array.isArray(r))return{actions:Bo(r,t,n)};if(Ao(r)){if(Array.isArray(r.actions))return{documentId:t.documentId(r.documentId,`${n}.documentId`),actions:Bo(r.actions,t,n)};if(t.extract&&typeof r.type==`string`)return{actions:Bo([r],t,n)}}throw Error(`${t.block}: "${n}" must be a list of actions or an object with an "actions" list; got ${jo(r)}`)}function Ho(e,t,n=`actions`){return Vo(e,t,n).actions}function Uo(e,t){if(e==null||e===``)return{};let n=t.json(e,`payload`);if(!Ao(n))throw Error(`${t.block}: "payload" must be an object; got ${jo(n)}`);for(let e of[`documentType`,`name`])if(n[e]!==void 0&&typeof n[e]!=`string`)throw Error(`${t.block}: "payload.${e}" must be a string`);return{documentType:n.documentType,name:n.name,actions:n.actions}}function Wo(e,t){if(e==null||e===``)return{};let n=t.json(e,`input`);if(!Ao(n))throw Error(`${t.block}: "input" must be an object; got ${jo(n)}`);return n}function Go(e){let t=typeof e==`string`?e.split(`,`):e;return Array.isArray(t)?t.map(e=>{if(typeof e==`string`)return e;let t=e;return typeof t?.type==`string`?t.type:``}).map(e=>e.trim()).filter(Boolean):[]}function Ko(e){if(typeof e!=`string`)return;let t=e.trim();if(t&&!t.includes(`{{`))return t}function qo(e){let t=e?.nodes;return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function Jo(e){let t=qo(e).filter(e=>e.kind===`folder`),n=new Map(t.map(e=>[e.id,e])),r=e=>{let t=[],r=/* @__PURE__ */ new Set,i=e;for(;i&&!r.has(i.id);)r.add(i.id),t.unshift(i.name||`(unnamed)`),i=i.parentFolder?n.get(i.parentFolder):void 0;return t.join(` / `)};return t.map(e=>({label:r(e),value:e.id})).sort((e,t)=>e.label.localeCompare(t.label))}const Yo=/\b(?:input|enum|type)\s+(\w+)/g,Xo=/* @__PURE__ */ new Set([`String`,`Int`,`Float`,`Boolean`,`ID`]);function Zo(e,t,n){return RegExp(`${t}\\s+${n}\\s*\\{[^}]*\\}`).exec(e)?.[0]??null}function Qo(e,t){if(!t)return e;let n=new Set([...e.matchAll(Yo)].map(e=>e[1])),r=[...new Set([...e.matchAll(/:\s*\[?\s*(\w+)/g)].map(e=>e[1]).filter(e=>!n.has(e)&&!Xo.has(e)))].map(e=>Zo(t,`enum`,e)).filter(e=>e!==null);return r.length?`${e}\n\n${r.join(`
269
269
 
270
- `)}`:e}function $o(e){if(e.reactor)return e.reactor;let t=/* @__PURE__ */ Error(`ctx.reactor is not served to this resolver`);throw t.name=`ReactorAccessDeniedError`,t}async function es(e){let t=await e.getDocumentModelModules(),n=[...t.results];for(;t.next&&t.results.length>0;)t=await t.next(),n.push(...t.results);return n}async function ts(e){let t=/* @__PURE__ */ new Map;for(let n of await es(e)){let e=n.documentModel.global;e.id&&!t.has(e.id)&&t.set(e.id,e.name)}return[...t].map(([e,t])=>({documentType:e,name:t})).sort((e,t)=>e.documentType.localeCompare(t.documentType))}async function ns(e,t){let n=t?[t]:(await ts(e)).map(e=>e.documentType),r=(await Promise.all(n.map(t=>e.find({type:t},void 0,{cursor:``,limit:100})))).flatMap(e=>e.results),i=e=>Gr(e)||e.header.slug||`(unnamed)`,a=/* @__PURE__ */ new Map;for(let e of r)a.set(i(e),(a.get(i(e))??0)+1);return{options:r.map(e=>{let n=i(e),{id:r,slug:o}=e.header,s=(a.get(n)??0)>1?`${n} (${o&&o!==n?o:r.slice(0,8)})`:n;return{label:t?s:`${s} — ${e.header.documentType}`,value:r}}),placeholder:t===`powerhouse/document-drive`?`Choose a drive`:t?`Documents of type ${t}`:`All documents on this reactor`}}const rs=(e=`Document type`,t=!1,n)=>q.Dropdown({auth:void 0,displayName:e,description:n,required:t,refreshers:[],options:async(e,t)=>({options:(await ts($o(t))).map(e=>({label:e.name?`${e.name} (${e.documentType})`:e.documentType,value:e.documentType}))})}),is=(e=`Document id`,t=!1,n)=>q.Dropdown({auth:void 0,displayName:e,description:n,required:t,refreshers:[`documentType`],options:(e,t)=>ns($o(t),Ko(e.documentType))}),as=(e,t)=>q.Dropdown({auth:void 0,displayName:e,description:t,required:!1,refreshers:[],options:(e,t)=>ns($o(t),zr)}),os=(e,t,n)=>q.Dropdown({auth:void 0,displayName:e,description:n,required:!1,refreshers:[t],options:async(e,n)=>{let r=Ko(e[t]);if(!r)return{disabled:!0,options:[],placeholder:`Pick a drive first`};let i=await $o(n).get(r),a=i.state,o=Jo(a.global).map(e=>({label:e.label,value:{driveId:i.header.id,folderId:e.value}})),s=Gr(i);return{options:o,placeholder:o.length?`Folders in ${s||`this drive`}`:`${s||`This drive`} has no folders`}}}),ss=(e,t)=>({...q.LongText({displayName:e,required:!1,description:t,advanced:!0}),display:`code`}),cs=()=>q.StaticDropdown({displayName:`Parse`,description:`Exact takes ids and JSON as given. Extract reads them out of an AI step's prose, and reports what it read from in extractedFrom`,required:!1,defaultValue:`exact`,advanced:!0,options:{options:ko}});async function ls(e,t){let n=Ko(t.documentType);if(n)return e.getDocumentModelModule(n);let r=Ko(t.documentId);if(!r)return;let i=await e.get(r);return e.getDocumentModelModuleForDocument(i)}const us=(e=`Action type`,t=!1,n)=>q.Dropdown({auth:void 0,displayName:e,description:n,required:t,refreshers:[`documentType`,`documentId`],options:async(e,t)=>{let n=await ls($o(t),e);if(!n)return{disabled:!0,options:[{label:`SET_NAME (base)`,value:Jr.type,inputSchema:Jr.inputSchema??void 0}],placeholder:`Pick a document type first`};let r=Yr(n);return{options:r.actions.map(e=>({label:`${e.type} (${e.module})`,value:e.type,documentType:r.documentType,...e.inputSchema?{inputSchema:Qo(e.inputSchema,r.stateSchema)}:{}})),placeholder:`Actions of ${r.documentType}`}}});function ds(e,t){let n=Yr(e),r=n.actions.find(e=>e.type===t);if(r?.inputSchema)return yo(Qo(r.inputSchema,n.stateSchema),t)??void 0}const fs=(e=`Input`)=>q.DynamicProperties({auth:void 0,displayName:e,required:!1,refreshers:[`documentType`,`documentId`,`actionType`],props:async(e,t)=>{let n=Ko(e.actionType);if(!n)return{};let r=await ls($o(t),e),i=r&&ds(r,n);return i?Co(i):{}}}),ps=e=>({key:`action`,display:`section`,label:`Action`,description:`${e} Pick a type, then fill in its input: the action needs both.`,props:[`actionType`,`input`]}),ms=`document-create`;function hs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function gs(e,t){if(e==null||e===``)return;let n=typeof e==`string`&&e.trim().startsWith(`{`)?t.json(e,`folderId`):e;if(typeof n==`string`)return n.trim()||void 0;if(hs(n)&&typeof n.driveId==`string`&&typeof n.folderId==`string`)return{driveId:n.driveId,folderId:n.folderId};throw Error(`${ms}: "folderId" must be a folder from the list, or a folder id with "parentId" set to its drive`)}async function _s(e,t,n){if(n&&typeof n==`object`)return{kind:`drive`,...n};if(!t){if(n)throw Error(`${ms}: a folder id needs "parentId", its drive`);return{kind:`none`}}let r=await e.get(t);if(Br.has(r.header.documentType))return{kind:`drive`,driveId:r.header.id,folderId:n};if(n)throw Error(`${ms}: "parentId" names a document, not a drive`);return{kind:`parent`,parentId:r.header.id}}async function vs(e,t,n,r){let i=t.documentModel.global.id;if(n.kind!==`drive`&&!r)return e.createEmpty(i,n.kind===`parent`?{parentIdentifier:n.parentId}:{});let a=await e.newDocument(i,{parentIdentifier:n.kind===`drive`?n.driveId:n.kind===`parent`?n.parentId:void 0,name:r||void 0});if(n.kind===`drive`){let t=await e.create(a,n.driveId);return await e.execute(n.driveId,Vr,[Xr(`ADD_FILE`,{id:t.header.id,name:t.header.name||t.header.id,documentType:i,parentFolder:n.folderId})]),t}return e.create(a,n.kind===`parent`?n.parentId:void 0)}const ys=kr({name:ms,displayName:`Create document`,description:`Creates a Powerhouse document. Outputs a reference to it: id, type, branch and revision.`,requireAuth:!1,requireReactor:`write`,propertyGroups:[ps(`Optional, sent right after the create.`)],props:{documentType:rs(),name:q.ShortText({displayName:`Document name`,required:!1}),parentId:as(`Parent drive`,`A drive, or a document to create the new one under`),folderId:os(`Folder`,`parentId`,`Omit for the drive's root`),actionType:us(`Type`,!1),input:fs(`Input`),actions:ss(`Action list (JSON)`,`Several actions after the create, or a payload from an earlier step: [{ "type": …, "input": … }]`),payload:q.ShortText({displayName:`Payload`,description:`JSON {documentType, name, actions?}, e.g. {{steps.draft.output}}`,required:!1,advanced:!0}),parse:cs()},run:async e=>{let t=e.reactor,n=e.propsValue,r=zo.of(ms,n.parse),i=Uo(n.payload,r),a=typeof n.documentType==`string`&&n.documentType||i.documentType;if(!a)throw Error(`${ms}: "documentType" is required, in the config or the payload`);let o=typeof n.name==`string`&&n.name||i.name,s=await _s(t,r.documentId(n.parentId,`parentId`),gs(n.folderId,r)),c=await t.getDocumentModelModule(a),l=(n.actions===void 0?Ho(i.actions,r,`payload.actions`):Ho(n.actions,r)).map(e=>Xr(e.type,e.input,e.scope)),u=typeof n.actionType==`string`?n.actionType.trim():``;if(u){let e=ds(c,u),t=Wo(n.input,r);l.unshift(Qr(c,u,e?Oo(e,t):t))}let d=await vs(t,c,s,o);return{...Mr((l.length?await t.execute(d.header.id,Vr,l):d).header),...r.output()}}}),bs=`document-dispatch`,xs=kr({name:bs,displayName:`Dispatch actions`,description:`Sends actions to a document. Outputs a reference to it: id, type, branch and revision.`,requireAuth:!1,requireReactor:`write`,propertyGroups:[ps(`Sent to the document.`)],props:{documentId:is(`Document id`,!0,`e.g. {{steps.create.output.documentId}}`),documentType:rs(`Document type`,!1,`Design-time hint when the document id is an expression`),actionType:us(`Type`,!1),input:fs(`Input`),actions:ss(`Action list (JSON)`,`Several actions at once, or a payload from an earlier step: [{ "type": …, "input": …, "scope"?: "global" }]`),allowedActions:q.ShortText({displayName:`Allowed action types`,description:`Comma-separated whitelist; enforced when set`,required:!1,advanced:!0}),branch:q.ShortText({displayName:`Branch`,required:!1,defaultValue:Vr,advanced:!0}),parse:cs()},run:async e=>{let t=e.reactor,n=e.propsValue,r=zo.of(bs,n.parse),i=Vo(n.actions,r),a=r.documentId(n.documentId,`documentId`)??i.documentId;if(!a)throw Error(`${bs}: "documentId" is required, in the config or the actions payload`);let o=i.actions.map(e=>Xr(e.type,e.input,e.scope)),s=typeof n.actionType==`string`?n.actionType.trim():``;if(s){let e=await t.getDocumentModelModuleForDocument(await t.get(a)),i=ds(e,s),c=Wo(n.input,r);o.unshift(Qr(e,s,i?Oo(i,c):c))}let c=Go(n.allowedActions),l=c.length?o.filter(e=>!c.includes(e.type)):[];if(l.length>0)throw Error(`${bs}: action(s) not allowed here: ${[...new Set(l.map(e=>e.type))].join(`, `)}`);if(o.length===0)throw Error(`${bs}: choose an Action, or give a non-empty "Action list (JSON)"`);let u=typeof n.branch==`string`&&n.branch.trim()||`main`;return{...Mr((await t.execute(a,u,o)).header),...r.output()}}}),Ss=`document-find`;function Cs(e){return btoa(JSON.stringify(e))}function ws(e){if(e!=null&&e!==``){try{let t=JSON.parse(atob(typeof e==`string`?e.trim():``));if(Number.isInteger(t.q)&&typeof t.c==`string`&&Number.isInteger(t.s)&&Number.isInteger(t.l))return t}catch{}throw Error(`${Ss}: "cursor" is not a nextCursor this step returned`)}}async function Ts(e,t,n){let r=n?{parentId:n}:{};return t?[{type:t,...r}]:n?[r]:(await ts(e)).map(e=>({type:e.documentType}))}const Es=kr({name:Ss,displayName:`Find documents`,description:`Lists documents by type and name.`,requireAuth:!1,requireReactor:`read`,props:{documentType:rs(`Document type`,!1,`Omit for any type`),parentId:as(`In drive`,`Omit for the whole reactor`),name:q.ShortText({displayName:`Name contains`,description:`Case-insensitive match`,required:!1}),matchPath:q.ShortText({displayName:`State field`,description:`Dotted path into the document's state, e.g. "orderId" or "settlement.status". With a value below, only documents holding it are returned.`,required:!1}),matchValue:q.ShortText({displayName:`State value`,description:`Compared as text, e.g. {{trigger.payload.orderId}}. Documents missing the field never match.`,required:!1}),includeState:q.Checkbox({displayName:`Include state`,description:`Returns each document's state as well as its header. Off by default: a page of documents carries a page of states.`,required:!1,defaultValue:!1}),limit:q.Number({displayName:`Max results`,description:`Defaults to 25, at most 100`,required:!1}),cursor:q.ShortText({displayName:`Cursor`,description:`Resumes a search, e.g. {{steps.find.output.nextCursor}}; omit to start from the first page`,required:!1,advanced:!0})},run:async e=>{let{documentType:t,parentId:n,name:r,limit:i,matchPath:a,matchValue:o,includeState:s}=e.propsValue,c=Math.min(Math.max(typeof i==`number`?i:25,1),100),l=typeof a==`string`?a.trim():``,u=typeof o==`string`?o.trim():``;if(l===``!=(u===``))throw Error(`${Ss}: "State field" and "State value" are set together or not at all`);let d=typeof r==`string`?r.trim().toLowerCase():``,f=l?{path:l,value:u}:void 0,p=e=>(!d||Gr(e).toLowerCase().includes(d))&&qr(e,f),m=d!==``||f!==void 0,h=await Ts(e.reactor,typeof t==`string`&&t.trim()?t.trim():void 0,typeof n==`string`&&n.trim()?n.trim():void 0),g=ws(e.propsValue.cursor)??{q:0,c:``,s:0,l:0},_=[],v;for(let t=0;g.q<h.length;t++){if(m&&t>=20){v=Cs(g);break}let n=g.l||(m?100:Math.max(c-_.length,1)),r=await e.reactor.find(h[g.q],void 0,{cursor:g.c,limit:n}),i=g.s;for(;i<r.results.length&&_.length<c;i++)p(r.results[i])&&_.push(r.results[i]);let a=i<r.results.length?{q:g.q,c:g.c,s:i,l:n}:r.nextCursor&&r.results.length>0?{q:g.q,c:r.nextCursor,s:0,l:0}:g.q+1<h.length?{q:g.q+1,c:``,s:0,l:0}:void 0;if(!a)break;if(_.length>=c){v=Cs(a);break}g=a}return{results:_.map(e=>s===!0?Ur(e):{header:e.header}),...v?{nextCursor:v}:{}}}}),Ds=`document-get`,Os=kr({name:Ds,displayName:`Get document`,description:`Reads a document's current state.`,requireAuth:!1,requireReactor:`read`,props:{documentId:is(`Document id`,!0,`e.g. {{steps.find.output.results.0.header.id}}`),documentType:rs(`Document type`,!1,`Design-time hint when the document id is an expression`),parse:cs()},run:async e=>{let t=zo.of(Ds,e.propsValue.parse),n=t.documentId(e.propsValue.documentId,`documentId`);if(!n)throw Error(`${Ds}: "documentId" is required`);return{...Ur(await e.reactor.get(n)),...t.output()}}}),ks=`document-schema`,As=kr({name:ks,displayName:`Get document schema`,description:`Action and state schemas of a document type.`,requireAuth:!1,requireReactor:`read`,props:{documentType:rs(`Document type`,!1,`Required unless a document id is given`),documentId:is(`Document id`,!1,`Resolves the type from this document instead`),actionType:us(`Only this action`,!1,`Omit to list every action`),parse:cs()},run:async e=>{let t=e.reactor,{actionType:n}=e.propsValue,r=zo.of(ks,e.propsValue.parse),i=typeof e.propsValue.documentType==`string`?e.propsValue.documentType.trim():``,a=i?void 0:r.documentId(e.propsValue.documentId,`documentId`);if(!i&&!a)throw Error(`${ks}: "documentType" is required`);let o=Yr(a?await t.getDocumentModelModuleForDocument(await t.get(a)):await t.getDocumentModelModule(i));return{documentType:o.documentType,name:o.name,stateSchema:o.stateSchema,actions:n?o.actions.filter(e=>e.type===n):o.actions,...r.output()}}}),js=kr({name:`document-types`,displayName:`List document types`,description:`Document models installed on this reactor.`,requireAuth:!1,requireReactor:`read`,props:{},run:async e=>{let t=await ts(e.reactor);return{count:t.length,types:t}}});function Ms(e){return()=>Promise.reject(/* @__PURE__ */ Error(`The "${e}" trigger is fired by the reactor, not polled`))}const Ns={documentId:`01234567-89ab-cdef-0123-456789abcdef`,documentType:`powerhouse/workflow`,branch:`main`,scope:`global`,action:{type:`SET_NAME`,input:{name:`Invoice`}},operation:{index:7,timestampUtcMs:`1757500000000`}},Ps={documentId:`01234567-89ab-cdef-0123-456789abcdef`,documentType:`powerhouse/workflow`,name:`Invoice`,driveId:`fedcba98-7654-3210-fedc-ba9876543210`,parentId:null,operation:{index:0,timestampUtcMs:`1757500000000`}},Fs=Ar({name:`document-event`,displayName:`Document event`,description:`Fires when a matching document operation lands.`,type:bn.POLLING,requireAuth:!1,requireReactor:`read`,props:{documentType:rs(`Document type`,!1,`e.g. powerhouse/connection`),documentId:is(`Document id`,!1,`Omit to match any document`),actionType:us(`Action type`,!1,`Omit to match any action`)},sampleData:Ns,onEnable:Ms(`document-event`),onDisable:Ms(`document-event`),run:Ms(`document-event`)}),Is=Ar({name:`document-created`,displayName:`Document created`,description:`Fires when a document is added to a drive.`,type:bn.POLLING,requireAuth:!1,requireReactor:`read`,props:{documentType:rs(`Document type`,!1,`Type of the created document; omit to match any`),driveId:as(`Drive`,`Omit to match documents outside every drive too`)},sampleData:Ps,onEnable:Ms(`document-created`),onDisable:Ms(`document-created`),run:Ms(`document-created`)}),Ls=Ar({name:`document-deleted`,displayName:`Document deleted`,description:`Fires when a document is removed from a drive.`,type:bn.POLLING,requireAuth:!1,requireReactor:`read`,props:{documentType:rs(`Document type`,!1,`Type of the deleted document; omit to match any`),driveId:as(`Drive`,`Omit to match documents outside every drive too`)},sampleData:Ps,onEnable:Ms(`document-deleted`),onDisable:Ms(`document-deleted`),run:Ms(`document-deleted`)}),Rs=mr({displayName:`Powerhouse Reactor`,description:`Read and write Powerhouse documents on the reactor this workflow runs in: create documents, dispatch actions, read state and schemas, and fire on document events.`,logoUrl:`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMTQgMTE0IiBmaWxsPSJub25lIj48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZmlsbD0iIzE2MTYxNiIgZD0iTTcxLjI5MTkgMEwyNC4zNDE1IDM4Ljg3NzJDMTcuNDU0OCA0NC41Nzk4IDE2Ljk1MzkgNTQuOTY1OSAyMy4yNiA2MS4zMDQ3TDM5LjUwMjggNzcuNjMxOEM0NC4yNjg0IDgyLjQyMjEgNDUuMjk5NiA4OS43ODM0IDQyLjAzMzUgOTUuNjk4OEwzMS45MjkgMTE0SDE1LjJDNi44MDUyNyAxMTQgMCAxMDcuMTk1IDAgOTguOFYxNS4yQzAgNi44MDUyNyA2LjgwNTI3IDAgMTUuMiAwSDcxLjI5MTlaTTgwLjExMSAwTDcxLjM0MTIgMTUuOTc1OEM2OC4xMDc4IDIxLjg2NiA2OS4xMjU1IDI5LjE4MDQgNzMuODQ0MSAzMy45NjQxTDkxLjA3NTEgNTEuNDMzMUM5Ny4zNjc0IDU3LjgxMjQgOTYuODA0NCA2OC4yMjI3IDg5Ljg2MDcgNzMuODg2MUw0MC42NzgyIDExNEg5OC44QzEwNy4xOTUgMTE0IDExNCAxMDcuMTk1IDExNCA5OC44VjE1LjJDMTE0IDYuODA1MjcgMTA3LjE5NSAwIDk4LjggMEg4MC4xMTFaIi8+PC9zdmc+`,authors:[`powerhouse`],auth:void 0,actions:[ys,xs,Os,Es,As,js],triggers:[Fs,Is,Ls]});export{Rs as default,Rs as reactor};
270
+ `)}`:e}function $o(e){if(e.reactor)return e.reactor;let t=/* @__PURE__ */ Error(`ctx.reactor is not served to this resolver`);throw t.name=`ReactorAccessDeniedError`,t}async function es(e){let t=await e.getDocumentModelModules(),n=[...t.results];for(;t.next&&t.results.length>0;)t=await t.next(),n.push(...t.results);return n}async function ts(e){let t=/* @__PURE__ */ new Map;for(let n of await es(e)){let e=n.documentModel.global;e.id&&!t.has(e.id)&&t.set(e.id,e.name)}return[...t].map(([e,t])=>({documentType:e,name:t})).sort((e,t)=>e.documentType.localeCompare(t.documentType))}async function ns(e,t){let n=t?[t]:(await ts(e)).map(e=>e.documentType),r=(await Promise.all(n.map(t=>e.find({type:t},void 0,{cursor:``,limit:100})))).flatMap(e=>e.results),i=e=>Gr(e)||e.header.slug||`(unnamed)`,a=/* @__PURE__ */ new Map;for(let e of r)a.set(i(e),(a.get(i(e))??0)+1);return{options:r.map(e=>{let n=i(e),{id:r,slug:o}=e.header,s=(a.get(n)??0)>1?`${n} (${o&&o!==n?o:r.slice(0,8)})`:n;return{label:t?s:`${s} — ${e.header.documentType}`,value:r}}),placeholder:t===`powerhouse/document-drive`?`Choose a drive`:t?`Documents of type ${t}`:`All documents on this reactor`}}const rs=(e=`Document type`,t=!1,n)=>q.Dropdown({auth:void 0,displayName:e,description:n,required:t,refreshers:[],options:async(e,t)=>({options:(await ts($o(t))).map(e=>({label:e.name?`${e.name} (${e.documentType})`:e.documentType,value:e.documentType}))})}),is=(e=`Document id`,t=!1,n)=>q.Dropdown({auth:void 0,displayName:e,description:n,required:t,refreshers:[`documentType`],options:(e,t)=>ns($o(t),Ko(e.documentType))}),as=(e,t)=>q.Dropdown({auth:void 0,displayName:e,description:t,required:!1,refreshers:[],options:(e,t)=>ns($o(t),zr)}),os=(e,t,n)=>q.Dropdown({auth:void 0,displayName:e,description:n,required:!1,refreshers:[t],options:async(e,n)=>{let r=Ko(e[t]);if(!r)return{disabled:!0,options:[],placeholder:`Pick a drive first`};let i=await $o(n).get(r),a=i.state,o=Jo(a.global).map(e=>({label:e.label,value:{driveId:i.header.id,folderId:e.value}})),s=Gr(i);return{options:o,placeholder:o.length?`Folders in ${s||`this drive`}`:`${s||`This drive`} has no folders`}}}),ss=(e,t)=>({...q.LongText({displayName:e,required:!1,description:t,advanced:!0}),display:`code`}),cs=()=>q.StaticDropdown({displayName:`Parse`,description:`Exact takes ids and JSON as given. Extract reads them out of an AI step's prose, and reports what it read from in extractedFrom`,required:!1,defaultValue:`exact`,advanced:!0,options:{options:ko}});async function ls(e,t){let n=Ko(t.documentType);if(n)return e.getDocumentModelModule(n);let r=Ko(t.documentId);if(!r)return;let i=await e.get(r);return e.getDocumentModelModuleForDocument(i)}const us=(e=`Action type`,t=!1,n)=>q.Dropdown({auth:void 0,displayName:e,description:n,required:t,refreshers:[`documentType`,`documentId`],options:async(e,t)=>{let n=await ls($o(t),e);if(!n)return{disabled:!0,options:[{label:`SET_NAME (base)`,value:Jr.type,inputSchema:Jr.inputSchema??void 0}],placeholder:`Pick a document type first`};let r=Yr(n);return{options:r.actions.map(e=>({label:`${e.type} (${e.module})`,value:e.type,documentType:r.documentType,...e.inputSchema?{inputSchema:Qo(e.inputSchema,r.stateSchema)}:{}})),placeholder:`Actions of ${r.documentType}`}}});function ds(e,t){let n=Yr(e),r=n.actions.find(e=>e.type===t);if(r?.inputSchema)return yo(Qo(r.inputSchema,n.stateSchema),t)??void 0}const fs=(e=`Input`)=>q.DynamicProperties({auth:void 0,displayName:e,required:!1,refreshers:[`documentType`,`documentId`,`actionType`],props:async(e,t)=>{let n=Ko(e.actionType);if(!n)return{};let r=await ls($o(t),e),i=r&&ds(r,n);return i?Co(i):{}}}),ps=e=>({key:`action`,display:`section`,label:`Action`,description:`${e} Pick a type, then fill in its input: the action needs both.`,props:[`actionType`,`input`]}),ms=`document-create`;function hs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function gs(e,t){if(e==null||e===``)return;let n=typeof e==`string`&&e.trim().startsWith(`{`)?t.json(e,`folderId`):e;if(typeof n==`string`)return n.trim()||void 0;if(hs(n)&&typeof n.driveId==`string`&&typeof n.folderId==`string`)return{driveId:n.driveId,folderId:n.folderId};throw Error(`${ms}: "folderId" must be a folder from the list, or a folder id with "parentId" set to its drive`)}async function _s(e,t,n){if(n&&typeof n==`object`)return{kind:`drive`,...n};if(!t){if(n)throw Error(`${ms}: a folder id needs "parentId", its drive`);return{kind:`none`}}let r=await e.get(t);if(Br.has(r.header.documentType))return{kind:`drive`,driveId:r.header.id,folderId:n};if(n)throw Error(`${ms}: "parentId" names a document, not a drive`);return{kind:`parent`,parentId:r.header.id}}async function vs(e,t,n,r){let i=t.documentModel.global.id;if(n.kind!==`drive`&&!r)return e.createEmpty(i,n.kind===`parent`?{parentIdentifier:n.parentId}:{});let a=await e.newDocument(i,{parentIdentifier:n.kind===`drive`?n.driveId:n.kind===`parent`?n.parentId:void 0,name:r||void 0});if(n.kind===`drive`){let t=await e.create(a,n.driveId);return await e.execute(n.driveId,Vr,[Xr(`ADD_FILE`,{id:t.header.id,name:t.header.name||t.header.id,documentType:i,parentFolder:n.folderId})]),t}return e.create(a,n.kind===`parent`?n.parentId:void 0)}const ys=kr({name:ms,displayName:`Create document`,description:`Creates a Powerhouse document. Outputs a reference to it: id, type, branch and revision.`,requireAuth:!1,requireReactor:`write`,propertyGroups:[ps(`Optional, sent right after the create.`)],props:{documentType:rs(),name:q.ShortText({displayName:`Document name`,required:!1}),parentId:as(`Parent drive`,`A drive, or a document to create the new one under`),folderId:os(`Folder`,`parentId`,`Omit for the drive's root`),actionType:us(`Type`,!1),input:fs(`Input`),actions:ss(`Action list (JSON)`,`Several actions after the create, or a payload from an earlier step: [{ "type": …, "input": … }]`),payload:q.ShortText({displayName:`Payload`,description:`JSON {documentType, name, actions?}, e.g. {{steps.draft.output}}`,required:!1,advanced:!0}),parse:cs()},run:async e=>{let t=e.reactor,n=e.propsValue,r=zo.of(ms,n.parse),i=Uo(n.payload,r),a=typeof n.documentType==`string`&&n.documentType||i.documentType;if(!a)throw Error(`${ms}: "documentType" is required, in the config or the payload`);let o=typeof n.name==`string`&&n.name||i.name,s=await _s(t,r.documentId(n.parentId,`parentId`),gs(n.folderId,r)),c=await t.getDocumentModelModule(a),l=(n.actions===void 0?Ho(i.actions,r,`payload.actions`):Ho(n.actions,r)).map(e=>Xr(e.type,e.input,e.scope)),u=typeof n.actionType==`string`?n.actionType.trim():``;if(u){let e=ds(c,u),t=Wo(n.input,r);l.unshift(Qr(c,u,e?Oo(e,t):t))}let d=await vs(t,c,s,o);return{...Mr((l.length?await t.execute(d.header.id,Vr,l):d).header),...r.output()}}}),bs=`document-dispatch`,xs=kr({name:bs,displayName:`Dispatch actions`,description:`Sends actions to a document. Outputs a reference to it: id, type, branch and revision.`,requireAuth:!1,requireReactor:`write`,propertyGroups:[ps(`Sent to the document.`)],props:{documentId:is(`Document id`,!0,`e.g. {{steps.create.output.documentId}}`),documentType:rs(`Document type`,!1,`Design-time hint when the document id is an expression`),actionType:us(`Type`,!1),input:fs(`Input`),actions:ss(`Action list (JSON)`,`Several actions at once, or a payload from an earlier step: [{ "type": …, "input": …, "scope"?: "global" }]`),allowedActions:q.ShortText({displayName:`Allowed action types`,description:`Comma-separated whitelist; enforced when set`,required:!1,advanced:!0}),branch:q.ShortText({displayName:`Branch`,required:!1,defaultValue:Vr,advanced:!0}),parse:cs()},run:async e=>{let t=e.reactor,n=e.propsValue,r=zo.of(bs,n.parse),i=Vo(n.actions,r),a=r.documentId(n.documentId,`documentId`)??i.documentId;if(!a)throw Error(`${bs}: "documentId" is required, in the config or the actions payload`);let o=i.actions.map(e=>Xr(e.type,e.input,e.scope)),s=typeof n.actionType==`string`?n.actionType.trim():``;if(s){let e=await t.getDocumentModelModuleForDocument(await t.get(a)),i=ds(e,s),c=Wo(n.input,r);o.unshift(Qr(e,s,i?Oo(i,c):c))}let c=Go(n.allowedActions),l=c.length?o.filter(e=>!c.includes(e.type)):[];if(l.length>0)throw Error(`${bs}: action(s) not allowed here: ${[...new Set(l.map(e=>e.type))].join(`, `)}`);if(o.length===0)throw Error(`${bs}: choose an Action, or give a non-empty "Action list (JSON)"`);let u=typeof n.branch==`string`&&n.branch.trim()||`main`;return{...Mr((await t.execute(a,u,o)).header),...r.output()}}}),Ss=`document-find`;function Cs(e){return btoa(JSON.stringify(e))}function ws(e){if(e!=null&&e!==``){try{let t=JSON.parse(atob(typeof e==`string`?e.trim():``));if(Number.isInteger(t.q)&&typeof t.c==`string`&&Number.isInteger(t.s)&&Number.isInteger(t.l))return t}catch{}throw Error(`${Ss}: "cursor" is not a nextCursor this step returned`)}}async function Ts(e,t,n){let r=n?{parentId:n}:{};return t?[{type:t,...r}]:n?[r]:(await ts(e)).map(e=>({type:e.documentType}))}const Es=kr({name:Ss,displayName:`Find documents`,description:`Lists documents by type and name.`,requireAuth:!1,requireReactor:`read`,props:{documentType:rs(`Document type`,!1,`Omit for any type`),parentId:as(`In drive`,`Omit for the whole reactor`),name:q.ShortText({displayName:`Name contains`,description:`Case-insensitive match`,required:!1}),matchPath:q.ShortText({displayName:`State field`,description:`Dotted path into the document's state, e.g. "orderId" or "settlement.status". With a value below, only documents holding it are returned.`,required:!1}),matchValue:q.ShortText({displayName:`State value`,description:`Compared as text, e.g. {{trigger.payload.orderId}}. Documents missing the field never match.`,required:!1}),includeState:q.Checkbox({displayName:`Include state`,description:`Returns each document's state as well as its header. Off by default: a page of documents carries a page of states.`,required:!1,defaultValue:!1}),limit:q.Number({displayName:`Max results`,description:`Defaults to 25, at most 100`,required:!1}),cursor:q.ShortText({displayName:`Cursor`,description:`Resumes a search, e.g. {{steps.find.output.nextCursor}}; omit to start from the first page`,required:!1,advanced:!0})},run:async e=>{let{documentType:t,parentId:n,name:r,limit:i,matchPath:a,matchValue:o,includeState:s}=e.propsValue,c=Math.min(Math.max(typeof i==`number`?i:25,1),100),l=typeof a==`string`?a.trim():``,u=typeof o==`string`?o.trim():``;if(l===``!=(u===``))throw Error(`${Ss}: "State field" and "State value" are set together or not at all`);let d=typeof r==`string`?r.trim().toLowerCase():``,f=l?{path:l,value:u}:void 0,p=e=>(!d||Gr(e).toLowerCase().includes(d))&&qr(e,f),m=d!==``||f!==void 0,h=await Ts(e.reactor,typeof t==`string`&&t.trim()?t.trim():void 0,typeof n==`string`&&n.trim()?n.trim():void 0),g=ws(e.propsValue.cursor)??{q:0,c:``,s:0,l:0},_=[],v;for(let t=0;g.q<h.length;t++){if(m&&t>=20){v=Cs(g);break}let n=g.l||(m?100:Math.max(c-_.length,1)),r=await e.reactor.find(h[g.q],void 0,{cursor:g.c,limit:n}),i=g.s;for(;i<r.results.length&&_.length<c;i++)p(r.results[i])&&_.push(r.results[i]);let a=i<r.results.length?{q:g.q,c:g.c,s:i,l:n}:r.nextCursor&&r.results.length>0?{q:g.q,c:r.nextCursor,s:0,l:0}:g.q+1<h.length?{q:g.q+1,c:``,s:0,l:0}:void 0;if(!a)break;if(_.length>=c){v=Cs(a);break}g=a}return{results:_.map(e=>s===!0?Ur(e):{header:e.header}),...v?{nextCursor:v}:{}}}}),Ds=`document-get`,Os=kr({name:Ds,displayName:`Get document`,description:`Reads a document's current state.`,requireAuth:!1,requireReactor:`read`,props:{documentId:is(`Document id`,!0,`e.g. {{steps.find.output.results.0.header.id}}`),documentType:rs(`Document type`,!1,`Design-time hint when the document id is an expression`),parse:cs()},run:async e=>{let t=zo.of(Ds,e.propsValue.parse),n=t.documentId(e.propsValue.documentId,`documentId`);if(!n)throw Error(`${Ds}: "documentId" is required`);return{...Ur(await e.reactor.get(n)),...t.output()}}}),ks=`document-schema`,As=kr({name:ks,displayName:`Get document schema`,description:`Action and state schemas of a document type.`,requireAuth:!1,requireReactor:`read`,props:{documentType:rs(`Document type`,!1,`Required unless a document id is given`),documentId:is(`Document id`,!1,`Resolves the type from this document instead`),actionType:us(`Only this action`,!1,`Omit to list every action`),parse:cs()},run:async e=>{let t=e.reactor,{actionType:n}=e.propsValue,r=zo.of(ks,e.propsValue.parse),i=typeof e.propsValue.documentType==`string`?e.propsValue.documentType.trim():``,a=i?void 0:r.documentId(e.propsValue.documentId,`documentId`);if(!i&&!a)throw Error(`${ks}: "documentType" is required`);let o=Yr(a?await t.getDocumentModelModuleForDocument(await t.get(a)):await t.getDocumentModelModule(i));return{documentType:o.documentType,name:o.name,stateSchema:o.stateSchema,actions:n?o.actions.filter(e=>e.type===n):o.actions,...r.output()}}}),js=kr({name:`document-types`,displayName:`List document types`,description:`Document models installed on this reactor.`,requireAuth:!1,requireReactor:`read`,props:{},run:async e=>{let t=await ts(e.reactor);return{count:t.length,types:t}}}),Ms=`index-query`,Ns=kr({name:Ms,displayName:`Query index`,description:`Runs a GraphQL query against one of this reactor's index subgraphs (a key index, a mail index, …) as the workflow's user. Outputs the query's data; a refused or unknown index is an error.`,requireAuth:!1,requireReactor:`read`,props:{subgraph:q.ShortText({displayName:`Index`,description:`The subgraph's name as the switchboard registers it, e.g. "key-index".`,required:!0}),query:q.LongText({displayName:`Query`,description:`A GraphQL query document. Mutations are refused.`,required:!0}),variables:q.Json({displayName:`Variables`,description:`The query's variables, as JSON.`,required:!1})},run:async e=>{let t=e.propsValue,n=String(t.subgraph).trim(),r=String(t.query).trim();if(!n)throw Error(`${Ms}: "Index" is required.`);if(!r)throw Error(`${Ms}: "Query" is required.`);let i=await e.reactor.query({subgraph:n,query:r,variables:Ps(t.variables)});if(i.errors?.length)throw Error(`The index "${n}" refused the query: ${i.errors.map(e=>e.message).join(`; `)}`);return i.data??{}}});function Ps(e){if(e==null||e===``)return;let t=typeof e==`string`?JSON.parse(e):e;if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`${Ms}: "Variables" must be a JSON object.`);return t}function Fs(e){return()=>Promise.reject(/* @__PURE__ */ Error(`The "${e}" trigger is fired by the reactor, not polled`))}const Is={documentId:`01234567-89ab-cdef-0123-456789abcdef`,documentType:`powerhouse/workflow`,branch:`main`,scope:`global`,action:{type:`SET_NAME`,input:{name:`Invoice`}},operation:{index:7,timestampUtcMs:`1757500000000`}},Ls={documentId:`01234567-89ab-cdef-0123-456789abcdef`,documentType:`powerhouse/workflow`,name:`Invoice`,driveId:`fedcba98-7654-3210-fedc-ba9876543210`,parentId:null,operation:{index:0,timestampUtcMs:`1757500000000`}},Rs=Ar({name:`document-event`,displayName:`Document event`,description:`Fires when a matching document operation lands.`,type:bn.POLLING,requireAuth:!1,requireReactor:`read`,props:{documentType:rs(`Document type`,!1,`e.g. powerhouse/connection`),documentId:is(`Document id`,!1,`Omit to match any document`),actionType:us(`Action type`,!1,`Omit to match any action`)},sampleData:Is,onEnable:Fs(`document-event`),onDisable:Fs(`document-event`),run:Fs(`document-event`)}),zs=Ar({name:`document-created`,displayName:`Document created`,description:`Fires when a document is added to a drive.`,type:bn.POLLING,requireAuth:!1,requireReactor:`read`,props:{documentType:rs(`Document type`,!1,`Type of the created document; omit to match any`),driveId:as(`Drive`,`Omit to match documents outside every drive too`)},sampleData:Ls,onEnable:Fs(`document-created`),onDisable:Fs(`document-created`),run:Fs(`document-created`)}),Bs=Ar({name:`document-deleted`,displayName:`Document deleted`,description:`Fires when a document is removed from a drive.`,type:bn.POLLING,requireAuth:!1,requireReactor:`read`,props:{documentType:rs(`Document type`,!1,`Type of the deleted document; omit to match any`),driveId:as(`Drive`,`Omit to match documents outside every drive too`)},sampleData:Ls,onEnable:Fs(`document-deleted`),onDisable:Fs(`document-deleted`),run:Fs(`document-deleted`)}),Vs=mr({displayName:`Powerhouse Reactor`,description:`Read and write Powerhouse documents on the reactor this workflow runs in: create documents, dispatch actions, read state, schemas and indexes, and fire on document events.`,logoUrl:`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMTQgMTE0IiBmaWxsPSJub25lIj48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZmlsbD0iIzE2MTYxNiIgZD0iTTcxLjI5MTkgMEwyNC4zNDE1IDM4Ljg3NzJDMTcuNDU0OCA0NC41Nzk4IDE2Ljk1MzkgNTQuOTY1OSAyMy4yNiA2MS4zMDQ3TDM5LjUwMjggNzcuNjMxOEM0NC4yNjg0IDgyLjQyMjEgNDUuMjk5NiA4OS43ODM0IDQyLjAzMzUgOTUuNjk4OEwzMS45MjkgMTE0SDE1LjJDNi44MDUyNyAxMTQgMCAxMDcuMTk1IDAgOTguOFYxNS4yQzAgNi44MDUyNyA2LjgwNTI3IDAgMTUuMiAwSDcxLjI5MTlaTTgwLjExMSAwTDcxLjM0MTIgMTUuOTc1OEM2OC4xMDc4IDIxLjg2NiA2OS4xMjU1IDI5LjE4MDQgNzMuODQ0MSAzMy45NjQxTDkxLjA3NTEgNTEuNDMzMUM5Ny4zNjc0IDU3LjgxMjQgOTYuODA0NCA2OC4yMjI3IDg5Ljg2MDcgNzMuODg2MUw0MC42NzgyIDExNEg5OC44QzEwNy4xOTUgMTE0IDExNCAxMDcuMTk1IDExNCA5OC44VjE1LjJDMTE0IDYuODA1MjcgMTA3LjE5NSAwIDk4LjggMEg4MC4xMTFaIi8+PC9zdmc+`,authors:[`powerhouse`],auth:void 0,actions:[ys,xs,Os,Es,As,js,Ns],triggers:[Rs,zs,Bs]});export{Vs as default,Vs as reactor};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/piece-reactor",
3
- "version": "6.2.3-dev.79",
4
- "description": "Read and write Powerhouse documents on the reactor this workflow runs in: create documents, dispatch actions, read state and schemas, and fire on document events.",
3
+ "version": "6.2.3-dev.80",
4
+ "description": "Read and write Powerhouse documents on the reactor this workflow runs in: create documents, dispatch actions, read state, schemas and indexes, and fire on document events.",
5
5
  "type": "module",
6
6
  "main": "index.mjs",
7
7
  "license": "AGPL-3.0-only",
@@ -145,6 +145,26 @@ function ReactorDenialNote(props) {
145
145
  children: ["No reactor access: ", props.denial]
146
146
  });
147
147
  }
148
+ /** Instead of the draft banner on a managed workflow: who keeps it, and that edits here are not saved. */
149
+ function ManagedBanner(props) {
150
+ const manager = props.model.managedBy;
151
+ if (!manager) return null;
152
+ return /* @__PURE__ */ jsxs("div", {
153
+ role: "status",
154
+ className: "pointer-events-auto flex max-w-xl items-center gap-3 rounded-lg border border-solid border-foreground/10 bg-card px-3 py-1.5 text-[13px] shadow-sm",
155
+ children: [/* @__PURE__ */ jsx("span", {
156
+ className: "h-2 w-2 shrink-0 rounded-full bg-muted-foreground",
157
+ "aria-hidden": true
158
+ }), /* @__PURE__ */ jsxs("span", {
159
+ className: "text-foreground",
160
+ children: [
161
+ "Managed by ",
162
+ /* @__PURE__ */ jsx("strong", { children: manager.label || manager.documentType }),
163
+ ". Change it there: edits here are not saved."
164
+ ]
165
+ })]
166
+ });
167
+ }
148
168
  function DraftBanner(props) {
149
169
  if (!hasDraftChanges(props.model)) return null;
150
170
  const { readiness } = props;
@@ -487,6 +507,6 @@ function describeTrigger(trigger) {
487
507
  }
488
508
  }
489
509
  //#endregion
490
- export { StepError as a, PublishState as c, StatusToggle as d, usePublish as f, uniqueStepKey as g, hasDraftChanges as h, DataViewer as i, PublishedMissingNote as l, VARIABLES_VIEW as m, describeSchedule as n, DraftBanner as o, STEP_PARAM as p, describeTrigger as r, PublishButton as s, describeCron as t, ReactorDenialNote as u };
510
+ export { uniqueStepKey as _, StepError as a, PublishButton as c, ReactorDenialNote as d, StatusToggle as f, hasDraftChanges as g, VARIABLES_VIEW as h, DataViewer as i, PublishState as l, STEP_PARAM as m, describeSchedule as n, DraftBanner as o, usePublish as p, describeTrigger as r, ManagedBanner as s, describeCron as t, PublishedMissingNote as u };
491
511
 
492
- //# sourceMappingURL=trigger-text-BRqIHmRS.mjs.map
512
+ //# sourceMappingURL=trigger-text-CmYejeFN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trigger-text-CmYejeFN.mjs","names":[],"sources":["../../editors/workflow-editor/ui/model.ts","../../editors/workflow-editor/ui/PublishControls.tsx","../../editors/workflow-editor/ui/StepError.tsx","../../editors/shared/document-ref.tsx","../../editors/shared/data-viewer.tsx","../../editors/workflow-editor/ui/trigger-text.ts"],"sourcesContent":["// Plain view model + callbacks; no document-model imports so the UI layer\n// stays independent of Powerhouse document plumbing.\nimport type { AddedBlock } from \"./add-follow-up.js\";\nimport type { BlockForm } from \"./forms.js\";\n\nexport type WorkflowStatusValue = \"DRAFT\" | \"ENABLED\" | \"DISABLED\" | \"ARCHIVED\";\n\nexport interface PointModel {\n x: number;\n y: number;\n}\n\nexport type PropertyModeValue = \"MANUAL\" | \"EXPRESSION\";\n\nexport interface PropertySettingModel {\n prop: string;\n mode: PropertyModeValue;\n // A DYNAMIC prop's resolved children, options stripped.\n schema?: unknown;\n}\n\nexport interface TestRecordModel {\n runId: string;\n testedAt: string;\n}\n\n// Editor bookkeeping on a step or the trigger; absent on older documents.\nexport interface BlockStateModel {\n propertySettings?: PropertySettingModel[] | null;\n lastTest?: TestRecordModel | null;\n updatedAt?: string | null;\n}\n\nexport interface TriggerModel extends BlockStateModel {\n id: string;\n pieceName: string;\n pieceVersion: string;\n triggerName: string;\n config: unknown;\n connectionId: string | null;\n // A REACTOR connection, for a trigger that declares requireReactor.\n reactorConnectionId?: string | null;\n}\n\nexport type BackoffKindValue = \"FIXED\" | \"EXPONENTIAL\";\n\nexport interface RetryPolicyModel {\n maxAttempts: number;\n backoff: BackoffKindValue;\n initialDelaySeconds: number;\n maxDelaySeconds: number;\n retryOn: string[];\n}\n\nexport interface StepModel extends BlockStateModel {\n id: string;\n key: string;\n name: string;\n pieceName: string;\n pieceVersion: string;\n actionName: string;\n connectionId: string | null;\n // A REACTOR connection, for an action that declares requireReactor.\n reactorConnectionId?: string | null;\n config: unknown;\n retry: RetryPolicyModel | null;\n timeoutSeconds: number | null;\n idempotencyKeyExpression: string | null;\n position: PointModel | null;\n skip?: boolean;\n}\n\nexport interface EdgeModel {\n id: string;\n from: string;\n to: string;\n port: string;\n condition: string | null;\n}\n\nexport type VariableTypeValue =\n | \"TEXT\"\n | \"NUMBER\"\n | \"BOOLEAN\"\n | \"JSON\"\n | \"SECRET\";\n\nexport interface VariableModel {\n id: string;\n key: string;\n value: unknown;\n description: string | null;\n // Null means untyped: the type is inferred from the value.\n type?: VariableTypeValue | null;\n}\n\nexport interface PublishedBlockModel {\n id: string;\n // The step's name, or \"Trigger\".\n label: string;\n pieceName: string;\n pieceVersion: string;\n kind: \"action\" | \"trigger\";\n name: string;\n reactorConnectionId: string | null;\n}\n\nexport interface PublishedModel {\n version: number;\n publishedAt: string;\n // The snapshot's blocks, trigger first; what actually runs.\n blocks?: PublishedBlockModel[];\n}\n\nexport interface WorkflowModel {\n name: string;\n description?: string | null;\n status: WorkflowStatusValue;\n version: number;\n trigger: TriggerModel | null;\n steps: StepModel[];\n edges: EdgeModel[];\n variables: VariableModel[];\n published?: PublishedModel | null;\n // Writes nothing, bookkeeping included.\n readOnly?: boolean;\n // Kept by another document (an app's integration): shown read-only.\n managedBy?: {\n documentId: string;\n documentType: string;\n label: string;\n } | null;\n}\n\n// The side panel's id for the variables editor, beside step and trigger ids.\nexport const VARIABLES_VIEW = \"__variables\";\n\n/** Query params of the editor's view: the open panel and its tab. */\nexport const STEP_PARAM = \"step\";\nexport const TAB_PARAM = \"tab\";\n\n// Unpublished changes: never published, or edited since.\nexport function hasDraftChanges(\n model: Pick<WorkflowModel, \"version\" | \"published\">,\n): boolean {\n return !model.published || model.published.version !== model.version;\n}\n\nexport interface AddStepInputModel {\n key: string;\n name: string;\n pieceName: string;\n pieceVersion: string;\n actionName: string;\n config: unknown;\n position?: PointModel;\n}\n\nexport interface UpdateStepInputModel {\n id: string;\n key?: string;\n name?: string;\n // \"Update to vZ\" edits only pieceVersion.\n pieceName?: string;\n pieceVersion?: string;\n actionName?: string;\n // null clears the step's connection.\n connectionId?: string | null;\n reactorConnectionId?: string | null;\n config?: unknown;\n // null clears each of these; undefined leaves them unchanged.\n retry?: RetryPolicyModel | null;\n timeoutSeconds?: number | null;\n idempotencyKeyExpression?: string | null;\n position?: PointModel;\n skip?: boolean;\n}\n\n// Field modes and DYNAMIC schemas ride along with the config edit they\n// belong to; undefined leaves them as they are.\nexport interface ConfigExtras {\n propertySettings?: PropertySettingModel[];\n}\n\nexport interface WorkflowEditorCallbacks {\n setName: (name: string) => void;\n setDescription: (description: string) => void;\n setStatus: (status: WorkflowStatusValue) => void;\n setTrigger: (\n input: {\n pieceName: string;\n pieceVersion: string;\n triggerName: string;\n config: unknown;\n connectionId?: string | null;\n reactorConnectionId?: string | null;\n } & ConfigExtras,\n ) => AddedBlock;\n // Field-level trigger edits: each leaves the trigger's other fields alone.\n setTriggerConfig: (config: unknown, extras?: ConfigExtras) => void;\n // null clears a connection; undefined leaves it unchanged.\n setTriggerConnection: (input: {\n connectionId?: string | null;\n reactorConnectionId?: string | null;\n }) => void;\n setTriggerPieceVersion: (pieceVersion: string) => void;\n clearTrigger: () => void;\n addStep: (input: AddStepInputModel) => AddedBlock;\n updateStep: (input: UpdateStepInputModel) => void;\n setStepConfig: (id: string, config: unknown, extras?: ConfigExtras) => void;\n // Snapshots the draft and turns the workflow on; resolves once applied.\n publish: () => Promise<void>;\n discardChanges: () => void;\n removeStep: (id: string) => void;\n addEdge: (input: {\n from: string;\n to: string;\n port: string;\n condition?: string;\n }) => void;\n removeEdge: (id: string) => void;\n // Upserts by id; no id adds a variable. Keys are unique.\n setVariable: (input: {\n id?: string;\n key: string;\n value: unknown;\n description?: string;\n // Undefined leaves the type as is; null clears it.\n type?: VariableTypeValue | null;\n }) => void;\n removeVariable: (id: string) => void;\n // Composite operations backing the canvas add buttons.\n // `port` is the inserted block's own port the old edge's target hangs off.\n insertStepOnEdge: (\n edgeId: string,\n input: AddStepInputModel,\n port: string,\n ) => AddedBlock | undefined;\n appendStep: (\n fromId: string,\n port: string,\n input: AddStepInputModel,\n ) => AddedBlock;\n // Completes a block added before its form loaded: the defaults still unset\n // and the port it continues on. Nothing when the block is gone.\n completeBlock: (added: AddedBlock, form: BlockForm) => void;\n // Copies a step with its config and advanced settings, detached from the\n // graph so no port ends up with two edges.\n duplicateStep: (id: string) => void;\n // Re-parents a step onto a port, keeping whatever follows it.\n moveStep: (move: {\n stepId: string;\n toParentId: string;\n port: string;\n }) => void;\n}\n\n// Slugified step key derived from a label, suffixed until it is free.\nexport function uniqueStepKey(taken: string[], label: string): string {\n const base =\n label\n .toLowerCase()\n .replaceAll(/[^a-z0-9]+/g, \"_\")\n .replaceAll(/^_+|_+$/g, \"\") || \"step\";\n const keys = new Set(taken);\n let key = base;\n let suffix = 2;\n while (keys.has(key)) key = `${base}_${suffix++}`;\n return key;\n}\n","// Publishing, the Activepieces way: a draft that is always editable, a\n// Publish that snapshots it, and an on/off switch for the published flow.\nimport { useState } from \"react\";\nimport { Button, Toggle, Tooltip } from \"../../shared/controls.js\";\nimport {\n hasDraftChanges,\n type WorkflowEditorCallbacks,\n type WorkflowModel,\n type WorkflowStatusValue,\n} from \"./model.js\";\nimport type { WorkflowReadiness } from \"./validation.js\";\n\n// Under enforcement a publish must be signed, or its runs reach no documents.\nexport interface PublishSignIn {\n required: boolean;\n pending: boolean;\n login: () => void;\n}\n\nfunction blockedReason(readiness: WorkflowReadiness): string {\n if (!readiness.hasTrigger) return \"Add a trigger first\";\n if (readiness.firstIncomplete) return \"You have incomplete steps\";\n return \"Checking the steps…\";\n}\n\nexport function usePublish(callbacks: WorkflowEditorCallbacks) {\n const [publishing, setPublishing] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const publish = () => {\n if (publishing) return;\n setPublishing(true);\n setError(null);\n callbacks\n .publish()\n .catch((cause: unknown) =>\n setError(cause instanceof Error ? cause.message : String(cause)),\n )\n .finally(() => setPublishing(false));\n };\n return { publishing, error, publish };\n}\n\nexport function PublishButton(props: {\n model: WorkflowModel;\n readiness: WorkflowReadiness;\n publishing: boolean;\n onPublish: () => void;\n onSelect: (id: string) => void;\n size?: \"sm\" | \"md\";\n signIn?: PublishSignIn;\n}) {\n const { model, readiness } = props;\n if (props.signIn?.required) {\n return (\n <Tooltip content=\"This Switchboard enforces document permissions, so a publish must be signed\">\n <Button\n size={props.size ?? \"sm\"}\n variant=\"primary\"\n disabled={props.signIn.pending}\n onClick={props.signIn.login}\n >\n Sign in to publish\n </Button>\n </Tooltip>\n );\n }\n const incomplete = !readiness.ready;\n const changes = hasDraftChanges(model);\n const target = readiness.firstIncomplete;\n const select = () => {\n if (target) props.onSelect(target);\n };\n return (\n <Tooltip\n enabled={incomplete}\n content={\n <button\n type=\"button\"\n className=\"font-medium text-wf-warn hover:underline\"\n onClick={select}\n >\n {blockedReason(readiness)}\n </button>\n }\n >\n {/* The disabled button passes clicks through to this wrapper. */}\n <span className=\"inline-flex\" onClick={incomplete ? select : undefined}>\n <Button\n size={props.size ?? \"sm\"}\n variant=\"primary\"\n disabled={incomplete || !changes || props.publishing}\n title={!changes && !incomplete ? \"No unpublished changes\" : undefined}\n onClick={props.onPublish}\n >\n {props.publishing ? \"Publishing…\" : \"Publish\"}\n </Button>\n </span>\n </Tooltip>\n );\n}\n\n// A dot and a word: Draft until first published, then Published, or\n// Unpublished changes once the draft moves on.\nexport function PublishState(props: {\n model: Pick<WorkflowModel, \"version\" | \"published\">;\n}) {\n const draft = hasDraftChanges(props.model);\n return (\n <span\n className=\"flex shrink-0 items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground\"\n title={\n props.model.published\n ? `Published ${new Date(props.model.published.publishedAt).toLocaleString()}`\n : \"Never published\"\n }\n >\n <span\n aria-hidden\n className={`h-2 w-2 rounded-full ${draft ? \"bg-wf-warn\" : \"bg-wf-ok\"}`}\n />\n <span>\n {!props.model.published\n ? \"Draft\"\n : draft\n ? \"Unpublished changes\"\n : \"Published\"}\n </span>\n {props.model.published && draft ? (\n <span className=\"text-muted-foreground/80\">\n · v{props.model.published.version} live\n </span>\n ) : null}\n </span>\n );\n}\n\nexport function StatusToggle(props: {\n published: boolean;\n status: WorkflowStatusValue;\n onChange: (status: WorkflowStatusValue) => void;\n tooltipSide?: \"below\" | \"left\";\n}) {\n // Nothing runs until the first publish.\n const allowed = props.published;\n const on = props.status === \"ENABLED\";\n return (\n <Tooltip\n enabled={!allowed}\n content=\"Publish the workflow first\"\n align=\"end\"\n side={props.tooltipSide}\n >\n <span className=\"flex items-center gap-2 text-xs text-muted-foreground\">\n <Toggle\n checked={on}\n disabled={!allowed}\n label={on ? \"Turn the workflow off\" : \"Turn the workflow on\"}\n onChange={(checked) =>\n props.onChange(checked ? \"ENABLED\" : \"DISABLED\")\n }\n />\n <span className=\"w-6\">{on ? \"On\" : \"Off\"}</span>\n </span>\n </Tooltip>\n );\n}\n\n// The live snapshot's blocks that need a reactor connection and bind none.\nexport function PublishedMissingNote(props: { missing: readonly string[] }) {\n if (props.missing.length === 0) return null;\n return (\n <span\n role=\"alert\"\n aria-label=\"Published version incomplete\"\n className=\"shrink-0 whitespace-nowrap rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs text-wf-warn\"\n title={`The published version is missing a reactor connection on: ${props.missing.join(\", \")}`}\n >\n Live version incomplete\n </span>\n );\n}\n\n// Why the runtime won't give the published workflow reactor access.\nexport function ReactorDenialNote(props: { denial: string | null }) {\n if (!props.denial) return null;\n return (\n <span\n role=\"alert\"\n aria-label=\"Reactor access denied\"\n className=\"max-w-80 truncate rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs text-wf-warn\"\n title={props.denial}\n >\n No reactor access: {props.denial}\n </span>\n );\n}\n\n/** Instead of the draft banner on a managed workflow: who keeps it, and that edits here are not saved. */\nexport function ManagedBanner(props: { model: WorkflowModel }) {\n const manager = props.model.managedBy;\n if (!manager) return null;\n return (\n <div\n role=\"status\"\n className=\"pointer-events-auto flex max-w-xl items-center gap-3 rounded-lg border border-solid border-foreground/10 bg-card px-3 py-1.5 text-[13px] shadow-sm\"\n >\n <span\n className=\"h-2 w-2 shrink-0 rounded-full bg-muted-foreground\"\n aria-hidden\n />\n <span className=\"text-foreground\">\n Managed by <strong>{manager.label || manager.documentType}</strong>.\n Change it there: edits here are not saved.\n </span>\n </div>\n );\n}\n\nexport function DraftBanner(props: {\n model: WorkflowModel;\n readiness: WorkflowReadiness;\n publishing: boolean;\n error: string | null;\n onPublish: () => void;\n onDiscard: () => void;\n onSelect: (id: string) => void;\n signIn?: PublishSignIn;\n}) {\n if (!hasDraftChanges(props.model)) return null;\n const { readiness } = props;\n const target = readiness.firstIncomplete;\n return (\n <div\n role=\"status\"\n className=\"pointer-events-auto flex items-center gap-3 rounded-lg border border-solid border-foreground/10 bg-card py-1.5 pl-3 pr-1.5 text-[13px] shadow-sm\"\n >\n <span className=\"h-2 w-2 shrink-0 rounded-full bg-wf-warn\" aria-hidden />\n <span className=\"text-foreground\">You have unpublished changes</span>\n {props.error ? (\n <span className=\"text-xs text-wf-fail\">{props.error}</span>\n ) : null}\n {!readiness.hasTrigger || target ? (\n <span className=\"flex items-center gap-1.5 text-xs text-wf-warn\">\n <span>{target ? \"Incomplete steps\" : \"No trigger yet\"}</span>\n {target ? (\n <button\n type=\"button\"\n className=\"font-medium underline underline-offset-2 hover:no-underline\"\n onClick={() => props.onSelect(target)}\n >\n Show\n </button>\n ) : null}\n </span>\n ) : null}\n <span className=\"flex items-center gap-1\">\n {props.model.published ? (\n <Button size=\"sm\" variant=\"ghost\" onClick={props.onDiscard}>\n Discard changes\n </Button>\n ) : null}\n <PublishButton\n model={props.model}\n readiness={readiness}\n publishing={props.publishing}\n onPublish={props.onPublish}\n onSelect={props.onSelect}\n signIn={props.signIn}\n />\n </span>\n </div>\n );\n}\n","// A step's error from a run.\nexport function StepError(props: { error: string }) {\n return (\n <pre className=\"overflow-auto whitespace-pre-wrap rounded-md bg-wf-fail/10 p-2.5 text-xs text-wf-fail\">\n {props.error}\n </pre>\n );\n}\n","// The documents a run's data references: the run journal keeps a reference\n// (id, type, branch, revision) in place of a document's state.\nimport type { DocumentReference } from \"@powerhousedao/pieces-framework/workflow\";\nimport { useSetSelectedNode } from \"@powerhousedao/reactor-browser\";\nimport { Button } from \"./controls.js\";\n\n// Beyond this many, the rest are counted.\nconst SHOWN = 3;\n\nfunction shortId(id: string): string {\n return id.length > 16 ? `${id.slice(0, 6)}…${id.slice(-6)}` : id;\n}\n\nfunction revisionText(reference: DocumentReference): string {\n const scopes = Object.entries(reference.revision)\n .map(([scope, count]) => `${scope} ${count}`)\n .join(\" · \");\n return reference.branch === \"main\"\n ? scopes\n : `${reference.branch}: ${scopes}`;\n}\n\nfunction DocumentRefRow(props: { reference: DocumentReference }) {\n const { reference } = props;\n const setSelectedNode = useSetSelectedNode();\n return (\n <li\n aria-label={`Document ${reference.documentId}`}\n className=\"flex items-center gap-2\"\n >\n <div className=\"min-w-0 flex-1 text-xs\">\n <div className=\"flex min-w-0 items-baseline gap-1.5\">\n <span className=\"truncate font-medium text-foreground\">\n {reference.documentType}\n </span>\n <span\n className=\"shrink-0 font-mono text-[11px] text-muted-foreground\"\n title={reference.documentId}\n >\n {shortId(reference.documentId)}\n </span>\n </div>\n <div className=\"truncate text-[11px] text-muted-foreground\">\n Revision {revisionText(reference)}\n </div>\n </div>\n <Button\n size=\"sm\"\n onClick={() => setSelectedNode(reference.documentId)}\n aria-label={`Open document ${reference.documentId}`}\n >\n Open document\n </Button>\n </li>\n );\n}\n\nexport function DocumentRefs(props: { references: DocumentReference[] }) {\n const { references } = props;\n const hidden = references.length - SHOWN;\n return (\n <div\n role=\"group\"\n aria-label=\"Document references\"\n className=\"flex flex-col gap-1.5\"\n >\n <ul className=\"m-0 flex list-none flex-col gap-1.5 p-0\">\n {references.slice(0, SHOWN).map((reference, index) => (\n <DocumentRefRow\n key={`${reference.documentId}-${index}`}\n reference={reference}\n />\n ))}\n </ul>\n {hidden > 0 ? (\n <p className=\"text-[11px] text-muted-foreground\">\n and {hidden} more in the data below\n </p>\n ) : null}\n <p className=\"text-[11px] text-muted-foreground\">\n The run kept a reference, not the state. Opening shows the document as\n it is now: past revisions can&apos;t be read yet (#3179).\n </p>\n </div>\n );\n}\n","// A run's data (a step's input or output, a trigger payload) as a foldable\n// tree, with a raw JSON view and, given a root, per-key {{references}}.\nimport {\n DOCUMENT_REF_KEY,\n documentRefsIn,\n isDocumentRefMarker,\n} from \"@powerhousedao/pieces-framework/workflow\";\nimport { lazy, Suspense, useState } from \"react\";\nimport { IconButton } from \"./controls.js\";\nimport { DocumentRefs } from \"./document-ref.js\";\n\nconst DataTree = lazy(() => import(\"./data-tree.js\"));\n\nfunction stringify(value: unknown): string {\n try {\n // undefined for functions and symbols, despite the typing.\n return (JSON.stringify(value, null, 2) as string | undefined) ?? \"\";\n } catch {\n return String(value as string);\n }\n}\n\nfunction isEmpty(value: unknown): boolean {\n if (value === undefined || value === null) return true;\n if (typeof value === \"object\") return Object.keys(value).length === 0;\n return false;\n}\n\nfunction RawJson(props: { text: string }) {\n return (\n <pre className=\"max-h-72 overflow-auto whitespace-pre-wrap break-words font-mono text-xs text-foreground\">\n {props.text}\n </pre>\n );\n}\n\n// Stands in while the tree's chunk loads.\nfunction TreeSkeleton() {\n return (\n <div\n role=\"status\"\n aria-label=\"Loading data\"\n className=\"flex animate-pulse flex-col gap-2 py-1\"\n >\n {[\"w-2/5\", \"w-3/5\", \"w-1/2\", \"w-1/3\"].map((width, index) => (\n <span\n key={width}\n className={`h-2.5 rounded bg-muted ${width}`}\n style={{ marginLeft: index === 0 ? 0 : 16 }}\n />\n ))}\n </div>\n );\n}\n\nexport function DataViewer(props: {\n label: string;\n value: unknown;\n // Expression prefix for this value, e.g. \"steps.fetch.output\".\n root?: string;\n emptyText?: string;\n}) {\n const [raw, setRaw] = useState(false);\n const [copied, setCopied] = useState(false);\n const empty = isEmpty(props.value);\n const text = stringify(props.value);\n const tree = typeof props.value === \"object\" && props.value !== null;\n const references = tree ? documentRefsIn(props.value) : [];\n // A whole value that is a reference shows as one; its other keys stay a tree.\n const treeValue = isDocumentRefMarker(props.value)\n ? Object.fromEntries(\n Object.entries(props.value).filter(([key]) => key !== DOCUMENT_REF_KEY),\n )\n : props.value;\n\n return (\n <section\n aria-label={props.label}\n className=\"min-w-0 rounded-md border border-solid border-border bg-card\"\n >\n <header className=\"flex h-8 items-center gap-1 border-b border-solid border-border pl-3 pr-1\">\n <h4 className=\"mr-auto text-xs font-medium text-foreground\">\n {props.label}\n </h4>\n {!empty && tree ? (\n <button\n type=\"button\"\n aria-pressed={raw}\n className=\"rounded px-1.5 py-0.5 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40\"\n onClick={() => setRaw((value) => !value)}\n >\n {raw ? \"Tree\" : \"JSON\"}\n </button>\n ) : null}\n {!empty ? (\n <IconButton\n icon={copied ? \"check\" : \"copy\"}\n label={`Copy ${props.label.toLowerCase()} as JSON`}\n onClick={() => {\n void navigator.clipboard.writeText(text).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1500);\n });\n }}\n />\n ) : null}\n </header>\n <div className=\"px-3 py-2\">\n {empty ? (\n <p className=\"text-xs text-muted-foreground\">\n {props.emptyText ?? \"Nothing\"}\n </p>\n ) : !tree ? (\n <p className=\"break-words font-mono text-xs text-foreground\">\n {text}\n </p>\n ) : raw ? (\n <RawJson text={text} />\n ) : (\n <div className=\"flex flex-col gap-2\">\n {references.length > 0 ? (\n <DocumentRefs references={references} />\n ) : null}\n {isEmpty(treeValue) ? null : (\n <div className=\"max-h-72 overflow-auto\">\n <Suspense fallback={<TreeSkeleton />}>\n <DataTree value={treeValue as object} root={props.root} />\n </Suspense>\n </div>\n )}\n </div>\n )}\n </div>\n </section>\n );\n}\n","// Plain-language descriptions of when a workflow starts: \"Every day at\n// 08:00 UTC\" rather than \"0 8 * * *\". Unknown shapes fall back to the raw text.\nimport { blockKey } from \"@powerhousedao/pieces-framework/block-type\";\nimport { blockMeta } from \"./block-meta.js\";\nimport {\n MANUAL_TRIGGER,\n REACTOR_PIECE,\n SCHEDULE_TRIGGER,\n WEBHOOK_TRIGGER,\n} from \"./blocks.js\";\nimport { parseScheduleConfig } from \"@powerhousedao/pieces-framework/workflow\";\n\nconst WEEKDAYS = [\n \"Sunday\",\n \"Monday\",\n \"Tuesday\",\n \"Wednesday\",\n \"Thursday\",\n \"Friday\",\n \"Saturday\",\n];\n\nconst UNIT_LABEL: Record<string, [string, string]> = {\n minutes: [\"minute\", \"minutes\"],\n hours: [\"hour\", \"hours\"],\n days: [\"day\", \"days\"],\n};\n\nfunction isInt(field: string): boolean {\n return /^\\d+$/.test(field);\n}\n\nfunction clock(hour: string, minute: string): string {\n return `${hour.padStart(2, \"0\")}:${minute.padStart(2, \"0\")}`;\n}\n\nfunction dayList(field: string): string | undefined {\n if (field === \"1-5\") return \"on weekdays\";\n if (field === \"0,6\" || field === \"6,0\") return \"at weekends\";\n const days = field.split(\",\");\n if (!days.every((day) => isInt(day) && Number(day) <= 7)) return undefined;\n const names = days.map((day) => WEEKDAYS[Number(day) % 7]);\n if (names.length === 1) return `every ${names[0]}`;\n return `on ${names.slice(0, -1).join(\", \")} and ${names[names.length - 1]}`;\n}\n\n/** Describes a five-field cron expression, or returns undefined. */\nexport function describeCron(cron: string): string | undefined {\n const fields = cron.trim().split(/\\s+/);\n if (fields.length !== 5) return undefined;\n const [minute, hour, dayOfMonth, month, dayOfWeek] = fields;\n if (month !== \"*\") return undefined;\n\n const everyMinutes = /^\\*\\/(\\d+)$/.exec(minute);\n if (everyMinutes && hour === \"*\" && dayOfMonth === \"*\" && dayOfWeek === \"*\") {\n const n = Number(everyMinutes[1]);\n return n === 1 ? \"Every minute\" : `Every ${n} minutes`;\n }\n if (minute === \"*\" && hour === \"*\" && dayOfMonth === \"*\" && dayOfWeek === \"*\")\n return \"Every minute\";\n if (isInt(minute) && hour === \"*\" && dayOfMonth === \"*\" && dayOfWeek === \"*\")\n return minute === \"0\"\n ? \"Every hour, on the hour\"\n : `Every hour at ${minute.padStart(2, \"0\")} past`;\n\n const everyHours = /^\\*\\/(\\d+)$/.exec(hour);\n if (isInt(minute) && everyHours && dayOfMonth === \"*\" && dayOfWeek === \"*\") {\n return `Every ${everyHours[1]} hours`;\n }\n if (!isInt(minute) || !isInt(hour)) return undefined;\n const at = clock(hour, minute);\n\n if (dayOfMonth === \"*\" && dayOfWeek === \"*\") return `Every day at ${at}`;\n if (dayOfMonth === \"*\") {\n const days = dayList(dayOfWeek);\n return days\n ? `${days.charAt(0).toUpperCase()}${days.slice(1)} at ${at}`\n : undefined;\n }\n if (isInt(dayOfMonth) && dayOfWeek === \"*\") {\n return `Every month on day ${dayOfMonth} at ${at}`;\n }\n return undefined;\n}\n\nexport function describeSchedule(config: unknown): string {\n let schedule;\n try {\n schedule = parseScheduleConfig(config);\n } catch {\n return \"On a schedule that does not parse\";\n }\n if (schedule.mode === \"interval\") {\n const unit = UNIT_LABEL[schedule.unit];\n return schedule.every === 1\n ? `Every ${unit[0]}`\n : `Every ${schedule.every} ${unit[1]}`;\n }\n const described = describeCron(schedule.cron);\n return described\n ? `${described} ${schedule.timezone}`\n : `On schedule ${schedule.cron}`;\n}\n\n// A literal config value; an expression or a blank says nothing to show.\nfunction literal(config: unknown, key: string): string | undefined {\n if (!config || typeof config !== \"object\") return undefined;\n const value = (config as Record<string, unknown>)[key];\n if (typeof value !== \"string\") return undefined;\n const text = value.trim();\n return text && !text.includes(\"{{\") ? text : undefined;\n}\n\n// \"umh/production-ledger\" reads as \"Production Ledger\".\nfunction documentTypeLabel(documentType: string): string {\n const name = documentType.split(\"/\").pop() ?? documentType;\n return name\n .split(/[-_\\s]+/)\n .filter(Boolean)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\" \");\n}\n\n// \"APPROVE_ORDER\" reads as \"Approve order\".\nfunction actionTypeLabel(actionType: string): string {\n const words = actionType\n .toLowerCase()\n .split(/[_\\s]+/)\n .filter(Boolean);\n const text = words.join(\" \");\n return text.charAt(0).toUpperCase() + text.slice(1);\n}\n\n/** Describes a reactor document trigger by what it filters on. */\nexport function describeDocumentTrigger(\n triggerName: string,\n config: unknown,\n): string | undefined {\n const documentType = literal(config, \"documentType\");\n const label = documentType ? documentTypeLabel(documentType) : \"\";\n const subject = label\n ? `${/^[AEIOU]/.test(label) ? \"an\" : \"a\"} ${label}`\n : literal(config, \"documentId\")\n ? \"its document\"\n : \"a document\";\n switch (triggerName) {\n case \"document-event\": {\n const actionType = literal(config, \"actionType\");\n return actionType\n ? `When ${actionTypeLabel(actionType)} runs on ${subject}`\n : `When ${subject} changes`;\n }\n case \"document-created\":\n return `When ${subject} is created`;\n case \"document-deleted\":\n return `When ${subject} is deleted`;\n default:\n return undefined;\n }\n}\n\n/** When a workflow starts, from its trigger. */\nexport function describeTrigger(\n trigger:\n | { pieceName: string; triggerName: string; config: unknown }\n | null\n | undefined,\n): string {\n if (!trigger) return \"Never starts: no trigger\";\n const block = {\n pieceName: trigger.pieceName,\n kind: \"trigger\" as const,\n name: trigger.triggerName,\n };\n switch (blockKey(block)) {\n case blockKey(MANUAL_TRIGGER):\n return \"Manual\";\n case blockKey(WEBHOOK_TRIGGER):\n return \"When its webhook is called\";\n case blockKey(SCHEDULE_TRIGGER):\n return describeSchedule(trigger.config);\n default: {\n if (trigger.pieceName === REACTOR_PIECE) {\n const described = describeDocumentTrigger(\n trigger.triggerName,\n trigger.config,\n );\n if (described) return described;\n }\n const meta = blockMeta(block);\n const piece = meta.subtitle.replace(/ · Trigger$/, \"\");\n return `${meta.displayName} in ${piece}`;\n }\n }\n}\n"],"mappings":";;;;;;;AAuIA,MAAa,iBAAiB;;AAG9B,MAAa,aAAa;AAI1B,SAAgB,gBACd,OACS;CACT,OAAO,CAAC,MAAM,aAAa,MAAM,UAAU,YAAY,MAAM;AAC/D;AAgHA,SAAgB,cAAc,OAAiB,OAAuB;CACpE,MAAM,OACJ,MACG,YAAY,CAAC,CACb,WAAW,eAAe,GAAG,CAAC,CAC9B,WAAW,YAAY,EAAE,KAAK;CACnC,MAAM,OAAO,IAAI,IAAI,KAAK;CAC1B,IAAI,MAAM;CACV,IAAI,SAAS;CACb,OAAO,KAAK,IAAI,GAAG,GAAG,MAAM,GAAG,KAAK,GAAG;CACvC,OAAO;AACT;;;AC1PA,SAAS,cAAc,WAAsC;CAC3D,IAAI,CAAC,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BAAgB,UAAU,EAAE,WAAW,YAC/C,QAAQ,QAAQ;EACtB;EACA,KAAK,oBACH,OAAO,QAAQ,QAAQ;EACzB,KAAK,oBACH,OAAO,QAAQ,QAAQ;EACzB,SACE;CACJ;AACF;;AAGA,SAAgB,gBACd,SAIQ;CACR,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,QAAQ;EACZ,WAAW,QAAQ;EACnB,MAAM;EACN,MAAM,QAAQ;CAChB;CACA,QAAQ,SAAS,KAAK,GAAtB;EACE,KAAK,SAAS,cAAc,GAC1B,OAAO;EACT,KAAK,SAAS,eAAe,GAC3B,OAAO;EACT,KAAK,SAAS,gBAAgB,GAC5B,OAAO,iBAAiB,QAAQ,MAAM;EACxC,SAAS;GACP,IAAI,QAAQ,cAAA,gCAA6B;IACvC,MAAM,YAAY,wBAChB,QAAQ,aACR,QAAQ,MACV;IACA,IAAI,WAAW,OAAO;GACxB;GACA,MAAM,OAAO,UAAU,KAAK;GAC5B,MAAM,QAAQ,KAAK,SAAS,QAAQ,eAAe,EAAE;GACrD,OAAO,GAAG,KAAK,YAAY,MAAM;EACnC;CACF;AACF"}
@@ -1,8 +1,8 @@
1
1
  import { m as connectionUpgradeManifest } from "./module-weVJEMpP.mjs";
2
- import { m as workflowUpgradeManifest } from "./module-DV3LLvxo.mjs";
2
+ import { m as workflowUpgradeManifest } from "./module-D9Zx5Zow.mjs";
3
3
  //#region document-models/upgrade-manifests.ts
4
4
  const upgradeManifests = [connectionUpgradeManifest, workflowUpgradeManifest];
5
5
  //#endregion
6
6
  export { upgradeManifests as t };
7
7
 
8
- //# sourceMappingURL=upgrade-manifests-CO9zzPnE.mjs.map
8
+ //# sourceMappingURL=upgrade-manifests-VF8Jt_YR.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade-manifests-CO9zzPnE.mjs","names":[],"sources":["../../document-models/upgrade-manifests.ts"],"sourcesContent":["/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { UpgradeManifest } from \"document-model\";\nimport { connectionUpgradeManifest } from \"document-models/connection/upgrades\";\nimport { workflowUpgradeManifest } from \"document-models/workflow/upgrades\";\n\nexport const upgradeManifests: UpgradeManifest<readonly number[]>[] = [\n connectionUpgradeManifest,\n workflowUpgradeManifest,\n];\n"],"mappings":";;;AAQA,MAAa,mBAAyD,CACpE,2BACA,uBACF"}
1
+ {"version":3,"file":"upgrade-manifests-VF8Jt_YR.mjs","names":[],"sources":["../../document-models/upgrade-manifests.ts"],"sourcesContent":["/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { UpgradeManifest } from \"document-model\";\nimport { connectionUpgradeManifest } from \"document-models/connection/upgrades\";\nimport { workflowUpgradeManifest } from \"document-models/workflow/upgrades\";\n\nexport const upgradeManifests: UpgradeManifest<readonly number[]>[] = [\n connectionUpgradeManifest,\n workflowUpgradeManifest,\n];\n"],"mappings":";;;AAQA,MAAa,mBAAyD,CACpE,2BACA,uBACF"}
@@ -1,4 +1,4 @@
1
- import { a as utils, d as isWorkflowDocument, l as assertIsWorkflowDocument, t as Workflow } from "./module-DV3LLvxo.mjs";
1
+ import { a as utils, d as isWorkflowDocument, l as assertIsWorkflowDocument, t as Workflow } from "./module-D9Zx5Zow.mjs";
2
2
  import { useDocumentById, useDocumentsInSelectedDrive, useDocumentsInSelectedFolder, useSelectedDocument } from "@powerhousedao/reactor-browser";
3
3
  import { PHDocumentController, createBaseState, defaultBaseState } from "document-model";
4
4
  //#region document-models/workflow/v1/gen/controller.ts
@@ -37,7 +37,8 @@ function defaultGlobalState() {
37
37
  },
38
38
  published: null,
39
39
  lastRunAt: null,
40
- lastRunStatus: null
40
+ lastRunStatus: null,
41
+ managedBy: null
41
42
  };
42
43
  }
43
44
  function defaultLocalState() {
@@ -105,4 +106,4 @@ function useWorkflowDocumentsInSelectedFolder() {
105
106
  //#endregion
106
107
  export { createState$1 as a, defaultLocalState as c, useWorkflowDocumentsInSelectedFolder as i, defaultPHState as l, useWorkflowDocumentById as n, createWorkflowDocument as o, useWorkflowDocumentsInSelectedDrive as r, defaultGlobalState as s, useSelectedWorkflowDocument as t, WorkflowController as u };
107
108
 
108
- //# sourceMappingURL=workflow-BS5m4jtr.mjs.map
109
+ //# sourceMappingURL=workflow-DqF9VsBQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-DqF9VsBQ.mjs","names":["createState"],"sources":["../../document-models/workflow/v1/gen/controller.ts","../../document-models/workflow/v1/gen/ph-factories.ts","../../document-models/workflow/v1/hooks.ts"],"sourcesContent":["/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport { PHDocumentController } from \"document-model\";\nimport { Workflow } from \"../module.js\";\nimport type { WorkflowAction, WorkflowPHState } from \"./types.js\";\n\nexport const WorkflowController = PHDocumentController.forDocumentModel<\n WorkflowPHState,\n WorkflowAction\n>(Workflow);\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n * Factory methods for creating WorkflowDocument instances\n */\nimport type { PHAuthState, PHBaseState, PHDocumentState } from \"document-model\";\nimport { createBaseState, defaultBaseState } from \"document-model\";\nimport type {\n WorkflowDocument,\n WorkflowGlobalState,\n WorkflowLocalState,\n WorkflowPHState,\n} from \"./types.js\";\nimport { utils } from \"./utils.js\";\n\nexport function defaultGlobalState(): WorkflowGlobalState {\n return {\n name: \"\",\n description: null,\n status: \"DRAFT\",\n version: 0,\n trigger: null,\n steps: [],\n edges: [],\n variables: [],\n policy: {\n concurrency: \"QUEUE\",\n maxParallelRuns: null,\n runTimeoutSeconds: 3600,\n maxSuspensionDays: 30,\n defaultRetry: {\n maxAttempts: 1,\n backoff: \"FIXED\",\n initialDelaySeconds: 5,\n maxDelaySeconds: 300,\n retryOn: [],\n },\n onFailure: \"PARK\",\n retainRunsDays: 30,\n journalAsDocument: false,\n },\n published: null,\n lastRunAt: null,\n lastRunStatus: null,\n managedBy: null,\n };\n}\n\nexport function defaultLocalState(): WorkflowLocalState {\n return {};\n}\n\nexport function defaultPHState(): WorkflowPHState {\n return {\n ...defaultBaseState(),\n global: defaultGlobalState(),\n local: defaultLocalState(),\n };\n}\n\nexport function createGlobalState(\n state?: Partial<WorkflowGlobalState>,\n): WorkflowGlobalState {\n return {\n ...defaultGlobalState(),\n ...(state || {}),\n };\n}\n\nexport function createLocalState(\n state?: Partial<WorkflowLocalState>,\n): WorkflowLocalState {\n return {\n ...defaultLocalState(),\n ...(state || {}),\n } as WorkflowLocalState;\n}\n\nexport function createState(\n baseState?: Partial<PHBaseState>,\n globalState?: Partial<WorkflowGlobalState>,\n localState?: Partial<WorkflowLocalState>,\n): WorkflowPHState {\n return {\n ...createBaseState(baseState?.auth, baseState?.document),\n global: createGlobalState(globalState),\n local: createLocalState(localState),\n };\n}\n\n/**\n * Creates a WorkflowDocument with custom global and local state\n * This properly handles the PHBaseState requirements while allowing\n * document-specific state to be set.\n */\nexport function createWorkflowDocument(\n state?: Partial<{\n auth?: Partial<PHAuthState>;\n document?: Partial<PHDocumentState>;\n global?: Partial<WorkflowGlobalState>;\n local?: Partial<WorkflowLocalState>;\n }>,\n): WorkflowDocument {\n const document = utils.createDocument(\n createState(\n createBaseState(state?.auth, { version: 1, ...state?.document }),\n state?.global,\n state?.local,\n ),\n );\n\n return document;\n}\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { DocumentDispatch } from \"@powerhousedao/reactor-browser\";\nimport {\n useDocumentById,\n useDocumentsInSelectedDrive,\n useDocumentsInSelectedFolder,\n useSelectedDocument,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n WorkflowAction,\n WorkflowDocument,\n} from \"document-models/workflow/v1\";\nimport {\n assertIsWorkflowDocument,\n isWorkflowDocument,\n} from \"./gen/document-schema.js\";\n\n/** Hook to get a Workflow document by its id */\nexport function useWorkflowDocumentById(\n documentId: string | null | undefined,\n):\n | [WorkflowDocument, DocumentDispatch<WorkflowAction>]\n | [undefined, undefined] {\n const [document, dispatch] = useDocumentById(documentId);\n if (!isWorkflowDocument(document)) return [undefined, undefined];\n return [document, dispatch];\n}\n\n/** Hook to get the selected Workflow document */\nexport function useSelectedWorkflowDocument(): [\n WorkflowDocument,\n DocumentDispatch<WorkflowAction>,\n] {\n const [document, dispatch] = useSelectedDocument();\n\n assertIsWorkflowDocument(document);\n return [document, dispatch] as const;\n}\n\n/** Hook to get all Workflow documents in the selected drive */\nexport function useWorkflowDocumentsInSelectedDrive() {\n const documentsInSelectedDrive = useDocumentsInSelectedDrive();\n return documentsInSelectedDrive?.filter(isWorkflowDocument);\n}\n\n/** Hook to get all Workflow documents in the selected folder */\nexport function useWorkflowDocumentsInSelectedFolder() {\n const documentsInSelectedFolder = useDocumentsInSelectedFolder();\n return documentsInSelectedFolder?.filter(isWorkflowDocument);\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,qBAAqB,qBAAqB,iBAGrD,QAAQ;;;ACIV,SAAgB,qBAA0C;CACxD,OAAO;EACL,MAAM;EACN,aAAa;EACb,QAAQ;EACR,SAAS;EACT,SAAS;EACT,OAAO,CAAC;EACR,OAAO,CAAC;EACR,WAAW,CAAC;EACZ,QAAQ;GACN,aAAa;GACb,iBAAiB;GACjB,mBAAmB;GACnB,mBAAmB;GACnB,cAAc;IACZ,aAAa;IACb,SAAS;IACT,qBAAqB;IACrB,iBAAiB;IACjB,SAAS,CAAC;GACZ;GACA,WAAW;GACX,gBAAgB;GAChB,mBAAmB;EACrB;EACA,WAAW;EACX,WAAW;EACX,eAAe;EACf,WAAW;CACb;AACF;AAEA,SAAgB,oBAAwC;CACtD,OAAO,CAAC;AACV;AAEA,SAAgB,iBAAkC;CAChD,OAAO;EACL,GAAG,iBAAiB;EACpB,QAAQ,mBAAmB;EAC3B,OAAO,kBAAkB;CAC3B;AACF;AAEA,SAAgB,kBACd,OACqB;CACrB,OAAO;EACL,GAAG,mBAAmB;EACtB,GAAI,SAAS,CAAC;CAChB;AACF;AAEA,SAAgB,iBACd,OACoB;CACpB,OAAO;EACL,GAAG,kBAAkB;EACrB,GAAI,SAAS,CAAC;CAChB;AACF;AAEA,SAAgBA,cACd,WACA,aACA,YACiB;CACjB,OAAO;EACL,GAAG,gBAAgB,WAAW,MAAM,WAAW,QAAQ;EACvD,QAAQ,kBAAkB,WAAW;EACrC,OAAO,iBAAiB,UAAU;CACpC;AACF;;;;;;AAOA,SAAgB,uBACd,OAMkB;CASlB,OARiB,MAAM,eACrBA,cACE,gBAAgB,OAAO,MAAM;EAAE,SAAS;EAAG,GAAG,OAAO;CAAS,CAAC,GAC/D,OAAO,QACP,OAAO,KACT,CAGY;AAChB;;;;AC3FA,SAAgB,wBACd,YAGyB;CACzB,MAAM,CAAC,UAAU,YAAY,gBAAgB,UAAU;CACvD,IAAI,CAAC,mBAAmB,QAAQ,GAAG,OAAO,CAAC,KAAA,GAAW,KAAA,CAAS;CAC/D,OAAO,CAAC,UAAU,QAAQ;AAC5B;;AAGA,SAAgB,8BAGd;CACA,MAAM,CAAC,UAAU,YAAY,oBAAoB;CAEjD,yBAAyB,QAAQ;CACjC,OAAO,CAAC,UAAU,QAAQ;AAC5B;;AAGA,SAAgB,sCAAsC;CAEpD,OADiC,4BACH,CAAC,EAAE,OAAO,kBAAkB;AAC5D;;AAGA,SAAgB,uCAAuC;CAErD,OADkC,6BACH,CAAC,EAAE,OAAO,kBAAkB;AAC7D"}
@@ -45,8 +45,8 @@
45
45
  {
46
46
  "id": "@powerhousedao/piece-reactor",
47
47
  "name": "Powerhouse Reactor",
48
- "version": "6.2.3-dev.79",
49
- "description": "Read and write Powerhouse documents on the reactor this workflow runs in: create documents, dispatch actions, read state and schemas, and fire on document events.",
48
+ "version": "6.2.3-dev.80",
49
+ "description": "Read and write Powerhouse documents on the reactor this workflow runs in: create documents, dispatch actions, read state, schemas and indexes, and fire on document events.",
50
50
  "bundle": "dist/node/pieces/reactor",
51
51
  "descriptor": "dist/node/pieces/reactor/descriptor.json"
52
52
  }