primitive-admin 1.3.0-alpha.0 → 1.3.0-alpha.2
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 +45 -0
- package/dist/src/commands/admins.js +91 -0
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/auth-passkeys.d.ts +7 -0
- package/dist/src/commands/auth-passkeys.js +99 -0
- package/dist/src/commands/auth-passkeys.js.map +1 -0
- package/dist/src/commands/auth-sessions.js +7 -28
- package/dist/src/commands/auth-sessions.js.map +1 -1
- package/dist/src/commands/auth.js +32 -6
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/db3-types.d.ts +27 -0
- package/dist/src/commands/db3-types.js +288 -2
- package/dist/src/commands/db3-types.js.map +1 -1
- package/dist/src/commands/db3.d.ts +16 -2
- package/dist/src/commands/db3.js +614 -5
- package/dist/src/commands/db3.js.map +1 -1
- package/dist/src/commands/documents.js +7 -0
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/functions.js +8 -3
- package/dist/src/commands/functions.js.map +1 -1
- package/dist/src/commands/hosting.js +177 -14
- package/dist/src/commands/hosting.js.map +1 -1
- package/dist/src/commands/metadata.js +14 -6
- package/dist/src/commands/metadata.js.map +1 -1
- package/dist/src/commands/secrets.d.ts +38 -0
- package/dist/src/commands/secrets.js +102 -4
- package/dist/src/commands/secrets.js.map +1 -1
- package/dist/src/commands/spent-tokens.d.ts +19 -0
- package/dist/src/commands/spent-tokens.js +79 -0
- package/dist/src/commands/spent-tokens.js.map +1 -0
- package/dist/src/commands/sync-app-settings.d.ts +145 -0
- package/dist/src/commands/sync-app-settings.js +341 -8
- package/dist/src/commands/sync-app-settings.js.map +1 -1
- package/dist/src/commands/sync.d.ts +62 -15
- package/dist/src/commands/sync.js +437 -48
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/usage.d.ts +24 -0
- package/dist/src/commands/usage.js +54 -0
- package/dist/src/commands/usage.js.map +1 -1
- package/dist/src/commands/users.js +41 -1
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/lib/admin-login-tables.d.ts +31 -0
- package/dist/src/lib/admin-login-tables.js +75 -0
- package/dist/src/lib/admin-login-tables.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +241 -0
- package/dist/src/lib/api-client.js +203 -10
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +42 -3
- package/dist/src/lib/app-settings-descriptor.js +114 -1
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/auth-flow.d.ts +13 -0
- package/dist/src/lib/auth-flow.js +23 -2
- package/dist/src/lib/auth-flow.js.map +1 -1
- package/dist/src/lib/command-groups.js +2 -0
- package/dist/src/lib/command-groups.js.map +1 -1
- package/dist/src/lib/config-object-descriptor.js +6 -1
- package/dist/src/lib/config-object-descriptor.js.map +1 -1
- package/dist/src/lib/credentials-store.d.ts +19 -0
- package/dist/src/lib/credentials-store.js +66 -2
- package/dist/src/lib/credentials-store.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTypeIR.d.ts +2 -0
- package/dist/src/lib/db-codegen/dbTypeIR.js +3 -1
- package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
- package/dist/src/lib/db-type-records.d.ts +20 -1
- package/dist/src/lib/db-type-records.js +17 -4
- package/dist/src/lib/db-type-records.js.map +1 -1
- package/dist/src/lib/db3-export.d.ts +43 -8
- package/dist/src/lib/db3-export.js +133 -13
- package/dist/src/lib/db3-export.js.map +1 -1
- package/dist/src/lib/db3-json-fields.d.ts +49 -0
- package/dist/src/lib/db3-json-fields.js +195 -0
- package/dist/src/lib/db3-json-fields.js.map +1 -0
- package/dist/src/lib/db3-type-archive.d.ts +59 -0
- package/dist/src/lib/db3-type-archive.js +95 -0
- package/dist/src/lib/db3-type-archive.js.map +1 -0
- package/dist/src/lib/db3-type-models.d.ts +15 -1
- package/dist/src/lib/db3-type-models.js +147 -16
- package/dist/src/lib/db3-type-models.js.map +1 -1
- package/dist/src/lib/document-export-record-log.d.ts +7 -0
- package/dist/src/lib/document-export-record-log.js +9 -0
- package/dist/src/lib/document-export-record-log.js.map +1 -1
- package/dist/src/lib/document-ingest-artifact.d.ts +6 -0
- package/dist/src/lib/document-ingest-artifact.js +20 -1
- package/dist/src/lib/document-ingest-artifact.js.map +1 -1
- package/dist/src/lib/function-authorize-check.js +5 -0
- package/dist/src/lib/function-authorize-check.js.map +1 -1
- package/dist/src/lib/function-authorize-view.d.ts +9 -0
- package/dist/src/lib/function-authorize-view.js +27 -4
- package/dist/src/lib/function-authorize-view.js.map +1 -1
- package/dist/src/lib/function-collect.d.ts +28 -0
- package/dist/src/lib/function-collect.js +129 -2
- package/dist/src/lib/function-collect.js.map +1 -1
- package/dist/src/lib/function-db-types.js +31 -2
- package/dist/src/lib/function-db-types.js.map +1 -1
- package/dist/src/lib/function-grants-preflight.d.ts +99 -0
- package/dist/src/lib/function-grants-preflight.js +154 -2
- package/dist/src/lib/function-grants-preflight.js.map +1 -1
- package/dist/src/lib/function-lint.d.ts +29 -1
- package/dist/src/lib/function-lint.js +208 -0
- package/dist/src/lib/function-lint.js.map +1 -1
- package/dist/src/lib/function-sync.d.ts +73 -0
- package/dist/src/lib/function-sync.js +107 -2
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/generated-command-status.js +46 -8
- package/dist/src/lib/generated-command-status.js.map +1 -1
- package/dist/src/lib/generated-config-surfaces.d.ts +351 -9
- package/dist/src/lib/generated-config-surfaces.js +1009 -24
- package/dist/src/lib/generated-config-surfaces.js.map +1 -1
- package/dist/src/lib/generated-sdk-types.d.ts +1 -1
- package/dist/src/lib/generated-sdk-types.js +1 -1
- package/dist/src/lib/generated-sdk-types.js.map +1 -1
- package/dist/src/lib/hosting-trust-step.d.ts +67 -0
- package/dist/src/lib/hosting-trust-step.js +279 -0
- package/dist/src/lib/hosting-trust-step.js.map +1 -0
- package/dist/src/lib/hosting-trust.d.ts +77 -0
- package/dist/src/lib/hosting-trust.js +194 -0
- package/dist/src/lib/hosting-trust.js.map +1 -0
- package/dist/src/lib/primitive-declaration.js +89 -10
- package/dist/src/lib/primitive-declaration.js.map +1 -1
- package/dist/src/lib/refresh-admin-credentials.d.ts +34 -4
- package/dist/src/lib/refresh-admin-credentials.js +85 -29
- package/dist/src/lib/refresh-admin-credentials.js.map +1 -1
- package/dist/src/lib/refresh-stored-login.d.ts +85 -0
- package/dist/src/lib/refresh-stored-login.js +233 -0
- package/dist/src/lib/refresh-stored-login.js.map +1 -0
- package/dist/src/lib/row-field-rename.d.ts +18 -0
- package/dist/src/lib/row-field-rename.js +32 -0
- package/dist/src/lib/row-field-rename.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +13 -2
- package/dist/src/lib/schema-codegen/generated-field-grammar.js +24 -1
- package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -1
- package/dist/src/lib/schema-defs-module.d.ts +29 -0
- package/dist/src/lib/schema-defs-module.js +103 -0
- package/dist/src/lib/schema-defs-module.js.map +1 -0
- package/dist/src/lib/swift-codegen/sharedGenerator.d.ts +6 -0
- package/dist/src/lib/swift-codegen/sharedGenerator.js +74 -0
- package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -1
- package/dist/src/lib/toml-list-edit.d.ts +33 -0
- package/dist/src/lib/toml-list-edit.js +481 -0
- package/dist/src/lib/toml-list-edit.js.map +1 -0
- package/dist/src/lib/toml-scalar-edit.d.ts +9 -0
- package/dist/src/lib/toml-scalar-edit.js +67 -1
- package/dist/src/lib/toml-scalar-edit.js.map +1 -1
- package/dist/src/lib/usage-meters.d.ts +16 -0
- package/dist/src/lib/usage-meters.js +52 -0
- package/dist/src/lib/usage-meters.js.map +1 -0
- package/dist/src/types/index.d.ts +9 -0
- package/package.json +2 -2
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A db3 JSON field's object def, as the push preflight and `functions codegen`
|
|
3
|
+
* hold it to what the clients can check (#5899).
|
|
4
|
+
*
|
|
5
|
+
* A field whose `ref` names a `schemas/` object def is stored as canonical
|
|
6
|
+
* JSON text, and the web and Swift clients validate a value against the def's
|
|
7
|
+
* compiled schema before it is stored. Each client implements the keywords of
|
|
8
|
+
* {@link DB3_JSON_KEYWORDS} and no other, so a def a db3 field refs may use
|
|
9
|
+
* only those; the same def used by no db3 field is held to nothing here.
|
|
10
|
+
*/
|
|
11
|
+
import { join } from "path";
|
|
12
|
+
import { parseConfigToml } from "./config-toml.js";
|
|
13
|
+
import { readDb3TypesDir, resolveDb3TypeModels } from "./db3-type-models.js";
|
|
14
|
+
import { loadSchemaFamilyIndex } from "./schema-family-index.js";
|
|
15
|
+
/**
|
|
16
|
+
* The keywords both client validators implement, with the meaning the server's
|
|
17
|
+
* validator gives each: the structural keywords, the bounds, and the
|
|
18
|
+
* annotations, which no validator reads. `additionalProperties` is a boolean
|
|
19
|
+
* and `items` one schema; `oneOf` is the enum-tagged union the dialect allows.
|
|
20
|
+
*/
|
|
21
|
+
export const DB3_JSON_KEYWORDS = Object.freeze([
|
|
22
|
+
"type",
|
|
23
|
+
"enum",
|
|
24
|
+
"properties",
|
|
25
|
+
"required",
|
|
26
|
+
"additionalProperties",
|
|
27
|
+
"items",
|
|
28
|
+
"oneOf",
|
|
29
|
+
"minimum",
|
|
30
|
+
"maximum",
|
|
31
|
+
"minLength",
|
|
32
|
+
"maxLength",
|
|
33
|
+
"pattern",
|
|
34
|
+
"minItems",
|
|
35
|
+
"maxItems",
|
|
36
|
+
"title",
|
|
37
|
+
"description",
|
|
38
|
+
"default",
|
|
39
|
+
"format",
|
|
40
|
+
"examples",
|
|
41
|
+
"$comment",
|
|
42
|
+
"deprecated",
|
|
43
|
+
"readOnly",
|
|
44
|
+
"writeOnly",
|
|
45
|
+
]);
|
|
46
|
+
const ALLOWED = new Set(DB3_JSON_KEYWORDS);
|
|
47
|
+
const isTable = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
48
|
+
/**
|
|
49
|
+
* The first keyword of a compiled schema the client validators do not
|
|
50
|
+
* implement, as a phrase (`uniqueItems (at properties.tags)`), or null. A node's
|
|
51
|
+
* own keywords are read before the nodes below it.
|
|
52
|
+
*/
|
|
53
|
+
export function db3JsonKeywordProblem(schema, at = []) {
|
|
54
|
+
if (!isTable(schema))
|
|
55
|
+
return null;
|
|
56
|
+
const where = at.length === 0 ? "at the root" : `at ${at.join(".")}`;
|
|
57
|
+
for (const key of Object.keys(schema)) {
|
|
58
|
+
if (!ALLOWED.has(key))
|
|
59
|
+
return `${key} (${where})`;
|
|
60
|
+
if (key === "additionalProperties" && typeof schema[key] !== "boolean")
|
|
61
|
+
return `additionalProperties (a schema, ${where})`;
|
|
62
|
+
if (key === "items" && !isTable(schema[key]))
|
|
63
|
+
return `items (a list of schemas, ${where})`;
|
|
64
|
+
}
|
|
65
|
+
if (isTable(schema.properties)) {
|
|
66
|
+
for (const [name, child] of Object.entries(schema.properties)) {
|
|
67
|
+
const found = db3JsonKeywordProblem(child, [...at, "properties", name]);
|
|
68
|
+
if (found)
|
|
69
|
+
return found;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (isTable(schema.items)) {
|
|
73
|
+
const found = db3JsonKeywordProblem(schema.items, [...at, "items"]);
|
|
74
|
+
if (found)
|
|
75
|
+
return found;
|
|
76
|
+
}
|
|
77
|
+
if (Array.isArray(schema.oneOf)) {
|
|
78
|
+
for (const [index, member] of schema.oneOf.entries()) {
|
|
79
|
+
const found = db3JsonKeywordProblem(member, [...at, "oneOf", String(index)]);
|
|
80
|
+
if (found)
|
|
81
|
+
return found;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Whether `pattern` holds a backreference (`\1`, `\k<name>`) outside a character
|
|
88
|
+
* class. ECMAScript resets a group's capture on each repetition of its
|
|
89
|
+
* quantifier and matches a backreference to a group that took no part as
|
|
90
|
+
* empty; ICU, under the Swift client's validator, keeps the earlier capture and
|
|
91
|
+
* fails it, so the two clients would answer the same value differently. Every
|
|
92
|
+
* pattern is compiled with the `u` flag, under which `\<digit>` and `\k` mean
|
|
93
|
+
* nothing else.
|
|
94
|
+
*/
|
|
95
|
+
export function patternHasBackreference(pattern) {
|
|
96
|
+
let inClass = false;
|
|
97
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
98
|
+
const c = pattern[i];
|
|
99
|
+
if (c === "\\") {
|
|
100
|
+
const next = pattern[i + 1];
|
|
101
|
+
if (!inClass && next !== undefined && (/[1-9]/.test(next) || next === "k"))
|
|
102
|
+
return true;
|
|
103
|
+
i++;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (inClass) {
|
|
107
|
+
if (c === "]")
|
|
108
|
+
inClass = false;
|
|
109
|
+
}
|
|
110
|
+
else if (c === "[") {
|
|
111
|
+
inClass = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The first `pattern` of a compiled schema holding a backreference, as a
|
|
118
|
+
* phrase (`a backreference in pattern (at properties.code)`), or null.
|
|
119
|
+
*/
|
|
120
|
+
export function db3JsonPatternProblem(schema, at = []) {
|
|
121
|
+
if (!isTable(schema))
|
|
122
|
+
return null;
|
|
123
|
+
if (typeof schema.pattern === "string" && patternHasBackreference(schema.pattern)) {
|
|
124
|
+
return `a backreference in pattern (${at.length === 0 ? "at the root" : `at ${at.join(".")}`})`;
|
|
125
|
+
}
|
|
126
|
+
const children = [
|
|
127
|
+
...(isTable(schema.properties) ? Object.entries(schema.properties).map(([name, child]) => [child, ["properties", name]]) : []),
|
|
128
|
+
...(isTable(schema.items) ? [[schema.items, ["items"]]] : []),
|
|
129
|
+
...(Array.isArray(schema.oneOf) ? schema.oneOf.map((member, index) => [member, ["oneOf", String(index)]]) : []),
|
|
130
|
+
];
|
|
131
|
+
for (const [child, step] of children) {
|
|
132
|
+
const found = db3JsonPatternProblem(child, [...at, ...step]);
|
|
133
|
+
if (found)
|
|
134
|
+
return found;
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Each JSON field of the tree's `db3-types/` whose def uses a keyword outside
|
|
140
|
+
* {@link DB3_JSON_KEYWORDS}, named at the file that declares the field. A def
|
|
141
|
+
* whose file does not compile is left to the `schemas/` preflight.
|
|
142
|
+
*/
|
|
143
|
+
export function db3JsonDefRefusals(configDir) {
|
|
144
|
+
const db3Dir = join(configDir, "db3-types");
|
|
145
|
+
const { jsonFields } = resolveDb3TypeModels(db3Dir);
|
|
146
|
+
if (jsonFields.size === 0)
|
|
147
|
+
return [];
|
|
148
|
+
const compiled = new Map();
|
|
149
|
+
for (const local of loadSchemaFamilyIndex(configDir).locals) {
|
|
150
|
+
const compile = local.compile;
|
|
151
|
+
if (compile && compile.ok)
|
|
152
|
+
compiled.set(local.file, compile.defs);
|
|
153
|
+
}
|
|
154
|
+
const contents = readDb3TypesDir(db3Dir);
|
|
155
|
+
const refusals = [];
|
|
156
|
+
for (const [file, models] of jsonFields) {
|
|
157
|
+
let parsed;
|
|
158
|
+
try {
|
|
159
|
+
parsed = parseConfigToml(contents.get(file) ?? "");
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
for (const [model, fields] of models) {
|
|
165
|
+
for (const [field, def] of fields) {
|
|
166
|
+
// A model the file names through `[type] models` is reported where it is declared.
|
|
167
|
+
const raw = parsed?.models?.[model]?.fields?.[field];
|
|
168
|
+
if (!isTable(raw) || !("ref" in raw))
|
|
169
|
+
continue;
|
|
170
|
+
const defs = compiled.get(def.file);
|
|
171
|
+
if (!defs || !Object.prototype.hasOwnProperty.call(defs, def.name))
|
|
172
|
+
continue;
|
|
173
|
+
const at = `db3-types/${file}: [models.${model}.fields.${field}] ref ${JSON.stringify(raw.ref)}: schemas/${def.file}.toml#${def.name} uses`;
|
|
174
|
+
const problem = db3JsonKeywordProblem(defs[def.name]);
|
|
175
|
+
if (problem) {
|
|
176
|
+
refusals.push({
|
|
177
|
+
file,
|
|
178
|
+
message: `${at} ${problem}, which the client validators do not implement; a def a db3 field refs may use only ${DB3_JSON_KEYWORDS.join(", ")}.`,
|
|
179
|
+
});
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const backreference = db3JsonPatternProblem(defs[def.name]);
|
|
183
|
+
if (backreference) {
|
|
184
|
+
refusals.push({
|
|
185
|
+
file,
|
|
186
|
+
message: `${at} ${backreference}, which JavaScript and the Swift client's regular expressions evaluate differently; ` +
|
|
187
|
+
"a def a db3 field refs may not use a backreference (\\1 or \\k<name>) in a pattern.",
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return refusals;
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=db3-json-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db3-json-fields.js","sourceRoot":"","sources":["../../../src/lib/db3-json-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,MAAM;IACN,MAAM;IACN,YAAY;IACZ,UAAU;IACV,sBAAsB;IACtB,OAAO;IACP,OAAO;IACP,SAAS;IACT,SAAS;IACT,WAAW;IACX,WAAW;IACX,SAAS;IACT,UAAU;IACV,UAAU;IACV,OAAO;IACP,aAAa;IACb,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,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;qBAChJ,CAAC,CAAC;oBACH,SAAS;gBACX,CAAC;gBACD,MAAM,aAAa,GAAG,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC5D,IAAI,aAAa,EAAE,CAAC;oBAClB,QAAQ,CAAC,IAAI,CAAC;wBACZ,IAAI;wBACJ,OAAO,EACL,GAAG,EAAE,IAAI,aAAa,sFAAsF;4BAC5G,qFAAqF;qBACxF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pure parts of `primitive db3-types archive|unarchive` (#6020): which
|
|
3
|
+
* file declares a type, how its `archived` key is edited, and what a failed
|
|
4
|
+
* push means for the file.
|
|
5
|
+
*
|
|
6
|
+
* The commands edit `[type] archived` in the type's `db3-types/` file and
|
|
7
|
+
* push that one type through `config push`. A push the server refused with
|
|
8
|
+
* an answer (any 4xx) stored nothing, so the file is put back. A push that
|
|
9
|
+
* ended without such an answer (no answer at all, an unreadable one, a 5xx)
|
|
10
|
+
* may have been stored, so the server is read before the file is touched.
|
|
11
|
+
*/
|
|
12
|
+
import type { Db3TypePushReport } from "../commands/sync.js";
|
|
13
|
+
/** What a failed push means: `refused` (nothing stored) or `unknown` (perhaps stored). */
|
|
14
|
+
export type ArchivePushFailureKind = "refused" | "unknown";
|
|
15
|
+
/**
|
|
16
|
+
* Classify a failed push: an error carrying an HTTP status from 400 to 499
|
|
17
|
+
* is the server's answer, which stored nothing (`refused`); any other
|
|
18
|
+
* failure — no status (the connection failed, the body could not be read),
|
|
19
|
+
* a 5xx — may follow a stored write (`unknown`).
|
|
20
|
+
*/
|
|
21
|
+
export declare function archivePushFailureKind(err: unknown): ArchivePushFailureKind;
|
|
22
|
+
/** The `db3-types/` file that declares `type`: by its `[type] name`, else by its file name. */
|
|
23
|
+
export declare function findDb3TypeFile(db3TypesDir: string, type: string): {
|
|
24
|
+
file: string;
|
|
25
|
+
filePath: string;
|
|
26
|
+
} | null;
|
|
27
|
+
/**
|
|
28
|
+
* The file's text with `[type] archived` set to the asked state: `archived =
|
|
29
|
+
* true` written in place (comments and key order kept), or the line removed,
|
|
30
|
+
* every other byte unchanged.
|
|
31
|
+
*/
|
|
32
|
+
export declare function withArchivedKey(text: string, archived: boolean): string;
|
|
33
|
+
/**
|
|
34
|
+
* A copy of a parsed `db3-types/` document without `[type] archived`, for
|
|
35
|
+
* comparing everything else the file holds with the server. The copy keeps
|
|
36
|
+
* each TOML date its kind (`cloneTomlValue`, not `structuredClone`): a local
|
|
37
|
+
* date default read back as a plain `Date` compares as a change.
|
|
38
|
+
*/
|
|
39
|
+
export declare function withoutArchivedKey<T>(document: T): T;
|
|
40
|
+
/** A push failure as the commands print it. */
|
|
41
|
+
export type ArchivePushFailure = {
|
|
42
|
+
message: string;
|
|
43
|
+
code?: string;
|
|
44
|
+
statusCode?: number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* What a `config push` run that did not report `applied` means for the file.
|
|
48
|
+
* Only an answer that settles it is `refused`: a 4xx from the server, or a
|
|
49
|
+
* gate decline before any request. Everything else is `unknown`, the write
|
|
50
|
+
* may have been stored, and the server is read before the file is touched:
|
|
51
|
+
* a 5xx or a failure with no status, a `skipped` report, and no report at
|
|
52
|
+
* all (the child can end after its `PUT` and before writing the report, and
|
|
53
|
+
* a report that cannot be written is ignored). `pushOutput` is the tail of
|
|
54
|
+
* the push's own output, quoted when there is no report.
|
|
55
|
+
*/
|
|
56
|
+
export declare function archivePushOutcome(report: Db3TypePushReport | null, type: string, pushOutput: string): {
|
|
57
|
+
kind: ArchivePushFailureKind;
|
|
58
|
+
failure: ArchivePushFailure | null;
|
|
59
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pure parts of `primitive db3-types archive|unarchive` (#6020): which
|
|
3
|
+
* file declares a type, how its `archived` key is edited, and what a failed
|
|
4
|
+
* push means for the file.
|
|
5
|
+
*
|
|
6
|
+
* The commands edit `[type] archived` in the type's `db3-types/` file and
|
|
7
|
+
* push that one type through `config push`. A push the server refused with
|
|
8
|
+
* an answer (any 4xx) stored nothing, so the file is put back. A push that
|
|
9
|
+
* ended without such an answer (no answer at all, an unreadable one, a 5xx)
|
|
10
|
+
* may have been stored, so the server is read before the file is touched.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readFileSync, readdirSync } from "fs";
|
|
13
|
+
import { basename, join } from "path";
|
|
14
|
+
import { parseRawToml } from "./config-toml.js";
|
|
15
|
+
import { cloneTomlValue } from "./db3-type-models.js";
|
|
16
|
+
import { removeTomlScalar, setTomlScalar } from "./toml-scalar-edit.js";
|
|
17
|
+
/**
|
|
18
|
+
* Classify a failed push: an error carrying an HTTP status from 400 to 499
|
|
19
|
+
* is the server's answer, which stored nothing (`refused`); any other
|
|
20
|
+
* failure — no status (the connection failed, the body could not be read),
|
|
21
|
+
* a 5xx — may follow a stored write (`unknown`).
|
|
22
|
+
*/
|
|
23
|
+
export function archivePushFailureKind(err) {
|
|
24
|
+
const status = err?.statusCode;
|
|
25
|
+
return typeof status === "number" && status >= 400 && status <= 499 ? "refused" : "unknown";
|
|
26
|
+
}
|
|
27
|
+
/** The `db3-types/` file that declares `type`: by its `[type] name`, else by its file name. */
|
|
28
|
+
export function findDb3TypeFile(db3TypesDir, type) {
|
|
29
|
+
if (!existsSync(db3TypesDir))
|
|
30
|
+
return null;
|
|
31
|
+
const files = readdirSync(db3TypesDir).filter((f) => f.endsWith(".toml")).sort();
|
|
32
|
+
let byName = null;
|
|
33
|
+
for (const file of files) {
|
|
34
|
+
try {
|
|
35
|
+
const parsed = parseRawToml(readFileSync(join(db3TypesDir, file), "utf-8"));
|
|
36
|
+
const declared = parsed?.type?.name;
|
|
37
|
+
if (declared === type)
|
|
38
|
+
return { file, filePath: join(db3TypesDir, file) };
|
|
39
|
+
if (declared === undefined && basename(file, ".toml") === type)
|
|
40
|
+
byName = file;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
if (basename(file, ".toml") === type)
|
|
44
|
+
byName = file;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return byName ? { file: byName, filePath: join(db3TypesDir, byName) } : null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The file's text with `[type] archived` set to the asked state: `archived =
|
|
51
|
+
* true` written in place (comments and key order kept), or the line removed,
|
|
52
|
+
* every other byte unchanged.
|
|
53
|
+
*/
|
|
54
|
+
export function withArchivedKey(text, archived) {
|
|
55
|
+
return archived ? setTomlScalar(text, "type.archived", true) : removeTomlScalar(text, "type.archived");
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A copy of a parsed `db3-types/` document without `[type] archived`, for
|
|
59
|
+
* comparing everything else the file holds with the server. The copy keeps
|
|
60
|
+
* each TOML date its kind (`cloneTomlValue`, not `structuredClone`): a local
|
|
61
|
+
* date default read back as a plain `Date` compares as a change.
|
|
62
|
+
*/
|
|
63
|
+
export function withoutArchivedKey(document) {
|
|
64
|
+
const copy = cloneTomlValue(document);
|
|
65
|
+
if (copy?.type && typeof copy.type === "object")
|
|
66
|
+
delete copy.type.archived;
|
|
67
|
+
return copy;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* What a `config push` run that did not report `applied` means for the file.
|
|
71
|
+
* Only an answer that settles it is `refused`: a 4xx from the server, or a
|
|
72
|
+
* gate decline before any request. Everything else is `unknown`, the write
|
|
73
|
+
* may have been stored, and the server is read before the file is touched:
|
|
74
|
+
* a 5xx or a failure with no status, a `skipped` report, and no report at
|
|
75
|
+
* all (the child can end after its `PUT` and before writing the report, and
|
|
76
|
+
* a report that cannot be written is ignored). `pushOutput` is the tail of
|
|
77
|
+
* the push's own output, quoted when there is no report.
|
|
78
|
+
*/
|
|
79
|
+
export function archivePushOutcome(report, type, pushOutput) {
|
|
80
|
+
if (report?.outcome === "failed")
|
|
81
|
+
return { kind: archivePushFailureKind(report.failure), failure: report.failure };
|
|
82
|
+
if (report?.outcome === "declined") {
|
|
83
|
+
return {
|
|
84
|
+
kind: "refused",
|
|
85
|
+
failure: {
|
|
86
|
+
message: `config push declined the type (${report.action}): the server's row moved since this tree last read it. ` +
|
|
87
|
+
`Run \`primitive config pull --only db3-type/${type}\`, then run this command again`,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (report?.outcome === "skipped")
|
|
92
|
+
return { kind: "unknown", failure: null };
|
|
93
|
+
return { kind: "unknown", failure: { message: `config push ended without reporting the type:\n${pushOutput}` } };
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=db3-type-archive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db3-type-archive.js","sourceRoot":"","sources":["../../../src/lib/db3-type-archive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAKxE;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAY;IACjD,MAAM,MAAM,GAAI,GAAmD,EAAE,UAAU,CAAC;IAChF,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9F,CAAC;AAED,+FAA+F;AAC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E,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACzG,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAI,QAAW;IAC/C,MAAM,IAAI,GAAG,cAAc,CAAC,QAAQ,CAAQ,CAAC;IAC7C,IAAI,IAAI,EAAE,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC3E,OAAO,IAAI,CAAC;AACd,CAAC;AAKD;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAgC,EAChC,IAAY,EACZ,UAAkB;IAElB,IAAI,MAAM,EAAE,OAAO,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IACnH,IAAI,MAAM,EAAE,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO;YACL,IAAI,EAAE,SAAS;YACf,OAAO,EAAE;gBACP,OAAO,EACL,kCAAkC,MAAM,CAAC,MAAM,0DAA0D;oBACzG,+CAA+C,IAAI,iCAAiC;aACvF;SACF,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,EAAE,OAAO,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,kDAAkD,UAAU,EAAE,EAAE,EAAE,CAAC;AACnH,CAAC"}
|
|
@@ -19,8 +19,12 @@
|
|
|
19
19
|
* A field may also `ref` a shared enum in the `schemas/` directory beside
|
|
20
20
|
* `db3-types/` (#5545): the resolved document holds `type = "string"` and the
|
|
21
21
|
* enum's values where the `ref` was, in every declaration that carries it.
|
|
22
|
+
* In a file with a `[type]` table it may `ref` an object def there too
|
|
23
|
+
* (#5899): a JSON field, stored as canonical JSON text, whose resolved field
|
|
24
|
+
* is `type = "string"` with only `required` beside it. The def is answered
|
|
25
|
+
* beside the document (`jsonFields`), for the generators only.
|
|
22
26
|
*/
|
|
23
|
-
import { type SharedEnumKeys, type SharedEnumRef } from "js-bao";
|
|
27
|
+
import { type SharedEnumKeys, type SharedEnumRef, type SharedObjectRef } from "js-bao";
|
|
24
28
|
/** One refusal: the sentence, and the files (by name in `db3-types/`) it is about. */
|
|
25
29
|
export interface Db3TypeModelsRefusal {
|
|
26
30
|
files: string[];
|
|
@@ -31,6 +35,8 @@ export interface Db3TypeModelsRefusal {
|
|
|
31
35
|
* push sends, carries no trace of it.
|
|
32
36
|
*/
|
|
33
37
|
export type Db3EnumRefs = Map<string, Map<string, SharedEnumRef>>;
|
|
38
|
+
/** #5899 — the object def each JSON field's `ref` named, by model then field. Codegen only, as `Db3EnumRefs` is. */
|
|
39
|
+
export type Db3JsonFields = Map<string, Map<string, SharedObjectRef>>;
|
|
34
40
|
export interface Db3TypeModelsResolution {
|
|
35
41
|
/** Per file name, the resolved document. A refused file is absent. */
|
|
36
42
|
documents: Map<string, any>;
|
|
@@ -42,6 +48,8 @@ export interface Db3TypeModelsResolution {
|
|
|
42
48
|
* names through `[type] models` brings the declaring file's.
|
|
43
49
|
*/
|
|
44
50
|
enumRefs: Map<string, Db3EnumRefs>;
|
|
51
|
+
/** #5899 — per resolved file that holds one, each JSON field with its object def, gathered as `enumRefs` is. */
|
|
52
|
+
jsonFields: Map<string, Db3JsonFields>;
|
|
45
53
|
}
|
|
46
54
|
/**
|
|
47
55
|
* What a field's shared-enum `ref` resolves against (#5545): the `schemas/`
|
|
@@ -88,6 +96,12 @@ export declare function resolveDb3TypeModels(db3TypesDir: string): Db3TypeModels
|
|
|
88
96
|
* (the preflight reports it), is returned as given.
|
|
89
97
|
*/
|
|
90
98
|
export declare function resolveDb3TypeDocument(db3TypesDir: string, file: string, parsed: any): any;
|
|
99
|
+
/**
|
|
100
|
+
* #5899 — each field of a `database-type-configs/` file whose `ref` names an
|
|
101
|
+
* object def: a JSON field belongs to a db3 type in `db3-types/`, which is the
|
|
102
|
+
* only directory whose refs the CLI expands.
|
|
103
|
+
*/
|
|
104
|
+
export declare function databaseTypeConfigJsonRefusals(configDir: string): Db3TypeModelsRefusal[];
|
|
91
105
|
/** The pull's decision for the reference-form files of `db3-types/`. */
|
|
92
106
|
export interface Db3TypePullPlan {
|
|
93
107
|
/** Local reference-form files whose resolved document reads as the server row: left as they are. */
|