primitive-admin 1.1.0-alpha.4 → 1.1.0-alpha.40
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 +325 -31
- package/assets/skill/skills/primitive-platform/SKILL.md +281 -0
- package/dist/bin/primitive.d.ts +2 -0
- package/dist/bin/primitive.js +266 -16
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/admins.d.ts +2 -0
- package/dist/src/commands/admins.js +123 -18
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/analytics.d.ts +2 -0
- package/dist/src/commands/analytics.js +464 -55
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps.d.ts +2 -0
- package/dist/src/commands/apps.js +55 -13
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/auth.d.ts +2 -0
- package/dist/src/commands/auth.js +177 -7
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/blob-buckets.d.ts +2 -0
- package/dist/src/commands/blob-buckets.js +422 -0
- package/dist/src/commands/blob-buckets.js.map +1 -0
- package/dist/src/commands/catalog.d.ts +2 -0
- package/dist/src/commands/catalog.js +34 -35
- package/dist/src/commands/catalog.js.map +1 -1
- package/dist/src/commands/collection-type-configs.d.ts +2 -0
- package/dist/src/commands/collection-type-configs.js +178 -0
- package/dist/src/commands/collection-type-configs.js.map +1 -0
- package/dist/src/commands/collections.d.ts +2 -0
- package/dist/src/commands/collections.js +515 -0
- package/dist/src/commands/collections.js.map +1 -0
- package/dist/src/commands/comparisons.d.ts +2 -0
- package/dist/src/commands/comparisons.js +6 -6
- package/dist/src/commands/comparisons.js.map +1 -1
- package/dist/src/commands/cron-triggers.d.ts +2 -0
- package/dist/src/commands/cron-triggers.js +357 -0
- package/dist/src/commands/cron-triggers.js.map +1 -0
- package/dist/src/commands/database-types.d.ts +2 -0
- package/dist/src/commands/database-types.js +471 -0
- package/dist/src/commands/database-types.js.map +1 -0
- package/dist/src/commands/databases.d.ts +2 -0
- package/dist/src/commands/databases.js +1462 -83
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.d.ts +2 -0
- package/dist/src/commands/documents.js +518 -11
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/email-templates.d.ts +2 -0
- package/dist/src/commands/email-templates.js +281 -0
- package/dist/src/commands/email-templates.js.map +1 -0
- package/dist/src/commands/env.d.ts +12 -0
- package/dist/src/commands/env.js +260 -0
- package/dist/src/commands/env.js.map +1 -0
- package/dist/src/commands/group-type-configs.d.ts +2 -0
- package/dist/src/commands/group-type-configs.js +181 -0
- package/dist/src/commands/group-type-configs.js.map +1 -0
- package/dist/src/commands/groups.d.ts +2 -0
- package/dist/src/commands/groups.js +45 -43
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.d.ts +159 -0
- package/dist/src/commands/guides.js +449 -35
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/init.d.ts +17 -0
- package/dist/src/commands/init.js +811 -201
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.d.ts +2 -0
- package/dist/src/commands/integrations.js +533 -46
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/llm.d.ts +2 -0
- package/dist/src/commands/llm.js +4 -2
- package/dist/src/commands/llm.js.map +1 -1
- package/dist/src/commands/prompts.d.ts +2 -0
- package/dist/src/commands/prompts.js +50 -52
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rule-sets.d.ts +3 -0
- package/dist/src/commands/rule-sets.js +388 -0
- package/dist/src/commands/rule-sets.js.map +1 -0
- 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/secrets.d.ts +2 -0
- package/dist/src/commands/secrets.js +108 -0
- package/dist/src/commands/secrets.js.map +1 -0
- package/dist/src/commands/skill.d.ts +2 -0
- package/dist/src/commands/skill.js +29 -0
- package/dist/src/commands/skill.js.map +1 -0
- package/dist/src/commands/sync.d.ts +174 -0
- package/dist/src/commands/sync.js +4392 -235
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.d.ts +2 -0
- package/dist/src/commands/tokens.js +122 -19
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/users.d.ts +2 -0
- package/dist/src/commands/users.js +440 -22
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/waitlist.d.ts +2 -0
- package/dist/src/commands/waitlist.js +10 -10
- package/dist/src/commands/waitlist.js.map +1 -1
- package/dist/src/commands/webhooks.d.ts +2 -0
- package/dist/src/commands/webhooks.js +391 -0
- package/dist/src/commands/webhooks.js.map +1 -0
- package/dist/src/commands/workflows.d.ts +49 -0
- package/dist/src/commands/workflows.js +1009 -123
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/api-client.d.ts +1272 -0
- package/dist/src/lib/api-client.js +1115 -83
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/auth-flow.d.ts +8 -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/cli-manifest.d.ts +60 -0
- package/dist/src/lib/cli-manifest.js +70 -0
- package/dist/src/lib/cli-manifest.js.map +1 -0
- package/dist/src/lib/config.d.ts +53 -0
- package/dist/src/lib/config.js +92 -53
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/confirm-prompt.d.ts +83 -0
- package/dist/src/lib/confirm-prompt.js +110 -0
- package/dist/src/lib/confirm-prompt.js.map +1 -0
- package/dist/src/lib/constants.d.ts +2 -0
- package/dist/src/lib/constants.js +3 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/crash-handlers.d.ts +20 -0
- package/dist/src/lib/crash-handlers.js +49 -0
- package/dist/src/lib/crash-handlers.js.map +1 -0
- package/dist/src/lib/credentials-store.d.ts +79 -0
- package/dist/src/lib/credentials-store.js +307 -0
- package/dist/src/lib/credentials-store.js.map +1 -0
- package/dist/src/lib/csv.d.ts +48 -0
- package/dist/src/lib/csv.js +177 -0
- package/dist/src/lib/csv.js.map +1 -0
- package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
- package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
- package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
- package/dist/src/lib/db-codegen/dbGenerator.d.ts +111 -0
- package/dist/src/lib/db-codegen/dbGenerator.js +371 -0
- package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
- package/dist/src/lib/db-codegen/dbNaming.d.ts +45 -0
- package/dist/src/lib/db-codegen/dbNaming.js +104 -0
- package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTemplates.d.ts +97 -0
- package/dist/src/lib/db-codegen/dbTemplates.js +159 -0
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +78 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js +112 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
- package/dist/src/lib/env-resolver.d.ts +62 -0
- package/dist/src/lib/env-resolver.js +121 -0
- package/dist/src/lib/env-resolver.js.map +1 -0
- package/dist/src/lib/fetch.d.ts +5 -0
- package/dist/src/lib/generated-allowlist.d.ts +28 -0
- package/dist/src/lib/generated-allowlist.js +213 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -0
- package/dist/src/lib/init-config.d.ts +59 -0
- package/dist/src/lib/init-config.js +113 -0
- package/dist/src/lib/init-config.js.map +1 -0
- package/dist/src/lib/migration-nag.d.ts +49 -0
- package/dist/src/lib/migration-nag.js +163 -0
- package/dist/src/lib/migration-nag.js.map +1 -0
- package/dist/src/lib/output.d.ts +86 -0
- package/dist/src/lib/output.js +150 -8
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/paginate.d.ts +33 -0
- package/dist/src/lib/paginate.js +42 -0
- package/dist/src/lib/paginate.js.map +1 -0
- package/dist/src/lib/project-config.d.ts +97 -0
- package/dist/src/lib/project-config.js +209 -0
- package/dist/src/lib/project-config.js.map +1 -0
- 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/refresh-admin-credentials.d.ts +65 -0
- package/dist/src/lib/refresh-admin-credentials.js +103 -0
- package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
- package/dist/src/lib/resolve-platform.d.ts +45 -0
- package/dist/src/lib/resolve-platform.js +43 -0
- package/dist/src/lib/resolve-platform.js.map +1 -0
- package/dist/src/lib/skill-installer.d.ts +23 -0
- package/dist/src/lib/skill-installer.js +135 -0
- package/dist/src/lib/skill-installer.js.map +1 -0
- package/dist/src/lib/snapshots.d.ts +99 -0
- package/dist/src/lib/snapshots.js +357 -0
- package/dist/src/lib/snapshots.js.map +1 -0
- package/dist/src/lib/sync-paths.d.ts +72 -0
- package/dist/src/lib/sync-paths.js +130 -0
- package/dist/src/lib/sync-paths.js.map +1 -0
- package/dist/src/lib/template.d.ts +97 -0
- package/dist/src/lib/template.js +336 -62
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/token-inject.d.ts +56 -0
- package/dist/src/lib/token-inject.js +204 -0
- package/dist/src/lib/token-inject.js.map +1 -0
- package/dist/src/lib/toml-database-config.d.ts +152 -0
- package/dist/src/lib/toml-database-config.js +600 -0
- package/dist/src/lib/toml-database-config.js.map +1 -0
- package/dist/src/lib/toml-metadata-config.d.ts +108 -0
- package/dist/src/lib/toml-metadata-config.js +371 -0
- package/dist/src/lib/toml-metadata-config.js.map +1 -0
- package/dist/src/lib/toml-params-validator.d.ts +129 -0
- package/dist/src/lib/toml-params-validator.js +298 -0
- package/dist/src/lib/toml-params-validator.js.map +1 -0
- package/dist/src/lib/version-check.d.ts +10 -0
- package/dist/src/lib/version-check.js +172 -0
- package/dist/src/lib/version-check.js.map +1 -0
- package/dist/src/lib/workflow-apply.d.ts +66 -0
- package/dist/src/lib/workflow-apply.js +117 -0
- package/dist/src/lib/workflow-apply.js.map +1 -0
- package/dist/src/lib/workflow-fragments.d.ts +41 -0
- package/dist/src/lib/workflow-fragments.js +121 -0
- package/dist/src/lib/workflow-fragments.js.map +1 -0
- package/dist/src/lib/workflow-toml-validator.d.ts +95 -0
- package/dist/src/lib/workflow-toml-validator.js +323 -0
- package/dist/src/lib/workflow-toml-validator.js.map +1 -0
- package/dist/src/types/index.d.ts +520 -0
- package/dist/src/validators.d.ts +64 -0
- package/dist/src/validators.js +63 -0
- package/dist/src/validators.js.map +1 -0
- package/package.json +18 -4
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI TOML parser / validator / serializer for resource-metadata config
|
|
3
|
+
* surfaces (issue #1304, P-B — CLI/TOML config-sync).
|
|
4
|
+
*
|
|
5
|
+
* Two surfaces, mirroring the "config change ships all three surfaces" rule
|
|
6
|
+
* (CLAUDE.md; same shape as the database type-config helpers in
|
|
7
|
+
* `toml-database-config.ts`):
|
|
8
|
+
*
|
|
9
|
+
* 1. `MetadataCategoryConfig` blocks — a per-`{resourceType, category}`
|
|
10
|
+
* typed-schema + read/write-rule definition. These round-trip through
|
|
11
|
+
* `primitive sync push` / `pull` against the P-A REST API
|
|
12
|
+
* (`metadata-categories` CRUD). One file = one category, using a single
|
|
13
|
+
* `[metadataCategoryConfig]` section so the nested `schema.fields.*`
|
|
14
|
+
* tables serialize cleanly and byte-stably.
|
|
15
|
+
*
|
|
16
|
+
* 2. The declared-access manifest (`[metadata]` + `secrets` blocks) that
|
|
17
|
+
* lives on the owning config surfaces (`CollectionTypeConfig` /
|
|
18
|
+
* `DatabaseTypeConfig` / `WorkflowDefinition`). This module provides the
|
|
19
|
+
* TOML *structure* + *validator* + byte-stable round-trip helpers for the
|
|
20
|
+
* manifest so a bad value is rejected with a clear error. Wiring the
|
|
21
|
+
* manifest onto those config models' sync push/pull (which needs a
|
|
22
|
+
* storage field on each model) is P-C's "persist the manifest on owning
|
|
23
|
+
* configs" work — this module ships the parse/validate/serialize the
|
|
24
|
+
* P-C eval-site folding will call, matching how earlier phases shipped a
|
|
25
|
+
* validated mechanism ahead of its live wiring.
|
|
26
|
+
*
|
|
27
|
+
* All functions here are pure and unit-testable (no network, no filesystem).
|
|
28
|
+
* `validate*` functions return an error string (or `null` when valid) rather
|
|
29
|
+
* than throwing, mirroring `validateCategorySchema` server-side.
|
|
30
|
+
*/
|
|
31
|
+
/** The reserved projected category (computed live from a resource's columns).
|
|
32
|
+
* Matches the server's `RESERVED_PROJECTED_CATEGORY`. */
|
|
33
|
+
export declare const RESERVED_CATEGORY = "attrs";
|
|
34
|
+
/** The REST body shape for a category-config upsert (P-A `metadata-categories`). */
|
|
35
|
+
export interface MetadataCategoryConfigInput {
|
|
36
|
+
resourceType: string;
|
|
37
|
+
category: string;
|
|
38
|
+
schema: unknown;
|
|
39
|
+
readRule: string | null;
|
|
40
|
+
writeRule: string | null;
|
|
41
|
+
description: string | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalize a parsed `[metadataCategoryConfig]` TOML section into the REST
|
|
45
|
+
* upsert body. Server-managed fields (`schemaVersion`, `generation`) are never
|
|
46
|
+
* emitted or read here — they'd churn a round-trip.
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseMetadataCategoryToml(tomlData: any): MetadataCategoryConfigInput;
|
|
49
|
+
/**
|
|
50
|
+
* Validate a parsed category config (post-{@link parseMetadataCategoryToml}).
|
|
51
|
+
* Returns an error string, or `null` when valid. The server re-validates on
|
|
52
|
+
* write; this is the fast local check so `sync push` fails with a clear
|
|
53
|
+
* message before hitting the network.
|
|
54
|
+
*/
|
|
55
|
+
export declare function validateMetadataCategoryConfig(input: MetadataCategoryConfigInput): string | null;
|
|
56
|
+
/**
|
|
57
|
+
* Validate the `schema` block is a well-formed js-bao `FieldOptions` map:
|
|
58
|
+
* `{ fields: { <name>: { type, required?, maxLength?, maxCount?, enum? } } }`.
|
|
59
|
+
* Mirrors the server's `validateCategorySchema`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function validateCategorySchema(schema: unknown): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Serialize a category config (as returned by the P-A REST API — `schema` is a
|
|
64
|
+
* parsed object) to byte-stable TOML. Only the authored fields are emitted;
|
|
65
|
+
* server-managed `schemaVersion` / `generation` / `appId` / `categoryKey` are
|
|
66
|
+
* dropped so a pull → push → pull cycle is a no-op.
|
|
67
|
+
*
|
|
68
|
+
* Scalars are inserted before `schema` so `@iarna/toml` emits them ahead of
|
|
69
|
+
* the nested `[metadataCategoryConfig.schema.fields.*]` tables.
|
|
70
|
+
*/
|
|
71
|
+
export declare function serializeMetadataCategoryConfig(config: any): string;
|
|
72
|
+
export interface DeclaredAccessManifest {
|
|
73
|
+
self?: {
|
|
74
|
+
categories: string[];
|
|
75
|
+
};
|
|
76
|
+
paths?: Record<string, {
|
|
77
|
+
from?: string;
|
|
78
|
+
rootFrom?: string;
|
|
79
|
+
via?: string;
|
|
80
|
+
type?: string;
|
|
81
|
+
categories: string[];
|
|
82
|
+
}>;
|
|
83
|
+
secrets?: string[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Read the declared-access manifest out of a parsed config TOML: the top-level
|
|
87
|
+
* `[metadata]` table (self + paths) and the `secrets` array. Returns `null`
|
|
88
|
+
* when neither is present (the config declares no metadata/secrets access).
|
|
89
|
+
*/
|
|
90
|
+
export declare function parseDeclaredAccessManifestToml(tomlData: any): DeclaredAccessManifest | null;
|
|
91
|
+
/**
|
|
92
|
+
* Validate a declared-access manifest structurally. Returns an error string,
|
|
93
|
+
* or `null` when valid. This is the local surface-level check (identifier
|
|
94
|
+
* names, key shape, exactly-one-root per path); the server's
|
|
95
|
+
* `validatePathGraph` still does the deep graph validation (cycles, depth,
|
|
96
|
+
* schema-mismatch) at persist time.
|
|
97
|
+
*/
|
|
98
|
+
export declare function validateDeclaredAccessManifest(manifest: DeclaredAccessManifest | null | undefined): string | null;
|
|
99
|
+
/**
|
|
100
|
+
* Serialize a declared-access manifest into the TOML fragment object that
|
|
101
|
+
* merges into an owning config's TOML data (the caller spreads the returned
|
|
102
|
+
* keys alongside the config's own section). Returns `{}` when empty so a
|
|
103
|
+
* config with no declared access emits nothing (byte-stable).
|
|
104
|
+
*/
|
|
105
|
+
export declare function serializeDeclaredAccessManifest(manifest: DeclaredAccessManifest | null | undefined): {
|
|
106
|
+
metadata?: any;
|
|
107
|
+
secrets?: string[];
|
|
108
|
+
};
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI TOML parser / validator / serializer for resource-metadata config
|
|
3
|
+
* surfaces (issue #1304, P-B — CLI/TOML config-sync).
|
|
4
|
+
*
|
|
5
|
+
* Two surfaces, mirroring the "config change ships all three surfaces" rule
|
|
6
|
+
* (CLAUDE.md; same shape as the database type-config helpers in
|
|
7
|
+
* `toml-database-config.ts`):
|
|
8
|
+
*
|
|
9
|
+
* 1. `MetadataCategoryConfig` blocks — a per-`{resourceType, category}`
|
|
10
|
+
* typed-schema + read/write-rule definition. These round-trip through
|
|
11
|
+
* `primitive sync push` / `pull` against the P-A REST API
|
|
12
|
+
* (`metadata-categories` CRUD). One file = one category, using a single
|
|
13
|
+
* `[metadataCategoryConfig]` section so the nested `schema.fields.*`
|
|
14
|
+
* tables serialize cleanly and byte-stably.
|
|
15
|
+
*
|
|
16
|
+
* 2. The declared-access manifest (`[metadata]` + `secrets` blocks) that
|
|
17
|
+
* lives on the owning config surfaces (`CollectionTypeConfig` /
|
|
18
|
+
* `DatabaseTypeConfig` / `WorkflowDefinition`). This module provides the
|
|
19
|
+
* TOML *structure* + *validator* + byte-stable round-trip helpers for the
|
|
20
|
+
* manifest so a bad value is rejected with a clear error. Wiring the
|
|
21
|
+
* manifest onto those config models' sync push/pull (which needs a
|
|
22
|
+
* storage field on each model) is P-C's "persist the manifest on owning
|
|
23
|
+
* configs" work — this module ships the parse/validate/serialize the
|
|
24
|
+
* P-C eval-site folding will call, matching how earlier phases shipped a
|
|
25
|
+
* validated mechanism ahead of its live wiring.
|
|
26
|
+
*
|
|
27
|
+
* All functions here are pure and unit-testable (no network, no filesystem).
|
|
28
|
+
* `validate*` functions return an error string (or `null` when valid) rather
|
|
29
|
+
* than throwing, mirroring `validateCategorySchema` server-side.
|
|
30
|
+
*/
|
|
31
|
+
import * as TOML from "@iarna/toml";
|
|
32
|
+
/** Identifier-safe name: letters, digits, underscore; not starting with a digit.
|
|
33
|
+
* Matches the server's `METADATA_KEY_PATTERN`. */
|
|
34
|
+
const IDENTIFIER_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
35
|
+
/** The reserved projected category (computed live from a resource's columns).
|
|
36
|
+
* Matches the server's `RESERVED_PROJECTED_CATEGORY`. */
|
|
37
|
+
export const RESERVED_CATEGORY = "attrs";
|
|
38
|
+
/** The subset of js-bao `FieldOptions` field types the metadata schema accepts.
|
|
39
|
+
* Matches the server's `MetadataFieldType`. */
|
|
40
|
+
const METADATA_FIELD_TYPES = new Set([
|
|
41
|
+
"string",
|
|
42
|
+
"number",
|
|
43
|
+
"boolean",
|
|
44
|
+
"date",
|
|
45
|
+
"id",
|
|
46
|
+
"stringset",
|
|
47
|
+
]);
|
|
48
|
+
const CATEGORY_SECTION_KEYS = new Set([
|
|
49
|
+
"resourceType",
|
|
50
|
+
"category",
|
|
51
|
+
"schema",
|
|
52
|
+
"readRule",
|
|
53
|
+
"writeRule",
|
|
54
|
+
"description",
|
|
55
|
+
]);
|
|
56
|
+
/**
|
|
57
|
+
* Normalize a parsed `[metadataCategoryConfig]` TOML section into the REST
|
|
58
|
+
* upsert body. Server-managed fields (`schemaVersion`, `generation`) are never
|
|
59
|
+
* emitted or read here — they'd churn a round-trip.
|
|
60
|
+
*/
|
|
61
|
+
export function parseMetadataCategoryToml(tomlData) {
|
|
62
|
+
const section = (tomlData && tomlData.metadataCategoryConfig) || {};
|
|
63
|
+
return {
|
|
64
|
+
resourceType: section.resourceType,
|
|
65
|
+
category: section.category,
|
|
66
|
+
schema: section.schema,
|
|
67
|
+
readRule: section.readRule ?? null,
|
|
68
|
+
writeRule: section.writeRule ?? null,
|
|
69
|
+
description: section.description ?? null,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Validate a parsed category config (post-{@link parseMetadataCategoryToml}).
|
|
74
|
+
* Returns an error string, or `null` when valid. The server re-validates on
|
|
75
|
+
* write; this is the fast local check so `sync push` fails with a clear
|
|
76
|
+
* message before hitting the network.
|
|
77
|
+
*/
|
|
78
|
+
export function validateMetadataCategoryConfig(input) {
|
|
79
|
+
if (!input.resourceType || typeof input.resourceType !== "string") {
|
|
80
|
+
return "metadataCategoryConfig.resourceType is required and must be a string";
|
|
81
|
+
}
|
|
82
|
+
if (!IDENTIFIER_PATTERN.test(input.resourceType)) {
|
|
83
|
+
return `metadataCategoryConfig.resourceType "${input.resourceType}" must be identifier-safe (letters, digits, underscore; not starting with a digit)`;
|
|
84
|
+
}
|
|
85
|
+
if (!input.category || typeof input.category !== "string") {
|
|
86
|
+
return "metadataCategoryConfig.category is required and must be a string";
|
|
87
|
+
}
|
|
88
|
+
if (!IDENTIFIER_PATTERN.test(input.category)) {
|
|
89
|
+
return `metadataCategoryConfig.category "${input.category}" must be identifier-safe (letters, digits, underscore; not starting with a digit)`;
|
|
90
|
+
}
|
|
91
|
+
if (input.category === RESERVED_CATEGORY) {
|
|
92
|
+
return `metadataCategoryConfig.category "${RESERVED_CATEGORY}" is reserved (a projected category computed from the resource's own columns) and cannot be defined`;
|
|
93
|
+
}
|
|
94
|
+
if (input.readRule !== null &&
|
|
95
|
+
input.readRule !== undefined &&
|
|
96
|
+
typeof input.readRule !== "string") {
|
|
97
|
+
return "metadataCategoryConfig.readRule must be a string (a CEL expression)";
|
|
98
|
+
}
|
|
99
|
+
if (input.writeRule !== null &&
|
|
100
|
+
input.writeRule !== undefined &&
|
|
101
|
+
typeof input.writeRule !== "string") {
|
|
102
|
+
return "metadataCategoryConfig.writeRule must be a string (a CEL expression)";
|
|
103
|
+
}
|
|
104
|
+
if (input.description !== null &&
|
|
105
|
+
input.description !== undefined &&
|
|
106
|
+
typeof input.description !== "string") {
|
|
107
|
+
return "metadataCategoryConfig.description must be a string";
|
|
108
|
+
}
|
|
109
|
+
return validateCategorySchema(input.schema);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Validate the `schema` block is a well-formed js-bao `FieldOptions` map:
|
|
113
|
+
* `{ fields: { <name>: { type, required?, maxLength?, maxCount?, enum? } } }`.
|
|
114
|
+
* Mirrors the server's `validateCategorySchema`.
|
|
115
|
+
*/
|
|
116
|
+
export function validateCategorySchema(schema) {
|
|
117
|
+
if (schema === null || typeof schema !== "object" || Array.isArray(schema)) {
|
|
118
|
+
return "metadataCategoryConfig.schema must be a table with a 'fields' map";
|
|
119
|
+
}
|
|
120
|
+
const fields = schema.fields;
|
|
121
|
+
if (fields === null || typeof fields !== "object" || Array.isArray(fields)) {
|
|
122
|
+
return "metadataCategoryConfig.schema.fields must be a table";
|
|
123
|
+
}
|
|
124
|
+
// Reject unknown top-level keys under `schema` (only `fields` is meaningful).
|
|
125
|
+
for (const key of Object.keys(schema)) {
|
|
126
|
+
if (key !== "fields") {
|
|
127
|
+
return `metadataCategoryConfig.schema has an unknown key "${key}" (only "fields" is allowed)`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
for (const [name, def] of Object.entries(fields)) {
|
|
131
|
+
if (!IDENTIFIER_PATTERN.test(name)) {
|
|
132
|
+
return `schema field name "${name}" must be identifier-safe`;
|
|
133
|
+
}
|
|
134
|
+
if (def === null || typeof def !== "object" || Array.isArray(def)) {
|
|
135
|
+
return `schema field "${name}" must be a table with a "type"`;
|
|
136
|
+
}
|
|
137
|
+
const field = def;
|
|
138
|
+
if (typeof field.type !== "string" || !METADATA_FIELD_TYPES.has(field.type)) {
|
|
139
|
+
return `schema field "${name}" has an invalid type (allowed: ${[
|
|
140
|
+
...METADATA_FIELD_TYPES,
|
|
141
|
+
].join(", ")})`;
|
|
142
|
+
}
|
|
143
|
+
if (field.enum !== undefined) {
|
|
144
|
+
if (!Array.isArray(field.enum) ||
|
|
145
|
+
field.enum.some((v) => typeof v !== "string")) {
|
|
146
|
+
return `schema field "${name}" enum must be an array of strings`;
|
|
147
|
+
}
|
|
148
|
+
if (field.type !== "string") {
|
|
149
|
+
return `schema field "${name}" enum is only valid on a "string" field`;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (field.maxLength !== undefined && typeof field.maxLength !== "number") {
|
|
153
|
+
return `schema field "${name}" maxLength must be a number`;
|
|
154
|
+
}
|
|
155
|
+
if (field.maxCount !== undefined && typeof field.maxCount !== "number") {
|
|
156
|
+
return `schema field "${name}" maxCount must be a number`;
|
|
157
|
+
}
|
|
158
|
+
if (field.required !== undefined && typeof field.required !== "boolean") {
|
|
159
|
+
return `schema field "${name}" required must be a boolean`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Serialize a category config (as returned by the P-A REST API — `schema` is a
|
|
166
|
+
* parsed object) to byte-stable TOML. Only the authored fields are emitted;
|
|
167
|
+
* server-managed `schemaVersion` / `generation` / `appId` / `categoryKey` are
|
|
168
|
+
* dropped so a pull → push → pull cycle is a no-op.
|
|
169
|
+
*
|
|
170
|
+
* Scalars are inserted before `schema` so `@iarna/toml` emits them ahead of
|
|
171
|
+
* the nested `[metadataCategoryConfig.schema.fields.*]` tables.
|
|
172
|
+
*/
|
|
173
|
+
export function serializeMetadataCategoryConfig(config) {
|
|
174
|
+
const section = {
|
|
175
|
+
resourceType: config.resourceType,
|
|
176
|
+
category: config.category,
|
|
177
|
+
};
|
|
178
|
+
if (config.readRule !== null && config.readRule !== undefined) {
|
|
179
|
+
section.readRule = config.readRule;
|
|
180
|
+
}
|
|
181
|
+
if (config.writeRule !== null && config.writeRule !== undefined) {
|
|
182
|
+
section.writeRule = config.writeRule;
|
|
183
|
+
}
|
|
184
|
+
if (config.description !== null &&
|
|
185
|
+
config.description !== undefined &&
|
|
186
|
+
config.description !== "") {
|
|
187
|
+
section.description = config.description;
|
|
188
|
+
}
|
|
189
|
+
// `schema` may arrive as a parsed object (REST) or a JSON string (defensive).
|
|
190
|
+
let schema = config.schema;
|
|
191
|
+
if (typeof schema === "string") {
|
|
192
|
+
try {
|
|
193
|
+
schema = JSON.parse(schema);
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
schema = { fields: {} };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
section.schema = schema ?? { fields: {} };
|
|
200
|
+
return TOML.stringify({ metadataCategoryConfig: section });
|
|
201
|
+
}
|
|
202
|
+
// --- Declared-access manifest (`[metadata]` + `secrets`) -------------------
|
|
203
|
+
//
|
|
204
|
+
// The manifest that lives on an owning config surface. Shape mirrors the
|
|
205
|
+
// server's `MetadataDeclaration` (`src/app-api/helpers/metadata-cel-access.ts`):
|
|
206
|
+
// metadata.self.categories = ["profile"]
|
|
207
|
+
// [metadata.paths.<name>] from|rootFrom, via, type, categories
|
|
208
|
+
// secrets = ["STRIPE_KEY"]
|
|
209
|
+
/** Root contexts a `rootFrom` path may start at (subjectless contexts). */
|
|
210
|
+
const ROOT_CONTEXT_PREFIXES = ["input", "record", "params"];
|
|
211
|
+
const MANIFEST_KEYS = new Set(["self", "paths", "secrets"]);
|
|
212
|
+
const SELF_KEYS = new Set(["categories"]);
|
|
213
|
+
const PATH_KEYS = new Set(["from", "rootFrom", "via", "type", "categories"]);
|
|
214
|
+
/**
|
|
215
|
+
* Read the declared-access manifest out of a parsed config TOML: the top-level
|
|
216
|
+
* `[metadata]` table (self + paths) and the `secrets` array. Returns `null`
|
|
217
|
+
* when neither is present (the config declares no metadata/secrets access).
|
|
218
|
+
*/
|
|
219
|
+
export function parseDeclaredAccessManifestToml(tomlData) {
|
|
220
|
+
const metadata = tomlData?.metadata;
|
|
221
|
+
const secrets = tomlData?.secrets;
|
|
222
|
+
if (metadata === undefined && secrets === undefined)
|
|
223
|
+
return null;
|
|
224
|
+
const manifest = {};
|
|
225
|
+
if (metadata && typeof metadata === "object") {
|
|
226
|
+
if (metadata.self !== undefined) {
|
|
227
|
+
manifest.self = { categories: metadata.self?.categories };
|
|
228
|
+
}
|
|
229
|
+
if (metadata.paths !== undefined) {
|
|
230
|
+
manifest.paths = metadata.paths;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (secrets !== undefined) {
|
|
234
|
+
manifest.secrets = secrets;
|
|
235
|
+
}
|
|
236
|
+
return manifest;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Validate a declared-access manifest structurally. Returns an error string,
|
|
240
|
+
* or `null` when valid. This is the local surface-level check (identifier
|
|
241
|
+
* names, key shape, exactly-one-root per path); the server's
|
|
242
|
+
* `validatePathGraph` still does the deep graph validation (cycles, depth,
|
|
243
|
+
* schema-mismatch) at persist time.
|
|
244
|
+
*/
|
|
245
|
+
export function validateDeclaredAccessManifest(manifest) {
|
|
246
|
+
if (manifest === null || manifest === undefined)
|
|
247
|
+
return null;
|
|
248
|
+
if (typeof manifest !== "object" || Array.isArray(manifest)) {
|
|
249
|
+
return "declared-access manifest must be a table";
|
|
250
|
+
}
|
|
251
|
+
// `self`
|
|
252
|
+
if (manifest.self !== undefined) {
|
|
253
|
+
const self = manifest.self;
|
|
254
|
+
if (self === null || typeof self !== "object" || Array.isArray(self)) {
|
|
255
|
+
return "metadata.self must be a table with a 'categories' array";
|
|
256
|
+
}
|
|
257
|
+
for (const key of Object.keys(self)) {
|
|
258
|
+
if (!SELF_KEYS.has(key)) {
|
|
259
|
+
return `metadata.self has an unknown key "${key}" (only "categories" is allowed)`;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const catError = validateCategoryList(self.categories, "metadata.self");
|
|
263
|
+
if (catError)
|
|
264
|
+
return catError;
|
|
265
|
+
}
|
|
266
|
+
// `paths`
|
|
267
|
+
if (manifest.paths !== undefined) {
|
|
268
|
+
const paths = manifest.paths;
|
|
269
|
+
if (paths === null || typeof paths !== "object" || Array.isArray(paths)) {
|
|
270
|
+
return "metadata.paths must be a table of named path declarations";
|
|
271
|
+
}
|
|
272
|
+
const declaredNodes = new Set(["self", ...Object.keys(paths)]);
|
|
273
|
+
for (const [name, raw] of Object.entries(paths)) {
|
|
274
|
+
if (!IDENTIFIER_PATTERN.test(name)) {
|
|
275
|
+
return `metadata.paths."${name}" name must be identifier-safe`;
|
|
276
|
+
}
|
|
277
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
278
|
+
return `metadata.paths."${name}" must be a table`;
|
|
279
|
+
}
|
|
280
|
+
const p = raw;
|
|
281
|
+
for (const key of Object.keys(p)) {
|
|
282
|
+
if (!PATH_KEYS.has(key)) {
|
|
283
|
+
return `metadata.paths."${name}" has an unknown key "${key}" (allowed: ${[
|
|
284
|
+
...PATH_KEYS,
|
|
285
|
+
].join(", ")})`;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const hasFrom = typeof p.from === "string" && p.from !== "";
|
|
289
|
+
const hasRoot = typeof p.rootFrom === "string" && p.rootFrom !== "";
|
|
290
|
+
if (hasFrom === hasRoot) {
|
|
291
|
+
return `metadata.paths."${name}" must declare exactly one of "from" or "rootFrom"`;
|
|
292
|
+
}
|
|
293
|
+
if (hasFrom) {
|
|
294
|
+
if (!declaredNodes.has(p.from)) {
|
|
295
|
+
return `metadata.paths."${name}" from "${p.from}" references an undeclared node (must be "self" or another declared path)`;
|
|
296
|
+
}
|
|
297
|
+
if (typeof p.via !== "string" || !p.via.includes(".")) {
|
|
298
|
+
return `metadata.paths."${name}" must declare a "via" of the form "<category>.<key>"`;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
// rootFrom: a static context path (`input.*` / `record.*` / `params.*`).
|
|
303
|
+
const rootFrom = p.rootFrom;
|
|
304
|
+
const prefix = rootFrom.split(".")[0];
|
|
305
|
+
if (!ROOT_CONTEXT_PREFIXES.includes(prefix)) {
|
|
306
|
+
return `metadata.paths."${name}" rootFrom "${rootFrom}" must be a static context path (${ROOT_CONTEXT_PREFIXES.join(".")}.*)`;
|
|
307
|
+
}
|
|
308
|
+
if (p.via !== undefined) {
|
|
309
|
+
return `metadata.paths."${name}" roots at "${rootFrom}" and must not also declare "via"`;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (typeof p.type !== "string" || p.type === "") {
|
|
313
|
+
return `metadata.paths."${name}" must declare a target "type" (the resource type)`;
|
|
314
|
+
}
|
|
315
|
+
const catError = validateCategoryList(p.categories, `metadata.paths."${name}"`);
|
|
316
|
+
if (catError)
|
|
317
|
+
return catError;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
// `secrets`
|
|
321
|
+
if (manifest.secrets !== undefined) {
|
|
322
|
+
if (!Array.isArray(manifest.secrets) ||
|
|
323
|
+
manifest.secrets.some((s) => typeof s !== "string")) {
|
|
324
|
+
return "secrets must be an array of secret key names (strings)";
|
|
325
|
+
}
|
|
326
|
+
for (const key of manifest.secrets) {
|
|
327
|
+
if (!IDENTIFIER_PATTERN.test(key)) {
|
|
328
|
+
return `secrets key "${key}" must be identifier-safe`;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
function validateCategoryList(categories, where) {
|
|
335
|
+
if (!Array.isArray(categories) ||
|
|
336
|
+
categories.some((c) => typeof c !== "string")) {
|
|
337
|
+
return `${where}.categories must be an array of category names (strings)`;
|
|
338
|
+
}
|
|
339
|
+
for (const cat of categories) {
|
|
340
|
+
if (cat !== RESERVED_CATEGORY && !IDENTIFIER_PATTERN.test(cat)) {
|
|
341
|
+
return `${where}.categories entry "${cat}" must be identifier-safe`;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Serialize a declared-access manifest into the TOML fragment object that
|
|
348
|
+
* merges into an owning config's TOML data (the caller spreads the returned
|
|
349
|
+
* keys alongside the config's own section). Returns `{}` when empty so a
|
|
350
|
+
* config with no declared access emits nothing (byte-stable).
|
|
351
|
+
*/
|
|
352
|
+
export function serializeDeclaredAccessManifest(manifest) {
|
|
353
|
+
if (!manifest)
|
|
354
|
+
return {};
|
|
355
|
+
const out = {};
|
|
356
|
+
const metadata = {};
|
|
357
|
+
if (manifest.self && Array.isArray(manifest.self.categories)) {
|
|
358
|
+
metadata.self = { categories: manifest.self.categories };
|
|
359
|
+
}
|
|
360
|
+
if (manifest.paths && Object.keys(manifest.paths).length > 0) {
|
|
361
|
+
metadata.paths = manifest.paths;
|
|
362
|
+
}
|
|
363
|
+
if (Object.keys(metadata).length > 0) {
|
|
364
|
+
out.metadata = metadata;
|
|
365
|
+
}
|
|
366
|
+
if (Array.isArray(manifest.secrets) && manifest.secrets.length > 0) {
|
|
367
|
+
out.secrets = manifest.secrets;
|
|
368
|
+
}
|
|
369
|
+
return out;
|
|
370
|
+
}
|
|
371
|
+
//# sourceMappingURL=toml-metadata-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toml-metadata-config.js","sourceRoot":"","sources":["../../../src/lib/toml-metadata-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC;mDACmD;AACnD,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AAEtD;0DAC0D;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAEzC;gDACgD;AAChD,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,QAAQ;IACR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BAA+B,CAC7C,QAAmD;IAEnD,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC;IACzB,MAAM,GAAG,GAA2C,EAAE,CAAC;IACvD,MAAM,QAAQ,GAAQ,EAAE,CAAC;IACzB,IAAI,QAAQ,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7D,QAAQ,CAAC,IAAI,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3D,CAAC;IACD,IAAI,QAAQ,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7D,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAClC,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnE,GAAG,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IACjC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validator: every `$params.X` reference inside an operation's
|
|
3
|
+
* `definition` must correspond to a declared param in
|
|
4
|
+
* `[[operations.params]]` (or the legacy JSON-string params object).
|
|
5
|
+
*
|
|
6
|
+
* Background (issue #752): a typo like `$params.proectId` used to
|
|
7
|
+
* silently no-op at runtime. With native TOML, we can catch these at
|
|
8
|
+
* `sync push` time with the file path and line number of the
|
|
9
|
+
* operation block where the bad reference appears.
|
|
10
|
+
*
|
|
11
|
+
* Design notes:
|
|
12
|
+
* - Line attribution is per-operation, not per-reference. We don't
|
|
13
|
+
* parse `definition` line-by-line; we just locate the
|
|
14
|
+
* `[[operations]]` header for the named op in the raw source and
|
|
15
|
+
* report that line. This is the load-bearing UX (jump to the
|
|
16
|
+
* offending op block); pinpointing the exact `$params.X` reference
|
|
17
|
+
* inside a sub-table would require swapping the TOML parser, which
|
|
18
|
+
* the issue explicitly leaves to implementer judgement.
|
|
19
|
+
* - We intentionally diverge from the server-side `collectParamRefs`
|
|
20
|
+
* in `database-type-operations-controller.ts:1163`. The server pushes
|
|
21
|
+
* the full path (e.g. `"X.Y"` for `$params.X.Y`); the CLI extracts
|
|
22
|
+
* only the first segment (`"X"`). Net effect: the CLI validator is
|
|
23
|
+
* more lenient than the server — `$params.X.Y` passes the CLI check
|
|
24
|
+
* when `X` alone is declared in `[[operations.params]]`, even though
|
|
25
|
+
* the server treats the full path as the lookup key. The server
|
|
26
|
+
* remains authoritative; the CLI's first-segment extraction is a
|
|
27
|
+
* pragmatic choice so authors can declare structured params (e.g.
|
|
28
|
+
* `config: { type: "object" }`) and reference sub-fields like
|
|
29
|
+
* `$params.config.subKey` without listing every sub-field
|
|
30
|
+
* individually (review feedback r3246635661).
|
|
31
|
+
*/
|
|
32
|
+
export interface ValidationIssue {
|
|
33
|
+
file: string;
|
|
34
|
+
line: number;
|
|
35
|
+
op: string;
|
|
36
|
+
message: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ValidationResult {
|
|
39
|
+
errors: ValidationIssue[];
|
|
40
|
+
warnings: ValidationIssue[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Walk an arbitrary JSON-ish value and collect `$params.X` references
|
|
44
|
+
* found in string-valued leaves, returning only the first dotted segment
|
|
45
|
+
* (`"X"` for `$params.X.Y`). Intentionally more lenient than the
|
|
46
|
+
* server-side helper, which pushes the full path — see the module
|
|
47
|
+
* doc-comment for the rationale.
|
|
48
|
+
*/
|
|
49
|
+
export declare function collectParamRefs(value: any): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Collect bare `params.X` references from a CEL string (issue #1239).
|
|
52
|
+
*
|
|
53
|
+
* Access rules reference operation params with the bare `params.X` form (no
|
|
54
|
+
* `$` prefix), unlike `definition`, which uses `$params.X` (scanned by
|
|
55
|
+
* {@link collectParamRefs}). This helper feeds the operation's `access` CEL
|
|
56
|
+
* and each per-param `access` CEL into the "referenced" set so a param used
|
|
57
|
+
* only by an access rule is not wrongly flagged "declared but not referenced".
|
|
58
|
+
*
|
|
59
|
+
* Supported forms, all whitespace-tolerant:
|
|
60
|
+
* - dot notation: `params.claimedUserId`, `params . claimedUserId`
|
|
61
|
+
* - dot path: `params.config.subField` → first segment `config`
|
|
62
|
+
* - bracket notation: `params["claimedUserId"]`, `params['claimedUserId']`
|
|
63
|
+
*
|
|
64
|
+
* Word-boundary guard: a `params` preceded by an identifier char, `$`, or `.`
|
|
65
|
+
* is NOT a match, so `$params.x` (definition syntax), `myparams.x`, and a
|
|
66
|
+
* dotted member access like `database.metadata.params.userId` are ignored —
|
|
67
|
+
* `params` only counts as the params root when it's a standalone root
|
|
68
|
+
* identifier. To avoid counting a `params.` that merely appears inside a quoted
|
|
69
|
+
* string literal (e.g. `note == "see params.docs"`), bracket keys are scanned
|
|
70
|
+
* first (they legitimately contain quotes), then string literals are stripped
|
|
71
|
+
* before the dot-notation scan.
|
|
72
|
+
*
|
|
73
|
+
* Purely additive: this only grows the referenced set, loosening the soft
|
|
74
|
+
* warning. The blocking `$params` error path is untouched.
|
|
75
|
+
*/
|
|
76
|
+
export declare function collectCelParamRefs(cel: any): string[];
|
|
77
|
+
/**
|
|
78
|
+
* Normalize a `params` value (object, array, or JSON string) into the
|
|
79
|
+
* set of declared param names.
|
|
80
|
+
*/
|
|
81
|
+
export declare function declaredParamNames(params: any): Set<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Find the 1-indexed line number in `rawToml` where the `[[operations]]`
|
|
84
|
+
* block declaring `opName` starts. Returns 0 if not found.
|
|
85
|
+
*
|
|
86
|
+
* Implementation: walk in source order, track the most recent
|
|
87
|
+
* `[[operations]]` header, and when we see a `name = "<opName>"` line
|
|
88
|
+
* before the next `[[operations]]` or top-level header, return that
|
|
89
|
+
* header's line.
|
|
90
|
+
*/
|
|
91
|
+
export declare function locateOperationLine(rawToml: string, opName: string): number;
|
|
92
|
+
export interface ValidateOptions {
|
|
93
|
+
filePath: string;
|
|
94
|
+
rawToml: string;
|
|
95
|
+
/**
|
|
96
|
+
* Operations as parsed for the wire (definition/params already in JS
|
|
97
|
+
* object form). The validator works against the parsed shape so it's
|
|
98
|
+
* indifferent to native vs JSON-string source.
|
|
99
|
+
*/
|
|
100
|
+
operations: Array<{
|
|
101
|
+
name: string;
|
|
102
|
+
definition: any;
|
|
103
|
+
params?: any;
|
|
104
|
+
/**
|
|
105
|
+
* The operation-level `access` CEL rule, if any (issue #1239). Params
|
|
106
|
+
* referenced here via bare `params.X` count as "referenced" so they are
|
|
107
|
+
* not wrongly flagged "declared but not referenced". May be null/absent
|
|
108
|
+
* when the operation inherits the type's `defaultAccess`.
|
|
109
|
+
*/
|
|
110
|
+
access?: any;
|
|
111
|
+
}>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Validate `$params` references across every operation in a parsed
|
|
115
|
+
* database-type config.
|
|
116
|
+
*
|
|
117
|
+
* Errors (blocking):
|
|
118
|
+
* - A `$params.X` reference inside `definition` where `X` is not
|
|
119
|
+
* declared in `[[operations.params]]`.
|
|
120
|
+
*
|
|
121
|
+
* Warnings (soft, not blocking):
|
|
122
|
+
* - A param declared in `[[operations.params]]` that is not referenced
|
|
123
|
+
* anywhere in `definition`. Authors may be staging a deprecation.
|
|
124
|
+
*/
|
|
125
|
+
export declare function validateOperations(opts: ValidateOptions): ValidationResult;
|
|
126
|
+
/**
|
|
127
|
+
* Format a validation issue as `<file>:<line>: <message>`.
|
|
128
|
+
*/
|
|
129
|
+
export declare function formatIssue(issue: ValidationIssue): string;
|