@oomol-lab/open-flow 0.1.0-beta.60 → 0.1.0-beta.62

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.
@@ -5691,6 +5691,18 @@ function preprocess(fn, schema) {
5691
5691
  });
5692
5692
  }
5693
5693
  //#endregion
5694
+ //#region src/flow/common/webhookMethod.ts
5695
+ var webhookMethods = [
5696
+ "GET",
5697
+ "POST",
5698
+ "PUT",
5699
+ "PATCH",
5700
+ "DELETE"
5701
+ ];
5702
+ function webhookSupportsBody(method) {
5703
+ return method !== "GET";
5704
+ }
5705
+ //#endregion
5694
5706
  //#region src/openapi/common/authBindings.ts
5695
5707
  /** Never allow credentials to enter a Revision as literal node inputs. */
5696
5708
  function assertOpenApiAuthBindings(document) {
@@ -8589,15 +8601,6 @@ var triggerScheduleSchema = array(union([object({
8589
8601
  ]),
8590
8602
  value: number()
8591
8603
  })]));
8592
- //#endregion
8593
- //#region src/flow/common/webhookMethod.ts
8594
- var webhookMethods = [
8595
- "GET",
8596
- "POST",
8597
- "PUT",
8598
- "PATCH",
8599
- "DELETE"
8600
- ];
8601
8604
  var text = string$1();
8602
8605
  var json$3 = json$4();
8603
8606
  var strings$1 = array(text);
@@ -8973,7 +8976,7 @@ var graph = object({
8973
8976
  nodes: record$3(text, node),
8974
8977
  edges: array(edge).default([])
8975
8978
  });
8976
- var binding = object({
8979
+ var binding$1 = object({
8977
8980
  kind: literal("variable"),
8978
8981
  target: text
8979
8982
  });
@@ -8983,7 +8986,7 @@ var module = object({
8983
8986
  source: text
8984
8987
  });
8985
8988
  var document = preprocess(rejectRetiredDefinitions, object({
8986
- bindings: record$3(text, binding),
8989
+ bindings: record$3(text, binding$1),
8987
8990
  graph
8988
8991
  }));
8989
8992
  var revision = object({
@@ -9027,7 +9030,7 @@ var shapes = {
9027
9030
  },
9028
9031
  "binding.create": {
9029
9032
  bindingId: text,
9030
- binding
9033
+ binding: binding$1
9031
9034
  },
9032
9035
  "binding.delete": { bindingId: text },
9033
9036
  "binding.target.set": {
@@ -9195,7 +9198,7 @@ var authenticationSchema = union([
9195
9198
  in: _enum(["header", "query"])
9196
9199
  })
9197
9200
  ]);
9198
- strictObject({
9201
+ var authoringOpenApiSchema = strictObject({
9199
9202
  sourceUrl: string$1().min(1),
9200
9203
  path: string$1().min(1),
9201
9204
  method: string$1().min(1),
@@ -9292,36 +9295,53 @@ var when = union([
9292
9295
  all,
9293
9296
  strictObject({ any: array(union([expression, all])) })
9294
9297
  ]);
9295
- strictObject({}), strictObject({ sourceFlowIds: array(id$1).optional() }), authoringDefinitionSchemas.webhook.omit({ bodyFields: true }).extend({ body: inputFields }).strict(), strictObject({ schedule: authoringDefinitionSchemas.schedule }), strictObject({
9296
- key: id$1,
9297
- connectionId: id$1.optional(),
9298
- schedule: authoringDefinitionSchemas.schedule
9299
- }), strictObject({
9300
- key: id$1,
9301
- connectionId: id$1.optional()
9302
- }), strictObject({
9303
- inputs: inputFields,
9304
- outputs: outputFields,
9305
- capabilities: authoringDefinitionSchemas.capabilities.optional()
9306
- }), authoringDefinitionSchemas.connector.strict(), authoringDefinitionSchemas.agent.omit({
9307
- prompt: true,
9308
- tools: true
9309
- }).extend({
9310
- inputs: inputFields,
9311
- resultSchema: json$2.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),
9312
- tools: array(agentTool),
9313
- notification: notification.optional()
9314
- }).strict(), authoringLlmConfiguration.extend({ inputs: inputFields }), authoringDefinitionSchemas.decision, strictObject({
9315
- match: _enum(["first", "all"]),
9316
- branches: array(strictObject({
9317
- name: id$1,
9318
- description: string$1().optional(),
9319
- when
9320
- }))
9321
- }), strictObject({
9322
- values: patch,
9323
- outputs: outputFields
9324
- }), strictObject({ inputs: inputFields }), strictObject({ inputs: inputFields });
9298
+ var authoringConfigurations = {
9299
+ manual: strictObject({}),
9300
+ error: strictObject({ sourceFlowIds: array(id$1).optional() }),
9301
+ webhook: authoringDefinitionSchemas.webhook.omit({ bodyFields: true }).extend({ body: inputFields }).strict(),
9302
+ cron: strictObject({ schedule: authoringDefinitionSchemas.schedule }),
9303
+ poll: strictObject({
9304
+ key: id$1,
9305
+ connectionId: id$1.optional(),
9306
+ schedule: authoringDefinitionSchemas.schedule
9307
+ }),
9308
+ integration: strictObject({
9309
+ key: id$1,
9310
+ connectionId: id$1.optional()
9311
+ }),
9312
+ code: strictObject({
9313
+ inputs: inputFields,
9314
+ outputs: outputFields,
9315
+ capabilities: authoringDefinitionSchemas.capabilities.optional()
9316
+ }),
9317
+ connector: authoringDefinitionSchemas.connector.strict(),
9318
+ openapi: authoringOpenApiSchema,
9319
+ agent: authoringDefinitionSchemas.agent.omit({
9320
+ prompt: true,
9321
+ tools: true
9322
+ }).extend({
9323
+ inputs: inputFields,
9324
+ resultSchema: json$2.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),
9325
+ tools: array(agentTool),
9326
+ notification: notification.optional()
9327
+ }).strict(),
9328
+ llm: authoringLlmConfiguration.extend({ inputs: inputFields }),
9329
+ decision: authoringDefinitionSchemas.decision,
9330
+ condition: strictObject({
9331
+ match: _enum(["first", "all"]),
9332
+ branches: array(strictObject({
9333
+ name: id$1,
9334
+ description: string$1().optional(),
9335
+ when
9336
+ }))
9337
+ }),
9338
+ value: strictObject({
9339
+ values: patch,
9340
+ outputs: outputFields
9341
+ }),
9342
+ wait: strictObject({ inputs: inputFields }),
9343
+ approval: strictObject({ inputs: inputFields })
9344
+ };
9325
9345
  var updates = strictObject({
9326
9346
  name: id$1.optional(),
9327
9347
  description: string$1().optional(),
@@ -9468,40 +9488,6 @@ var authoringSearchResponse = object({
9468
9488
  version: literal(1)
9469
9489
  });
9470
9490
  //#endregion
9471
- //#region src/control/common/providerIconSprite.ts
9472
- /** Optional artwork must never make an otherwise usable catalog unavailable. */
9473
- function providerIconAppearance(metadata, position) {
9474
- if (!metadata || typeof metadata != "object" || !position || typeof position != "object") return {};
9475
- const m = metadata;
9476
- const p = position;
9477
- if (typeof m.version != "string" || ![
9478
- m.pixelRatio,
9479
- m.iconSize,
9480
- m.width,
9481
- m.height
9482
- ].every((v) => Number.isInteger(v) && v > 0) || ![
9483
- m.bleed,
9484
- p.x,
9485
- p.y
9486
- ].every((v) => Number.isInteger(v) && v >= 0) || p.x + m.iconSize > m.width || p.y + m.iconSize > m.height) return {};
9487
- try {
9488
- for (const url of [m.lightUrl, m.darkUrl]) if (typeof url != "string" || ![
9489
- "https:",
9490
- "http:",
9491
- "data:"
9492
- ].includes(new URL(url).protocol)) return {};
9493
- } catch {
9494
- return {};
9495
- }
9496
- return {
9497
- iconSprite: m,
9498
- iconSpritePosition: {
9499
- x: p.x,
9500
- y: p.y
9501
- }
9502
- };
9503
- }
9504
- //#endregion
9505
9491
  //#region src/control/common/errors.ts
9506
9492
  var controlErrorCode = {
9507
9493
  authenticationRequired: "authentication.required",
@@ -9601,95 +9587,542 @@ function optionalString(value) {
9601
9587
  if (value == null) return;
9602
9588
  return string(value);
9603
9589
  }
9604
- new TextEncoder();
9605
- //#endregion
9606
- //#region src/control/common/providerAccess.ts
9607
- var sourceSchema = discriminatedUnion("kind", [strictObject({ kind: literal("admin-delegation") }), strictObject({
9608
- kind: literal("policy"),
9609
- ruleId: string$1().min(1).nullable()
9610
- })]);
9611
- function parseProviderAccessSource(value) {
9612
- return sourceSchema.parse(value);
9613
- }
9614
9590
  //#endregion
9615
- //#region src/control/common/connectorDecoders.ts
9616
- function accessPermissions(value) {
9591
+ //#region src/control/common/publicationDecoders.ts
9592
+ function publication(value) {
9617
9593
  const source = record$1(value);
9618
- exact(source, [
9619
- "actionIds",
9620
- "allActions",
9621
- "triggerIds",
9622
- "allTriggers",
9623
- "configured",
9624
- "proxy"
9625
- ]);
9626
- if (!Array.isArray(source.actionIds)) return invalidResponse("permissions.actionIds: expected an array.");
9627
- if (!Array.isArray(source.triggerIds)) return invalidResponse("permissions.triggerIds: expected an array.");
9628
- if (typeof source.allActions != "boolean") return invalidResponse("permissions.allActions: expected a boolean.");
9629
- if (typeof source.allTriggers != "boolean") return invalidResponse("permissions.allTriggers: expected a boolean.");
9630
- if (typeof source.configured != "boolean") return invalidResponse("permissions.configured: expected a boolean.");
9631
- if (typeof source.proxy != "boolean") return invalidResponse("permissions.proxy: expected a boolean.");
9632
- const actionIds = source.actionIds.map(string);
9633
- const triggerIds = source.triggerIds.map(string);
9634
- if (new Set(actionIds).size != actionIds.length) return invalidResponse("permissions.actionIds: duplicate IDs.");
9635
- if (source.allActions && actionIds.length != 0) return invalidResponse("permissions.actionIds: must be empty when allActions is true.");
9636
- if (new Set(triggerIds).size != triggerIds.length) return invalidResponse("permissions.triggerIds: duplicate IDs.");
9637
- if (source.allTriggers && triggerIds.length != 0) return invalidResponse("permissions.triggerIds: must be empty when allTriggers is true.");
9638
- if (source.proxy && (!source.allActions || !source.allTriggers || source.configured)) return invalidResponse("permissions.proxy: requires allActions=true, allTriggers=true and configured=false.");
9594
+ const liveEnd = source.liveEnd == null ? void 0 : record$1(source.liveEnd);
9595
+ if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
9596
+ const operation = source.operation;
9597
+ const sourcePublicationId = source.sourcePublicationId;
9598
+ if (source.version != 1) return invalidResponse();
9599
+ if (operation != "publish" && operation != "rollback") return invalidResponse();
9600
+ if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
9639
9601
  return {
9640
- actionIds,
9641
- triggerIds,
9642
- allTriggers: source.allTriggers,
9643
- allActions: source.allActions,
9644
- configured: source.configured,
9645
- proxy: source.proxy
9602
+ ...liveEnd == null ? {} : { liveEnd: {
9603
+ enabled: liveEnd.enabled,
9604
+ endedAt: string(liveEnd.endedAt)
9605
+ } },
9606
+ actorId: string(source.actorId),
9607
+ closureDigest: string(source.closureDigest),
9608
+ createdAt: string(source.createdAt),
9609
+ engineContract: string(source.engineContract),
9610
+ flowId: string(source.flowId),
9611
+ modelVersion: integer(source.modelVersion),
9612
+ operation,
9613
+ publicationId: string(source.publicationId),
9614
+ sharedAccessDigest: string(source.sharedAccessDigest),
9615
+ revisionDigest: string(source.revisionDigest),
9616
+ revisionId: string(source.revisionId),
9617
+ ...sourcePublicationId == null ? {} : { sourcePublicationId },
9618
+ version: 1
9646
9619
  };
9647
9620
  }
9648
- function accessBinding(value, candidate) {
9621
+ function publishOperation(value) {
9649
9622
  const source = record$1(value);
9650
- const policyRevision = source.policyRevision;
9651
9623
  const status = source.status;
9652
- const isDefault = source.isDefault;
9653
- const legacy = Object.hasOwn(source, "displayName") && !Object.hasOwn(source, "connectionDisplayName");
9654
- const permissions = candidate && Object.hasOwn(source, "permissions") ? accessPermissions(source.permissions) : void 0;
9655
- const permissionGroupName = source.permissionGroupName;
9656
- exact(source, [
9657
- "accessBindingId",
9658
- "connectionId",
9659
- "source",
9660
- legacy ? "displayName" : "connectionDisplayName",
9661
- ...candidate && Object.hasOwn(source, "isDefault") ? ["isDefault"] : [],
9662
- ...candidate && permissions != null ? ["permissions"] : [],
9663
- ...Object.hasOwn(source, "permissionGroupName") ? ["permissionGroupName"] : [],
9664
- ...policyRevision == null ? [] : ["policyRevision"],
9665
- "providerId",
9666
- ...candidate ? [] : ["status"]
9667
- ]);
9668
- if (policyRevision != null && typeof policyRevision != "string") return invalidResponse("policyRevision: expected a string.");
9669
- if (candidate && isDefault !== void 0 && typeof isDefault != "boolean") return invalidResponse("isDefault: expected a boolean.");
9670
- if (permissionGroupName !== void 0 && permissionGroupName !== null && typeof permissionGroupName != "string") return invalidResponse("permissionGroupName: expected a string or null.");
9671
- if (!candidate && status != "active" && status != "forbidden" && status != "invalid" && status != "missing") return invalidResponse();
9672
- let bindingSource;
9673
- try {
9674
- bindingSource = parseProviderAccessSource(source.source);
9675
- } catch {
9676
- return invalidResponse("source: expected { kind: 'admin-delegation' } or { kind: 'policy', ruleId: string | null }.");
9624
+ const common = {
9625
+ createdAt: string(source.createdAt),
9626
+ flowId: string(source.flowId),
9627
+ operationId: string(source.operationId),
9628
+ revisionId: string(source.revisionId),
9629
+ updatedAt: string(source.updatedAt),
9630
+ version: 1
9631
+ };
9632
+ if (source.version != 1) return invalidResponse();
9633
+ switch (status) {
9634
+ case "pending":
9635
+ exact(source, [
9636
+ "createdAt",
9637
+ "flowId",
9638
+ "operationId",
9639
+ "revisionId",
9640
+ "status",
9641
+ "updatedAt",
9642
+ "version"
9643
+ ]);
9644
+ return {
9645
+ ...common,
9646
+ status
9647
+ };
9648
+ case "succeeded":
9649
+ exact(source, [
9650
+ "createdAt",
9651
+ "flowId",
9652
+ "operationId",
9653
+ "publicationId",
9654
+ "revisionId",
9655
+ "status",
9656
+ "updatedAt",
9657
+ "version"
9658
+ ]);
9659
+ return {
9660
+ ...common,
9661
+ publicationId: string(source.publicationId),
9662
+ status
9663
+ };
9664
+ case "failed": {
9665
+ exact(source, [
9666
+ "createdAt",
9667
+ "flowId",
9668
+ "issue",
9669
+ "operationId",
9670
+ "revisionId",
9671
+ "status",
9672
+ "updatedAt",
9673
+ "version"
9674
+ ]);
9675
+ const issue = record$1(source.issue);
9676
+ const nodeId = issue.nodeId;
9677
+ exact(issue, [
9678
+ "code",
9679
+ "message",
9680
+ ...nodeId == null ? [] : ["nodeId"]
9681
+ ]);
9682
+ return {
9683
+ ...common,
9684
+ issue: {
9685
+ code: string(issue.code),
9686
+ message: string(issue.message),
9687
+ ...nodeId == null ? {} : { nodeId: string(nodeId) }
9688
+ },
9689
+ status
9690
+ };
9691
+ }
9692
+ default: return invalidResponse();
9677
9693
  }
9694
+ }
9695
+ function live(value) {
9696
+ const source = record$1(value);
9697
+ const status = source.status;
9698
+ const candidate = source.publication;
9699
+ if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
9700
+ if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
9701
+ if (status == "not-published" && candidate !== null) return invalidResponse();
9702
+ if (status != "not-published" && candidate === null) return invalidResponse();
9678
9703
  return {
9679
- accessBindingId: string(source.accessBindingId),
9680
- connectionId: string(source.connectionId),
9681
- source: bindingSource,
9682
- connectionDisplayName: string(legacy ? source.displayName : source.connectionDisplayName),
9683
- ...candidate && typeof isDefault == "boolean" ? { isDefault } : {},
9684
- ...permissions == null ? {} : { permissions },
9685
- ...permissionGroupName === void 0 ? {} : { permissionGroupName },
9686
- ...policyRevision == null ? {} : { policyRevision },
9687
- providerId: string(source.providerId),
9688
- ...candidate ? {} : { status }
9704
+ flowId: string(source.flowId),
9705
+ hasUnpublishedChanges: source.hasUnpublishedChanges,
9706
+ publication: candidate === null ? null : publication(candidate),
9707
+ revision: integer(source.revision),
9708
+ status,
9709
+ version: 1
9689
9710
  };
9690
9711
  }
9691
- function accessMode(value) {
9692
- if (value != "implicit" && value != "selectable") return invalidResponse("mode: expected implicit or selectable.");
9712
+ function publicationPage(value) {
9713
+ const source = record$1(value);
9714
+ const nextCursor = source.nextCursor;
9715
+ const total = source.total;
9716
+ if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
9717
+ if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
9718
+ if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
9719
+ return {
9720
+ ...nextCursor == null ? {} : { nextCursor },
9721
+ publications: source.publications.map(publication),
9722
+ ...total == null ? {} : { total },
9723
+ version: 1
9724
+ };
9725
+ }
9726
+ //#endregion
9727
+ //#region src/trigger/common/configSchema.ts
9728
+ var configInputsSchema = array(union([strictObject({
9729
+ handle: string$1().min(1),
9730
+ description: string$1().optional(),
9731
+ jsonSchema: json$4(),
9732
+ nullable: boolean(),
9733
+ value: json$4().optional()
9734
+ }), strictObject({
9735
+ group: string$1(),
9736
+ collapsed: boolean().optional()
9737
+ })]));
9738
+ //#endregion
9739
+ //#region src/control/common/triggerDecoders.ts
9740
+ function triggerKeySummary(value) {
9741
+ const source = record$1(value);
9742
+ const type = source.type;
9743
+ if (type != "integration" && type != "poll") return invalidResponse();
9744
+ return {
9745
+ description: typeof source.description == "string" ? source.description : invalidResponse(),
9746
+ displayName: string(source.displayName),
9747
+ key: string(source.key),
9748
+ name: string(source.name),
9749
+ provider: string(source.provider),
9750
+ type
9751
+ };
9752
+ }
9753
+ function triggerKey(value) {
9754
+ const source = record$1(value);
9755
+ const summary = triggerKeySummary(source);
9756
+ const base = {
9757
+ configInputs: configInputsSchema.parse(source.configInputs),
9758
+ definitionVersion: source.definitionVersion === 2 ? 2 : invalidResponse(),
9759
+ description: summary.description,
9760
+ displayName: summary.displayName,
9761
+ key: summary.key,
9762
+ name: summary.name,
9763
+ outputs: (Array.isArray(source.outputs) ? source.outputs : invalidResponse()).map((entry) => {
9764
+ const port = record$1(entry);
9765
+ return Object.assign({
9766
+ handle: string(port.handle),
9767
+ jsonSchema: jsonValue(port.jsonSchema),
9768
+ nullable: typeof port.nullable === "boolean" ? port.nullable : invalidResponse()
9769
+ }, port.description == null ? {} : { description: string(port.description) });
9770
+ }),
9771
+ provider: summary.provider
9772
+ };
9773
+ if (summary.type == "poll") return {
9774
+ ...base,
9775
+ type: "poll"
9776
+ };
9777
+ const endpoint = record$1(source.endpoint);
9778
+ const body = record$1(endpoint.body);
9779
+ if (!Array.isArray(endpoint.methods) || !Array.isArray(body.formats) || typeof body.allowArray != "boolean" || typeof body.allowEmpty != "boolean") return invalidResponse();
9780
+ const methods = endpoint.methods.map(string);
9781
+ const formats = body.formats.map(string);
9782
+ const successStatus = integer(endpoint.successStatus);
9783
+ if (methods.some((method) => ![
9784
+ "DELETE",
9785
+ "GET",
9786
+ "HEAD",
9787
+ "PATCH",
9788
+ "POST",
9789
+ "PUT"
9790
+ ].includes(method)) || formats.some((format) => ![
9791
+ "form",
9792
+ "json",
9793
+ "multipart",
9794
+ "text"
9795
+ ].includes(format)) || successStatus < 200 || successStatus > 299) return invalidResponse();
9796
+ return {
9797
+ ...base,
9798
+ endpoint: {
9799
+ body: {
9800
+ allowArray: body.allowArray,
9801
+ allowEmpty: body.allowEmpty,
9802
+ formats
9803
+ },
9804
+ methods,
9805
+ successStatus
9806
+ },
9807
+ type: "integration"
9808
+ };
9809
+ }
9810
+ var triggerKinds = /* @__PURE__ */ new Set([
9811
+ "error",
9812
+ "cron",
9813
+ "integration",
9814
+ "poll",
9815
+ "webhook"
9816
+ ]);
9817
+ var triggerHealth = /* @__PURE__ */ new Set([
9818
+ "failed",
9819
+ "healthy",
9820
+ "initializing",
9821
+ "needs_reauth",
9822
+ "suspended"
9823
+ ]);
9824
+ var triggerActivityKinds = /* @__PURE__ */ new Set([
9825
+ "delivery.failed",
9826
+ "health.failed",
9827
+ "health.needs_reauth",
9828
+ "health.recovered",
9829
+ "health.suspended",
9830
+ "operator.paused",
9831
+ "operator.resumed"
9832
+ ]);
9833
+ function triggerBinding(value) {
9834
+ const source = record$1(value);
9835
+ const health = source.health;
9836
+ const listener = source.listener == null ? void 0 : record$1(source.listener);
9837
+ if (listener != null && listener.health != "healthy" && listener.health != "failed" && listener.health != "needs_reauth") return invalidResponse();
9838
+ const kind = source.kind;
9839
+ const runtimeVersion = integer(source.runtimeVersion);
9840
+ if (source.version != 1 || typeof health != "string" || !triggerHealth.has(health)) return invalidResponse();
9841
+ if (typeof kind != "string" || !triggerKinds.has(kind)) return invalidResponse();
9842
+ if (runtimeVersion <= 0) return invalidResponse();
9843
+ return {
9844
+ ...source.currentPublicationId == null ? {} : { currentPublicationId: string(source.currentPublicationId) },
9845
+ ...source.currentRevisionId == null ? {} : { currentRevisionId: string(source.currentRevisionId) },
9846
+ ...source.endpointUrl == null ? {} : { endpointUrl: string(source.endpointUrl) },
9847
+ ...listener == null ? {} : { listener: {
9848
+ health: listener.health,
9849
+ ...listener.lastErrorCode == null ? {} : { lastErrorCode: string(listener.lastErrorCode) }
9850
+ } },
9851
+ flowId: string(source.flowId),
9852
+ health,
9853
+ kind,
9854
+ ...source.lastErrorCode == null ? {} : { lastErrorCode: string(source.lastErrorCode) },
9855
+ runtimeVersion,
9856
+ triggerNodeId: string(source.triggerNodeId),
9857
+ updatedAt: string(source.updatedAt),
9858
+ version: 1
9859
+ };
9860
+ }
9861
+ function triggerBindingDetail(value) {
9862
+ const source = record$1(value);
9863
+ if (source.version != 1) return invalidResponse();
9864
+ return {
9865
+ binding: triggerBinding(source.binding),
9866
+ version: 1
9867
+ };
9868
+ }
9869
+ function triggerActivity(value) {
9870
+ const source = record$1(value);
9871
+ const kind = source.kind;
9872
+ if (typeof kind != "string" || !triggerActivityKinds.has(kind)) return invalidResponse();
9873
+ const errorCode = optionalString(source.errorCode);
9874
+ const errorMessage = optionalString(source.errorMessage);
9875
+ if (errorMessage != null && errorMessage.length > 512) return invalidResponse();
9876
+ return {
9877
+ activityId: string(source.activityId),
9878
+ createdAt: string(source.createdAt),
9879
+ ...errorCode == null ? {} : { errorCode },
9880
+ ...errorMessage == null ? {} : { errorMessage },
9881
+ kind
9882
+ };
9883
+ }
9884
+ function triggerActivityPage(value) {
9885
+ const source = record$1(value);
9886
+ const nextCursor = optionalString(source.nextCursor);
9887
+ if (source.version != 1 || !Array.isArray(source.activities)) return invalidResponse();
9888
+ return {
9889
+ activities: source.activities.map(triggerActivity),
9890
+ ...nextCursor == null ? {} : { nextCursor },
9891
+ version: 1
9892
+ };
9893
+ }
9894
+ function pollTriggerTestResult(value) {
9895
+ const source = record$1(value);
9896
+ const filtered = integer(source.filtered);
9897
+ if (source.version != 1 || !Array.isArray(source.events) || typeof source.hasMore != "boolean" || filtered < 0) return invalidResponse();
9898
+ return {
9899
+ events: source.events.map((event) => {
9900
+ const object = record$1(event);
9901
+ return Object.fromEntries(Object.entries(object).map(([key, item]) => [key, jsonValue(item)]));
9902
+ }),
9903
+ filtered,
9904
+ hasMore: source.hasMore,
9905
+ version: 1
9906
+ };
9907
+ }
9908
+ //#endregion
9909
+ //#region src/control/common/liveDetails.ts
9910
+ var metadata = {
9911
+ nodeId: string$1().min(1),
9912
+ name: string$1(),
9913
+ description: string$1().optional()
9914
+ };
9915
+ var binding = unknown().transform(triggerBinding);
9916
+ var provider = {
9917
+ provider: string$1().min(1),
9918
+ inputs: record$3(string$1(), discriminatedUnion("kind", [strictObject({
9919
+ kind: literal("value"),
9920
+ value: json$4()
9921
+ }), strictObject({ kind: literal("unset") })]))
9922
+ };
9923
+ var entrySchema = discriminatedUnion("type", [
9924
+ strictObject({
9925
+ ...metadata,
9926
+ type: literal("manual"),
9927
+ config: authoringConfigurations.manual
9928
+ }),
9929
+ strictObject({
9930
+ ...metadata,
9931
+ type: literal("webhook"),
9932
+ config: authoringConfigurations.webhook,
9933
+ binding
9934
+ }),
9935
+ strictObject({
9936
+ ...metadata,
9937
+ type: literal("cron"),
9938
+ config: authoringConfigurations.cron,
9939
+ binding
9940
+ }),
9941
+ strictObject({
9942
+ ...metadata,
9943
+ type: literal("error"),
9944
+ config: authoringConfigurations.error,
9945
+ binding
9946
+ }),
9947
+ strictObject({
9948
+ ...metadata,
9949
+ ...provider,
9950
+ type: literal("poll"),
9951
+ config: authoringConfigurations.poll,
9952
+ binding
9953
+ }),
9954
+ strictObject({
9955
+ ...metadata,
9956
+ ...provider,
9957
+ type: literal("integration"),
9958
+ config: authoringConfigurations.integration,
9959
+ binding
9960
+ })
9961
+ ]);
9962
+ function decodeLiveDetails(value) {
9963
+ const source = record$1(value);
9964
+ const flowId = string(source.flowId);
9965
+ if (source.version != 1 || !Array.isArray(source.entries)) return invalidResponse();
9966
+ if (source.publication === null) {
9967
+ if (source.status != "not-published" || source.entries.length != 0 || Object.hasOwn(source, "enabled")) return invalidResponse();
9968
+ return {
9969
+ flowId,
9970
+ publication: null,
9971
+ status: "not-published",
9972
+ entries: [],
9973
+ version: 1
9974
+ };
9975
+ }
9976
+ const current = publication(source.publication);
9977
+ const status = source.status;
9978
+ if (current.flowId != flowId || typeof source.enabled != "boolean") return invalidResponse();
9979
+ if (status != "runnable" && status != "suspended") return invalidResponse();
9980
+ if (!source.enabled && source.status == "runnable") return invalidResponse();
9981
+ return {
9982
+ flowId,
9983
+ publication: current,
9984
+ status,
9985
+ enabled: source.enabled,
9986
+ entries: decodeEntries(source.entries, current),
9987
+ version: 1
9988
+ };
9989
+ }
9990
+ /** Both producers and consumers enforce the same published-entry invariants. */
9991
+ function decodeEntries(values, current) {
9992
+ const parsed = array(entrySchema).safeParse(values);
9993
+ if (!parsed.success) return invalidResponse();
9994
+ const ids = /* @__PURE__ */ new Set();
9995
+ for (const entry of parsed.data) {
9996
+ if (ids.has(entry.nodeId)) return invalidResponse();
9997
+ ids.add(entry.nodeId);
9998
+ if (entry.type != "manual" && (entry.binding.flowId != current.flowId || entry.binding.triggerNodeId != entry.nodeId || entry.binding.kind != entry.type || entry.binding.currentPublicationId != current.publicationId || entry.binding.currentRevisionId != current.revisionId)) return invalidResponse();
9999
+ if (entry.type == "webhook" && (!entry.binding.endpointUrl || !webhookSupportsBody(entry.config.method) && Object.keys(entry.config.body).length > 0)) return invalidResponse();
10000
+ }
10001
+ return parsed.data;
10002
+ }
10003
+ //#endregion
10004
+ //#region src/control/common/providerIconSprite.ts
10005
+ /** Optional artwork must never make an otherwise usable catalog unavailable. */
10006
+ function providerIconAppearance(metadata, position) {
10007
+ if (!metadata || typeof metadata != "object" || !position || typeof position != "object") return {};
10008
+ const m = metadata;
10009
+ const p = position;
10010
+ if (typeof m.version != "string" || ![
10011
+ m.pixelRatio,
10012
+ m.iconSize,
10013
+ m.width,
10014
+ m.height
10015
+ ].every((v) => Number.isInteger(v) && v > 0) || ![
10016
+ m.bleed,
10017
+ p.x,
10018
+ p.y
10019
+ ].every((v) => Number.isInteger(v) && v >= 0) || p.x + m.iconSize > m.width || p.y + m.iconSize > m.height) return {};
10020
+ try {
10021
+ for (const url of [m.lightUrl, m.darkUrl]) if (typeof url != "string" || ![
10022
+ "https:",
10023
+ "http:",
10024
+ "data:"
10025
+ ].includes(new URL(url).protocol)) return {};
10026
+ } catch {
10027
+ return {};
10028
+ }
10029
+ return {
10030
+ iconSprite: m,
10031
+ iconSpritePosition: {
10032
+ x: p.x,
10033
+ y: p.y
10034
+ }
10035
+ };
10036
+ }
10037
+ new TextEncoder();
10038
+ //#endregion
10039
+ //#region src/control/common/providerAccess.ts
10040
+ var sourceSchema = discriminatedUnion("kind", [strictObject({ kind: literal("admin-delegation") }), strictObject({
10041
+ kind: literal("policy"),
10042
+ ruleId: string$1().min(1).nullable()
10043
+ })]);
10044
+ function parseProviderAccessSource(value) {
10045
+ return sourceSchema.parse(value);
10046
+ }
10047
+ //#endregion
10048
+ //#region src/control/common/connectorDecoders.ts
10049
+ function accessPermissions(value) {
10050
+ const source = record$1(value);
10051
+ exact(source, [
10052
+ "actionIds",
10053
+ "allActions",
10054
+ "triggerIds",
10055
+ "allTriggers",
10056
+ "configured",
10057
+ "proxy"
10058
+ ]);
10059
+ if (!Array.isArray(source.actionIds)) return invalidResponse("permissions.actionIds: expected an array.");
10060
+ if (!Array.isArray(source.triggerIds)) return invalidResponse("permissions.triggerIds: expected an array.");
10061
+ if (typeof source.allActions != "boolean") return invalidResponse("permissions.allActions: expected a boolean.");
10062
+ if (typeof source.allTriggers != "boolean") return invalidResponse("permissions.allTriggers: expected a boolean.");
10063
+ if (typeof source.configured != "boolean") return invalidResponse("permissions.configured: expected a boolean.");
10064
+ if (typeof source.proxy != "boolean") return invalidResponse("permissions.proxy: expected a boolean.");
10065
+ const actionIds = source.actionIds.map(string);
10066
+ const triggerIds = source.triggerIds.map(string);
10067
+ if (new Set(actionIds).size != actionIds.length) return invalidResponse("permissions.actionIds: duplicate IDs.");
10068
+ if (source.allActions && actionIds.length != 0) return invalidResponse("permissions.actionIds: must be empty when allActions is true.");
10069
+ if (new Set(triggerIds).size != triggerIds.length) return invalidResponse("permissions.triggerIds: duplicate IDs.");
10070
+ if (source.allTriggers && triggerIds.length != 0) return invalidResponse("permissions.triggerIds: must be empty when allTriggers is true.");
10071
+ if (source.proxy && (!source.allActions || !source.allTriggers || source.configured)) return invalidResponse("permissions.proxy: requires allActions=true, allTriggers=true and configured=false.");
10072
+ return {
10073
+ actionIds,
10074
+ triggerIds,
10075
+ allTriggers: source.allTriggers,
10076
+ allActions: source.allActions,
10077
+ configured: source.configured,
10078
+ proxy: source.proxy
10079
+ };
10080
+ }
10081
+ function accessBinding(value, candidate) {
10082
+ const source = record$1(value);
10083
+ const policyRevision = source.policyRevision;
10084
+ const status = source.status;
10085
+ const isDefault = source.isDefault;
10086
+ const legacy = Object.hasOwn(source, "displayName") && !Object.hasOwn(source, "connectionDisplayName");
10087
+ const permissions = candidate && Object.hasOwn(source, "permissions") ? accessPermissions(source.permissions) : void 0;
10088
+ const permissionGroupName = source.permissionGroupName;
10089
+ exact(source, [
10090
+ "accessBindingId",
10091
+ "connectionId",
10092
+ "source",
10093
+ legacy ? "displayName" : "connectionDisplayName",
10094
+ ...candidate && Object.hasOwn(source, "isDefault") ? ["isDefault"] : [],
10095
+ ...candidate && permissions != null ? ["permissions"] : [],
10096
+ ...Object.hasOwn(source, "permissionGroupName") ? ["permissionGroupName"] : [],
10097
+ ...policyRevision == null ? [] : ["policyRevision"],
10098
+ "providerId",
10099
+ ...candidate ? [] : ["status"]
10100
+ ]);
10101
+ if (policyRevision != null && typeof policyRevision != "string") return invalidResponse("policyRevision: expected a string.");
10102
+ if (candidate && isDefault !== void 0 && typeof isDefault != "boolean") return invalidResponse("isDefault: expected a boolean.");
10103
+ if (permissionGroupName !== void 0 && permissionGroupName !== null && typeof permissionGroupName != "string") return invalidResponse("permissionGroupName: expected a string or null.");
10104
+ if (!candidate && status != "active" && status != "forbidden" && status != "invalid" && status != "missing") return invalidResponse();
10105
+ let bindingSource;
10106
+ try {
10107
+ bindingSource = parseProviderAccessSource(source.source);
10108
+ } catch {
10109
+ return invalidResponse("source: expected { kind: 'admin-delegation' } or { kind: 'policy', ruleId: string | null }.");
10110
+ }
10111
+ return {
10112
+ accessBindingId: string(source.accessBindingId),
10113
+ connectionId: string(source.connectionId),
10114
+ source: bindingSource,
10115
+ connectionDisplayName: string(legacy ? source.displayName : source.connectionDisplayName),
10116
+ ...candidate && typeof isDefault == "boolean" ? { isDefault } : {},
10117
+ ...permissions == null ? {} : { permissions },
10118
+ ...permissionGroupName === void 0 ? {} : { permissionGroupName },
10119
+ ...policyRevision == null ? {} : { policyRevision },
10120
+ providerId: string(source.providerId),
10121
+ ...candidate ? {} : { status }
10122
+ };
10123
+ }
10124
+ function accessMode(value) {
10125
+ if (value != "implicit" && value != "selectable") return invalidResponse("mode: expected implicit or selectable.");
9693
10126
  return value;
9694
10127
  }
9695
10128
  function connectorAccess(value) {
@@ -9919,289 +10352,104 @@ function connectorActionMetadata(value) {
9919
10352
  actionId: string(source.actionId),
9920
10353
  ...source.operationType == null ? {} : { operationType: string(source.operationType) },
9921
10354
  authenticated: typeof source.authenticated == "boolean" ? source.authenticated : invalidResponse(),
9922
- description: typeof source.description == "string" ? source.description : invalidResponse(),
9923
- ...homepageUrl == null ? {} : { homepageUrl },
9924
- ...icon == null ? {} : { icon },
9925
- ...providerIconAppearance(source.iconSprite, source.iconSpritePosition),
9926
- inputs: ports(source.inputs, inputPort),
9927
- name: string(source.name),
9928
- outputs: ports(source.outputs, port),
9929
- serviceId: string(source.serviceId),
9930
- serviceName: string(source.serviceName)
9931
- };
9932
- }
9933
- function connectorAction(value) {
9934
- const { defaultConnection, ...metadata } = record$1(value);
9935
- const action = connectorActionMetadata(metadata);
9936
- if (defaultConnection == null) return action;
9937
- const preferred = connection(defaultConnection);
9938
- if (preferred.serviceId != action.serviceId || preferred.status != "active") return invalidResponse();
9939
- return {
9940
- ...action,
9941
- defaultConnection: preferred
9942
- };
9943
- }
9944
- function connectorProvider(value) {
9945
- const source = record$1(value);
9946
- const homepageUrl = source.homepageUrl;
9947
- const icon = source.icon;
9948
- if (source.noSetup !== void 0 && typeof source.noSetup != "boolean") return invalidResponse();
9949
- exact(source, [
9950
- ...Object.hasOwn(source, "noSetup") ? ["noSetup"] : [],
9951
- "serviceId",
9952
- "serviceName",
9953
- ...homepageUrl == null ? [] : ["homepageUrl"],
9954
- ...icon == null ? [] : ["icon"],
9955
- ..."iconSprite" in source ? ["iconSprite"] : [],
9956
- ..."iconSpritePosition" in source ? ["iconSpritePosition"] : []
9957
- ]);
9958
- if (homepageUrl != null && typeof homepageUrl != "string" || icon != null && typeof icon != "string") return invalidResponse();
9959
- return {
9960
- ...homepageUrl == null ? {} : { homepageUrl },
9961
- ...icon == null ? {} : { icon },
9962
- ...providerIconAppearance(source.iconSprite, source.iconSpritePosition),
9963
- serviceId: string(source.serviceId),
9964
- serviceName: string(source.serviceName),
9965
- ...source.noSetup === void 0 ? {} : { noSetup: source.noSetup }
9966
- };
9967
- }
9968
- //#endregion
9969
- //#region src/control/common/eventSources.ts
9970
- var id = string$1().min(1).max(256);
9971
- var eventType = string$1().regex(/^[a-z][a-z0-9_.]{0,127}$/);
9972
- var name = string$1().trim().min(1).max(128);
9973
- var eventSourceSchema = strictObject({
9974
- version: literal(1),
9975
- sourceId: id,
9976
- revision: int().positive(),
9977
- name,
9978
- provider: _enum(["feishu", "feishu_app_bot"]),
9979
- appId: id,
9980
- connectionId: id,
9981
- teamId: id.nullable(),
9982
- enabled: boolean(),
9983
- eventTypes: array(eventType),
9984
- manageSubscriptions: boolean(),
9985
- verificationTokenConfigured: boolean(),
9986
- encryptKeyConfigured: boolean(),
9987
- endpointUrl: string$1().nullable(),
9988
- verifiedAt: string$1().nullable(),
9989
- lastReceivedAt: string$1().nullable(),
9990
- updatedAt: string$1(),
9991
- consumers: array(strictObject({
9992
- flowId: id,
9993
- flowName: string$1(),
9994
- triggerNodeId: id
9995
- }))
9996
- });
9997
- function decodeEventSource(value) {
9998
- return eventSourceSchema.parse(value);
9999
- }
10000
- function decodeEventSources(value) {
10001
- return strictObject({
10002
- version: literal(1),
10003
- sources: array(eventSourceSchema),
10004
- teamId: id.nullable().optional()
10005
- }).parse(value);
10006
- }
10007
- var uiLanguageTags = new Map([
10008
- "en",
10009
- "zh-CN",
10010
- "zh-TW",
10011
- "ja",
10012
- "ko",
10013
- "ru",
10014
- "fr"
10015
- ].map((language) => [language.toLowerCase(), language]));
10016
- function isUiLanguage(value) {
10017
- return typeof value == "string" && uiLanguageTags.get(value.toLowerCase()) == value;
10018
- }
10019
- //#endregion
10020
- //#region src/trigger/common/configSchema.ts
10021
- var configInputsSchema = array(union([strictObject({
10022
- handle: string$1().min(1),
10023
- description: string$1().optional(),
10024
- jsonSchema: json$4(),
10025
- nullable: boolean(),
10026
- value: json$4().optional()
10027
- }), strictObject({
10028
- group: string$1(),
10029
- collapsed: boolean().optional()
10030
- })]));
10031
- //#endregion
10032
- //#region src/control/common/triggerDecoders.ts
10033
- function triggerKeySummary(value) {
10034
- const source = record$1(value);
10035
- const type = source.type;
10036
- if (type != "integration" && type != "poll") return invalidResponse();
10037
- return {
10038
- description: typeof source.description == "string" ? source.description : invalidResponse(),
10039
- displayName: string(source.displayName),
10040
- key: string(source.key),
10041
- name: string(source.name),
10042
- provider: string(source.provider),
10043
- type
10044
- };
10045
- }
10046
- function triggerKey(value) {
10047
- const source = record$1(value);
10048
- const summary = triggerKeySummary(source);
10049
- const base = {
10050
- configInputs: configInputsSchema.parse(source.configInputs),
10051
- definitionVersion: source.definitionVersion === 2 ? 2 : invalidResponse(),
10052
- description: summary.description,
10053
- displayName: summary.displayName,
10054
- key: summary.key,
10055
- name: summary.name,
10056
- outputs: (Array.isArray(source.outputs) ? source.outputs : invalidResponse()).map((entry) => {
10057
- const port = record$1(entry);
10058
- return Object.assign({
10059
- handle: string(port.handle),
10060
- jsonSchema: jsonValue(port.jsonSchema),
10061
- nullable: typeof port.nullable === "boolean" ? port.nullable : invalidResponse()
10062
- }, port.description == null ? {} : { description: string(port.description) });
10063
- }),
10064
- provider: summary.provider
10065
- };
10066
- if (summary.type == "poll") return {
10067
- ...base,
10068
- type: "poll"
10069
- };
10070
- const endpoint = record$1(source.endpoint);
10071
- const body = record$1(endpoint.body);
10072
- if (!Array.isArray(endpoint.methods) || !Array.isArray(body.formats) || typeof body.allowArray != "boolean" || typeof body.allowEmpty != "boolean") return invalidResponse();
10073
- const methods = endpoint.methods.map(string);
10074
- const formats = body.formats.map(string);
10075
- const successStatus = integer(endpoint.successStatus);
10076
- if (methods.some((method) => ![
10077
- "DELETE",
10078
- "GET",
10079
- "HEAD",
10080
- "PATCH",
10081
- "POST",
10082
- "PUT"
10083
- ].includes(method)) || formats.some((format) => ![
10084
- "form",
10085
- "json",
10086
- "multipart",
10087
- "text"
10088
- ].includes(format)) || successStatus < 200 || successStatus > 299) return invalidResponse();
10089
- return {
10090
- ...base,
10091
- endpoint: {
10092
- body: {
10093
- allowArray: body.allowArray,
10094
- allowEmpty: body.allowEmpty,
10095
- formats
10096
- },
10097
- methods,
10098
- successStatus
10099
- },
10100
- type: "integration"
10101
- };
10102
- }
10103
- var triggerKinds = /* @__PURE__ */ new Set([
10104
- "error",
10105
- "cron",
10106
- "integration",
10107
- "poll",
10108
- "webhook"
10109
- ]);
10110
- var triggerHealth = /* @__PURE__ */ new Set([
10111
- "failed",
10112
- "healthy",
10113
- "initializing",
10114
- "needs_reauth",
10115
- "suspended"
10116
- ]);
10117
- var triggerActivityKinds = /* @__PURE__ */ new Set([
10118
- "delivery.failed",
10119
- "health.failed",
10120
- "health.needs_reauth",
10121
- "health.recovered",
10122
- "health.suspended",
10123
- "operator.paused",
10124
- "operator.resumed"
10125
- ]);
10126
- function triggerBinding(value) {
10127
- const source = record$1(value);
10128
- const health = source.health;
10129
- const listener = source.listener == null ? void 0 : record$1(source.listener);
10130
- if (listener != null && listener.health != "healthy" && listener.health != "failed" && listener.health != "needs_reauth") return invalidResponse();
10131
- const kind = source.kind;
10132
- const operatorState = source.operatorState;
10133
- const runtimeVersion = integer(source.runtimeVersion);
10134
- if (source.version != 1 || typeof health != "string" || !triggerHealth.has(health)) return invalidResponse();
10135
- if (typeof kind != "string" || !triggerKinds.has(kind)) return invalidResponse();
10136
- if (operatorState != "active" && operatorState != "paused") return invalidResponse();
10137
- if (runtimeVersion <= 0) return invalidResponse();
10138
- return {
10139
- ...source.currentPublicationId == null ? {} : { currentPublicationId: string(source.currentPublicationId) },
10140
- ...source.currentRevisionId == null ? {} : { currentRevisionId: string(source.currentRevisionId) },
10141
- ...source.endpointUrl == null ? {} : { endpointUrl: string(source.endpointUrl) },
10142
- ...listener == null ? {} : { listener: {
10143
- health: listener.health,
10144
- ...listener.lastErrorCode == null ? {} : { lastErrorCode: string(listener.lastErrorCode) }
10145
- } },
10146
- flowId: string(source.flowId),
10147
- health,
10148
- kind,
10149
- ...source.lastErrorCode == null ? {} : { lastErrorCode: string(source.lastErrorCode) },
10150
- operatorState,
10151
- runtimeVersion,
10152
- triggerNodeId: string(source.triggerNodeId),
10153
- updatedAt: string(source.updatedAt),
10154
- version: 1
10155
- };
10156
- }
10157
- function triggerBindingDetail(value) {
10158
- const source = record$1(value);
10159
- if (source.version != 1) return invalidResponse();
10160
- return {
10161
- binding: triggerBinding(source.binding),
10162
- version: 1
10163
- };
10164
- }
10165
- function triggerActivity(value) {
10166
- const source = record$1(value);
10167
- const kind = source.kind;
10168
- if (typeof kind != "string" || !triggerActivityKinds.has(kind)) return invalidResponse();
10169
- const errorCode = optionalString(source.errorCode);
10170
- const errorMessage = optionalString(source.errorMessage);
10171
- if (errorMessage != null && errorMessage.length > 512) return invalidResponse();
10172
- return {
10173
- activityId: string(source.activityId),
10174
- createdAt: string(source.createdAt),
10175
- ...errorCode == null ? {} : { errorCode },
10176
- ...errorMessage == null ? {} : { errorMessage },
10177
- kind
10355
+ description: typeof source.description == "string" ? source.description : invalidResponse(),
10356
+ ...homepageUrl == null ? {} : { homepageUrl },
10357
+ ...icon == null ? {} : { icon },
10358
+ ...providerIconAppearance(source.iconSprite, source.iconSpritePosition),
10359
+ inputs: ports(source.inputs, inputPort),
10360
+ name: string(source.name),
10361
+ outputs: ports(source.outputs, port),
10362
+ serviceId: string(source.serviceId),
10363
+ serviceName: string(source.serviceName)
10178
10364
  };
10179
10365
  }
10180
- function triggerActivityPage(value) {
10181
- const source = record$1(value);
10182
- const nextCursor = optionalString(source.nextCursor);
10183
- if (source.version != 1 || !Array.isArray(source.activities)) return invalidResponse();
10366
+ function connectorAction(value) {
10367
+ const { defaultConnection, ...metadata } = record$1(value);
10368
+ const action = connectorActionMetadata(metadata);
10369
+ if (defaultConnection == null) return action;
10370
+ const preferred = connection(defaultConnection);
10371
+ if (preferred.serviceId != action.serviceId || preferred.status != "active") return invalidResponse();
10184
10372
  return {
10185
- activities: source.activities.map(triggerActivity),
10186
- ...nextCursor == null ? {} : { nextCursor },
10187
- version: 1
10373
+ ...action,
10374
+ defaultConnection: preferred
10188
10375
  };
10189
10376
  }
10190
- function pollTriggerTestResult(value) {
10377
+ function connectorProvider(value) {
10191
10378
  const source = record$1(value);
10192
- const filtered = integer(source.filtered);
10193
- if (source.version != 1 || !Array.isArray(source.events) || typeof source.hasMore != "boolean" || filtered < 0) return invalidResponse();
10379
+ const homepageUrl = source.homepageUrl;
10380
+ const icon = source.icon;
10381
+ if (source.noSetup !== void 0 && typeof source.noSetup != "boolean") return invalidResponse();
10382
+ exact(source, [
10383
+ ...Object.hasOwn(source, "noSetup") ? ["noSetup"] : [],
10384
+ "serviceId",
10385
+ "serviceName",
10386
+ ...homepageUrl == null ? [] : ["homepageUrl"],
10387
+ ...icon == null ? [] : ["icon"],
10388
+ ..."iconSprite" in source ? ["iconSprite"] : [],
10389
+ ..."iconSpritePosition" in source ? ["iconSpritePosition"] : []
10390
+ ]);
10391
+ if (homepageUrl != null && typeof homepageUrl != "string" || icon != null && typeof icon != "string") return invalidResponse();
10194
10392
  return {
10195
- events: source.events.map((event) => {
10196
- const object = record$1(event);
10197
- return Object.fromEntries(Object.entries(object).map(([key, item]) => [key, jsonValue(item)]));
10198
- }),
10199
- filtered,
10200
- hasMore: source.hasMore,
10201
- version: 1
10393
+ ...homepageUrl == null ? {} : { homepageUrl },
10394
+ ...icon == null ? {} : { icon },
10395
+ ...providerIconAppearance(source.iconSprite, source.iconSpritePosition),
10396
+ serviceId: string(source.serviceId),
10397
+ serviceName: string(source.serviceName),
10398
+ ...source.noSetup === void 0 ? {} : { noSetup: source.noSetup }
10202
10399
  };
10203
10400
  }
10204
10401
  //#endregion
10402
+ //#region src/control/common/eventSources.ts
10403
+ var id = string$1().min(1).max(256);
10404
+ var eventType = string$1().regex(/^[a-z][a-z0-9_.]{0,127}$/);
10405
+ var name = string$1().trim().min(1).max(128);
10406
+ var eventSourceSchema = strictObject({
10407
+ version: literal(1),
10408
+ sourceId: id,
10409
+ revision: int().positive(),
10410
+ name,
10411
+ provider: _enum(["feishu", "feishu_app_bot"]),
10412
+ appId: id,
10413
+ connectionId: id,
10414
+ teamId: id.nullable(),
10415
+ enabled: boolean(),
10416
+ eventTypes: array(eventType),
10417
+ manageSubscriptions: boolean(),
10418
+ verificationTokenConfigured: boolean(),
10419
+ encryptKeyConfigured: boolean(),
10420
+ endpointUrl: string$1().nullable(),
10421
+ verifiedAt: string$1().nullable(),
10422
+ lastReceivedAt: string$1().nullable(),
10423
+ updatedAt: string$1(),
10424
+ consumers: array(strictObject({
10425
+ flowId: id,
10426
+ flowName: string$1(),
10427
+ triggerNodeId: id
10428
+ }))
10429
+ });
10430
+ function decodeEventSource(value) {
10431
+ return eventSourceSchema.parse(value);
10432
+ }
10433
+ function decodeEventSources(value) {
10434
+ return strictObject({
10435
+ version: literal(1),
10436
+ sources: array(eventSourceSchema),
10437
+ teamId: id.nullable().optional()
10438
+ }).parse(value);
10439
+ }
10440
+ var uiLanguageTags = new Map([
10441
+ "en",
10442
+ "zh-CN",
10443
+ "zh-TW",
10444
+ "ja",
10445
+ "ko",
10446
+ "ru",
10447
+ "fr"
10448
+ ].map((language) => [language.toLowerCase(), language]));
10449
+ function isUiLanguage(value) {
10450
+ return typeof value == "string" && uiLanguageTags.get(value.toLowerCase()) == value;
10451
+ }
10452
+ //#endregion
10205
10453
  //#region src/control/common/triggerCatalog.ts
10206
10454
  function decodeTriggerCatalog(value) {
10207
10455
  const source = record$1(value);
@@ -10534,140 +10782,54 @@ function errorListener(value) {
10534
10782
  enabled: source.enabled
10535
10783
  };
10536
10784
  }
10537
- //#endregion
10538
- //#region src/control/common/publicationDecoders.ts
10539
- function publication(value) {
10540
- const source = record$1(value);
10541
- const liveEnd = source.liveEnd == null ? void 0 : record$1(source.liveEnd);
10542
- if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
10543
- const operation = source.operation;
10544
- const sourcePublicationId = source.sourcePublicationId;
10545
- if (source.version != 1) return invalidResponse();
10546
- if (operation != "publish" && operation != "rollback") return invalidResponse();
10547
- if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
10785
+ function variableReferences(input) {
10786
+ const source = record$1(input);
10787
+ exact(source, [
10788
+ "version",
10789
+ "references",
10790
+ "unknown"
10791
+ ]);
10792
+ if (source.version != 1 || !Array.isArray(source.references) || !Array.isArray(source.unknown)) return invalidResponse();
10548
10793
  return {
10549
- ...liveEnd == null ? {} : { liveEnd: {
10550
- enabled: liveEnd.enabled,
10551
- endedAt: string(liveEnd.endedAt)
10552
- } },
10553
- actorId: string(source.actorId),
10554
- closureDigest: string(source.closureDigest),
10555
- createdAt: string(source.createdAt),
10556
- engineContract: string(source.engineContract),
10557
- flowId: string(source.flowId),
10558
- modelVersion: integer(source.modelVersion),
10559
- operation,
10560
- publicationId: string(source.publicationId),
10561
- sharedAccessDigest: string(source.sharedAccessDigest),
10562
- revisionDigest: string(source.revisionDigest),
10563
- revisionId: string(source.revisionId),
10564
- ...sourcePublicationId == null ? {} : { sourcePublicationId },
10565
- version: 1
10566
- };
10567
- }
10568
- function publishOperation(value) {
10569
- const source = record$1(value);
10570
- const status = source.status;
10571
- const common = {
10572
- createdAt: string(source.createdAt),
10573
- flowId: string(source.flowId),
10574
- operationId: string(source.operationId),
10575
- revisionId: string(source.revisionId),
10576
- updatedAt: string(source.updatedAt),
10577
- version: 1
10578
- };
10579
- if (source.version != 1) return invalidResponse();
10580
- switch (status) {
10581
- case "pending":
10582
- exact(source, [
10583
- "createdAt",
10584
- "flowId",
10585
- "operationId",
10586
- "revisionId",
10587
- "status",
10588
- "updatedAt",
10589
- "version"
10590
- ]);
10591
- return {
10592
- ...common,
10593
- status
10594
- };
10595
- case "succeeded":
10596
- exact(source, [
10597
- "createdAt",
10794
+ version: 1,
10795
+ references: source.references.map((value) => {
10796
+ const item = record$1(value);
10797
+ exact(item, [
10598
10798
  "flowId",
10599
- "operationId",
10600
- "publicationId",
10601
- "revisionId",
10602
- "status",
10603
- "updatedAt",
10604
- "version"
10799
+ "flowName",
10800
+ "draft",
10801
+ "live"
10605
10802
  ]);
10803
+ if (typeof item.draft != "boolean") return invalidResponse();
10804
+ const live = item.live === null ? null : record$1(item.live);
10805
+ if (live != null) {
10806
+ exact(live, ["publicationId", "enabled"]);
10807
+ if (typeof live.enabled != "boolean") return invalidResponse();
10808
+ }
10606
10809
  return {
10607
- ...common,
10608
- publicationId: string(source.publicationId),
10609
- status
10810
+ flowId: string(item.flowId),
10811
+ flowName: string(item.flowName),
10812
+ draft: item.draft,
10813
+ live: live == null ? null : {
10814
+ publicationId: string(live.publicationId),
10815
+ enabled: live.enabled
10816
+ }
10610
10817
  };
10611
- case "failed": {
10612
- exact(source, [
10613
- "createdAt",
10818
+ }),
10819
+ unknown: source.unknown.map((value) => {
10820
+ const item = record$1(value);
10821
+ exact(item, [
10614
10822
  "flowId",
10615
- "issue",
10616
- "operationId",
10617
- "revisionId",
10618
- "status",
10619
- "updatedAt",
10620
- "version"
10621
- ]);
10622
- const issue = record$1(source.issue);
10623
- const nodeId = issue.nodeId;
10624
- exact(issue, [
10625
- "code",
10626
- "message",
10627
- ...nodeId == null ? [] : ["nodeId"]
10823
+ "flowName",
10824
+ "scope"
10628
10825
  ]);
10826
+ if (item.scope !== "draft" && item.scope !== "live") return invalidResponse();
10629
10827
  return {
10630
- ...common,
10631
- issue: {
10632
- code: string(issue.code),
10633
- message: string(issue.message),
10634
- ...nodeId == null ? {} : { nodeId: string(nodeId) }
10635
- },
10636
- status
10828
+ flowId: string(item.flowId),
10829
+ flowName: string(item.flowName),
10830
+ scope: item.scope
10637
10831
  };
10638
- }
10639
- default: return invalidResponse();
10640
- }
10641
- }
10642
- function live(value) {
10643
- const source = record$1(value);
10644
- const status = source.status;
10645
- const candidate = source.publication;
10646
- if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
10647
- if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
10648
- if (status == "not-published" && candidate !== null) return invalidResponse();
10649
- if (status != "not-published" && candidate === null) return invalidResponse();
10650
- return {
10651
- flowId: string(source.flowId),
10652
- hasUnpublishedChanges: source.hasUnpublishedChanges,
10653
- publication: candidate === null ? null : publication(candidate),
10654
- revision: integer(source.revision),
10655
- status,
10656
- version: 1
10657
- };
10658
- }
10659
- function publicationPage(value) {
10660
- const source = record$1(value);
10661
- const nextCursor = source.nextCursor;
10662
- const total = source.total;
10663
- if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
10664
- if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
10665
- if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
10666
- return {
10667
- ...nextCursor == null ? {} : { nextCursor },
10668
- publications: source.publications.map(publication),
10669
- ...total == null ? {} : { total },
10670
- version: 1
10832
+ })
10671
10833
  };
10672
10834
  }
10673
10835
  //#endregion
@@ -11239,6 +11401,9 @@ var ControlClient = class {
11239
11401
  version: 1
11240
11402
  };
11241
11403
  }
11404
+ async getVariableReferences(name, signal) {
11405
+ return variableReferences(await this.request(`/v1/variables/${segment(name)}/references`, { signal }));
11406
+ }
11242
11407
  async getVariable(name) {
11243
11408
  return variable(await this.request(`/v1/variables/${segment(name)}`));
11244
11409
  }
@@ -11351,18 +11516,6 @@ var ControlClient = class {
11351
11516
  const query = parameters.size == 0 ? "" : `?${parameters}`;
11352
11517
  return triggerActivityPage(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/activities${query}`));
11353
11518
  }
11354
- async pauseFlowTrigger(flowId, triggerNodeId) {
11355
- return triggerBinding(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/pause`, {
11356
- body: JSON.stringify({ version: 1 }),
11357
- method: "POST"
11358
- }));
11359
- }
11360
- async resumeFlowTrigger(flowId, triggerNodeId) {
11361
- return triggerBinding(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/resume`, {
11362
- body: JSON.stringify({ version: 1 }),
11363
- method: "POST"
11364
- }));
11365
- }
11366
11519
  async testFlowPollTrigger(flowId, triggerNodeId) {
11367
11520
  return pollTriggerTestResult(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/test`, {
11368
11521
  body: JSON.stringify({ version: 1 }),
@@ -11618,6 +11771,11 @@ var ControlClient = class {
11618
11771
  method: "POST"
11619
11772
  }));
11620
11773
  }
11774
+ async getLiveDetails(flowId, signal) {
11775
+ const details = decodeLiveDetails(await this.request(`/v1/flows/${segment(flowId)}/live/details`, { signal }));
11776
+ if (details.flowId != flowId) return invalidResponse();
11777
+ return details;
11778
+ }
11621
11779
  async getLive(flowId, signal) {
11622
11780
  return live(await this.request(`/v1/flows/${segment(flowId)}/live`, { signal }));
11623
11781
  }
@@ -12902,17 +13060,24 @@ var triggerControlApiConformanceCases = [{
12902
13060
  const base = `/v1/flows/${flowId}/triggers`;
12903
13061
  const bindings = list((await json(await request(harness, base), 200, "List Trigger bindings")).bindings, "Trigger bindings").map((value) => record(value, "Trigger binding"));
12904
13062
  equal(bindings.map((value) => value.triggerNodeId), ["cron", "webhook"], "Trigger binding order");
12905
- for (const binding of bindings) equal(binding.currentPublicationId, publicationId, "Trigger Publication");
13063
+ for (const binding of bindings) {
13064
+ equal(binding.currentPublicationId, publicationId, "Trigger Publication");
13065
+ equal(binding.operatorState, void 0, "No individual Trigger control state");
13066
+ }
13067
+ const online = await client(harness).getLiveDetails(flowId);
13068
+ equal(online.publication?.publicationId, publicationId, "Online Publication");
13069
+ equal(online.entries.map((entry) => entry.type), ["cron", "webhook"], "Online entries");
13070
+ const onlineWebhook = online.entries.find((entry) => entry.type == "webhook");
13071
+ if (onlineWebhook?.type != "webhook") fail("Missing online Webhook.");
13072
+ equal(onlineWebhook.config.method, "POST", "Online request method");
13073
+ equal(onlineWebhook.config.body, {}, "Online request fields");
12906
13074
  const webhookPath = `${base}/webhook`;
12907
13075
  const endpointUrl = requiredString(record((await json(await request(harness, webhookPath), 200, "Read Webhook")).binding, "Webhook").endpointUrl, "Webhook endpoint");
12908
- const state = (action) => request(harness, `${webhookPath}/${action}`, {
13076
+ for (const action of ["pause", "resume"]) equal((await request(harness, `${webhookPath}/${action}`, {
12909
13077
  body: JSON.stringify({ version: 1 }),
12910
13078
  method: "POST"
12911
- });
12912
- equal((await json(await state("pause"), 200, "Pause Webhook")).operatorState, "paused", "Paused state");
12913
- equal((await harness.request(new Request(endpointUrl, { method: "POST" }))).status, 404, "Paused callback");
12914
- equal((await json(await state("resume"), 200, "Resume Webhook")).operatorState, "active", "Resumed state");
12915
- equal((await harness.request(new Request(endpointUrl, { method: "POST" }))).status, 200, "Resumed callback");
13079
+ })).status, 404, "Individual Trigger control is unavailable");
13080
+ equal(onlineWebhook.binding.endpointUrl, endpointUrl, "Online endpoint shares binding authority");
12916
13081
  const enable = (enabled) => request(harness, `/v1/flows/${flowId}/enabled`, {
12917
13082
  method: "PUT",
12918
13083
  body: JSON.stringify({
@@ -12923,19 +13088,9 @@ var triggerControlApiConformanceCases = [{
12923
13088
  });
12924
13089
  await json(await enable(false), 200, "Disable Trigger Flow");
12925
13090
  equal((await harness.request(new Request(endpointUrl, { method: "POST" }))).status, 404, "Disabled Flow blocks callback");
12926
- await json(await state("pause"), 200, "Pause binding while Flow disabled");
12927
13091
  await json(await enable(true), 200, "Enable Trigger Flow");
12928
- equal((await harness.request(new Request(endpointUrl, { method: "POST" }))).status, 404, "Enabling preserves binding pause");
12929
- await json(await state("resume"), 200, "Resume binding after enabling Flow");
12930
13092
  equal((await harness.request(new Request(endpointUrl, { method: "POST" }))).status, 200, "Enabled Flow permits callback");
12931
- const api = client(harness);
12932
- const activities = await api.listFlowTriggerActivities(flowId, "webhook");
12933
- if (activities.activities.length < 2) fail("Webhook fixture must record callback activities.");
12934
- const firstPage = await api.listFlowTriggerActivities(flowId, "webhook", { limit: 1 });
12935
- equal(firstPage.activities, activities.activities.slice(0, 1), "First Trigger activity page");
12936
- const cursor = requiredString(firstPage.nextCursor, "Trigger activity cursor");
12937
- equal((await api.listFlowTriggerActivities(flowId, "webhook", { cursor })).activities, activities.activities.slice(1), "Trigger activity continuation");
12938
- await error(await request(harness, `${base}/cron/activities?cursor=${encodeURIComponent(cursor)}`), 400, "page.invalid-cursor", "Activity cursor belongs to one Trigger");
13093
+ equal((await client(harness).listFlowTriggerActivities(flowId, "webhook")).activities, [], "Flow toggles do not record individual Trigger operations");
12939
13094
  await completePublish(harness, await publishRequest(harness, flowId, changedRevisionId(await json(await changeRequest(harness, flowId, triggerRevisionId, [{
12940
13095
  kind: "graph.node.delete",
12941
13096
  nodeId: "webhook"