@akanjs/client 0.0.45 → 0.0.46
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/index.js +44 -890
- package/package.json +2 -8
package/index.js
CHANGED
|
@@ -91,316 +91,9 @@ var usePathCtx = () => {
|
|
|
91
91
|
return contextValues;
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
// pkgs/@akanjs/base/src/base.ts
|
|
95
|
-
var version = "0.9.0";
|
|
96
|
-
var logo = `
|
|
97
|
-
_ _ _
|
|
98
|
-
/ \\ | | ____ _ _ __ (_)___
|
|
99
|
-
/ _ \\ | |/ / _' | '_ \\ | / __|
|
|
100
|
-
/ ___ \\| < (_| | | | |_ | \\__ \\
|
|
101
|
-
/_/ \\_\\_|\\_\\__,_|_| |_(_)/ |___/
|
|
102
|
-
|__/ ver ${version}
|
|
103
|
-
? See more details on docs https://www.akanjs.com/docs
|
|
104
|
-
\u2605 Star Akanjs on GitHub https://github.com/aka-bassman/akanjs
|
|
105
|
-
|
|
106
|
-
`;
|
|
107
|
-
|
|
108
|
-
// pkgs/@akanjs/base/src/baseEnv.ts
|
|
109
|
-
var appName = process.env.NEXT_PUBLIC_APP_NAME ?? "unknown";
|
|
110
|
-
var repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? "unknown";
|
|
111
|
-
var serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "unknown";
|
|
112
|
-
if (appName === "unknown")
|
|
113
|
-
throw new Error("environment variable NEXT_PUBLIC_APP_NAME is required");
|
|
114
|
-
if (repoName === "unknown")
|
|
115
|
-
throw new Error("environment variable NEXT_PUBLIC_REPO_NAME is required");
|
|
116
|
-
if (serveDomain === "unknown")
|
|
117
|
-
throw new Error("environment variable NEXT_PUBLIC_SERVE_DOMAIN is required");
|
|
118
|
-
var environment = process.env.NEXT_PUBLIC_ENV ?? "debug";
|
|
119
|
-
var operationType = typeof window !== "undefined" ? "client" : process.env.NEXT_RUNTIME ? "client" : "server";
|
|
120
|
-
var operationMode = process.env.NEXT_PUBLIC_OPERATION_MODE ?? "cloud";
|
|
121
|
-
var networkType = process.env.NEXT_PUBLIC_NETWORK_TYPE ?? (environment === "main" ? "mainnet" : environment === "develop" ? "testnet" : "debugnet");
|
|
122
|
-
var tunnelUsername = process.env.SSU_TUNNEL_USERNAME ?? "root";
|
|
123
|
-
var tunnelPassword = process.env.SSU_TUNNEL_PASSWORD ?? repoName;
|
|
124
|
-
var baseEnv = {
|
|
125
|
-
repoName,
|
|
126
|
-
serveDomain,
|
|
127
|
-
appName,
|
|
128
|
-
environment,
|
|
129
|
-
operationType,
|
|
130
|
-
operationMode,
|
|
131
|
-
networkType,
|
|
132
|
-
tunnelUsername,
|
|
133
|
-
tunnelPassword
|
|
134
|
-
};
|
|
135
|
-
var side = typeof window === "undefined" ? "server" : "client";
|
|
136
|
-
var renderMode = process.env.RENDER_ENV ?? "ssr";
|
|
137
|
-
var clientHost = process.env.NEXT_PUBLIC_CLIENT_HOST ?? (operationMode === "local" || side === "server" ? "localhost" : window.location.hostname);
|
|
138
|
-
var clientPort = parseInt(
|
|
139
|
-
process.env.NEXT_PUBLIC_CLIENT_PORT ?? (operationMode === "local" ? renderMode === "ssr" ? "4200" : "4201" : "443")
|
|
140
|
-
);
|
|
141
|
-
var clientHttpProtocol = side === "client" ? window.location.protocol : clientHost === "localhost" ? "http:" : "https:";
|
|
142
|
-
var clientHttpUri = `${clientHttpProtocol}//${clientHost}${clientPort === 443 ? "" : `:${clientPort}`}`;
|
|
143
|
-
var serverHost = process.env.SERVER_HOST ?? (operationMode === "local" ? typeof window === "undefined" ? "localhost" : window.location.host.split(":")[0] : renderMode === "csr" ? `${appName}-${environment}.${serveDomain}` : side === "client" ? window.location.host.split(":")[0] : operationMode === "cloud" ? `backend-svc.${appName}-${environment}.svc.cluster.local` : "localhost");
|
|
144
|
-
var serverPort = parseInt(
|
|
145
|
-
process.env.SERVER_PORT ?? (operationMode === "local" || side === "server" ? "8080" : "443")
|
|
146
|
-
);
|
|
147
|
-
var serverHttpProtocol = side === "client" ? window.location.protocol : "http:";
|
|
148
|
-
var serverHttpUri = `${serverHttpProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}/backend`;
|
|
149
|
-
var serverGraphqlUri = `${serverHttpUri}/graphql`;
|
|
150
|
-
var serverWsProtocol = serverHttpProtocol === "http:" ? "ws:" : "wss:";
|
|
151
|
-
var serverWsUri = `${serverWsProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}`;
|
|
152
|
-
var baseClientEnv = {
|
|
153
|
-
...baseEnv,
|
|
154
|
-
side,
|
|
155
|
-
renderMode,
|
|
156
|
-
websocket: true,
|
|
157
|
-
clientHost,
|
|
158
|
-
clientPort,
|
|
159
|
-
clientHttpProtocol,
|
|
160
|
-
clientHttpUri,
|
|
161
|
-
serverHost,
|
|
162
|
-
serverPort,
|
|
163
|
-
serverHttpProtocol,
|
|
164
|
-
serverHttpUri,
|
|
165
|
-
serverGraphqlUri,
|
|
166
|
-
serverWsProtocol,
|
|
167
|
-
serverWsUri
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
// pkgs/@akanjs/base/src/scalar.ts
|
|
171
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
172
|
-
var dayjs = import_dayjs.default;
|
|
173
|
-
var Int = class {
|
|
174
|
-
__Scalar__;
|
|
175
|
-
};
|
|
176
|
-
var Upload = class {
|
|
177
|
-
__Scalar__;
|
|
178
|
-
filename;
|
|
179
|
-
mimetype;
|
|
180
|
-
encoding;
|
|
181
|
-
createReadStream;
|
|
182
|
-
};
|
|
183
|
-
var Float = class {
|
|
184
|
-
__Scalar__;
|
|
185
|
-
};
|
|
186
|
-
var ID = class {
|
|
187
|
-
__Scalar__;
|
|
188
|
-
};
|
|
189
|
-
var JSON2 = class {
|
|
190
|
-
__Scalar__;
|
|
191
|
-
};
|
|
192
|
-
var getNonArrayModel = (arraiedModel2) => {
|
|
193
|
-
let arrDepth = 0;
|
|
194
|
-
let target = arraiedModel2;
|
|
195
|
-
while (Array.isArray(target)) {
|
|
196
|
-
target = target[0];
|
|
197
|
-
arrDepth++;
|
|
198
|
-
}
|
|
199
|
-
return [target, arrDepth];
|
|
200
|
-
};
|
|
201
|
-
var scalarSet = /* @__PURE__ */ new Set([String, Boolean, Date, ID, Int, Float, Upload, JSON2, Map]);
|
|
202
|
-
var scalarNameMap = /* @__PURE__ */ new Map([
|
|
203
|
-
[ID, "ID"],
|
|
204
|
-
[Int, "Int"],
|
|
205
|
-
[Float, "Float"],
|
|
206
|
-
[String, "String"],
|
|
207
|
-
[Boolean, "Boolean"],
|
|
208
|
-
[Date, "Date"],
|
|
209
|
-
[Upload, "Upload"],
|
|
210
|
-
[JSON2, "JSON"],
|
|
211
|
-
[Map, "Map"]
|
|
212
|
-
]);
|
|
213
|
-
var scalarArgMap = /* @__PURE__ */ new Map([
|
|
214
|
-
[ID, null],
|
|
215
|
-
[String, ""],
|
|
216
|
-
[Boolean, false],
|
|
217
|
-
[Date, dayjs(/* @__PURE__ */ new Date(-1))],
|
|
218
|
-
[Int, 0],
|
|
219
|
-
[Float, 0],
|
|
220
|
-
[JSON2, {}],
|
|
221
|
-
[Map, {}]
|
|
222
|
-
]);
|
|
223
|
-
var scalarDefaultMap = /* @__PURE__ */ new Map([
|
|
224
|
-
[ID, null],
|
|
225
|
-
[String, ""],
|
|
226
|
-
[Boolean, false],
|
|
227
|
-
[Date, dayjs(/* @__PURE__ */ new Date(-1))],
|
|
228
|
-
[Int, 0],
|
|
229
|
-
[Float, 0],
|
|
230
|
-
[JSON2, {}]
|
|
231
|
-
]);
|
|
232
|
-
var isGqlScalar = (modelRef) => scalarSet.has(modelRef);
|
|
233
|
-
var isGqlMap = (modelRef) => modelRef === Map;
|
|
234
|
-
|
|
235
|
-
// pkgs/@akanjs/common/src/isDayjs.ts
|
|
236
|
-
var import_dayjs2 = require("dayjs");
|
|
237
|
-
|
|
238
|
-
// pkgs/@akanjs/common/src/isQueryEqual.ts
|
|
239
|
-
var import_dayjs3 = __toESM(require("dayjs"));
|
|
240
|
-
|
|
241
|
-
// pkgs/@akanjs/common/src/isValidDate.ts
|
|
242
|
-
var import_dayjs4 = __toESM(require("dayjs"));
|
|
243
|
-
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
244
|
-
import_dayjs4.default.extend(import_customParseFormat.default);
|
|
245
|
-
|
|
246
|
-
// pkgs/@akanjs/common/src/pluralize.ts
|
|
247
|
-
var import_pluralize = __toESM(require("pluralize"));
|
|
248
|
-
|
|
249
|
-
// pkgs/@akanjs/common/src/Logger.ts
|
|
250
|
-
var import_dayjs5 = __toESM(require("dayjs"));
|
|
251
|
-
var logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
|
|
252
|
-
var clc = {
|
|
253
|
-
bold: (text) => `\x1B[1m${text}\x1B[0m`,
|
|
254
|
-
green: (text) => `\x1B[32m${text}\x1B[39m`,
|
|
255
|
-
yellow: (text) => `\x1B[33m${text}\x1B[39m`,
|
|
256
|
-
red: (text) => `\x1B[31m${text}\x1B[39m`,
|
|
257
|
-
magentaBright: (text) => `\x1B[95m${text}\x1B[39m`,
|
|
258
|
-
cyanBright: (text) => `\x1B[96m${text}\x1B[39m`
|
|
259
|
-
};
|
|
260
|
-
var colorizeMap = {
|
|
261
|
-
trace: clc.bold,
|
|
262
|
-
verbose: clc.cyanBright,
|
|
263
|
-
debug: clc.magentaBright,
|
|
264
|
-
log: clc.green,
|
|
265
|
-
info: clc.green,
|
|
266
|
-
warn: clc.yellow,
|
|
267
|
-
error: clc.red
|
|
268
|
-
};
|
|
269
|
-
var Logger = class _Logger {
|
|
270
|
-
static #ignoreCtxSet = /* @__PURE__ */ new Set([
|
|
271
|
-
"InstanceLoader",
|
|
272
|
-
"RoutesResolver",
|
|
273
|
-
"RouterExplorer",
|
|
274
|
-
"NestFactory",
|
|
275
|
-
"WebSocketsController",
|
|
276
|
-
"GraphQLModule",
|
|
277
|
-
"NestApplication"
|
|
278
|
-
]);
|
|
279
|
-
static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
|
|
280
|
-
static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
|
|
281
|
-
static #startAt = (0, import_dayjs5.default)();
|
|
282
|
-
static setLevel(level) {
|
|
283
|
-
this.level = level;
|
|
284
|
-
this.#levelIdx = logLevels.findIndex((l) => l === level);
|
|
285
|
-
}
|
|
286
|
-
name;
|
|
287
|
-
constructor(name) {
|
|
288
|
-
this.name = name;
|
|
289
|
-
}
|
|
290
|
-
trace(msg, context = "") {
|
|
291
|
-
if (_Logger.#levelIdx <= 0)
|
|
292
|
-
_Logger.#printMessages(this.name ?? "App", msg, context, "trace");
|
|
293
|
-
}
|
|
294
|
-
verbose(msg, context = "") {
|
|
295
|
-
if (_Logger.#levelIdx <= 1)
|
|
296
|
-
_Logger.#printMessages(this.name ?? "App", msg, context, "verbose");
|
|
297
|
-
}
|
|
298
|
-
debug(msg, context = "") {
|
|
299
|
-
if (_Logger.#levelIdx <= 2)
|
|
300
|
-
_Logger.#printMessages(this.name ?? "App", msg, context, "debug");
|
|
301
|
-
}
|
|
302
|
-
log(msg, context = "") {
|
|
303
|
-
if (_Logger.#levelIdx <= 3)
|
|
304
|
-
_Logger.#printMessages(this.name ?? "App", msg, context, "log");
|
|
305
|
-
}
|
|
306
|
-
info(msg, context = "") {
|
|
307
|
-
if (_Logger.#levelIdx <= 4)
|
|
308
|
-
_Logger.#printMessages(this.name ?? "App", msg, context, "info");
|
|
309
|
-
}
|
|
310
|
-
warn(msg, context = "") {
|
|
311
|
-
if (_Logger.#levelIdx <= 5)
|
|
312
|
-
_Logger.#printMessages(this.name ?? "App", msg, context, "warn");
|
|
313
|
-
}
|
|
314
|
-
error(msg, context = "") {
|
|
315
|
-
if (_Logger.#levelIdx <= 6)
|
|
316
|
-
_Logger.#printMessages(this.name ?? "App", msg, context, "error");
|
|
317
|
-
}
|
|
318
|
-
raw(msg, method) {
|
|
319
|
-
_Logger.rawLog(msg, method);
|
|
320
|
-
}
|
|
321
|
-
rawLog(msg, method) {
|
|
322
|
-
_Logger.rawLog(msg, method);
|
|
323
|
-
}
|
|
324
|
-
static trace(msg, context = "") {
|
|
325
|
-
if (_Logger.#levelIdx <= 0)
|
|
326
|
-
_Logger.#printMessages("App", msg, context, "trace");
|
|
327
|
-
}
|
|
328
|
-
static verbose(msg, context = "") {
|
|
329
|
-
if (_Logger.#levelIdx <= 1)
|
|
330
|
-
_Logger.#printMessages("App", msg, context, "verbose");
|
|
331
|
-
}
|
|
332
|
-
static debug(msg, context = "") {
|
|
333
|
-
if (_Logger.#levelIdx <= 2)
|
|
334
|
-
_Logger.#printMessages("App", msg, context, "debug");
|
|
335
|
-
}
|
|
336
|
-
static log(msg, context = "") {
|
|
337
|
-
if (_Logger.#levelIdx <= 3)
|
|
338
|
-
_Logger.#printMessages("App", msg, context, "log");
|
|
339
|
-
}
|
|
340
|
-
static info(msg, context = "") {
|
|
341
|
-
if (_Logger.#levelIdx <= 4)
|
|
342
|
-
_Logger.#printMessages("App", msg, context, "info");
|
|
343
|
-
}
|
|
344
|
-
static warn(msg, context = "") {
|
|
345
|
-
if (_Logger.#levelIdx <= 5)
|
|
346
|
-
_Logger.#printMessages("App", msg, context, "warn");
|
|
347
|
-
}
|
|
348
|
-
static error(msg, context = "") {
|
|
349
|
-
if (_Logger.#levelIdx <= 6)
|
|
350
|
-
_Logger.#printMessages("App", msg, context, "error");
|
|
351
|
-
}
|
|
352
|
-
static #colorize(msg, logLevel) {
|
|
353
|
-
return colorizeMap[logLevel](msg);
|
|
354
|
-
}
|
|
355
|
-
static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
|
|
356
|
-
if (this.#ignoreCtxSet.has(context))
|
|
357
|
-
return;
|
|
358
|
-
const now = (0, import_dayjs5.default)();
|
|
359
|
-
const processMsg = this.#colorize(
|
|
360
|
-
`[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
|
|
361
|
-
logLevel
|
|
362
|
-
);
|
|
363
|
-
const timestampMsg = now.format("MM/DD/YYYY, HH:mm:ss A");
|
|
364
|
-
const logLevelMsg = this.#colorize(logLevel.toUpperCase().padStart(7, " "), logLevel);
|
|
365
|
-
const contextMsg = context ? clc.yellow(`[${context}] `) : "";
|
|
366
|
-
const contentMsg = this.#colorize(content, logLevel);
|
|
367
|
-
const timeDiffMsg = clc.yellow(`+${now.diff(_Logger.#startAt, "ms")}ms`);
|
|
368
|
-
if (typeof window === "undefined")
|
|
369
|
-
process[writeStreamType].write(
|
|
370
|
-
`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
|
|
371
|
-
`
|
|
372
|
-
);
|
|
373
|
-
else
|
|
374
|
-
console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
|
|
375
|
-
`);
|
|
376
|
-
}
|
|
377
|
-
static rawLog(msg, method) {
|
|
378
|
-
this.raw(`${msg}
|
|
379
|
-
`, method);
|
|
380
|
-
}
|
|
381
|
-
static raw(msg, method) {
|
|
382
|
-
if (typeof window === "undefined" && method !== "console" && global.process)
|
|
383
|
-
global.process.stdout.write(msg);
|
|
384
|
-
else
|
|
385
|
-
console.log(msg);
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
// pkgs/@akanjs/common/src/lowerlize.ts
|
|
390
|
-
var lowerlize = (str) => {
|
|
391
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
// pkgs/@akanjs/common/src/sleep.ts
|
|
395
|
-
var sleep = async (ms) => {
|
|
396
|
-
return new Promise((resolve) => {
|
|
397
|
-
setTimeout(() => {
|
|
398
|
-
resolve(true);
|
|
399
|
-
}, ms);
|
|
400
|
-
});
|
|
401
|
-
};
|
|
402
|
-
|
|
403
94
|
// pkgs/@akanjs/client/src/router.ts
|
|
95
|
+
var import_base = require("@akanjs/base");
|
|
96
|
+
var import_common = require("@akanjs/common");
|
|
404
97
|
var import_navigation = require("next/navigation");
|
|
405
98
|
var getPathInfo = (href, lang, prefix) => {
|
|
406
99
|
const langLength = lang.length + 1;
|
|
@@ -418,14 +111,14 @@ var Router = class {
|
|
|
418
111
|
#instance = {
|
|
419
112
|
push: (href) => {
|
|
420
113
|
const { pathname } = this.#getPathInfo(href);
|
|
421
|
-
Logger.log(`push to:${pathname}`);
|
|
422
|
-
if (baseClientEnv.side === "server")
|
|
114
|
+
import_common.Logger.log(`push to:${pathname}`);
|
|
115
|
+
if (import_base.baseClientEnv.side === "server")
|
|
423
116
|
void (0, import_navigation.redirect)(pathname);
|
|
424
117
|
},
|
|
425
118
|
replace: (href) => {
|
|
426
119
|
const { pathname } = this.#getPathInfo(href);
|
|
427
|
-
Logger.log(`replace to:${pathname}`);
|
|
428
|
-
if (baseClientEnv.side === "server")
|
|
120
|
+
import_common.Logger.log(`replace to:${pathname}`);
|
|
121
|
+
if (import_base.baseClientEnv.side === "server")
|
|
429
122
|
void (0, import_navigation.redirect)(pathname);
|
|
430
123
|
},
|
|
431
124
|
back: () => {
|
|
@@ -445,7 +138,7 @@ var Router = class {
|
|
|
445
138
|
else
|
|
446
139
|
this.#initNextClientRouter(options);
|
|
447
140
|
this.isInitialized = true;
|
|
448
|
-
Logger.verbose("Router initialized");
|
|
141
|
+
import_common.Logger.verbose("Router initialized");
|
|
449
142
|
}
|
|
450
143
|
#initNextServerRouter(options) {
|
|
451
144
|
}
|
|
@@ -511,7 +204,7 @@ var Router = class {
|
|
|
511
204
|
return getPathInfo(href, this.#lang, prefix);
|
|
512
205
|
}
|
|
513
206
|
#postPathChange({ path, pathname }) {
|
|
514
|
-
Logger.log(`pathChange-start:${path}`);
|
|
207
|
+
import_common.Logger.log(`pathChange-start:${path}`);
|
|
515
208
|
window.parent.postMessage({ type: "pathChange", path, pathname }, "*");
|
|
516
209
|
}
|
|
517
210
|
push(href) {
|
|
@@ -525,27 +218,27 @@ var Router = class {
|
|
|
525
218
|
return void 0;
|
|
526
219
|
}
|
|
527
220
|
back() {
|
|
528
|
-
if (baseClientEnv.side === "server")
|
|
221
|
+
if (import_base.baseClientEnv.side === "server")
|
|
529
222
|
throw new Error("back is only available in client side");
|
|
530
223
|
this.#checkInitialized();
|
|
531
224
|
this.#instance.back();
|
|
532
225
|
return void 0;
|
|
533
226
|
}
|
|
534
227
|
refresh() {
|
|
535
|
-
if (baseClientEnv.side === "server")
|
|
228
|
+
if (import_base.baseClientEnv.side === "server")
|
|
536
229
|
throw new Error("refresh is only available in client side");
|
|
537
230
|
this.#checkInitialized();
|
|
538
231
|
this.#instance.refresh();
|
|
539
232
|
return void 0;
|
|
540
233
|
}
|
|
541
234
|
async redirect(href) {
|
|
542
|
-
if (baseClientEnv.side === "server") {
|
|
235
|
+
if (import_base.baseClientEnv.side === "server") {
|
|
543
236
|
const nextHeaders = require("next/headers");
|
|
544
237
|
const headers2 = await nextHeaders.headers?.() ?? /* @__PURE__ */ new Map();
|
|
545
238
|
const lang = headers2.get("x-locale") ?? this.#lang;
|
|
546
239
|
const basePath = headers2.get("x-base-path");
|
|
547
240
|
const { pathname } = getPathInfo(href, lang, basePath ?? "");
|
|
548
|
-
Logger.log(`redirect to:${pathname}`);
|
|
241
|
+
import_common.Logger.log(`redirect to:${pathname}`);
|
|
549
242
|
(0, import_navigation.redirect)(pathname);
|
|
550
243
|
} else {
|
|
551
244
|
const { pathname } = getPathInfo(href, this.#lang, this.#prefix);
|
|
@@ -555,15 +248,15 @@ var Router = class {
|
|
|
555
248
|
}
|
|
556
249
|
notFound() {
|
|
557
250
|
this.#checkInitialized();
|
|
558
|
-
if (baseClientEnv.side === "server") {
|
|
559
|
-
Logger.log(`redirect to:/404`);
|
|
251
|
+
if (import_base.baseClientEnv.side === "server") {
|
|
252
|
+
import_common.Logger.log(`redirect to:/404`);
|
|
560
253
|
(0, import_navigation.notFound)();
|
|
561
254
|
} else
|
|
562
255
|
this.#instance.replace("/404");
|
|
563
256
|
return void 0;
|
|
564
257
|
}
|
|
565
258
|
setLang(lang) {
|
|
566
|
-
if (baseClientEnv.side === "server")
|
|
259
|
+
if (import_base.baseClientEnv.side === "server")
|
|
567
260
|
throw new Error("setLang is only available in client side");
|
|
568
261
|
this.#checkInitialized();
|
|
569
262
|
const { path } = getPathInfo(window.location.pathname, this.#lang, this.#prefix);
|
|
@@ -572,13 +265,13 @@ var Router = class {
|
|
|
572
265
|
return void 0;
|
|
573
266
|
}
|
|
574
267
|
getPath(pathname = window.location.pathname) {
|
|
575
|
-
if (baseClientEnv.side === "server")
|
|
268
|
+
if (import_base.baseClientEnv.side === "server")
|
|
576
269
|
throw new Error("getPath is only available in client side");
|
|
577
270
|
const { path } = getPathInfo(pathname, this.#lang, this.#prefix);
|
|
578
271
|
return path;
|
|
579
272
|
}
|
|
580
273
|
getFullPath(withLang = true) {
|
|
581
|
-
if (baseClientEnv.side === "server")
|
|
274
|
+
if (import_base.baseClientEnv.side === "server")
|
|
582
275
|
throw new Error("getPath is only available in client side");
|
|
583
276
|
return `${withLang ? `/${this.#lang}` : ""}/${this.#prefix}${this.getPath()}`;
|
|
584
277
|
}
|
|
@@ -591,570 +284,32 @@ var Router = class {
|
|
|
591
284
|
};
|
|
592
285
|
var router = new Router();
|
|
593
286
|
|
|
594
|
-
// pkgs/@akanjs/signal/src/client.ts
|
|
595
|
-
var import_core = require("@urql/core");
|
|
596
|
-
var import_socket = require("socket.io-client");
|
|
597
|
-
var SocketIo = class {
|
|
598
|
-
socket;
|
|
599
|
-
roomSubscribeMap = /* @__PURE__ */ new Map();
|
|
600
|
-
constructor(uri) {
|
|
601
|
-
this.socket = (0, import_socket.io)(uri, { transports: ["websocket"] });
|
|
602
|
-
this.socket.on("connect", () => {
|
|
603
|
-
this.roomSubscribeMap.forEach((option) => {
|
|
604
|
-
this.socket.emit(option.key, { ...option.message, __subscribe__: true });
|
|
605
|
-
});
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
on(event, callback) {
|
|
609
|
-
this.socket.on(event, callback);
|
|
610
|
-
}
|
|
611
|
-
removeListener(event, callback) {
|
|
612
|
-
this.socket.removeListener(event, callback);
|
|
613
|
-
}
|
|
614
|
-
removeAllListeners() {
|
|
615
|
-
this.socket.removeAllListeners();
|
|
616
|
-
}
|
|
617
|
-
hasListeners(event) {
|
|
618
|
-
return this.socket.hasListeners(event);
|
|
619
|
-
}
|
|
620
|
-
emit(key, data) {
|
|
621
|
-
this.socket.emit(key, data);
|
|
622
|
-
}
|
|
623
|
-
subscribe(option) {
|
|
624
|
-
if (!this.roomSubscribeMap.has(option.roomId)) {
|
|
625
|
-
this.roomSubscribeMap.set(option.roomId, option);
|
|
626
|
-
this.socket.emit(option.key, { ...option.message, __subscribe__: true });
|
|
627
|
-
}
|
|
628
|
-
this.socket.on(option.roomId, option.handleEvent);
|
|
629
|
-
}
|
|
630
|
-
unsubscribe(roomId, handleEvent) {
|
|
631
|
-
this.socket.removeListener(roomId, handleEvent);
|
|
632
|
-
const option = this.roomSubscribeMap.get(roomId);
|
|
633
|
-
if (this.hasListeners(roomId) || !option)
|
|
634
|
-
return;
|
|
635
|
-
this.roomSubscribeMap.delete(roomId);
|
|
636
|
-
this.socket.emit(option.key, { ...option.message, __subscribe__: false });
|
|
637
|
-
}
|
|
638
|
-
disconnect() {
|
|
639
|
-
this.socket.disconnect();
|
|
640
|
-
return this;
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
var Client = class _Client {
|
|
644
|
-
static globalIoMap = /* @__PURE__ */ new Map();
|
|
645
|
-
static tokenStore = /* @__PURE__ */ new Map();
|
|
646
|
-
async waitUntilWebSocketConnected(ws = baseClientEnv.serverWsUri) {
|
|
647
|
-
if (baseClientEnv.side === "server")
|
|
648
|
-
return true;
|
|
649
|
-
while (!this.getIo(ws).socket.connected) {
|
|
650
|
-
Logger.verbose("waiting for websocket to initialize...");
|
|
651
|
-
await sleep(300);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
isInitialized = false;
|
|
655
|
-
uri = baseClientEnv.serverGraphqlUri;
|
|
656
|
-
ws = baseClientEnv.serverWsUri;
|
|
657
|
-
udp = null;
|
|
658
|
-
gql = (0, import_core.createClient)({ url: this.uri, fetch, exchanges: [import_core.cacheExchange, import_core.fetchExchange] });
|
|
659
|
-
jwt = null;
|
|
660
|
-
async getJwt() {
|
|
661
|
-
const isNextServer = baseClientEnv.side === "server" && baseEnv.operationType === "client";
|
|
662
|
-
if (isNextServer) {
|
|
663
|
-
const nextHeaders = require("next/headers");
|
|
664
|
-
return (await nextHeaders.cookies?.())?.get("jwt")?.value ?? (await nextHeaders.headers?.())?.get("jwt") ?? this.jwt ?? null;
|
|
665
|
-
} else
|
|
666
|
-
return _Client.tokenStore.get(this) ?? null;
|
|
667
|
-
}
|
|
668
|
-
io = null;
|
|
669
|
-
init(data = {}) {
|
|
670
|
-
Object.assign(this, data);
|
|
671
|
-
this.setLink(data.uri);
|
|
672
|
-
this.setIo(data.ws);
|
|
673
|
-
this.isInitialized = true;
|
|
674
|
-
}
|
|
675
|
-
setIo(ws = baseClientEnv.serverWsUri) {
|
|
676
|
-
this.ws = ws;
|
|
677
|
-
const existingIo = _Client.globalIoMap.get(ws);
|
|
678
|
-
if (existingIo) {
|
|
679
|
-
this.io = existingIo;
|
|
680
|
-
return;
|
|
681
|
-
}
|
|
682
|
-
this.io = new SocketIo(ws);
|
|
683
|
-
_Client.globalIoMap.set(ws, this.io);
|
|
684
|
-
}
|
|
685
|
-
getIo(ws = baseClientEnv.serverWsUri) {
|
|
686
|
-
const existingIo = _Client.globalIoMap.get(ws);
|
|
687
|
-
if (existingIo)
|
|
688
|
-
return existingIo;
|
|
689
|
-
const io2 = new SocketIo(ws);
|
|
690
|
-
_Client.globalIoMap.set(ws, io2);
|
|
691
|
-
return io2;
|
|
692
|
-
}
|
|
693
|
-
setLink(uri = baseClientEnv.serverGraphqlUri) {
|
|
694
|
-
this.uri = uri;
|
|
695
|
-
this.gql = (0, import_core.createClient)({
|
|
696
|
-
url: this.uri,
|
|
697
|
-
fetch,
|
|
698
|
-
exchanges: [import_core.cacheExchange, import_core.fetchExchange],
|
|
699
|
-
// requestPolicy: "network-only",
|
|
700
|
-
fetchOptions: () => {
|
|
701
|
-
return {
|
|
702
|
-
headers: {
|
|
703
|
-
"apollo-require-preflight": "true",
|
|
704
|
-
...this.jwt ? { authorization: `Bearer ${this.jwt}` } : {}
|
|
705
|
-
}
|
|
706
|
-
};
|
|
707
|
-
}
|
|
708
|
-
});
|
|
709
|
-
}
|
|
710
|
-
setJwt(jwt) {
|
|
711
|
-
_Client.tokenStore.set(this, jwt);
|
|
712
|
-
}
|
|
713
|
-
reset() {
|
|
714
|
-
this.io?.disconnect();
|
|
715
|
-
this.io = null;
|
|
716
|
-
this.jwt = null;
|
|
717
|
-
}
|
|
718
|
-
clone(data = {}) {
|
|
719
|
-
const newClient = new _Client();
|
|
720
|
-
newClient.init({ ...this, ...data });
|
|
721
|
-
if (data.jwt)
|
|
722
|
-
_Client.tokenStore.set(newClient, data.jwt);
|
|
723
|
-
return newClient;
|
|
724
|
-
}
|
|
725
|
-
terminate() {
|
|
726
|
-
this.reset();
|
|
727
|
-
_Client.globalIoMap.forEach((io2) => io2.disconnect());
|
|
728
|
-
this.isInitialized = false;
|
|
729
|
-
}
|
|
730
|
-
setUdp(udp) {
|
|
731
|
-
this.udp = udp;
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
|
-
var client = new Client();
|
|
735
|
-
|
|
736
|
-
// pkgs/@akanjs/constant/src/scalar.ts
|
|
737
|
-
var import_reflect_metadata = require("reflect-metadata");
|
|
738
|
-
var scalarExampleMap = /* @__PURE__ */ new Map([
|
|
739
|
-
[ID, "1234567890abcdef12345678"],
|
|
740
|
-
[Int, 0],
|
|
741
|
-
[Float, 0],
|
|
742
|
-
[String, "String"],
|
|
743
|
-
[Boolean, true],
|
|
744
|
-
[Date, (/* @__PURE__ */ new Date()).toISOString()],
|
|
745
|
-
[Upload, "FileUpload"],
|
|
746
|
-
[JSON2, {}],
|
|
747
|
-
[Map, {}]
|
|
748
|
-
]);
|
|
749
|
-
var getClassMeta = (modelRef) => {
|
|
750
|
-
const [target] = getNonArrayModel(modelRef);
|
|
751
|
-
const classMeta = Reflect.getMetadata("class", target.prototype);
|
|
752
|
-
if (!classMeta)
|
|
753
|
-
throw new Error(`No ClassMeta for this target ${target.name}`);
|
|
754
|
-
return classMeta;
|
|
755
|
-
};
|
|
756
|
-
var getFieldMetas = (modelRef) => {
|
|
757
|
-
const [target] = getNonArrayModel(modelRef);
|
|
758
|
-
const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
|
|
759
|
-
const keySortMap = { id: -1, createdAt: 1, updatedAt: 2, removedAt: 3 };
|
|
760
|
-
return [...metadataMap.values()].sort((a, b) => (keySortMap[a.key] ?? 0) - (keySortMap[b.key] ?? 0));
|
|
761
|
-
};
|
|
762
|
-
var getFieldMetaMapOnPrototype = (prototype) => {
|
|
763
|
-
const metadataMap = Reflect.getMetadata("fields", prototype) ?? /* @__PURE__ */ new Map();
|
|
764
|
-
return new Map(metadataMap);
|
|
765
|
-
};
|
|
766
|
-
var setFieldMetaMapOnPrototype = (prototype, metadataMap) => {
|
|
767
|
-
Reflect.defineMetadata("fields", new Map(metadataMap), prototype);
|
|
768
|
-
};
|
|
769
|
-
|
|
770
|
-
// pkgs/@akanjs/constant/src/fieldMeta.ts
|
|
771
|
-
var applyFieldMeta = (modelRef, arrDepth, option, optionArrDepth) => {
|
|
772
|
-
const isArray = arrDepth > 0;
|
|
773
|
-
const isClass = !isGqlScalar(modelRef);
|
|
774
|
-
const isMap = isGqlMap(modelRef);
|
|
775
|
-
const { refName, type } = isClass ? getClassMeta(modelRef) : { refName: "", type: "scalar" };
|
|
776
|
-
const name = isClass ? refName : scalarNameMap.get(modelRef) ?? "Unknown";
|
|
777
|
-
if (isMap && !option.of)
|
|
778
|
-
throw new Error("Map type must have 'of' option");
|
|
779
|
-
return (prototype, key) => {
|
|
780
|
-
const metadata = {
|
|
781
|
-
nullable: option.nullable ?? false,
|
|
782
|
-
ref: option.ref,
|
|
783
|
-
refPath: option.refPath,
|
|
784
|
-
refType: option.refType,
|
|
785
|
-
default: option.default ?? (isArray ? [] : null),
|
|
786
|
-
type: option.type,
|
|
787
|
-
fieldType: option.fieldType ?? "property",
|
|
788
|
-
immutable: option.immutable ?? false,
|
|
789
|
-
min: option.min,
|
|
790
|
-
max: option.max,
|
|
791
|
-
enum: option.enum,
|
|
792
|
-
select: option.select ?? true,
|
|
793
|
-
minlength: option.minlength,
|
|
794
|
-
maxlength: option.maxlength,
|
|
795
|
-
query: option.query,
|
|
796
|
-
accumulate: option.accumulate,
|
|
797
|
-
example: option.example,
|
|
798
|
-
validate: option.validate,
|
|
799
|
-
key,
|
|
800
|
-
name,
|
|
801
|
-
isClass,
|
|
802
|
-
isScalar: type === "scalar",
|
|
803
|
-
modelRef,
|
|
804
|
-
arrDepth,
|
|
805
|
-
isArray,
|
|
806
|
-
optArrDepth: optionArrDepth,
|
|
807
|
-
isMap,
|
|
808
|
-
of: option.of,
|
|
809
|
-
text: option.text
|
|
810
|
-
};
|
|
811
|
-
const metadataMap = getFieldMetaMapOnPrototype(prototype);
|
|
812
|
-
metadataMap.set(key, metadata);
|
|
813
|
-
setFieldMetaMapOnPrototype(prototype, metadataMap);
|
|
814
|
-
};
|
|
815
|
-
};
|
|
816
|
-
var makeField = (customOption) => (returns, fieldOption) => {
|
|
817
|
-
const [modelRef, arrDepth] = getNonArrayModel(returns());
|
|
818
|
-
if (!fieldOption)
|
|
819
|
-
return applyFieldMeta(modelRef, arrDepth, { ...customOption }, arrDepth);
|
|
820
|
-
const [opt, optArrDepth] = getNonArrayModel(fieldOption);
|
|
821
|
-
return applyFieldMeta(modelRef, arrDepth, { ...opt, ...customOption }, optArrDepth);
|
|
822
|
-
};
|
|
823
|
-
var Field = {
|
|
824
|
-
Prop: makeField({ fieldType: "property" }),
|
|
825
|
-
Hidden: makeField({ fieldType: "hidden", nullable: true }),
|
|
826
|
-
Secret: makeField({ fieldType: "hidden", select: false, nullable: true }),
|
|
827
|
-
Resolve: makeField({ fieldType: "resolve" })
|
|
828
|
-
};
|
|
829
|
-
|
|
830
|
-
// pkgs/@akanjs/constant/src/constantDecorator.ts
|
|
831
|
-
var import_reflect_metadata2 = require("reflect-metadata");
|
|
832
|
-
|
|
833
|
-
// pkgs/@akanjs/constant/src/filterMeta.ts
|
|
834
|
-
var setFilterMeta = (filterRef, filterMeta) => {
|
|
835
|
-
const existingFilterMeta = Reflect.getMetadata("filter", filterRef.prototype);
|
|
836
|
-
if (existingFilterMeta)
|
|
837
|
-
Object.assign(filterMeta.sort, existingFilterMeta.sort);
|
|
838
|
-
Reflect.defineMetadata("filter", filterMeta, filterRef.prototype);
|
|
839
|
-
};
|
|
840
|
-
var getFilterKeyMetaMapOnPrototype = (prototype) => {
|
|
841
|
-
const metadataMap = Reflect.getMetadata("filterKey", prototype) ?? /* @__PURE__ */ new Map();
|
|
842
|
-
return new Map(metadataMap);
|
|
843
|
-
};
|
|
844
|
-
var setFilterKeyMetaMapOnPrototype = (prototype, metadataMap) => {
|
|
845
|
-
Reflect.defineMetadata("filterKey", new Map(metadataMap), prototype);
|
|
846
|
-
};
|
|
847
|
-
var applyFilterKeyMeta = (option) => {
|
|
848
|
-
return (prototype, key, descriptor) => {
|
|
849
|
-
const metadata = { key, ...option, descriptor };
|
|
850
|
-
const metadataMap = getFilterKeyMetaMapOnPrototype(prototype);
|
|
851
|
-
metadataMap.set(key, metadata);
|
|
852
|
-
setFilterKeyMetaMapOnPrototype(prototype, metadataMap);
|
|
853
|
-
};
|
|
854
|
-
};
|
|
855
|
-
var makeFilter = (customOption) => (fieldOption) => {
|
|
856
|
-
return applyFilterKeyMeta({ ...customOption, ...fieldOption });
|
|
857
|
-
};
|
|
858
|
-
var getFilterArgMetasOnPrototype = (prototype, key) => {
|
|
859
|
-
const filterArgMetas = Reflect.getMetadata("filterArg", prototype, key) ?? [];
|
|
860
|
-
return filterArgMetas;
|
|
861
|
-
};
|
|
862
|
-
var setFilterArgMetasOnPrototype = (prototype, key, filterArgMetas) => {
|
|
863
|
-
Reflect.defineMetadata("filterArg", filterArgMetas, prototype, key);
|
|
864
|
-
};
|
|
865
|
-
var applyFilterArgMeta = (name, returns, argOption) => {
|
|
866
|
-
return (prototype, key, idx) => {
|
|
867
|
-
const [modelRef, arrDepth] = getNonArrayModel(returns());
|
|
868
|
-
const [opt, optArrDepth] = getNonArrayModel(argOption ?? {});
|
|
869
|
-
const filterArgMeta = { name, ...opt, modelRef, arrDepth, isArray: arrDepth > 0, optArrDepth };
|
|
870
|
-
const filterArgMetas = getFilterArgMetasOnPrototype(prototype, key);
|
|
871
|
-
filterArgMetas[idx] = filterArgMeta;
|
|
872
|
-
setFilterArgMetasOnPrototype(prototype, key, filterArgMetas);
|
|
873
|
-
};
|
|
874
|
-
};
|
|
875
|
-
var Filter = {
|
|
876
|
-
Mongo: makeFilter({ type: "mongo" }),
|
|
877
|
-
// Meili: makeFilter({ fieldType: "hidden", nullable: true }),
|
|
878
|
-
Arg: applyFilterArgMeta
|
|
879
|
-
};
|
|
880
|
-
|
|
881
|
-
// pkgs/@akanjs/constant/src/baseGql.ts
|
|
882
|
-
var import_reflect_metadata3 = require("reflect-metadata");
|
|
883
|
-
var defaultFieldMeta = {
|
|
884
|
-
fieldType: "property",
|
|
885
|
-
immutable: false,
|
|
886
|
-
select: true,
|
|
887
|
-
isClass: false,
|
|
888
|
-
isScalar: true,
|
|
889
|
-
nullable: false,
|
|
890
|
-
isArray: false,
|
|
891
|
-
arrDepth: 0,
|
|
892
|
-
optArrDepth: 0,
|
|
893
|
-
default: null,
|
|
894
|
-
isMap: false
|
|
895
|
-
};
|
|
896
|
-
var idFieldMeta = { ...defaultFieldMeta, key: "id", name: "ID", modelRef: ID };
|
|
897
|
-
var createdAtFieldMeta = { ...defaultFieldMeta, key: "createdAt", name: "Date", modelRef: Date };
|
|
898
|
-
var updatedAtFieldMeta = { ...defaultFieldMeta, key: "updatedAt", name: "Date", modelRef: Date };
|
|
899
|
-
var removedAtFieldMeta = {
|
|
900
|
-
...defaultFieldMeta,
|
|
901
|
-
key: "removedAt",
|
|
902
|
-
name: "Date",
|
|
903
|
-
modelRef: Date,
|
|
904
|
-
nullable: true,
|
|
905
|
-
default: null
|
|
906
|
-
};
|
|
907
|
-
|
|
908
|
-
// pkgs/@akanjs/constant/src/classMeta.ts
|
|
909
|
-
var import_reflect_metadata4 = require("reflect-metadata");
|
|
910
|
-
var InputModelStorage = class {
|
|
911
|
-
};
|
|
912
|
-
var LightModelStorage = class {
|
|
913
|
-
};
|
|
914
|
-
var FullModelStorage = class {
|
|
915
|
-
};
|
|
916
|
-
var ScalarModelStorage = class {
|
|
917
|
-
};
|
|
918
|
-
var FilterModelStorage = class {
|
|
919
|
-
};
|
|
920
|
-
var hasTextField = (modelRef) => {
|
|
921
|
-
const fieldMetas = getFieldMetas(modelRef);
|
|
922
|
-
return fieldMetas.some(
|
|
923
|
-
(fieldMeta) => !!fieldMeta.text || fieldMeta.isScalar && fieldMeta.isClass && fieldMeta.select && hasTextField(fieldMeta.modelRef)
|
|
924
|
-
);
|
|
925
|
-
};
|
|
926
|
-
var applyClassMeta = (type, modelType, storage2) => {
|
|
927
|
-
return function(refName) {
|
|
928
|
-
return function(target) {
|
|
929
|
-
const modelRef = target;
|
|
930
|
-
const classMeta = { refName, type, modelType, modelRef, hasTextField: hasTextField(modelRef) };
|
|
931
|
-
Reflect.defineMetadata("class", classMeta, modelRef.prototype);
|
|
932
|
-
Reflect.defineMetadata(refName, modelRef, storage2.prototype);
|
|
933
|
-
};
|
|
934
|
-
};
|
|
935
|
-
};
|
|
936
|
-
var applyFilterMeta = (storage2) => {
|
|
937
|
-
return function(refName) {
|
|
938
|
-
return function(target) {
|
|
939
|
-
const modelRef = target;
|
|
940
|
-
setFilterMeta(modelRef, { refName, sort: {} });
|
|
941
|
-
Reflect.defineMetadata(refName, modelRef, storage2.prototype);
|
|
942
|
-
};
|
|
943
|
-
};
|
|
944
|
-
};
|
|
945
|
-
var Model = {
|
|
946
|
-
Light: applyClassMeta("light", "data", LightModelStorage),
|
|
947
|
-
Object: applyClassMeta("full", "ephemeral", FullModelStorage),
|
|
948
|
-
Full: applyClassMeta("full", "data", FullModelStorage),
|
|
949
|
-
Input: applyClassMeta("input", "data", InputModelStorage),
|
|
950
|
-
Scalar: applyClassMeta("scalar", "data", ScalarModelStorage),
|
|
951
|
-
Summary: applyClassMeta("scalar", "summary", ScalarModelStorage),
|
|
952
|
-
Insight: applyClassMeta("scalar", "insight", ScalarModelStorage),
|
|
953
|
-
Filter: applyFilterMeta(FilterModelStorage)
|
|
954
|
-
};
|
|
955
|
-
|
|
956
|
-
// pkgs/@akanjs/signal/src/immerify.ts
|
|
957
|
-
var import_immer = require("immer");
|
|
958
|
-
|
|
959
|
-
// pkgs/@akanjs/signal/src/signalDecorators.ts
|
|
960
|
-
var import_reflect_metadata5 = require("reflect-metadata");
|
|
961
|
-
var createArgMetaDecorator = (type) => {
|
|
962
|
-
return function(option = {}) {
|
|
963
|
-
return function(prototype, key, idx) {
|
|
964
|
-
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
965
|
-
argMetas[idx] = { key, idx, type, option };
|
|
966
|
-
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
967
|
-
};
|
|
968
|
-
};
|
|
969
|
-
};
|
|
970
|
-
var Account = createArgMetaDecorator("Account");
|
|
971
|
-
var defaultAccount = {
|
|
972
|
-
__InternalArg__: "Account",
|
|
973
|
-
appName: baseEnv.appName,
|
|
974
|
-
environment: baseEnv.environment
|
|
975
|
-
};
|
|
976
|
-
var Self = createArgMetaDecorator("Self");
|
|
977
|
-
var Me = createArgMetaDecorator("Me");
|
|
978
|
-
var UserIp = createArgMetaDecorator("UserIp");
|
|
979
|
-
var Access = createArgMetaDecorator("Access");
|
|
980
|
-
var Req = createArgMetaDecorator("Req");
|
|
981
|
-
var Res = createArgMetaDecorator("Res");
|
|
982
|
-
var Ws = createArgMetaDecorator("Ws");
|
|
983
|
-
var Job = createArgMetaDecorator("Job");
|
|
984
|
-
var getQuery = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
985
|
-
return (prototype, key, descriptor) => {
|
|
986
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
987
|
-
metadataMap.set(key, {
|
|
988
|
-
returns,
|
|
989
|
-
signalOption,
|
|
990
|
-
key,
|
|
991
|
-
descriptor,
|
|
992
|
-
guards: [allow, ...guards],
|
|
993
|
-
type: "Query"
|
|
994
|
-
});
|
|
995
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
996
|
-
};
|
|
997
|
-
};
|
|
998
|
-
var getMutation = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
999
|
-
return (prototype, key, descriptor) => {
|
|
1000
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
1001
|
-
metadataMap.set(key, {
|
|
1002
|
-
returns,
|
|
1003
|
-
signalOption,
|
|
1004
|
-
key,
|
|
1005
|
-
descriptor,
|
|
1006
|
-
guards: [allow, ...guards],
|
|
1007
|
-
type: "Mutation"
|
|
1008
|
-
});
|
|
1009
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
1010
|
-
};
|
|
1011
|
-
};
|
|
1012
|
-
var getMessage = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
1013
|
-
return (prototype, key, descriptor) => {
|
|
1014
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
1015
|
-
metadataMap.set(key, {
|
|
1016
|
-
returns,
|
|
1017
|
-
signalOption,
|
|
1018
|
-
key,
|
|
1019
|
-
descriptor,
|
|
1020
|
-
guards: [allow, ...guards],
|
|
1021
|
-
type: "Message"
|
|
1022
|
-
});
|
|
1023
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
1024
|
-
};
|
|
1025
|
-
};
|
|
1026
|
-
var getPubsub = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
1027
|
-
return (prototype, key, descriptor) => {
|
|
1028
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
1029
|
-
metadataMap.set(key, {
|
|
1030
|
-
returns,
|
|
1031
|
-
signalOption,
|
|
1032
|
-
key,
|
|
1033
|
-
descriptor,
|
|
1034
|
-
guards: [allow, ...guards],
|
|
1035
|
-
type: "Pubsub"
|
|
1036
|
-
});
|
|
1037
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
1038
|
-
};
|
|
1039
|
-
};
|
|
1040
|
-
var getProcess = (serverType) => function(returns, signalOption = {}) {
|
|
1041
|
-
return (prototype, key, descriptor) => {
|
|
1042
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
1043
|
-
metadataMap.set(key, {
|
|
1044
|
-
returns,
|
|
1045
|
-
signalOption: { ...signalOption, serverType: lowerlize(serverType) },
|
|
1046
|
-
key,
|
|
1047
|
-
descriptor,
|
|
1048
|
-
guards: ["None"],
|
|
1049
|
-
type: "Process"
|
|
1050
|
-
});
|
|
1051
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
1052
|
-
};
|
|
1053
|
-
};
|
|
1054
|
-
var Query = {
|
|
1055
|
-
Public: getQuery("Public"),
|
|
1056
|
-
Every: getQuery("Every"),
|
|
1057
|
-
Admin: getQuery("Admin"),
|
|
1058
|
-
User: getQuery("User"),
|
|
1059
|
-
SuperAdmin: getQuery("SuperAdmin"),
|
|
1060
|
-
None: getQuery("None"),
|
|
1061
|
-
Owner: getQuery("Owner")
|
|
1062
|
-
};
|
|
1063
|
-
var Mutation = {
|
|
1064
|
-
Public: getMutation("Public"),
|
|
1065
|
-
Every: getMutation("Every"),
|
|
1066
|
-
Admin: getMutation("Admin"),
|
|
1067
|
-
User: getMutation("User"),
|
|
1068
|
-
SuperAdmin: getMutation("SuperAdmin"),
|
|
1069
|
-
None: getMutation("None"),
|
|
1070
|
-
Owner: getMutation("Owner")
|
|
1071
|
-
};
|
|
1072
|
-
var Message = {
|
|
1073
|
-
Public: getMessage("Public"),
|
|
1074
|
-
Every: getMessage("Every"),
|
|
1075
|
-
Admin: getMessage("Admin"),
|
|
1076
|
-
User: getMessage("User"),
|
|
1077
|
-
SuperAdmin: getMessage("SuperAdmin"),
|
|
1078
|
-
None: getMessage("None"),
|
|
1079
|
-
Owner: getMessage("Owner")
|
|
1080
|
-
};
|
|
1081
|
-
var Pubsub = {
|
|
1082
|
-
Public: getPubsub("Public"),
|
|
1083
|
-
Every: getPubsub("Every"),
|
|
1084
|
-
Admin: getPubsub("Admin"),
|
|
1085
|
-
User: getPubsub("User"),
|
|
1086
|
-
SuperAdmin: getPubsub("SuperAdmin"),
|
|
1087
|
-
None: getPubsub("None"),
|
|
1088
|
-
Owner: getPubsub("Owner")
|
|
1089
|
-
};
|
|
1090
|
-
var Process = {
|
|
1091
|
-
Federation: getProcess("Federation"),
|
|
1092
|
-
Batch: getProcess("Batch"),
|
|
1093
|
-
All: getProcess("All")
|
|
1094
|
-
};
|
|
1095
|
-
var getArg = (type) => function(name, returns, argsOption = {}) {
|
|
1096
|
-
return function(prototype, key, idx) {
|
|
1097
|
-
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
1098
|
-
argMetas[idx] = { name, returns, argsOption, key, idx, type };
|
|
1099
|
-
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
1100
|
-
};
|
|
1101
|
-
};
|
|
1102
|
-
var Arg = {
|
|
1103
|
-
Body: getArg("Body"),
|
|
1104
|
-
Param: getArg("Param"),
|
|
1105
|
-
Query: getArg("Query"),
|
|
1106
|
-
Upload: getArg("Upload"),
|
|
1107
|
-
Msg: getArg("Msg"),
|
|
1108
|
-
Room: getArg("Room")
|
|
1109
|
-
};
|
|
1110
|
-
var getGqlMetaMapOnPrototype = (prototype) => {
|
|
1111
|
-
const gqlMetaMap = Reflect.getMetadata("gql", prototype);
|
|
1112
|
-
return gqlMetaMap ?? /* @__PURE__ */ new Map();
|
|
1113
|
-
};
|
|
1114
|
-
var setGqlMetaMapOnPrototype = (prototype, gqlMetaMap) => {
|
|
1115
|
-
Reflect.defineMetadata("gql", gqlMetaMap, prototype);
|
|
1116
|
-
};
|
|
1117
|
-
var getArgMetasOnPrototype = (prototype, key) => {
|
|
1118
|
-
return Reflect.getMetadata("args", prototype, key) ?? [];
|
|
1119
|
-
};
|
|
1120
|
-
var setArgMetasOnPrototype = (prototype, key, argMetas) => {
|
|
1121
|
-
Reflect.defineMetadata("args", argMetas, prototype, key);
|
|
1122
|
-
};
|
|
1123
|
-
|
|
1124
|
-
// pkgs/@akanjs/signal/src/baseFetch.ts
|
|
1125
|
-
var nativeFetch = fetch;
|
|
1126
|
-
var baseFetch = Object.assign(nativeFetch, {
|
|
1127
|
-
client,
|
|
1128
|
-
clone: function(option = {}) {
|
|
1129
|
-
return {
|
|
1130
|
-
...this,
|
|
1131
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
1132
|
-
client: this.client.clone(option)
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
});
|
|
1136
|
-
|
|
1137
287
|
// pkgs/@akanjs/client/src/cookie.ts
|
|
1138
|
-
var
|
|
288
|
+
var import_base3 = require("@akanjs/base");
|
|
289
|
+
var import_common2 = require("@akanjs/common");
|
|
290
|
+
var import_signal = require("@akanjs/signal");
|
|
291
|
+
var import_signal2 = require("@akanjs/signal");
|
|
292
|
+
var import_core = require("@capacitor/core");
|
|
1139
293
|
var import_js_cookie = __toESM(require("js-cookie"));
|
|
1140
294
|
var import_jwt_decode = require("jwt-decode");
|
|
1141
295
|
var import_react2 = __toESM(require("react"));
|
|
1142
296
|
|
|
1143
297
|
// pkgs/@akanjs/client/src/storage.ts
|
|
298
|
+
var import_base2 = require("@akanjs/base");
|
|
1144
299
|
var import_preferences = require("@capacitor/preferences");
|
|
1145
300
|
var storage = {
|
|
1146
301
|
getItem: async (key) => {
|
|
1147
|
-
if (baseClientEnv.side === "server")
|
|
302
|
+
if (import_base2.baseClientEnv.side === "server")
|
|
1148
303
|
return;
|
|
1149
|
-
if (baseClientEnv.renderMode === "ssr")
|
|
304
|
+
if (import_base2.baseClientEnv.renderMode === "ssr")
|
|
1150
305
|
return localStorage.getItem(key);
|
|
1151
306
|
else
|
|
1152
307
|
return (await import_preferences.Preferences.get({ key })).value;
|
|
1153
308
|
},
|
|
1154
309
|
setItem: async (key, value) => {
|
|
1155
|
-
if (baseClientEnv.side === "server")
|
|
310
|
+
if (import_base2.baseClientEnv.side === "server")
|
|
1156
311
|
return;
|
|
1157
|
-
if (baseClientEnv.renderMode === "ssr") {
|
|
312
|
+
if (import_base2.baseClientEnv.renderMode === "ssr") {
|
|
1158
313
|
localStorage.setItem(key, value);
|
|
1159
314
|
return;
|
|
1160
315
|
} else {
|
|
@@ -1163,9 +318,9 @@ var storage = {
|
|
|
1163
318
|
}
|
|
1164
319
|
},
|
|
1165
320
|
removeItem: (key) => {
|
|
1166
|
-
if (baseClientEnv.side === "server")
|
|
321
|
+
if (import_base2.baseClientEnv.side === "server")
|
|
1167
322
|
return;
|
|
1168
|
-
if (baseClientEnv.renderMode === "ssr") {
|
|
323
|
+
if (import_base2.baseClientEnv.renderMode === "ssr") {
|
|
1169
324
|
localStorage.removeItem(key);
|
|
1170
325
|
return;
|
|
1171
326
|
} else
|
|
@@ -1174,7 +329,7 @@ var storage = {
|
|
|
1174
329
|
};
|
|
1175
330
|
|
|
1176
331
|
// pkgs/@akanjs/client/src/cookie.ts
|
|
1177
|
-
var cookies = baseClientEnv.side === "server" ? () => {
|
|
332
|
+
var cookies = import_base3.baseClientEnv.side === "server" ? () => {
|
|
1178
333
|
const nextHeaders = require("next/headers");
|
|
1179
334
|
const cookies2 = nextHeaders.cookies();
|
|
1180
335
|
return import_react2.default.use(cookies2);
|
|
@@ -1191,35 +346,35 @@ var cookies = baseClientEnv.side === "server" ? () => {
|
|
|
1191
346
|
);
|
|
1192
347
|
};
|
|
1193
348
|
var setCookie = (key, value, options = { path: "/", sameSite: "none", secure: true }) => {
|
|
1194
|
-
if (baseClientEnv.side === "server")
|
|
349
|
+
if (import_base3.baseClientEnv.side === "server")
|
|
1195
350
|
return;
|
|
1196
351
|
else
|
|
1197
|
-
void
|
|
352
|
+
void import_core.CapacitorCookies.setCookie({ key, value });
|
|
1198
353
|
};
|
|
1199
354
|
var getCookie = (key) => {
|
|
1200
|
-
if (baseClientEnv.side === "server")
|
|
355
|
+
if (import_base3.baseClientEnv.side === "server")
|
|
1201
356
|
return cookies().get(key)?.value;
|
|
1202
357
|
else
|
|
1203
358
|
return document.cookie.split(";").find((c) => c.trim().startsWith(`${key}=`))?.split("=")[1];
|
|
1204
359
|
};
|
|
1205
360
|
var removeCookie = (key, options = { path: "/" }) => {
|
|
1206
|
-
if (baseClientEnv.side === "server")
|
|
361
|
+
if (import_base3.baseClientEnv.side === "server")
|
|
1207
362
|
return cookies().delete(key);
|
|
1208
363
|
else {
|
|
1209
364
|
document.cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
|
|
1210
365
|
}
|
|
1211
366
|
};
|
|
1212
|
-
var headers = baseClientEnv.side === "server" ? () => import_react2.default.use(require("next/headers").headers()) : () => /* @__PURE__ */ new Map();
|
|
367
|
+
var headers = import_base3.baseClientEnv.side === "server" ? () => import_react2.default.use(require("next/headers").headers()) : () => /* @__PURE__ */ new Map();
|
|
1213
368
|
var getHeader = (key) => {
|
|
1214
369
|
return headers().get(key);
|
|
1215
370
|
};
|
|
1216
371
|
var getAccount = () => {
|
|
1217
372
|
const jwt = getCookie("jwt") ?? getHeader("jwt");
|
|
1218
373
|
if (!jwt)
|
|
1219
|
-
return defaultAccount;
|
|
374
|
+
return import_signal2.defaultAccount;
|
|
1220
375
|
const account = (0, import_jwt_decode.jwtDecode)(jwt);
|
|
1221
|
-
if (account.appName !== baseEnv.appName || account.environment !== baseEnv.environment)
|
|
1222
|
-
return defaultAccount;
|
|
376
|
+
if (account.appName !== import_base3.baseEnv.appName || account.environment !== import_base3.baseEnv.environment)
|
|
377
|
+
return import_signal2.defaultAccount;
|
|
1223
378
|
return account;
|
|
1224
379
|
};
|
|
1225
380
|
function getMe(option) {
|
|
@@ -1227,7 +382,7 @@ function getMe(option) {
|
|
|
1227
382
|
if (!me && option) {
|
|
1228
383
|
if (option.unauthorize === "notFound")
|
|
1229
384
|
router.notFound();
|
|
1230
|
-
else if (baseClientEnv.side === "client")
|
|
385
|
+
else if (import_base3.baseClientEnv.side === "client")
|
|
1231
386
|
router.replace(option.unauthorize);
|
|
1232
387
|
else
|
|
1233
388
|
import_react2.default.use(router.redirect(option.unauthorize));
|
|
@@ -1239,7 +394,7 @@ function getSelf(option) {
|
|
|
1239
394
|
if (!self && option) {
|
|
1240
395
|
if (option.unauthorize === "notFound")
|
|
1241
396
|
router.notFound();
|
|
1242
|
-
else if (baseClientEnv.side === "client")
|
|
397
|
+
else if (import_base3.baseClientEnv.side === "client")
|
|
1243
398
|
router.replace(option.unauthorize);
|
|
1244
399
|
else
|
|
1245
400
|
import_react2.default.use(router.redirect(option.unauthorize));
|
|
@@ -1247,7 +402,7 @@ function getSelf(option) {
|
|
|
1247
402
|
return self;
|
|
1248
403
|
}
|
|
1249
404
|
var setAuth = ({ jwt }) => {
|
|
1250
|
-
client.setJwt(jwt);
|
|
405
|
+
import_signal.client.setJwt(jwt);
|
|
1251
406
|
setCookie("jwt", jwt);
|
|
1252
407
|
void storage.setItem("jwt", jwt);
|
|
1253
408
|
};
|
|
@@ -1255,11 +410,11 @@ var initAuth = ({ jwt } = {}) => {
|
|
|
1255
410
|
const token = jwt ?? cookies().get("jwt")?.value;
|
|
1256
411
|
if (token)
|
|
1257
412
|
setAuth({ jwt: token });
|
|
1258
|
-
client.init();
|
|
1259
|
-
Logger.verbose(`JWT set from cookie: ${token}`);
|
|
413
|
+
import_signal.client.init();
|
|
414
|
+
import_common2.Logger.verbose(`JWT set from cookie: ${token}`);
|
|
1260
415
|
};
|
|
1261
416
|
var resetAuth = () => {
|
|
1262
|
-
client.reset();
|
|
417
|
+
import_signal.client.reset();
|
|
1263
418
|
removeCookie("jwt");
|
|
1264
419
|
void storage.removeItem("jwt");
|
|
1265
420
|
};
|
|
@@ -1374,4 +529,3 @@ var device = new Device();
|
|
|
1374
529
|
var createFont = (data) => null;
|
|
1375
530
|
var Nanum_Gothic_Coding = createFont;
|
|
1376
531
|
var Noto_Sans_KR = createFont;
|
|
1377
|
-
//! Nextjs는 환경변수를 build time에 그냥 하드코딩으로 값을 넣어버림. operationMode같은것들 잘 동작안할 수 있음. 추후 수정 필요.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -20,18 +20,12 @@
|
|
|
20
20
|
"@capacitor/haptics": "^7.0.1",
|
|
21
21
|
"@capacitor/keyboard": "^7.0.1",
|
|
22
22
|
"@capacitor/preferences": "^7.0.1",
|
|
23
|
-
"@urql/core": "^5.1.0",
|
|
24
23
|
"capacitor-plugin-safe-area": "^3.0.4",
|
|
25
24
|
"clsx": "^2.1.1",
|
|
26
|
-
"dayjs": "^1.11.13",
|
|
27
|
-
"immer": "^10.1.1",
|
|
28
25
|
"js-cookie": "^3.0.5",
|
|
29
26
|
"jwt-decode": "^4.0.0",
|
|
30
27
|
"next": "^15.3.2",
|
|
31
|
-
"pluralize": "^8.0.0",
|
|
32
28
|
"react": "^18.3.1",
|
|
33
|
-
"react-device-detect": "^2.2.3"
|
|
34
|
-
"reflect-metadata": "^0.2.2",
|
|
35
|
-
"socket.io-client": "^4.8.1"
|
|
29
|
+
"react-device-detect": "^2.2.3"
|
|
36
30
|
}
|
|
37
31
|
}
|