over-zero 0.0.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/cjs/build/readPermissions.cjs +51 -0
- package/dist/cjs/build/readPermissions.js +48 -0
- package/dist/cjs/build/readPermissions.js.map +6 -0
- package/dist/cjs/build/readPermissions.native.js +56 -0
- package/dist/cjs/build/readPermissions.native.js.map +6 -0
- package/dist/cjs/build/schema.cjs +28 -0
- package/dist/cjs/build/schema.js +22 -0
- package/dist/cjs/build/schema.js.map +6 -0
- package/dist/cjs/build/schema.native.js +28 -0
- package/dist/cjs/build/schema.native.js.map +6 -0
- package/dist/cjs/createClient.cjs +89 -0
- package/dist/cjs/createClient.js +76 -0
- package/dist/cjs/createClient.js.map +6 -0
- package/dist/cjs/createClient.native.js +81 -0
- package/dist/cjs/createClient.native.js.map +6 -0
- package/dist/cjs/createMutations.cjs +50 -0
- package/dist/cjs/createMutations.js +43 -0
- package/dist/cjs/createMutations.js.map +6 -0
- package/dist/cjs/createMutations.native.js +50 -0
- package/dist/cjs/createMutations.native.js.map +6 -0
- package/dist/cjs/createPermissions.cjs +128 -0
- package/dist/cjs/createPermissions.js +121 -0
- package/dist/cjs/createPermissions.js.map +6 -0
- package/dist/cjs/createPermissions.native.js +135 -0
- package/dist/cjs/createPermissions.native.js.map +6 -0
- package/dist/cjs/createServer.cjs +92 -0
- package/dist/cjs/createServer.js +71 -0
- package/dist/cjs/createServer.js.map +6 -0
- package/dist/cjs/createServer.native.js +75 -0
- package/dist/cjs/createServer.native.js.map +6 -0
- package/dist/cjs/helpers/batchQuery.cjs +49 -0
- package/dist/cjs/helpers/batchQuery.js +38 -0
- package/dist/cjs/helpers/batchQuery.js.map +6 -0
- package/dist/cjs/helpers/batchQuery.native.js +42 -0
- package/dist/cjs/helpers/batchQuery.native.js.map +6 -0
- package/dist/cjs/helpers/clearZeroDatabase.cjs +57 -0
- package/dist/cjs/helpers/clearZeroDatabase.js +57 -0
- package/dist/cjs/helpers/clearZeroDatabase.js.map +6 -0
- package/dist/cjs/helpers/clearZeroDatabase.native.js +71 -0
- package/dist/cjs/helpers/clearZeroDatabase.native.js.map +6 -0
- package/dist/cjs/helpers/context.cjs +40 -0
- package/dist/cjs/helpers/context.js +36 -0
- package/dist/cjs/helpers/context.js.map +6 -0
- package/dist/cjs/helpers/context.native.js +42 -0
- package/dist/cjs/helpers/context.native.js.map +6 -0
- package/dist/cjs/helpers/createMutators.cjs +87 -0
- package/dist/cjs/helpers/createMutators.js +81 -0
- package/dist/cjs/helpers/createMutators.js.map +6 -0
- package/dist/cjs/helpers/createMutators.native.js +116 -0
- package/dist/cjs/helpers/createMutators.native.js.map +6 -0
- package/dist/cjs/helpers/ensureLoggedIn.cjs +33 -0
- package/dist/cjs/helpers/ensureLoggedIn.js +25 -0
- package/dist/cjs/helpers/ensureLoggedIn.js.map +6 -0
- package/dist/cjs/helpers/ensureLoggedIn.native.js +29 -0
- package/dist/cjs/helpers/ensureLoggedIn.native.js.map +6 -0
- package/dist/cjs/helpers/getAuthData.cjs +36 -0
- package/dist/cjs/helpers/getAuthData.js +29 -0
- package/dist/cjs/helpers/getAuthData.js.map +6 -0
- package/dist/cjs/helpers/getAuthData.native.js +33 -0
- package/dist/cjs/helpers/getAuthData.native.js.map +6 -0
- package/dist/cjs/helpers/prettyFormatZeroQuery.cjs +107 -0
- package/dist/cjs/helpers/prettyFormatZeroQuery.js +92 -0
- package/dist/cjs/helpers/prettyFormatZeroQuery.js.map +6 -0
- package/dist/cjs/helpers/prettyFormatZeroQuery.native.js +99 -0
- package/dist/cjs/helpers/prettyFormatZeroQuery.native.js.map +6 -0
- package/dist/cjs/helpers/setupZeroClientGlobalEffects.cjs +40 -0
- package/dist/cjs/helpers/setupZeroClientGlobalEffects.js +36 -0
- package/dist/cjs/helpers/setupZeroClientGlobalEffects.js.map +6 -0
- package/dist/cjs/helpers/setupZeroClientGlobalEffects.native.js +36 -0
- package/dist/cjs/helpers/setupZeroClientGlobalEffects.native.js.map +6 -0
- package/dist/cjs/helpers/useAuthData.cjs +32 -0
- package/dist/cjs/helpers/useAuthData.js +25 -0
- package/dist/cjs/helpers/useAuthData.js.map +6 -0
- package/dist/cjs/helpers/useAuthData.native.js +33 -0
- package/dist/cjs/helpers/useAuthData.native.js.map +6 -0
- package/dist/cjs/helpers/useZDB.cjs +70 -0
- package/dist/cjs/helpers/useZDB.js +51 -0
- package/dist/cjs/helpers/useZDB.js.map +6 -0
- package/dist/cjs/helpers/useZDB.native.js +68 -0
- package/dist/cjs/helpers/useZDB.native.js.map +6 -0
- package/dist/cjs/helpers/zeroEmitter.cjs +27 -0
- package/dist/cjs/helpers/zeroEmitter.js +22 -0
- package/dist/cjs/helpers/zeroEmitter.js.map +6 -0
- package/dist/cjs/helpers/zeroEmitter.native.js +26 -0
- package/dist/cjs/helpers/zeroEmitter.native.js.map +6 -0
- package/dist/cjs/index.cjs +23 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/index.native.js +30 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/cjs/types.cjs +16 -0
- package/dist/cjs/types.js +14 -0
- package/dist/cjs/types.js.map +6 -0
- package/dist/cjs/types.native.js +15 -0
- package/dist/cjs/types.native.js.map +6 -0
- package/dist/esm/build/readPermissions.js +36 -0
- package/dist/esm/build/readPermissions.js.map +6 -0
- package/dist/esm/build/readPermissions.mjs +28 -0
- package/dist/esm/build/readPermissions.mjs.map +1 -0
- package/dist/esm/build/readPermissions.native.js +34 -0
- package/dist/esm/build/readPermissions.native.js.map +1 -0
- package/dist/esm/build/schema.js +7 -0
- package/dist/esm/build/schema.js.map +6 -0
- package/dist/esm/build/schema.mjs +4 -0
- package/dist/esm/build/schema.mjs.map +1 -0
- package/dist/esm/build/schema.native.js +4 -0
- package/dist/esm/build/schema.native.js.map +1 -0
- package/dist/esm/createClient.js +68 -0
- package/dist/esm/createClient.js.map +6 -0
- package/dist/esm/createClient.mjs +66 -0
- package/dist/esm/createClient.mjs.map +1 -0
- package/dist/esm/createClient.native.js +74 -0
- package/dist/esm/createClient.native.js.map +1 -0
- package/dist/esm/createMutations.js +27 -0
- package/dist/esm/createMutations.js.map +6 -0
- package/dist/esm/createMutations.mjs +27 -0
- package/dist/esm/createMutations.mjs.map +1 -0
- package/dist/esm/createMutations.native.js +29 -0
- package/dist/esm/createMutations.native.js.map +1 -0
- package/dist/esm/createPermissions.js +106 -0
- package/dist/esm/createPermissions.js.map +6 -0
- package/dist/esm/createPermissions.mjs +105 -0
- package/dist/esm/createPermissions.mjs.map +1 -0
- package/dist/esm/createPermissions.native.js +129 -0
- package/dist/esm/createPermissions.native.js.map +1 -0
- package/dist/esm/createServer.js +54 -0
- package/dist/esm/createServer.js.map +6 -0
- package/dist/esm/createServer.mjs +58 -0
- package/dist/esm/createServer.mjs.map +1 -0
- package/dist/esm/createServer.native.js +61 -0
- package/dist/esm/createServer.native.js.map +1 -0
- package/dist/esm/helpers/batchQuery.js +22 -0
- package/dist/esm/helpers/batchQuery.js.map +6 -0
- package/dist/esm/helpers/batchQuery.mjs +26 -0
- package/dist/esm/helpers/batchQuery.mjs.map +1 -0
- package/dist/esm/helpers/batchQuery.native.js +23 -0
- package/dist/esm/helpers/batchQuery.native.js.map +1 -0
- package/dist/esm/helpers/clearZeroDatabase.js +42 -0
- package/dist/esm/helpers/clearZeroDatabase.js.map +6 -0
- package/dist/esm/helpers/clearZeroDatabase.mjs +34 -0
- package/dist/esm/helpers/clearZeroDatabase.mjs.map +1 -0
- package/dist/esm/helpers/clearZeroDatabase.native.js +50 -0
- package/dist/esm/helpers/clearZeroDatabase.native.js.map +1 -0
- package/dist/esm/helpers/context.js +20 -0
- package/dist/esm/helpers/context.js.map +6 -0
- package/dist/esm/helpers/context.mjs +15 -0
- package/dist/esm/helpers/context.mjs.map +1 -0
- package/dist/esm/helpers/context.native.js +15 -0
- package/dist/esm/helpers/context.native.js.map +1 -0
- package/dist/esm/helpers/createMutators.js +69 -0
- package/dist/esm/helpers/createMutators.js.map +6 -0
- package/dist/esm/helpers/createMutators.mjs +64 -0
- package/dist/esm/helpers/createMutators.mjs.map +1 -0
- package/dist/esm/helpers/createMutators.native.js +101 -0
- package/dist/esm/helpers/createMutators.native.js.map +1 -0
- package/dist/esm/helpers/ensureLoggedIn.js +10 -0
- package/dist/esm/helpers/ensureLoggedIn.js.map +6 -0
- package/dist/esm/helpers/ensureLoggedIn.mjs +10 -0
- package/dist/esm/helpers/ensureLoggedIn.mjs.map +1 -0
- package/dist/esm/helpers/ensureLoggedIn.native.js +10 -0
- package/dist/esm/helpers/ensureLoggedIn.native.js.map +1 -0
- package/dist/esm/helpers/getAuthData.js +13 -0
- package/dist/esm/helpers/getAuthData.js.map +6 -0
- package/dist/esm/helpers/getAuthData.mjs +13 -0
- package/dist/esm/helpers/getAuthData.mjs.map +1 -0
- package/dist/esm/helpers/getAuthData.native.js +13 -0
- package/dist/esm/helpers/getAuthData.native.js.map +1 -0
- package/dist/esm/helpers/prettyFormatZeroQuery.js +76 -0
- package/dist/esm/helpers/prettyFormatZeroQuery.js.map +6 -0
- package/dist/esm/helpers/prettyFormatZeroQuery.mjs +84 -0
- package/dist/esm/helpers/prettyFormatZeroQuery.mjs.map +1 -0
- package/dist/esm/helpers/prettyFormatZeroQuery.native.js +93 -0
- package/dist/esm/helpers/prettyFormatZeroQuery.native.js.map +1 -0
- package/dist/esm/helpers/setupZeroClientGlobalEffects.js +40 -0
- package/dist/esm/helpers/setupZeroClientGlobalEffects.js.map +6 -0
- package/dist/esm/helpers/setupZeroClientGlobalEffects.mjs +41 -0
- package/dist/esm/helpers/setupZeroClientGlobalEffects.mjs.map +1 -0
- package/dist/esm/helpers/setupZeroClientGlobalEffects.native.js +41 -0
- package/dist/esm/helpers/setupZeroClientGlobalEffects.native.js.map +1 -0
- package/dist/esm/helpers/useAuthData.js +11 -0
- package/dist/esm/helpers/useAuthData.js.map +6 -0
- package/dist/esm/helpers/useAuthData.mjs +9 -0
- package/dist/esm/helpers/useAuthData.mjs.map +1 -0
- package/dist/esm/helpers/useAuthData.native.js +13 -0
- package/dist/esm/helpers/useAuthData.native.js.map +1 -0
- package/dist/esm/helpers/useZDB.js +38 -0
- package/dist/esm/helpers/useZDB.js.map +6 -0
- package/dist/esm/helpers/useZDB.mjs +47 -0
- package/dist/esm/helpers/useZDB.mjs.map +1 -0
- package/dist/esm/helpers/useZDB.native.js +55 -0
- package/dist/esm/helpers/useZDB.native.js.map +1 -0
- package/dist/esm/helpers/zeroEmitter.js +6 -0
- package/dist/esm/helpers/zeroEmitter.js.map +6 -0
- package/dist/esm/helpers/zeroEmitter.mjs +4 -0
- package/dist/esm/helpers/zeroEmitter.mjs.map +1 -0
- package/dist/esm/helpers/zeroEmitter.native.js +4 -0
- package/dist/esm/helpers/zeroEmitter.native.js.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +6 -0
- package/dist/esm/index.mjs +7 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +7 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +6 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/package.json +51 -0
- package/readme.md +16 -0
- package/src/createPermissions.ts +281 -0
- package/src/createZeroClient.tsx +191 -0
- package/src/createZeroServer.ts +153 -0
- package/src/helpers/batchQuery.ts +45 -0
- package/src/helpers/clearZeroDatabase.ts +68 -0
- package/src/helpers/context.ts +28 -0
- package/src/helpers/createMutators.ts +139 -0
- package/src/helpers/ensureLoggedIn.ts +8 -0
- package/src/helpers/getAuthData.tsx +12 -0
- package/src/helpers/prettyFormatZeroQuery.ts +167 -0
- package/src/helpers/useAuthData.ts +13 -0
- package/src/helpers/useZeroDebug.ts +104 -0
- package/src/helpers/zeroEmitter.ts +5 -0
- package/src/index.ts +15 -0
- package/src/mutations.ts +121 -0
- package/src/types.ts +49 -0
- package/types/createMutations.d.ts +20 -0
- package/types/createMutations.d.ts.map +1 -0
- package/types/createPermissions.d.ts +37 -0
- package/types/createPermissions.d.ts.map +1 -0
- package/types/createZeroClient.d.ts +45 -0
- package/types/createZeroClient.d.ts.map +1 -0
- package/types/createZeroServer.d.ts +61 -0
- package/types/createZeroServer.d.ts.map +1 -0
- package/types/helpers/batchQuery.d.ts +7 -0
- package/types/helpers/batchQuery.d.ts.map +1 -0
- package/types/helpers/clearZeroDatabase.d.ts +2 -0
- package/types/helpers/clearZeroDatabase.d.ts.map +1 -0
- package/types/helpers/context.d.ts +5 -0
- package/types/helpers/context.d.ts.map +1 -0
- package/types/helpers/createMutators.d.ts +16 -0
- package/types/helpers/createMutators.d.ts.map +1 -0
- package/types/helpers/ensureLoggedIn.d.ts +2 -0
- package/types/helpers/ensureLoggedIn.d.ts.map +1 -0
- package/types/helpers/getAuthData.d.ts +1 -0
- package/types/helpers/getAuthData.d.ts.map +1 -0
- package/types/helpers/prettyFormatZeroQuery.d.ts +3 -0
- package/types/helpers/prettyFormatZeroQuery.d.ts.map +1 -0
- package/types/helpers/useAuthData.d.ts +1 -0
- package/types/helpers/useAuthData.d.ts.map +1 -0
- package/types/helpers/useZeroDebug.d.ts +3 -0
- package/types/helpers/useZeroDebug.d.ts.map +1 -0
- package/types/helpers/zeroEmitter.d.ts +2 -0
- package/types/helpers/zeroEmitter.d.ts.map +1 -0
- package/types/index.d.ts +9 -0
- package/types/index.d.ts.map +1 -0
- package/types/types.d.ts +21 -0
- package/types/types.d.ts.map +1 -0
|
@@ -0,0 +1,87 @@
|
|
|
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) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var createMutators_exports = {};
|
|
22
|
+
__export(createMutators_exports, {
|
|
23
|
+
createMutators: () => createMutators
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(createMutators_exports);
|
|
26
|
+
var import_platform = require("~/constants/platform"),
|
|
27
|
+
import_helpers = require("@vxrn/helpers"),
|
|
28
|
+
import_context = require("../context"),
|
|
29
|
+
import_models = require("../models"),
|
|
30
|
+
import_can = require("./can");
|
|
31
|
+
function createMutators({
|
|
32
|
+
environment,
|
|
33
|
+
authData,
|
|
34
|
+
createServerActions,
|
|
35
|
+
asyncTasks = []
|
|
36
|
+
}) {
|
|
37
|
+
const serverActions = createServerActions?.(authData);
|
|
38
|
+
function withContext(fn) {
|
|
39
|
+
return async (tx, ...args) => {
|
|
40
|
+
const mutationContext = {
|
|
41
|
+
tx,
|
|
42
|
+
authData,
|
|
43
|
+
environment,
|
|
44
|
+
can: import_can.can,
|
|
45
|
+
serverActions,
|
|
46
|
+
asyncTasks
|
|
47
|
+
};
|
|
48
|
+
return await (0, import_context.runWithContext)(mutationContext, () => fn(mutationContext, ...args));
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function withDevelopmentLogging(name, fn) {
|
|
52
|
+
return process.env.NODE_ENV !== "development" && !process.env.IS_TESTING ? fn : async (...args) => {
|
|
53
|
+
const startTime = performance.now();
|
|
54
|
+
try {
|
|
55
|
+
import_platform.isServer && console.info(`[mutator] ${name} start`);
|
|
56
|
+
const result = await fn(...args),
|
|
57
|
+
duration = (performance.now() - startTime).toFixed(2);
|
|
58
|
+
return import_platform.isClient ? (console.groupCollapsed(`[mutator] ${name} completed in ${duration}ms`), console.info("\u2192", args[1]), console.info("\u2190", result), console.trace(), console.groupEnd()) : console.info(`[mutator] ${name} completed in ${duration}ms`), result;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
const duration = (performance.now() - startTime).toFixed(2);
|
|
61
|
+
throw console.groupCollapsed(`[mutator] ${name} failed after ${duration}ms`), console.error("error:", error), console.info("arguments:", JSON.stringify(args[1], null, 2)), console.info("stack trace:", new Error().stack), console.groupEnd(), error;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function withTimeoutGuard(name, fn, timeoutMs = import_helpers.time.ms.minutes(1)) {
|
|
66
|
+
return async (...args) => {
|
|
67
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
reject(new Error(`[mutator] ${name} timeout after ${timeoutMs}ms`));
|
|
70
|
+
}, timeoutMs);
|
|
71
|
+
});
|
|
72
|
+
return Promise.race([fn(...args), timeoutPromise]);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function decorateMutators(modules) {
|
|
76
|
+
const result = {};
|
|
77
|
+
for (const [moduleName, moduleExports] of Object.entries(modules)) {
|
|
78
|
+
result[moduleName] = {};
|
|
79
|
+
for (const [name, exportValue] of Object.entries(moduleExports)) if (typeof exportValue == "function") {
|
|
80
|
+
const fullName = `${moduleName}.${name}`;
|
|
81
|
+
result[moduleName][name] = withDevelopmentLogging(fullName, withTimeoutGuard(fullName, withContext(exportValue)));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
return decorateMutators(import_models.modelMutators);
|
|
87
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var createMutators_exports = {};
|
|
16
|
+
__export(createMutators_exports, {
|
|
17
|
+
createMutators: () => createMutators
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(createMutators_exports);
|
|
20
|
+
var import_platform = require("~/constants/platform"), import_helpers = require("@vxrn/helpers"), import_context = require("../context"), import_models = require("../models"), import_can = require("./can");
|
|
21
|
+
function createMutators({
|
|
22
|
+
environment,
|
|
23
|
+
authData,
|
|
24
|
+
createServerActions,
|
|
25
|
+
asyncTasks = []
|
|
26
|
+
}) {
|
|
27
|
+
const serverActions = createServerActions?.(authData);
|
|
28
|
+
function withContext(fn) {
|
|
29
|
+
return async (tx, ...args) => {
|
|
30
|
+
const mutationContext = {
|
|
31
|
+
tx,
|
|
32
|
+
authData,
|
|
33
|
+
environment,
|
|
34
|
+
can: import_can.can,
|
|
35
|
+
serverActions,
|
|
36
|
+
asyncTasks
|
|
37
|
+
};
|
|
38
|
+
return await (0, import_context.runWithContext)(mutationContext, () => fn(mutationContext, ...args));
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function withDevelopmentLogging(name, fn) {
|
|
42
|
+
return process.env.NODE_ENV !== "development" && !process.env.IS_TESTING ? fn : async (...args) => {
|
|
43
|
+
const startTime = performance.now();
|
|
44
|
+
try {
|
|
45
|
+
import_platform.isServer && console.info(`[mutator] ${name} start`);
|
|
46
|
+
const result = await fn(...args), duration = (performance.now() - startTime).toFixed(2);
|
|
47
|
+
return import_platform.isClient ? (console.groupCollapsed(`[mutator] ${name} completed in ${duration}ms`), console.info("\u2192", args[1]), console.info("\u2190", result), console.trace(), console.groupEnd()) : console.info(`[mutator] ${name} completed in ${duration}ms`), result;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
const duration = (performance.now() - startTime).toFixed(2);
|
|
50
|
+
throw console.groupCollapsed(`[mutator] ${name} failed after ${duration}ms`), console.error("error:", error), console.info("arguments:", JSON.stringify(args[1], null, 2)), console.info("stack trace:", new Error().stack), console.groupEnd(), error;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function withTimeoutGuard(name, fn, timeoutMs = import_helpers.time.ms.minutes(1)) {
|
|
55
|
+
return async (...args) => {
|
|
56
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
reject(new Error(`[mutator] ${name} timeout after ${timeoutMs}ms`));
|
|
59
|
+
}, timeoutMs);
|
|
60
|
+
});
|
|
61
|
+
return Promise.race([fn(...args), timeoutPromise]);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function decorateMutators(modules) {
|
|
65
|
+
const result = {};
|
|
66
|
+
for (const [moduleName, moduleExports] of Object.entries(modules)) {
|
|
67
|
+
result[moduleName] = {};
|
|
68
|
+
for (const [name, exportValue] of Object.entries(moduleExports))
|
|
69
|
+
if (typeof exportValue == "function") {
|
|
70
|
+
const fullName = `${moduleName}.${name}`;
|
|
71
|
+
result[moduleName][name] = withDevelopmentLogging(
|
|
72
|
+
fullName,
|
|
73
|
+
withTimeoutGuard(fullName, withContext(exportValue))
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
return decorateMutators(import_models.modelMutators);
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=createMutators.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/createMutators.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAmC,iCACnC,iBAAqB,0BACrB,iBAAoD,uBACpD,gBAA8B,sBAG9B,aAAoB;AAqBb,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa,CAAC;AAChB,GAAiB;AACf,QAAM,gBAAgB,sBAAsB,QAAQ;AAEpD,WAAS,YAAgC,IAAsC;AAC7E,WAAO,OAAO,OAAW,SAA8B;AACrD,YAAM,kBAAkB;AAAA,QACtB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,aAAO,UAAM,+BAAe,iBAAiB,MAGpC,GAAG,iBAAiB,GAAG,IAAI,CACnC;AAAA,IACH;AAAA,EACF;AAEA,WAAS,uBACP,MACA,IACA;AACA,WAAI,QAAQ,IAAI,aAAa,iBAAiB,CAAC,QAAQ,IAAI,aAClD,KAGF,UAAU,SAA8B;AAC7C,YAAM,YAAY,YAAY,IAAI;AAElC,UAAI;AACF,QAAI,4BACF,QAAQ,KAAK,aAAa,IAAI,QAAQ;AAExC,cAAM,SAAS,MAAM,GAAG,GAAG,IAAI,GACzB,YAAY,YAAY,IAAI,IAAI,WAAW,QAAQ,CAAC;AAC1D,eAAI,4BACF,QAAQ,eAAe,aAAa,IAAI,iBAAiB,QAAQ,IAAI,GACrE,QAAQ,KAA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rD;AAAA,QACF;AAAA,IAEJ;AAEA,WAAO;AAAA,EACT;AAEA,SAAO,iBAAiB,2BAAa;AACvC;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var createMutators_exports = {};
|
|
17
|
+
__export(createMutators_exports, {
|
|
18
|
+
createMutators: () => createMutators
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(createMutators_exports);
|
|
21
|
+
var import_platform = require("~/constants/platform"), import_helpers = require("@vxrn/helpers"), import_context = require("../context"), import_models = require("../models"), import_can = require("./can");
|
|
22
|
+
function createMutators(param) {
|
|
23
|
+
var { environment, authData, createServerActions, asyncTasks = [] } = param, serverActions = createServerActions == null ? void 0 : createServerActions(authData);
|
|
24
|
+
function withContext(fn) {
|
|
25
|
+
return async function(tx) {
|
|
26
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)
|
|
27
|
+
args[_key - 1] = arguments[_key];
|
|
28
|
+
var mutationContext = {
|
|
29
|
+
tx,
|
|
30
|
+
authData,
|
|
31
|
+
environment,
|
|
32
|
+
can: import_can.can,
|
|
33
|
+
serverActions,
|
|
34
|
+
asyncTasks
|
|
35
|
+
};
|
|
36
|
+
return await (0, import_context.runWithContext)(mutationContext, function() {
|
|
37
|
+
return fn(mutationContext, ...args);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function withDevelopmentLogging(name, fn) {
|
|
42
|
+
return process.env.NODE_ENV !== "development" && !process.env.IS_TESTING ? fn : async function() {
|
|
43
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)
|
|
44
|
+
args[_key] = arguments[_key];
|
|
45
|
+
var startTime = performance.now();
|
|
46
|
+
try {
|
|
47
|
+
import_platform.isServer && console.info(`[mutator] ${name} start`);
|
|
48
|
+
var result = await fn(...args), duration = (performance.now() - startTime).toFixed(2);
|
|
49
|
+
return import_platform.isClient ? (console.groupCollapsed(`[mutator] ${name} completed in ${duration}ms`), console.info("\u2192", args[1]), console.info("\u2190", result), console.trace(), console.groupEnd()) : console.info(`[mutator] ${name} completed in ${duration}ms`), result;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
var duration1 = (performance.now() - startTime).toFixed(2);
|
|
52
|
+
throw console.groupCollapsed(`[mutator] ${name} failed after ${duration1}ms`), console.error("error:", error), console.info("arguments:", JSON.stringify(args[1], null, 2)), console.info("stack trace:", new Error().stack), console.groupEnd(), error;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function withTimeoutGuard(name, fn) {
|
|
57
|
+
var timeoutMs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : import_helpers.time.ms.minutes(1);
|
|
58
|
+
return async function() {
|
|
59
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)
|
|
60
|
+
args[_key] = arguments[_key];
|
|
61
|
+
var timeoutPromise = new Promise(function(_, reject) {
|
|
62
|
+
setTimeout(function() {
|
|
63
|
+
reject(new Error(`[mutator] ${name} timeout after ${timeoutMs}ms`));
|
|
64
|
+
}, timeoutMs);
|
|
65
|
+
});
|
|
66
|
+
return Promise.race([
|
|
67
|
+
fn(...args),
|
|
68
|
+
timeoutPromise
|
|
69
|
+
]);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function decorateMutators(modules) {
|
|
73
|
+
var result = {}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
74
|
+
try {
|
|
75
|
+
for (var _iterator = Object.entries(modules)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
76
|
+
var [moduleName, moduleExports] = _step.value;
|
|
77
|
+
result[moduleName] = {};
|
|
78
|
+
var _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0;
|
|
79
|
+
try {
|
|
80
|
+
for (var _iterator1 = Object.entries(moduleExports)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
|
|
81
|
+
var [name, exportValue] = _step1.value;
|
|
82
|
+
if (typeof exportValue == "function") {
|
|
83
|
+
var fullName = `${moduleName}.${name}`;
|
|
84
|
+
result[moduleName][name] = withDevelopmentLogging(fullName, withTimeoutGuard(fullName, withContext(exportValue)));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
} catch (err) {
|
|
88
|
+
_didIteratorError1 = !0, _iteratorError1 = err;
|
|
89
|
+
} finally {
|
|
90
|
+
try {
|
|
91
|
+
!_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
|
|
92
|
+
} finally {
|
|
93
|
+
if (_didIteratorError1)
|
|
94
|
+
throw _iteratorError1;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} catch (err) {
|
|
99
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
100
|
+
} finally {
|
|
101
|
+
try {
|
|
102
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
103
|
+
} finally {
|
|
104
|
+
if (_didIteratorError)
|
|
105
|
+
throw _iteratorError;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
return decorateMutators(import_models.modelMutators);
|
|
111
|
+
}
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
createMutators
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=createMutators.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/createMutators.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAmC,iCACnC,iBAAqB,0BACrB,iBAA+B,uBAC/B,gBAA8B,sBAC9B,aAAoB;AACb,SAAS,eAAe,OAAO;AAClC,MAAI,EAAE,aAAa,UAAU,qBAAqB,aAAa,CAAC,EAAE,IAAI,OAClE,gBAAgB,uBAAwB,OAAyC,SAAS,oBAAoB,QAAQ;AAC1H,WAAS,YAAY,IAAI;AACrB,WAAO,eAAe,IAAI;AACtB,eAAQ,OAAO,UAAU,QAAQ,OAAO,IAAI,MAAM,OAAO,IAAI,OAAO,IAAI,CAAC,GAAG,OAAO,GAAG,OAAO,MAAM;AAC/F,aAAK,OAAO,CAAC,IAAI,UAAU,IAAI;AAEnC,UAAI,kBAAkB;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACJ;AACA,aAAO,UAAM,+BAAe,iBAAiB,WAAW;AAGpD,eAAO,GAAG,iBAAiB,GAAG,IAAI;AAAA,MACtC,CAAC;AAAA,IACL;AAAA,EACJ;AACA,WAAS,uBAAuB,MAAM,IAAI;AACtC,WAAI,QAAQ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A,QACJ;AAAA,MACJ;AAAA,IACJ,SAAS,KAAK;AACV,0BAAoB,IACpB,iBAAiB;AAAA,IACrB,UAAE;AACE,UAAI;AACA,QAAI,CAAC,6BAA6B,UAAU,UAAU,QAClD,UAAU,OAAO;AAAA,MAEzB,UAAE;AACE,YAAI;AACA,gBAAM;AAAA,MAEd;AAAA,IACJ;AACA,WAAO;AAAA,EACX;AACA,SAAO,iBAAiB,2BAAa;AACzC;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var ensureLoggedIn_exports = {};
|
|
22
|
+
__export(ensureLoggedIn_exports, {
|
|
23
|
+
ensureLoggedIn: () => ensureLoggedIn
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(ensureLoggedIn_exports);
|
|
26
|
+
var import_helpers = require("@vxrn/helpers"),
|
|
27
|
+
import_context = require("src/context");
|
|
28
|
+
const ensureLoggedIn = () => {
|
|
29
|
+
const {
|
|
30
|
+
authData
|
|
31
|
+
} = (0, import_context.context)();
|
|
32
|
+
return (0, import_helpers.ensure)(authData, "logged in"), authData;
|
|
33
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
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: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var ensureLoggedIn_exports = {};
|
|
16
|
+
__export(ensureLoggedIn_exports, {
|
|
17
|
+
ensureLoggedIn: () => ensureLoggedIn
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(ensureLoggedIn_exports);
|
|
20
|
+
var import_helpers = require("@vxrn/helpers"), import_context = require("src/context");
|
|
21
|
+
const ensureLoggedIn = () => {
|
|
22
|
+
const { authData } = (0, import_context.context)();
|
|
23
|
+
return (0, import_helpers.ensure)(authData, "logged in"), authData;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=ensureLoggedIn.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var ensureLoggedIn_exports = {};
|
|
17
|
+
__export(ensureLoggedIn_exports, {
|
|
18
|
+
ensureLoggedIn: () => ensureLoggedIn
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(ensureLoggedIn_exports);
|
|
21
|
+
var import_helpers = require("@vxrn/helpers"), import_context = require("src/context"), ensureLoggedIn = function() {
|
|
22
|
+
var { authData } = (0, import_context.context)();
|
|
23
|
+
return (0, import_helpers.ensure)(authData, "logged in"), authData;
|
|
24
|
+
};
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
ensureLoggedIn
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=ensureLoggedIn.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
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) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var getAuthData_exports = {};
|
|
22
|
+
__export(getAuthData_exports, {
|
|
23
|
+
getAuthData: () => getAuthData
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(getAuthData_exports);
|
|
26
|
+
var import_authClient = require("~/auth/client/authClient");
|
|
27
|
+
const getAuthData = () => {
|
|
28
|
+
const {
|
|
29
|
+
user
|
|
30
|
+
} = (0, import_authClient.getAuth)();
|
|
31
|
+
return user ? {
|
|
32
|
+
id: user.id || "anon",
|
|
33
|
+
email: user.email,
|
|
34
|
+
role: void 0
|
|
35
|
+
} : null;
|
|
36
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
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: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var getAuthData_exports = {};
|
|
16
|
+
__export(getAuthData_exports, {
|
|
17
|
+
getAuthData: () => getAuthData
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(getAuthData_exports);
|
|
20
|
+
var import_authClient = require("~/auth/client/authClient");
|
|
21
|
+
const getAuthData = () => {
|
|
22
|
+
const { user } = (0, import_authClient.getAuth)();
|
|
23
|
+
return user ? {
|
|
24
|
+
id: user.id || "anon",
|
|
25
|
+
email: user.email,
|
|
26
|
+
role: void 0
|
|
27
|
+
} : null;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=getAuthData.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/getAuthData.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAwB;AAEjB,MAAM,cAAc,MAAM;AAC/B,QAAM,EAAE,KAAK,QAAI,2BAAQ;AACzB,SAAO,OACH;AAAA,IACE,IAAI,KAAK,MAAM;AAAA,IACf,OAAO,KAAK;AAAA,IACZ,MAAM;AAAA,EACR,IACA;AACN;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var getAuthData_exports = {};
|
|
17
|
+
__export(getAuthData_exports, {
|
|
18
|
+
getAuthData: () => getAuthData
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(getAuthData_exports);
|
|
21
|
+
var import_authClient = require("~/auth/client/authClient"), getAuthData = function() {
|
|
22
|
+
var { user } = (0, import_authClient.getAuth)();
|
|
23
|
+
return user ? {
|
|
24
|
+
id: user.id || "anon",
|
|
25
|
+
email: user.email,
|
|
26
|
+
role: void 0
|
|
27
|
+
} : null;
|
|
28
|
+
};
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
getAuthData
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=getAuthData.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/getAuthData.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAwB,qCACb,cAAc,WAAW;AAChC,MAAI,EAAE,KAAK,QAAI,2BAAQ;AACvB,SAAO,OAAO;AAAA,IACV,IAAI,KAAK,MAAM;AAAA,IACf,OAAO,KAAK;AAAA,IACZ,MAAM;AAAA,EACV,IAAI;AACR;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
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) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var prettyFormatZeroQuery_exports = {};
|
|
22
|
+
__export(prettyFormatZeroQuery_exports, {
|
|
23
|
+
prettyFormatZeroQuery: () => prettyFormatZeroQuery
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(prettyFormatZeroQuery_exports);
|
|
26
|
+
var import_helpers = require("@vxrn/helpers");
|
|
27
|
+
const prettyFormatZeroQuery = (query, mode = "full") => {
|
|
28
|
+
const astObject = query._completeAst?.();
|
|
29
|
+
return astObject ? mode === "minimal" ? prettyFormatMinimal(astObject) : prettyFormatFull(astObject) : "";
|
|
30
|
+
},
|
|
31
|
+
prettyFormatFull = (astObject, indent = 0) => {
|
|
32
|
+
if (!astObject || !astObject.table) return "";
|
|
33
|
+
const spaces = " ".repeat(indent);
|
|
34
|
+
let query = astObject.table,
|
|
35
|
+
hasChainedMethods = !1;
|
|
36
|
+
if (astObject.where) {
|
|
37
|
+
const whereClause = formatWhere(astObject.where);
|
|
38
|
+
hasChainedMethods ? query += `
|
|
39
|
+
${spaces} ${whereClause}` : (query += whereClause, hasChainedMethods = !0);
|
|
40
|
+
}
|
|
41
|
+
if (astObject.limit) {
|
|
42
|
+
const limitClause = `.limit(${astObject.limit})`;
|
|
43
|
+
hasChainedMethods ? query += `
|
|
44
|
+
${spaces} ${limitClause}` : (query += limitClause, hasChainedMethods = !0);
|
|
45
|
+
}
|
|
46
|
+
if (astObject.orderBy && astObject.orderBy.length > 0) {
|
|
47
|
+
const orderByClause = `.orderBy(${astObject.orderBy.map(([field, direction]) => `${field}, ${direction}`).join(", ")})`;
|
|
48
|
+
hasChainedMethods ? query += `
|
|
49
|
+
${spaces} ${orderByClause}` : (query += orderByClause, hasChainedMethods = !0);
|
|
50
|
+
}
|
|
51
|
+
if (astObject.related && astObject.related.length > 0) {
|
|
52
|
+
astObject.related.forEach(rel => {
|
|
53
|
+
if (rel.subquery) {
|
|
54
|
+
const alias = rel.subquery.alias || rel.subquery.table,
|
|
55
|
+
subQuery = prettyFormatFull(rel.subquery, indent + 1);
|
|
56
|
+
query += `
|
|
57
|
+
${spaces} .related(${alias}, q => q.${subQuery}`;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const closingParens = ")".repeat(astObject.related.length);
|
|
61
|
+
query += `
|
|
62
|
+
${spaces}${closingParens}`;
|
|
63
|
+
}
|
|
64
|
+
return query;
|
|
65
|
+
},
|
|
66
|
+
prettyFormatMinimal = astObject => {
|
|
67
|
+
if (!astObject || !astObject.table) return "";
|
|
68
|
+
let query = astObject.table;
|
|
69
|
+
if (astObject.where && (query += formatWhere(astObject.where).replace(".where(", "(")), astObject.related && astObject.related.length > 0) {
|
|
70
|
+
const subQueries = collectSubQueryTables(astObject.related),
|
|
71
|
+
count = subQueries.length,
|
|
72
|
+
tableNames = subQueries.join(", ");
|
|
73
|
+
query += ` (+${count}: ${(0, import_helpers.ellipsis)(tableNames, 30)})`;
|
|
74
|
+
}
|
|
75
|
+
return query;
|
|
76
|
+
},
|
|
77
|
+
collectSubQueryTables = related => {
|
|
78
|
+
const tables = [];
|
|
79
|
+
return related.forEach(rel => {
|
|
80
|
+
if (rel.subquery) {
|
|
81
|
+
const tableName = rel.subquery.alias || rel.subquery.table;
|
|
82
|
+
tables.push(tableName), rel.subquery.related && rel.subquery.related.length > 0 && tables.push(...collectSubQueryTables(rel.subquery.related));
|
|
83
|
+
}
|
|
84
|
+
}), tables;
|
|
85
|
+
},
|
|
86
|
+
formatWhere = where => {
|
|
87
|
+
if (!where) return "";
|
|
88
|
+
if (where.type === "simple") {
|
|
89
|
+
const column = where.left?.name || where.left,
|
|
90
|
+
value = where.right?.value !== void 0 ? where.right.value : where.right,
|
|
91
|
+
op = where.op || "=";
|
|
92
|
+
return column === "id" && op === "=" && (typeof value == "string" || typeof value == "number") ? `(${value})` : op === "=" ? `.where(${column}, ${value})` : `.where(${column}, ${op}, ${value})`;
|
|
93
|
+
}
|
|
94
|
+
if (where.type === "and" && where.conditions) {
|
|
95
|
+
let result = "";
|
|
96
|
+
return where.conditions.forEach((condition, index) => {
|
|
97
|
+
index === 0 ? result += formatWhere(condition) : result += `.and(${formatWhere(condition).slice(1)})`;
|
|
98
|
+
}), result;
|
|
99
|
+
}
|
|
100
|
+
if (where.type === "or" && where.conditions) {
|
|
101
|
+
let result = "";
|
|
102
|
+
return where.conditions.forEach((condition, index) => {
|
|
103
|
+
index === 0 ? result += formatWhere(condition) : result += `.or(${formatWhere(condition).slice(1)})`;
|
|
104
|
+
}), result;
|
|
105
|
+
}
|
|
106
|
+
return "";
|
|
107
|
+
};
|