primitive-admin 1.0.52 → 1.0.54
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 +38 -10
- package/dist/bin/primitive.js +6 -0
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/auth.js +16 -6
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/blob-buckets.js +84 -7
- package/dist/src/commands/blob-buckets.js.map +1 -1
- package/dist/src/commands/catalog.js +3 -3
- package/dist/src/commands/catalog.js.map +1 -1
- package/dist/src/commands/collections.js +12 -9
- package/dist/src/commands/collections.js.map +1 -1
- package/dist/src/commands/database-types.js +11 -1
- package/dist/src/commands/database-types.js.map +1 -1
- package/dist/src/commands/databases.js +197 -74
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/group-type-configs.js +1 -9
- package/dist/src/commands/group-type-configs.js.map +1 -1
- package/dist/src/commands/groups.js +12 -6
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.d.ts +161 -0
- package/dist/src/commands/guides.js +502 -84
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/init.js +77 -45
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.js +2 -2
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/metadata.d.ts +2 -0
- package/dist/src/commands/metadata.js +344 -0
- package/dist/src/commands/metadata.js.map +1 -0
- package/dist/src/commands/prompts.js +2 -2
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rule-sets.d.ts +1 -0
- package/dist/src/commands/rule-sets.js +25 -3
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/scripts.d.ts +2 -0
- package/dist/src/commands/scripts.js +667 -0
- package/dist/src/commands/scripts.js.map +1 -0
- package/dist/src/commands/sync.d.ts +212 -16
- package/dist/src/commands/sync.js +1688 -287
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/vars.d.ts +8 -0
- package/dist/src/commands/vars.js +110 -0
- package/dist/src/commands/vars.js.map +1 -0
- package/dist/src/commands/webhooks.js +17 -3
- package/dist/src/commands/webhooks.js.map +1 -1
- package/dist/src/commands/workflows.d.ts +30 -0
- package/dist/src/commands/workflows.js +651 -52
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/api-client.d.ts +123 -19
- package/dist/src/lib/api-client.js +128 -4
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/batch.d.ts +26 -0
- package/dist/src/lib/batch.js +32 -0
- package/dist/src/lib/batch.js.map +1 -0
- package/dist/src/lib/block-layout.d.ts +160 -0
- package/dist/src/lib/block-layout.js +451 -0
- package/dist/src/lib/block-layout.js.map +1 -0
- package/dist/src/lib/codegen-shared/generatedFiles.d.ts +61 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js +127 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +68 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +168 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
- package/dist/src/lib/config-toml.d.ts +10 -0
- package/dist/src/lib/config-toml.js +42 -0
- package/dist/src/lib/config-toml.js.map +1 -0
- package/dist/src/lib/config.d.ts +16 -0
- package/dist/src/lib/config.js +41 -0
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/constants.d.ts +9 -0
- package/dist/src/lib/constants.js +9 -0
- package/dist/src/lib/constants.js.map +1 -1
- package/dist/src/lib/csv.d.ts +1 -2
- package/dist/src/lib/csv.js +3 -8
- package/dist/src/lib/csv.js.map +1 -1
- package/dist/src/lib/db-codegen/dbGenerator.d.ts +35 -7
- package/dist/src/lib/db-codegen/dbGenerator.js +384 -125
- package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -1
- package/dist/src/lib/db-codegen/dbNaming.d.ts +29 -0
- package/dist/src/lib/db-codegen/dbNaming.js +58 -0
- package/dist/src/lib/db-codegen/dbNaming.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTemplates.d.ts +114 -5
- package/dist/src/lib/db-codegen/dbTemplates.js +163 -16
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +7 -3
- package/dist/src/lib/db-codegen/dbTsTypes.js +23 -1
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
- package/dist/src/lib/generated-allowlist.js +52 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -1
- package/dist/src/lib/init-config.d.ts +13 -0
- package/dist/src/lib/init-config.js +21 -2
- package/dist/src/lib/init-config.js.map +1 -1
- package/dist/src/lib/output.d.ts +42 -5
- package/dist/src/lib/output.js +70 -4
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/query-operators.d.ts +43 -0
- package/dist/src/lib/query-operators.js +80 -0
- package/dist/src/lib/query-operators.js.map +1 -0
- package/dist/src/lib/template.d.ts +9 -5
- package/dist/src/lib/template.js +58 -45
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/toml-database-config.d.ts +10 -19
- package/dist/src/lib/toml-database-config.js +28 -59
- package/dist/src/lib/toml-database-config.js.map +1 -1
- package/dist/src/lib/toml-metadata-config.d.ts +147 -0
- package/dist/src/lib/toml-metadata-config.js +463 -0
- package/dist/src/lib/toml-metadata-config.js.map +1 -0
- package/dist/src/lib/toml-native-form.d.ts +46 -0
- package/dist/src/lib/toml-native-form.js +78 -0
- package/dist/src/lib/toml-native-form.js.map +1 -0
- package/dist/src/lib/toml-params-validator.d.ts +34 -0
- package/dist/src/lib/toml-params-validator.js +118 -3
- package/dist/src/lib/toml-params-validator.js.map +1 -1
- package/dist/src/lib/workflow-apply.d.ts +86 -0
- package/dist/src/lib/workflow-apply.js +127 -0
- package/dist/src/lib/workflow-apply.js.map +1 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
- package/dist/src/lib/workflow-codegen/generator.d.ts +74 -0
- package/dist/src/lib/workflow-codegen/generator.js +215 -0
- package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
- package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
- package/dist/src/lib/workflow-codegen/naming.js +81 -0
- package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +64 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.js +282 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
- package/dist/src/lib/workflow-fragments.js +3 -3
- package/dist/src/lib/workflow-fragments.js.map +1 -1
- package/dist/src/lib/workflow-payload.d.ts +68 -0
- package/dist/src/lib/workflow-payload.js +150 -0
- package/dist/src/lib/workflow-payload.js.map +1 -0
- package/dist/src/lib/workflow-toml-validator.d.ts +1 -1
- package/dist/src/lib/workflow-toml-validator.js +37 -1
- package/dist/src/lib/workflow-toml-validator.js.map +1 -1
- package/dist/src/types/index.d.ts +11 -0
- package/dist/src/validators.d.ts +4 -3
- package/dist/src/validators.js +6 -5
- package/dist/src/validators.js.map +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared source-directory resolution for the CLI codegen commands
|
|
3
|
+
* (`workflows codegen` #1442 and `databases codegen` #814, issue #1510).
|
|
4
|
+
*
|
|
5
|
+
* Both commands read a set of `*.toml` schemas out of a synced sub-directory
|
|
6
|
+
* (`workflows/` or `database-types/`) and render `*.generated.ts` beside them.
|
|
7
|
+
* Historically each command located that source directory by scanning EVERY
|
|
8
|
+
* `.primitive/sync/<env>/<appId>/<subdir>` slot and either hard-erroring on
|
|
9
|
+
* more than one (`workflows`) or silently merging across environments
|
|
10
|
+
* (`databases`, via a `seenTypes` dedup). Neither did any environment
|
|
11
|
+
* resolution, so `PRIMITIVE_ENV=dev workflows codegen` would happily generate
|
|
12
|
+
* from the `alpha` TOML while `databases codegen` followed a different env —
|
|
13
|
+
* the two generated-type trees could come from different environments in one
|
|
14
|
+
* run.
|
|
15
|
+
*
|
|
16
|
+
* This helper resolves the source directory the same way every other CLI
|
|
17
|
+
* command targets an environment: `--env` → `PRIMITIVE_ENV` →
|
|
18
|
+
* `defaultEnvironment` → single-env → error. `--sync-dir` and `--app` remain
|
|
19
|
+
* explicit overrides. It returns ONLY the resolved source directory; TOML
|
|
20
|
+
* collection, type filtering/dedup, and output-dir defaulting stay in each
|
|
21
|
+
* command.
|
|
22
|
+
*
|
|
23
|
+
* Design notes (binding, from the plan of record for #1510):
|
|
24
|
+
* - Call `getCurrentEnvironment()` DIRECTLY when no `--sync-dir` is given.
|
|
25
|
+
* `resolveSyncDir()`'s internal `safeEnv()` swallows the resolver's
|
|
26
|
+
* ambiguity error and falls back to `./config`, so genuine ambiguity must
|
|
27
|
+
* be surfaced here, not through `resolveSyncDir()`.
|
|
28
|
+
* - Throw plain `Error`s; the calling commands keep their existing
|
|
29
|
+
* `error(); process.exit(1)` convention (they catch at the boundary).
|
|
30
|
+
* - Do NOT use `resolveAppId()` — it is auth-oriented and exits the process,
|
|
31
|
+
* which is wrong for an offline codegen path.
|
|
32
|
+
* - Preserve the `--app`-alone legacy fallback: when `--app` is given, NO
|
|
33
|
+
* environment was explicitly requested, and env resolution fails (or there
|
|
34
|
+
* is no project config / legacy bare-dir mode), scan
|
|
35
|
+
* `.primitive/sync/<env>/<app>/<subdir>` for that specific app, resolving
|
|
36
|
+
* when it appears under exactly one env and erroring (naming the candidate
|
|
37
|
+
* envs) when it appears under more than one. This keeps the existing
|
|
38
|
+
* integration contract
|
|
39
|
+
* (`cli/tests/integration/workflows-codegen.test.ts`) intact.
|
|
40
|
+
* - Do NOT fall through to that scan when an environment WAS explicitly named
|
|
41
|
+
* (`--env` or `PRIMITIVE_ENV`) but is invalid/unknown: surface the
|
|
42
|
+
* resolver's error instead, so an explicit env selection never silently
|
|
43
|
+
* generates code from a different synced environment.
|
|
44
|
+
*/
|
|
45
|
+
export interface ResolveCodegenSourceDirOptions {
|
|
46
|
+
/** `--app <app-id>` override, if the user passed it. */
|
|
47
|
+
app?: string;
|
|
48
|
+
/** `--sync-dir <path>` override, if the user passed it. */
|
|
49
|
+
syncDir?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ResolveCodegenSourceDirArgs {
|
|
52
|
+
/** The synced sub-directory to resolve, e.g. "workflows" or "database-types". */
|
|
53
|
+
subdir: string;
|
|
54
|
+
/** Parsed command options (`--app`, `--sync-dir`). */
|
|
55
|
+
options: ResolveCodegenSourceDirOptions;
|
|
56
|
+
/**
|
|
57
|
+
* Working directory the legacy scan is rooted at. Defaults to
|
|
58
|
+
* `process.cwd()`; parameterised so unit tests can point it at a tmp tree
|
|
59
|
+
* (vitest workers can't `chdir`).
|
|
60
|
+
*/
|
|
61
|
+
cwd?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resolves the single source directory a codegen command should read its
|
|
65
|
+
* `*.toml` schemas from. Throws a plain `Error` (with a user-facing message)
|
|
66
|
+
* when the directory can't be resolved unambiguously or doesn't exist.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveCodegenSourceDir(args: ResolveCodegenSourceDirArgs): string;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared source-directory resolution for the CLI codegen commands
|
|
3
|
+
* (`workflows codegen` #1442 and `databases codegen` #814, issue #1510).
|
|
4
|
+
*
|
|
5
|
+
* Both commands read a set of `*.toml` schemas out of a synced sub-directory
|
|
6
|
+
* (`workflows/` or `database-types/`) and render `*.generated.ts` beside them.
|
|
7
|
+
* Historically each command located that source directory by scanning EVERY
|
|
8
|
+
* `.primitive/sync/<env>/<appId>/<subdir>` slot and either hard-erroring on
|
|
9
|
+
* more than one (`workflows`) or silently merging across environments
|
|
10
|
+
* (`databases`, via a `seenTypes` dedup). Neither did any environment
|
|
11
|
+
* resolution, so `PRIMITIVE_ENV=dev workflows codegen` would happily generate
|
|
12
|
+
* from the `alpha` TOML while `databases codegen` followed a different env —
|
|
13
|
+
* the two generated-type trees could come from different environments in one
|
|
14
|
+
* run.
|
|
15
|
+
*
|
|
16
|
+
* This helper resolves the source directory the same way every other CLI
|
|
17
|
+
* command targets an environment: `--env` → `PRIMITIVE_ENV` →
|
|
18
|
+
* `defaultEnvironment` → single-env → error. `--sync-dir` and `--app` remain
|
|
19
|
+
* explicit overrides. It returns ONLY the resolved source directory; TOML
|
|
20
|
+
* collection, type filtering/dedup, and output-dir defaulting stay in each
|
|
21
|
+
* command.
|
|
22
|
+
*
|
|
23
|
+
* Design notes (binding, from the plan of record for #1510):
|
|
24
|
+
* - Call `getCurrentEnvironment()` DIRECTLY when no `--sync-dir` is given.
|
|
25
|
+
* `resolveSyncDir()`'s internal `safeEnv()` swallows the resolver's
|
|
26
|
+
* ambiguity error and falls back to `./config`, so genuine ambiguity must
|
|
27
|
+
* be surfaced here, not through `resolveSyncDir()`.
|
|
28
|
+
* - Throw plain `Error`s; the calling commands keep their existing
|
|
29
|
+
* `error(); process.exit(1)` convention (they catch at the boundary).
|
|
30
|
+
* - Do NOT use `resolveAppId()` — it is auth-oriented and exits the process,
|
|
31
|
+
* which is wrong for an offline codegen path.
|
|
32
|
+
* - Preserve the `--app`-alone legacy fallback: when `--app` is given, NO
|
|
33
|
+
* environment was explicitly requested, and env resolution fails (or there
|
|
34
|
+
* is no project config / legacy bare-dir mode), scan
|
|
35
|
+
* `.primitive/sync/<env>/<app>/<subdir>` for that specific app, resolving
|
|
36
|
+
* when it appears under exactly one env and erroring (naming the candidate
|
|
37
|
+
* envs) when it appears under more than one. This keeps the existing
|
|
38
|
+
* integration contract
|
|
39
|
+
* (`cli/tests/integration/workflows-codegen.test.ts`) intact.
|
|
40
|
+
* - Do NOT fall through to that scan when an environment WAS explicitly named
|
|
41
|
+
* (`--env` or `PRIMITIVE_ENV`) but is invalid/unknown: surface the
|
|
42
|
+
* resolver's error instead, so an explicit env selection never silently
|
|
43
|
+
* generates code from a different synced environment.
|
|
44
|
+
*/
|
|
45
|
+
import { existsSync, readdirSync } from "fs";
|
|
46
|
+
import { basename, dirname, join } from "path";
|
|
47
|
+
import { getCurrentEnvironment, getExplicitEnvName } from "../env-resolver.js";
|
|
48
|
+
import { getCurrentAppId } from "../config.js";
|
|
49
|
+
import { resolveSyncDir, assertSafePathComponent } from "../sync-paths.js";
|
|
50
|
+
/**
|
|
51
|
+
* Resolves the single source directory a codegen command should read its
|
|
52
|
+
* `*.toml` schemas from. Throws a plain `Error` (with a user-facing message)
|
|
53
|
+
* when the directory can't be resolved unambiguously or doesn't exist.
|
|
54
|
+
*/
|
|
55
|
+
export function resolveCodegenSourceDir(args) {
|
|
56
|
+
const { subdir, options } = args;
|
|
57
|
+
const cwd = args.cwd ?? process.cwd();
|
|
58
|
+
// 1. --sync-dir is an explicit override: use <sync-dir>/<subdir> verbatim.
|
|
59
|
+
if (options.syncDir) {
|
|
60
|
+
return requireExisting(join(options.syncDir, subdir), subdir, undefined);
|
|
61
|
+
}
|
|
62
|
+
// 2. Resolve the active environment. Call getCurrentEnvironment() directly
|
|
63
|
+
// (not via resolveSyncDir/safeEnv) so a genuinely ambiguous project
|
|
64
|
+
// surfaces the resolver's "No environment selected… Available: …" error
|
|
65
|
+
// with a non-zero exit — unless the caller narrowed the target with
|
|
66
|
+
// --app AND did not name an environment, in which case we fall back to the
|
|
67
|
+
// legacy per-app scan.
|
|
68
|
+
//
|
|
69
|
+
// The `--app`-alone fallback only applies when NO environment was
|
|
70
|
+
// explicitly requested (neither `--env` nor `PRIMITIVE_ENV`). When the
|
|
71
|
+
// user DID name an env but it's invalid/unknown, getCurrentEnvironment()
|
|
72
|
+
// throws; we must surface that error (non-zero exit) rather than silently
|
|
73
|
+
// scanning the app under some OTHER synced environment — that would
|
|
74
|
+
// generate code from the wrong env instead of honoring the explicit
|
|
75
|
+
// selection.
|
|
76
|
+
const explicitEnvRequested = getExplicitEnvName() !== null || !!process.env.PRIMITIVE_ENV;
|
|
77
|
+
let env;
|
|
78
|
+
try {
|
|
79
|
+
env = getCurrentEnvironment();
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
if (options.app && !explicitEnvRequested) {
|
|
83
|
+
return scanSyncTree({ subdir, appId: options.app, cwd });
|
|
84
|
+
}
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
// 3. Project mode: resolve the app id and build the env/app-scoped path.
|
|
88
|
+
if (env) {
|
|
89
|
+
const appId = options.app ?? env.config.appId ?? getCurrentAppId();
|
|
90
|
+
if (!appId) {
|
|
91
|
+
throw new Error(`No app configured for environment "${env.name}" in .primitive/config.json ` +
|
|
92
|
+
`and no --app given. Add "appId" to the environment or pass --app <app-id>.`);
|
|
93
|
+
}
|
|
94
|
+
// resolveSyncDir re-reads the (cached) resolved env and guards appId via
|
|
95
|
+
// assertSafePathComponent, so an unsafe --app is rejected here.
|
|
96
|
+
const dir = join(resolveSyncDir({ appId }), subdir);
|
|
97
|
+
return requireExisting(dir, subdir, appId);
|
|
98
|
+
}
|
|
99
|
+
// 4. Legacy / bare-dir mode (no .primitive/config.json): scan the sync tree,
|
|
100
|
+
// filtered to --app when given. This preserves the pre-#1510 behavior.
|
|
101
|
+
return scanSyncTree({ subdir, appId: options.app, cwd });
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Legacy fallback: scan `<cwd>/.primitive/sync/<env>/<app>/<subdir>` for a
|
|
105
|
+
* source directory. When `appId` is given, only that app's slots are
|
|
106
|
+
* considered. Resolves to the single match; errors clearly on zero or on
|
|
107
|
+
* ambiguity (naming the candidate apps or envs).
|
|
108
|
+
*/
|
|
109
|
+
function scanSyncTree(args) {
|
|
110
|
+
const { subdir, appId, cwd } = args;
|
|
111
|
+
// Defence-in-depth: an --app value flows into a file-system path below, so
|
|
112
|
+
// reject separators / `..` before using it.
|
|
113
|
+
if (appId)
|
|
114
|
+
assertSafePathComponent(appId, "appId");
|
|
115
|
+
const root = join(cwd, ".primitive", "sync");
|
|
116
|
+
const found = [];
|
|
117
|
+
if (existsSync(root)) {
|
|
118
|
+
for (const envName of readdirSync(root)) {
|
|
119
|
+
const envDir = join(root, envName);
|
|
120
|
+
try {
|
|
121
|
+
for (const app of readdirSync(envDir)) {
|
|
122
|
+
if (appId && app !== appId)
|
|
123
|
+
continue;
|
|
124
|
+
const candidate = join(envDir, app, subdir);
|
|
125
|
+
if (existsSync(candidate))
|
|
126
|
+
found.push(candidate);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// Not a directory (or unreadable) — skip.
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (found.length === 0) {
|
|
135
|
+
throw new Error(notFoundMessage(subdir, appId));
|
|
136
|
+
}
|
|
137
|
+
if (found.length > 1) {
|
|
138
|
+
if (appId) {
|
|
139
|
+
const envs = [
|
|
140
|
+
...new Set(found.map((d) => basename(dirname(dirname(d))))),
|
|
141
|
+
];
|
|
142
|
+
throw new Error(`App "${appId}" has a ${subdir}/ directory under multiple environments: ` +
|
|
143
|
+
`${envs.join(", ")}.\n` +
|
|
144
|
+
found.map((d) => ` ${d}`).join("\n") +
|
|
145
|
+
`\nPass --env <name> or --sync-dir to select one.`);
|
|
146
|
+
}
|
|
147
|
+
const apps = [...new Set(found.map((d) => basename(dirname(d))))];
|
|
148
|
+
throw new Error(`Found ${subdir}/ directories for more than one app/env:\n` +
|
|
149
|
+
found.map((d) => ` ${d}`).join("\n") +
|
|
150
|
+
`\nCodegen writes into one output dir, so it must run against one app. ` +
|
|
151
|
+
`Pass --app <app-id> (found: ${apps.join(", ")}) or --sync-dir to select one.`);
|
|
152
|
+
}
|
|
153
|
+
return found[0];
|
|
154
|
+
}
|
|
155
|
+
/** Verifies `dir` exists, throwing the standard "no source dir" error otherwise. */
|
|
156
|
+
function requireExisting(dir, subdir, appId) {
|
|
157
|
+
if (!existsSync(dir)) {
|
|
158
|
+
throw new Error(notFoundMessage(subdir, appId));
|
|
159
|
+
}
|
|
160
|
+
return dir;
|
|
161
|
+
}
|
|
162
|
+
function notFoundMessage(subdir, appId) {
|
|
163
|
+
return appId
|
|
164
|
+
? `No ${subdir}/ directory found for app "${appId}" under .primitive/sync/. ` +
|
|
165
|
+
`Check the --app id, pass --sync-dir, or run \`primitive sync pull\` first.`
|
|
166
|
+
: `No ${subdir}/ directory found. Pass --sync-dir or run \`primitive sync pull\` first.`;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=resolveCodegenSourceDir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveCodegenSourceDir.js","sourceRoot":"","sources":["../../../../src/lib/codegen-shared/resolveCodegenSourceDir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAsB3E;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAiC;IACvE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAEtC,2EAA2E;IAC3E,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,eAAe,CAAC,IA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GAAG,CAAC;AACb,CAAC;AAED,SAAS,eAAe,CAAC,MAAc,EAAE,KAAyB;IAChE,OAAO,KAAK;QACV,CAAC,CAAC,MAAM,MAAM,8BAA8B,KAAK,4BAA4B;YACzE,4EAA4E;QAChF,CAAC,CAAC,MAAM,MAAM,0EAA0E,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a TOML source string with a TOML 1.0-compliant parser.
|
|
3
|
+
* Accepts heterogeneous inline arrays that the old `@iarna` rejected.
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseConfigToml(content: string): Record<string, any>;
|
|
6
|
+
/**
|
|
7
|
+
* Serialize a config object to TOML with a TOML 1.0-compliant serializer.
|
|
8
|
+
* Emits heterogeneous arrays natively instead of falling back to a JSON string.
|
|
9
|
+
*/
|
|
10
|
+
export declare function stringifyConfigToml(data: any): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's single TOML wrapper. Every TOML parse/stringify in the CLI routes
|
|
3
|
+
* through here — config files (database-type configs, workflows, collection-type
|
|
4
|
+
* configs, v2 block configs) and non-config files alike (app.toml, prompts,
|
|
5
|
+
* integrations, cron triggers, webhooks, rule-sets, codegen, ...).
|
|
6
|
+
*
|
|
7
|
+
* Config files can carry **heterogeneous arrays**: a settings-gated pipeline
|
|
8
|
+
* produces a CEL step-reference string next to a filter object, e.g.
|
|
9
|
+
* `"$and" = ["$steps.settings.first.peerVisible", { status = "approved" }]`.
|
|
10
|
+
* TOML 1.0.0 permits heterogeneous arrays; the previous library `@iarna`
|
|
11
|
+
* targeted TOML 0.5 and threw on them in **both** directions (`stringify` and
|
|
12
|
+
* `parse`). `smol-toml` is TOML 1.0-compliant and round-trips them, so #1450
|
|
13
|
+
* swapped the config paths and #1464 finished the migration — moving every
|
|
14
|
+
* remaining site here and removing `@iarna` entirely. Keeping one library
|
|
15
|
+
* means one set of parser semantics to reason about.
|
|
16
|
+
*
|
|
17
|
+
* Behavioral notes for the smol-toml swap (measured against `@iarna@2.2.5`):
|
|
18
|
+
* every divergence is a loud error, never silent value drift. smol throws on
|
|
19
|
+
* integers beyond 2^53 (`@iarna` returned a BigInt that then broke
|
|
20
|
+
* `JSON.stringify` on push), rejects control characters in comments (TOML 1.0
|
|
21
|
+
* ban), and throws on stringifying an array containing `null` (`@iarna`
|
|
22
|
+
* silently dropped it). `null`/`undefined` data-loss guards live in
|
|
23
|
+
* `canEmitNative` (`toml-database-config.ts`), not here. `smol` re-emits with
|
|
24
|
+
* slightly different formatting (`[]` not `[ ]`, no array-of-tables indent) —
|
|
25
|
+
* a one-time reformat on the next `pull`.
|
|
26
|
+
*/
|
|
27
|
+
import * as smolToml from "smol-toml";
|
|
28
|
+
/**
|
|
29
|
+
* Parse a TOML source string with a TOML 1.0-compliant parser.
|
|
30
|
+
* Accepts heterogeneous inline arrays that the old `@iarna` rejected.
|
|
31
|
+
*/
|
|
32
|
+
export function parseConfigToml(content) {
|
|
33
|
+
return smolToml.parse(content);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Serialize a config object to TOML with a TOML 1.0-compliant serializer.
|
|
37
|
+
* Emits heterogeneous arrays natively instead of falling back to a JSON string.
|
|
38
|
+
*/
|
|
39
|
+
export function stringifyConfigToml(data) {
|
|
40
|
+
return smolToml.stringify(data);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=config-toml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-toml.js","sourceRoot":"","sources":["../../../src/lib/config-toml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAEtC;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,OAAO,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAwB,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAS;IAC3C,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/src/lib/config.d.ts
CHANGED
|
@@ -29,6 +29,22 @@ export declare function resolveAppId(appId: string | undefined, options: {
|
|
|
29
29
|
* the serverUrl saved in the legacy credentials file.
|
|
30
30
|
*/
|
|
31
31
|
export declare function getServerUrl(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the API base URL to authenticate against, used by `primitive login`
|
|
34
|
+
* (issue #1343).
|
|
35
|
+
*
|
|
36
|
+
* Unlike getServerUrl(), this must work *before* any credentials exist (first
|
|
37
|
+
* login), so it never falls back to the stored credentials' serverUrl:
|
|
38
|
+
*
|
|
39
|
+
* - Project mode → the active environment's `apiUrl` (canonical). Lets
|
|
40
|
+
* getCurrentEnvironment() throw on an unresolvable env (ambiguous/unknown
|
|
41
|
+
* --env) so the caller can fail loudly instead of silently targeting prod.
|
|
42
|
+
* - Legacy mode (no .primitive/config.json) → DEFAULT_SERVER_URL, which
|
|
43
|
+
* honors the PRIMITIVE_SERVER_URL escape hatch (constants.ts).
|
|
44
|
+
*
|
|
45
|
+
* The trailing slash is stripped so callers can build `${url}/admin/api/...`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getConfiguredServerUrl(): string;
|
|
32
48
|
/**
|
|
33
49
|
* Exposed so commands can check whether there's a pre-project-config
|
|
34
50
|
* credentials file at ~/.primitive/credentials.json (used by migration
|
package/dist/src/lib/config.js
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { clearCredentialsStore, clearCurrentAppStore, loadCredentialsStore, peekLegacyCredentials, saveCredentialsStore, setCurrentAppStore, } from "./credentials-store.js";
|
|
16
16
|
import { getCurrentEnvironment, getCurrentEnvNameSafe, } from "./env-resolver.js";
|
|
17
|
+
import { PROJECT_CONFIG_DISPLAY_NAME } from "./project-config.js";
|
|
18
|
+
import { DEFAULT_SERVER_URL } from "./constants.js";
|
|
17
19
|
export function loadCredentials() {
|
|
18
20
|
return loadCredentialsStore();
|
|
19
21
|
}
|
|
@@ -55,6 +57,26 @@ export function getCurrentAppId() {
|
|
|
55
57
|
export function resolveAppId(appId, options) {
|
|
56
58
|
const resolved = appId || options.app || getCurrentAppId();
|
|
57
59
|
if (!resolved) {
|
|
60
|
+
// When the active env declares an `appId` in .primitive/config.json but
|
|
61
|
+
// has no credentials slot, loadCredentialsStore() returns null (its
|
|
62
|
+
// null == unauthenticated contract), so getCurrentAppId() yields nothing
|
|
63
|
+
// even though an appId IS configured. In that case the accurate problem
|
|
64
|
+
// is that the user isn't authenticated for this env — not that no app was
|
|
65
|
+
// specified. (A creds slot would have blended in env.config.appId and made
|
|
66
|
+
// `resolved` truthy, so reaching here with a configured appId can only mean
|
|
67
|
+
// missing credentials.)
|
|
68
|
+
let env = null;
|
|
69
|
+
try {
|
|
70
|
+
env = getCurrentEnvironment();
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// Env resolution failed (ambiguous/unknown env) — fall back to the
|
|
74
|
+
// original "No app specified." message below.
|
|
75
|
+
}
|
|
76
|
+
if (env && env.config.appId) {
|
|
77
|
+
console.error(`Not logged in to environment "${env.name}". An appId is configured in ${PROJECT_CONFIG_DISPLAY_NAME} but you're not authenticated. Run 'primitive -e ${env.name} login'.`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
58
80
|
const envName = getCurrentEnvNameSafe();
|
|
59
81
|
const hint = envName
|
|
60
82
|
? `(current environment: ${envName}). Set 'appId' in .primitive/config.json, pass --app, or run 'primitive use <app-id>'.`
|
|
@@ -85,6 +107,25 @@ export function getServerUrl() {
|
|
|
85
107
|
}
|
|
86
108
|
return credentials.serverUrl;
|
|
87
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Resolves the API base URL to authenticate against, used by `primitive login`
|
|
112
|
+
* (issue #1343).
|
|
113
|
+
*
|
|
114
|
+
* Unlike getServerUrl(), this must work *before* any credentials exist (first
|
|
115
|
+
* login), so it never falls back to the stored credentials' serverUrl:
|
|
116
|
+
*
|
|
117
|
+
* - Project mode → the active environment's `apiUrl` (canonical). Lets
|
|
118
|
+
* getCurrentEnvironment() throw on an unresolvable env (ambiguous/unknown
|
|
119
|
+
* --env) so the caller can fail loudly instead of silently targeting prod.
|
|
120
|
+
* - Legacy mode (no .primitive/config.json) → DEFAULT_SERVER_URL, which
|
|
121
|
+
* honors the PRIMITIVE_SERVER_URL escape hatch (constants.ts).
|
|
122
|
+
*
|
|
123
|
+
* The trailing slash is stripped so callers can build `${url}/admin/api/...`.
|
|
124
|
+
*/
|
|
125
|
+
export function getConfiguredServerUrl() {
|
|
126
|
+
const env = getCurrentEnvironment(); // may throw on an unresolvable env
|
|
127
|
+
return (env ? env.config.apiUrl : DEFAULT_SERVER_URL).replace(/\/$/, "");
|
|
128
|
+
}
|
|
88
129
|
/**
|
|
89
130
|
* Exposed so commands can check whether there's a pre-project-config
|
|
90
131
|
* credentials file at ~/.primitive/credentials.json (used by migration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,qBAAq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AAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,IAAI,GAAG;YAAE,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,oEAAoE;IACtE,CAAC;IACD,MAAM,WAAW,GAAG,eAAe,EAAE,CAAC;IACtC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,WAAW,CAAC,SAAS,CAAC;AAC/B,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC,CAAC,mCAAmC;IACxE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,qBAAqB,EAAE,KAAK,IAAI,CAAC;AAC1C,CAAC"}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
export declare const PRODUCTION_SERVER_URL = "https://primitiveapi.com";
|
|
2
2
|
export declare const DEFAULT_SERVER_URL: string;
|
|
3
|
+
/**
|
|
4
|
+
* The alpha deployment's canonical server URL. Mirrors
|
|
5
|
+
* `wrangler.toml [env.alpha] WORKER_URL` — keep the two in sync; if the alpha
|
|
6
|
+
* URL ever changes, update both. Used only by `primitive guides` to detect the
|
|
7
|
+
* alpha target and fetch guides from the `primitive-docs` `next` branch instead
|
|
8
|
+
* of `main` (issue #1463). This is an internal-only convenience;
|
|
9
|
+
* security-through-obscurity is acceptable.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ALPHA_SERVER_URL = "https://js-bao-wss-alpha.primitive-labs-dev.workers.dev";
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
export const PRODUCTION_SERVER_URL = "https://primitiveapi.com";
|
|
2
2
|
export const DEFAULT_SERVER_URL = process.env.PRIMITIVE_SERVER_URL || PRODUCTION_SERVER_URL;
|
|
3
|
+
/**
|
|
4
|
+
* The alpha deployment's canonical server URL. Mirrors
|
|
5
|
+
* `wrangler.toml [env.alpha] WORKER_URL` — keep the two in sync; if the alpha
|
|
6
|
+
* URL ever changes, update both. Used only by `primitive guides` to detect the
|
|
7
|
+
* alpha target and fetch guides from the `primitive-docs` `next` branch instead
|
|
8
|
+
* of `main` (issue #1463). This is an internal-only convenience;
|
|
9
|
+
* security-through-obscurity is acceptable.
|
|
10
|
+
*/
|
|
11
|
+
export const ALPHA_SERVER_URL = "https://js-bao-wss-alpha.primitive-labs-dev.workers.dev";
|
|
3
12
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAEhE,MAAM,CAAC,MAAM,kBAAkB,GAC7B,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAEhE,MAAM,CAAC,MAAM,kBAAkB,GAC7B,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,qBAAqB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAC3B,yDAAyD,CAAC"}
|
package/dist/src/lib/csv.d.ts
CHANGED
|
@@ -44,5 +44,4 @@ export interface BuildRowsResult {
|
|
|
44
44
|
* `importCsv`.
|
|
45
45
|
*/
|
|
46
46
|
export declare function buildRows(rows: Record<string, any>[], options: BuildRowsOptions): BuildRowsResult;
|
|
47
|
-
|
|
48
|
-
export declare function chunk<T>(items: T[], size: number): T[][];
|
|
47
|
+
export { chunk } from "./batch.js";
|
package/dist/src/lib/csv.js
CHANGED
|
@@ -166,12 +166,7 @@ export function buildRows(rows, options) {
|
|
|
166
166
|
}
|
|
167
167
|
return { batch, rowCount: batch.length };
|
|
168
168
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
for (let i = 0; i < items.length; i += size) {
|
|
173
|
-
out.push(items.slice(i, i + size));
|
|
174
|
-
}
|
|
175
|
-
return out;
|
|
176
|
-
}
|
|
169
|
+
// `chunk()` moved to ./batch.ts (shared with `databases import`). Re-exported
|
|
170
|
+
// here so existing `import { chunk } from "../lib/csv.js"` callers keep working.
|
|
171
|
+
export { chunk } from "./batch.js";
|
|
177
172
|
//# sourceMappingURL=csv.js.map
|
package/dist/src/lib/csv.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.js","sourceRoot":"","sources":["../../../src/lib/csv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACtB,GAAW,EACX,SAAS,GAAG,GAAG;IAEf,0EAA0E;IAC1E,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACf,IAAI,QAAQ,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,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AAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1D,IAAI,KAAK,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE,CAAC;gBACnD,GAAG,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,aAAa;QACb,IAAI,EAAU,CAAC;QACf,IAAI,OAAO,CAAC,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;YACtD,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrC,CAAC;aAAM,IAAI,GAAG,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC;YAC1B,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,EAAE,GAAG,IAAI,EAAE,CAAC;QACd,CAAC;QACD,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;QACZ,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AAC3C,CAAC;AAED,8EAA8E;AAC9E,iFAAiF;AACjF,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -13,9 +13,13 @@
|
|
|
13
13
|
* - The banner + fingerprint header pattern and stale-output cleanup.
|
|
14
14
|
*
|
|
15
15
|
* Adds the OPERATIONS half (op-params interfaces + per-op result aliases)
|
|
16
|
-
* that codegen-v2 has no analog for.
|
|
17
|
-
* the
|
|
16
|
+
* that codegen-v2 has no analog for. A result alias is derived from `op.type`
|
|
17
|
+
* and, where the shape is derivable, the op's parsed `definition`: a query op's
|
|
18
|
+
* `projection` (#1439), a mutation op's step kinds (#1438), and a pipeline op's
|
|
19
|
+
* `return` step (#1437). This file resolves those into the small descriptors
|
|
20
|
+
* the templates consume; the templates stay pure string-emitters.
|
|
18
21
|
*/
|
|
22
|
+
import { type GeneratedFileMismatch } from "../codegen-shared/generatedFiles.js";
|
|
19
23
|
export interface DbCodegenInput {
|
|
20
24
|
/** Database type name (drives the output filename). */
|
|
21
25
|
databaseType: string;
|
|
@@ -53,15 +57,37 @@ export interface DbCodegenResult {
|
|
|
53
57
|
/** Only populated under `--check`: files whose on-disk content is out of date. */
|
|
54
58
|
mismatches: DbCheckMismatch[];
|
|
55
59
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Re-exported from the shared generated-file module so existing importers keep
|
|
62
|
+
* a stable type. The write/`--check`/cleanup lifecycle now lives in
|
|
63
|
+
* `codegen-shared/generatedFiles.ts` (shared with `workflows codegen`).
|
|
64
|
+
*/
|
|
65
|
+
export type DbCheckMismatch = GeneratedFileMismatch;
|
|
60
66
|
/**
|
|
61
67
|
* Render the in-memory `.generated.ts` content for a single database-type
|
|
62
68
|
* TOML. Exported so tests can assert on the rendered string directly.
|
|
63
69
|
*/
|
|
64
70
|
export declare function renderDbTypeFile(input: DbCodegenInput): string;
|
|
71
|
+
/**
|
|
72
|
+
* Infer the scalar element TS type for op params consumed by a `$in`/`$nin`
|
|
73
|
+
* filter operator (#1488, Phase 1). Codegen-only: a param compared with
|
|
74
|
+
* `$in`/`$nin` against a model field is definitionally an array, so the
|
|
75
|
+
* typed-ops factory (#1441) should emit `<elem>[]` rather than widening an
|
|
76
|
+
* untyped/object param to `Record<string, unknown>` (which `string[]` is not
|
|
77
|
+
* assignable to).
|
|
78
|
+
*
|
|
79
|
+
* Kept a small local helper next to {@link inferRequiredRecordFields} rather
|
|
80
|
+
* than a shared cross-runtime analysis pass (sponsor decision on #1488).
|
|
81
|
+
*
|
|
82
|
+
* Returns a map of param name → element TS type. The `"unknown"` sentinel means
|
|
83
|
+
* "emit `unknown[]`" — used when the compared field is missing from the model
|
|
84
|
+
* schema (or the op has no resolvable model), when the same param is bound to
|
|
85
|
+
* fields of differing element types, or when the param is also used as a scalar
|
|
86
|
+
* elsewhere (conservative widen, mirroring #845's disagreement rule / #1488
|
|
87
|
+
* Fork 4). A param absent from the map is not consumed by any array operator
|
|
88
|
+
* and keeps its declared-type mapping (inference never widens such a param).
|
|
89
|
+
*/
|
|
90
|
+
export declare function inferArrayParamElementTypes(op: any, fieldTypesByModel: Map<string, Map<string, string>>): Map<string, string>;
|
|
65
91
|
/**
|
|
66
92
|
* Per-model result of {@link inferRequiredRecordFields}. Shaped as an object
|
|
67
93
|
* (rather than a bare `Set`) so it can grow additional inferred metadata later
|
|
@@ -106,6 +132,8 @@ export interface InferredRecordModelInfo {
|
|
|
106
132
|
*/
|
|
107
133
|
export declare function inferRequiredRecordFields(operations: any[]): Map<string, InferredRecordModelInfo>;
|
|
108
134
|
/**
|
|
109
|
-
* Run codegen end-to-end across one or more database-type TOML inputs.
|
|
135
|
+
* Run codegen end-to-end across one or more database-type TOML inputs. The
|
|
136
|
+
* disk lifecycle (write / `--check` / stale cleanup) is delegated to the
|
|
137
|
+
* shared `writeOrCheckGeneratedFiles` (shared with `workflows codegen`).
|
|
110
138
|
*/
|
|
111
139
|
export declare function generateDbTypes(options: GenerateDbTypesOptions): Promise<DbCodegenResult>;
|