@aglyn/tenant-feature-instance 1.0.0-beta.143 → 1.0.0-beta.145
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/README.md +105 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,3 +1,106 @@
|
|
|
1
|
-
# tenant-feature-instance
|
|
1
|
+
# @aglyn/tenant-feature-instance
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Client-side React hooks for working with one Aglyn site instance over the
|
|
4
|
+
Firebase web SDK: the Firebase services provider, Firestore document and
|
|
5
|
+
collection hooks, and typed hooks for hosts, screens, layouts, components and
|
|
6
|
+
their versions. It is mainly an internal building block: the Aglyn console and
|
|
7
|
+
the console halves of the `@aglyn/plugins-*` packages read and write site data
|
|
8
|
+
through it. Install it directly only if you are building a client against an
|
|
9
|
+
Aglyn deployment's Firestore.
|
|
10
|
+
|
|
11
|
+
> Beta. Published from the Aglyn monorepo under the `beta` dist-tag; APIs can change between beta releases.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
npm install @aglyn/tenant-feature-instance@beta
|
|
16
|
+
|
|
17
|
+
Peer dependencies:
|
|
18
|
+
|
|
19
|
+
- `react`
|
|
20
|
+
- `firebase`
|
|
21
|
+
- `@mui/material` (for the duplicate-resource dialog)
|
|
22
|
+
|
|
23
|
+
## What's in it
|
|
24
|
+
|
|
25
|
+
Firebase services:
|
|
26
|
+
|
|
27
|
+
- `FirebaseServicesProvider` initializes the Firebase app from a
|
|
28
|
+
`firebaseConfig` and `appName`, and chooses auth persistence and the
|
|
29
|
+
Firestore local cache from its `authPersistence` prop.
|
|
30
|
+
- `useFirebaseApp`, `useFirestore`, `useAuth`, `useAnalytics`,
|
|
31
|
+
`useRemoteConfig`, `useUser` and `useSigninCheck` read from it.
|
|
32
|
+
- `fbClientAppOptions` and `FIREBASE_CLIENT_APP_NAME` are the client
|
|
33
|
+
configuration Aglyn's apps use, read from environment variables.
|
|
34
|
+
|
|
35
|
+
Generic Firestore hooks:
|
|
36
|
+
|
|
37
|
+
- `useFirestoreDoc` and `useFirestoreCollection` subscribe to a reference or
|
|
38
|
+
query built by the caller and return `data`, `status`, `error` and whether
|
|
39
|
+
the data still has pending local writes.
|
|
40
|
+
- `usePagedCollection`, the sorted paged collection hook and the switcher
|
|
41
|
+
collection hook page through larger collections.
|
|
42
|
+
- `useDoc`, `useDocData` and the modify-doc callback are the lower-level
|
|
43
|
+
helpers the typed hooks are built from.
|
|
44
|
+
|
|
45
|
+
Typed hooks over the platform model in `@aglyn/aglyn`:
|
|
46
|
+
|
|
47
|
+
- `useHost`, `useScreen`, `useScreenVersion`, `useLayout`, `useLayoutVersion`,
|
|
48
|
+
`useComponent`, the component version and form version hooks, and their
|
|
49
|
+
`...Ref` counterparts (`useHostRef`, `useScreenRef` and so on).
|
|
50
|
+
- `usePluginConfig` and `useSitePluginConfig` for a plugin's stored
|
|
51
|
+
configuration.
|
|
52
|
+
- `useOrgPlan`, the host organization id, organization member options, scope
|
|
53
|
+
tokens and host campaigns hooks.
|
|
54
|
+
- `useHostResourceApi`, `useHostVersionApi` and the duplicate-resource hook
|
|
55
|
+
and dialog (`DuplicateResourceDialog`) call the console's resource APIs.
|
|
56
|
+
|
|
57
|
+
Saving node trees:
|
|
58
|
+
|
|
59
|
+
- `saveNodesGuarded` and the guarded seed write save a document's nodes
|
|
60
|
+
against a baseline, and the Besigner nodes converter maps stored nodes to
|
|
61
|
+
and from the editor's form.
|
|
62
|
+
|
|
63
|
+
Constants: reserved site paths such as `API_DIR` and `STATIC_DIR`.
|
|
64
|
+
|
|
65
|
+
Every file under `src/lib` is also reachable by subpath, for example
|
|
66
|
+
`@aglyn/tenant-feature-instance/hooks/use-firestore-doc`.
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import {
|
|
72
|
+
FIREBASE_CLIENT_APP_NAME,
|
|
73
|
+
FirebaseServicesProvider,
|
|
74
|
+
fbClientAppOptions,
|
|
75
|
+
useHost,
|
|
76
|
+
} from '@aglyn/tenant-feature-instance'
|
|
77
|
+
|
|
78
|
+
function HostName({ hostId }: { hostId: string }) {
|
|
79
|
+
const { status, data } = useHost({ hostId })
|
|
80
|
+
if (status !== 'success') return null
|
|
81
|
+
return <span>{data?.displayName}</span>
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function App() {
|
|
85
|
+
return (
|
|
86
|
+
<FirebaseServicesProvider
|
|
87
|
+
firebaseConfig={fbClientAppOptions}
|
|
88
|
+
appName={FIREBASE_CLIENT_APP_NAME}
|
|
89
|
+
>
|
|
90
|
+
<HostName hostId="my-host" />
|
|
91
|
+
</FirebaseServicesProvider>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## How it fits
|
|
97
|
+
|
|
98
|
+
This is a feature piece of the `tenant` scope in the package map. It imports
|
|
99
|
+
the core (`@aglyn/aglyn`) and generic `@aglyn/shared-*` packages. It is the
|
|
100
|
+
client counterpart of `@aglyn/tenant-data-admin`, which does the same job on
|
|
101
|
+
the server with admin credentials. Plugins may import it; it never imports a
|
|
102
|
+
plugin.
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
Apache-2.0. Source: https://github.com/aglyn/aglyn/tree/main/libs/tenant/feature/instance
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/tenant-feature-instance",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.145",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-ui-jsx": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-util-http": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-util-timestamp": "1.0.0-beta.
|
|
28
|
+
"@aglyn/aglyn": "1.0.0-beta.145",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.0.0-beta.145",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.0.0-beta.145",
|
|
31
|
+
"@aglyn/shared-util-http": "1.0.0-beta.145",
|
|
32
|
+
"@aglyn/shared-util-timestamp": "1.0.0-beta.145",
|
|
33
33
|
"@swc/helpers": "0.5.23",
|
|
34
34
|
"lodash-es": "^4.18.1"
|
|
35
35
|
},
|