@aglyn/tenant-feature-instance 1.20.3 → 1.21.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/package.json +7 -7
- package/src/lib/hooks/use-seed-draft.d.ts +50 -0
- package/src/lib/hooks/use-seed-draft.js +135 -0
- package/src/lib/hooks/use-seed-draft.js.map +1 -0
- package/src/lib/hooks/use-seed-edits.d.ts +84 -0
- package/src/lib/hooks/use-seed-edits.js +188 -0
- package/src/lib/hooks/use-seed-edits.js.map +1 -0
- package/src/lib/tenant.d.ts +1 -0
- package/src/lib/tenant.js +1 -0
- package/src/lib/tenant.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/tenant-feature-instance",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.
|
|
30
|
-
"@aglyn/shared-ui-jsx": "1.
|
|
31
|
-
"@aglyn/shared-util-email": "1.
|
|
32
|
-
"@aglyn/shared-util-http": "1.
|
|
33
|
-
"@aglyn/shared-util-timestamp": "1.
|
|
28
|
+
"@aglyn/aglyn": "1.21.0",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.21.0",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.21.0",
|
|
31
|
+
"@aglyn/shared-util-email": "1.21.0",
|
|
32
|
+
"@aglyn/shared-util-http": "1.21.0",
|
|
33
|
+
"@aglyn/shared-util-timestamp": "1.21.0",
|
|
34
34
|
"@swc/helpers": "0.5.23",
|
|
35
35
|
"lodash-es": "^4.18.1",
|
|
36
36
|
"mobx": "^7.0.5"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A DIALOG'S DRAFT OF A ROW, KEPT AS EDITS OVER THE LIVE ROW (AGL-4047).
|
|
19
|
+
*
|
|
20
|
+
* {@link useSeedEdits} for the editor that opens on one row of a list: an
|
|
21
|
+
* Edit dialog, a drawer. Those used to copy the row into a
|
|
22
|
+
* `useState<Draft | null>` when they opened, which is the copy the hold in
|
|
23
|
+
* `use-seed-edits` warns about: opened from the cache's row, a Save held
|
|
24
|
+
* until the server answered would then write the cache's values for every
|
|
25
|
+
* field nobody touched.
|
|
26
|
+
*
|
|
27
|
+
* This is a drop-in for that `useState`. `setDraft(row)` opens the editor on
|
|
28
|
+
* a row, `setDraft(null)` closes it, and while it is open every
|
|
29
|
+
* `setDraft({ ...draft, name })` records only the keys that moved, as edits.
|
|
30
|
+
* The draft shown is `live(opened)` (the same row as the list has it NOW)
|
|
31
|
+
* with those edits on top, so the server's copy replaces the cache's under
|
|
32
|
+
* everything the person did not change.
|
|
33
|
+
*/
|
|
34
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
35
|
+
import { type SeedEdits } from './use-seed-edits';
|
|
36
|
+
/**
|
|
37
|
+
* The keys of `next` that differ from `values`, as an edit: for an editor
|
|
38
|
+
* that builds its whole next draft, to hand `useSeedEdits`' `edit` only what
|
|
39
|
+
* moved, so every other key keeps following the seed.
|
|
40
|
+
*/
|
|
41
|
+
export declare function seedEditsBetween<T extends object>(values: T, next: T): Partial<T>;
|
|
42
|
+
/**
|
|
43
|
+
* @param live The opened row as the list has it now, in the draft's shape,
|
|
44
|
+
* or `undefined` when the list no longer holds it (a new row, or one
|
|
45
|
+
* paged out of the window). Undefined keeps the row as it was opened.
|
|
46
|
+
* @returns `[draft, setDraft, form]`: the first two exactly as
|
|
47
|
+
* `useState<T | null>(null)` gives them, and the edits underneath.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useSeedDraft<T extends object>(live: (opened: T) => T | undefined): [T | null, Dispatch<SetStateAction<T | null>>, SeedEdits<T>];
|
|
50
|
+
export default useSeedDraft;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
/**
|
|
19
|
+
* A DIALOG'S DRAFT OF A ROW, KEPT AS EDITS OVER THE LIVE ROW (AGL-4047).
|
|
20
|
+
*
|
|
21
|
+
* {@link useSeedEdits} for the editor that opens on one row of a list: an
|
|
22
|
+
* Edit dialog, a drawer. Those used to copy the row into a
|
|
23
|
+
* `useState<Draft | null>` when they opened, which is the copy the hold in
|
|
24
|
+
* `use-seed-edits` warns about: opened from the cache's row, a Save held
|
|
25
|
+
* until the server answered would then write the cache's values for every
|
|
26
|
+
* field nobody touched.
|
|
27
|
+
*
|
|
28
|
+
* This is a drop-in for that `useState`. `setDraft(row)` opens the editor on
|
|
29
|
+
* a row, `setDraft(null)` closes it, and while it is open every
|
|
30
|
+
* `setDraft({ ...draft, name })` records only the keys that moved, as edits.
|
|
31
|
+
* The draft shown is `live(opened)` (the same row as the list has it NOW)
|
|
32
|
+
* with those edits on top, so the server's copy replaces the cache's under
|
|
33
|
+
* everything the person did not change.
|
|
34
|
+
*/ import { useCallback, useRef, useState } from "react";
|
|
35
|
+
import { useSeedEdits } from "./use-seed-edits.js";
|
|
36
|
+
const CLOSED = Object.freeze({});
|
|
37
|
+
function keyOf(seed) {
|
|
38
|
+
try {
|
|
39
|
+
var _JSON_stringify;
|
|
40
|
+
return (_JSON_stringify = JSON.stringify(seed)) != null ? _JSON_stringify : '';
|
|
41
|
+
} catch (unused) {
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The keys of `next` that differ from `values`, as an edit: for an editor
|
|
47
|
+
* that builds its whole next draft, to hand `useSeedEdits`' `edit` only what
|
|
48
|
+
* moved, so every other key keeps following the seed.
|
|
49
|
+
*/ export function seedEditsBetween(values, next) {
|
|
50
|
+
const patch = {};
|
|
51
|
+
const keys = new Set([
|
|
52
|
+
...Object.keys(values),
|
|
53
|
+
...Object.keys(next)
|
|
54
|
+
]);
|
|
55
|
+
for (const key of keys){
|
|
56
|
+
if (!Object.is(values[key], next[key])) patch[key] = next[key];
|
|
57
|
+
}
|
|
58
|
+
return patch;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @param live The opened row as the list has it now, in the draft's shape,
|
|
62
|
+
* or `undefined` when the list no longer holds it (a new row, or one
|
|
63
|
+
* paged out of the window). Undefined keeps the row as it was opened.
|
|
64
|
+
* @returns `[draft, setDraft, form]`: the first two exactly as
|
|
65
|
+
* `useState<T | null>(null)` gives them, and the edits underneath.
|
|
66
|
+
*/ export function useSeedDraft(live) {
|
|
67
|
+
var _live;
|
|
68
|
+
const [opened, setOpened] = useState(null);
|
|
69
|
+
const fresh = opened ? (_live = live(opened)) != null ? _live : opened : CLOSED;
|
|
70
|
+
/*
|
|
71
|
+
* `live` builds a new object on every render. Kept while it says the same
|
|
72
|
+
* thing, so the draft handed to a memoized editor keeps its identity until
|
|
73
|
+
* a keystroke or the server actually changes it.
|
|
74
|
+
*/ const stable = useRef(null);
|
|
75
|
+
const freshKey = keyOf(fresh);
|
|
76
|
+
// A row that cannot be written as JSON is never taken for unchanged.
|
|
77
|
+
if (!stable.current || !freshKey || stable.current.key !== freshKey) {
|
|
78
|
+
stable.current = {
|
|
79
|
+
key: freshKey,
|
|
80
|
+
seed: fresh
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const seed = stable.current.seed;
|
|
84
|
+
const form = useSeedEdits(seed);
|
|
85
|
+
const draft = opened ? form.values : null;
|
|
86
|
+
/*
|
|
87
|
+
* What the draft is as of the last call, so two calls in one handler (and
|
|
88
|
+
* the updater form) each build on the one before rather than on the
|
|
89
|
+
* render's copy.
|
|
90
|
+
*/ const current = useRef({
|
|
91
|
+
opened,
|
|
92
|
+
draft
|
|
93
|
+
});
|
|
94
|
+
current.current = {
|
|
95
|
+
opened,
|
|
96
|
+
draft
|
|
97
|
+
};
|
|
98
|
+
const { edit, discard } = form;
|
|
99
|
+
const setDraft = useCallback((action)=>{
|
|
100
|
+
const next = typeof action === 'function' ? action(current.current.draft) : action;
|
|
101
|
+
if (next === null) {
|
|
102
|
+
current.current = {
|
|
103
|
+
opened: null,
|
|
104
|
+
draft: null
|
|
105
|
+
};
|
|
106
|
+
setOpened(null);
|
|
107
|
+
discard();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (!current.current.opened) {
|
|
111
|
+
current.current = {
|
|
112
|
+
opened: next,
|
|
113
|
+
draft: next
|
|
114
|
+
};
|
|
115
|
+
setOpened(next);
|
|
116
|
+
discard();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
current.current = _extends({}, current.current, {
|
|
120
|
+
draft: next
|
|
121
|
+
});
|
|
122
|
+
edit((values)=>seedEditsBetween(values, next));
|
|
123
|
+
}, [
|
|
124
|
+
edit,
|
|
125
|
+
discard
|
|
126
|
+
]);
|
|
127
|
+
return [
|
|
128
|
+
draft,
|
|
129
|
+
setDraft,
|
|
130
|
+
form
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
export default useSeedDraft;
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=use-seed-draft.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/hooks/use-seed-draft.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\n/**\n * A DIALOG'S DRAFT OF A ROW, KEPT AS EDITS OVER THE LIVE ROW (AGL-4047).\n *\n * {@link useSeedEdits} for the editor that opens on one row of a list: an\n * Edit dialog, a drawer. Those used to copy the row into a\n * `useState<Draft | null>` when they opened, which is the copy the hold in\n * `use-seed-edits` warns about: opened from the cache's row, a Save held\n * until the server answered would then write the cache's values for every\n * field nobody touched.\n *\n * This is a drop-in for that `useState`. `setDraft(row)` opens the editor on\n * a row, `setDraft(null)` closes it, and while it is open every\n * `setDraft({ ...draft, name })` records only the keys that moved, as edits.\n * The draft shown is `live(opened)` (the same row as the list has it NOW)\n * with those edits on top, so the server's copy replaces the cache's under\n * everything the person did not change.\n */\n\nimport {\n useCallback,\n useRef,\n useState,\n type Dispatch,\n type SetStateAction,\n} from 'react'\nimport { useSeedEdits, type SeedEdits } from './use-seed-edits'\n\nconst CLOSED = Object.freeze({}) as object\n\nfunction keyOf(seed: object): string {\n try {\n return JSON.stringify(seed) ?? ''\n } catch {\n return ''\n }\n}\n\n/**\n * The keys of `next` that differ from `values`, as an edit: for an editor\n * that builds its whole next draft, to hand `useSeedEdits`' `edit` only what\n * moved, so every other key keeps following the seed.\n */\nexport function seedEditsBetween<T extends object>(\n values: T,\n next: T,\n): Partial<T> {\n const patch: Partial<T> = {}\n const keys = new Set([\n ...Object.keys(values),\n ...Object.keys(next),\n ]) as Set<keyof T>\n for (const key of keys) {\n if (!Object.is(values[key], next[key])) patch[key] = next[key]\n }\n return patch\n}\n\n/**\n * @param live The opened row as the list has it now, in the draft's shape,\n * or `undefined` when the list no longer holds it (a new row, or one\n * paged out of the window). Undefined keeps the row as it was opened.\n * @returns `[draft, setDraft, form]`: the first two exactly as\n * `useState<T | null>(null)` gives them, and the edits underneath.\n */\nexport function useSeedDraft<T extends object>(\n live: (opened: T) => T | undefined,\n): [T | null, Dispatch<SetStateAction<T | null>>, SeedEdits<T>] {\n const [opened, setOpened] = useState<T | null>(null)\n const fresh = opened ? (live(opened) ?? opened) : (CLOSED as T)\n /*\n * `live` builds a new object on every render. Kept while it says the same\n * thing, so the draft handed to a memoized editor keeps its identity until\n * a keystroke or the server actually changes it.\n */\n const stable = useRef<{ key: string; seed: T } | null>(null)\n const freshKey = keyOf(fresh)\n // A row that cannot be written as JSON is never taken for unchanged.\n if (!stable.current || !freshKey || stable.current.key !== freshKey) {\n stable.current = { key: freshKey, seed: fresh }\n }\n const seed = stable.current.seed\n const form = useSeedEdits<T>(seed)\n const draft = opened ? form.values : null\n\n /*\n * What the draft is as of the last call, so two calls in one handler (and\n * the updater form) each build on the one before rather than on the\n * render's copy.\n */\n const current = useRef<{ opened: T | null; draft: T | null }>({\n opened,\n draft,\n })\n current.current = { opened, draft }\n\n const { edit, discard } = form\n const setDraft = useCallback<Dispatch<SetStateAction<T | null>>>(\n (action) => {\n const next =\n typeof action === 'function'\n ? (action as (previous: T | null) => T | null)(current.current.draft)\n : action\n if (next === null) {\n current.current = { opened: null, draft: null }\n setOpened(null)\n discard()\n return\n }\n if (!current.current.opened) {\n current.current = { opened: next, draft: next }\n setOpened(next)\n discard()\n return\n }\n current.current = { ...current.current, draft: next }\n edit((values) => seedEditsBetween(values, next))\n },\n [edit, discard],\n )\n\n return [draft, setDraft, form]\n}\n\nexport default useSeedDraft\n"],"names":["useCallback","useRef","useState","useSeedEdits","CLOSED","Object","freeze","keyOf","seed","JSON","stringify","seedEditsBetween","values","next","patch","keys","Set","key","is","useSeedDraft","live","opened","setOpened","fresh","stable","freshKey","current","form","draft","edit","discard","setDraft","action"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA;;;;;;;;;;;;;;;;CAgBC,GAED,SACEA,WAAW,EACXC,MAAM,EACNC,QAAQ,QAGH,QAAO;AACd,SAASC,YAAY,QAAwB,sBAAkB;AAE/D,MAAMC,SAASC,OAAOC,MAAM,CAAC,CAAC;AAE9B,SAASC,MAAMC,IAAY;IACzB,IAAI;YACKC;QAAP,QAAOA,kBAAAA,KAAKC,SAAS,CAACF,iBAAfC,kBAAwB;IACjC,EAAE,eAAM;QACN,OAAO;IACT;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASE,iBACdC,MAAS,EACTC,IAAO;IAEP,MAAMC,QAAoB,CAAC;IAC3B,MAAMC,OAAO,IAAIC,IAAI;WAChBX,OAAOU,IAAI,CAACH;WACZP,OAAOU,IAAI,CAACF;KAChB;IACD,KAAK,MAAMI,OAAOF,KAAM;QACtB,IAAI,CAACV,OAAOa,EAAE,CAACN,MAAM,CAACK,IAAI,EAAEJ,IAAI,CAACI,IAAI,GAAGH,KAAK,CAACG,IAAI,GAAGJ,IAAI,CAACI,IAAI;IAChE;IACA,OAAOH;AACT;AAEA;;;;;;CAMC,GACD,OAAO,SAASK,aACdC,IAAkC;QAGVA;IADxB,MAAM,CAACC,QAAQC,UAAU,GAAGpB,SAAmB;IAC/C,MAAMqB,QAAQF,UAAUD,QAAAA,KAAKC,mBAALD,QAAgBC,SAAWjB;IACnD;;;;GAIC,GACD,MAAMoB,SAASvB,OAAwC;IACvD,MAAMwB,WAAWlB,MAAMgB;IACvB,qEAAqE;IACrE,IAAI,CAACC,OAAOE,OAAO,IAAI,CAACD,YAAYD,OAAOE,OAAO,CAACT,GAAG,KAAKQ,UAAU;QACnED,OAAOE,OAAO,GAAG;YAAET,KAAKQ;YAAUjB,MAAMe;QAAM;IAChD;IACA,MAAMf,OAAOgB,OAAOE,OAAO,CAAClB,IAAI;IAChC,MAAMmB,OAAOxB,aAAgBK;IAC7B,MAAMoB,QAAQP,SAASM,KAAKf,MAAM,GAAG;IAErC;;;;GAIC,GACD,MAAMc,UAAUzB,OAA8C;QAC5DoB;QACAO;IACF;IACAF,QAAQA,OAAO,GAAG;QAAEL;QAAQO;IAAM;IAElC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGH;IAC1B,MAAMI,WAAW/B,YACf,CAACgC;QACC,MAAMnB,OACJ,OAAOmB,WAAW,aACd,AAACA,OAA4CN,QAAQA,OAAO,CAACE,KAAK,IAClEI;QACN,IAAInB,SAAS,MAAM;YACjBa,QAAQA,OAAO,GAAG;gBAAEL,QAAQ;gBAAMO,OAAO;YAAK;YAC9CN,UAAU;YACVQ;YACA;QACF;QACA,IAAI,CAACJ,QAAQA,OAAO,CAACL,MAAM,EAAE;YAC3BK,QAAQA,OAAO,GAAG;gBAAEL,QAAQR;gBAAMe,OAAOf;YAAK;YAC9CS,UAAUT;YACViB;YACA;QACF;QACAJ,QAAQA,OAAO,GAAG,aAAKA,QAAQA,OAAO;YAAEE,OAAOf;;QAC/CgB,KAAK,CAACjB,SAAWD,iBAAiBC,QAAQC;IAC5C,GACA;QAACgB;QAAMC;KAAQ;IAGjB,OAAO;QAACF;QAAOG;QAAUJ;KAAK;AAChC;AAEA,eAAeR,aAAY"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Whether a save seeded from this read should be HELD rather than pressed.
|
|
19
|
+
*
|
|
20
|
+
* Unconfirmed, and not failed: a failed read is left to the guard, whose
|
|
21
|
+
* refusal says the values could not be loaded, which no wait would change.
|
|
22
|
+
* The same two flags the call site hands `writeGuardedBySeed`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isSeedChecking(read: {
|
|
25
|
+
fromCache?: boolean;
|
|
26
|
+
unreadable?: boolean;
|
|
27
|
+
}): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* What a held Save says beside it, so a held control is never unexplained.
|
|
30
|
+
* Takes the same `subject` as the guard ("profile", "language settings") and,
|
|
31
|
+
* like the guard's refusals, reads right for a plural one (AGL-1446).
|
|
32
|
+
*/
|
|
33
|
+
export declare function seedCheckingText(subject: string): string;
|
|
34
|
+
export interface SeedEdits<T extends object> {
|
|
35
|
+
/** The seed with the person's edits on top. What the form shows and saves. */
|
|
36
|
+
values: T;
|
|
37
|
+
/**
|
|
38
|
+
* The edits in force: unsaved ones, plus the ones a save just wrote until
|
|
39
|
+
* the seed shows them. For a form whose display reads which keys were
|
|
40
|
+
* touched rather than only the merged values.
|
|
41
|
+
*/
|
|
42
|
+
edits: Partial<T>;
|
|
43
|
+
/** Something is typed that has not been saved. */
|
|
44
|
+
dirty: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Record edits. A function receives the current values, for an edit that
|
|
47
|
+
* derives from them.
|
|
48
|
+
*/
|
|
49
|
+
edit: (patch: Partial<T> | ((values: T) => Partial<T>)) => void;
|
|
50
|
+
/** Take back the edit to these keys, so they follow the seed again. */
|
|
51
|
+
revert: (...keys: (keyof T)[]) => void;
|
|
52
|
+
/**
|
|
53
|
+
* The save landed. The edits it wrote stop being unsaved, and stay applied
|
|
54
|
+
* until the seed moves, so the form never flashes back to the values before
|
|
55
|
+
* the save. Pass what the save wrote (`edits` when it began) so a key typed
|
|
56
|
+
* again while the save was in flight stays unsaved; without it, every edit
|
|
57
|
+
* in force now counts as written.
|
|
58
|
+
*/
|
|
59
|
+
settle: (written?: Partial<T>) => void;
|
|
60
|
+
/** Throw every unsaved edit away. */
|
|
61
|
+
discard: () => void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A form's edits, kept as edits and replayed onto the seed on every render
|
|
65
|
+
* rather than copied from it once (AGL-4047).
|
|
66
|
+
*
|
|
67
|
+
* Edits are per top-level key. A key the person never touched always shows
|
|
68
|
+
* what the seed says NOW, so a confirmation that changes it is reflected, and
|
|
69
|
+
* a save writes it; a key they did touch keeps their value through any number
|
|
70
|
+
* of snapshots.
|
|
71
|
+
*/
|
|
72
|
+
export declare function useSeedEdits<T extends object>(seed: T): SeedEdits<T>;
|
|
73
|
+
export default useSeedEdits;
|
|
74
|
+
/**
|
|
75
|
+
* The rule {@link useSeedEdits} keeps, for a form that already holds its own
|
|
76
|
+
* buffer and seeds it once (AGL-4047).
|
|
77
|
+
*
|
|
78
|
+
* A key whose value still equals what the previous seed said is UNTOUCHED, so
|
|
79
|
+
* it follows the next seed; a key the person changed keeps their value. Hand it
|
|
80
|
+
* the seed the buffer was built from, the buffer as it stands, and the seed
|
|
81
|
+
* that just arrived, and store the result with the next seed as the new
|
|
82
|
+
* baseline. Compared by content, since a snapshot rebuilds every value.
|
|
83
|
+
*/
|
|
84
|
+
export declare function rebaseSeedEdits<T extends object>(previousSeed: T, current: T, nextSeed: T): T;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
/**
|
|
19
|
+
* A FORM SAVE IS NEVER REFUSED ON ITS FIRST PRESS JUST BECAUSE THE SERVER IS
|
|
20
|
+
* LATE (AGL-4047).
|
|
21
|
+
*
|
|
22
|
+
* `writeGuardedBySeed` waits for the server to confirm a cache-served seed
|
|
23
|
+
* before it writes (AGL-4120), and refuses with "We could not confirm your …
|
|
24
|
+
* with the server yet" when that wait runs past its deadline. Right after a
|
|
25
|
+
* page load on the shared cache the wait routinely ran past it, so the first
|
|
26
|
+
* press of Save was refused and the second, a few seconds later, saved.
|
|
27
|
+
*
|
|
28
|
+
* The fix has two halves, and a surface needs both:
|
|
29
|
+
*
|
|
30
|
+
* 1. HOLD SAVE while the seed is unconfirmed, with the reason beside it
|
|
31
|
+
* ({@link isSeedChecking}, {@link seedCheckingText}). The press then comes
|
|
32
|
+
* after the server answers, when the guard writes at once. The guard still
|
|
33
|
+
* wraps the write, for a read that falls back to the cache after the
|
|
34
|
+
* surface rendered.
|
|
35
|
+
* 2. KEEP THE EDITS AS EDITS ({@link useSeedEdits}), replayed onto whatever the
|
|
36
|
+
* seed is now. Without this, holding Save is a trap: a form that copied the
|
|
37
|
+
* cached values into its own state when they arrived would, once the server
|
|
38
|
+
* confirmed different ones, save the cached values for every field the
|
|
39
|
+
* person never touched, which is the loss the guard exists to stop. A form
|
|
40
|
+
* that reset itself on every snapshot would instead drop what was typed.
|
|
41
|
+
*
|
|
42
|
+
* Forms on `final-form` get the second half from `keepDirtyOnReinitialize`,
|
|
43
|
+
* which is the same rule: a field the person changed keeps their value, every
|
|
44
|
+
* other field follows the new seed.
|
|
45
|
+
*
|
|
46
|
+
* First built for a site's Admin › Plugins (#2552); this is that pattern
|
|
47
|
+
* lifted so every guarded form can share it.
|
|
48
|
+
*/ import { useCallback, useMemo, useRef, useState } from "react";
|
|
49
|
+
/**
|
|
50
|
+
* Whether a save seeded from this read should be HELD rather than pressed.
|
|
51
|
+
*
|
|
52
|
+
* Unconfirmed, and not failed: a failed read is left to the guard, whose
|
|
53
|
+
* refusal says the values could not be loaded, which no wait would change.
|
|
54
|
+
* The same two flags the call site hands `writeGuardedBySeed`.
|
|
55
|
+
*/ export function isSeedChecking(read) {
|
|
56
|
+
return Boolean(read.fromCache) && !read.unreadable;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* What a held Save says beside it, so a held control is never unexplained.
|
|
60
|
+
* Takes the same `subject` as the guard ("profile", "language settings") and,
|
|
61
|
+
* like the guard's refusals, reads right for a plural one (AGL-1446).
|
|
62
|
+
*/ export function seedCheckingText(subject) {
|
|
63
|
+
return `Checking your ${subject} with the server…`;
|
|
64
|
+
}
|
|
65
|
+
function seedKeyOf(seed) {
|
|
66
|
+
try {
|
|
67
|
+
var _JSON_stringify;
|
|
68
|
+
return (_JSON_stringify = JSON.stringify(seed)) != null ? _JSON_stringify : '';
|
|
69
|
+
} catch (unused) {
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A form's edits, kept as edits and replayed onto the seed on every render
|
|
75
|
+
* rather than copied from it once (AGL-4047).
|
|
76
|
+
*
|
|
77
|
+
* Edits are per top-level key. A key the person never touched always shows
|
|
78
|
+
* what the seed says NOW, so a confirmation that changes it is reflected, and
|
|
79
|
+
* a save writes it; a key they did touch keeps their value through any number
|
|
80
|
+
* of snapshots.
|
|
81
|
+
*/ export function useSeedEdits(seed) {
|
|
82
|
+
const [edits, setEdits] = useState({});
|
|
83
|
+
/**
|
|
84
|
+
* What a save just wrote, held against the seed it was written over. The
|
|
85
|
+
* seed normally moves at once, because a local write reaches the cache
|
|
86
|
+
* before the server acknowledges it; this covers the case where it has not.
|
|
87
|
+
*/ const [saved, setSaved] = useState(null);
|
|
88
|
+
const seedKey = seedKeyOf(seed);
|
|
89
|
+
// Dropped the moment the seed moves, so a later change back to the values
|
|
90
|
+
// as they stood before the save is shown as it is, not hidden behind it.
|
|
91
|
+
if (saved && saved.key !== seedKey) setSaved(null);
|
|
92
|
+
const applied = useMemo(()=>saved && saved.key === seedKey ? _extends({}, saved.edits, edits) : edits, [
|
|
93
|
+
saved,
|
|
94
|
+
seedKey,
|
|
95
|
+
edits
|
|
96
|
+
]);
|
|
97
|
+
const values = useMemo(()=>_extends({}, seed, applied), [
|
|
98
|
+
seed,
|
|
99
|
+
applied
|
|
100
|
+
]);
|
|
101
|
+
// Read by `edit`'s updater form and `settle`, which must see what is on
|
|
102
|
+
// screen at the call without re-creating the callbacks on every keystroke.
|
|
103
|
+
const latest = useRef({
|
|
104
|
+
seed,
|
|
105
|
+
seedKey,
|
|
106
|
+
applied
|
|
107
|
+
});
|
|
108
|
+
latest.current = {
|
|
109
|
+
seed,
|
|
110
|
+
seedKey,
|
|
111
|
+
applied
|
|
112
|
+
};
|
|
113
|
+
const edit = useCallback((patch)=>{
|
|
114
|
+
setEdits((current)=>{
|
|
115
|
+
const next = typeof patch === 'function' ? patch(_extends({}, latest.current.seed, latest.current.applied, current)) : patch;
|
|
116
|
+
return _extends({}, current, next);
|
|
117
|
+
});
|
|
118
|
+
}, []);
|
|
119
|
+
const revert = useCallback((...keys)=>{
|
|
120
|
+
setEdits((current)=>{
|
|
121
|
+
const next = _extends({}, current);
|
|
122
|
+
for (const key of keys)delete next[key];
|
|
123
|
+
return next;
|
|
124
|
+
});
|
|
125
|
+
setSaved((current)=>{
|
|
126
|
+
if (!current) return current;
|
|
127
|
+
const next = _extends({}, current.edits);
|
|
128
|
+
for (const key of keys)delete next[key];
|
|
129
|
+
return _extends({}, current, {
|
|
130
|
+
edits: next
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}, []);
|
|
134
|
+
const settle = useCallback((written)=>{
|
|
135
|
+
const wrote = written != null ? written : latest.current.applied;
|
|
136
|
+
setSaved({
|
|
137
|
+
key: latest.current.seedKey,
|
|
138
|
+
edits: wrote
|
|
139
|
+
});
|
|
140
|
+
setEdits((current)=>{
|
|
141
|
+
const next = {};
|
|
142
|
+
for (const key of Object.keys(current)){
|
|
143
|
+
if (!(key in wrote) || !Object.is(current[key], wrote[key])) {
|
|
144
|
+
next[key] = current[key];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return next;
|
|
148
|
+
});
|
|
149
|
+
}, []);
|
|
150
|
+
const discard = useCallback(()=>{
|
|
151
|
+
setSaved(null);
|
|
152
|
+
setEdits({});
|
|
153
|
+
}, []);
|
|
154
|
+
return {
|
|
155
|
+
values,
|
|
156
|
+
edits: applied,
|
|
157
|
+
dirty: Object.keys(edits).length > 0,
|
|
158
|
+
edit,
|
|
159
|
+
revert,
|
|
160
|
+
settle,
|
|
161
|
+
discard
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export default useSeedEdits;
|
|
165
|
+
/**
|
|
166
|
+
* The rule {@link useSeedEdits} keeps, for a form that already holds its own
|
|
167
|
+
* buffer and seeds it once (AGL-4047).
|
|
168
|
+
*
|
|
169
|
+
* A key whose value still equals what the previous seed said is UNTOUCHED, so
|
|
170
|
+
* it follows the next seed; a key the person changed keeps their value. Hand it
|
|
171
|
+
* the seed the buffer was built from, the buffer as it stands, and the seed
|
|
172
|
+
* that just arrived, and store the result with the next seed as the new
|
|
173
|
+
* baseline. Compared by content, since a snapshot rebuilds every value.
|
|
174
|
+
*/ export function rebaseSeedEdits(previousSeed, current, nextSeed) {
|
|
175
|
+
const next = _extends({}, nextSeed);
|
|
176
|
+
for (const key of Object.keys(current)){
|
|
177
|
+
if (seedKeyOf({
|
|
178
|
+
v: current[key]
|
|
179
|
+
}) !== seedKeyOf({
|
|
180
|
+
v: previousSeed[key]
|
|
181
|
+
})) {
|
|
182
|
+
next[key] = current[key];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return next;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
//# sourceMappingURL=use-seed-edits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/hooks/use-seed-edits.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\n/**\n * A FORM SAVE IS NEVER REFUSED ON ITS FIRST PRESS JUST BECAUSE THE SERVER IS\n * LATE (AGL-4047).\n *\n * `writeGuardedBySeed` waits for the server to confirm a cache-served seed\n * before it writes (AGL-4120), and refuses with \"We could not confirm your …\n * with the server yet\" when that wait runs past its deadline. Right after a\n * page load on the shared cache the wait routinely ran past it, so the first\n * press of Save was refused and the second, a few seconds later, saved.\n *\n * The fix has two halves, and a surface needs both:\n *\n * 1. HOLD SAVE while the seed is unconfirmed, with the reason beside it\n * ({@link isSeedChecking}, {@link seedCheckingText}). The press then comes\n * after the server answers, when the guard writes at once. The guard still\n * wraps the write, for a read that falls back to the cache after the\n * surface rendered.\n * 2. KEEP THE EDITS AS EDITS ({@link useSeedEdits}), replayed onto whatever the\n * seed is now. Without this, holding Save is a trap: a form that copied the\n * cached values into its own state when they arrived would, once the server\n * confirmed different ones, save the cached values for every field the\n * person never touched, which is the loss the guard exists to stop. A form\n * that reset itself on every snapshot would instead drop what was typed.\n *\n * Forms on `final-form` get the second half from `keepDirtyOnReinitialize`,\n * which is the same rule: a field the person changed keeps their value, every\n * other field follows the new seed.\n *\n * First built for a site's Admin › Plugins (#2552); this is that pattern\n * lifted so every guarded form can share it.\n */\n\nimport { useCallback, useMemo, useRef, useState } from 'react'\n\n/**\n * Whether a save seeded from this read should be HELD rather than pressed.\n *\n * Unconfirmed, and not failed: a failed read is left to the guard, whose\n * refusal says the values could not be loaded, which no wait would change.\n * The same two flags the call site hands `writeGuardedBySeed`.\n */\nexport function isSeedChecking(read: {\n fromCache?: boolean\n unreadable?: boolean\n}): boolean {\n return Boolean(read.fromCache) && !read.unreadable\n}\n\n/**\n * What a held Save says beside it, so a held control is never unexplained.\n * Takes the same `subject` as the guard (\"profile\", \"language settings\") and,\n * like the guard's refusals, reads right for a plural one (AGL-1446).\n */\nexport function seedCheckingText(subject: string): string {\n return `Checking your ${subject} with the server…`\n}\n\nexport interface SeedEdits<T extends object> {\n /** The seed with the person's edits on top. What the form shows and saves. */\n values: T\n /**\n * The edits in force: unsaved ones, plus the ones a save just wrote until\n * the seed shows them. For a form whose display reads which keys were\n * touched rather than only the merged values.\n */\n edits: Partial<T>\n /** Something is typed that has not been saved. */\n dirty: boolean\n /**\n * Record edits. A function receives the current values, for an edit that\n * derives from them.\n */\n edit: (patch: Partial<T> | ((values: T) => Partial<T>)) => void\n /** Take back the edit to these keys, so they follow the seed again. */\n revert: (...keys: (keyof T)[]) => void\n /**\n * The save landed. The edits it wrote stop being unsaved, and stay applied\n * until the seed moves, so the form never flashes back to the values before\n * the save. Pass what the save wrote (`edits` when it began) so a key typed\n * again while the save was in flight stays unsaved; without it, every edit\n * in force now counts as written.\n */\n settle: (written?: Partial<T>) => void\n /** Throw every unsaved edit away. */\n discard: () => void\n}\n\nfunction seedKeyOf(seed: object): string {\n try {\n return JSON.stringify(seed) ?? ''\n } catch {\n return ''\n }\n}\n\n/**\n * A form's edits, kept as edits and replayed onto the seed on every render\n * rather than copied from it once (AGL-4047).\n *\n * Edits are per top-level key. A key the person never touched always shows\n * what the seed says NOW, so a confirmation that changes it is reflected, and\n * a save writes it; a key they did touch keeps their value through any number\n * of snapshots.\n */\nexport function useSeedEdits<T extends object>(seed: T): SeedEdits<T> {\n const [edits, setEdits] = useState<Partial<T>>({})\n /**\n * What a save just wrote, held against the seed it was written over. The\n * seed normally moves at once, because a local write reaches the cache\n * before the server acknowledges it; this covers the case where it has not.\n */\n const [saved, setSaved] = useState<{ key: string; edits: Partial<T> } | null>(\n null,\n )\n const seedKey = seedKeyOf(seed)\n // Dropped the moment the seed moves, so a later change back to the values\n // as they stood before the save is shown as it is, not hidden behind it.\n if (saved && saved.key !== seedKey) setSaved(null)\n\n const applied = useMemo<Partial<T>>(\n () =>\n saved && saved.key === seedKey ? { ...saved.edits, ...edits } : edits,\n [saved, seedKey, edits],\n )\n const values = useMemo<T>(() => ({ ...seed, ...applied }), [seed, applied])\n\n // Read by `edit`'s updater form and `settle`, which must see what is on\n // screen at the call without re-creating the callbacks on every keystroke.\n const latest = useRef({ seed, seedKey, applied })\n latest.current = { seed, seedKey, applied }\n\n const edit = useCallback(\n (patch: Partial<T> | ((values: T) => Partial<T>)) => {\n setEdits((current) => {\n const next =\n typeof patch === 'function'\n ? patch({ ...latest.current.seed, ...latest.current.applied, ...current })\n : patch\n return { ...current, ...next }\n })\n },\n [],\n )\n\n const revert = useCallback((...keys: (keyof T)[]) => {\n setEdits((current) => {\n const next = { ...current }\n for (const key of keys) delete next[key]\n return next\n })\n setSaved((current) => {\n if (!current) return current\n const next = { ...current.edits }\n for (const key of keys) delete next[key]\n return { ...current, edits: next }\n })\n }, [])\n\n const settle = useCallback((written?: Partial<T>) => {\n const wrote = written ?? latest.current.applied\n setSaved({ key: latest.current.seedKey, edits: wrote })\n setEdits((current) => {\n const next: Partial<T> = {}\n for (const key of Object.keys(current) as (keyof T)[]) {\n if (!(key in wrote) || !Object.is(current[key], wrote[key])) {\n next[key] = current[key]\n }\n }\n return next\n })\n }, [])\n\n const discard = useCallback(() => {\n setSaved(null)\n setEdits({})\n }, [])\n\n return {\n values,\n edits: applied,\n dirty: Object.keys(edits).length > 0,\n edit,\n revert,\n settle,\n discard,\n }\n}\n\nexport default useSeedEdits\n\n/**\n * The rule {@link useSeedEdits} keeps, for a form that already holds its own\n * buffer and seeds it once (AGL-4047).\n *\n * A key whose value still equals what the previous seed said is UNTOUCHED, so\n * it follows the next seed; a key the person changed keeps their value. Hand it\n * the seed the buffer was built from, the buffer as it stands, and the seed\n * that just arrived, and store the result with the next seed as the new\n * baseline. Compared by content, since a snapshot rebuilds every value.\n */\nexport function rebaseSeedEdits<T extends object>(\n previousSeed: T,\n current: T,\n nextSeed: T,\n): T {\n const next = { ...nextSeed }\n for (const key of Object.keys(current) as (keyof T)[]) {\n if (seedKeyOf({ v: current[key] }) !== seedKeyOf({ v: previousSeed[key] })) {\n next[key] = current[key]\n }\n }\n return next\n}\n"],"names":["useCallback","useMemo","useRef","useState","isSeedChecking","read","Boolean","fromCache","unreadable","seedCheckingText","subject","seedKeyOf","seed","JSON","stringify","useSeedEdits","edits","setEdits","saved","setSaved","seedKey","key","applied","values","latest","current","edit","patch","next","revert","keys","settle","written","wrote","Object","is","discard","dirty","length","rebaseSeedEdits","previousSeed","nextSeed","v"],"mappings":"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"}
|
package/src/lib/tenant.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export * from './hooks/helpers/use-modify-doc-callback';
|
|
|
29
29
|
export * from './hooks/helpers/besigner-nodes-converter';
|
|
30
30
|
export * from './hooks/helpers/guarded-nodes-save';
|
|
31
31
|
export * from './hooks/helpers/guarded-seed-write';
|
|
32
|
+
export * from './hooks/use-seed-edits';
|
|
32
33
|
export * from './hooks/firestore-denial-reporter';
|
|
33
34
|
export * from './hooks/use-firestore-collection';
|
|
34
35
|
export * from './hooks/use-paged-collection';
|
package/src/lib/tenant.js
CHANGED
|
@@ -28,6 +28,7 @@ export * from "./hooks/helpers/use-modify-doc-callback.js";
|
|
|
28
28
|
export * from "./hooks/helpers/besigner-nodes-converter.js";
|
|
29
29
|
export * from "./hooks/helpers/guarded-nodes-save.js";
|
|
30
30
|
export * from "./hooks/helpers/guarded-seed-write.js";
|
|
31
|
+
export * from "./hooks/use-seed-edits.js";
|
|
31
32
|
export * from "./hooks/firestore-denial-reporter.js";
|
|
32
33
|
export * from "./hooks/use-firestore-collection.js";
|
|
33
34
|
export * from "./hooks/use-paged-collection.js";
|
package/src/lib/tenant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/tenant/feature/instance/src/lib/tenant.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './constants/mock-data'\nexport * from './constants/site-paths'\nexport * from './constants/firebase-config'\nexport * from './constants/firebase-emulator-hosts'\n\nexport * from './hooks/firebase/app-check-recaptcha-container'\nexport * from './hooks/firebase/auth-persistence'\nexport * from './hooks/firebase/firebase-services'\nexport * from './hooks/firebase/firestore-cache'\nexport * from './hooks/firebase/firestore-stall-recovery'\nexport * from './hooks/firebase/firestore-bounded-read'\nexport * from './hooks/helpers/use-doc'\nexport * from './hooks/helpers/use-modify-doc-callback'\nexport * from './hooks/helpers/besigner-nodes-converter'\nexport * from './hooks/helpers/guarded-nodes-save'\nexport * from './hooks/helpers/guarded-seed-write'\n\nexport * from './hooks/firestore-denial-reporter'\nexport * from './hooks/use-firestore-collection'\nexport * from './hooks/use-paged-collection'\nexport * from './hooks/use-sorted-paged-collection'\nexport * from './hooks/sorted-collection-window'\nexport * from './hooks/host-collection-queries'\nexport * from './hooks/list-filter-constraints'\nexport * from './hooks/use-firestore-doc'\nexport * from './hooks/use-switcher-collection'\nexport * from './hooks/use-host-activity-logger'\nexport * from './hooks/use-live-artifact-count'\nexport * from './hooks/use-component'\nexport * from './hooks/use-component-version'\nexport * from './hooks/use-host-document-version'\nexport * from './hooks/use-host-template'\nexport * from './hooks/use-console-host-route'\nexport * from './hooks/use-host-org-id'\nexport * from './hooks/use-container-options'\nexport * from './hooks/use-org-member-options'\nexport * from './hooks/use-org-plan'\nexport * from './hooks/use-merchant-payments'\nexport * from './hooks/plan-feature-lock'\nexport * from './hooks/use-plan-feature'\nexport * from './hooks/use-scope-tokens'\nexport * from './hooks/use-host-resource-api'\nexport * from './hooks/use-host-version-api'\nexport * from './hooks/use-duplicate-resource-api'\nexport * from './hooks/use-plugin-api-post'\nexport * from './components/duplicate-resource-dialog'\nexport * from './hooks/use-plugin-config'\nexport * from './hooks/use-host'\nexport * from './hooks/use-layout'\nexport * from './hooks/use-layout-version'\nexport * from './hooks/use-screen'\nexport * from './hooks/use-screen-version'\nexport * from './hooks/use-user-name'\nexport * from './hooks/use-user-photo'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,cAAc,2BAAuB;AACrC,cAAc,4BAAwB;AACtC,cAAc,iCAA6B;AAC3C,cAAc,yCAAqC;AAEnD,cAAc,oDAAgD;AAC9D,cAAc,uCAAmC;AACjD,cAAc,wCAAoC;AAClD,cAAc,sCAAkC;AAChD,cAAc,+CAA2C;AACzD,cAAc,6CAAyC;AACvD,cAAc,6BAAyB;AACvC,cAAc,6CAAyC;AACvD,cAAc,8CAA0C;AACxD,cAAc,wCAAoC;AAClD,cAAc,wCAAoC;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/tenant/feature/instance/src/lib/tenant.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './constants/mock-data'\nexport * from './constants/site-paths'\nexport * from './constants/firebase-config'\nexport * from './constants/firebase-emulator-hosts'\n\nexport * from './hooks/firebase/app-check-recaptcha-container'\nexport * from './hooks/firebase/auth-persistence'\nexport * from './hooks/firebase/firebase-services'\nexport * from './hooks/firebase/firestore-cache'\nexport * from './hooks/firebase/firestore-stall-recovery'\nexport * from './hooks/firebase/firestore-bounded-read'\nexport * from './hooks/helpers/use-doc'\nexport * from './hooks/helpers/use-modify-doc-callback'\nexport * from './hooks/helpers/besigner-nodes-converter'\nexport * from './hooks/helpers/guarded-nodes-save'\nexport * from './hooks/helpers/guarded-seed-write'\nexport * from './hooks/use-seed-edits'\n\nexport * from './hooks/firestore-denial-reporter'\nexport * from './hooks/use-firestore-collection'\nexport * from './hooks/use-paged-collection'\nexport * from './hooks/use-sorted-paged-collection'\nexport * from './hooks/sorted-collection-window'\nexport * from './hooks/host-collection-queries'\nexport * from './hooks/list-filter-constraints'\nexport * from './hooks/use-firestore-doc'\nexport * from './hooks/use-switcher-collection'\nexport * from './hooks/use-host-activity-logger'\nexport * from './hooks/use-live-artifact-count'\nexport * from './hooks/use-component'\nexport * from './hooks/use-component-version'\nexport * from './hooks/use-host-document-version'\nexport * from './hooks/use-host-template'\nexport * from './hooks/use-console-host-route'\nexport * from './hooks/use-host-org-id'\nexport * from './hooks/use-container-options'\nexport * from './hooks/use-org-member-options'\nexport * from './hooks/use-org-plan'\nexport * from './hooks/use-merchant-payments'\nexport * from './hooks/plan-feature-lock'\nexport * from './hooks/use-plan-feature'\nexport * from './hooks/use-scope-tokens'\nexport * from './hooks/use-host-resource-api'\nexport * from './hooks/use-host-version-api'\nexport * from './hooks/use-duplicate-resource-api'\nexport * from './hooks/use-plugin-api-post'\nexport * from './components/duplicate-resource-dialog'\nexport * from './hooks/use-plugin-config'\nexport * from './hooks/use-host'\nexport * from './hooks/use-layout'\nexport * from './hooks/use-layout-version'\nexport * from './hooks/use-screen'\nexport * from './hooks/use-screen-version'\nexport * from './hooks/use-user-name'\nexport * from './hooks/use-user-photo'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,cAAc,2BAAuB;AACrC,cAAc,4BAAwB;AACtC,cAAc,iCAA6B;AAC3C,cAAc,yCAAqC;AAEnD,cAAc,oDAAgD;AAC9D,cAAc,uCAAmC;AACjD,cAAc,wCAAoC;AAClD,cAAc,sCAAkC;AAChD,cAAc,+CAA2C;AACzD,cAAc,6CAAyC;AACvD,cAAc,6BAAyB;AACvC,cAAc,6CAAyC;AACvD,cAAc,8CAA0C;AACxD,cAAc,wCAAoC;AAClD,cAAc,wCAAoC;AAClD,cAAc,4BAAwB;AAEtC,cAAc,uCAAmC;AACjD,cAAc,sCAAkC;AAChD,cAAc,kCAA8B;AAC5C,cAAc,yCAAqC;AACnD,cAAc,sCAAkC;AAChD,cAAc,qCAAiC;AAC/C,cAAc,qCAAiC;AAC/C,cAAc,+BAA2B;AACzC,cAAc,qCAAiC;AAC/C,cAAc,sCAAkC;AAChD,cAAc,qCAAiC;AAC/C,cAAc,2BAAuB;AACrC,cAAc,mCAA+B;AAC7C,cAAc,uCAAmC;AACjD,cAAc,+BAA2B;AACzC,cAAc,oCAAgC;AAC9C,cAAc,6BAAyB;AACvC,cAAc,mCAA+B;AAC7C,cAAc,oCAAgC;AAC9C,cAAc,0BAAsB;AACpC,cAAc,mCAA+B;AAC7C,cAAc,+BAA2B;AACzC,cAAc,8BAA0B;AACxC,cAAc,8BAA0B;AACxC,cAAc,mCAA+B;AAC7C,cAAc,kCAA8B;AAC5C,cAAc,wCAAoC;AAClD,cAAc,iCAA6B;AAC3C,cAAc,4CAAwC;AACtD,cAAc,+BAA2B;AACzC,cAAc,sBAAkB;AAChC,cAAc,wBAAoB;AAClC,cAAc,gCAA4B;AAC1C,cAAc,wBAAoB;AAClC,cAAc,gCAA4B;AAC1C,cAAc,2BAAuB;AACrC,cAAc,4BAAwB"}
|