@arcote.tech/arc-adapter-db-postgres 0.4.6 → 0.4.9
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/index.js +67 -52
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1354,14 +1354,23 @@ var TOKEN_PREFIX = "arc:token:";
|
|
|
1354
1354
|
function hasLocalStorage() {
|
|
1355
1355
|
return typeof localStorage !== "undefined";
|
|
1356
1356
|
}
|
|
1357
|
+
function notifyTokenChange(scope) {
|
|
1358
|
+
if (typeof window !== "undefined") {
|
|
1359
|
+
queueMicrotask(() => {
|
|
1360
|
+
window.dispatchEvent(new CustomEvent("arc:token-change", { detail: { scope } }));
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1357
1364
|
|
|
1358
1365
|
class AuthAdapter {
|
|
1359
1366
|
scopes = new Map;
|
|
1360
1367
|
setToken(token, scope = "default") {
|
|
1361
1368
|
if (!token) {
|
|
1362
1369
|
this.scopes.delete(scope);
|
|
1363
|
-
if (hasLocalStorage())
|
|
1370
|
+
if (hasLocalStorage()) {
|
|
1364
1371
|
localStorage.removeItem(TOKEN_PREFIX + scope);
|
|
1372
|
+
notifyTokenChange(scope);
|
|
1373
|
+
}
|
|
1365
1374
|
return;
|
|
1366
1375
|
}
|
|
1367
1376
|
try {
|
|
@@ -1382,8 +1391,10 @@ class AuthAdapter {
|
|
|
1382
1391
|
exp: payload.exp
|
|
1383
1392
|
}
|
|
1384
1393
|
});
|
|
1385
|
-
if (hasLocalStorage())
|
|
1394
|
+
if (hasLocalStorage()) {
|
|
1386
1395
|
localStorage.setItem(TOKEN_PREFIX + scope, token);
|
|
1396
|
+
notifyTokenChange(scope);
|
|
1397
|
+
}
|
|
1387
1398
|
} catch {
|
|
1388
1399
|
this.scopes.delete(scope);
|
|
1389
1400
|
if (hasLocalStorage())
|
|
@@ -2439,38 +2450,6 @@ class ArcPrimitive extends ArcAbstract {
|
|
|
2439
2450
|
return value;
|
|
2440
2451
|
}
|
|
2441
2452
|
}
|
|
2442
|
-
|
|
2443
|
-
class ArcBoolean extends ArcPrimitive {
|
|
2444
|
-
hasToBeTrue() {
|
|
2445
|
-
return this.validation("hasToBeTrue", (value) => {
|
|
2446
|
-
if (!value)
|
|
2447
|
-
return {
|
|
2448
|
-
current: value
|
|
2449
|
-
};
|
|
2450
|
-
});
|
|
2451
|
-
}
|
|
2452
|
-
validation(name, validator) {
|
|
2453
|
-
const instance = this.pipeValidation(name, validator);
|
|
2454
|
-
return instance;
|
|
2455
|
-
}
|
|
2456
|
-
toJsonSchema() {
|
|
2457
|
-
const schema = { type: "boolean" };
|
|
2458
|
-
if (this._description) {
|
|
2459
|
-
schema.description = this._description;
|
|
2460
|
-
}
|
|
2461
|
-
return schema;
|
|
2462
|
-
}
|
|
2463
|
-
getColumnData() {
|
|
2464
|
-
const storeData = this.getStoreData();
|
|
2465
|
-
return {
|
|
2466
|
-
type: "boolean",
|
|
2467
|
-
storeData: {
|
|
2468
|
-
...storeData,
|
|
2469
|
-
isNullable: false
|
|
2470
|
-
}
|
|
2471
|
-
};
|
|
2472
|
-
}
|
|
2473
|
-
}
|
|
2474
2453
|
var stringValidator = typeValidatorBuilder("string");
|
|
2475
2454
|
|
|
2476
2455
|
class ArcString extends ArcPrimitive {
|
|
@@ -2622,6 +2601,60 @@ class ArcString extends ArcPrimitive {
|
|
|
2622
2601
|
function string() {
|
|
2623
2602
|
return new ArcString;
|
|
2624
2603
|
}
|
|
2604
|
+
|
|
2605
|
+
class ArcFragmentBase {
|
|
2606
|
+
is(type) {
|
|
2607
|
+
return this.types.includes(type);
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2611
|
+
class ArcContextElement extends ArcFragmentBase {
|
|
2612
|
+
name;
|
|
2613
|
+
types = ["context-element"];
|
|
2614
|
+
get id() {
|
|
2615
|
+
return this.name;
|
|
2616
|
+
}
|
|
2617
|
+
constructor(name) {
|
|
2618
|
+
super();
|
|
2619
|
+
this.name = name;
|
|
2620
|
+
}
|
|
2621
|
+
_seeds;
|
|
2622
|
+
getSeeds() {
|
|
2623
|
+
return this._seeds;
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
class ArcBoolean extends ArcPrimitive {
|
|
2628
|
+
hasToBeTrue() {
|
|
2629
|
+
return this.validation("hasToBeTrue", (value) => {
|
|
2630
|
+
if (!value)
|
|
2631
|
+
return {
|
|
2632
|
+
current: value
|
|
2633
|
+
};
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
validation(name, validator) {
|
|
2637
|
+
const instance = this.pipeValidation(name, validator);
|
|
2638
|
+
return instance;
|
|
2639
|
+
}
|
|
2640
|
+
toJsonSchema() {
|
|
2641
|
+
const schema = { type: "boolean" };
|
|
2642
|
+
if (this._description) {
|
|
2643
|
+
schema.description = this._description;
|
|
2644
|
+
}
|
|
2645
|
+
return schema;
|
|
2646
|
+
}
|
|
2647
|
+
getColumnData() {
|
|
2648
|
+
const storeData = this.getStoreData();
|
|
2649
|
+
return {
|
|
2650
|
+
type: "boolean",
|
|
2651
|
+
storeData: {
|
|
2652
|
+
...storeData,
|
|
2653
|
+
isNullable: false
|
|
2654
|
+
}
|
|
2655
|
+
};
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2625
2658
|
class ArcId extends ArcBranded {
|
|
2626
2659
|
generateFn;
|
|
2627
2660
|
constructor(name, generateFn) {
|
|
@@ -2691,24 +2724,6 @@ class ArcNumber extends ArcPrimitive {
|
|
|
2691
2724
|
};
|
|
2692
2725
|
}
|
|
2693
2726
|
}
|
|
2694
|
-
class ArcFragmentBase {
|
|
2695
|
-
is(type) {
|
|
2696
|
-
return this.types.includes(type);
|
|
2697
|
-
}
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
|
-
class ArcContextElement extends ArcFragmentBase {
|
|
2701
|
-
name;
|
|
2702
|
-
types = ["context-element"];
|
|
2703
|
-
get id() {
|
|
2704
|
-
return this.name;
|
|
2705
|
-
}
|
|
2706
|
-
constructor(name) {
|
|
2707
|
-
super();
|
|
2708
|
-
this.name = name;
|
|
2709
|
-
}
|
|
2710
|
-
}
|
|
2711
|
-
|
|
2712
2727
|
class ArcEvent extends ArcContextElement {
|
|
2713
2728
|
data;
|
|
2714
2729
|
eventId = id("event");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-adapter-db-postgres",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"postgres": "^3.4.4"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@arcote.tech/arc": "^0.4.
|
|
26
|
+
"@arcote.tech/arc": "^0.4.9"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/pg": "^8.11.0",
|