primitive-admin 1.1.0-alpha.74 → 1.1.0-alpha.76
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/bin/primitive.js +110 -21
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/collection-type-configs.js +1 -1
- package/dist/src/commands/collection-type-configs.js.map +1 -1
- package/dist/src/commands/config.js +8 -4
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/database-type-configs.js +1 -1
- package/dist/src/commands/database-type-configs.js.map +1 -1
- package/dist/src/commands/databases.js +25 -31
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.js +9 -24
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/env.d.ts +1 -1
- package/dist/src/commands/env.js +14 -11
- package/dist/src/commands/env.js.map +1 -1
- package/dist/src/commands/functions.js +173 -4
- package/dist/src/commands/functions.js.map +1 -1
- package/dist/src/commands/groups.js +1 -1
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/init.d.ts +12 -15
- package/dist/src/commands/init.js +36 -77
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/prompts.js +54 -39
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rule-sets.js +1 -1
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/scripts.js +17 -4
- package/dist/src/commands/scripts.js.map +1 -1
- package/dist/src/commands/sync-app-settings.js +2 -4
- package/dist/src/commands/sync-app-settings.js.map +1 -1
- package/dist/src/commands/sync.d.ts +41 -2
- package/dist/src/commands/sync.js +635 -364
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/workflows.js +62 -31
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/api-client.d.ts +23 -2
- package/dist/src/lib/api-client.js +24 -5
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-match-guard.d.ts +44 -0
- package/dist/src/lib/app-match-guard.js +72 -0
- package/dist/src/lib/app-match-guard.js.map +1 -0
- package/dist/src/lib/block-selector.d.ts +58 -0
- package/dist/src/lib/block-selector.js +92 -0
- package/dist/src/lib/block-selector.js.map +1 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +11 -8
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +108 -54
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -1
- package/dist/src/lib/config-object-descriptor.js +1 -3
- package/dist/src/lib/config-object-descriptor.js.map +1 -1
- package/dist/src/lib/config.d.ts +2 -2
- package/dist/src/lib/config.js +2 -2
- package/dist/src/lib/credentials-store.d.ts +3 -3
- package/dist/src/lib/credentials-store.js +3 -3
- package/dist/src/lib/credentials-store.js.map +1 -1
- package/dist/src/lib/document-export-permissions.d.ts +30 -0
- package/dist/src/lib/document-export-permissions.js +54 -0
- package/dist/src/lib/document-export-permissions.js.map +1 -0
- package/dist/src/lib/env-resolver-core.d.ts +41 -9
- package/dist/src/lib/env-resolver-core.js +84 -13
- package/dist/src/lib/env-resolver-core.js.map +1 -1
- package/dist/src/lib/env-resolver.d.ts +3 -3
- package/dist/src/lib/env-resolver.js +2 -2
- package/dist/src/lib/function-bundle.d.ts +11 -1
- package/dist/src/lib/function-bundle.js +13 -1
- package/dist/src/lib/function-bundle.js.map +1 -1
- package/dist/src/lib/function-collect.d.ts +123 -0
- package/dist/src/lib/function-collect.js +463 -0
- package/dist/src/lib/function-collect.js.map +1 -0
- package/dist/src/lib/function-db-types.d.ts +149 -0
- package/dist/src/lib/function-db-types.js +587 -0
- package/dist/src/lib/function-db-types.js.map +1 -0
- package/dist/src/lib/function-grants-preflight.d.ts +64 -0
- package/dist/src/lib/function-grants-preflight.js +100 -0
- package/dist/src/lib/function-grants-preflight.js.map +1 -0
- package/dist/src/lib/function-sync.d.ts +23 -0
- package/dist/src/lib/function-sync.js +65 -1
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/function-triggers.d.ts +6 -0
- package/dist/src/lib/function-triggers.js +63 -4
- package/dist/src/lib/function-triggers.js.map +1 -1
- package/dist/src/lib/generated-config-surfaces.d.ts +340 -0
- package/dist/src/lib/generated-config-surfaces.js +669 -17
- package/dist/src/lib/generated-config-surfaces.js.map +1 -1
- package/dist/src/lib/generated-sdk-types.d.ts +12 -0
- package/dist/src/lib/generated-sdk-types.js +13 -0
- package/dist/src/lib/generated-sdk-types.js.map +1 -0
- package/dist/src/lib/init-adopt.js +2 -2
- package/dist/src/lib/init-adopt.js.map +1 -1
- package/dist/src/lib/init-assets.js +3 -3
- package/dist/src/lib/init-config.d.ts +1 -1
- package/dist/src/lib/init-ios-links.js +1 -1
- package/dist/src/lib/init-ios-links.js.map +1 -1
- package/dist/src/lib/init-plan.d.ts +1 -1
- package/dist/src/lib/init-plan.js +1 -1
- package/dist/src/lib/init-xcode.d.ts +2 -2
- package/dist/src/lib/init-xcode.js +6 -5
- package/dist/src/lib/init-xcode.js.map +1 -1
- package/dist/src/lib/local-state.d.ts +1 -1
- package/dist/src/lib/local-state.js +1 -1
- package/dist/src/lib/local-test-cases.d.ts +1 -1
- package/dist/src/lib/local-test-cases.js +2 -1
- package/dist/src/lib/local-test-cases.js.map +1 -1
- package/dist/src/lib/migration-nag.d.ts +2 -2
- package/dist/src/lib/migration-nag.js +4 -3
- package/dist/src/lib/migration-nag.js.map +1 -1
- package/dist/src/lib/project-config.d.ts +23 -20
- package/dist/src/lib/project-config.js +27 -45
- package/dist/src/lib/project-config.js.map +1 -1
- package/dist/src/lib/snapshots.d.ts +2 -2
- package/dist/src/lib/snapshots.js +2 -2
- package/dist/src/lib/swift-codegen/generator.d.ts +1 -1
- package/dist/src/lib/swift-codegen/generator.js +1 -1
- package/dist/src/lib/sync-dir-selector.d.ts +1 -1
- package/dist/src/lib/sync-dir-selector.js +1 -1
- package/dist/src/lib/sync-paths.d.ts +52 -16
- package/dist/src/lib/sync-paths.js +68 -22
- package/dist/src/lib/sync-paths.js.map +1 -1
- package/dist/src/lib/sync-resource-types.d.ts +2 -2
- package/dist/src/lib/sync-resource-types.js +2 -2
- package/dist/src/lib/template.d.ts +2 -2
- package/dist/src/lib/template.js +2 -2
- package/dist/src/lib/test-case-keys.d.ts +1 -1
- package/dist/src/lib/test-case-keys.js +1 -1
- package/dist/src/lib/toml-database-config.js +19 -2
- package/dist/src/lib/toml-database-config.js.map +1 -1
- package/dist/src/lib/workflow-codegen/generator.d.ts +1 -1
- package/dist/src/lib/workflow-codegen/generator.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The typed database handle's generated declarations — #3182 phase 4.
|
|
3
|
+
*
|
|
4
|
+
* The intent settles what the handle is before unified-schemas: "generated at
|
|
5
|
+
* push time from the database type's TOML schema (js-bao's
|
|
6
|
+
* `loadSchemaFromTomlString`; not the client's runtime Yjs discovery): model
|
|
7
|
+
* names and field types in phase 2". So this is a THIRD renderer over the same
|
|
8
|
+
* `describeDbType` IR the TypeScript and Swift client generators already share
|
|
9
|
+
* — not a second parser and not a second idea of what a model is. Inline
|
|
10
|
+
* filter typing waits for unified-schemas, as the intent says.
|
|
11
|
+
*
|
|
12
|
+
* ── Why three files, in `functions/` ─────────────────────────────────────
|
|
13
|
+
*
|
|
14
|
+
* A generated declaration nothing loads is decoration (D3182-006). Function
|
|
15
|
+
* sources live under an environment- and app-specific config-tree path, the
|
|
16
|
+
* CLI's esbuild step never typechecks, and a project's own `tsconfig.json`
|
|
17
|
+
* commonly includes only `src`. So `config push` writes, beside the sources it
|
|
18
|
+
* serves:
|
|
19
|
+
*
|
|
20
|
+
* - `primitive-db-types.d.ts` — the app's database types, and the module
|
|
21
|
+
* augmentation that binds them to `ctx.db`;
|
|
22
|
+
* - `primitive-functions.d.ts` — the SDK's own types. The package is not on
|
|
23
|
+
* npm yet, and even when it is, a config tree is not an npm project:
|
|
24
|
+
* without this the bare `primitive-functions` specifier every function
|
|
25
|
+
* imports would not resolve at all, and the augmentation would have
|
|
26
|
+
* nothing to augment;
|
|
27
|
+
* - `tsconfig.json` — the wiring, so an editor and a bare `tsc` both see all
|
|
28
|
+
* three with nothing for an author to configure.
|
|
29
|
+
*
|
|
30
|
+
* The two `.d.ts` files are GENERATED and rewritten on every push. The tsconfig
|
|
31
|
+
* is SCAFFOLDED once and then left to its author, because it is the file an
|
|
32
|
+
* author has a legitimate reason to adjust — with one exception: the two facts
|
|
33
|
+
* that make the wiring work at all (the `primitive-functions` path mapping and
|
|
34
|
+
* the declarations being in the program) are repaired when they are missing,
|
|
35
|
+
* so a tsconfig written by hand, or scaffolded before the #3209 rename, does
|
|
36
|
+
* not leave push reporting success over a program no compiler can load
|
|
37
|
+
* (SO3182-004). Everything else in the file is left exactly as written.
|
|
38
|
+
*
|
|
39
|
+
* None of the three is part of the pushed envelope: they are regenerated, not
|
|
40
|
+
* round-tripped, and the bundler never sees them (types are erased, and the
|
|
41
|
+
* tsconfig is not a module).
|
|
42
|
+
*/
|
|
43
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "fs";
|
|
44
|
+
import { basename, join } from "path";
|
|
45
|
+
import { parseConfigToml } from "./config-toml.js";
|
|
46
|
+
import { describeDbType } from "./db-codegen/dbTypeIR.js";
|
|
47
|
+
import { tsTypeForDbFieldType } from "./db-codegen/dbTsTypes.js";
|
|
48
|
+
import { objectPropertyKey } from "./db-codegen/dbNaming.js";
|
|
49
|
+
import { SDK_TYPES_SOURCE } from "./generated-sdk-types.js";
|
|
50
|
+
export const DB_TYPES_DECLARATION_FILE = "primitive-db-types.d.ts";
|
|
51
|
+
export const SDK_TYPES_FILE = "primitive-functions.d.ts";
|
|
52
|
+
export const FUNCTIONS_TSCONFIG_FILE = "tsconfig.json";
|
|
53
|
+
const HEADER = `// GENERATED by \`primitive config push\` from database-type-configs/*.toml.
|
|
54
|
+
// DO NOT EDIT — your changes are overwritten on the next push.
|
|
55
|
+
//
|
|
56
|
+
// It gives \`ctx.db(databaseId, "<type>").model("<Model>")\` the model names and
|
|
57
|
+
// field types this app's database types declare. Inline filter typing arrives
|
|
58
|
+
// with unified schemas; until then a filter is an ordinary object.
|
|
59
|
+
`;
|
|
60
|
+
function quote(value) {
|
|
61
|
+
return JSON.stringify(value);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A model or field name as a TYPE member key.
|
|
65
|
+
*
|
|
66
|
+
* Model and field names are whatever the TOML says — js-bao preserves them
|
|
67
|
+
* verbatim — so `Order-Item` and `first-name` are ordinary schemas and are not
|
|
68
|
+
* TypeScript identifiers. Emitting one raw makes the whole declaration a syntax
|
|
69
|
+
* error, which breaks the editor and `tsc` wiring for every OTHER type in the
|
|
70
|
+
* tree too. The client generators' own `objectPropertyKey` answers this,
|
|
71
|
+
* except that its `__proto__` case is a computed key — legal in an object
|
|
72
|
+
* literal, not in a type member — so that one is quoted instead.
|
|
73
|
+
*/
|
|
74
|
+
function memberKey(name) {
|
|
75
|
+
const key = objectPropertyKey(name);
|
|
76
|
+
return key.startsWith("[") ? quote(name) : key;
|
|
77
|
+
}
|
|
78
|
+
/** A TS string-literal union, or `string` when there is nothing to narrow to. */
|
|
79
|
+
function fieldType(type, enumValues) {
|
|
80
|
+
if (type === "string" && Array.isArray(enumValues) && enumValues.length > 0) {
|
|
81
|
+
return enumValues.map((v) => quote(v)).join(" | ");
|
|
82
|
+
}
|
|
83
|
+
return tsTypeForDbFieldType(type);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The declaration for a whole config tree's database types.
|
|
87
|
+
*
|
|
88
|
+
* Sorted by type and by model so the bytes depend on the SCHEMAS and not on
|
|
89
|
+
* the order the files were read in — push rewrites this on every run, and
|
|
90
|
+
* unstable output would be a permanent diff in a developer's repository.
|
|
91
|
+
*/
|
|
92
|
+
export function renderDbTypesDeclaration(sources) {
|
|
93
|
+
const types = [...sources].sort((a, b) => a.databaseType < b.databaseType ? -1 : a.databaseType > b.databaseType ? 1 : 0);
|
|
94
|
+
const lines = [HEADER, "export interface PrimitiveDatabaseSchemas {"];
|
|
95
|
+
for (const source of types) {
|
|
96
|
+
let records = [];
|
|
97
|
+
try {
|
|
98
|
+
const ir = describeDbType({
|
|
99
|
+
databaseType: source.databaseType,
|
|
100
|
+
tomlPath: source.tomlPath,
|
|
101
|
+
tomlContent: source.tomlContent,
|
|
102
|
+
});
|
|
103
|
+
records = [...ir.records]
|
|
104
|
+
.sort((a, b) => (a.modelName < b.modelName ? -1 : 1))
|
|
105
|
+
.map((record) => {
|
|
106
|
+
const declared = new Set();
|
|
107
|
+
const members = [];
|
|
108
|
+
for (const field of record.fields) {
|
|
109
|
+
declared.add(field.name);
|
|
110
|
+
members.push(` ${memberKey(field.name)}${field.required ? "" : "?"}: ${fieldType(field.type, field.enum)};`);
|
|
111
|
+
}
|
|
112
|
+
// Server-stamped fields exist on a read row but not on one a
|
|
113
|
+
// function just built, so they are optional — the same call the
|
|
114
|
+
// client renderer makes.
|
|
115
|
+
for (const stamped of [...ir.stampedFields].sort()) {
|
|
116
|
+
if (declared.has(stamped))
|
|
117
|
+
continue;
|
|
118
|
+
declared.add(stamped);
|
|
119
|
+
members.push(` ${memberKey(stamped)}?: string;`);
|
|
120
|
+
}
|
|
121
|
+
return { modelName: record.modelName, members };
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
// A type whose TOML this renderer cannot describe contributes no models
|
|
126
|
+
// rather than failing the push: its own preflight reports the file, and
|
|
127
|
+
// an untyped handle is what a schemaless type gets anyway.
|
|
128
|
+
records = [];
|
|
129
|
+
}
|
|
130
|
+
if (records.length === 0) {
|
|
131
|
+
lines.push(` ${quote(source.databaseType)}: {};`);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
lines.push(` ${quote(source.databaseType)}: {`);
|
|
135
|
+
for (const record of records) {
|
|
136
|
+
if (record.members.length === 0) {
|
|
137
|
+
lines.push(` ${memberKey(record.modelName)}: Record<string, unknown>;`);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
lines.push(` ${memberKey(record.modelName)}: {`);
|
|
141
|
+
lines.push(...record.members);
|
|
142
|
+
lines.push(` };`);
|
|
143
|
+
}
|
|
144
|
+
lines.push(` };`);
|
|
145
|
+
}
|
|
146
|
+
lines.push("}");
|
|
147
|
+
lines.push("");
|
|
148
|
+
// The augmentation. Only emitted when there is something to bind: an empty
|
|
149
|
+
// one would claim the app has no database types, and `ctx.db` would stop
|
|
150
|
+
// accepting any type key at all rather than staying open.
|
|
151
|
+
if (types.length > 0) {
|
|
152
|
+
lines.push(`declare module "primitive-functions" {`);
|
|
153
|
+
lines.push(` interface DatabaseSchemas extends PrimitiveDatabaseSchemas {}`);
|
|
154
|
+
lines.push(`}`);
|
|
155
|
+
lines.push("");
|
|
156
|
+
}
|
|
157
|
+
return lines.join("\n");
|
|
158
|
+
}
|
|
159
|
+
/** The scaffolded compiler wiring. Written once; an author owns it after. */
|
|
160
|
+
export function renderFunctionsTsconfig() {
|
|
161
|
+
return (JSON.stringify({
|
|
162
|
+
// Scaffolded by `primitive config push` (#3182). Yours to adjust — push
|
|
163
|
+
// writes it once and then leaves it alone. What it must keep doing is
|
|
164
|
+
// pointing `primitive-functions` at the generated declaration beside
|
|
165
|
+
// it, so
|
|
166
|
+
// your editor and `tsc` type your functions with no other setup.
|
|
167
|
+
compilerOptions: {
|
|
168
|
+
target: "ES2022",
|
|
169
|
+
module: "ESNext",
|
|
170
|
+
moduleResolution: "Bundler",
|
|
171
|
+
// A function runs in a Worker, so the globals it may use are the
|
|
172
|
+
// worker ones: `fetch`, `Response`, `URL`, `crypto`, `console`, the
|
|
173
|
+
// timers. `ES2022` alone typechecks the language and none of the
|
|
174
|
+
// runtime, so ordinary deployed code reports "Cannot find name
|
|
175
|
+
// 'fetch'" — which reads as broken types and is fixed by editing
|
|
176
|
+
// this file, the one thing the scaffold exists to avoid
|
|
177
|
+
// (F3182-003).
|
|
178
|
+
lib: ["ES2022", "WebWorker"],
|
|
179
|
+
strict: true,
|
|
180
|
+
noEmit: true,
|
|
181
|
+
skipLibCheck: true,
|
|
182
|
+
types: [],
|
|
183
|
+
paths: {
|
|
184
|
+
"primitive-functions": [`./${SDK_TYPES_FILE}`],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
include: ["**/*.ts", `./${DB_TYPES_DECLARATION_FILE}`, `./${SDK_TYPES_FILE}`],
|
|
188
|
+
}, null, 2) + "\n");
|
|
189
|
+
}
|
|
190
|
+
/** The bare specifier every function imports, and the tsconfig must resolve. */
|
|
191
|
+
export const SDK_MODULE_SPECIFIER = "primitive-functions";
|
|
192
|
+
/** The include entry that covers every source AND both declarations. */
|
|
193
|
+
const SOURCES_INCLUDE = "**/*.ts";
|
|
194
|
+
/**
|
|
195
|
+
* A tsconfig's contents with `//` and block comments blanked out.
|
|
196
|
+
*
|
|
197
|
+
* A tsconfig is JSONC — comments are legal and common — and the difference
|
|
198
|
+
* matters twice: push must not reformat a commented file out from under its
|
|
199
|
+
* author, and it must still be able to READ one well enough to say whether the
|
|
200
|
+
* typed handle will load. Blanking rather than deleting keeps the text length
|
|
201
|
+
* (and so any offsets) intact; only `JSON.parse` ever sees the result.
|
|
202
|
+
*/
|
|
203
|
+
function stripJsonComments(text) {
|
|
204
|
+
let out = "";
|
|
205
|
+
let inString = false;
|
|
206
|
+
let escaped = false;
|
|
207
|
+
let inLine = false;
|
|
208
|
+
let inBlock = false;
|
|
209
|
+
for (let i = 0; i < text.length; i++) {
|
|
210
|
+
const ch = text[i];
|
|
211
|
+
const next = text[i + 1];
|
|
212
|
+
if (inLine) {
|
|
213
|
+
if (ch === "\n") {
|
|
214
|
+
inLine = false;
|
|
215
|
+
out += ch;
|
|
216
|
+
}
|
|
217
|
+
else
|
|
218
|
+
out += " ";
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (inBlock) {
|
|
222
|
+
if (ch === "*" && next === "/") {
|
|
223
|
+
inBlock = false;
|
|
224
|
+
out += " ";
|
|
225
|
+
i++;
|
|
226
|
+
}
|
|
227
|
+
else
|
|
228
|
+
out += ch === "\n" ? ch : " ";
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (inString) {
|
|
232
|
+
out += ch;
|
|
233
|
+
if (escaped)
|
|
234
|
+
escaped = false;
|
|
235
|
+
else if (ch === "\\")
|
|
236
|
+
escaped = true;
|
|
237
|
+
else if (ch === '"')
|
|
238
|
+
inString = false;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (ch === '"') {
|
|
242
|
+
inString = true;
|
|
243
|
+
out += ch;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (ch === "/" && next === "/") {
|
|
247
|
+
inLine = true;
|
|
248
|
+
out += " ";
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (ch === "/" && next === "*") {
|
|
252
|
+
inBlock = true;
|
|
253
|
+
out += " ";
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
out += ch;
|
|
257
|
+
}
|
|
258
|
+
return out;
|
|
259
|
+
}
|
|
260
|
+
function isGlobEntry(entry) {
|
|
261
|
+
return typeof entry === "string" && entry.includes("*");
|
|
262
|
+
}
|
|
263
|
+
function isSourceEntry(entry) {
|
|
264
|
+
if (typeof entry !== "string")
|
|
265
|
+
return false;
|
|
266
|
+
if (entry === `./${DB_TYPES_DECLARATION_FILE}` ||
|
|
267
|
+
entry === DB_TYPES_DECLARATION_FILE ||
|
|
268
|
+
entry === `./${SDK_TYPES_FILE}` ||
|
|
269
|
+
entry === SDK_TYPES_FILE) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
return isGlobEntry(entry) || entry.endsWith(".ts");
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The gaps in an already-parsed tsconfig object.
|
|
276
|
+
*
|
|
277
|
+
* Three separate facts, because two of them used to be one: a config that
|
|
278
|
+
* listed the two declarations and nothing else counted as "covered" while no
|
|
279
|
+
* function source was in the program at all, so `tsc` typechecked the
|
|
280
|
+
* declarations against themselves and push reported success (CR3182-003).
|
|
281
|
+
*/
|
|
282
|
+
function tsconfigWiringGaps(parsed) {
|
|
283
|
+
const compilerOptions = parsed.compilerOptions && typeof parsed.compilerOptions === "object"
|
|
284
|
+
? parsed.compilerOptions
|
|
285
|
+
: {};
|
|
286
|
+
const paths = compilerOptions.paths && typeof compilerOptions.paths === "object"
|
|
287
|
+
? compilerOptions.paths
|
|
288
|
+
: {};
|
|
289
|
+
const mapped = Array.isArray(paths[SDK_MODULE_SPECIFIER])
|
|
290
|
+
? paths[SDK_MODULE_SPECIFIER]
|
|
291
|
+
: [];
|
|
292
|
+
const include = Array.isArray(parsed.include) ? parsed.include : [];
|
|
293
|
+
const files = Array.isArray(parsed.files) ? parsed.files : [];
|
|
294
|
+
// With neither `include` nor `files`, TypeScript takes every file under the
|
|
295
|
+
// directory — sources and declarations alike — so there is nothing to add.
|
|
296
|
+
const implicitlyAll = parsed.include === undefined && parsed.files === undefined;
|
|
297
|
+
const listed = [...include, ...files];
|
|
298
|
+
const wildcard = listed.includes(SOURCES_INCLUDE);
|
|
299
|
+
return {
|
|
300
|
+
mapping: !mapped.includes(`./${SDK_TYPES_FILE}`),
|
|
301
|
+
declarations: !implicitlyAll &&
|
|
302
|
+
!wildcard &&
|
|
303
|
+
!(listed.includes(`./${DB_TYPES_DECLARATION_FILE}`) &&
|
|
304
|
+
listed.includes(`./${SDK_TYPES_FILE}`)),
|
|
305
|
+
sources: !implicitlyAll && !wildcard && !listed.some(isSourceEntry),
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function describeGaps(gaps) {
|
|
309
|
+
const problems = [];
|
|
310
|
+
if (gaps.mapping) {
|
|
311
|
+
problems.push(`\`compilerOptions.paths\` does not map "${SDK_MODULE_SPECIFIER}" to ` +
|
|
312
|
+
`"./${SDK_TYPES_FILE}", so a function's import of the SDK does not resolve`);
|
|
313
|
+
}
|
|
314
|
+
if (gaps.declarations) {
|
|
315
|
+
problems.push(`\`include\` does not cover "./${DB_TYPES_DECLARATION_FILE}" and ` +
|
|
316
|
+
`"./${SDK_TYPES_FILE}", so the database augmentation is never loaded`);
|
|
317
|
+
}
|
|
318
|
+
if (gaps.sources) {
|
|
319
|
+
problems.push("`include` covers no function source, so `tsc` typechecks none of them");
|
|
320
|
+
}
|
|
321
|
+
return problems;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Whether an existing tsconfig still carries the wiring the handle needs — the
|
|
325
|
+
* repaired document when push can fix it, and the problems when it cannot.
|
|
326
|
+
*
|
|
327
|
+
* The scaffold is written once and then belongs to its author, but "belongs to
|
|
328
|
+
* its author" cannot mean "silently stops working": a tree scaffolded before
|
|
329
|
+
* the `primitive-functions` rename (#3209) points at a declaration push no
|
|
330
|
+
* longer writes, and a tsconfig an author wrote by hand never had the wiring at
|
|
331
|
+
* all. Either way push claims success while no compiler can load the
|
|
332
|
+
* augmentation (SO3182-004).
|
|
333
|
+
*
|
|
334
|
+
* So the three REQUIRED facts — the module path mapping, the declarations being
|
|
335
|
+
* in the program, and the SOURCES being in the program — are repaired in a
|
|
336
|
+
* plain-JSON file, and everything else in it is left exactly as written. The
|
|
337
|
+
* mapping is APPENDED to any the author already has, so a deliberate mapping
|
|
338
|
+
* still wins and ours is only the fallback.
|
|
339
|
+
*
|
|
340
|
+
* A JSONC file (comments are legal in a tsconfig) is never rewritten —
|
|
341
|
+
* reformatting an author's file is worse than leaving it — but it IS read, and
|
|
342
|
+
* anything missing is reported instead of passing in silence (CR3182-003).
|
|
343
|
+
*/
|
|
344
|
+
export function inspectFunctionsTsconfig(existing) {
|
|
345
|
+
if (existing === null) {
|
|
346
|
+
return { repaired: renderFunctionsTsconfig(), problems: [] };
|
|
347
|
+
}
|
|
348
|
+
let parsed;
|
|
349
|
+
let plainJson = true;
|
|
350
|
+
try {
|
|
351
|
+
parsed = JSON.parse(existing);
|
|
352
|
+
}
|
|
353
|
+
catch {
|
|
354
|
+
plainJson = false;
|
|
355
|
+
try {
|
|
356
|
+
parsed = JSON.parse(stripJsonComments(existing));
|
|
357
|
+
}
|
|
358
|
+
catch {
|
|
359
|
+
return {
|
|
360
|
+
repaired: null,
|
|
361
|
+
problems: [
|
|
362
|
+
"it is not valid JSON or JSONC, so neither push nor a compiler can " +
|
|
363
|
+
"read it — fix the syntax, or delete it and let push scaffold a new one",
|
|
364
|
+
],
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
369
|
+
return {
|
|
370
|
+
repaired: null,
|
|
371
|
+
problems: ["it is not a JSON object, so it configures no compiler"],
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
const gaps = tsconfigWiringGaps(parsed);
|
|
375
|
+
if (!gaps.mapping && !gaps.declarations && !gaps.sources) {
|
|
376
|
+
return { repaired: null, problems: [] };
|
|
377
|
+
}
|
|
378
|
+
if (!plainJson) {
|
|
379
|
+
// Comments are the author's; repairing would strip them. Say what is
|
|
380
|
+
// missing instead of reporting success over a program that cannot load the
|
|
381
|
+
// handle.
|
|
382
|
+
return { repaired: null, problems: describeGaps(gaps) };
|
|
383
|
+
}
|
|
384
|
+
const compilerOptions = parsed.compilerOptions && typeof parsed.compilerOptions === "object"
|
|
385
|
+
? parsed.compilerOptions
|
|
386
|
+
: (parsed.compilerOptions = {});
|
|
387
|
+
const paths = compilerOptions.paths && typeof compilerOptions.paths === "object"
|
|
388
|
+
? compilerOptions.paths
|
|
389
|
+
: (compilerOptions.paths = {});
|
|
390
|
+
if (gaps.mapping) {
|
|
391
|
+
const mapped = Array.isArray(paths[SDK_MODULE_SPECIFIER])
|
|
392
|
+
? paths[SDK_MODULE_SPECIFIER]
|
|
393
|
+
: [];
|
|
394
|
+
paths[SDK_MODULE_SPECIFIER] = [...mapped, `./${SDK_TYPES_FILE}`];
|
|
395
|
+
}
|
|
396
|
+
if (gaps.declarations || gaps.sources) {
|
|
397
|
+
const include = Array.isArray(parsed.include) ? parsed.include : [];
|
|
398
|
+
const added = [];
|
|
399
|
+
// The sources come back through the same wildcard the scaffold uses, which
|
|
400
|
+
// covers the declarations too — so it is added first and the explicit
|
|
401
|
+
// declaration entries only when it is not.
|
|
402
|
+
if (gaps.sources)
|
|
403
|
+
added.push(SOURCES_INCLUDE);
|
|
404
|
+
else if (gaps.declarations) {
|
|
405
|
+
added.push(`./${DB_TYPES_DECLARATION_FILE}`, `./${SDK_TYPES_FILE}`);
|
|
406
|
+
}
|
|
407
|
+
parsed.include = [...include, ...added];
|
|
408
|
+
}
|
|
409
|
+
return { repaired: JSON.stringify(parsed, null, 2) + "\n", problems: [] };
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* The repaired document alone, or null to leave the file alone.
|
|
413
|
+
*
|
|
414
|
+
* Kept as the narrow answer `planFunctionTypeArtifacts` needs; the problems a
|
|
415
|
+
* repair cannot cover travel through `inspectFunctionsTsconfig`.
|
|
416
|
+
*/
|
|
417
|
+
export function reconcileFunctionsTsconfig(existing) {
|
|
418
|
+
return inspectFunctionsTsconfig(existing).repaired;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Every database-type TOML in the tree, read once.
|
|
422
|
+
*
|
|
423
|
+
* The type KEY is the one push and the grant preflight use — `[type]
|
|
424
|
+
* databaseType` when the file declares it, the file name only as the fallback.
|
|
425
|
+
* Taking the file name unconditionally would type the handle under a key the
|
|
426
|
+
* platform never hears about, so `ctx.db(id, "<declared-type>")` — the key the
|
|
427
|
+
* grant names — would not compile while a wrong one would (SO3182-003).
|
|
428
|
+
*/
|
|
429
|
+
export function databaseTypeSources(configDir) {
|
|
430
|
+
const dir = join(configDir, "database-type-configs");
|
|
431
|
+
if (!existsSync(dir))
|
|
432
|
+
return [];
|
|
433
|
+
const sources = [];
|
|
434
|
+
for (const file of readdirSync(dir).filter((f) => f.endsWith(".toml"))) {
|
|
435
|
+
const tomlPath = join(dir, file);
|
|
436
|
+
let tomlContent;
|
|
437
|
+
try {
|
|
438
|
+
tomlContent = readFileSync(tomlPath, "utf-8");
|
|
439
|
+
}
|
|
440
|
+
catch {
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
let declared = null;
|
|
444
|
+
try {
|
|
445
|
+
const parsed = parseConfigToml(tomlContent);
|
|
446
|
+
if (parsed?.type?.databaseType)
|
|
447
|
+
declared = String(parsed.type.databaseType);
|
|
448
|
+
}
|
|
449
|
+
catch {
|
|
450
|
+
// A file that does not parse is reported by its own preflight; the
|
|
451
|
+
// renderer falls back to the name push would fall back to.
|
|
452
|
+
}
|
|
453
|
+
sources.push({
|
|
454
|
+
databaseType: declared || basename(file, ".toml"),
|
|
455
|
+
tomlPath,
|
|
456
|
+
tomlContent,
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
return sources;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* What push would write, without writing it.
|
|
463
|
+
*
|
|
464
|
+
* Nothing at all when the tree has no `functions/` directory: the artifacts
|
|
465
|
+
* exist to type function sources, and a tree with none needs no compiler
|
|
466
|
+
* wiring.
|
|
467
|
+
*/
|
|
468
|
+
export function planFunctionTypeArtifacts(configDir, sdkTypes) {
|
|
469
|
+
const functionsDir = join(configDir, "functions");
|
|
470
|
+
if (!existsSync(functionsDir))
|
|
471
|
+
return [];
|
|
472
|
+
const declaration = renderDbTypesDeclaration(databaseTypeSources(configDir));
|
|
473
|
+
const artifacts = [
|
|
474
|
+
{
|
|
475
|
+
relative: `functions/${DB_TYPES_DECLARATION_FILE}`,
|
|
476
|
+
absolute: join(functionsDir, DB_TYPES_DECLARATION_FILE),
|
|
477
|
+
contents: declaration,
|
|
478
|
+
regenerated: true,
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
relative: `functions/${SDK_TYPES_FILE}`,
|
|
482
|
+
absolute: join(functionsDir, SDK_TYPES_FILE),
|
|
483
|
+
contents: sdkTypes ?? loadSdkTypes(),
|
|
484
|
+
regenerated: true,
|
|
485
|
+
},
|
|
486
|
+
];
|
|
487
|
+
// The tsconfig is planned against what is on disk: scaffolded when absent,
|
|
488
|
+
// repaired when its wiring is missing, and left alone otherwise — so an
|
|
489
|
+
// author's own edits survive a push and a broken program does not.
|
|
490
|
+
const tsconfigPath = join(functionsDir, FUNCTIONS_TSCONFIG_FILE);
|
|
491
|
+
let onDisk = null;
|
|
492
|
+
if (existsSync(tsconfigPath)) {
|
|
493
|
+
try {
|
|
494
|
+
onDisk = readFileSync(tsconfigPath, "utf-8");
|
|
495
|
+
}
|
|
496
|
+
catch {
|
|
497
|
+
onDisk = null;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
const tsconfig = reconcileFunctionsTsconfig(onDisk);
|
|
501
|
+
if (tsconfig !== null) {
|
|
502
|
+
artifacts.push({
|
|
503
|
+
relative: `functions/${FUNCTIONS_TSCONFIG_FILE}`,
|
|
504
|
+
absolute: tsconfigPath,
|
|
505
|
+
contents: tsconfig,
|
|
506
|
+
regenerated: false,
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
return artifacts;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* The tsconfig wiring push could not repair, phrased for the author.
|
|
513
|
+
*
|
|
514
|
+
* Push repairs a plain-JSON tsconfig in place, but it will not rewrite one that
|
|
515
|
+
* carries comments and it cannot read one that is broken. Reporting is what is
|
|
516
|
+
* left, and it is not optional: a typed handle that no compiler loads is the
|
|
517
|
+
* failure mode this whole artifact exists to prevent, and staying silent about
|
|
518
|
+
* it is how it reaches an author as "my types just don't work" (CR3182-003).
|
|
519
|
+
*/
|
|
520
|
+
export function functionTypeWiringProblems(configDir) {
|
|
521
|
+
const functionsDir = join(configDir, "functions");
|
|
522
|
+
if (!existsSync(functionsDir))
|
|
523
|
+
return [];
|
|
524
|
+
const tsconfigPath = join(functionsDir, FUNCTIONS_TSCONFIG_FILE);
|
|
525
|
+
if (!existsSync(tsconfigPath))
|
|
526
|
+
return [];
|
|
527
|
+
let onDisk;
|
|
528
|
+
try {
|
|
529
|
+
onDisk = readFileSync(tsconfigPath, "utf-8");
|
|
530
|
+
}
|
|
531
|
+
catch {
|
|
532
|
+
return [];
|
|
533
|
+
}
|
|
534
|
+
return inspectFunctionsTsconfig(onDisk).problems;
|
|
535
|
+
}
|
|
536
|
+
/** Write them, and report the tree-relative paths that changed on disk. */
|
|
537
|
+
export function writeFunctionTypeArtifacts(configDir, sdkTypes) {
|
|
538
|
+
const artifacts = planFunctionTypeArtifacts(configDir, sdkTypes);
|
|
539
|
+
if (artifacts.length === 0)
|
|
540
|
+
return [];
|
|
541
|
+
mkdirSync(join(configDir, "functions"), { recursive: true });
|
|
542
|
+
const written = [];
|
|
543
|
+
for (const artifact of artifacts) {
|
|
544
|
+
const exists = existsSync(artifact.absolute);
|
|
545
|
+
if (exists && readFileSync(artifact.absolute, "utf-8") === artifact.contents) {
|
|
546
|
+
written.push(artifact.relative);
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
writeFileSync(artifact.absolute, artifact.contents);
|
|
550
|
+
written.push(artifact.relative);
|
|
551
|
+
}
|
|
552
|
+
return written;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* The artifacts a `--check` run would rewrite: the freshness answer for CI and
|
|
556
|
+
* for an editor that wants to know its types are current.
|
|
557
|
+
*
|
|
558
|
+
* The tsconfig is only ever planned when it is missing or its wiring is (see
|
|
559
|
+
* `reconcileFunctionsTsconfig`), so a hand-edited but correctly wired one is
|
|
560
|
+
* never reported — and one that would leave the declarations unloadable always
|
|
561
|
+
* is.
|
|
562
|
+
*/
|
|
563
|
+
export function staleFunctionTypeArtifacts(configDir) {
|
|
564
|
+
const stale = [];
|
|
565
|
+
for (const artifact of planFunctionTypeArtifacts(configDir)) {
|
|
566
|
+
if (!existsSync(artifact.absolute)) {
|
|
567
|
+
stale.push(artifact.relative);
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
if (readFileSync(artifact.absolute, "utf-8") !== artifact.contents) {
|
|
571
|
+
stale.push(artifact.relative);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
return stale;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* The SDK's own declaration, as the CLI ships it.
|
|
578
|
+
*
|
|
579
|
+
* Vendored at build time by `cli/scripts/gen-sdk-types.mjs` from
|
|
580
|
+
* `packages/primitive-functions/index.d.ts` — the file `pnpm functions:profile`
|
|
581
|
+
* generates — so the types a config tree gets are the types the platform bakes
|
|
582
|
+
* into the sandbox, and the CLI still imports server source at build time only.
|
|
583
|
+
*/
|
|
584
|
+
function loadSdkTypes() {
|
|
585
|
+
return SDK_TYPES_SOURCE;
|
|
586
|
+
}
|
|
587
|
+
//# sourceMappingURL=function-db-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-db-types.js","sourceRoot":"","sources":["../../../src/lib/function-db-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,CAAC,MAAM,yBAAyB,GAAG,yBAAyB,CAAC;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG,0BAA0B,CAAC;AACzD,MAAM,CAA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Y,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACnE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,YAAY;IACnB,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `config push`'s local check of a function's capabilities — #3182,
|
|
3
|
+
* project `server-functions` phase 1, rewritten by #3279.
|
|
4
|
+
*
|
|
5
|
+
* The server is authoritative (the raw admin route exists, and it derives the
|
|
6
|
+
* capabilities from the TOML inside the envelope). This is the other
|
|
7
|
+
* enforcement point: an author who writes a retired grant string, or an
|
|
8
|
+
* `integration:` naming an integration the tree does not declare, should see
|
|
9
|
+
* it against their own file, in the front-loaded preflight pass, with nothing
|
|
10
|
+
* applied — not as a server refusal partway through a push that has already
|
|
11
|
+
* created three other things.
|
|
12
|
+
*
|
|
13
|
+
* The GRAMMAR is not restated here. It is the vendored `function-grants.ts` —
|
|
14
|
+
* the same module the server imports — so the two checks cannot drift into
|
|
15
|
+
* two rules. Since #3279 that grammar keeps three kinds (`integration:<key>`,
|
|
16
|
+
* `secret:<NAME>`, the high-blast opt-ins) and refuses everything it retired
|
|
17
|
+
* with the retirement, so a file still declaring a `database:` grant is
|
|
18
|
+
* told what changed rather than "unknown family".
|
|
19
|
+
*
|
|
20
|
+
* ── What "the app has this integration" means locally ────────────────────
|
|
21
|
+
*
|
|
22
|
+
* The tree is the intent: an integration declared in `integrations/` will
|
|
23
|
+
* exist after this push (objects are applied before functions). One that
|
|
24
|
+
* exists only on the server is real too, so the caller merges the live
|
|
25
|
+
* listing in when it could fetch one. When neither is available the target
|
|
26
|
+
* check is SKIPPED rather than guessed — the server will still refuse, and a
|
|
27
|
+
* preflight that refuses a valid tree because it could not reach the network
|
|
28
|
+
* would be worse than one that defers.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* The integration keys this push will leave in place — #3183.
|
|
32
|
+
*
|
|
33
|
+
* A set rather than a map because an `integration:` grant names one object
|
|
34
|
+
* and nothing about its inside. `secret:` has no target set (D3183-002): its
|
|
35
|
+
* values are provisioned per environment, out of band, so a tree can never
|
|
36
|
+
* answer for them.
|
|
37
|
+
*/
|
|
38
|
+
export interface KnownConfigObjectKeys {
|
|
39
|
+
integrations: Set<string>;
|
|
40
|
+
}
|
|
41
|
+
/** The set, read from the tree's `integrations/`. */
|
|
42
|
+
export declare function configObjectKeysFromTree(configDir: string): KnownConfigObjectKeys;
|
|
43
|
+
/** The server's keys, then the tree's — the tree is what this push applies. */
|
|
44
|
+
export declare function mergeKnownGrantTargets(fromServer: KnownConfigObjectKeys, fromTree: KnownConfigObjectKeys): KnownConfigObjectKeys;
|
|
45
|
+
export interface FunctionGrantPreflightInput {
|
|
46
|
+
/** Absolute path of `functions/<key>.toml`, for the message. */
|
|
47
|
+
filePath: string;
|
|
48
|
+
/** The already-parsed document, so the file is read once. */
|
|
49
|
+
tomlData: any;
|
|
50
|
+
/**
|
|
51
|
+
* Integration keys this push will leave in place, or null when the live
|
|
52
|
+
* listing could not be fetched and the tree declares none — in which case
|
|
53
|
+
* only the grammar is checked here, and the server has the last word.
|
|
54
|
+
*/
|
|
55
|
+
knownTargets?: KnownConfigObjectKeys | null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Everything wrong with one function file's capabilities, as push-ready lines.
|
|
59
|
+
*
|
|
60
|
+
* Each message names the file, because the preflight pass reports every file's
|
|
61
|
+
* errors together and "unknown integration 'stripe'" on its own does not say
|
|
62
|
+
* which function asked for it.
|
|
63
|
+
*/
|
|
64
|
+
export declare function functionGrantErrors(input: FunctionGrantPreflightInput): string[];
|