@symbo.ls/sdk 2.32.2 → 2.32.4
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/cjs/config/environment.js +43 -8
- package/dist/cjs/index.js +12 -4
- package/dist/cjs/services/AdminService.js +4 -4
- package/dist/cjs/services/AuthService.js +36 -149
- package/dist/cjs/services/BaseService.js +5 -18
- package/dist/cjs/services/BranchService.js +10 -10
- package/dist/cjs/services/CollabService.js +94 -61
- package/dist/cjs/services/CoreService.js +19 -19
- package/dist/cjs/services/DnsService.js +4 -4
- package/dist/cjs/services/FileService.js +2 -2
- package/dist/cjs/services/PaymentService.js +2 -2
- package/dist/cjs/services/PlanService.js +12 -12
- package/dist/cjs/services/ProjectService.js +45 -35
- package/dist/cjs/services/PullRequestService.js +7 -7
- package/dist/cjs/services/ScreenshotService.js +304 -0
- package/dist/cjs/services/SubscriptionService.js +14 -14
- package/dist/cjs/services/index.js +4 -0
- package/dist/cjs/utils/TokenManager.js +16 -5
- package/dist/cjs/utils/changePreprocessor.js +134 -0
- package/dist/cjs/utils/jsonDiff.js +46 -4
- package/dist/cjs/utils/ordering.js +274 -0
- package/dist/cjs/utils/services.js +14 -1
- package/dist/esm/config/environment.js +43 -8
- package/dist/esm/index.js +1099 -417
- package/dist/esm/services/AdminService.js +68 -35
- package/dist/esm/services/AuthService.js +100 -168
- package/dist/esm/services/BaseService.js +64 -31
- package/dist/esm/services/BranchService.js +74 -41
- package/dist/esm/services/CollabService.js +570 -97
- package/dist/esm/services/CoreService.js +83 -50
- package/dist/esm/services/DnsService.js +68 -35
- package/dist/esm/services/FileService.js +66 -33
- package/dist/esm/services/PaymentService.js +66 -33
- package/dist/esm/services/PlanService.js +76 -43
- package/dist/esm/services/ProjectService.js +547 -66
- package/dist/esm/services/PullRequestService.js +71 -38
- package/dist/esm/services/ScreenshotService.js +992 -0
- package/dist/esm/services/SubscriptionService.js +78 -45
- package/dist/esm/services/index.js +1076 -412
- package/dist/esm/utils/CollabClient.js +89 -12
- package/dist/esm/utils/TokenManager.js +16 -5
- package/dist/esm/utils/changePreprocessor.js +442 -0
- package/dist/esm/utils/jsonDiff.js +46 -4
- package/dist/esm/utils/ordering.js +256 -0
- package/dist/esm/utils/services.js +14 -1
- package/dist/node/config/environment.js +43 -8
- package/dist/node/index.js +14 -5
- package/dist/node/services/AdminService.js +4 -4
- package/dist/node/services/AuthService.js +36 -139
- package/dist/node/services/BaseService.js +5 -18
- package/dist/node/services/BranchService.js +10 -10
- package/dist/node/services/CollabService.js +95 -62
- package/dist/node/services/CoreService.js +19 -19
- package/dist/node/services/DnsService.js +4 -4
- package/dist/node/services/FileService.js +2 -2
- package/dist/node/services/PaymentService.js +2 -2
- package/dist/node/services/PlanService.js +12 -12
- package/dist/node/services/ProjectService.js +45 -35
- package/dist/node/services/PullRequestService.js +7 -7
- package/dist/node/services/ScreenshotService.js +285 -0
- package/dist/node/services/SubscriptionService.js +14 -14
- package/dist/node/services/index.js +4 -0
- package/dist/node/utils/TokenManager.js +16 -5
- package/dist/node/utils/changePreprocessor.js +115 -0
- package/dist/node/utils/jsonDiff.js +46 -4
- package/dist/node/utils/ordering.js +255 -0
- package/dist/node/utils/services.js +14 -1
- package/package.json +7 -6
- package/src/config/environment.js +48 -9
- package/src/index.js +38 -22
- package/src/services/AdminService.js +4 -4
- package/src/services/AuthService.js +42 -175
- package/src/services/BaseService.js +7 -24
- package/src/services/BranchService.js +10 -10
- package/src/services/CollabService.js +115 -74
- package/src/services/CoreService.js +19 -19
- package/src/services/DnsService.js +4 -4
- package/src/services/FileService.js +2 -2
- package/src/services/PaymentService.js +2 -2
- package/src/services/PlanService.js +12 -12
- package/src/services/ProjectService.js +50 -35
- package/src/services/PullRequestService.js +7 -7
- package/src/services/ScreenshotService.js +258 -0
- package/src/services/SubscriptionService.js +14 -14
- package/src/services/index.js +6 -1
- package/src/utils/TokenManager.js +19 -5
- package/src/utils/changePreprocessor.js +139 -0
- package/src/utils/jsonDiff.js +40 -5
- package/src/utils/ordering.js +244 -0
- package/src/utils/services.js +15 -1
|
@@ -56,7 +56,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
56
56
|
}
|
|
57
57
|
throw new Error(response.message);
|
|
58
58
|
} catch (error) {
|
|
59
|
-
throw new Error(`Failed to create subscription: ${error.message}
|
|
59
|
+
throw new Error(`Failed to create subscription: ${error.message}`, { cause: error });
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
@@ -77,7 +77,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
77
77
|
}
|
|
78
78
|
throw new Error(response.message);
|
|
79
79
|
} catch (error) {
|
|
80
|
-
throw new Error(`Failed to get project subscription status: ${error.message}
|
|
80
|
+
throw new Error(`Failed to get project subscription status: ${error.message}`, { cause: error });
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
@@ -98,7 +98,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
98
98
|
}
|
|
99
99
|
throw new Error(response.message);
|
|
100
100
|
} catch (error) {
|
|
101
|
-
throw new Error(`Failed to get subscription usage: ${error.message}
|
|
101
|
+
throw new Error(`Failed to get subscription usage: ${error.message}`, { cause: error });
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
@@ -119,7 +119,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
119
119
|
}
|
|
120
120
|
throw new Error(response.message);
|
|
121
121
|
} catch (error) {
|
|
122
|
-
throw new Error(`Failed to cancel subscription: ${error.message}
|
|
122
|
+
throw new Error(`Failed to cancel subscription: ${error.message}`, { cause: error });
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
@@ -156,7 +156,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
156
156
|
}
|
|
157
157
|
throw new Error(response.message);
|
|
158
158
|
} catch (error) {
|
|
159
|
-
throw new Error(`Failed to list invoices: ${error.message}
|
|
159
|
+
throw new Error(`Failed to list invoices: ${error.message}`, { cause: error });
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
@@ -183,7 +183,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
183
183
|
}
|
|
184
184
|
throw new Error(response.message);
|
|
185
185
|
} catch (error) {
|
|
186
|
-
throw new Error(`Failed to get portal URL: ${error.message}
|
|
186
|
+
throw new Error(`Failed to get portal URL: ${error.message}`, { cause: error });
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
// ==================== SUBSCRIPTION HELPER METHODS ====================
|
|
@@ -218,7 +218,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
218
218
|
const status = await this.getProjectStatus(projectId);
|
|
219
219
|
return status.hasSubscription === true;
|
|
220
220
|
} catch (error) {
|
|
221
|
-
throw new Error(`Failed to check subscription status: ${error.message}
|
|
221
|
+
throw new Error(`Failed to check subscription status: ${error.message}`, { cause: error });
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
@@ -232,7 +232,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
232
232
|
}
|
|
233
233
|
return status.subscription;
|
|
234
234
|
} catch (error) {
|
|
235
|
-
throw new Error(`Failed to get project subscription: ${error.message}
|
|
235
|
+
throw new Error(`Failed to get project subscription: ${error.message}`, { cause: error });
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
@@ -246,7 +246,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
246
246
|
}
|
|
247
247
|
return status.usage;
|
|
248
248
|
} catch (error) {
|
|
249
|
-
throw new Error(`Failed to get project usage: ${error.message}
|
|
249
|
+
throw new Error(`Failed to get project usage: ${error.message}`, { cause: error });
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
/**
|
|
@@ -260,7 +260,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
260
260
|
pagination: result.pagination || {}
|
|
261
261
|
};
|
|
262
262
|
} catch (error) {
|
|
263
|
-
throw new Error(`Failed to get invoices with pagination: ${error.message}
|
|
263
|
+
throw new Error(`Failed to get invoices with pagination: ${error.message}`, { cause: error });
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
/**
|
|
@@ -271,7 +271,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
271
271
|
const usage = await this.getUsage(subscriptionId);
|
|
272
272
|
return usage && usage.subscription && usage.subscription.status === "active";
|
|
273
273
|
} catch (error) {
|
|
274
|
-
throw new Error(`Failed to check subscription status: ${error.message}
|
|
274
|
+
throw new Error(`Failed to check subscription status: ${error.message}`, { cause: error });
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
/**
|
|
@@ -282,7 +282,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
282
282
|
const usage = await this.getUsage(subscriptionId);
|
|
283
283
|
return usage.limits || {};
|
|
284
284
|
} catch (error) {
|
|
285
|
-
throw new Error(`Failed to get subscription limits: ${error.message}
|
|
285
|
+
throw new Error(`Failed to get subscription limits: ${error.message}`, { cause: error });
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
/**
|
|
@@ -318,7 +318,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
318
318
|
}
|
|
319
319
|
throw new Error(response.message);
|
|
320
320
|
} catch (error) {
|
|
321
|
-
throw new Error(`Failed to change subscription: ${error.message}
|
|
321
|
+
throw new Error(`Failed to change subscription: ${error.message}`, { cause: error });
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
/**
|
|
@@ -346,7 +346,7 @@ class SubscriptionService extends import_BaseService.BaseService {
|
|
|
346
346
|
}
|
|
347
347
|
throw new Error(response.message);
|
|
348
348
|
} catch (error) {
|
|
349
|
-
throw new Error(`Failed to downgrade subscription: ${error.message}
|
|
349
|
+
throw new Error(`Failed to downgrade subscription: ${error.message}`, { cause: error });
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
@@ -28,6 +28,7 @@ __export(services_exports, {
|
|
|
28
28
|
PlanService: () => import_PlanService.PlanService,
|
|
29
29
|
ProjectService: () => import_ProjectService.ProjectService,
|
|
30
30
|
PullRequestService: () => import_PullRequestService.PullRequestService,
|
|
31
|
+
ScreenshotService: () => import_ScreenshotService.ScreenshotService,
|
|
31
32
|
SubscriptionService: () => import_SubscriptionService.SubscriptionService,
|
|
32
33
|
createAdminService: () => createAdminService,
|
|
33
34
|
createAuthService: () => createAuthService,
|
|
@@ -40,6 +41,7 @@ __export(services_exports, {
|
|
|
40
41
|
createPlanService: () => createPlanService,
|
|
41
42
|
createProjectService: () => createProjectService,
|
|
42
43
|
createPullRequestService: () => createPullRequestService,
|
|
44
|
+
createScreenshotService: () => createScreenshotService,
|
|
43
45
|
createSubscriptionService: () => createSubscriptionService
|
|
44
46
|
});
|
|
45
47
|
module.exports = __toCommonJS(services_exports);
|
|
@@ -55,6 +57,7 @@ var import_DnsService = require("./DnsService.js");
|
|
|
55
57
|
var import_BranchService = require("./BranchService.js");
|
|
56
58
|
var import_PullRequestService = require("./PullRequestService.js");
|
|
57
59
|
var import_AdminService = require("./AdminService.js");
|
|
60
|
+
var import_ScreenshotService = require("./ScreenshotService.js");
|
|
58
61
|
const createService = (ServiceClass, config) => new ServiceClass(config);
|
|
59
62
|
const createAuthService = (config) => createService(import_AuthService.AuthService, config);
|
|
60
63
|
const createCoreService = (config) => createService(import_CoreService.CoreService, config);
|
|
@@ -68,3 +71,4 @@ const createDnsService = (config) => createService(import_DnsService.DnsService,
|
|
|
68
71
|
const createBranchService = (config) => createService(import_BranchService.BranchService, config);
|
|
69
72
|
const createPullRequestService = (config) => createService(import_PullRequestService.PullRequestService, config);
|
|
70
73
|
const createAdminService = (config) => createService(import_AdminService.AdminService, config);
|
|
74
|
+
const createScreenshotService = (config) => createService(import_ScreenshotService.ScreenshotService, config);
|
|
@@ -26,7 +26,7 @@ class TokenManager {
|
|
|
26
26
|
constructor(options = {}) {
|
|
27
27
|
this.config = {
|
|
28
28
|
storagePrefix: "symbols_",
|
|
29
|
-
storageType: typeof window === "undefined" || process.env.NODE_ENV === "test" ? "memory" : "localStorage",
|
|
29
|
+
storageType: typeof window === "undefined" || process.env.NODE_ENV === "test" || process.env.NODE_ENV === "testing" ? "memory" : "localStorage",
|
|
30
30
|
// 'localStorage' | 'sessionStorage' | 'memory'
|
|
31
31
|
refreshBuffer: 60 * 1e3,
|
|
32
32
|
// Refresh 1 minute before expiry
|
|
@@ -66,15 +66,26 @@ class TokenManager {
|
|
|
66
66
|
if (typeof window === "undefined") {
|
|
67
67
|
return this._memoryStorage;
|
|
68
68
|
}
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const safeGetStorage = (provider) => {
|
|
70
|
+
try {
|
|
71
|
+
const storage = provider();
|
|
72
|
+
const testKey = `${this.config.storagePrefix}__tm_test__`;
|
|
73
|
+
storage.setItem(testKey, "1");
|
|
74
|
+
storage.removeItem(testKey);
|
|
75
|
+
return storage;
|
|
76
|
+
} catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const localStorageInstance = safeGetStorage(() => window.localStorage);
|
|
81
|
+
const sessionStorageInstance = safeGetStorage(() => window.sessionStorage);
|
|
71
82
|
switch (this.config.storageType) {
|
|
72
83
|
case "sessionStorage":
|
|
73
|
-
return
|
|
84
|
+
return sessionStorageInstance || this._memoryStorage;
|
|
74
85
|
case "memory":
|
|
75
86
|
return this._memoryStorage;
|
|
76
87
|
default:
|
|
77
|
-
return
|
|
88
|
+
return localStorageInstance || this._memoryStorage;
|
|
78
89
|
}
|
|
79
90
|
}
|
|
80
91
|
/**
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var changePreprocessor_exports = {};
|
|
19
|
+
__export(changePreprocessor_exports, {
|
|
20
|
+
preprocessChanges: () => preprocessChanges
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(changePreprocessor_exports);
|
|
23
|
+
var import_jsonDiff = require("./jsonDiff.js");
|
|
24
|
+
var import_ordering = require("./ordering.js");
|
|
25
|
+
function isPlainObject(val) {
|
|
26
|
+
return val && typeof val === "object" && !Array.isArray(val);
|
|
27
|
+
}
|
|
28
|
+
function getByPathSafe(root, path) {
|
|
29
|
+
if (!root || typeof root.getByPath !== "function") {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
return root.getByPath(path);
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function preprocessChanges(root, tuples = [], options = {}) {
|
|
39
|
+
const expandTuple = (t) => {
|
|
40
|
+
const [action, path, value] = t || [];
|
|
41
|
+
const isSchemaPath = Array.isArray(path) && path[0] === "schema";
|
|
42
|
+
if (action === "delete") {
|
|
43
|
+
return [t];
|
|
44
|
+
}
|
|
45
|
+
const canConsiderExpansion = action === "update" && Array.isArray(path) && (path.length === 1 || path.length === 2 || isSchemaPath && path.length === 3) && isPlainObject(value);
|
|
46
|
+
if (!canConsiderExpansion) {
|
|
47
|
+
return [t];
|
|
48
|
+
}
|
|
49
|
+
const prev = getByPathSafe(root, path) || {};
|
|
50
|
+
const next = value || {};
|
|
51
|
+
if (!isPlainObject(prev) || !isPlainObject(next)) {
|
|
52
|
+
return [t];
|
|
53
|
+
}
|
|
54
|
+
const ops = (0, import_jsonDiff.diffJson)(prev, next, []);
|
|
55
|
+
if (!ops.length) {
|
|
56
|
+
return [t];
|
|
57
|
+
}
|
|
58
|
+
const out = [];
|
|
59
|
+
for (let i = 0; i < ops.length; i++) {
|
|
60
|
+
const op = ops[i];
|
|
61
|
+
const fullPath = [...path, ...op.path];
|
|
62
|
+
const last = fullPath[fullPath.length - 1];
|
|
63
|
+
if (op.action === "set") {
|
|
64
|
+
out.push(["update", fullPath, op.value]);
|
|
65
|
+
} else if (op.action === "del") {
|
|
66
|
+
if (last !== "__order") {
|
|
67
|
+
out.push(["delete", fullPath]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
};
|
|
73
|
+
const minimizeTuples = (input) => {
|
|
74
|
+
const out = [];
|
|
75
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
76
|
+
for (let i = 0; i < input.length; i++) {
|
|
77
|
+
const expanded = expandTuple(input[i]);
|
|
78
|
+
for (let k = 0; k < expanded.length; k++) {
|
|
79
|
+
const tuple = expanded[k];
|
|
80
|
+
const isDelete = Array.isArray(tuple) && tuple[0] === "delete";
|
|
81
|
+
const isOrderKey = isDelete && Array.isArray(tuple[1]) && tuple[1][tuple[1].length - 1] === "__order";
|
|
82
|
+
if (!isOrderKey) {
|
|
83
|
+
const key = JSON.stringify(tuple);
|
|
84
|
+
if (!seen2.has(key)) {
|
|
85
|
+
seen2.add(key);
|
|
86
|
+
out.push(tuple);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
};
|
|
93
|
+
const granularChanges = (() => {
|
|
94
|
+
try {
|
|
95
|
+
const res = minimizeTuples(tuples);
|
|
96
|
+
if (options.append && options.append.length) {
|
|
97
|
+
res.push(...options.append);
|
|
98
|
+
}
|
|
99
|
+
return res;
|
|
100
|
+
} catch {
|
|
101
|
+
return Array.isArray(tuples) ? tuples.slice() : [];
|
|
102
|
+
}
|
|
103
|
+
})();
|
|
104
|
+
const baseOrders = (0, import_ordering.computeOrdersForTuples)(root, granularChanges);
|
|
105
|
+
const preferOrdersMap = /* @__PURE__ */ new Map();
|
|
106
|
+
for (let i = 0; i < tuples.length; i++) {
|
|
107
|
+
const t = tuples[i];
|
|
108
|
+
if (!Array.isArray(t) || t.length < 3) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const [action, path, value] = t;
|
|
112
|
+
if (action !== "update" || !Array.isArray(path) || path.length !== 1 && path.length !== 2 || !isPlainObject(value)) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const keys = Object.keys(value).filter((k) => k !== "__order");
|
|
116
|
+
const key = JSON.stringify(path);
|
|
117
|
+
preferOrdersMap.set(key, { path, keys });
|
|
118
|
+
}
|
|
119
|
+
const mergedOrders = [];
|
|
120
|
+
const seen = /* @__PURE__ */ new Set();
|
|
121
|
+
preferOrdersMap.forEach((v, k) => {
|
|
122
|
+
seen.add(k);
|
|
123
|
+
mergedOrders.push(v);
|
|
124
|
+
});
|
|
125
|
+
for (let i = 0; i < baseOrders.length; i++) {
|
|
126
|
+
const v = baseOrders[i];
|
|
127
|
+
const k = JSON.stringify(v.path);
|
|
128
|
+
if (!seen.has(k)) {
|
|
129
|
+
seen.add(k);
|
|
130
|
+
mergedOrders.push(v);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return { granularChanges, orders: mergedOrders };
|
|
134
|
+
}
|
|
@@ -36,12 +36,54 @@ function isPlainObject(o) {
|
|
|
36
36
|
return o && typeof o === "object" && !Array.isArray(o);
|
|
37
37
|
}
|
|
38
38
|
function deepEqual(a, b) {
|
|
39
|
-
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
39
|
+
if (Object.is(a, b)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (typeof a === "function" && typeof b === "function") {
|
|
43
|
+
try {
|
|
44
|
+
return a.toString() === b.toString();
|
|
45
|
+
} catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (typeof a === "function" || typeof b === "function") {
|
|
43
50
|
return false;
|
|
44
51
|
}
|
|
52
|
+
if (a instanceof Date && b instanceof Date) {
|
|
53
|
+
return a.getTime() === b.getTime();
|
|
54
|
+
}
|
|
55
|
+
if (a instanceof RegExp && b instanceof RegExp) {
|
|
56
|
+
return String(a) === String(b);
|
|
57
|
+
}
|
|
58
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
59
|
+
if (a.length !== b.length) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
for (let i = 0; i < a.length; i++) {
|
|
63
|
+
if (!deepEqual(a[i], b[i])) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
70
|
+
const aKeys = Object.keys(a);
|
|
71
|
+
const bKeys = Object.keys(b);
|
|
72
|
+
if (aKeys.length !== bKeys.length) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
for (let i = 0; i < aKeys.length; i++) {
|
|
76
|
+
const key = aKeys[i];
|
|
77
|
+
if (!Object.hasOwn(b, key)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (!deepEqual(a[key], b[key])) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
45
87
|
}
|
|
46
88
|
function getRootMap(ydoc) {
|
|
47
89
|
return ydoc.getMap("root");
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var ordering_exports = {};
|
|
19
|
+
__export(ordering_exports, {
|
|
20
|
+
computeOrdersForTuples: () => computeOrdersForTuples,
|
|
21
|
+
computeOrdersFromState: () => computeOrdersFromState,
|
|
22
|
+
getParentPathsFromTuples: () => getParentPathsFromTuples
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ordering_exports);
|
|
25
|
+
function isObjectLike(val) {
|
|
26
|
+
return val && typeof val === "object" && !Array.isArray(val);
|
|
27
|
+
}
|
|
28
|
+
function normalizePath(path) {
|
|
29
|
+
if (Array.isArray(path)) {
|
|
30
|
+
return path;
|
|
31
|
+
}
|
|
32
|
+
if (typeof path === "string") {
|
|
33
|
+
return [path];
|
|
34
|
+
}
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
function getParentPathsFromTuples(tuples = []) {
|
|
38
|
+
const seen = /* @__PURE__ */ new Set();
|
|
39
|
+
const parents = [];
|
|
40
|
+
const META_KEYS = /* @__PURE__ */ new Set([
|
|
41
|
+
"style",
|
|
42
|
+
"class",
|
|
43
|
+
"text",
|
|
44
|
+
"html",
|
|
45
|
+
"content",
|
|
46
|
+
"data",
|
|
47
|
+
"attr",
|
|
48
|
+
"state",
|
|
49
|
+
"scope",
|
|
50
|
+
"define",
|
|
51
|
+
"on",
|
|
52
|
+
"extend",
|
|
53
|
+
"extends",
|
|
54
|
+
"childExtend",
|
|
55
|
+
"childExtends",
|
|
56
|
+
"children",
|
|
57
|
+
"component",
|
|
58
|
+
"context",
|
|
59
|
+
"tag",
|
|
60
|
+
"key",
|
|
61
|
+
"__order",
|
|
62
|
+
"if"
|
|
63
|
+
]);
|
|
64
|
+
for (let i = 0; i < tuples.length; i++) {
|
|
65
|
+
const tuple = tuples[i];
|
|
66
|
+
if (!Array.isArray(tuple) || tuple.length < 2) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const path = normalizePath(tuple[1]);
|
|
70
|
+
if (!path.length) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (path[0] === "schema") {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const immediateParent = path.slice(0, -1);
|
|
77
|
+
if (immediateParent.length) {
|
|
78
|
+
const key = JSON.stringify(immediateParent);
|
|
79
|
+
if (!seen.has(key)) {
|
|
80
|
+
seen.add(key);
|
|
81
|
+
parents.push(immediateParent);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const last = path[path.length - 1];
|
|
85
|
+
if (META_KEYS.has(last) && path.length >= 2) {
|
|
86
|
+
const containerParent = path.slice(0, -2);
|
|
87
|
+
if (containerParent.length) {
|
|
88
|
+
const key2 = JSON.stringify(containerParent);
|
|
89
|
+
if (!seen.has(key2)) {
|
|
90
|
+
seen.add(key2);
|
|
91
|
+
parents.push(containerParent);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
for (let j = 0; j < path.length; j++) {
|
|
96
|
+
const seg = path[j];
|
|
97
|
+
if (!META_KEYS.has(seg)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const containerParent2 = path.slice(0, j);
|
|
101
|
+
if (!containerParent2.length) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const key3 = JSON.stringify(containerParent2);
|
|
105
|
+
if (!seen.has(key3)) {
|
|
106
|
+
seen.add(key3);
|
|
107
|
+
parents.push(containerParent2);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return parents;
|
|
112
|
+
}
|
|
113
|
+
function computeOrdersFromState(root, parentPaths = []) {
|
|
114
|
+
if (!root || typeof root.getByPath !== "function") {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
const orders = [];
|
|
118
|
+
const EXCLUDE_KEYS = /* @__PURE__ */ new Set(["__order"]);
|
|
119
|
+
for (let i = 0; i < parentPaths.length; i++) {
|
|
120
|
+
const parentPath = parentPaths[i];
|
|
121
|
+
const obj = (() => {
|
|
122
|
+
try {
|
|
123
|
+
return root.getByPath(parentPath);
|
|
124
|
+
} catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
})();
|
|
128
|
+
if (!isObjectLike(obj)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const keys = Object.keys(obj).filter((k) => !EXCLUDE_KEYS.has(k));
|
|
132
|
+
orders.push({ path: parentPath, keys });
|
|
133
|
+
}
|
|
134
|
+
return orders;
|
|
135
|
+
}
|
|
136
|
+
function normaliseSchemaCode(code) {
|
|
137
|
+
if (typeof code !== "string" || !code.length) {
|
|
138
|
+
return "";
|
|
139
|
+
}
|
|
140
|
+
return code.replaceAll("/////n", "\n").replaceAll("/////tilde", "`");
|
|
141
|
+
}
|
|
142
|
+
function parseExportedObject(code) {
|
|
143
|
+
const src = normaliseSchemaCode(code);
|
|
144
|
+
if (!src) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const body = src.replace(/^\s*export\s+default\s*/u, "return ");
|
|
148
|
+
try {
|
|
149
|
+
return new Function(body)();
|
|
150
|
+
} catch {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function extractTopLevelKeysFromCode(code) {
|
|
155
|
+
const obj = parseExportedObject(code);
|
|
156
|
+
if (!obj || typeof obj !== "object") {
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
return Object.keys(obj);
|
|
160
|
+
}
|
|
161
|
+
function computeOrdersForTuples(root, tuples = []) {
|
|
162
|
+
const pendingChildrenByContainer = /* @__PURE__ */ new Map();
|
|
163
|
+
for (let i = 0; i < tuples.length; i++) {
|
|
164
|
+
const t = tuples[i];
|
|
165
|
+
if (!Array.isArray(t)) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const [action, path] = t;
|
|
169
|
+
const p = normalizePath(path);
|
|
170
|
+
if (!Array.isArray(p) || p.length < 3) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (p[0] === "schema") {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
const [typeName, containerKey, childKey] = p;
|
|
177
|
+
const containerPath = [typeName, containerKey];
|
|
178
|
+
const key = JSON.stringify(containerPath);
|
|
179
|
+
if (!pendingChildrenByContainer.has(key)) {
|
|
180
|
+
pendingChildrenByContainer.set(key, /* @__PURE__ */ new Set());
|
|
181
|
+
}
|
|
182
|
+
if (action === "update" || action === "set") {
|
|
183
|
+
pendingChildrenByContainer.get(key).add(childKey);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const preferredOrderMap = /* @__PURE__ */ new Map();
|
|
187
|
+
for (let i = 0; i < tuples.length; i++) {
|
|
188
|
+
const t = tuples[i];
|
|
189
|
+
if (!Array.isArray(t)) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const [action, path, value] = t;
|
|
193
|
+
const p = normalizePath(path);
|
|
194
|
+
if (action !== "update" || !Array.isArray(p) || p.length < 3) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (p[0] !== "schema") {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const [, type, key] = p;
|
|
201
|
+
const containerPath = [type, key];
|
|
202
|
+
const uses = value && Array.isArray(value.uses) ? value.uses : null;
|
|
203
|
+
const code = value && value.code;
|
|
204
|
+
const obj = (() => {
|
|
205
|
+
try {
|
|
206
|
+
return root && typeof root.getByPath === "function" ? root.getByPath(containerPath) : null;
|
|
207
|
+
} catch {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
})();
|
|
211
|
+
if (!obj) {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
const present = new Set(Object.keys(obj));
|
|
215
|
+
const EXCLUDE_KEYS = /* @__PURE__ */ new Set(["__order"]);
|
|
216
|
+
const codeKeys = extractTopLevelKeysFromCode(code);
|
|
217
|
+
let resolved = [];
|
|
218
|
+
const pendingKey = JSON.stringify(containerPath);
|
|
219
|
+
const pendingChildren = pendingChildrenByContainer.get(pendingKey) || /* @__PURE__ */ new Set();
|
|
220
|
+
const eligible = /* @__PURE__ */ new Set([...present, ...pendingChildren]);
|
|
221
|
+
if (Array.isArray(codeKeys) && codeKeys.length) {
|
|
222
|
+
resolved = codeKeys.filter((k) => eligible.has(k) && !EXCLUDE_KEYS.has(k));
|
|
223
|
+
}
|
|
224
|
+
if (Array.isArray(uses) && uses.length) {
|
|
225
|
+
for (let u = 0; u < uses.length; u++) {
|
|
226
|
+
const keyName = uses[u];
|
|
227
|
+
if (eligible.has(keyName) && !EXCLUDE_KEYS.has(keyName) && !resolved.includes(keyName)) {
|
|
228
|
+
resolved.push(keyName);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (pendingChildren.size) {
|
|
233
|
+
for (const child of pendingChildren) {
|
|
234
|
+
if (!EXCLUDE_KEYS.has(child) && !resolved.includes(child)) {
|
|
235
|
+
resolved.push(child);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (resolved.length) {
|
|
240
|
+
preferredOrderMap.set(JSON.stringify(containerPath), { path: containerPath, keys: resolved });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const parents = getParentPathsFromTuples(tuples);
|
|
244
|
+
const orders = [];
|
|
245
|
+
const seen = /* @__PURE__ */ new Set();
|
|
246
|
+
preferredOrderMap.forEach((v) => {
|
|
247
|
+
const k = JSON.stringify(v.path);
|
|
248
|
+
if (!seen.has(k)) {
|
|
249
|
+
seen.add(k);
|
|
250
|
+
orders.push(v);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
const fallbackOrders = computeOrdersFromState(root, parents);
|
|
254
|
+
for (let i = 0; i < fallbackOrders.length; i++) {
|
|
255
|
+
const v = fallbackOrders[i];
|
|
256
|
+
const k = JSON.stringify(v.path);
|
|
257
|
+
if (seen.has(k)) {
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const pending = pendingChildrenByContainer.get(k);
|
|
261
|
+
if (pending && pending.size) {
|
|
262
|
+
const existing = new Set(v.keys);
|
|
263
|
+
for (const child of pending) {
|
|
264
|
+
if (existing.has(child)) {
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
v.keys.push(child);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
seen.add(k);
|
|
271
|
+
orders.push(v);
|
|
272
|
+
}
|
|
273
|
+
return orders;
|
|
274
|
+
}
|
|
@@ -245,5 +245,18 @@ const SERVICE_METHODS = {
|
|
|
245
245
|
promoteToAdmin: "admin",
|
|
246
246
|
demoteFromAdmin: "admin",
|
|
247
247
|
// Utility methods
|
|
248
|
-
getHealthStatus: "core"
|
|
248
|
+
getHealthStatus: "core",
|
|
249
|
+
// Screenshot methods
|
|
250
|
+
createScreenshotProject: "screenshot",
|
|
251
|
+
getProjectScreenshots: "screenshot",
|
|
252
|
+
reprocessProjectScreenshots: "screenshot",
|
|
253
|
+
recreateProjectScreenshots: "screenshot",
|
|
254
|
+
deleteProjectScreenshots: "screenshot",
|
|
255
|
+
getThumbnailCandidate: "screenshot",
|
|
256
|
+
updateProjectThumbnail: "screenshot",
|
|
257
|
+
getPageScreenshot: "screenshot",
|
|
258
|
+
getComponentScreenshot: "screenshot",
|
|
259
|
+
getScreenshotByKey: "screenshot",
|
|
260
|
+
getQueueStatistics: "screenshot",
|
|
261
|
+
refreshThumbnail: "screenshot"
|
|
249
262
|
};
|