@pyric/cli 0.1.0-alpha.25 → 0.1.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rtdb/inspect-deployed-rules.d.ts +3 -17
- package/dist/rtdb/inspect-deployed-rules.d.ts.map +1 -1
- package/dist/rtdb/inspect-deployed-rules.js +4 -54
- package/dist/rtdb/inspect-deployed-rules.js.map +1 -1
- package/dist/serve/site-ui/docs/index.json +35 -0
- package/dist/serve/site-ui/docs/pyric-rules-reference-api/index.html +372 -201
- package/dist/serve/site-ui/docs/pyric-rules-reference-api.md +148 -9
- package/dist/serve/site-ui/docs/secure/rtdb-rules-in-typescript/index.html +56 -1
- package/dist/serve/site-ui/docs/secure/rtdb-rules-in-typescript.md +33 -0
- package/dist/serve/site-ui/examples/chess/index.html +1 -1
- package/package.json +4 -4
- package/src/rtdb/inspect-deployed-rules.ts +5 -77
|
@@ -9,21 +9,9 @@
|
|
|
9
9
|
* URL, and it is not returned in any result or message.
|
|
10
10
|
*/
|
|
11
11
|
import type { ToolHandler } from 'pyric/sandbox/internal';
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
export type RtdbRuleKind
|
|
15
|
-
/**
|
|
16
|
-
* One rule expression that differs. `deployed` is absent for `added` and
|
|
17
|
-
* `local` is absent for `removed`: the change is what deploying the local
|
|
18
|
-
* ruleset would do to the deployed one.
|
|
19
|
-
*/
|
|
20
|
-
export interface RtdbRuleChange {
|
|
21
|
-
path: string;
|
|
22
|
-
kind: RtdbRuleKind;
|
|
23
|
-
change: 'added' | 'removed' | 'changed';
|
|
24
|
-
deployed?: string;
|
|
25
|
-
local?: string;
|
|
26
|
-
}
|
|
12
|
+
import { type RtdbRuleChange } from 'pyric/rules/internal/rtdb';
|
|
13
|
+
export { DIFFED_RULE_KINDS, diffRtdbRules } from 'pyric/rules/internal/rtdb';
|
|
14
|
+
export type { DiffRtdbRulesOptions, RtdbRuleChange, RtdbRuleKind } from 'pyric/rules/internal/rtdb';
|
|
27
15
|
export interface InspectDeployedRtdbRulesOptions {
|
|
28
16
|
scope: {
|
|
29
17
|
resolveToken(): Promise<string>;
|
|
@@ -47,8 +35,6 @@ export type InspectDeployedRtdbRulesResult = {
|
|
|
47
35
|
};
|
|
48
36
|
};
|
|
49
37
|
export declare function inspectDeployedRtdbRules(options: InspectDeployedRtdbRulesOptions): Promise<InspectDeployedRtdbRulesResult>;
|
|
50
|
-
/** Node-level diff of two `rules` trees, ordered by path then rule kind. */
|
|
51
|
-
export declare function diffRtdbRules(deployed: Record<string, unknown>, local: Record<string, unknown>): RtdbRuleChange[];
|
|
52
38
|
export interface RtdbInspectRulesToolDeps {
|
|
53
39
|
scope: {
|
|
54
40
|
resolveToken(): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect-deployed-rules.d.ts","sourceRoot":"","sources":["../../src/rtdb/inspect-deployed-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"inspect-deployed-rules.d.ts","sourceRoot":"","sources":["../../src/rtdb/inspect-deployed-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAM/E,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC7E,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEpG,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE;QAAE,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,MAAM,MAAM,8BAA8B,GACtC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAAC,IAAI,EAAE,cAAc,EAAE,CAAA;CAAE,GAClF;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAO5D,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,8BAA8B,CAAC,CA8CzC;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE;QAAE,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,cAAc,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,oFAAoF;AACpF,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,wBAAwB,GAAG,WAAW,CA0BtF"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { diffRtdbRules } from 'pyric/rules/internal/rtdb';
|
|
1
2
|
import { parseRtdbRulesText } from './rules-json.js';
|
|
2
3
|
import { HOSTED_CREDENTIAL_SOURCES } from '../credentials/node/scope.js';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
// The diff itself is pure and lives in `pyric` (public from `pyric/rules`);
|
|
5
|
+
// it is re-exported here so this module's exports stay as they were.
|
|
6
|
+
export { DIFFED_RULE_KINDS, diffRtdbRules } from 'pyric/rules/internal/rtdb';
|
|
5
7
|
const failure = (code, message) => ({
|
|
6
8
|
ok: false,
|
|
7
9
|
error: { code, message },
|
|
@@ -43,58 +45,6 @@ export async function inspectDeployedRtdbRules(options) {
|
|
|
43
45
|
}
|
|
44
46
|
return { ok: true, deployed, diff: diffRtdbRules(deployed.rules, local.rules) };
|
|
45
47
|
}
|
|
46
|
-
/** Node-level diff of two `rules` trees, ordered by path then rule kind. */
|
|
47
|
-
export function diffRtdbRules(deployed, local) {
|
|
48
|
-
const deployedRules = collectRules(deployed);
|
|
49
|
-
const localRules = collectRules(local);
|
|
50
|
-
const changes = [];
|
|
51
|
-
for (const key of new Set([...deployedRules.keys(), ...localRules.keys()])) {
|
|
52
|
-
const d = deployedRules.get(key);
|
|
53
|
-
const l = localRules.get(key);
|
|
54
|
-
if (d?.value === l?.value)
|
|
55
|
-
continue;
|
|
56
|
-
const node = (d ?? l);
|
|
57
|
-
const change = {
|
|
58
|
-
path: node.path,
|
|
59
|
-
kind: node.kind,
|
|
60
|
-
change: d === undefined ? 'added' : l === undefined ? 'removed' : 'changed',
|
|
61
|
-
};
|
|
62
|
-
if (d !== undefined)
|
|
63
|
-
change.deployed = d.value;
|
|
64
|
-
if (l !== undefined)
|
|
65
|
-
change.local = l.value;
|
|
66
|
-
changes.push(change);
|
|
67
|
-
}
|
|
68
|
-
return changes.sort((a, b) => compare(a.path, b.path) || compare(a.kind, b.kind));
|
|
69
|
-
}
|
|
70
|
-
const compare = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
71
|
-
function formatRuleValue(kind, value) {
|
|
72
|
-
if (kind === '.indexOn') {
|
|
73
|
-
const normalized = typeof value === 'string' ? [value] : value;
|
|
74
|
-
return JSON.stringify(normalized);
|
|
75
|
-
}
|
|
76
|
-
// A boolean and its string form are one expression: `true` and "true".
|
|
77
|
-
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
78
|
-
}
|
|
79
|
-
function collectRules(root) {
|
|
80
|
-
const out = new Map();
|
|
81
|
-
const walk = (node, path) => {
|
|
82
|
-
for (const [key, child] of Object.entries(node)) {
|
|
83
|
-
if (key.startsWith('.')) {
|
|
84
|
-
if (DIFFED_RULE_KINDS.includes(key)) {
|
|
85
|
-
const kind = key;
|
|
86
|
-
const value = formatRuleValue(kind, child);
|
|
87
|
-
out.set(`${path}\u0000${kind}`, { path, kind, value });
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else if (typeof child === 'object' && child !== null && !Array.isArray(child)) {
|
|
91
|
-
walk(child, `${path === '/' ? '' : path}/${key}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
walk(root, '/');
|
|
96
|
-
return out;
|
|
97
|
-
}
|
|
98
48
|
/** Library tool, the Realtime Database counterpart of `firestore_inspect_rules`. */
|
|
99
49
|
export function createRtdbInspectRulesTool(deps) {
|
|
100
50
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect-deployed-rules.js","sourceRoot":"","sources":["../../src/rtdb/inspect-deployed-rules.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,
|
|
1
|
+
{"version":3,"file":"inspect-deployed-rules.js","sourceRoot":"","sources":["../../src/rtdb/inspect-deployed-rules.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAuB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,4EAA4E;AAC5E,qEAAqE;AACrE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAe7E,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,OAAe,EAAkC,EAAE,CAAC,CAAC;IAClF,EAAE,EAAE,KAAK;IACT,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;CACzB,CAAC,C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W;gBAC7B,cAAc,EAAE,MAAM,IAAI,CAAC,cAAc,EAAE;gBAC3C,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACzD,CAAC,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;gBACf,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,mBAAmB,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YACzF,CAAC;YACD,OAAO;gBACL,EAAE,EAAE,IAAI;gBACR,OAAO,EACL,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;oBACtB,CAAC,CAAC,gDAAgD;oBAClD,CAAC,CAAC,+CAA+C,MAAM,CAAC,IAAI,CAAC,MAAM,sBAAsB;gBAC7F,IAAI,EAAE,MAAM;aACb,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1137,6 +1137,11 @@
|
|
|
1137
1137
|
"slug": "ship-the-json",
|
|
1138
1138
|
"text": "Ship the JSON"
|
|
1139
1139
|
},
|
|
1140
|
+
{
|
|
1141
|
+
"depth": 2,
|
|
1142
|
+
"slug": "compare-compiled-rules-with-the-rules-you-wrote-by-hand",
|
|
1143
|
+
"text": "Compare compiled rules with the rules you wrote by hand"
|
|
1144
|
+
},
|
|
1140
1145
|
{
|
|
1141
1146
|
"depth": 2,
|
|
1142
1147
|
"slug": "turn-enforcement-from-a-deployed-game",
|
|
@@ -7567,6 +7572,11 @@
|
|
|
7567
7572
|
"slug": "classes",
|
|
7568
7573
|
"text": "Classes"
|
|
7569
7574
|
},
|
|
7575
|
+
{
|
|
7576
|
+
"depth": 3,
|
|
7577
|
+
"slug": "rtdbexpressionsyntaxerror",
|
|
7578
|
+
"text": "RtdbExpressionSyntaxError"
|
|
7579
|
+
},
|
|
7570
7580
|
{
|
|
7571
7581
|
"depth": 3,
|
|
7572
7582
|
"slug": "rulesassertionerror",
|
|
@@ -7592,6 +7602,11 @@
|
|
|
7592
7602
|
"slug": "caseresult",
|
|
7593
7603
|
"text": "CaseResult"
|
|
7594
7604
|
},
|
|
7605
|
+
{
|
|
7606
|
+
"depth": 3,
|
|
7607
|
+
"slug": "diffrtdbrulesoptions",
|
|
7608
|
+
"text": "DiffRtdbRulesOptions"
|
|
7609
|
+
},
|
|
7595
7610
|
{
|
|
7596
7611
|
"depth": 3,
|
|
7597
7612
|
"slug": "evaluatedruleinfo",
|
|
@@ -7692,6 +7707,11 @@
|
|
|
7692
7707
|
"slug": "rtdbfirebasejsonoptions",
|
|
7693
7708
|
"text": "RtdbFirebaseJsonOptions"
|
|
7694
7709
|
},
|
|
7710
|
+
{
|
|
7711
|
+
"depth": 3,
|
|
7712
|
+
"slug": "rtdbrulechange",
|
|
7713
|
+
"text": "RtdbRuleChange"
|
|
7714
|
+
},
|
|
7695
7715
|
{
|
|
7696
7716
|
"depth": 3,
|
|
7697
7717
|
"slug": "rtdbrulecoverage",
|
|
@@ -7822,6 +7842,11 @@
|
|
|
7822
7842
|
"slug": "rtdbruleevaluation",
|
|
7823
7843
|
"text": "RtdbRuleEvaluation"
|
|
7824
7844
|
},
|
|
7845
|
+
{
|
|
7846
|
+
"depth": 3,
|
|
7847
|
+
"slug": "rtdbrulekind",
|
|
7848
|
+
"text": "RtdbRuleKind"
|
|
7849
|
+
},
|
|
7825
7850
|
{
|
|
7826
7851
|
"depth": 3,
|
|
7827
7852
|
"slug": "rtdbrulesfindingrule",
|
|
@@ -8097,11 +8122,21 @@
|
|
|
8097
8122
|
"slug": "bytes",
|
|
8098
8123
|
"text": "bytes()"
|
|
8099
8124
|
},
|
|
8125
|
+
{
|
|
8126
|
+
"depth": 3,
|
|
8127
|
+
"slug": "canonicalrtdbexpression",
|
|
8128
|
+
"text": "canonicalRtdbExpression()"
|
|
8129
|
+
},
|
|
8100
8130
|
{
|
|
8101
8131
|
"depth": 3,
|
|
8102
8132
|
"slug": "definertdbrules",
|
|
8103
8133
|
"text": "defineRtdbRules()"
|
|
8104
8134
|
},
|
|
8135
|
+
{
|
|
8136
|
+
"depth": 3,
|
|
8137
|
+
"slug": "diffrtdbrules",
|
|
8138
|
+
"text": "diffRtdbRules()"
|
|
8139
|
+
},
|
|
8105
8140
|
{
|
|
8106
8141
|
"depth": 3,
|
|
8107
8142
|
"slug": "duration",
|