@mdfriday/foundry 26.3.20 → 26.3.22
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/cli.js
CHANGED
|
@@ -4599,6 +4599,7 @@ var init_identity2 = __esm({
|
|
|
4599
4599
|
IdentityAppService = class {
|
|
4600
4600
|
userFactory;
|
|
4601
4601
|
currentUser = null;
|
|
4602
|
+
cachedServerConfig = null;
|
|
4602
4603
|
constructor(options) {
|
|
4603
4604
|
this.userFactory = options.userFactory;
|
|
4604
4605
|
}
|
|
@@ -4606,16 +4607,22 @@ var init_identity2 = __esm({
|
|
|
4606
4607
|
// Initialization
|
|
4607
4608
|
// ============================================================================
|
|
4608
4609
|
/**
|
|
4609
|
-
*
|
|
4610
|
+
* 初始化服务(加载已保存的用户和服务器配置)
|
|
4610
4611
|
*/
|
|
4611
4612
|
async initialize() {
|
|
4612
4613
|
try {
|
|
4613
|
-
this.currentUser = await
|
|
4614
|
+
[this.currentUser, this.cachedServerConfig] = await Promise.all([
|
|
4615
|
+
this.userFactory.load(),
|
|
4616
|
+
this.userFactory.loadServerConfig()
|
|
4617
|
+
]);
|
|
4614
4618
|
if (this.currentUser) {
|
|
4615
4619
|
log7.info("User session restored");
|
|
4616
4620
|
} else {
|
|
4617
4621
|
log7.debug("No existing user session");
|
|
4618
4622
|
}
|
|
4623
|
+
if (this.cachedServerConfig) {
|
|
4624
|
+
log7.debug("Server config loaded from storage");
|
|
4625
|
+
}
|
|
4619
4626
|
} catch (error) {
|
|
4620
4627
|
log7.error("Failed to initialize identity service", error);
|
|
4621
4628
|
}
|
|
@@ -4627,18 +4634,18 @@ var init_identity2 = __esm({
|
|
|
4627
4634
|
* 用户登录
|
|
4628
4635
|
*/
|
|
4629
4636
|
async login(email, password) {
|
|
4630
|
-
const
|
|
4631
|
-
const user = await this.userFactory.login(email, password, savedConfig || void 0);
|
|
4637
|
+
const user = await this.userFactory.login(email, password, this.cachedServerConfig || void 0);
|
|
4632
4638
|
this.currentUser = user;
|
|
4639
|
+
this.cachedServerConfig = user.getServerConfig();
|
|
4633
4640
|
return user;
|
|
4634
4641
|
}
|
|
4635
4642
|
/**
|
|
4636
4643
|
* 用户注册
|
|
4637
4644
|
*/
|
|
4638
4645
|
async register(email, password) {
|
|
4639
|
-
const
|
|
4640
|
-
const user = await this.userFactory.register(email, password, savedConfig || void 0);
|
|
4646
|
+
const user = await this.userFactory.register(email, password, this.cachedServerConfig || void 0);
|
|
4641
4647
|
this.currentUser = user;
|
|
4648
|
+
this.cachedServerConfig = user.getServerConfig();
|
|
4642
4649
|
return user;
|
|
4643
4650
|
}
|
|
4644
4651
|
/**
|
|
@@ -4682,7 +4689,7 @@ var init_identity2 = __esm({
|
|
|
4682
4689
|
return {
|
|
4683
4690
|
isAuthenticated: false,
|
|
4684
4691
|
email: "",
|
|
4685
|
-
serverUrl:
|
|
4692
|
+
serverUrl: this.getServerConfig().getApiUrl(),
|
|
4686
4693
|
tokenExpired: true,
|
|
4687
4694
|
hasToken: false,
|
|
4688
4695
|
hasLicense: false,
|
|
@@ -4703,12 +4710,14 @@ var init_identity2 = __esm({
|
|
|
4703
4710
|
// ============================================================================
|
|
4704
4711
|
/**
|
|
4705
4712
|
* 获取服务器配置
|
|
4713
|
+
*
|
|
4714
|
+
* 优先级:当前用户配置 > 缓存配置 > 默认配置
|
|
4706
4715
|
*/
|
|
4707
4716
|
getServerConfig() {
|
|
4708
4717
|
if (this.currentUser) {
|
|
4709
4718
|
return this.currentUser.getServerConfig();
|
|
4710
4719
|
}
|
|
4711
|
-
return ServerConfig.createDefault();
|
|
4720
|
+
return this.cachedServerConfig || ServerConfig.createDefault();
|
|
4712
4721
|
}
|
|
4713
4722
|
/**
|
|
4714
4723
|
* 更新服务器配置
|
|
@@ -4718,6 +4727,7 @@ var init_identity2 = __esm({
|
|
|
4718
4727
|
this.currentUser = this.userFactory.createAnonymous();
|
|
4719
4728
|
}
|
|
4720
4729
|
await this.userFactory.updateServerConfig(this.currentUser, updates);
|
|
4730
|
+
this.cachedServerConfig = this.currentUser.getServerConfig();
|
|
4721
4731
|
}
|
|
4722
4732
|
// ============================================================================
|
|
4723
4733
|
// License Management
|
|
@@ -4729,8 +4739,7 @@ var init_identity2 = __esm({
|
|
|
4729
4739
|
* @returns 试用 License 信息和凭证
|
|
4730
4740
|
*/
|
|
4731
4741
|
async requestTrial(email) {
|
|
4732
|
-
|
|
4733
|
-
return this.userFactory.requestTrialLicense(email, savedConfig || void 0);
|
|
4742
|
+
return this.userFactory.requestTrialLicense(email, this.cachedServerConfig || void 0);
|
|
4734
4743
|
}
|
|
4735
4744
|
/**
|
|
4736
4745
|
* 使用 License Key 登录
|
|
@@ -4741,9 +4750,9 @@ var init_identity2 = __esm({
|
|
|
4741
4750
|
* @returns 登录成功的用户
|
|
4742
4751
|
*/
|
|
4743
4752
|
async loginWithLicense(licenseKey) {
|
|
4744
|
-
const
|
|
4745
|
-
const user = await this.userFactory.loginWithLicense(licenseKey, savedConfig || void 0);
|
|
4753
|
+
const user = await this.userFactory.loginWithLicense(licenseKey, this.cachedServerConfig || void 0);
|
|
4746
4754
|
this.currentUser = user;
|
|
4755
|
+
this.cachedServerConfig = user.getServerConfig();
|
|
4747
4756
|
return user;
|
|
4748
4757
|
}
|
|
4749
4758
|
/**
|
|
@@ -4785,9 +4794,9 @@ var init_identity2 = __esm({
|
|
|
4785
4794
|
* @returns 登录并激活后的 User
|
|
4786
4795
|
*/
|
|
4787
4796
|
async requestAndActivateTrial(email) {
|
|
4788
|
-
const
|
|
4789
|
-
const user = await this.userFactory.requestAndActivateTrial(email, savedConfig || void 0);
|
|
4797
|
+
const user = await this.userFactory.requestAndActivateTrial(email, this.cachedServerConfig || void 0);
|
|
4790
4798
|
this.currentUser = user;
|
|
4799
|
+
this.cachedServerConfig = user.getServerConfig();
|
|
4791
4800
|
return user;
|
|
4792
4801
|
}
|
|
4793
4802
|
/**
|
|
@@ -8660,7 +8669,7 @@ var init_mdfriday_publisher = __esm({
|
|
|
8660
8669
|
try {
|
|
8661
8670
|
log12.info(`Starting MDFriday deployment from: ${sourceDir}`);
|
|
8662
8671
|
log12.info(`Deployment type: ${this.config.deploymentType}`);
|
|
8663
|
-
if (!this.config.accessToken) {
|
|
8672
|
+
if (this.config.deploymentType !== "free" && !this.config.accessToken) {
|
|
8664
8673
|
throw new Error(
|
|
8665
8674
|
"MDFriday access token not found.\nPlease login first:\n mdf auth login"
|
|
8666
8675
|
);
|
|
@@ -8755,7 +8764,7 @@ var init_mdfriday_publisher = __esm({
|
|
|
8755
8764
|
*/
|
|
8756
8765
|
async testConnection() {
|
|
8757
8766
|
try {
|
|
8758
|
-
if (!this.config.accessToken) {
|
|
8767
|
+
if (this.config.deploymentType !== "free" && !this.config.accessToken) {
|
|
8759
8768
|
return {
|
|
8760
8769
|
success: false,
|
|
8761
8770
|
error: "Access token not found. Please login first: mdf auth login"
|
|
@@ -8825,12 +8834,16 @@ var init_mdfriday_publisher = __esm({
|
|
|
8825
8834
|
this.config.path || "",
|
|
8826
8835
|
this.config.deploymentType
|
|
8827
8836
|
);
|
|
8837
|
+
const isFreeDeployment = this.config.deploymentType === "free";
|
|
8838
|
+
const uploadUrl = isFreeDeployment ? `${this.getApiUrl()}/api/mdf/preview/friday?type=MDFPreview` : `${this.getApiUrl()}/api/mdf/preview?type=MDFPreview`;
|
|
8839
|
+
const headers = {};
|
|
8840
|
+
if (!isFreeDeployment && this.config.accessToken) {
|
|
8841
|
+
headers["Authorization"] = `Bearer ${this.config.accessToken}`;
|
|
8842
|
+
}
|
|
8828
8843
|
const response = await this.httpClient.postMultipart(
|
|
8829
|
-
|
|
8844
|
+
uploadUrl,
|
|
8830
8845
|
formData,
|
|
8831
|
-
|
|
8832
|
-
"Authorization": `Bearer ${this.config.accessToken}`
|
|
8833
|
-
}
|
|
8846
|
+
headers
|
|
8834
8847
|
);
|
|
8835
8848
|
clearInterval(progressInterval);
|
|
8836
8849
|
progressCallback?.(100);
|
|
@@ -8863,12 +8876,16 @@ var init_mdfriday_publisher = __esm({
|
|
|
8863
8876
|
host_name: "MDFriday Preview",
|
|
8864
8877
|
license_key: this.config.licenseKey || ""
|
|
8865
8878
|
};
|
|
8879
|
+
const isFreeDeployment = this.config.deploymentType === "free";
|
|
8880
|
+
const deployApiUrl = isFreeDeployment ? `${this.getApiUrl()}/api/mdf/preview/friday/deploy?type=MDFPreview&id=${previewId}` : `${this.getApiUrl()}/api/mdf/preview/deploy?type=MDFPreview&id=${previewId}`;
|
|
8881
|
+
const headers = {};
|
|
8882
|
+
if (!isFreeDeployment && this.config.accessToken) {
|
|
8883
|
+
headers["Authorization"] = `Bearer ${this.config.accessToken}`;
|
|
8884
|
+
}
|
|
8866
8885
|
const response = await this.httpClient.postMultipart(
|
|
8867
|
-
|
|
8886
|
+
deployApiUrl,
|
|
8868
8887
|
formData,
|
|
8869
|
-
|
|
8870
|
-
"Authorization": `Bearer ${this.config.accessToken}`
|
|
8871
|
-
}
|
|
8888
|
+
headers
|
|
8872
8889
|
);
|
|
8873
8890
|
if (!response.ok) {
|
|
8874
8891
|
const errorText = await response.text();
|
|
@@ -55163,7 +55180,7 @@ For more information, visit: https://help.mdfriday.com
|
|
|
55163
55180
|
* Show version
|
|
55164
55181
|
*/
|
|
55165
55182
|
showVersion() {
|
|
55166
|
-
const version = "26.3.
|
|
55183
|
+
const version = "26.3.22";
|
|
55167
55184
|
return {
|
|
55168
55185
|
success: true,
|
|
55169
55186
|
message: `MDFriday CLI v${version}`
|