primitive-admin 1.0.61 → 1.0.62
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 +125 -69
- package/assets/skill/skills/primitive-platform/SKILL.md +336 -37
- package/dist/bin/primitive.js +25 -14
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/analytics.js +36 -16
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps.js +49 -188
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/blob-buckets.js +13 -153
- package/dist/src/commands/blob-buckets.js.map +1 -1
- package/dist/src/commands/collection-type-configs.js +14 -100
- package/dist/src/commands/collection-type-configs.js.map +1 -1
- package/dist/src/commands/collections.js +47 -8
- package/dist/src/commands/collections.js.map +1 -1
- package/dist/src/commands/config.d.ts +46 -0
- package/dist/src/commands/config.js +479 -0
- package/dist/src/commands/config.js.map +1 -0
- package/dist/src/commands/connections.js +12 -7
- package/dist/src/commands/connections.js.map +1 -1
- package/dist/src/commands/cron-triggers.js +84 -176
- package/dist/src/commands/cron-triggers.js.map +1 -1
- package/dist/src/commands/database-type-configs.d.ts +2 -0
- package/dist/src/commands/database-type-configs.js +171 -0
- package/dist/src/commands/database-type-configs.js.map +1 -0
- package/dist/src/commands/database-types.js +4 -4
- package/dist/src/commands/database-types.js.map +1 -1
- package/dist/src/commands/databases.d.ts +63 -0
- package/dist/src/commands/databases.js +649 -87
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.js +869 -12
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/email-templates.js +18 -125
- package/dist/src/commands/email-templates.js.map +1 -1
- package/dist/src/commands/env.d.ts +12 -1
- package/dist/src/commands/env.js +98 -25
- package/dist/src/commands/env.js.map +1 -1
- package/dist/src/commands/feature-flags.d.ts +14 -0
- package/dist/src/commands/feature-flags.js +116 -0
- package/dist/src/commands/feature-flags.js.map +1 -0
- package/dist/src/commands/group-type-configs.js +14 -109
- package/dist/src/commands/group-type-configs.js.map +1 -1
- package/dist/src/commands/init.d.ts +9 -1
- package/dist/src/commands/init.js +1056 -277
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.js +136 -421
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/metadata-category-configs.d.ts +12 -0
- package/dist/src/commands/metadata-category-configs.js +112 -0
- package/dist/src/commands/metadata-category-configs.js.map +1 -0
- package/dist/src/commands/metadata.js +33 -141
- package/dist/src/commands/metadata.js.map +1 -1
- package/dist/src/commands/prompts.js +206 -563
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rule-sets.d.ts +1 -1
- package/dist/src/commands/rule-sets.js +16 -132
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/scripts.js +67 -234
- package/dist/src/commands/scripts.js.map +1 -1
- package/dist/src/commands/sessions.js +17 -5
- package/dist/src/commands/sessions.js.map +1 -1
- package/dist/src/commands/sync-app-settings.d.ts +113 -70
- package/dist/src/commands/sync-app-settings.js +193 -242
- package/dist/src/commands/sync-app-settings.js.map +1 -1
- package/dist/src/commands/sync.d.ts +1932 -49
- package/dist/src/commands/sync.js +9521 -1769
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.js +8 -2
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/users.js +92 -1
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/vars.js +44 -58
- package/dist/src/commands/vars.js.map +1 -1
- package/dist/src/commands/webhooks.js +318 -156
- package/dist/src/commands/webhooks.js.map +1 -1
- package/dist/src/commands/workflows.d.ts +49 -12
- package/dist/src/commands/workflows.js +652 -1086
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/access-rule-display.d.ts +21 -0
- package/dist/src/lib/access-rule-display.js +34 -0
- package/dist/src/lib/access-rule-display.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +541 -61
- package/dist/src/lib/api-client.js +559 -102
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +180 -25
- package/dist/src/lib/app-settings-descriptor.js +403 -82
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/canonical-json.d.ts +12 -0
- package/dist/src/lib/canonical-json.js +35 -0
- package/dist/src/lib/canonical-json.js.map +1 -0
- package/dist/src/lib/cli-manifest.d.ts +8 -0
- package/dist/src/lib/cli-manifest.js +1 -0
- package/dist/src/lib/cli-manifest.js.map +1 -1
- package/dist/src/lib/codegen-shared/generatedFiles.d.ts +6 -2
- package/dist/src/lib/codegen-shared/generatedFiles.js +9 -2
- package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -1
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +6 -6
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +8 -8
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -1
- package/dist/src/lib/config-object-descriptor.d.ts +127 -0
- package/dist/src/lib/config-object-descriptor.js +658 -0
- package/dist/src/lib/config-object-descriptor.js.map +1 -0
- package/dist/src/lib/config-payload.d.ts +85 -0
- package/dist/src/lib/config-payload.js +116 -0
- package/dist/src/lib/config-payload.js.map +1 -0
- package/dist/src/lib/config-surface.d.ts +130 -0
- package/dist/src/lib/config-surface.js +300 -0
- package/dist/src/lib/config-surface.js.map +1 -0
- package/dist/src/lib/credentials-store.d.ts +10 -0
- package/dist/src/lib/credentials-store.js +23 -0
- package/dist/src/lib/credentials-store.js.map +1 -1
- package/dist/src/lib/data-input.d.ts +23 -0
- package/dist/src/lib/data-input.js +50 -0
- package/dist/src/lib/data-input.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTemplates.js +1 -1
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTypeIR.d.ts +1 -1
- package/dist/src/lib/env-resolver-core.d.ts +147 -0
- package/dist/src/lib/env-resolver-core.js +265 -0
- package/dist/src/lib/env-resolver-core.js.map +1 -0
- package/dist/src/lib/env-resolver.d.ts +28 -6
- package/dist/src/lib/env-resolver.js +44 -32
- package/dist/src/lib/env-resolver.js.map +1 -1
- package/dist/src/lib/generated-allowlist.js +12 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -1
- package/dist/src/lib/generated-config-surfaces.d.ts +682 -0
- package/dist/src/lib/generated-config-surfaces.js +4058 -0
- package/dist/src/lib/generated-config-surfaces.js.map +1 -0
- package/dist/src/lib/generated-template-lint.d.ts +212 -0
- package/dist/src/lib/generated-template-lint.js +624 -0
- package/dist/src/lib/generated-template-lint.js.map +1 -0
- package/dist/src/lib/init-adopt.d.ts +16 -0
- package/dist/src/lib/init-adopt.js +34 -0
- package/dist/src/lib/init-adopt.js.map +1 -0
- package/dist/src/lib/init-assets.d.ts +39 -0
- package/dist/src/lib/init-assets.js +97 -0
- package/dist/src/lib/init-assets.js.map +1 -0
- package/dist/src/lib/init-config.d.ts +44 -5
- package/dist/src/lib/init-config.js +80 -7
- package/dist/src/lib/init-config.js.map +1 -1
- package/dist/src/lib/init-ios-links.d.ts +50 -0
- package/dist/src/lib/init-ios-links.js +153 -0
- package/dist/src/lib/init-ios-links.js.map +1 -0
- package/dist/src/lib/init-plan.d.ts +80 -0
- package/dist/src/lib/init-plan.js +95 -0
- package/dist/src/lib/init-plan.js.map +1 -0
- package/dist/src/lib/init-production-env.d.ts +48 -0
- package/dist/src/lib/init-production-env.js +59 -0
- package/dist/src/lib/init-production-env.js.map +1 -0
- package/dist/src/lib/init-schema.d.ts +74 -0
- package/dist/src/lib/init-schema.js +358 -0
- package/dist/src/lib/init-schema.js.map +1 -0
- package/dist/src/lib/init-xcode.d.ts +33 -0
- package/dist/src/lib/init-xcode.js +114 -0
- package/dist/src/lib/init-xcode.js.map +1 -0
- package/dist/src/lib/integration-request-config.d.ts +30 -0
- package/dist/src/lib/integration-request-config.js +145 -0
- package/dist/src/lib/integration-request-config.js.map +1 -0
- package/dist/src/lib/local-state.d.ts +55 -0
- package/dist/src/lib/local-state.js +167 -0
- package/dist/src/lib/local-state.js.map +1 -0
- package/dist/src/lib/log-inspection.d.ts +568 -0
- package/dist/src/lib/log-inspection.js +639 -0
- package/dist/src/lib/log-inspection.js.map +1 -0
- package/dist/src/lib/migration-nag.d.ts +2 -2
- package/dist/src/lib/migration-nag.js +3 -3
- package/dist/src/lib/object-status-filter.d.ts +22 -0
- package/dist/src/lib/object-status-filter.js +45 -0
- package/dist/src/lib/object-status-filter.js.map +1 -0
- package/dist/src/lib/output.d.ts +24 -1
- package/dist/src/lib/output.js +42 -1
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/package-manager.d.ts +140 -0
- package/dist/src/lib/package-manager.js +305 -0
- package/dist/src/lib/package-manager.js.map +1 -0
- package/dist/src/lib/paginate.d.ts +50 -0
- package/dist/src/lib/paginate.js +53 -0
- package/dist/src/lib/paginate.js.map +1 -1
- package/dist/src/lib/platform-owned.d.ts +29 -3
- package/dist/src/lib/platform-owned.js +42 -3
- package/dist/src/lib/platform-owned.js.map +1 -1
- package/dist/src/lib/project-config.js +13 -5
- package/dist/src/lib/project-config.js.map +1 -1
- package/dist/src/lib/query-operators.d.ts +1 -1
- package/dist/src/lib/query-operators.js +1 -1
- package/dist/src/lib/record-filter.d.ts +18 -0
- package/dist/src/lib/record-filter.js +55 -0
- package/dist/src/lib/record-filter.js.map +1 -0
- package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
- package/dist/src/lib/resolve-init-dev-port.js +55 -0
- package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
- package/dist/src/lib/resolve-init-server.d.ts +64 -0
- package/dist/src/lib/resolve-init-server.js +77 -0
- package/dist/src/lib/resolve-init-server.js.map +1 -0
- package/dist/src/lib/resolve-platform.d.ts +43 -14
- package/dist/src/lib/resolve-platform.js +74 -12
- package/dist/src/lib/resolve-platform.js.map +1 -1
- package/dist/src/lib/run-status.d.ts +19 -0
- package/dist/src/lib/run-status.generated.d.ts +39 -0
- package/dist/src/lib/run-status.generated.js +66 -0
- package/dist/src/lib/run-status.generated.js.map +1 -0
- package/dist/src/lib/run-status.js +19 -0
- package/dist/src/lib/run-status.js.map +1 -0
- package/dist/src/lib/server-text-normalization.d.ts +51 -0
- package/dist/src/lib/server-text-normalization.js +90 -0
- package/dist/src/lib/server-text-normalization.js.map +1 -0
- package/dist/src/lib/server-url.d.ts +22 -0
- package/dist/src/lib/server-url.js +33 -0
- package/dist/src/lib/server-url.js.map +1 -0
- package/dist/src/lib/signing-secret-status.d.ts +81 -0
- package/dist/src/lib/signing-secret-status.js +116 -0
- package/dist/src/lib/signing-secret-status.js.map +1 -0
- package/dist/src/lib/skill-installer.js +6 -3
- package/dist/src/lib/skill-installer.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/dbGenerator.d.ts +15 -2
- package/dist/src/lib/swift-codegen/dbGenerator.js +250 -18
- package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/generator.d.ts +11 -2
- package/dist/src/lib/swift-codegen/generator.js +181 -7
- package/dist/src/lib/swift-codegen/generator.js.map +1 -1
- package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +7 -3
- package/dist/src/lib/swift-codegen/siblingSymbols.js +4 -1
- package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -1
- package/dist/src/lib/sync-dir-selector.d.ts +21 -0
- package/dist/src/lib/sync-dir-selector.js +30 -0
- package/dist/src/lib/sync-dir-selector.js.map +1 -0
- package/dist/src/lib/sync-paths.d.ts +39 -0
- package/dist/src/lib/sync-paths.js +70 -2
- package/dist/src/lib/sync-paths.js.map +1 -1
- package/dist/src/lib/sync-resource-types.d.ts +138 -31
- package/dist/src/lib/sync-resource-types.js +241 -47
- package/dist/src/lib/sync-resource-types.js.map +1 -1
- package/dist/src/lib/sync-selectors.d.ts +95 -0
- package/dist/src/lib/sync-selectors.js +228 -0
- package/dist/src/lib/sync-selectors.js.map +1 -0
- package/dist/src/lib/template.d.ts +62 -4
- package/dist/src/lib/template.js +147 -39
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/test-case-keys.d.ts +29 -0
- package/dist/src/lib/test-case-keys.js +55 -0
- package/dist/src/lib/test-case-keys.js.map +1 -0
- package/dist/src/lib/test-case-variables.d.ts +15 -0
- package/dist/src/lib/test-case-variables.js +29 -0
- package/dist/src/lib/test-case-variables.js.map +1 -0
- package/dist/src/lib/toml-database-config.d.ts +4 -4
- package/dist/src/lib/toml-database-config.js +27 -34
- package/dist/src/lib/toml-database-config.js.map +1 -1
- package/dist/src/lib/toml-metadata-config.d.ts +9 -5
- package/dist/src/lib/toml-metadata-config.js +40 -45
- package/dist/src/lib/toml-metadata-config.js.map +1 -1
- package/dist/src/lib/toml-native-form.d.ts +1 -1
- package/dist/src/lib/toml-native-form.js +1 -1
- package/dist/src/lib/toml-params-validator.d.ts +1 -1
- package/dist/src/lib/toml-params-validator.js +1 -1
- package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
- package/dist/src/lib/toml-scalar-edit.js +283 -0
- package/dist/src/lib/toml-scalar-edit.js.map +1 -0
- package/dist/src/lib/user-selector.d.ts +24 -0
- package/dist/src/lib/user-selector.js +33 -0
- package/dist/src/lib/user-selector.js.map +1 -0
- package/dist/src/lib/version-check.d.ts +25 -0
- package/dist/src/lib/version-check.js +77 -8
- package/dist/src/lib/version-check.js.map +1 -1
- package/dist/src/lib/watch.d.ts +121 -0
- package/dist/src/lib/watch.js +169 -0
- package/dist/src/lib/watch.js.map +1 -0
- package/dist/src/lib/workflow-apply.d.ts +69 -45
- package/dist/src/lib/workflow-apply.js +99 -72
- package/dist/src/lib/workflow-apply.js.map +1 -1
- package/dist/src/lib/workflow-codegen/generator.js +4 -4
- package/dist/src/lib/workflow-codegen/generator.js.map +1 -1
- package/dist/src/lib/workflow-codegen/invokerIR.d.ts +11 -0
- package/dist/src/lib/workflow-codegen/invokerIR.js +5 -0
- package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -1
- package/dist/src/lib/workflow-config-apply.d.ts +70 -0
- package/dist/src/lib/workflow-config-apply.js +137 -0
- package/dist/src/lib/workflow-config-apply.js.map +1 -0
- package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
- package/dist/src/lib/workflow-config-sidecar.js +96 -0
- package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
- package/dist/src/lib/workflow-defaults.d.ts +29 -0
- package/dist/src/lib/workflow-defaults.js +41 -0
- package/dist/src/lib/workflow-defaults.js.map +1 -0
- package/dist/src/lib/workflow-include-preserve.d.ts +76 -0
- package/dist/src/lib/workflow-include-preserve.js +286 -0
- package/dist/src/lib/workflow-include-preserve.js.map +1 -0
- package/dist/src/lib/workflow-payload.d.ts +31 -20
- package/dist/src/lib/workflow-payload.js +100 -110
- package/dist/src/lib/workflow-payload.js.map +1 -1
- package/dist/src/lib/workflow-toml-validator.d.ts +37 -16
- package/dist/src/lib/workflow-toml-validator.js +141 -16
- package/dist/src/lib/workflow-toml-validator.js.map +1 -1
- package/dist/src/types/index.d.ts +78 -22
- package/dist/src/validators.d.ts +7 -7
- package/dist/src/validators.js +6 -6
- package/package.json +11 -6
- package/dist/src/commands/settings.d.ts +0 -15
- package/dist/src/commands/settings.js +0 -102
- package/dist/src/commands/settings.js.map +0 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `primitive config` — the whole TOML configuration tree (issues #2645, #2759).
|
|
3
|
+
*
|
|
4
|
+
* #2645 replaced the eleven config-setting flags with three local verbs:
|
|
5
|
+
* `fields` documents the surface that per-flag `--help` used to, `create`
|
|
6
|
+
* scaffolds an object, and `set` edits one key from a script. It put them under
|
|
7
|
+
* `config` rather than under `sync` because none of them touches the network.
|
|
8
|
+
*
|
|
9
|
+
* #2759 removed the other side of that line. Splitting by "does this call the
|
|
10
|
+
* API?" is a transport distinction, not one users think in: authoring was
|
|
11
|
+
* `config` and applying was `sync`, so every real workflow crossed the boundary
|
|
12
|
+
* and this group's own help had to end its example sequence by switching nouns.
|
|
13
|
+
* `config` now carries the reconciliation verbs too (`init`, `pull`, `push`,
|
|
14
|
+
* `diff`, `revert`, `migrate-toml`, `migrate-v2`), registered onto the group
|
|
15
|
+
* returned below by `registerConfigSyncCommands` in `sync.ts` — that module
|
|
16
|
+
* keeps its name and exports; only where its verbs hang changed.
|
|
17
|
+
*
|
|
18
|
+
* The split that remains is the one users do think in: the per-surface groups
|
|
19
|
+
* (`workflows`, `webhooks`, …) read and operate on live objects, `config` owns
|
|
20
|
+
* the files that define them.
|
|
21
|
+
*/
|
|
22
|
+
import { Command } from "commander";
|
|
23
|
+
import { type ConfigObjectDescriptor } from "../lib/config-object-descriptor.js";
|
|
24
|
+
/**
|
|
25
|
+
* Why `value` cannot be what `path` declares, or `null` when it can.
|
|
26
|
+
*
|
|
27
|
+
* `config set` used to check only that a path was DECLARED, so
|
|
28
|
+
* `integration.timeoutMs=fast` wrote a string into a number field and the
|
|
29
|
+
* mistake surfaced as a server error on the next push. The descriptor exists to
|
|
30
|
+
* carry what per-flag `--help` used to carry (criterion 7), and that has to
|
|
31
|
+
* include the type — otherwise removing the flags traded a fast local error for
|
|
32
|
+
* a slow remote one.
|
|
33
|
+
*
|
|
34
|
+
* Deliberately silent about anything it cannot judge: an undeclared path (the
|
|
35
|
+
* declared-path check owns that message — two errors for one mistake is worse
|
|
36
|
+
* than one), the interior of a `table` / `table[]` / `json` field, and a var
|
|
37
|
+
* file's own keys. Those shapes belong to the server, and mirroring them here
|
|
38
|
+
* would be a second copy that goes stale.
|
|
39
|
+
*/
|
|
40
|
+
export declare function fieldTypeMismatch(descriptor: ConfigObjectDescriptor, path: string, value: string | number | boolean): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Register the `config` group and its local authoring verbs, and return the
|
|
43
|
+
* group so `registerConfigSyncCommands` can hang the server-reconciling verbs
|
|
44
|
+
* off the same noun (issue #2759).
|
|
45
|
+
*/
|
|
46
|
+
export declare function registerConfigCommands(program: Command): Command;
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `primitive config` — the whole TOML configuration tree (issues #2645, #2759).
|
|
3
|
+
*
|
|
4
|
+
* #2645 replaced the eleven config-setting flags with three local verbs:
|
|
5
|
+
* `fields` documents the surface that per-flag `--help` used to, `create`
|
|
6
|
+
* scaffolds an object, and `set` edits one key from a script. It put them under
|
|
7
|
+
* `config` rather than under `sync` because none of them touches the network.
|
|
8
|
+
*
|
|
9
|
+
* #2759 removed the other side of that line. Splitting by "does this call the
|
|
10
|
+
* API?" is a transport distinction, not one users think in: authoring was
|
|
11
|
+
* `config` and applying was `sync`, so every real workflow crossed the boundary
|
|
12
|
+
* and this group's own help had to end its example sequence by switching nouns.
|
|
13
|
+
* `config` now carries the reconciliation verbs too (`init`, `pull`, `push`,
|
|
14
|
+
* `diff`, `revert`, `migrate-toml`, `migrate-v2`), registered onto the group
|
|
15
|
+
* returned below by `registerConfigSyncCommands` in `sync.ts` — that module
|
|
16
|
+
* keeps its name and exports; only where its verbs hang changed.
|
|
17
|
+
*
|
|
18
|
+
* The split that remains is the one users do think in: the per-surface groups
|
|
19
|
+
* (`workflows`, `webhooks`, …) read and operate on live objects, `config` owns
|
|
20
|
+
* the files that define them.
|
|
21
|
+
*/
|
|
22
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
23
|
+
import { join, basename } from "path";
|
|
24
|
+
import chalk from "chalk";
|
|
25
|
+
import { resolveAppId } from "../lib/config.js";
|
|
26
|
+
import { resolveSyncDir, isAutoResolvedSyncDir } from "../lib/sync-paths.js";
|
|
27
|
+
import { CONFIG_OBJECT_DESCRIPTORS, getConfigObjectDescriptor, } from "../lib/config-object-descriptor.js";
|
|
28
|
+
import { PUSH_PRUNE_SPECS, isSafeSyncFilename, } from "../lib/sync-resource-types.js";
|
|
29
|
+
import { configAuthoringError } from "../lib/platform-owned.js";
|
|
30
|
+
import { filesDeclaringKey } from "../lib/sync-selectors.js";
|
|
31
|
+
import { setTomlScalar, parseScalarLiteral, TomlEditError, } from "../lib/toml-scalar-edit.js";
|
|
32
|
+
import { success, error, info, keyValue, divider, json } from "../lib/output.js";
|
|
33
|
+
function ensureDir(dirPath) {
|
|
34
|
+
if (!existsSync(dirPath)) {
|
|
35
|
+
mkdirSync(dirPath, { recursive: true });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The config slot for a LOCAL command (issue #2645).
|
|
40
|
+
*
|
|
41
|
+
* `config create`, `config set` and `config fields` never call the API, so an
|
|
42
|
+
* explicit `--dir` is enough on its own — resolving an app id first would make
|
|
43
|
+
* them require a login they do not need. Without `--dir` they fall back to the
|
|
44
|
+
* same per-environment slot every other `config` command uses.
|
|
45
|
+
*/
|
|
46
|
+
function resolveLocalSyncDir(appId, options) {
|
|
47
|
+
if (options.dir)
|
|
48
|
+
return options.dir;
|
|
49
|
+
// Outside a project there is no per-app slot: `resolveSyncDir` answers
|
|
50
|
+
// `./config` whatever the app id is. Resolving one anyway would exit these
|
|
51
|
+
// commands with "No app specified" for want of a login they never use — and
|
|
52
|
+
// scaffolding a file before you have an app is exactly the order the
|
|
53
|
+
// TOML-only path asks for (`config create`, edit, `config push`).
|
|
54
|
+
if (!isAutoResolvedSyncDir(undefined)) {
|
|
55
|
+
return resolveSyncDir({ appId: "", userDir: undefined });
|
|
56
|
+
}
|
|
57
|
+
const resolvedAppId = resolveAppId(appId, options);
|
|
58
|
+
const configDir = resolveSyncDir({ appId: resolvedAppId, userDir: undefined });
|
|
59
|
+
info(`Using per-environment config directory: ${configDir}`);
|
|
60
|
+
return configDir;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The `--only` selector key for a file — the key `config push` itself derives.
|
|
64
|
+
*
|
|
65
|
+
* Not always the file name: a metadata-category config lives at
|
|
66
|
+
* `<resourceType>.<category>.toml` but is keyed by the `resourceType#category`
|
|
67
|
+
* pair, so telling the user to push `--only metadata-category-config/<basename>`
|
|
68
|
+
* would print a command that resolves to nothing.
|
|
69
|
+
*/
|
|
70
|
+
function pushSelectorKey(descriptor, filePath) {
|
|
71
|
+
const spec = PUSH_PRUNE_SPECS.find((s) => s.resourceType.label === descriptor.type);
|
|
72
|
+
return spec ? spec.keyFromFile(filePath) : basename(filePath, ".toml");
|
|
73
|
+
}
|
|
74
|
+
/** Every configurable type name, for an error message. */
|
|
75
|
+
function configTypeList() {
|
|
76
|
+
return CONFIG_OBJECT_DESCRIPTORS.map((d) => d.type).join(", ");
|
|
77
|
+
}
|
|
78
|
+
function requireConfigDescriptor(type) {
|
|
79
|
+
const descriptor = getConfigObjectDescriptor(type);
|
|
80
|
+
if (!descriptor) {
|
|
81
|
+
error(`Unknown configuration type '${type}'. Configurable types: ${configTypeList()}`);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
return descriptor;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Whether `path` names something the type declares.
|
|
88
|
+
*
|
|
89
|
+
* An exact field match is obvious. A declared `table` / `table[]` / `json`
|
|
90
|
+
* field also covers everything BELOW it — `requestConfig.method`,
|
|
91
|
+
* `verification.jwt.header`, `vars.API_BASE_URL` — because those subtrees are
|
|
92
|
+
* free-form by design and enumerating them would be a second, always-stale
|
|
93
|
+
* copy of the server's shape.
|
|
94
|
+
*/
|
|
95
|
+
function isDeclaredFieldPath(descriptor, path) {
|
|
96
|
+
// `vars.toml` is a flat table of the app's own keys — every root-level key is
|
|
97
|
+
// legitimate, and the key format is validated by the push preflight.
|
|
98
|
+
if (descriptor.freeFormRootKeys && !path.includes("."))
|
|
99
|
+
return true;
|
|
100
|
+
for (const field of descriptor.fields) {
|
|
101
|
+
if (field.path === path)
|
|
102
|
+
return true;
|
|
103
|
+
if ((field.type === "table" || field.type === "table[]" || field.type === "json") &&
|
|
104
|
+
path.startsWith(`${field.path}.`)) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Why `value` cannot be what `path` declares, or `null` when it can.
|
|
112
|
+
*
|
|
113
|
+
* `config set` used to check only that a path was DECLARED, so
|
|
114
|
+
* `integration.timeoutMs=fast` wrote a string into a number field and the
|
|
115
|
+
* mistake surfaced as a server error on the next push. The descriptor exists to
|
|
116
|
+
* carry what per-flag `--help` used to carry (criterion 7), and that has to
|
|
117
|
+
* include the type — otherwise removing the flags traded a fast local error for
|
|
118
|
+
* a slow remote one.
|
|
119
|
+
*
|
|
120
|
+
* Deliberately silent about anything it cannot judge: an undeclared path (the
|
|
121
|
+
* declared-path check owns that message — two errors for one mistake is worse
|
|
122
|
+
* than one), the interior of a `table` / `table[]` / `json` field, and a var
|
|
123
|
+
* file's own keys. Those shapes belong to the server, and mirroring them here
|
|
124
|
+
* would be a second copy that goes stale.
|
|
125
|
+
*/
|
|
126
|
+
export function fieldTypeMismatch(descriptor, path, value) {
|
|
127
|
+
const field = descriptor.fields.find((f) => f.path === path);
|
|
128
|
+
if (!field)
|
|
129
|
+
return null;
|
|
130
|
+
const expected = field.type === "number" || field.type === "boolean" || field.type === "string"
|
|
131
|
+
? field.type
|
|
132
|
+
: null;
|
|
133
|
+
if (!expected || typeof value === expected)
|
|
134
|
+
return null;
|
|
135
|
+
return (`'${path}' is declared ${expected}, but '${value}' is a ${typeof value}. ` +
|
|
136
|
+
`Run 'primitive config fields ${descriptor.type}' to see the surface.`);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Resolve a `config set` target to the file it edits.
|
|
140
|
+
*
|
|
141
|
+
* Accepts `<type>/<key>` for the 13 per-entity types, plus the two root
|
|
142
|
+
* singletons by name: `app` (`app.toml`) and `vars` (`vars.toml`, whose keys
|
|
143
|
+
* are addressed as `vars.<KEY>`).
|
|
144
|
+
*
|
|
145
|
+
* The key is resolved the way `config push --only` resolves it — by the identity
|
|
146
|
+
* the local files DECLARE, falling back to the conventional file name when no
|
|
147
|
+
* file declares it. `config set` and the push that follows it have to agree about
|
|
148
|
+
* which object `<type>/<key>` is; resolving by file name alone meant a renamed
|
|
149
|
+
* file (`custom.toml` declaring `workflow.key = "greeting"`) could not be
|
|
150
|
+
* edited as `workflow/greeting` at all, while `workflow/custom` edited a file
|
|
151
|
+
* push would apply under a different key (issue #2645, review follow-up).
|
|
152
|
+
*/
|
|
153
|
+
function resolveSetTarget(selector, configDir) {
|
|
154
|
+
if (selector === "app") {
|
|
155
|
+
return {
|
|
156
|
+
descriptor: requireConfigDescriptor("app"),
|
|
157
|
+
filePath: join(configDir, "app.toml"),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (selector === "vars" || selector === "var") {
|
|
161
|
+
return {
|
|
162
|
+
descriptor: requireConfigDescriptor("var"),
|
|
163
|
+
filePath: join(configDir, "vars.toml"),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const slash = selector.indexOf("/");
|
|
167
|
+
if (slash === -1) {
|
|
168
|
+
error(`'${selector}' is not a configuration object. Use <type>/<key>, app, or vars. Types: ${configTypeList()}`);
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
171
|
+
const type = selector.slice(0, slash);
|
|
172
|
+
const key = selector.slice(slash + 1);
|
|
173
|
+
const descriptor = requireConfigDescriptor(type);
|
|
174
|
+
if (!descriptor.resourceType) {
|
|
175
|
+
error(`'${type}' is a single file — use '${type === "app" ? "app" : "vars"}' with no key`);
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
178
|
+
if (!key) {
|
|
179
|
+
error(`'${selector}': name the object, e.g. ${type}/<key>`);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
const refusal = configAuthoringError(type, key);
|
|
183
|
+
if (refusal) {
|
|
184
|
+
error(refusal);
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
const filename = descriptor.resourceType.fileFromKey(key);
|
|
188
|
+
// The key is a command-line argument, so it must never be able to steer the
|
|
189
|
+
// edit out of the type's directory — `workflow/../app` would otherwise let
|
|
190
|
+
// `config set` rewrite a file the operator did not name. Same guard `config create`
|
|
191
|
+
// applies before a write and prune applies before an unlink. Checked before
|
|
192
|
+
// the directory scan below so a traversing key never reaches the filesystem.
|
|
193
|
+
if (!isSafeSyncFilename(filename)) {
|
|
194
|
+
error(`'${key}' is not a usable key — it would edit outside ${descriptor.resourceType.dir}/.`);
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
const declaring = filesDeclaringKey(configDir, descriptor.type, key);
|
|
198
|
+
if (declaring.length > 1) {
|
|
199
|
+
error(`'${selector}' is declared by ${declaring.length} files (${declaring
|
|
200
|
+
.map((p) => basename(p))
|
|
201
|
+
.join(", ")}) — one key, one file. Remove or re-key the duplicates, then retry.`);
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
// No local file declares the key: fall back to the conventional path, so the
|
|
205
|
+
// "no local file at …" error names where `config pull` / `config create` would put it.
|
|
206
|
+
const filePath = declaring[0] ?? join(configDir, descriptor.resourceType.dir, filename);
|
|
207
|
+
// A file may declare a key other than its name, including a platform-owned
|
|
208
|
+
// one. Push skips those (#1660), so editing one is an edit that can never be
|
|
209
|
+
// applied — refuse it by the key the file DECLARES, not only by the one the
|
|
210
|
+
// operator typed.
|
|
211
|
+
const declaredKey = pushSelectorKey(descriptor, filePath);
|
|
212
|
+
const declaredRefusal = declaredKey === key
|
|
213
|
+
? null
|
|
214
|
+
: configAuthoringError(descriptor.type, declaredKey);
|
|
215
|
+
if (declaredRefusal) {
|
|
216
|
+
error(declaredRefusal);
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
return { descriptor, filePath };
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Register the `config` group and its local authoring verbs, and return the
|
|
223
|
+
* group so `registerConfigSyncCommands` can hang the server-reconciling verbs
|
|
224
|
+
* off the same noun (issue #2759).
|
|
225
|
+
*/
|
|
226
|
+
export function registerConfigCommands(program) {
|
|
227
|
+
const config = program
|
|
228
|
+
.command("config")
|
|
229
|
+
.description("Manage app configuration as TOML files — author locally, then pull/diff/push against the server")
|
|
230
|
+
.addHelpText("after", `
|
|
231
|
+
Configuration is authored in TOML and applied with 'primitive config push'.
|
|
232
|
+
'fields', 'create' and 'set' only read and write local files — nothing there
|
|
233
|
+
contacts the server, so they work before you have an app, and a script can edit
|
|
234
|
+
a file without a login. 'init', 'pull', 'push', 'diff' and 'revert' reconcile
|
|
235
|
+
those files with the server.
|
|
236
|
+
|
|
237
|
+
Examples:
|
|
238
|
+
$ primitive config fields workflow
|
|
239
|
+
$ primitive config create workflow order-intake
|
|
240
|
+
$ primitive config set workflow/order-intake workflow.description="Intake"
|
|
241
|
+
$ primitive config push --only workflow/order-intake
|
|
242
|
+
|
|
243
|
+
Availability is not configuration: a workflow's status is server-owned, so it
|
|
244
|
+
is not a settable key here. Take one out of service with
|
|
245
|
+
'primitive workflows disable' (and back with 'enable').
|
|
246
|
+
|
|
247
|
+
Directory Structure:
|
|
248
|
+
config/
|
|
249
|
+
.primitive-sync.json # Sync state (auto-managed)
|
|
250
|
+
app.toml # App settings
|
|
251
|
+
integrations/*.toml # Integration configs
|
|
252
|
+
integrations/{key}.tests/*.toml # Integration test cases
|
|
253
|
+
webhooks/*.toml # Webhook configs
|
|
254
|
+
cron-triggers/*.toml # Cron trigger configs
|
|
255
|
+
blob-buckets/*.toml # Blob bucket configs
|
|
256
|
+
prompts/*.toml # Prompt configs
|
|
257
|
+
prompts/{key}.tests/*.toml # Prompt test cases
|
|
258
|
+
workflows/*.toml # Workflow definitions
|
|
259
|
+
workflows/{key}.tests/*.toml # Workflow test cases
|
|
260
|
+
transforms/*.rhai # Rhai transform bodies
|
|
261
|
+
transforms/{name}.tests/*.toml # Transform test cases
|
|
262
|
+
database-type-configs/*.toml # Database type configs + operations
|
|
263
|
+
rule-sets/*.toml # Access rule sets
|
|
264
|
+
group-type-configs/*.toml # Group type configs
|
|
265
|
+
collection-type-configs/*.toml # Collection type configs
|
|
266
|
+
metadata-category-configs/*.toml # Resource-metadata category configs
|
|
267
|
+
email-templates/*.toml # Email template overrides
|
|
268
|
+
`);
|
|
269
|
+
// ── The TOML authoring surface (issue #2645) ─────────────────────────────
|
|
270
|
+
//
|
|
271
|
+
// Server-side configuration is authored in TOML and applied with
|
|
272
|
+
// `config push`. These three commands are what replaced the config-setting
|
|
273
|
+
// flags: `fields` documents the surface that per-flag `--help` used to,
|
|
274
|
+
// `create` scaffolds an object without an API call, and `set` edits one key
|
|
275
|
+
// from a script. None of them touches the network.
|
|
276
|
+
config
|
|
277
|
+
.command("fields")
|
|
278
|
+
.description("List a configuration type's TOML keys, types, required and default")
|
|
279
|
+
.argument("<type>", `Configuration type (${CONFIG_OBJECT_DESCRIPTORS.length} available)`)
|
|
280
|
+
.option("--json", "Output as JSON")
|
|
281
|
+
.addHelpText("after", `
|
|
282
|
+
Types:
|
|
283
|
+
${CONFIG_OBJECT_DESCRIPTORS.map((d) => `${d.type} — ${d.description}`).join("\n ")}
|
|
284
|
+
|
|
285
|
+
Examples:
|
|
286
|
+
$ primitive config fields workflow
|
|
287
|
+
$ primitive config fields webhook --json
|
|
288
|
+
`)
|
|
289
|
+
.action(async (type, options) => {
|
|
290
|
+
const descriptor = requireConfigDescriptor(type);
|
|
291
|
+
const asJson = (f) => ({
|
|
292
|
+
path: f.path,
|
|
293
|
+
type: f.type,
|
|
294
|
+
required: f.required,
|
|
295
|
+
default: f.default ?? null,
|
|
296
|
+
description: f.description,
|
|
297
|
+
});
|
|
298
|
+
if (options.json) {
|
|
299
|
+
json({
|
|
300
|
+
type: descriptor.type,
|
|
301
|
+
file: descriptor.fileHint,
|
|
302
|
+
description: descriptor.description,
|
|
303
|
+
identity: descriptor.identity ?? null,
|
|
304
|
+
fields: descriptor.fields.map(asJson),
|
|
305
|
+
// A type authored across more than one file reports the other files
|
|
306
|
+
// too — the workflow's named-config sidecars are the whole of what
|
|
307
|
+
// the removed `workflows configs` verbs used to set (issue #2645).
|
|
308
|
+
companionFiles: (descriptor.companionFiles ?? []).map((companion) => ({
|
|
309
|
+
file: companion.fileHint,
|
|
310
|
+
description: companion.description,
|
|
311
|
+
fields: companion.fields.map(asJson),
|
|
312
|
+
})),
|
|
313
|
+
});
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
keyValue("Type", descriptor.type);
|
|
317
|
+
keyValue("File", descriptor.fileHint);
|
|
318
|
+
keyValue("About", descriptor.description);
|
|
319
|
+
divider();
|
|
320
|
+
if (descriptor.freeFormRootKeys) {
|
|
321
|
+
info(`${descriptor.fileHint} is a flat table of your own keys — KEY = "value" at the root, matching ^[A-Z][A-Z0-9_]{0,63}$. There is no fixed field surface.`);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (descriptor.fields.length === 0) {
|
|
325
|
+
info(`${descriptor.fileHint} is a script body, not a table of keys — there is no field surface to list.`);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const printField = (field) => {
|
|
329
|
+
const flags = [
|
|
330
|
+
field.required ? "required" : "optional",
|
|
331
|
+
field.default === undefined ? null : `default ${JSON.stringify(field.default)}`,
|
|
332
|
+
]
|
|
333
|
+
.filter(Boolean)
|
|
334
|
+
.join(", ");
|
|
335
|
+
console.log(` ${chalk.cyan(field.path)} ${chalk.dim(field.type)} ${chalk.dim(`(${flags})`)}`);
|
|
336
|
+
console.log(` ${field.description}`);
|
|
337
|
+
};
|
|
338
|
+
for (const field of descriptor.fields) {
|
|
339
|
+
printField(field);
|
|
340
|
+
}
|
|
341
|
+
// The rest of the object's surface, where it spans more than one file.
|
|
342
|
+
// `config set` addresses the main file only, so these are listed rather
|
|
343
|
+
// than folded in — but leaving them out would under-report exactly what
|
|
344
|
+
// the removed `workflows configs` flags used to document (issue #2645).
|
|
345
|
+
for (const companion of descriptor.companionFiles ?? []) {
|
|
346
|
+
divider();
|
|
347
|
+
keyValue("File", companion.fileHint);
|
|
348
|
+
info(companion.description);
|
|
349
|
+
for (const field of companion.fields) {
|
|
350
|
+
printField(field);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
divider();
|
|
354
|
+
info(`Edit ${descriptor.fileHint}, then run 'primitive config push'.`);
|
|
355
|
+
});
|
|
356
|
+
config
|
|
357
|
+
.command("create")
|
|
358
|
+
.description("Scaffold a configuration file locally (no API call)")
|
|
359
|
+
.argument("<type>", "Configuration type — see 'primitive config fields'")
|
|
360
|
+
.argument("<key>", "The object's key; it becomes the file name")
|
|
361
|
+
.option("--app <app-id>", "App ID")
|
|
362
|
+
.option("--dir <path>", "Config directory (overrides the auto-resolved per-env path)")
|
|
363
|
+
.addHelpText("after", `
|
|
364
|
+
Creates the file from the type's defaults and stops there — nothing is sent to
|
|
365
|
+
the server until you edit the file and run 'primitive config push'.
|
|
366
|
+
|
|
367
|
+
Examples:
|
|
368
|
+
$ primitive config create workflow order-intake
|
|
369
|
+
$ primitive config create webhook stripe-events
|
|
370
|
+
$ primitive config push --only workflow/order-intake
|
|
371
|
+
`)
|
|
372
|
+
.action(async (type, key, options) => {
|
|
373
|
+
const descriptor = requireConfigDescriptor(type);
|
|
374
|
+
if (!descriptor.resourceType) {
|
|
375
|
+
error(`${descriptor.type} is a root singleton (${descriptor.fileHint}) — it is not created per key. Run 'primitive config pull' to write it.`);
|
|
376
|
+
process.exit(1);
|
|
377
|
+
}
|
|
378
|
+
const refusal = configAuthoringError(descriptor.type, key);
|
|
379
|
+
if (refusal) {
|
|
380
|
+
error(refusal);
|
|
381
|
+
process.exit(1);
|
|
382
|
+
}
|
|
383
|
+
const configDir = resolveLocalSyncDir(undefined, options);
|
|
384
|
+
const dir = join(configDir, descriptor.resourceType.dir);
|
|
385
|
+
const filename = descriptor.resourceType.fileFromKey(key);
|
|
386
|
+
// The key comes from the command line, so it must never be able to steer
|
|
387
|
+
// a write out of the slot — the same guard the prune path applies before
|
|
388
|
+
// an unlink.
|
|
389
|
+
if (!isSafeSyncFilename(filename)) {
|
|
390
|
+
error(`'${key}' is not a usable key — it would write outside ${dir}.`);
|
|
391
|
+
process.exit(1);
|
|
392
|
+
}
|
|
393
|
+
const filePath = join(dir, filename);
|
|
394
|
+
if (existsSync(filePath)) {
|
|
395
|
+
error(`${descriptor.resourceType.dir}/${descriptor.resourceType.fileFromKey(key)} already exists — edit it, or pick another key.`);
|
|
396
|
+
process.exit(1);
|
|
397
|
+
}
|
|
398
|
+
ensureDir(dir);
|
|
399
|
+
writeFileSync(filePath, descriptor.scaffold(key));
|
|
400
|
+
success(`Created ${filePath}`);
|
|
401
|
+
info(`Next: edit it, then 'primitive config push --only ${descriptor.type}/${pushSelectorKey(descriptor, filePath)}'.`);
|
|
402
|
+
});
|
|
403
|
+
config
|
|
404
|
+
.command("set")
|
|
405
|
+
.description("Set a field in a configuration file locally (no API call)")
|
|
406
|
+
.argument("<object>", "<type>/<key>, app, or vars")
|
|
407
|
+
.argument("<assignments...>", "One or more <path>=<value>, e.g. workflow.description=\"Intake\"")
|
|
408
|
+
.option("--app <app-id>", "App ID")
|
|
409
|
+
.option("--dir <path>", "Config directory (overrides the auto-resolved per-env path)")
|
|
410
|
+
.addHelpText("after", `
|
|
411
|
+
Edits the file in place, preserving comments and key order, and writes nothing
|
|
412
|
+
to the server. Only scalars are settable — a table or an array is edited in the
|
|
413
|
+
file directly.
|
|
414
|
+
|
|
415
|
+
'true'/'false' and numeric values are written with those types; wrap a value in
|
|
416
|
+
double quotes to force a string.
|
|
417
|
+
|
|
418
|
+
Examples:
|
|
419
|
+
$ primitive config set workflow/order-intake workflow.description="Intake"
|
|
420
|
+
$ primitive config push --only workflow/order-intake
|
|
421
|
+
|
|
422
|
+
A server-owned key such as status is not settable: availability is changed
|
|
423
|
+
with 'primitive <noun> enable|disable', never through a file.
|
|
424
|
+
`)
|
|
425
|
+
.action(async (object, assignments, options) => {
|
|
426
|
+
const configDir = resolveLocalSyncDir(undefined, options);
|
|
427
|
+
const { descriptor, filePath } = resolveSetTarget(object, configDir);
|
|
428
|
+
if (!existsSync(filePath)) {
|
|
429
|
+
error(`No local file at ${filePath}. Run 'primitive config pull' to fetch it, or 'primitive config create ${descriptor.type} <key>' to create one.`);
|
|
430
|
+
process.exit(1);
|
|
431
|
+
}
|
|
432
|
+
let text = readFileSync(filePath, "utf-8");
|
|
433
|
+
const applied = [];
|
|
434
|
+
for (const assignment of assignments) {
|
|
435
|
+
const eq = assignment.indexOf("=");
|
|
436
|
+
if (eq <= 0) {
|
|
437
|
+
error(`'${assignment}' is not <path>=<value>, e.g. workflow.name="Order intake"`);
|
|
438
|
+
process.exit(1);
|
|
439
|
+
}
|
|
440
|
+
const path = assignment.slice(0, eq).trim();
|
|
441
|
+
const raw = assignment.slice(eq + 1);
|
|
442
|
+
if (!isDeclaredFieldPath(descriptor, path)) {
|
|
443
|
+
error(`'${path}' is not a ${descriptor.type} field. Run 'primitive config fields ${descriptor.type}' to see the surface.`);
|
|
444
|
+
process.exit(1);
|
|
445
|
+
}
|
|
446
|
+
const value = parseScalarLiteral(raw);
|
|
447
|
+
const typeError = fieldTypeMismatch(descriptor, path, value);
|
|
448
|
+
if (typeError) {
|
|
449
|
+
error(typeError);
|
|
450
|
+
process.exit(1);
|
|
451
|
+
}
|
|
452
|
+
try {
|
|
453
|
+
text = setTomlScalar(text, path, value);
|
|
454
|
+
}
|
|
455
|
+
catch (e) {
|
|
456
|
+
if (e instanceof TomlEditError) {
|
|
457
|
+
error(`${filePath}: ${e.message}`);
|
|
458
|
+
process.exit(1);
|
|
459
|
+
}
|
|
460
|
+
throw e;
|
|
461
|
+
}
|
|
462
|
+
applied.push(path);
|
|
463
|
+
}
|
|
464
|
+
writeFileSync(filePath, text);
|
|
465
|
+
success(`Updated ${filePath} (${applied.join(", ")})`);
|
|
466
|
+
// The follow-up has to be a command that actually runs: `--only` takes
|
|
467
|
+
// `app`, `var/<KEY>` per var, or `<type>/<key>` where the key is the one
|
|
468
|
+
// push derives from the file — for a metadata-category config that is the
|
|
469
|
+
// `resourceType#category` pair, not the file name.
|
|
470
|
+
const pushTargets = descriptor.type === "app"
|
|
471
|
+
? ["app"]
|
|
472
|
+
: descriptor.type === "var"
|
|
473
|
+
? applied.map((path) => `var/${path}`)
|
|
474
|
+
: [`${descriptor.type}/${pushSelectorKey(descriptor, filePath)}`];
|
|
475
|
+
info(`Next: 'primitive config push --only ${pushTargets.join(",")}' to apply it.`);
|
|
476
|
+
});
|
|
477
|
+
return config;
|
|
478
|
+
}
|
|
479
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAE1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,k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,CAAC,GAAG,CAAC,CAAC;QACvD,uEAAuE;QACvE,yEAAyE;QACzE,0EAA0E;QAC1E,mDAAmD;QACnD,MAAM,WAAW,GACf,UAAU,CAAC,IAAI,KAAK,KAAK;YACvB,CAAC,CAAC,CAAC,KAAK,CAAC;YACT,CAAC,CAAC,UAAU,CAAC,IAAI,KAAK,KAAK;gBACzB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC;gBACtC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,IAAI,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;QACxE,IAAI,CACF,uCAAuC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAC7E,CAAC;IACJ,CAAC,CAAC,CAAC;IAEL,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Option } from "commander";
|
|
1
2
|
import { ApiClient } from "../lib/api-client.js";
|
|
2
3
|
import { resolveAppId } from "../lib/config.js";
|
|
3
4
|
import { error, info, formatTable, formatDate, json, } from "../lib/output.js";
|
|
5
|
+
import { resolveUserSelector } from "../lib/user-selector.js";
|
|
4
6
|
export function registerConnectionsCommands(program) {
|
|
5
7
|
const connections = program
|
|
6
8
|
.command("connections")
|
|
@@ -15,32 +17,35 @@ user notification channel).
|
|
|
15
17
|
|
|
16
18
|
Examples:
|
|
17
19
|
$ primitive connections list --document 01HXY...
|
|
18
|
-
$ primitive connections list --user 01HXY...
|
|
20
|
+
$ primitive connections list --user-id 01HXY...
|
|
19
21
|
$ primitive connections list --database 01HXY... --limit 50
|
|
20
|
-
$ primitive connections list --user 01HXY... --json
|
|
22
|
+
$ primitive connections list --user-id 01HXY... --json
|
|
21
23
|
`);
|
|
22
24
|
connections
|
|
23
25
|
.command("list")
|
|
24
26
|
.description("List live connections for exactly one of a document, user, or database")
|
|
25
27
|
.option("--app <app-id>", "App ID (uses current app if not specified)")
|
|
26
28
|
.option("--document <document-id>", "List connections for this document")
|
|
27
|
-
.option("--user <user-id>", "List connections for this user")
|
|
29
|
+
.option("--user-id <user-id>", "List connections for this user")
|
|
30
|
+
// Deprecated alias of --user-id, kept accepted but out of --help (#2357).
|
|
31
|
+
.addOption(new Option("--user <user-id>", "Deprecated alias of --user-id").hideHelp())
|
|
28
32
|
.option("--database <database-id>", "List database subscriptions for this database")
|
|
29
33
|
.option("--limit <n>", "Maximum rows to return (default 25, max 100)")
|
|
30
34
|
.option("--cursor <cursor>", "Pagination cursor from a previous page")
|
|
31
35
|
.option("--json", "Output as JSON")
|
|
32
36
|
.action(async (options) => {
|
|
37
|
+
const userId = resolveUserSelector(options, "connections list");
|
|
33
38
|
const selectors = [
|
|
34
39
|
options.document ? "document" : null,
|
|
35
|
-
|
|
40
|
+
userId ? "user" : null,
|
|
36
41
|
options.database ? "database" : null,
|
|
37
42
|
].filter(Boolean);
|
|
38
43
|
if (selectors.length === 0) {
|
|
39
|
-
error("Provide exactly one selector: --document, --user, or --database.");
|
|
44
|
+
error("Provide exactly one selector: --document, --user-id, or --database.");
|
|
40
45
|
process.exit(1);
|
|
41
46
|
}
|
|
42
47
|
if (selectors.length > 1) {
|
|
43
|
-
error("Provide only one selector: --document, --user, or --database (not more than one).");
|
|
48
|
+
error("Provide only one selector: --document, --user-id, or --database (not more than one).");
|
|
44
49
|
process.exit(1);
|
|
45
50
|
}
|
|
46
51
|
const resolvedAppId = resolveAppId(undefined, options);
|
|
@@ -53,7 +58,7 @@ Examples:
|
|
|
53
58
|
try {
|
|
54
59
|
const { items, nextCursor } = await client.listConnections(resolvedAppId, {
|
|
55
60
|
documentId: options.document,
|
|
56
|
-
userId
|
|
61
|
+
userId,
|
|
57
62
|
databaseId: options.database,
|
|
58
63
|
}, { limit, cursor: options.cursor });
|
|
59
64
|
if (options.json) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../../src/commands/connections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../../src/commands/connections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,KAAK,EACL,IAAI,EACJ,WAAW,EACX,UAAU,EACV,IAAI,GACL,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,UAAU,2BAA2B,CAAC,OAAgB;IAC1D,MAAM,WAAW,GAAG,OAAO;SACxB,OAAO,CAAC,aAAa,CAAC;SACtB,WAAW,CAAC,kEAAkE,CAAC;SAC/E,WAAW,CACV,OAAO,EACP;;;;;;;;;;;;;CAaL,CACI,CAAC;IAEJ,WAAW;SACR,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CACV,wEAAwE,CACzE;SACA,MAAM,CAAC,gBAAgB,EAAE,4CAA4C,CAAC;SACtE,MAAM,CAAC,0BAA0B,EAAE,oCAAoC,CAAC;SACxE,MAAM,CAAC,qBAAqB,EAAE,gCAAgC,CAAC;QAChE,0EAA0E;SACzE,SAAS,CAAC,IAAI,MAAM,CAAC,kBAAkB,EAAE,+BAA+B,CAAC,CAAC,QAAQ,EAAE,CAAC;SACrF,MAAM,CAAC,0BAA0B,EAAE,+CAA+C,CAAC;SACnF,MAAM,CAAC,aAAa,EAAE,8CAA8C,CAAC;SACrE,MAAM,CAAC,mBAAmB,EAAE,wCAAwC,CAAC;SACrE,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,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