pyric-admin 0.1.0-alpha.7 → 0.1.0-alpha.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/LICENSE +216 -0
- package/README.md +136 -29
- package/README.md.orig +48 -0
- package/dist/app/index.d.ts +23 -134
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +69 -202
- package/dist/app/index.js.map +1 -1
- package/dist/app/lifecycle.d.ts +7 -0
- package/dist/app/lifecycle.d.ts.map +1 -0
- package/dist/app/lifecycle.js +15 -0
- package/dist/app/lifecycle.js.map +1 -0
- package/dist/auth/index.d.ts +76 -105
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +27 -86
- package/dist/auth/index.js.map +1 -1
- package/dist/database/index.d.ts +72 -39
- package/dist/database/index.d.ts.map +1 -1
- package/dist/database/index.js +27 -45
- package/dist/database/index.js.map +1 -1
- package/dist/firestore/index.d.ts.map +1 -1
- package/dist/firestore/index.js +4 -1
- package/dist/firestore/index.js.map +1 -1
- package/dist/messaging/index.d.ts +154 -0
- package/dist/messaging/index.d.ts.map +1 -0
- package/dist/messaging/index.js +238 -0
- package/dist/messaging/index.js.map +1 -0
- package/dist/storage/index.d.ts +19 -38
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +14 -43
- package/dist/storage/index.js.map +1 -1
- package/package.json +16 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
|
|
204
|
+
Copyright 2026 David East
|
|
205
|
+
|
|
206
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
207
|
+
you may not use this file except in compliance with the License.
|
|
208
|
+
You may obtain a copy of the License at
|
|
209
|
+
|
|
210
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
211
|
+
|
|
212
|
+
Unless required by applicable law or agreed to in writing, software
|
|
213
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
214
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
215
|
+
See the License for the specific language governing permissions and
|
|
216
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,49 +1,156 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://pyric.dev/pyric-logo.svg" alt="Pyric" width="180" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
real Firebase Admin SDK backends.
|
|
5
|
+
<h1 align="center">Build with Firebase without touching production</h1>
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
backend-selection model as the client package.
|
|
7
|
+
<p align="center">Keep the same <code>firebase/*</code> code. Pyric runs it against a local backend during development, then gets out of the way when the app ships to Firebase.</p>
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
> best-effort mirror contracts of `firebase-admin` — not guaranteed parity.
|
|
11
|
-
> Any exported surface beyond the mirrored shapes is experimental public-alpha
|
|
12
|
-
> and may change without notice.
|
|
9
|
+
<p align="center"><a href="https://pyric.dev">pyric.dev</a></p>
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
<br />
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|---|---|
|
|
18
|
-
| `pyric-admin/app` | Admin app initialization for sandbox or production |
|
|
19
|
-
| `pyric-admin/firestore` | Admin Firestore shape over sandbox or `firebase-admin/firestore` |
|
|
20
|
-
| `pyric-admin/auth` | Admin Auth shape over sandbox or `firebase-admin/auth` |
|
|
21
|
-
| `pyric-admin/database` | Admin Realtime Database shape over sandbox or `firebase-admin/database` |
|
|
22
|
-
| `pyric-admin/storage` | Admin Storage shape over sandbox or `firebase-admin/storage` |
|
|
13
|
+
Pyric adds a development-only resolution layer to a Firebase application. Run the Vite development server and supported Firebase imports resolve to a browser-local backend. Run a normal production build and those imports resolve to Firebase again. The application source does not branch between the two.
|
|
23
14
|
|
|
24
|
-
|
|
15
|
+
The mirrored data services do not connect to a production Firebase project. Local writes cannot delete production data or create Firebase usage charges, and local rules changes do not deploy. Pyric owns the development sandbox and verification workflow. Firebase owns production, with `firebase-tools` or the Firebase Console handling deployment.
|
|
16
|
+
|
|
17
|
+
## Start a new Firebase application locally
|
|
18
|
+
|
|
19
|
+
Create a Vite application with canonical Firebase imports, Firestore rules, and the Pyric development plugin already configured:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx create-pyric my-app
|
|
23
|
+
cd my-app
|
|
24
|
+
npm install
|
|
25
|
+
npm run dev
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`npm create pyric my-app` runs the same scaffold.
|
|
29
|
+
|
|
30
|
+
## Run an existing Firebase application locally
|
|
31
|
+
|
|
32
|
+
Install the development plugin:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install --save-dev @pyric/cli
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Add it to the existing Vite configuration:
|
|
25
39
|
|
|
26
40
|
```ts
|
|
27
|
-
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
41
|
+
// vite.config.ts
|
|
42
|
+
import { defineConfig } from 'vite';
|
|
43
|
+
import { pyricSandbox } from '@pyric/cli/vite';
|
|
30
44
|
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
export default defineConfig({
|
|
46
|
+
plugins: [pyricSandbox()],
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Start the normal development server:
|
|
33
51
|
|
|
34
|
-
|
|
52
|
+
```bash
|
|
53
|
+
npm run dev
|
|
35
54
|
```
|
|
36
55
|
|
|
37
|
-
|
|
56
|
+
During `vite dev`, the plugin swaps supported `firebase/*` modules at resolution time. The backend runs in a SharedWorker, so tabs on the same development origin use one local backend. Browser-local persistence uses IndexedDB.
|
|
57
|
+
|
|
58
|
+
Pyric Studio is available on the Vite origin at `/__pyric/ui/`. It opens the same backend used by the application.
|
|
59
|
+
|
|
60
|
+
For a static application or a Node process, `pyric dev` provides the same development-only package swap without the Vite plugin. The [CLI reference](packages/cli/docs/reference/cli.md) documents those paths and every command.
|
|
61
|
+
|
|
62
|
+
## Keep writing Firebase code
|
|
63
|
+
|
|
64
|
+
Application code continues to import Firebase:
|
|
38
65
|
|
|
39
66
|
```ts
|
|
40
|
-
|
|
67
|
+
// src/firebase.ts
|
|
68
|
+
import { initializeApp } from 'firebase/app';
|
|
69
|
+
import { getAuth } from 'firebase/auth';
|
|
70
|
+
import { getFirestore } from 'firebase/firestore';
|
|
41
71
|
|
|
42
72
|
const app = initializeApp({
|
|
43
|
-
|
|
73
|
+
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
|
|
74
|
+
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
|
|
75
|
+
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export const auth = getAuth(app);
|
|
79
|
+
export const db = getFirestore(app);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The Firebase configuration is accepted by the local mirror during development. The production build passes that same configuration to Firebase. Normal Auth, Firestore, Realtime Database, Storage, Messaging, and Firebase AI Logic usage still belongs in the [Firebase documentation](https://firebase.google.com/docs).
|
|
83
|
+
|
|
84
|
+
Pyric documents the parts that differ locally, including supported behavior, Security Rules, persistence, inspection, verification, and known gaps. See [use the Vite plugin](packages/cli/docs/how-to/use-the-vite-plugin.md) for the complete plugin contract.
|
|
85
|
+
|
|
86
|
+
## Inspect and correct a failed operation
|
|
87
|
+
|
|
88
|
+
Pyric Studio shows local data, requests, authentication state, Security Rules verdicts, and denied operations. Open `/__pyric/ui/` on the development server and reproduce the failure. A denied request includes the path and verdict needed to correct the rule or the application code.
|
|
89
|
+
|
|
90
|
+
The Vite plugin discovers the Firestore rules path from `firebase.json`, or falls back to `firestore.rules`. Saving that file replaces the active local ruleset without a production deploy. A parse failure leaves the last valid ruleset active and reports the error in the development server.
|
|
91
|
+
|
|
92
|
+
State and test identities stay browser-local by default. Add `persist: true` to write a committable `.pyric/state/state.json`, or use `seed` to start from a known scenario:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
pyricSandbox({
|
|
96
|
+
persist: true,
|
|
97
|
+
seed: 'seed.json',
|
|
44
98
|
});
|
|
45
99
|
```
|
|
46
100
|
|
|
47
|
-
|
|
101
|
+
See [persistence and multi-tab behavior](packages/cli/docs/how-to/serve-persistence-and-multi-tab.md) for reset and seed precedence.
|
|
102
|
+
|
|
103
|
+
## Give coding agents the same local Firebase target
|
|
104
|
+
|
|
105
|
+
An agent can keep writing the same Firebase code while inspecting and changing the backend that the application is already using. Agent access is opt-in. Enable the MCP bridge in the Vite plugin:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
pyricSandbox({ bridge: true });
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The bridge mounts on the Vite development origin and routes agent operations to the same SharedWorker backend used by the application and Studio. The included [Claude Code plugin](pyric-plugin/README.md) discovers that bridge, while other MCP clients can connect to its HTTP endpoint.
|
|
112
|
+
|
|
113
|
+
This protects the local workflow, not an independently credentialed process. A coding agent with production Firebase credentials or deployment access can still affect production outside Pyric.
|
|
114
|
+
|
|
115
|
+
## Verify the rules boundary
|
|
116
|
+
|
|
117
|
+
Development sessions capture Firestore and Realtime Database operations in `.pyric/last-session.json` by default. Replay those requests against candidate rules before deployment:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npx pyric verify
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The default engine runs locally. The optional Firestore Rules Test API engine sends derived rule cases to Google's hosted evaluator when production-authority verification is needed. It verifies rules and does not deploy them. See [verify against a captured session](packages/cli/docs/how-to/verify-against-a-captured-session.md).
|
|
124
|
+
|
|
125
|
+
## Ship the same application code
|
|
126
|
+
|
|
127
|
+
A standard Vite production build leaves the development swap inactive:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npm run build
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The built application contains the real Firebase SDK and uses the Firebase configuration already present in the source. Deploy the build, rules, and indexes with `firebase-tools` or the Firebase Console. Pyric has no production deployment path.
|
|
134
|
+
|
|
135
|
+
## Check what Pyric mirrors
|
|
136
|
+
|
|
137
|
+
Pyric is an independent implementation of observable Firebase behavior. Conformance evidence records what has been compared with Firebase and keeps five outcomes distinct: conforms, documented divergence, bug, unsupported, and unverified. The evidence is a floor, not a claim that every Firebase behavior has been measured.
|
|
138
|
+
|
|
139
|
+
Read the generated matrices for [App](packages/pyric/docs/app/COMPAT.md), [Auth](packages/pyric/docs/auth/COMPAT.md), [Firestore](packages/pyric/docs/firestore/COMPAT.md), [Realtime Database](packages/pyric/docs/database/COMPAT.md), [Storage](packages/pyric/docs/storage/COMPAT.md), [Messaging](packages/pyric/docs/messaging/COMPAT.md), [AI Logic](packages/pyric/docs/ai/COMPAT.md), [Security Rules](packages/pyric/docs/rules/COMPAT.md), and [Functions with Realtime Database](packages/cli/docs/functions-rtdb/COMPAT.md). The [versioning and compatibility policy](packages/pyric/docs/explanation/versioning-and-compatibility.md) explains the release boundary.
|
|
140
|
+
|
|
141
|
+
## Stability
|
|
142
|
+
|
|
143
|
+
Pyric is alpha software, currently `0.1.0-alpha.8`. Firebase-shaped surfaces are tracked through the compatibility matrices. Pyric-specific development APIs may change between alpha releases. All packages are ESM-only and require Node 22.15 or later.
|
|
144
|
+
|
|
145
|
+
## Develop Pyric
|
|
146
|
+
|
|
147
|
+
The repository is a Bun workspace:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
bun install
|
|
151
|
+
bun run build
|
|
152
|
+
bun run test
|
|
153
|
+
bun run compat:check
|
|
154
|
+
```
|
|
48
155
|
|
|
49
|
-
|
|
156
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md), [CONTEXT.md](CONTEXT.md), and [AGENTS.md](AGENTS.md) before changing the codebase.
|
package/README.md.orig
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# `pyric-admin`
|
|
2
|
+
|
|
3
|
+
Firebase Admin-shaped adapters for a Pyric sandbox.
|
|
4
|
+
|
|
5
|
+
Use these subpaths when tests, development servers, or scripts need
|
|
6
|
+
`firebase-admin` ergonomics against local or browser-hosted sandbox state. In
|
|
7
|
+
activated development, `@pyric/cli/register` resolves canonical
|
|
8
|
+
`firebase-admin/*` imports here. With activation absent, production execution
|
|
9
|
+
loads `firebase-admin` directly.
|
|
10
|
+
|
|
11
|
+
> **Alpha.** These are best-effort mirror contracts of `firebase-admin`. Read
|
|
12
|
+
> the conformance matrices and service references for implemented behaviour and
|
|
13
|
+
> explicit gaps.
|
|
14
|
+
|
|
15
|
+
## Subpaths
|
|
16
|
+
|
|
17
|
+
| Subpath | Sandbox surface |
|
|
18
|
+
|---|---|
|
|
19
|
+
| `pyric-admin/app` | Admin app registry and sandbox binding |
|
|
20
|
+
| `pyric-admin/firestore` | Admin Firestore shape |
|
|
21
|
+
| `pyric-admin/auth` | Admin Auth shape |
|
|
22
|
+
| `pyric-admin/database` | Admin Realtime Database shape |
|
|
23
|
+
| `pyric-admin/storage` | Admin Storage shape |
|
|
24
|
+
|
|
25
|
+
## Explicit sandbox setup
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { initializeApp } from 'pyric-admin/app';
|
|
29
|
+
import { initializeSandbox } from 'pyric/sandbox';
|
|
30
|
+
import { getFirestore } from 'pyric-admin/firestore';
|
|
31
|
+
|
|
32
|
+
const app = initializeApp({ sandbox: initializeSandbox() });
|
|
33
|
+
const db = getFirestore(app);
|
|
34
|
+
|
|
35
|
+
await db.collection('posts').doc('hello').set({ title: 'Hello' });
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
For unchanged server source, keep `firebase-admin/*` imports and run the
|
|
39
|
+
development command through `pyric dev`. Production runs the same source
|
|
40
|
+
without sandbox activation and therefore resolves Firebase Admin directly.
|
|
41
|
+
|
|
42
|
+
## Documentation
|
|
43
|
+
|
|
44
|
+
- [App registry and activation](docs/app/)
|
|
45
|
+
- [Firestore](docs/firestore/)
|
|
46
|
+
- [Auth API](https://pyric.dev/docs/pyric-admin-auth-reference-api/)
|
|
47
|
+
- [Realtime Database API](https://pyric.dev/docs/pyric-admin-database-reference-api/)
|
|
48
|
+
- [Storage API](https://pyric.dev/docs/pyric-admin-storage-reference-api/)
|
package/dist/app/index.d.ts
CHANGED
|
@@ -1,158 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `pyric-admin/app` —
|
|
3
|
-
* default-app registry and AMBIENT INIT (adoption experience, layer 3).
|
|
2
|
+
* `pyric-admin/app` — sandbox-only admin app registry.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* brand for backend dispatch.
|
|
9
|
-
*
|
|
10
|
-
* Current shadow scope:
|
|
11
|
-
* - `initializeApp({ credential, ... })` — prod-backed (live;
|
|
12
|
-
* delegates to `firebase-admin/app.initializeApp`).
|
|
13
|
-
* - `initializeApp({ sandbox })` — sandbox-backed (live).
|
|
14
|
-
* - `initializeApp()` — BARE, zero pyric identifiers in app code. The
|
|
15
|
-
* environment decides the backend (see "Ambient init" below).
|
|
16
|
-
* - Per-subpath adapter dispatch via the brand: implemented in
|
|
17
|
-
* `pyric-admin/{auth,database,storage}` via structural
|
|
18
|
-
* checks on the `app` argument. Phase 4 commits use property
|
|
19
|
-
* probing today; cutover swaps to brand-symbol reads.
|
|
20
|
-
*
|
|
21
|
-
* ── Default-app registry ──────────────────────────────────────────────
|
|
22
|
-
*
|
|
23
|
-
* Mirrors `firebase-admin/app`'s lifecycle exactly (oracle:
|
|
24
|
-
* `firebase-admin/lib/app/lifecycle.js`):
|
|
25
|
-
*
|
|
26
|
-
* - `initializeApp(config?, name?)` registers under `'[DEFAULT]'` when
|
|
27
|
-
* unnamed; `getApp(name?)` / `getApps()` / `deleteApp(app)` read it.
|
|
28
|
-
* - Duplicate-name errors carry firebase-admin's codes and message
|
|
29
|
-
* text: `app/duplicate-app` for a config'd re-init with a different
|
|
30
|
-
* configuration, `app/invalid-app-options` for a bare-vs-config'd
|
|
31
|
-
* mismatch (firebase-admin's autoInit mismatch), `app/no-app` from
|
|
32
|
-
* `getApp` on a missing name, `app/invalid-app-name` for a
|
|
33
|
-
* non-string/empty name. Errors reuse firebase-admin's own
|
|
34
|
-
* `FirebaseAppError` class, so `instanceof`, `constructor.name`,
|
|
35
|
-
* `.code`, and message text match production byte-for-byte
|
|
36
|
-
* (oracle: `admin-app-*` observations).
|
|
37
|
-
* - Idempotency mirror: a bare `initializeApp()` repeated for the same
|
|
38
|
-
* name returns the existing auto-initialized app (firebase-admin's
|
|
39
|
-
* autoInit path); `initializeApp({ sandbox })` repeated with the
|
|
40
|
-
* SAME `Sandbox` reference returns the existing app (the reference
|
|
41
|
-
* is our deep-equal analog — sandboxes have identity, not value
|
|
42
|
-
* equality); prod re-inits delegate the equality decision to
|
|
43
|
-
* firebase-admin itself (deep-equal options → same app; credential /
|
|
44
|
-
* httpAgent present → `app/invalid-app-options`, exactly upstream).
|
|
45
|
-
*
|
|
46
|
-
* ── Ambient init (bare `initializeApp()`) ─────────────────────────────
|
|
47
|
-
*
|
|
48
|
-
* The user's server code contains ZERO pyric identifiers — bare
|
|
49
|
-
* `initializeApp()` + no-arg `getDatabase()` / `getAuth()`. The
|
|
50
|
-
* environment picks the backend:
|
|
51
|
-
*
|
|
52
|
-
* - `PYRIC_SANDBOX` unset → exactly firebase-admin's behavior:
|
|
53
|
-
* delegate to `firebase-admin/app.initializeApp()` (FIREBASE_CONFIG
|
|
54
|
-
* env + application-default credentials), register the prod arm.
|
|
55
|
-
* - `PYRIC_SANDBOX=remote` or `remote:<url>` → obtain a remote sandbox
|
|
56
|
-
* handle from the factory installed by `pyric-tools/register` at
|
|
57
|
-
* `globalThis[REMOTE_SANDBOX_FACTORY]`
|
|
58
|
-
* (`Symbol.for('pyric.remote.sandboxFactory')`) and register the
|
|
59
|
-
* sandbox arm. One activation line is logged to stderr. If the env
|
|
60
|
-
* is set but no factory is installed, throw with remediation (run
|
|
61
|
-
* under `pyric dev`, or add `--import pyric-tools/register` to
|
|
62
|
-
* NODE_OPTIONS).
|
|
63
|
-
* - Production guard: refuses to route to a sandbox when
|
|
64
|
-
* `NODE_ENV === 'production'`, unless `PYRIC_SANDBOX_FORCE=1`.
|
|
65
|
-
*
|
|
66
|
-
* Ambient resolution happens ONLY on the bare call — any explicit
|
|
67
|
-
* config (`{ sandbox }` or prod `AppOptions`, even `{}`) bypasses the
|
|
68
|
-
* env entirely, so pyric-aware code keeps full control.
|
|
4
|
+
* Production selection happens before this module loads: activated Node
|
|
5
|
+
* processes resolve `firebase-admin/app` here, while inactive applications
|
|
6
|
+
* continue resolving their own `firebase-admin/app` package unchanged.
|
|
69
7
|
*/
|
|
70
8
|
import { type Sandbox } from 'pyric/sandbox';
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Brand on every PyricAdminApp. Matches the symbol used in
|
|
74
|
-
* `pyric/app` so a future shared `pyric/runtime` package can
|
|
75
|
-
* unify dispatch helpers across both packages.
|
|
76
|
-
*/
|
|
9
|
+
/** Brand carried by every sandbox admin app. */
|
|
77
10
|
export declare const ADMIN_APP_TARGET: unique symbol;
|
|
78
|
-
export type PyricAdminAppTarget = 'sandbox'
|
|
79
|
-
/** firebase-admin's default app name
|
|
11
|
+
export type PyricAdminAppTarget = 'sandbox';
|
|
12
|
+
/** firebase-admin's default app name. */
|
|
80
13
|
export declare const DEFAULT_APP_NAME = "[DEFAULT]";
|
|
81
14
|
export interface SandboxAdminApp {
|
|
82
15
|
readonly [ADMIN_APP_TARGET]: 'sandbox';
|
|
83
16
|
readonly sandbox: Sandbox;
|
|
84
|
-
/** Registry name (mirrors firebase-admin `App.name`). */
|
|
85
|
-
readonly name: string;
|
|
86
|
-
}
|
|
87
|
-
export interface ProdAdminApp {
|
|
88
|
-
readonly [ADMIN_APP_TARGET]: 'prod';
|
|
89
|
-
readonly adminApp: AdminApp;
|
|
90
|
-
/** Registry name (mirrors firebase-admin `App.name`). */
|
|
91
17
|
readonly name: string;
|
|
92
18
|
}
|
|
93
|
-
export type PyricAdminApp = SandboxAdminApp
|
|
19
|
+
export type PyricAdminApp = SandboxAdminApp;
|
|
94
20
|
export type InitializeAdminAppConfig = {
|
|
95
21
|
sandbox: Sandbox;
|
|
96
|
-
}
|
|
22
|
+
};
|
|
97
23
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* `errorName: "FirebaseAppError"`). The published typings declare only the
|
|
104
|
-
* base `Error` constructor, but the real runtime class is
|
|
105
|
-
* `new FirebaseAppError(code, message)` where `code` becomes `app/<code>` —
|
|
106
|
-
* the typed cast recovers it.
|
|
24
|
+
* Firebase Functions' ESM runtime statically imports this credential factory
|
|
25
|
+
* while linking its database provider. Pyric initializes the sandbox app
|
|
26
|
+
* before that provider executes, so the factory is not used by supported
|
|
27
|
+
* Functions flows. Keep the named export link-compatible, but fail clearly if
|
|
28
|
+
* application code asks the development sandbox for production credentials.
|
|
107
29
|
*/
|
|
108
|
-
declare
|
|
109
|
-
readonly code: string;
|
|
110
|
-
};
|
|
111
|
-
/** @deprecated Alias kept for pre-merge call sites; errors ARE `FirebaseAppError`. */
|
|
112
|
-
export declare const PyricAdminAppError: new (code: string, message: string) => Error & {
|
|
113
|
-
readonly code: string;
|
|
114
|
-
};
|
|
115
|
-
export type PyricAdminAppError = InstanceType<typeof AdminAppError>;
|
|
30
|
+
export declare function applicationDefault(): never;
|
|
116
31
|
/**
|
|
117
|
-
* Initialize a
|
|
118
|
-
* (default `'[DEFAULT]'`), mirroring `firebase-admin/app.initializeApp`.
|
|
32
|
+
* Initialize a sandbox admin app.
|
|
119
33
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* const app = initializeApp();
|
|
125
|
-
*
|
|
126
|
-
* // Prod-backed
|
|
127
|
-
* import { applicationDefault } from 'firebase-admin/app';
|
|
128
|
-
* const app = initializeApp({ credential: applicationDefault() });
|
|
129
|
-
*
|
|
130
|
-
* // Sandbox-backed
|
|
131
|
-
* import { initializeSandbox } from 'pyric/sandbox';
|
|
132
|
-
* const app = initializeApp({ sandbox: initializeSandbox() });
|
|
133
|
-
* ```
|
|
34
|
+
* An explicit `{ sandbox }` config binds an in-process or remote sandbox.
|
|
35
|
+
* A bare call resolves the remote sandbox factory installed by
|
|
36
|
+
* `@pyric/cli/register`. Production callers must import `firebase-admin/app`
|
|
37
|
+
* without Pyric activation instead of passing production options here.
|
|
134
38
|
*/
|
|
135
39
|
export declare function initializeApp(config?: InitializeAdminAppConfig, name?: string): PyricAdminApp;
|
|
136
|
-
/**
|
|
137
|
-
* Return the registered app for `name` (default `'[DEFAULT]'`).
|
|
138
|
-
* Mirrors `firebase-admin/app.getApp` — including the exact `app/no-app`
|
|
139
|
-
* error text on a miss.
|
|
140
|
-
*/
|
|
40
|
+
/** Return the registered app for `name`. */
|
|
141
41
|
export declare function getApp(name?: string): PyricAdminApp;
|
|
142
|
-
/**
|
|
143
|
-
* A copy of the list of all registered apps.
|
|
144
|
-
* Mirrors `firebase-admin/app.getApps`.
|
|
145
|
-
*/
|
|
42
|
+
/** Return a copy of the app registry. */
|
|
146
43
|
export declare function getApps(): PyricAdminApp[];
|
|
147
|
-
/**
|
|
148
|
-
* Remove `app` from the registry, mirroring `firebase-admin/app.deleteApp`.
|
|
149
|
-
* Prod-backed apps also delete the underlying firebase-admin app (freeing
|
|
150
|
-
* its resources and its slot in firebase-admin's own registry, so the
|
|
151
|
-
* name can be re-initialized). Sandbox-backed apps only deregister — the
|
|
152
|
-
* `Sandbox` handle's lifetime belongs to its creator.
|
|
153
|
-
*/
|
|
44
|
+
/** Remove a sandbox app from the registry. */
|
|
154
45
|
export declare function deleteApp(app: PyricAdminApp): Promise<void>;
|
|
155
46
|
export declare function isSandboxAdminApp(app: PyricAdminApp): app is SandboxAdminApp;
|
|
156
|
-
export declare function isProdAdminApp(app: PyricAdminApp): app is ProdAdminApp;
|
|
157
|
-
export {};
|
|
158
47
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/app/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAIL,KAAK,OAAO,EACb,MAAM,eAAe,CAAC;AAGvB,gDAAgD;AAChD,eAAO,MAAM,gBAAgB,eAAuC,CAAC;AACrE,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAE5C,yCAAyC;AACzC,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,CAAC,gBAAgB,CAAC,EAAE,SAAS,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,aAAa,GAAG,eAAe,CAAC;AAC5C,MAAM,MAAM,wBAAwB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5D;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,KAAK,CAK1C;AA4CD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,MAAM,CAAC,EAAE,wBAAwB,EACjC,IAAI,GAAE,MAAyB,GAC9B,aAAa,CAqCf;AAED,4CAA4C;AAC5C,wBAAgB,MAAM,CAAC,IAAI,GAAE,MAAyB,GAAG,aAAa,CAarE;AAED,yCAAyC;AACzC,wBAAgB,OAAO,IAAI,aAAa,EAAE,CAEzC;AAED,8CAA8C;AAC9C,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAS3D;AAgED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,GAAG,IAAI,eAAe,CAE5E"}
|