304 lines
10 KiB
TypeScript
304 lines
10 KiB
TypeScript
// Module ID: 13244
|
|
// Function ID: 13245
|
|
// Name: conjurePublishConnection
|
|
// Dependencies: [10652, 13229, 584, 11411, 13232, 2]
|
|
// Exports: draftPatchNotes, publishProject, rejectPendingPublish
|
|
|
|
// Module 13244 (conjurePublishConnection)
|
|
import DispatcherDefault from "Dispatcher" /* 584 */;
|
|
import ConjurePublishActionCreators from "ConjurePublishActionCreators" /* 11411 */;
|
|
import conjureProjectSockets from "conjureProjectSockets" /* 13232 */;
|
|
import ConjureProjectStore from "ConjureProjectStore" /* 10652 */;
|
|
import ConjurePublishStatusStore from "ConjurePublishStatusStore" /* 13229 */;
|
|
import size from "module_2" /* 2 */;
|
|
|
|
function rejectPendingPatchNotesDraft(projectId, arg1) {
|
|
const value = map1.get(projectId);
|
|
const obj = map1;
|
|
if (null != value) {
|
|
obj.delete(projectId);
|
|
const _clearTimeout = clearTimeout;
|
|
clearTimeout(value.timeout);
|
|
const _Error = Error;
|
|
const self = this;
|
|
const self2 = this;
|
|
const reject = value.reject;
|
|
const error = new Error(arg1);
|
|
reject(error);
|
|
}
|
|
}
|
|
let obj = {
|
|
publish_notice(id, projectId) {
|
|
projectId = projectId.projectId;
|
|
const obj = DispatcherDefault;
|
|
const obj2 = { type: "CONJURE_CHAT_PUBLISH_NOTICE", projectId, id: id.id, content: id.content, timestamp: id.ts, publishNotice: id.publish_notice };
|
|
obj.dispatch(obj2);
|
|
}
|
|
};
|
|
let obj2 = {
|
|
publish_cta(publish_cta, arg1) {
|
|
let obj;
|
|
let obj3;
|
|
if (null != publish_cta.publish_cta) {
|
|
const surface = publish_cta.publish_cta.surface;
|
|
let tmp3 = null;
|
|
const obj2 = { type: "CONJURE_CHAT_TURN_PATCH", projectId: tmp, turnId: publish_cta.turn_id, patch: obj };
|
|
const dispatch = DispatcherDefault.dispatch;
|
|
DispatcherDefault;
|
|
if (null != surface) {
|
|
tmp3 = null;
|
|
if (set.has(surface)) {
|
|
tmp3 = surface;
|
|
}
|
|
}
|
|
obj = { publishCta: obj3 };
|
|
obj3 = { surface: tmp3 };
|
|
dispatch(obj2);
|
|
}
|
|
},
|
|
publish_status(published, projectId) {
|
|
let found;
|
|
let published_at;
|
|
let published_revision;
|
|
let tmp2;
|
|
projectId = projectId.projectId;
|
|
const surface = published.surface;
|
|
const obj = { type: "CONJURE_PROJECT_PUBLISH_STATUS_UPDATE", projectId, published: true === published.published, hasUnpublishedChanges: true === published.has_unpublished_changes, surface: tmp2, previewAppChannels: found, publishedRevision: published_revision, publishedAt: published_at, publishing: true === published.publishing };
|
|
tmp2 = null;
|
|
const dispatch = DispatcherDefault.dispatch;
|
|
DispatcherDefault;
|
|
if (null != surface) {
|
|
tmp2 = null;
|
|
if (set.has(surface)) {
|
|
tmp2 = surface;
|
|
}
|
|
}
|
|
if (Array.isArray(published.preview_app_channels)) {
|
|
const preview_app_channels = published.preview_app_channels;
|
|
found = preview_app_channels.filter((item) => typeof item === "string");
|
|
} else {
|
|
found = [];
|
|
}
|
|
published_revision = null;
|
|
if (typeof published.published_revision === "number") {
|
|
published_revision = published.published_revision;
|
|
}
|
|
published_at = null;
|
|
if (typeof published.published_at === "string") {
|
|
published_at = published.published_at;
|
|
}
|
|
dispatch(obj);
|
|
},
|
|
publish_result(ok, projectId) {
|
|
projectId = projectId.projectId;
|
|
const value = map.get(projectId);
|
|
map.delete(projectId);
|
|
if (null != value) {
|
|
const _clearTimeout = clearTimeout;
|
|
clearTimeout(value.timeout);
|
|
value.resolve(ok);
|
|
}
|
|
if (true !== ok.ok) {
|
|
let str = ok.error;
|
|
const trackPublishFailed = ConjurePublishActionCreators.trackPublishFailed;
|
|
ConjurePublishActionCreators;
|
|
if (str == null) {
|
|
str = "publish_result not ok";
|
|
}
|
|
trackPublishFailed(projectId, str, false);
|
|
} else {
|
|
const publishStatus = ConjurePublishStatusStore.getPublishStatus(projectId);
|
|
if (null != publishStatus) {
|
|
const obj = { type: "CONJURE_PROJECT_PUBLISH_STATUS_UPDATE", projectId, published: true, hasUnpublishedChanges: false, surface: null, previewAppChannels: null, publishedRevision: null, publishedAt: null };
|
|
({ surface: obj3.surface, previewAppChannels: obj3.previewAppChannels, publishedRevision: obj3.publishedRevision, publishedAt: obj3.publishedAt } = publishStatus);
|
|
const obj2 = DispatcherDefault;
|
|
obj2.dispatch(obj);
|
|
}
|
|
}
|
|
},
|
|
patch_notes_draft(nonce, projectId) {
|
|
projectId = projectId.projectId;
|
|
const value = map1.get(projectId);
|
|
const obj = map1;
|
|
const tmp = null != value && value.nonce === nonce.nonce;
|
|
if (tmp) {
|
|
obj.delete(projectId);
|
|
const _clearTimeout = clearTimeout;
|
|
clearTimeout(value.timeout);
|
|
value.resolve(nonce);
|
|
}
|
|
}
|
|
};
|
|
const map = new Map();
|
|
const map1 = new Map();
|
|
const set = new Set(["activity", "automod", "widget", "bot"]);
|
|
let result = size.fileFinishedImporting("modules/conjure/publish/conjurePublishConnection.tsx");
|
|
|
|
export const publishFrameHandlers = obj;
|
|
export const publishStepHandlers = obj2;
|
|
export const publishProject = function publishProject(id) {
|
|
const projectId = id;
|
|
let c1 = false;
|
|
const promise = new Promise(function(resolve, reject) {
|
|
let error1;
|
|
let tmp = dependencyMap;
|
|
let obj = conjureProjectSockets;
|
|
const conjureSocket = obj.getConjureSocket(projectId);
|
|
if (null != conjureSocket) {
|
|
if (map.has(projectId)) {
|
|
const _Error4 = Error;
|
|
const self5 = this;
|
|
const self6 = this;
|
|
let error = new Error("Publish already in flight");
|
|
reject(error);
|
|
} else {
|
|
const _setTimeout = setTimeout;
|
|
const timerId = setTimeout(function() {
|
|
const value = map.get(projectId);
|
|
const obj = map;
|
|
const tmp = projectId;
|
|
if (null != value) {
|
|
obj.delete(tmp);
|
|
const _clearTimeout = clearTimeout;
|
|
clearTimeout(value.timeout);
|
|
const _Error = Error;
|
|
const self = this;
|
|
const self2 = this;
|
|
const reject = value.reject;
|
|
const error = new Error("Publish timed out");
|
|
reject(error);
|
|
}
|
|
}, 900000);
|
|
const obj2 = { resolve, reject, timeout: timerId };
|
|
const result = obj3.set(tmp2, obj2);
|
|
c1 = true;
|
|
const obj4 = { type: "CONJURE_PROJECT_PUBLISH_START", projectId };
|
|
const obj5 = DispatcherDefault;
|
|
obj5.dispatch(obj4);
|
|
try {
|
|
conjureSocket.sendPublish();
|
|
} catch (error1) {
|
|
obj3.delete(tmp2);
|
|
let _clearTimeout = clearTimeout;
|
|
clearTimeout(timerId);
|
|
const _Error2 = Error;
|
|
if (!(error1 instanceof Error)) {
|
|
const _Error3 = Error;
|
|
const self3 = this;
|
|
const self4 = this;
|
|
error1 = new Error("publish send failed");
|
|
}
|
|
reject(error1);
|
|
}
|
|
}
|
|
} else {
|
|
let _Error = Error;
|
|
let self = this;
|
|
let self2 = this;
|
|
const error2 = new Error("Not connected");
|
|
reject(error2);
|
|
}
|
|
});
|
|
const catchPromise = promise.catch((error) => {
|
|
let str = "publish failed";
|
|
const trackPublishFailed = ConjurePublishActionCreators.trackPublishFailed;
|
|
ConjurePublishActionCreators;
|
|
const tmp2 = projectId;
|
|
if (error instanceof Error) {
|
|
str = error.message;
|
|
}
|
|
trackPublishFailed(tmp2, str, false);
|
|
throw error;
|
|
});
|
|
return catchPromise.finally(() => {
|
|
const tmp = c1;
|
|
if (tmp) {
|
|
const obj2 = { type: "CONJURE_PROJECT_PUBLISH_SETTLE", projectId };
|
|
const obj = DispatcherDefault;
|
|
obj.dispatch(obj2);
|
|
}
|
|
});
|
|
};
|
|
export const draftPatchNotes = function draftPatchNotes(id) {
|
|
let closure_0 = id;
|
|
const promise = new Promise(function(resolve, reject) {
|
|
let error;
|
|
let obj = conjureProjectSockets;
|
|
let tmp = id;
|
|
const conjureSocket = obj.getConjureSocket(id);
|
|
if (null != conjureSocket) {
|
|
rejectPendingPatchNotesDraft(tmp, "Superseded by a newer draft request");
|
|
const _Date = Date;
|
|
const _Math = Math;
|
|
const timestamp = Date.now();
|
|
const _HermesInternal = HermesInternal;
|
|
const str3 = Math.random();
|
|
const str1 = str3.toString(36);
|
|
const combined = "" + timestamp + "-" + str1.slice(2);
|
|
const _setTimeout = setTimeout;
|
|
const timerId = setTimeout(function() {
|
|
const value = map1.get(id);
|
|
const obj = map1;
|
|
const tmp = id;
|
|
if (null != value) {
|
|
obj.delete(tmp);
|
|
const _clearTimeout = clearTimeout;
|
|
clearTimeout(value.timeout);
|
|
const _Error = Error;
|
|
const self = this;
|
|
const self2 = this;
|
|
const reject = value.reject;
|
|
const error = new Error("Draft timed out");
|
|
reject(error);
|
|
}
|
|
}, 45000);
|
|
const obj3 = { resolve, reject, timeout: timerId, nonce: combined };
|
|
const result = map1.set(tmp, obj3);
|
|
const obj2 = map1;
|
|
try {
|
|
const sendDraftPatchNotes = conjureSocket.sendDraftPatchNotes;
|
|
const project = ConjureProjectStore.getProject(tmp);
|
|
let name;
|
|
if (project != null) {
|
|
name = project.name;
|
|
}
|
|
sendDraftPatchNotes(combined, name);
|
|
} catch (error) {
|
|
obj2.delete(tmp);
|
|
let _clearTimeout = clearTimeout;
|
|
clearTimeout(timerId);
|
|
const _Error2 = Error;
|
|
if (!(error instanceof Error)) {
|
|
const _Error3 = Error;
|
|
const self3 = this;
|
|
const self4 = this;
|
|
error = new Error("draft send failed");
|
|
}
|
|
reject(error);
|
|
}
|
|
} else {
|
|
let _Error = Error;
|
|
let self = this;
|
|
let self2 = this;
|
|
const error1 = new Error("Not connected");
|
|
reject(error1);
|
|
}
|
|
});
|
|
return promise;
|
|
};
|
|
export const rejectPendingPublish = function rejectPendingPublish(projectId, arg1) {
|
|
const value = map.get(projectId);
|
|
const obj = map;
|
|
if (null != value) {
|
|
obj.delete(projectId);
|
|
const _clearTimeout = clearTimeout;
|
|
clearTimeout(value.timeout);
|
|
const _Error = Error;
|
|
const self = this;
|
|
const self2 = this;
|
|
const reject = value.reject;
|
|
const error = new Error(arg1);
|
|
reject(error);
|
|
}
|
|
};
|
|
export { rejectPendingPatchNotesDraft };
|