@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.
@@ -5667,6 +5667,18 @@ function preprocess(fn, schema) {
5667
5667
  });
5668
5668
  }
5669
5669
  //#endregion
5670
+ //#region src/flow/common/webhookMethod.ts
5671
+ var webhookMethods = [
5672
+ "GET",
5673
+ "POST",
5674
+ "PUT",
5675
+ "PATCH",
5676
+ "DELETE"
5677
+ ];
5678
+ function webhookSupportsBody(method) {
5679
+ return method !== "GET";
5680
+ }
5681
+ //#endregion
5670
5682
  //#region ../../node_modules/.bun/dequal@2.0.3/node_modules/dequal/lite/index.mjs
5671
5683
  var has = Object.prototype.hasOwnProperty;
5672
5684
  function dequal(foo, bar) {
@@ -8616,18 +8628,6 @@ var triggerScheduleSchema = array(union([object({
8616
8628
  ]),
8617
8629
  value: number()
8618
8630
  })]));
8619
- //#endregion
8620
- //#region src/flow/common/webhookMethod.ts
8621
- var webhookMethods = [
8622
- "GET",
8623
- "POST",
8624
- "PUT",
8625
- "PATCH",
8626
- "DELETE"
8627
- ];
8628
- function webhookSupportsBody(method) {
8629
- return method !== "GET";
8630
- }
8631
8631
  var text = string$1();
8632
8632
  var json$2 = json$3();
8633
8633
  var strings$1 = array(text);
@@ -9003,7 +9003,7 @@ var graph = object({
9003
9003
  nodes: record$2(text, node),
9004
9004
  edges: array(edge).default([])
9005
9005
  });
9006
- var binding = object({
9006
+ var binding$1 = object({
9007
9007
  kind: literal("variable"),
9008
9008
  target: text
9009
9009
  });
@@ -9013,7 +9013,7 @@ var module = object({
9013
9013
  source: text
9014
9014
  });
9015
9015
  var document = preprocess(rejectRetiredDefinitions, object({
9016
- bindings: record$2(text, binding),
9016
+ bindings: record$2(text, binding$1),
9017
9017
  graph
9018
9018
  }));
9019
9019
  var revision = object({
@@ -9057,7 +9057,7 @@ var shapes = {
9057
9057
  },
9058
9058
  "binding.create": {
9059
9059
  bindingId: text,
9060
- binding
9060
+ binding: binding$1
9061
9061
  },
9062
9062
  "binding.delete": { bindingId: text },
9063
9063
  "binding.target.set": {
@@ -9225,7 +9225,7 @@ var authenticationSchema = union([
9225
9225
  in: _enum(["header", "query"])
9226
9226
  })
9227
9227
  ]);
9228
- strictObject({
9228
+ var authoringOpenApiSchema = strictObject({
9229
9229
  sourceUrl: string$1().min(1),
9230
9230
  path: string$1().min(1),
9231
9231
  method: string$1().min(1),
@@ -9322,36 +9322,53 @@ var when = union([
9322
9322
  all,
9323
9323
  strictObject({ any: array(union([expression, all])) })
9324
9324
  ]);
9325
- strictObject({}), strictObject({ sourceFlowIds: array(id$1).optional() }), authoringDefinitionSchemas.webhook.omit({ bodyFields: true }).extend({ body: inputFields }).strict(), strictObject({ schedule: authoringDefinitionSchemas.schedule }), strictObject({
9326
- key: id$1,
9327
- connectionId: id$1.optional(),
9328
- schedule: authoringDefinitionSchemas.schedule
9329
- }), strictObject({
9330
- key: id$1,
9331
- connectionId: id$1.optional()
9332
- }), strictObject({
9333
- inputs: inputFields,
9334
- outputs: outputFields,
9335
- capabilities: authoringDefinitionSchemas.capabilities.optional()
9336
- }), authoringDefinitionSchemas.connector.strict(), authoringDefinitionSchemas.agent.omit({
9337
- prompt: true,
9338
- tools: true
9339
- }).extend({
9340
- inputs: inputFields,
9341
- resultSchema: json$1.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),
9342
- tools: array(agentTool),
9343
- notification: notification.optional()
9344
- }).strict(), authoringLlmConfiguration.extend({ inputs: inputFields }), authoringDefinitionSchemas.decision, strictObject({
9345
- match: _enum(["first", "all"]),
9346
- branches: array(strictObject({
9347
- name: id$1,
9348
- description: string$1().optional(),
9349
- when
9350
- }))
9351
- }), strictObject({
9352
- values: patch,
9353
- outputs: outputFields
9354
- }), strictObject({ inputs: inputFields }), strictObject({ inputs: inputFields });
9325
+ var authoringConfigurations = {
9326
+ manual: strictObject({}),
9327
+ error: strictObject({ sourceFlowIds: array(id$1).optional() }),
9328
+ webhook: authoringDefinitionSchemas.webhook.omit({ bodyFields: true }).extend({ body: inputFields }).strict(),
9329
+ cron: strictObject({ schedule: authoringDefinitionSchemas.schedule }),
9330
+ poll: strictObject({
9331
+ key: id$1,
9332
+ connectionId: id$1.optional(),
9333
+ schedule: authoringDefinitionSchemas.schedule
9334
+ }),
9335
+ integration: strictObject({
9336
+ key: id$1,
9337
+ connectionId: id$1.optional()
9338
+ }),
9339
+ code: strictObject({
9340
+ inputs: inputFields,
9341
+ outputs: outputFields,
9342
+ capabilities: authoringDefinitionSchemas.capabilities.optional()
9343
+ }),
9344
+ connector: authoringDefinitionSchemas.connector.strict(),
9345
+ openapi: authoringOpenApiSchema,
9346
+ agent: authoringDefinitionSchemas.agent.omit({
9347
+ prompt: true,
9348
+ tools: true
9349
+ }).extend({
9350
+ inputs: inputFields,
9351
+ resultSchema: json$1.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),
9352
+ tools: array(agentTool),
9353
+ notification: notification.optional()
9354
+ }).strict(),
9355
+ llm: authoringLlmConfiguration.extend({ inputs: inputFields }),
9356
+ decision: authoringDefinitionSchemas.decision,
9357
+ condition: strictObject({
9358
+ match: _enum(["first", "all"]),
9359
+ branches: array(strictObject({
9360
+ name: id$1,
9361
+ description: string$1().optional(),
9362
+ when
9363
+ }))
9364
+ }),
9365
+ value: strictObject({
9366
+ values: patch,
9367
+ outputs: outputFields
9368
+ }),
9369
+ wait: strictObject({ inputs: inputFields }),
9370
+ approval: strictObject({ inputs: inputFields })
9371
+ };
9355
9372
  var updates = strictObject({
9356
9373
  name: id$1.optional(),
9357
9374
  description: string$1().optional(),
@@ -9498,38 +9515,36 @@ var authoringSearchResponse = object({
9498
9515
  version: literal(1)
9499
9516
  });
9500
9517
  //#endregion
9501
- //#region src/control/common/providerIconSprite.ts
9502
- /** Optional artwork must never make an otherwise usable catalog unavailable. */
9503
- function providerIconAppearance(metadata, position) {
9504
- if (!metadata || typeof metadata != "object" || !position || typeof position != "object") return {};
9505
- const m = metadata;
9506
- const p = position;
9507
- if (typeof m.version != "string" || ![
9508
- m.pixelRatio,
9509
- m.iconSize,
9510
- m.width,
9511
- m.height
9512
- ].every((v) => Number.isInteger(v) && v > 0) || ![
9513
- m.bleed,
9514
- p.x,
9515
- p.y
9516
- ].every((v) => Number.isInteger(v) && v >= 0) || p.x + m.iconSize > m.width || p.y + m.iconSize > m.height) return {};
9517
- try {
9518
- for (const url of [m.lightUrl, m.darkUrl]) if (typeof url != "string" || ![
9519
- "https:",
9520
- "http:",
9521
- "data:"
9522
- ].includes(new URL(url).protocol)) return {};
9523
- } catch {
9524
- return {};
9518
+ //#region src/control/common/authoringFields.ts
9519
+ /** Business field contracts, independent of storage handles and presentation groups. */
9520
+ function fieldsView(ports) {
9521
+ return Object.fromEntries(ports.flatMap((port) => "handle" in port ? [[port.handle, {
9522
+ schema: port.jsonSchema,
9523
+ nullable: port.nullable,
9524
+ ...port.description == null ? {} : { description: port.description },
9525
+ ...Object.hasOwn(port, "value") ? { default: port.value } : {}
9526
+ }]] : []));
9527
+ }
9528
+ //#endregion
9529
+ //#region src/control/common/authoringTriggers.ts
9530
+ /** Shared business configuration for authoring and published entry inspection. */
9531
+ function triggerConfiguration(node) {
9532
+ switch (node.kind) {
9533
+ case "manual": return {};
9534
+ case "webhook": return {
9535
+ body: fieldsView(node.bodyFields),
9536
+ method: node.method,
9537
+ ...node.options == null ? {} : { options: node.options }
9538
+ };
9539
+ case "cron": return { schedule: node.cronTimes };
9540
+ case "error": return node.sourceFlowIds == null ? {} : { sourceFlowIds: node.sourceFlowIds };
9541
+ case "poll":
9542
+ case "integration": return {
9543
+ key: node.definition.key,
9544
+ ...node.connectionId == null ? {} : { connectionId: node.connectionId },
9545
+ ...node.kind == "poll" ? { schedule: node.pollTimes } : {}
9546
+ };
9525
9547
  }
9526
- return {
9527
- iconSprite: m,
9528
- iconSpritePosition: {
9529
- x: p.x,
9530
- y: p.y
9531
- }
9532
- };
9533
9548
  }
9534
9549
  //#endregion
9535
9550
  //#region src/control/common/errors.ts
@@ -9679,160 +9694,630 @@ function optionalString(value) {
9679
9694
  return string(value);
9680
9695
  }
9681
9696
  //#endregion
9682
- //#region src/flow/common/encoding.ts
9683
- var encoder$1 = new TextEncoder();
9684
- function canonicalText(value) {
9685
- if (value == null || typeof value == "boolean" || typeof value == "string" || typeof value == "number") return JSON.stringify(value);
9686
- if (Array.isArray(value)) return `[${value.map(canonicalText).join(",")}]`;
9687
- const object = value;
9688
- return `{${Object.keys(object).toSorted().map((key) => `${JSON.stringify(key)}:${canonicalText(object[key])}`).join(",")}}`;
9689
- }
9690
- function canonicalJsonBytes(value) {
9691
- return encoder$1.encode(canonicalText(value));
9692
- }
9693
- async function digestBytes(bytes) {
9694
- const input = new Uint8Array(bytes.byteLength);
9695
- input.set(bytes);
9696
- return `sha256:${[...new Uint8Array(await crypto.subtle.digest("SHA-256", input))].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
9697
- }
9698
- //#endregion
9699
- //#region src/control/common/providerAccess.ts
9700
- var sourceSchema = discriminatedUnion("kind", [strictObject({ kind: literal("admin-delegation") }), strictObject({
9701
- kind: literal("policy"),
9702
- ruleId: string$1().min(1).nullable()
9703
- })]);
9704
- function parseProviderAccessSource(value) {
9705
- return sourceSchema.parse(value);
9706
- }
9707
- async function providerAccessBindingId(teamId, identity) {
9708
- return await digestBytes(canonicalJsonBytes([
9709
- "provider-access",
9710
- 2,
9711
- teamId,
9712
- identity.connectionId,
9713
- identity.providerId,
9714
- identity.source
9715
- ]));
9716
- }
9717
- //#endregion
9718
- //#region src/control/common/connectorDecoders.ts
9719
- function accessPermissions(value) {
9697
+ //#region src/control/common/publicationDecoders.ts
9698
+ function publication(value) {
9720
9699
  const source = record(value);
9721
- exact(source, [
9722
- "actionIds",
9723
- "allActions",
9724
- "triggerIds",
9725
- "allTriggers",
9726
- "configured",
9727
- "proxy"
9728
- ]);
9729
- if (!Array.isArray(source.actionIds)) return invalidResponse("permissions.actionIds: expected an array.");
9730
- if (!Array.isArray(source.triggerIds)) return invalidResponse("permissions.triggerIds: expected an array.");
9731
- if (typeof source.allActions != "boolean") return invalidResponse("permissions.allActions: expected a boolean.");
9732
- if (typeof source.allTriggers != "boolean") return invalidResponse("permissions.allTriggers: expected a boolean.");
9733
- if (typeof source.configured != "boolean") return invalidResponse("permissions.configured: expected a boolean.");
9734
- if (typeof source.proxy != "boolean") return invalidResponse("permissions.proxy: expected a boolean.");
9735
- const actionIds = source.actionIds.map(string);
9736
- const triggerIds = source.triggerIds.map(string);
9737
- if (new Set(actionIds).size != actionIds.length) return invalidResponse("permissions.actionIds: duplicate IDs.");
9738
- if (source.allActions && actionIds.length != 0) return invalidResponse("permissions.actionIds: must be empty when allActions is true.");
9739
- if (new Set(triggerIds).size != triggerIds.length) return invalidResponse("permissions.triggerIds: duplicate IDs.");
9740
- if (source.allTriggers && triggerIds.length != 0) return invalidResponse("permissions.triggerIds: must be empty when allTriggers is true.");
9741
- if (source.proxy && (!source.allActions || !source.allTriggers || source.configured)) return invalidResponse("permissions.proxy: requires allActions=true, allTriggers=true and configured=false.");
9700
+ const liveEnd = source.liveEnd == null ? void 0 : record(source.liveEnd);
9701
+ if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
9702
+ const operation = source.operation;
9703
+ const sourcePublicationId = source.sourcePublicationId;
9704
+ if (source.version != 1) return invalidResponse();
9705
+ if (operation != "publish" && operation != "rollback") return invalidResponse();
9706
+ if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
9742
9707
  return {
9743
- actionIds,
9744
- triggerIds,
9745
- allTriggers: source.allTriggers,
9746
- allActions: source.allActions,
9747
- configured: source.configured,
9748
- proxy: source.proxy
9708
+ ...liveEnd == null ? {} : { liveEnd: {
9709
+ enabled: liveEnd.enabled,
9710
+ endedAt: string(liveEnd.endedAt)
9711
+ } },
9712
+ actorId: string(source.actorId),
9713
+ closureDigest: string(source.closureDigest),
9714
+ createdAt: string(source.createdAt),
9715
+ engineContract: string(source.engineContract),
9716
+ flowId: string(source.flowId),
9717
+ modelVersion: integer(source.modelVersion),
9718
+ operation,
9719
+ publicationId: string(source.publicationId),
9720
+ sharedAccessDigest: string(source.sharedAccessDigest),
9721
+ revisionDigest: string(source.revisionDigest),
9722
+ revisionId: string(source.revisionId),
9723
+ ...sourcePublicationId == null ? {} : { sourcePublicationId },
9724
+ version: 1
9749
9725
  };
9750
9726
  }
9751
- function accessBinding(value, candidate) {
9727
+ function publishOperation(value) {
9752
9728
  const source = record(value);
9753
- const policyRevision = source.policyRevision;
9754
9729
  const status = source.status;
9755
- const isDefault = source.isDefault;
9756
- const legacy = Object.hasOwn(source, "displayName") && !Object.hasOwn(source, "connectionDisplayName");
9757
- const permissions = candidate && Object.hasOwn(source, "permissions") ? accessPermissions(source.permissions) : void 0;
9758
- const permissionGroupName = source.permissionGroupName;
9759
- exact(source, [
9760
- "accessBindingId",
9761
- "connectionId",
9762
- "source",
9763
- legacy ? "displayName" : "connectionDisplayName",
9764
- ...candidate && Object.hasOwn(source, "isDefault") ? ["isDefault"] : [],
9765
- ...candidate && permissions != null ? ["permissions"] : [],
9766
- ...Object.hasOwn(source, "permissionGroupName") ? ["permissionGroupName"] : [],
9767
- ...policyRevision == null ? [] : ["policyRevision"],
9768
- "providerId",
9769
- ...candidate ? [] : ["status"]
9770
- ]);
9771
- if (policyRevision != null && typeof policyRevision != "string") return invalidResponse("policyRevision: expected a string.");
9772
- if (candidate && isDefault !== void 0 && typeof isDefault != "boolean") return invalidResponse("isDefault: expected a boolean.");
9773
- if (permissionGroupName !== void 0 && permissionGroupName !== null && typeof permissionGroupName != "string") return invalidResponse("permissionGroupName: expected a string or null.");
9774
- if (!candidate && status != "active" && status != "forbidden" && status != "invalid" && status != "missing") return invalidResponse();
9775
- let bindingSource;
9776
- try {
9777
- bindingSource = parseProviderAccessSource(source.source);
9778
- } catch {
9779
- return invalidResponse("source: expected { kind: 'admin-delegation' } or { kind: 'policy', ruleId: string | null }.");
9780
- }
9781
- return {
9782
- accessBindingId: string(source.accessBindingId),
9783
- connectionId: string(source.connectionId),
9784
- source: bindingSource,
9785
- connectionDisplayName: string(legacy ? source.displayName : source.connectionDisplayName),
9786
- ...candidate && typeof isDefault == "boolean" ? { isDefault } : {},
9787
- ...permissions == null ? {} : { permissions },
9788
- ...permissionGroupName === void 0 ? {} : { permissionGroupName },
9789
- ...policyRevision == null ? {} : { policyRevision },
9790
- providerId: string(source.providerId),
9791
- ...candidate ? {} : { status }
9730
+ const common = {
9731
+ createdAt: string(source.createdAt),
9732
+ flowId: string(source.flowId),
9733
+ operationId: string(source.operationId),
9734
+ revisionId: string(source.revisionId),
9735
+ updatedAt: string(source.updatedAt),
9736
+ version: 1
9792
9737
  };
9793
- }
9794
- function accessMode(value) {
9795
- if (value != "implicit" && value != "selectable") return invalidResponse("mode: expected implicit or selectable.");
9796
- return value;
9797
- }
9798
- function connectorAccess(value) {
9799
- const source = record(value);
9800
- exact(source, [
9801
- "accessRevision",
9802
- "bindings",
9803
- "mode",
9804
- "sharedAccessDigest",
9805
- ..."providerIds" in source ? ["providerIds"] : [],
9806
- ..."discardedBindingCount" in source ? ["discardedBindingCount"] : [],
9807
- "version"
9808
- ]);
9809
- const accessRevision = integer(source.accessRevision);
9810
- if (source.version != 1 || accessRevision < 0 || !Array.isArray(source.bindings)) return invalidResponse();
9811
- if ("providerIds" in source && !Array.isArray(source.providerIds)) return invalidResponse();
9812
- const providerIds = source.providerIds == null ? void 0 : source.providerIds.map((id) => string(id));
9813
- if (providerIds != null && new Set(providerIds).size != providerIds.length) return invalidResponse();
9814
- let discardedBindingCount = source.discardedBindingCount == null ? 0 : integer(source.discardedBindingCount);
9815
- if (discardedBindingCount < 0) return invalidResponse();
9816
- const bindings = [];
9817
- for (const entry of source.bindings) try {
9818
- bindings.push(accessBinding(entry, false));
9819
- } catch (error) {
9820
- if (!(error instanceof ApiError) || error.code != "response.invalid") throw error;
9821
- if (entry != null && typeof entry == "object" && !Array.isArray(entry) && typeof entry.accessBindingId == "string" && entry.accessBindingId.length > 0 && typeof entry.providerId == "string" && entry.providerId.length > 0) bindings.push({
9822
- accessBindingId: entry.accessBindingId,
9823
- providerId: entry.providerId,
9824
- connectionId: null,
9825
- source: null,
9826
- status: "invalid",
9827
- connectionDisplayName: typeof entry.connectionDisplayName == "string" && entry.connectionDisplayName.length > 0 ? entry.connectionDisplayName : typeof entry.displayName == "string" && entry.displayName.length > 0 ? entry.displayName : entry.providerId,
9828
- permissionGroupName: typeof entry.permissionGroupName == "string" ? entry.permissionGroupName : null
9829
- });
9830
- else discardedBindingCount++;
9831
- }
9832
- if (new Set(bindings.map((binding) => binding.accessBindingId)).size != bindings.length) return invalidResponse();
9833
- return {
9834
- accessRevision,
9835
- ...discardedBindingCount == 0 ? {} : { discardedBindingCount },
9738
+ if (source.version != 1) return invalidResponse();
9739
+ switch (status) {
9740
+ case "pending":
9741
+ exact(source, [
9742
+ "createdAt",
9743
+ "flowId",
9744
+ "operationId",
9745
+ "revisionId",
9746
+ "status",
9747
+ "updatedAt",
9748
+ "version"
9749
+ ]);
9750
+ return {
9751
+ ...common,
9752
+ status
9753
+ };
9754
+ case "succeeded":
9755
+ exact(source, [
9756
+ "createdAt",
9757
+ "flowId",
9758
+ "operationId",
9759
+ "publicationId",
9760
+ "revisionId",
9761
+ "status",
9762
+ "updatedAt",
9763
+ "version"
9764
+ ]);
9765
+ return {
9766
+ ...common,
9767
+ publicationId: string(source.publicationId),
9768
+ status
9769
+ };
9770
+ case "failed": {
9771
+ exact(source, [
9772
+ "createdAt",
9773
+ "flowId",
9774
+ "issue",
9775
+ "operationId",
9776
+ "revisionId",
9777
+ "status",
9778
+ "updatedAt",
9779
+ "version"
9780
+ ]);
9781
+ const issue = record(source.issue);
9782
+ const nodeId = issue.nodeId;
9783
+ exact(issue, [
9784
+ "code",
9785
+ "message",
9786
+ ...nodeId == null ? [] : ["nodeId"]
9787
+ ]);
9788
+ return {
9789
+ ...common,
9790
+ issue: {
9791
+ code: string(issue.code),
9792
+ message: string(issue.message),
9793
+ ...nodeId == null ? {} : { nodeId: string(nodeId) }
9794
+ },
9795
+ status
9796
+ };
9797
+ }
9798
+ default: return invalidResponse();
9799
+ }
9800
+ }
9801
+ function live(value) {
9802
+ const source = record(value);
9803
+ const status = source.status;
9804
+ const candidate = source.publication;
9805
+ if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
9806
+ if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
9807
+ if (status == "not-published" && candidate !== null) return invalidResponse();
9808
+ if (status != "not-published" && candidate === null) return invalidResponse();
9809
+ return {
9810
+ flowId: string(source.flowId),
9811
+ hasUnpublishedChanges: source.hasUnpublishedChanges,
9812
+ publication: candidate === null ? null : publication(candidate),
9813
+ revision: integer(source.revision),
9814
+ status,
9815
+ version: 1
9816
+ };
9817
+ }
9818
+ function publicationPage(value) {
9819
+ const source = record(value);
9820
+ const nextCursor = source.nextCursor;
9821
+ const total = source.total;
9822
+ if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
9823
+ if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
9824
+ if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
9825
+ return {
9826
+ ...nextCursor == null ? {} : { nextCursor },
9827
+ publications: source.publications.map(publication),
9828
+ ...total == null ? {} : { total },
9829
+ version: 1
9830
+ };
9831
+ }
9832
+ //#endregion
9833
+ //#region src/trigger/common/configSchema.ts
9834
+ var configInputsSchema = array(union([strictObject({
9835
+ handle: string$1().min(1),
9836
+ description: string$1().optional(),
9837
+ jsonSchema: json$3(),
9838
+ nullable: boolean(),
9839
+ value: json$3().optional()
9840
+ }), strictObject({
9841
+ group: string$1(),
9842
+ collapsed: boolean().optional()
9843
+ })]));
9844
+ //#endregion
9845
+ //#region src/control/common/triggerDecoders.ts
9846
+ function triggerKeySummary(value) {
9847
+ const source = record(value);
9848
+ const type = source.type;
9849
+ if (type != "integration" && type != "poll") return invalidResponse();
9850
+ return {
9851
+ description: typeof source.description == "string" ? source.description : invalidResponse(),
9852
+ displayName: string(source.displayName),
9853
+ key: string(source.key),
9854
+ name: string(source.name),
9855
+ provider: string(source.provider),
9856
+ type
9857
+ };
9858
+ }
9859
+ function triggerKey(value) {
9860
+ const source = record(value);
9861
+ const summary = triggerKeySummary(source);
9862
+ const base = {
9863
+ configInputs: configInputsSchema.parse(source.configInputs),
9864
+ definitionVersion: source.definitionVersion === 2 ? 2 : invalidResponse(),
9865
+ description: summary.description,
9866
+ displayName: summary.displayName,
9867
+ key: summary.key,
9868
+ name: summary.name,
9869
+ outputs: (Array.isArray(source.outputs) ? source.outputs : invalidResponse()).map((entry) => {
9870
+ const port = record(entry);
9871
+ return Object.assign({
9872
+ handle: string(port.handle),
9873
+ jsonSchema: jsonValue(port.jsonSchema),
9874
+ nullable: typeof port.nullable === "boolean" ? port.nullable : invalidResponse()
9875
+ }, port.description == null ? {} : { description: string(port.description) });
9876
+ }),
9877
+ provider: summary.provider
9878
+ };
9879
+ if (summary.type == "poll") return {
9880
+ ...base,
9881
+ type: "poll"
9882
+ };
9883
+ const endpoint = record(source.endpoint);
9884
+ const body = record(endpoint.body);
9885
+ if (!Array.isArray(endpoint.methods) || !Array.isArray(body.formats) || typeof body.allowArray != "boolean" || typeof body.allowEmpty != "boolean") return invalidResponse();
9886
+ const methods = endpoint.methods.map(string);
9887
+ const formats = body.formats.map(string);
9888
+ const successStatus = integer(endpoint.successStatus);
9889
+ if (methods.some((method) => ![
9890
+ "DELETE",
9891
+ "GET",
9892
+ "HEAD",
9893
+ "PATCH",
9894
+ "POST",
9895
+ "PUT"
9896
+ ].includes(method)) || formats.some((format) => ![
9897
+ "form",
9898
+ "json",
9899
+ "multipart",
9900
+ "text"
9901
+ ].includes(format)) || successStatus < 200 || successStatus > 299) return invalidResponse();
9902
+ return {
9903
+ ...base,
9904
+ endpoint: {
9905
+ body: {
9906
+ allowArray: body.allowArray,
9907
+ allowEmpty: body.allowEmpty,
9908
+ formats
9909
+ },
9910
+ methods,
9911
+ successStatus
9912
+ },
9913
+ type: "integration"
9914
+ };
9915
+ }
9916
+ var triggerKinds = /* @__PURE__ */ new Set([
9917
+ "error",
9918
+ "cron",
9919
+ "integration",
9920
+ "poll",
9921
+ "webhook"
9922
+ ]);
9923
+ var triggerHealth = /* @__PURE__ */ new Set([
9924
+ "failed",
9925
+ "healthy",
9926
+ "initializing",
9927
+ "needs_reauth",
9928
+ "suspended"
9929
+ ]);
9930
+ var triggerActivityKinds = /* @__PURE__ */ new Set([
9931
+ "delivery.failed",
9932
+ "health.failed",
9933
+ "health.needs_reauth",
9934
+ "health.recovered",
9935
+ "health.suspended",
9936
+ "operator.paused",
9937
+ "operator.resumed"
9938
+ ]);
9939
+ function triggerBinding(value) {
9940
+ const source = record(value);
9941
+ const health = source.health;
9942
+ const listener = source.listener == null ? void 0 : record(source.listener);
9943
+ if (listener != null && listener.health != "healthy" && listener.health != "failed" && listener.health != "needs_reauth") return invalidResponse();
9944
+ const kind = source.kind;
9945
+ const runtimeVersion = integer(source.runtimeVersion);
9946
+ if (source.version != 1 || typeof health != "string" || !triggerHealth.has(health)) return invalidResponse();
9947
+ if (typeof kind != "string" || !triggerKinds.has(kind)) return invalidResponse();
9948
+ if (runtimeVersion <= 0) return invalidResponse();
9949
+ return {
9950
+ ...source.currentPublicationId == null ? {} : { currentPublicationId: string(source.currentPublicationId) },
9951
+ ...source.currentRevisionId == null ? {} : { currentRevisionId: string(source.currentRevisionId) },
9952
+ ...source.endpointUrl == null ? {} : { endpointUrl: string(source.endpointUrl) },
9953
+ ...listener == null ? {} : { listener: {
9954
+ health: listener.health,
9955
+ ...listener.lastErrorCode == null ? {} : { lastErrorCode: string(listener.lastErrorCode) }
9956
+ } },
9957
+ flowId: string(source.flowId),
9958
+ health,
9959
+ kind,
9960
+ ...source.lastErrorCode == null ? {} : { lastErrorCode: string(source.lastErrorCode) },
9961
+ runtimeVersion,
9962
+ triggerNodeId: string(source.triggerNodeId),
9963
+ updatedAt: string(source.updatedAt),
9964
+ version: 1
9965
+ };
9966
+ }
9967
+ function triggerBindingDetail(value) {
9968
+ const source = record(value);
9969
+ if (source.version != 1) return invalidResponse();
9970
+ return {
9971
+ binding: triggerBinding(source.binding),
9972
+ version: 1
9973
+ };
9974
+ }
9975
+ function triggerActivity(value) {
9976
+ const source = record(value);
9977
+ const kind = source.kind;
9978
+ if (typeof kind != "string" || !triggerActivityKinds.has(kind)) return invalidResponse();
9979
+ const errorCode = optionalString(source.errorCode);
9980
+ const errorMessage = optionalString(source.errorMessage);
9981
+ if (errorMessage != null && errorMessage.length > 512) return invalidResponse();
9982
+ return {
9983
+ activityId: string(source.activityId),
9984
+ createdAt: string(source.createdAt),
9985
+ ...errorCode == null ? {} : { errorCode },
9986
+ ...errorMessage == null ? {} : { errorMessage },
9987
+ kind
9988
+ };
9989
+ }
9990
+ function triggerActivityPage(value) {
9991
+ const source = record(value);
9992
+ const nextCursor = optionalString(source.nextCursor);
9993
+ if (source.version != 1 || !Array.isArray(source.activities)) return invalidResponse();
9994
+ return {
9995
+ activities: source.activities.map(triggerActivity),
9996
+ ...nextCursor == null ? {} : { nextCursor },
9997
+ version: 1
9998
+ };
9999
+ }
10000
+ function pollTriggerTestResult(value) {
10001
+ const source = record(value);
10002
+ const filtered = integer(source.filtered);
10003
+ if (source.version != 1 || !Array.isArray(source.events) || typeof source.hasMore != "boolean" || filtered < 0) return invalidResponse();
10004
+ return {
10005
+ events: source.events.map((event) => {
10006
+ const object = record(event);
10007
+ return Object.fromEntries(Object.entries(object).map(([key, item]) => [key, jsonValue(item)]));
10008
+ }),
10009
+ filtered,
10010
+ hasMore: source.hasMore,
10011
+ version: 1
10012
+ };
10013
+ }
10014
+ //#endregion
10015
+ //#region src/control/common/liveDetails.ts
10016
+ var metadata = {
10017
+ nodeId: string$1().min(1),
10018
+ name: string$1(),
10019
+ description: string$1().optional()
10020
+ };
10021
+ var binding = unknown().transform(triggerBinding);
10022
+ var provider = {
10023
+ provider: string$1().min(1),
10024
+ inputs: record$2(string$1(), discriminatedUnion("kind", [strictObject({
10025
+ kind: literal("value"),
10026
+ value: json$3()
10027
+ }), strictObject({ kind: literal("unset") })]))
10028
+ };
10029
+ var entrySchema = discriminatedUnion("type", [
10030
+ strictObject({
10031
+ ...metadata,
10032
+ type: literal("manual"),
10033
+ config: authoringConfigurations.manual
10034
+ }),
10035
+ strictObject({
10036
+ ...metadata,
10037
+ type: literal("webhook"),
10038
+ config: authoringConfigurations.webhook,
10039
+ binding
10040
+ }),
10041
+ strictObject({
10042
+ ...metadata,
10043
+ type: literal("cron"),
10044
+ config: authoringConfigurations.cron,
10045
+ binding
10046
+ }),
10047
+ strictObject({
10048
+ ...metadata,
10049
+ type: literal("error"),
10050
+ config: authoringConfigurations.error,
10051
+ binding
10052
+ }),
10053
+ strictObject({
10054
+ ...metadata,
10055
+ ...provider,
10056
+ type: literal("poll"),
10057
+ config: authoringConfigurations.poll,
10058
+ binding
10059
+ }),
10060
+ strictObject({
10061
+ ...metadata,
10062
+ ...provider,
10063
+ type: literal("integration"),
10064
+ config: authoringConfigurations.integration,
10065
+ binding
10066
+ })
10067
+ ]);
10068
+ /** Project only the selected published definition and its current bindings. */
10069
+ function liveEntries(content, current, bindings) {
10070
+ const byNode = new Map(bindings.filter((item) => item.flowId == current.flowId && item.currentPublicationId == current.publicationId && item.currentRevisionId == current.revisionId).map((item) => [item.triggerNodeId, item]));
10071
+ return decodeEntries(Object.entries(content.document.graph.nodes).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).flatMap(([nodeId, node]) => {
10072
+ if (node.kind != "manual" && node.kind != "webhook" && node.kind != "cron" && node.kind != "error" && node.kind != "poll" && node.kind != "integration") return [];
10073
+ const config = triggerConfiguration(node);
10074
+ return [{
10075
+ nodeId,
10076
+ name: node.name,
10077
+ type: node.kind,
10078
+ ...node.description == null ? {} : { description: node.description },
10079
+ config: node.kind == "webhook" && !webhookSupportsBody(node.method) ? {
10080
+ ...config,
10081
+ body: {}
10082
+ } : config,
10083
+ ...node.kind == "manual" ? {} : { binding: byNode.get(nodeId) },
10084
+ ...node.kind == "poll" || node.kind == "integration" ? {
10085
+ provider: node.definition.provider,
10086
+ inputs: node.config
10087
+ } : {}
10088
+ }];
10089
+ }), current);
10090
+ }
10091
+ function decodeLiveDetails(value) {
10092
+ const source = record(value);
10093
+ const flowId = string(source.flowId);
10094
+ if (source.version != 1 || !Array.isArray(source.entries)) return invalidResponse();
10095
+ if (source.publication === null) {
10096
+ if (source.status != "not-published" || source.entries.length != 0 || Object.hasOwn(source, "enabled")) return invalidResponse();
10097
+ return {
10098
+ flowId,
10099
+ publication: null,
10100
+ status: "not-published",
10101
+ entries: [],
10102
+ version: 1
10103
+ };
10104
+ }
10105
+ const current = publication(source.publication);
10106
+ const status = source.status;
10107
+ if (current.flowId != flowId || typeof source.enabled != "boolean") return invalidResponse();
10108
+ if (status != "runnable" && status != "suspended") return invalidResponse();
10109
+ if (!source.enabled && source.status == "runnable") return invalidResponse();
10110
+ return {
10111
+ flowId,
10112
+ publication: current,
10113
+ status,
10114
+ enabled: source.enabled,
10115
+ entries: decodeEntries(source.entries, current),
10116
+ version: 1
10117
+ };
10118
+ }
10119
+ /** Both producers and consumers enforce the same published-entry invariants. */
10120
+ function decodeEntries(values, current) {
10121
+ const parsed = array(entrySchema).safeParse(values);
10122
+ if (!parsed.success) return invalidResponse();
10123
+ const ids = /* @__PURE__ */ new Set();
10124
+ for (const entry of parsed.data) {
10125
+ if (ids.has(entry.nodeId)) return invalidResponse();
10126
+ ids.add(entry.nodeId);
10127
+ 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();
10128
+ if (entry.type == "webhook" && (!entry.binding.endpointUrl || !webhookSupportsBody(entry.config.method) && Object.keys(entry.config.body).length > 0)) return invalidResponse();
10129
+ }
10130
+ return parsed.data;
10131
+ }
10132
+ //#endregion
10133
+ //#region src/control/common/providerIconSprite.ts
10134
+ /** Optional artwork must never make an otherwise usable catalog unavailable. */
10135
+ function providerIconAppearance(metadata, position) {
10136
+ if (!metadata || typeof metadata != "object" || !position || typeof position != "object") return {};
10137
+ const m = metadata;
10138
+ const p = position;
10139
+ if (typeof m.version != "string" || ![
10140
+ m.pixelRatio,
10141
+ m.iconSize,
10142
+ m.width,
10143
+ m.height
10144
+ ].every((v) => Number.isInteger(v) && v > 0) || ![
10145
+ m.bleed,
10146
+ p.x,
10147
+ p.y
10148
+ ].every((v) => Number.isInteger(v) && v >= 0) || p.x + m.iconSize > m.width || p.y + m.iconSize > m.height) return {};
10149
+ try {
10150
+ for (const url of [m.lightUrl, m.darkUrl]) if (typeof url != "string" || ![
10151
+ "https:",
10152
+ "http:",
10153
+ "data:"
10154
+ ].includes(new URL(url).protocol)) return {};
10155
+ } catch {
10156
+ return {};
10157
+ }
10158
+ return {
10159
+ iconSprite: m,
10160
+ iconSpritePosition: {
10161
+ x: p.x,
10162
+ y: p.y
10163
+ }
10164
+ };
10165
+ }
10166
+ //#endregion
10167
+ //#region src/flow/common/encoding.ts
10168
+ var encoder$1 = new TextEncoder();
10169
+ function canonicalText(value) {
10170
+ if (value == null || typeof value == "boolean" || typeof value == "string" || typeof value == "number") return JSON.stringify(value);
10171
+ if (Array.isArray(value)) return `[${value.map(canonicalText).join(",")}]`;
10172
+ const object = value;
10173
+ return `{${Object.keys(object).toSorted().map((key) => `${JSON.stringify(key)}:${canonicalText(object[key])}`).join(",")}}`;
10174
+ }
10175
+ function canonicalJsonBytes(value) {
10176
+ return encoder$1.encode(canonicalText(value));
10177
+ }
10178
+ async function digestBytes(bytes) {
10179
+ const input = new Uint8Array(bytes.byteLength);
10180
+ input.set(bytes);
10181
+ return `sha256:${[...new Uint8Array(await crypto.subtle.digest("SHA-256", input))].map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
10182
+ }
10183
+ //#endregion
10184
+ //#region src/control/common/providerAccess.ts
10185
+ var sourceSchema = discriminatedUnion("kind", [strictObject({ kind: literal("admin-delegation") }), strictObject({
10186
+ kind: literal("policy"),
10187
+ ruleId: string$1().min(1).nullable()
10188
+ })]);
10189
+ function parseProviderAccessSource(value) {
10190
+ return sourceSchema.parse(value);
10191
+ }
10192
+ async function providerAccessBindingId(teamId, identity) {
10193
+ return await digestBytes(canonicalJsonBytes([
10194
+ "provider-access",
10195
+ 2,
10196
+ teamId,
10197
+ identity.connectionId,
10198
+ identity.providerId,
10199
+ identity.source
10200
+ ]));
10201
+ }
10202
+ //#endregion
10203
+ //#region src/control/common/connectorDecoders.ts
10204
+ function accessPermissions(value) {
10205
+ const source = record(value);
10206
+ exact(source, [
10207
+ "actionIds",
10208
+ "allActions",
10209
+ "triggerIds",
10210
+ "allTriggers",
10211
+ "configured",
10212
+ "proxy"
10213
+ ]);
10214
+ if (!Array.isArray(source.actionIds)) return invalidResponse("permissions.actionIds: expected an array.");
10215
+ if (!Array.isArray(source.triggerIds)) return invalidResponse("permissions.triggerIds: expected an array.");
10216
+ if (typeof source.allActions != "boolean") return invalidResponse("permissions.allActions: expected a boolean.");
10217
+ if (typeof source.allTriggers != "boolean") return invalidResponse("permissions.allTriggers: expected a boolean.");
10218
+ if (typeof source.configured != "boolean") return invalidResponse("permissions.configured: expected a boolean.");
10219
+ if (typeof source.proxy != "boolean") return invalidResponse("permissions.proxy: expected a boolean.");
10220
+ const actionIds = source.actionIds.map(string);
10221
+ const triggerIds = source.triggerIds.map(string);
10222
+ if (new Set(actionIds).size != actionIds.length) return invalidResponse("permissions.actionIds: duplicate IDs.");
10223
+ if (source.allActions && actionIds.length != 0) return invalidResponse("permissions.actionIds: must be empty when allActions is true.");
10224
+ if (new Set(triggerIds).size != triggerIds.length) return invalidResponse("permissions.triggerIds: duplicate IDs.");
10225
+ if (source.allTriggers && triggerIds.length != 0) return invalidResponse("permissions.triggerIds: must be empty when allTriggers is true.");
10226
+ if (source.proxy && (!source.allActions || !source.allTriggers || source.configured)) return invalidResponse("permissions.proxy: requires allActions=true, allTriggers=true and configured=false.");
10227
+ return {
10228
+ actionIds,
10229
+ triggerIds,
10230
+ allTriggers: source.allTriggers,
10231
+ allActions: source.allActions,
10232
+ configured: source.configured,
10233
+ proxy: source.proxy
10234
+ };
10235
+ }
10236
+ function accessBinding(value, candidate) {
10237
+ const source = record(value);
10238
+ const policyRevision = source.policyRevision;
10239
+ const status = source.status;
10240
+ const isDefault = source.isDefault;
10241
+ const legacy = Object.hasOwn(source, "displayName") && !Object.hasOwn(source, "connectionDisplayName");
10242
+ const permissions = candidate && Object.hasOwn(source, "permissions") ? accessPermissions(source.permissions) : void 0;
10243
+ const permissionGroupName = source.permissionGroupName;
10244
+ exact(source, [
10245
+ "accessBindingId",
10246
+ "connectionId",
10247
+ "source",
10248
+ legacy ? "displayName" : "connectionDisplayName",
10249
+ ...candidate && Object.hasOwn(source, "isDefault") ? ["isDefault"] : [],
10250
+ ...candidate && permissions != null ? ["permissions"] : [],
10251
+ ...Object.hasOwn(source, "permissionGroupName") ? ["permissionGroupName"] : [],
10252
+ ...policyRevision == null ? [] : ["policyRevision"],
10253
+ "providerId",
10254
+ ...candidate ? [] : ["status"]
10255
+ ]);
10256
+ if (policyRevision != null && typeof policyRevision != "string") return invalidResponse("policyRevision: expected a string.");
10257
+ if (candidate && isDefault !== void 0 && typeof isDefault != "boolean") return invalidResponse("isDefault: expected a boolean.");
10258
+ if (permissionGroupName !== void 0 && permissionGroupName !== null && typeof permissionGroupName != "string") return invalidResponse("permissionGroupName: expected a string or null.");
10259
+ if (!candidate && status != "active" && status != "forbidden" && status != "invalid" && status != "missing") return invalidResponse();
10260
+ let bindingSource;
10261
+ try {
10262
+ bindingSource = parseProviderAccessSource(source.source);
10263
+ } catch {
10264
+ return invalidResponse("source: expected { kind: 'admin-delegation' } or { kind: 'policy', ruleId: string | null }.");
10265
+ }
10266
+ return {
10267
+ accessBindingId: string(source.accessBindingId),
10268
+ connectionId: string(source.connectionId),
10269
+ source: bindingSource,
10270
+ connectionDisplayName: string(legacy ? source.displayName : source.connectionDisplayName),
10271
+ ...candidate && typeof isDefault == "boolean" ? { isDefault } : {},
10272
+ ...permissions == null ? {} : { permissions },
10273
+ ...permissionGroupName === void 0 ? {} : { permissionGroupName },
10274
+ ...policyRevision == null ? {} : { policyRevision },
10275
+ providerId: string(source.providerId),
10276
+ ...candidate ? {} : { status }
10277
+ };
10278
+ }
10279
+ function accessMode(value) {
10280
+ if (value != "implicit" && value != "selectable") return invalidResponse("mode: expected implicit or selectable.");
10281
+ return value;
10282
+ }
10283
+ function connectorAccess(value) {
10284
+ const source = record(value);
10285
+ exact(source, [
10286
+ "accessRevision",
10287
+ "bindings",
10288
+ "mode",
10289
+ "sharedAccessDigest",
10290
+ ..."providerIds" in source ? ["providerIds"] : [],
10291
+ ..."discardedBindingCount" in source ? ["discardedBindingCount"] : [],
10292
+ "version"
10293
+ ]);
10294
+ const accessRevision = integer(source.accessRevision);
10295
+ if (source.version != 1 || accessRevision < 0 || !Array.isArray(source.bindings)) return invalidResponse();
10296
+ if ("providerIds" in source && !Array.isArray(source.providerIds)) return invalidResponse();
10297
+ const providerIds = source.providerIds == null ? void 0 : source.providerIds.map((id) => string(id));
10298
+ if (providerIds != null && new Set(providerIds).size != providerIds.length) return invalidResponse();
10299
+ let discardedBindingCount = source.discardedBindingCount == null ? 0 : integer(source.discardedBindingCount);
10300
+ if (discardedBindingCount < 0) return invalidResponse();
10301
+ const bindings = [];
10302
+ for (const entry of source.bindings) try {
10303
+ bindings.push(accessBinding(entry, false));
10304
+ } catch (error) {
10305
+ if (!(error instanceof ApiError) || error.code != "response.invalid") throw error;
10306
+ if (entry != null && typeof entry == "object" && !Array.isArray(entry) && typeof entry.accessBindingId == "string" && entry.accessBindingId.length > 0 && typeof entry.providerId == "string" && entry.providerId.length > 0) bindings.push({
10307
+ accessBindingId: entry.accessBindingId,
10308
+ providerId: entry.providerId,
10309
+ connectionId: null,
10310
+ source: null,
10311
+ status: "invalid",
10312
+ connectionDisplayName: typeof entry.connectionDisplayName == "string" && entry.connectionDisplayName.length > 0 ? entry.connectionDisplayName : typeof entry.displayName == "string" && entry.displayName.length > 0 ? entry.displayName : entry.providerId,
10313
+ permissionGroupName: typeof entry.permissionGroupName == "string" ? entry.permissionGroupName : null
10314
+ });
10315
+ else discardedBindingCount++;
10316
+ }
10317
+ if (new Set(bindings.map((binding) => binding.accessBindingId)).size != bindings.length) return invalidResponse();
10318
+ return {
10319
+ accessRevision,
10320
+ ...discardedBindingCount == 0 ? {} : { discardedBindingCount },
9836
10321
  ...providerIds == null ? {} : { providerIds },
9837
10322
  bindings,
9838
10323
  mode: accessMode(source.mode),
@@ -10419,265 +10904,80 @@ function actionSummary(action) {
10419
10904
  } },
10420
10905
  description: action.description,
10421
10906
  name: action.name,
10422
- serviceId: action.serviceId,
10423
- serviceName: action.serviceName
10424
- };
10425
- }
10426
- function nodeDetails(content, nodeId, node) {
10427
- if (node.kind != "task") return {
10428
- node,
10429
- nodeId
10430
- };
10431
- if ("moduleId" in node.task) {
10432
- const module = content.modules[node.task.moduleId];
10433
- return {
10434
- node,
10435
- nodeId,
10436
- ...module == null ? {} : { module }
10437
- };
10438
- }
10439
- const task = node.task;
10440
- return {
10441
- node,
10442
- nodeId,
10443
- ...task == null ? {} : { task }
10444
- };
10445
- }
10446
- //#endregion
10447
- //#region src/control/common/eventSources.ts
10448
- var id = string$1().min(1).max(256);
10449
- var eventType = string$1().regex(/^[a-z][a-z0-9_.]{0,127}$/);
10450
- var name = string$1().trim().min(1).max(128);
10451
- var eventSourceSchema = strictObject({
10452
- version: literal(1),
10453
- sourceId: id,
10454
- revision: int().positive(),
10455
- name,
10456
- provider: _enum(["feishu", "feishu_app_bot"]),
10457
- appId: id,
10458
- connectionId: id,
10459
- teamId: id.nullable(),
10460
- enabled: boolean(),
10461
- eventTypes: array(eventType),
10462
- manageSubscriptions: boolean(),
10463
- verificationTokenConfigured: boolean(),
10464
- encryptKeyConfigured: boolean(),
10465
- endpointUrl: string$1().nullable(),
10466
- verifiedAt: string$1().nullable(),
10467
- lastReceivedAt: string$1().nullable(),
10468
- updatedAt: string$1(),
10469
- consumers: array(strictObject({
10470
- flowId: id,
10471
- flowName: string$1(),
10472
- triggerNodeId: id
10473
- }))
10474
- });
10475
- function decodeEventSource(value) {
10476
- return eventSourceSchema.parse(value);
10477
- }
10478
- function decodeEventSources(value) {
10479
- return strictObject({
10480
- version: literal(1),
10481
- sources: array(eventSourceSchema),
10482
- teamId: id.nullable().optional()
10483
- }).parse(value);
10484
- }
10485
- var uiLanguageTags = new Map([
10486
- "en",
10487
- "zh-CN",
10488
- "zh-TW",
10489
- "ja",
10490
- "ko",
10491
- "ru",
10492
- "fr"
10493
- ].map((language) => [language.toLowerCase(), language]));
10494
- function isUiLanguage(value) {
10495
- return typeof value == "string" && uiLanguageTags.get(value.toLowerCase()) == value;
10496
- }
10497
- //#endregion
10498
- //#region src/trigger/common/configSchema.ts
10499
- var configInputsSchema = array(union([strictObject({
10500
- handle: string$1().min(1),
10501
- description: string$1().optional(),
10502
- jsonSchema: json$3(),
10503
- nullable: boolean(),
10504
- value: json$3().optional()
10505
- }), strictObject({
10506
- group: string$1(),
10507
- collapsed: boolean().optional()
10508
- })]));
10509
- //#endregion
10510
- //#region src/control/common/triggerDecoders.ts
10511
- function triggerKeySummary(value) {
10512
- const source = record(value);
10513
- const type = source.type;
10514
- if (type != "integration" && type != "poll") return invalidResponse();
10515
- return {
10516
- description: typeof source.description == "string" ? source.description : invalidResponse(),
10517
- displayName: string(source.displayName),
10518
- key: string(source.key),
10519
- name: string(source.name),
10520
- provider: string(source.provider),
10521
- type
10522
- };
10523
- }
10524
- function triggerKey(value) {
10525
- const source = record(value);
10526
- const summary = triggerKeySummary(source);
10527
- const base = {
10528
- configInputs: configInputsSchema.parse(source.configInputs),
10529
- definitionVersion: source.definitionVersion === 2 ? 2 : invalidResponse(),
10530
- description: summary.description,
10531
- displayName: summary.displayName,
10532
- key: summary.key,
10533
- name: summary.name,
10534
- outputs: (Array.isArray(source.outputs) ? source.outputs : invalidResponse()).map((entry) => {
10535
- const port = record(entry);
10536
- return Object.assign({
10537
- handle: string(port.handle),
10538
- jsonSchema: jsonValue(port.jsonSchema),
10539
- nullable: typeof port.nullable === "boolean" ? port.nullable : invalidResponse()
10540
- }, port.description == null ? {} : { description: string(port.description) });
10541
- }),
10542
- provider: summary.provider
10543
- };
10544
- if (summary.type == "poll") return {
10545
- ...base,
10546
- type: "poll"
10547
- };
10548
- const endpoint = record(source.endpoint);
10549
- const body = record(endpoint.body);
10550
- if (!Array.isArray(endpoint.methods) || !Array.isArray(body.formats) || typeof body.allowArray != "boolean" || typeof body.allowEmpty != "boolean") return invalidResponse();
10551
- const methods = endpoint.methods.map(string);
10552
- const formats = body.formats.map(string);
10553
- const successStatus = integer(endpoint.successStatus);
10554
- if (methods.some((method) => ![
10555
- "DELETE",
10556
- "GET",
10557
- "HEAD",
10558
- "PATCH",
10559
- "POST",
10560
- "PUT"
10561
- ].includes(method)) || formats.some((format) => ![
10562
- "form",
10563
- "json",
10564
- "multipart",
10565
- "text"
10566
- ].includes(format)) || successStatus < 200 || successStatus > 299) return invalidResponse();
10567
- return {
10568
- ...base,
10569
- endpoint: {
10570
- body: {
10571
- allowArray: body.allowArray,
10572
- allowEmpty: body.allowEmpty,
10573
- formats
10574
- },
10575
- methods,
10576
- successStatus
10577
- },
10578
- type: "integration"
10579
- };
10580
- }
10581
- var triggerKinds = /* @__PURE__ */ new Set([
10582
- "error",
10583
- "cron",
10584
- "integration",
10585
- "poll",
10586
- "webhook"
10587
- ]);
10588
- var triggerHealth = /* @__PURE__ */ new Set([
10589
- "failed",
10590
- "healthy",
10591
- "initializing",
10592
- "needs_reauth",
10593
- "suspended"
10594
- ]);
10595
- var triggerActivityKinds = /* @__PURE__ */ new Set([
10596
- "delivery.failed",
10597
- "health.failed",
10598
- "health.needs_reauth",
10599
- "health.recovered",
10600
- "health.suspended",
10601
- "operator.paused",
10602
- "operator.resumed"
10603
- ]);
10604
- function triggerBinding(value) {
10605
- const source = record(value);
10606
- const health = source.health;
10607
- const listener = source.listener == null ? void 0 : record(source.listener);
10608
- if (listener != null && listener.health != "healthy" && listener.health != "failed" && listener.health != "needs_reauth") return invalidResponse();
10609
- const kind = source.kind;
10610
- const operatorState = source.operatorState;
10611
- const runtimeVersion = integer(source.runtimeVersion);
10612
- if (source.version != 1 || typeof health != "string" || !triggerHealth.has(health)) return invalidResponse();
10613
- if (typeof kind != "string" || !triggerKinds.has(kind)) return invalidResponse();
10614
- if (operatorState != "active" && operatorState != "paused") return invalidResponse();
10615
- if (runtimeVersion <= 0) return invalidResponse();
10616
- return {
10617
- ...source.currentPublicationId == null ? {} : { currentPublicationId: string(source.currentPublicationId) },
10618
- ...source.currentRevisionId == null ? {} : { currentRevisionId: string(source.currentRevisionId) },
10619
- ...source.endpointUrl == null ? {} : { endpointUrl: string(source.endpointUrl) },
10620
- ...listener == null ? {} : { listener: {
10621
- health: listener.health,
10622
- ...listener.lastErrorCode == null ? {} : { lastErrorCode: string(listener.lastErrorCode) }
10623
- } },
10624
- flowId: string(source.flowId),
10625
- health,
10626
- kind,
10627
- ...source.lastErrorCode == null ? {} : { lastErrorCode: string(source.lastErrorCode) },
10628
- operatorState,
10629
- runtimeVersion,
10630
- triggerNodeId: string(source.triggerNodeId),
10631
- updatedAt: string(source.updatedAt),
10632
- version: 1
10907
+ serviceId: action.serviceId,
10908
+ serviceName: action.serviceName
10633
10909
  };
10634
10910
  }
10635
- function triggerBindingDetail(value) {
10636
- const source = record(value);
10637
- if (source.version != 1) return invalidResponse();
10638
- return {
10639
- binding: triggerBinding(source.binding),
10640
- version: 1
10911
+ function nodeDetails(content, nodeId, node) {
10912
+ if (node.kind != "task") return {
10913
+ node,
10914
+ nodeId
10641
10915
  };
10642
- }
10643
- function triggerActivity(value) {
10644
- const source = record(value);
10645
- const kind = source.kind;
10646
- if (typeof kind != "string" || !triggerActivityKinds.has(kind)) return invalidResponse();
10647
- const errorCode = optionalString(source.errorCode);
10648
- const errorMessage = optionalString(source.errorMessage);
10649
- if (errorMessage != null && errorMessage.length > 512) return invalidResponse();
10916
+ if ("moduleId" in node.task) {
10917
+ const module = content.modules[node.task.moduleId];
10918
+ return {
10919
+ node,
10920
+ nodeId,
10921
+ ...module == null ? {} : { module }
10922
+ };
10923
+ }
10924
+ const task = node.task;
10650
10925
  return {
10651
- activityId: string(source.activityId),
10652
- createdAt: string(source.createdAt),
10653
- ...errorCode == null ? {} : { errorCode },
10654
- ...errorMessage == null ? {} : { errorMessage },
10655
- kind
10926
+ node,
10927
+ nodeId,
10928
+ ...task == null ? {} : { task }
10656
10929
  };
10657
10930
  }
10658
- function triggerActivityPage(value) {
10659
- const source = record(value);
10660
- const nextCursor = optionalString(source.nextCursor);
10661
- if (source.version != 1 || !Array.isArray(source.activities)) return invalidResponse();
10662
- return {
10663
- activities: source.activities.map(triggerActivity),
10664
- ...nextCursor == null ? {} : { nextCursor },
10665
- version: 1
10666
- };
10931
+ //#endregion
10932
+ //#region src/control/common/eventSources.ts
10933
+ var id = string$1().min(1).max(256);
10934
+ var eventType = string$1().regex(/^[a-z][a-z0-9_.]{0,127}$/);
10935
+ var name = string$1().trim().min(1).max(128);
10936
+ var eventSourceSchema = strictObject({
10937
+ version: literal(1),
10938
+ sourceId: id,
10939
+ revision: int().positive(),
10940
+ name,
10941
+ provider: _enum(["feishu", "feishu_app_bot"]),
10942
+ appId: id,
10943
+ connectionId: id,
10944
+ teamId: id.nullable(),
10945
+ enabled: boolean(),
10946
+ eventTypes: array(eventType),
10947
+ manageSubscriptions: boolean(),
10948
+ verificationTokenConfigured: boolean(),
10949
+ encryptKeyConfigured: boolean(),
10950
+ endpointUrl: string$1().nullable(),
10951
+ verifiedAt: string$1().nullable(),
10952
+ lastReceivedAt: string$1().nullable(),
10953
+ updatedAt: string$1(),
10954
+ consumers: array(strictObject({
10955
+ flowId: id,
10956
+ flowName: string$1(),
10957
+ triggerNodeId: id
10958
+ }))
10959
+ });
10960
+ function decodeEventSource(value) {
10961
+ return eventSourceSchema.parse(value);
10667
10962
  }
10668
- function pollTriggerTestResult(value) {
10669
- const source = record(value);
10670
- const filtered = integer(source.filtered);
10671
- if (source.version != 1 || !Array.isArray(source.events) || typeof source.hasMore != "boolean" || filtered < 0) return invalidResponse();
10672
- return {
10673
- events: source.events.map((event) => {
10674
- const object = record(event);
10675
- return Object.fromEntries(Object.entries(object).map(([key, item]) => [key, jsonValue(item)]));
10676
- }),
10677
- filtered,
10678
- hasMore: source.hasMore,
10679
- version: 1
10680
- };
10963
+ function decodeEventSources(value) {
10964
+ return strictObject({
10965
+ version: literal(1),
10966
+ sources: array(eventSourceSchema),
10967
+ teamId: id.nullable().optional()
10968
+ }).parse(value);
10969
+ }
10970
+ var uiLanguageTags = new Map([
10971
+ "en",
10972
+ "zh-CN",
10973
+ "zh-TW",
10974
+ "ja",
10975
+ "ko",
10976
+ "ru",
10977
+ "fr"
10978
+ ].map((language) => [language.toLowerCase(), language]));
10979
+ function isUiLanguage(value) {
10980
+ return typeof value == "string" && uiLanguageTags.get(value.toLowerCase()) == value;
10681
10981
  }
10682
10982
  //#endregion
10683
10983
  //#region src/control/common/triggerCatalog.ts
@@ -11135,140 +11435,54 @@ function errorListener(value) {
11135
11435
  enabled: source.enabled
11136
11436
  };
11137
11437
  }
11138
- //#endregion
11139
- //#region src/control/common/publicationDecoders.ts
11140
- function publication(value) {
11141
- const source = record(value);
11142
- const liveEnd = source.liveEnd == null ? void 0 : record(source.liveEnd);
11143
- if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
11144
- const operation = source.operation;
11145
- const sourcePublicationId = source.sourcePublicationId;
11146
- if (source.version != 1) return invalidResponse();
11147
- if (operation != "publish" && operation != "rollback") return invalidResponse();
11148
- if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
11438
+ function variableReferences(input) {
11439
+ const source = record(input);
11440
+ exact(source, [
11441
+ "version",
11442
+ "references",
11443
+ "unknown"
11444
+ ]);
11445
+ if (source.version != 1 || !Array.isArray(source.references) || !Array.isArray(source.unknown)) return invalidResponse();
11149
11446
  return {
11150
- ...liveEnd == null ? {} : { liveEnd: {
11151
- enabled: liveEnd.enabled,
11152
- endedAt: string(liveEnd.endedAt)
11153
- } },
11154
- actorId: string(source.actorId),
11155
- closureDigest: string(source.closureDigest),
11156
- createdAt: string(source.createdAt),
11157
- engineContract: string(source.engineContract),
11158
- flowId: string(source.flowId),
11159
- modelVersion: integer(source.modelVersion),
11160
- operation,
11161
- publicationId: string(source.publicationId),
11162
- sharedAccessDigest: string(source.sharedAccessDigest),
11163
- revisionDigest: string(source.revisionDigest),
11164
- revisionId: string(source.revisionId),
11165
- ...sourcePublicationId == null ? {} : { sourcePublicationId },
11166
- version: 1
11167
- };
11168
- }
11169
- function publishOperation(value) {
11170
- const source = record(value);
11171
- const status = source.status;
11172
- const common = {
11173
- createdAt: string(source.createdAt),
11174
- flowId: string(source.flowId),
11175
- operationId: string(source.operationId),
11176
- revisionId: string(source.revisionId),
11177
- updatedAt: string(source.updatedAt),
11178
- version: 1
11179
- };
11180
- if (source.version != 1) return invalidResponse();
11181
- switch (status) {
11182
- case "pending":
11183
- exact(source, [
11184
- "createdAt",
11185
- "flowId",
11186
- "operationId",
11187
- "revisionId",
11188
- "status",
11189
- "updatedAt",
11190
- "version"
11191
- ]);
11192
- return {
11193
- ...common,
11194
- status
11195
- };
11196
- case "succeeded":
11197
- exact(source, [
11198
- "createdAt",
11447
+ version: 1,
11448
+ references: source.references.map((value) => {
11449
+ const item = record(value);
11450
+ exact(item, [
11199
11451
  "flowId",
11200
- "operationId",
11201
- "publicationId",
11202
- "revisionId",
11203
- "status",
11204
- "updatedAt",
11205
- "version"
11452
+ "flowName",
11453
+ "draft",
11454
+ "live"
11206
11455
  ]);
11456
+ if (typeof item.draft != "boolean") return invalidResponse();
11457
+ const live = item.live === null ? null : record(item.live);
11458
+ if (live != null) {
11459
+ exact(live, ["publicationId", "enabled"]);
11460
+ if (typeof live.enabled != "boolean") return invalidResponse();
11461
+ }
11207
11462
  return {
11208
- ...common,
11209
- publicationId: string(source.publicationId),
11210
- status
11463
+ flowId: string(item.flowId),
11464
+ flowName: string(item.flowName),
11465
+ draft: item.draft,
11466
+ live: live == null ? null : {
11467
+ publicationId: string(live.publicationId),
11468
+ enabled: live.enabled
11469
+ }
11211
11470
  };
11212
- case "failed": {
11213
- exact(source, [
11214
- "createdAt",
11471
+ }),
11472
+ unknown: source.unknown.map((value) => {
11473
+ const item = record(value);
11474
+ exact(item, [
11215
11475
  "flowId",
11216
- "issue",
11217
- "operationId",
11218
- "revisionId",
11219
- "status",
11220
- "updatedAt",
11221
- "version"
11222
- ]);
11223
- const issue = record(source.issue);
11224
- const nodeId = issue.nodeId;
11225
- exact(issue, [
11226
- "code",
11227
- "message",
11228
- ...nodeId == null ? [] : ["nodeId"]
11476
+ "flowName",
11477
+ "scope"
11229
11478
  ]);
11479
+ if (item.scope !== "draft" && item.scope !== "live") return invalidResponse();
11230
11480
  return {
11231
- ...common,
11232
- issue: {
11233
- code: string(issue.code),
11234
- message: string(issue.message),
11235
- ...nodeId == null ? {} : { nodeId: string(nodeId) }
11236
- },
11237
- status
11481
+ flowId: string(item.flowId),
11482
+ flowName: string(item.flowName),
11483
+ scope: item.scope
11238
11484
  };
11239
- }
11240
- default: return invalidResponse();
11241
- }
11242
- }
11243
- function live(value) {
11244
- const source = record(value);
11245
- const status = source.status;
11246
- const candidate = source.publication;
11247
- if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
11248
- if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
11249
- if (status == "not-published" && candidate !== null) return invalidResponse();
11250
- if (status != "not-published" && candidate === null) return invalidResponse();
11251
- return {
11252
- flowId: string(source.flowId),
11253
- hasUnpublishedChanges: source.hasUnpublishedChanges,
11254
- publication: candidate === null ? null : publication(candidate),
11255
- revision: integer(source.revision),
11256
- status,
11257
- version: 1
11258
- };
11259
- }
11260
- function publicationPage(value) {
11261
- const source = record(value);
11262
- const nextCursor = source.nextCursor;
11263
- const total = source.total;
11264
- if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
11265
- if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
11266
- if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
11267
- return {
11268
- ...nextCursor == null ? {} : { nextCursor },
11269
- publications: source.publications.map(publication),
11270
- ...total == null ? {} : { total },
11271
- version: 1
11485
+ })
11272
11486
  };
11273
11487
  }
11274
11488
  //#endregion
@@ -11843,6 +12057,9 @@ var ControlClient = class {
11843
12057
  version: 1
11844
12058
  };
11845
12059
  }
12060
+ async getVariableReferences(name, signal) {
12061
+ return variableReferences(await this.request(`/v1/variables/${segment(name)}/references`, { signal }));
12062
+ }
11846
12063
  async getVariable(name) {
11847
12064
  return variable(await this.request(`/v1/variables/${segment(name)}`));
11848
12065
  }
@@ -11955,18 +12172,6 @@ var ControlClient = class {
11955
12172
  const query = parameters.size == 0 ? "" : `?${parameters}`;
11956
12173
  return triggerActivityPage(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/activities${query}`));
11957
12174
  }
11958
- async pauseFlowTrigger(flowId, triggerNodeId) {
11959
- return triggerBinding(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/pause`, {
11960
- body: JSON.stringify({ version: 1 }),
11961
- method: "POST"
11962
- }));
11963
- }
11964
- async resumeFlowTrigger(flowId, triggerNodeId) {
11965
- return triggerBinding(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/resume`, {
11966
- body: JSON.stringify({ version: 1 }),
11967
- method: "POST"
11968
- }));
11969
- }
11970
12175
  async testFlowPollTrigger(flowId, triggerNodeId) {
11971
12176
  return pollTriggerTestResult(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/test`, {
11972
12177
  body: JSON.stringify({ version: 1 }),
@@ -12222,6 +12427,11 @@ var ControlClient = class {
12222
12427
  method: "POST"
12223
12428
  }));
12224
12429
  }
12430
+ async getLiveDetails(flowId, signal) {
12431
+ const details = decodeLiveDetails(await this.request(`/v1/flows/${segment(flowId)}/live/details`, { signal }));
12432
+ if (details.flowId != flowId) return invalidResponse();
12433
+ return details;
12434
+ }
12225
12435
  async getLive(flowId, signal) {
12226
12436
  return live(await this.request(`/v1/flows/${segment(flowId)}/live`, { signal }));
12227
12437
  }
@@ -12388,4 +12598,4 @@ var ControlClient = class {
12388
12598
  }
12389
12599
  };
12390
12600
  //#endregion
12391
- export { ApiError, ControlClient, actionSummary, controlErrorCode, controlErrorMetadata, connectorAccess as decodeConnectorAccess, connectorAccessSnapshot as decodeConnectorAccessSnapshot, decodeEventSource, decodeEventSources, decodeResultList, decodeResultRead, decodeRunEvent, decodeTriggerCatalog, flowInspection, inspectFlowDraft, isRunTerminalEvent, nodeDetails, parseProviderAccessSource, parseResultQuery, providerAccessBindingId, providerIconAppearance, readResult, searchTriggerKeys };
12601
+ export { ApiError, ControlClient, actionSummary, controlErrorCode, controlErrorMetadata, connectorAccess as decodeConnectorAccess, connectorAccessSnapshot as decodeConnectorAccessSnapshot, decodeEventSource, decodeEventSources, decodeResultList, decodeResultRead, decodeRunEvent, decodeTriggerCatalog, flowInspection, inspectFlowDraft, isRunTerminalEvent, liveEntries, nodeDetails, parseProviderAccessSource, parseResultQuery, providerAccessBindingId, providerIconAppearance, readResult, searchTriggerKeys };