@teamkeel/functions-runtime 0.443.0 → 0.445.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -652,6 +652,21 @@ var s3Client = (() => {
652
652
  credentials: (0, import_credential_providers.fromEnv)()
653
653
  });
654
654
  })();
655
+ function rewriteFilesDomain(url) {
656
+ const domain = process.env.KEEL_FILES_DOMAIN;
657
+ if (domain) {
658
+ const override = new URL(domain);
659
+ url.protocol = override.protocol;
660
+ url.hostname = override.hostname;
661
+ url.port = override.port;
662
+ const overridePath = override.pathname.replace(/\/+$/, "");
663
+ if (overridePath && overridePath !== "/") {
664
+ url.pathname = overridePath + url.pathname;
665
+ }
666
+ }
667
+ return url;
668
+ }
669
+ __name(rewriteFilesDomain, "rewriteFilesDomain");
655
670
  var InlineFile = class _InlineFile {
656
671
  static {
657
672
  __name(this, "InlineFile");
@@ -791,7 +806,7 @@ var File = class _File extends InlineFile {
791
806
  ResponseContentDisposition: "inline"
792
807
  });
793
808
  const url = await (0, import_s3_request_presigner.getSignedUrl)(s3Client, command, { expiresIn: 60 * 60 });
794
- return new URL(url);
809
+ return rewriteFilesDomain(new URL(url));
795
810
  }
796
811
  // Generates a presigned upload URL. If the file doesn't have a key, a new one will be generated
797
812
  async getPresignedUploadUrl() {
@@ -806,7 +821,7 @@ var File = class _File extends InlineFile {
806
821
  Key: "files/" + this.key
807
822
  });
808
823
  const url = await (0, import_s3_request_presigner.getSignedUrl)(s3Client, command, { expiresIn: 60 * 60 });
809
- return new URL(url);
824
+ return rewriteFilesDomain(new URL(url));
810
825
  }
811
826
  // Persists the file
812
827
  toDbRecord() {
@@ -2103,26 +2118,35 @@ var Task = class {
2103
2118
  this.deferredUntil = data.deferredUntil ? new Date(data.deferredUntil) : null;
2104
2119
  this.createdAt = new Date(data.createdAt);
2105
2120
  this.updatedAt = new Date(data.updatedAt);
2106
- this.assignedToId = data.assignedTo ?? null;
2121
+ this.assignedToUserId = data.assignedToUser ?? null;
2122
+ this.assignedToTeam = data.assignedToTeam ?? null;
2107
2123
  this.assignedAt = data.assignedAt ? new Date(data.assignedAt) : null;
2108
2124
  this.resolvedAt = data.resolvedAt ? new Date(data.resolvedAt) : null;
2109
2125
  this.flowRunId = data.flowRunId ?? null;
2110
2126
  }
2111
2127
  /**
2112
- * Assigns the task to an identity.
2113
- * @param {Object} options Options containing identityId
2114
- * @param {string} options.identityId The ID of the identity to assign the task to
2128
+ * Assigns the task to a user or team.
2129
+ * @param {Object} options Options containing userId or teamName (exactly one required)
2130
+ * @param {string} [options.userId] The ID of the user to assign the task to
2131
+ * @param {string} [options.teamName] The name of the team to assign the task to
2115
2132
  * @returns {Promise<void>}
2116
2133
  */
2117
- async assign({ identityId }) {
2134
+ async assign({ userId, teamName }) {
2118
2135
  const name = spanNameForModelAPI(this._taskName, "assign");
2119
2136
  return withSpan(name, async () => {
2120
2137
  const apiUrl = getApiUrl();
2121
2138
  const url = `${apiUrl}/topics/json/${this._taskName}/tasks/${this.id}/assign`;
2139
+ const body = {};
2140
+ if (userId !== void 0) {
2141
+ body.assigned_to_user = userId;
2142
+ }
2143
+ if (teamName !== void 0) {
2144
+ body.assigned_to_team = teamName;
2145
+ }
2122
2146
  const response = await fetch(url, {
2123
2147
  method: "PUT",
2124
2148
  headers: buildHeaders(this._identity, this._authToken),
2125
- body: JSON.stringify({ assigned_to: identityId })
2149
+ body: JSON.stringify(body)
2126
2150
  });
2127
2151
  if (!response.ok) {
2128
2152
  const errorBody = await response.json().catch(() => ({}));