primitive-admin 1.2.0-alpha.1 → 1.2.0-alpha.11
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 +105 -134
- package/assets/skill/skills/primitive-platform/SKILL.md +37 -4
- package/dist/bin/primitive.js +30 -35
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/agent-sessions.d.ts +133 -0
- package/dist/src/commands/agent-sessions.js +792 -0
- package/dist/src/commands/agent-sessions.js.map +1 -0
- package/dist/src/commands/analytics.js +0 -148
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps-children.d.ts +54 -0
- package/dist/src/commands/apps-children.js +631 -0
- package/dist/src/commands/apps-children.js.map +1 -0
- package/dist/src/commands/apps.d.ts +6 -0
- package/dist/src/commands/apps.js +131 -9
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/auth-sessions.d.ts +3 -3
- package/dist/src/commands/auth-sessions.js +117 -23
- package/dist/src/commands/auth-sessions.js.map +1 -1
- package/dist/src/commands/auth.js +460 -36
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/collections.js +316 -256
- package/dist/src/commands/collections.js.map +1 -1
- package/dist/src/commands/config.d.ts +1 -1
- package/dist/src/commands/config.js +60 -28
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/connections.js +11 -12
- package/dist/src/commands/connections.js.map +1 -1
- package/dist/src/commands/database-type-configs.js +2 -76
- package/dist/src/commands/database-type-configs.js.map +1 -1
- package/dist/src/commands/databases.d.ts +9 -0
- package/dist/src/commands/databases.js +221 -457
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/db3-types.d.ts +15 -0
- package/dist/src/commands/db3-types.js +157 -0
- package/dist/src/commands/db3-types.js.map +1 -0
- package/dist/src/commands/db3.d.ts +12 -0
- package/dist/src/commands/db3.js +1052 -0
- package/dist/src/commands/db3.js.map +1 -0
- package/dist/src/commands/documents.d.ts +121 -2
- package/dist/src/commands/documents.js +1601 -1251
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/env.d.ts +9 -1
- package/dist/src/commands/env.js +164 -49
- package/dist/src/commands/env.js.map +1 -1
- package/dist/src/commands/function-trigger-commands.d.ts +28 -0
- package/dist/src/commands/function-trigger-commands.js +341 -0
- package/dist/src/commands/function-trigger-commands.js.map +1 -0
- package/dist/src/commands/functions.js +297 -24
- package/dist/src/commands/functions.js.map +1 -1
- package/dist/src/commands/groups.js +150 -49
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.js +5 -5
- package/dist/src/commands/init.d.ts +7 -0
- package/dist/src/commands/init.js +23 -5
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.js +14 -8
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/metadata-category-configs.d.ts +2 -2
- package/dist/src/commands/metadata-category-configs.js +2 -2
- package/dist/src/commands/prompts.d.ts +7 -0
- package/dist/src/commands/prompts.js +48 -5
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/scripts.d.ts +9 -17
- package/dist/src/commands/scripts.js +24 -479
- package/dist/src/commands/scripts.js.map +1 -1
- package/dist/src/commands/sync-app-settings.d.ts +36 -8
- package/dist/src/commands/sync-app-settings.js +109 -23
- package/dist/src/commands/sync-app-settings.js.map +1 -1
- package/dist/src/commands/sync.d.ts +360 -610
- package/dist/src/commands/sync.js +3151 -6697
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.js +3 -3
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/users.js +77 -2
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/workflows.d.ts +5 -83
- package/dist/src/commands/workflows.js +57 -2282
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/aggregate-output.d.ts +25 -0
- package/dist/src/lib/aggregate-output.js +53 -0
- package/dist/src/lib/aggregate-output.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +681 -551
- package/dist/src/lib/api-client.js +880 -814
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +47 -1
- package/dist/src/lib/app-settings-descriptor.js +114 -10
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/auth-fixtures.d.ts +44 -0
- package/dist/src/lib/auth-fixtures.js +61 -0
- package/dist/src/lib/auth-fixtures.js.map +1 -0
- package/dist/src/lib/auth-flow.d.ts +41 -1
- package/dist/src/lib/auth-flow.js +70 -16
- package/dist/src/lib/auth-flow.js.map +1 -1
- package/dist/src/lib/block-layout.d.ts +12 -23
- package/dist/src/lib/block-layout.js +26 -92
- package/dist/src/lib/block-layout.js.map +1 -1
- package/dist/src/lib/block-selector.d.ts +2 -2
- package/dist/src/lib/block-selector.js +2 -2
- package/dist/src/lib/child-apps-local.d.ts +164 -0
- package/dist/src/lib/child-apps-local.js +258 -0
- package/dist/src/lib/child-apps-local.js.map +1 -0
- package/dist/src/lib/ci-session-request.d.ts +22 -0
- package/dist/src/lib/ci-session-request.js +51 -0
- package/dist/src/lib/ci-session-request.js.map +1 -0
- package/dist/src/lib/codegen-shared/generatedFiles.d.ts +10 -8
- package/dist/src/lib/codegen-shared/generatedFiles.js +21 -15
- package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -1
- package/dist/src/lib/codegen-shared/prettierStable.d.ts +1 -1
- package/dist/src/lib/codegen-shared/prettierStable.js +1 -1
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +2 -2
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +2 -2
- package/dist/src/lib/collection-export.d.ts +76 -15
- package/dist/src/lib/collection-export.js +116 -23
- package/dist/src/lib/collection-export.js.map +1 -1
- package/dist/src/lib/collection-principal.d.ts +22 -0
- package/dist/src/lib/collection-principal.js +35 -0
- package/dist/src/lib/collection-principal.js.map +1 -0
- package/dist/src/lib/config-object-descriptor.d.ts +3 -22
- package/dist/src/lib/config-object-descriptor.js +56 -290
- package/dist/src/lib/config-object-descriptor.js.map +1 -1
- package/dist/src/lib/config-payload.js +2 -3
- package/dist/src/lib/config-payload.js.map +1 -1
- package/dist/src/lib/config-surface.d.ts +5 -7
- package/dist/src/lib/config-surface.js +18 -40
- package/dist/src/lib/config-surface.js.map +1 -1
- package/dist/src/lib/connections-list.d.ts +10 -0
- package/dist/src/lib/connections-list.js +18 -0
- package/dist/src/lib/connections-list.js.map +1 -0
- package/dist/src/lib/credentials-home.d.ts +58 -0
- package/dist/src/lib/credentials-home.js +204 -0
- package/dist/src/lib/credentials-home.js.map +1 -0
- package/dist/src/lib/credentials-lock.d.ts +88 -0
- package/dist/src/lib/credentials-lock.js +302 -0
- package/dist/src/lib/credentials-lock.js.map +1 -0
- package/dist/src/lib/credentials-store.d.ts +179 -24
- package/dist/src/lib/credentials-store.js +712 -77
- package/dist/src/lib/credentials-store.js.map +1 -1
- package/dist/src/lib/csv.d.ts +8 -9
- package/dist/src/lib/csv.js +3 -4
- package/dist/src/lib/csv.js.map +1 -1
- package/dist/src/lib/custodian.d.ts +8 -0
- package/dist/src/lib/custodian.js +18 -0
- package/dist/src/lib/custodian.js.map +1 -0
- package/dist/src/lib/db-codegen/dbGenerator.js +5 -16
- package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -1
- package/dist/src/lib/db-codegen/dbNaming.d.ts +5 -13
- package/dist/src/lib/db-codegen/dbNaming.js +5 -17
- package/dist/src/lib/db-codegen/dbNaming.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTemplates.d.ts +7 -56
- package/dist/src/lib/db-codegen/dbTemplates.js +25 -125
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +2 -2
- package/dist/src/lib/db-codegen/dbTsTypes.js +2 -2
- package/dist/src/lib/db-codegen/dbTypeIR.d.ts +67 -2
- package/dist/src/lib/db-codegen/dbTypeIR.js +13 -2
- package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
- package/dist/src/lib/db3-export.d.ts +231 -0
- package/dist/src/lib/db3-export.js +510 -0
- package/dist/src/lib/db3-export.js.map +1 -0
- package/dist/src/lib/db3-index-output.d.ts +27 -0
- package/dist/src/lib/db3-index-output.js +49 -0
- package/dist/src/lib/db3-index-output.js.map +1 -0
- package/dist/src/lib/document-export-lookups.d.ts +31 -0
- package/dist/src/lib/document-export-lookups.js +53 -0
- package/dist/src/lib/document-export-lookups.js.map +1 -0
- package/dist/src/lib/document-export-permissions.d.ts +7 -5
- package/dist/src/lib/document-export-permissions.js +7 -5
- package/dist/src/lib/document-export-permissions.js.map +1 -1
- package/dist/src/lib/document-export-record-log.d.ts +57 -0
- package/dist/src/lib/document-export-record-log.js +215 -0
- package/dist/src/lib/document-export-record-log.js.map +1 -0
- package/dist/src/lib/document-ingest-artifact.d.ts +26 -2
- package/dist/src/lib/document-ingest-artifact.js +42 -8
- package/dist/src/lib/document-ingest-artifact.js.map +1 -1
- package/dist/src/lib/document-ingest-format2.d.ts +36 -0
- package/dist/src/lib/document-ingest-format2.js +78 -0
- package/dist/src/lib/document-ingest-format2.js.map +1 -0
- package/dist/src/lib/document-ingest-input.d.ts +9 -0
- package/dist/src/lib/document-ingest-input.js +28 -1
- package/dist/src/lib/document-ingest-input.js.map +1 -1
- package/dist/src/lib/document-ingest-rows.d.ts +16 -0
- package/dist/src/lib/document-ingest-rows.js +17 -0
- package/dist/src/lib/document-ingest-rows.js.map +1 -1
- package/dist/src/lib/document-ingest.d.ts +33 -1
- package/dist/src/lib/document-ingest.js +49 -0
- package/dist/src/lib/document-ingest.js.map +1 -1
- package/dist/src/lib/document-schema-rows.d.ts +42 -0
- package/dist/src/lib/document-schema-rows.js +53 -0
- package/dist/src/lib/document-schema-rows.js.map +1 -0
- package/dist/src/lib/env-resolver-core.d.ts +70 -2
- package/dist/src/lib/env-resolver-core.js +137 -20
- package/dist/src/lib/env-resolver-core.js.map +1 -1
- package/dist/src/lib/env-resolver.d.ts +14 -2
- package/dist/src/lib/env-resolver.js +32 -10
- package/dist/src/lib/env-resolver.js.map +1 -1
- package/dist/src/lib/function-authorize-check.d.ts +142 -0
- package/dist/src/lib/function-authorize-check.js +310 -0
- package/dist/src/lib/function-authorize-check.js.map +1 -0
- package/dist/src/lib/function-authorize-view.d.ts +15 -0
- package/dist/src/lib/function-authorize-view.js +50 -0
- package/dist/src/lib/function-authorize-view.js.map +1 -0
- package/dist/src/lib/function-bundle.d.ts +38 -18
- package/dist/src/lib/function-bundle.js +96 -35
- package/dist/src/lib/function-bundle.js.map +1 -1
- package/dist/src/lib/function-collect.d.ts +75 -12
- package/dist/src/lib/function-collect.js +427 -12
- package/dist/src/lib/function-collect.js.map +1 -1
- package/dist/src/lib/function-db-types.d.ts +29 -0
- package/dist/src/lib/function-db-types.js +117 -7
- package/dist/src/lib/function-db-types.js.map +1 -1
- package/dist/src/lib/function-document-types.d.ts +5 -3
- package/dist/src/lib/function-document-types.js +10 -14
- package/dist/src/lib/function-document-types.js.map +1 -1
- package/dist/src/lib/function-lint.d.ts +34 -0
- package/dist/src/lib/function-lint.js +112 -0
- package/dist/src/lib/function-lint.js.map +1 -0
- package/dist/src/lib/function-log-row.js +21 -2
- package/dist/src/lib/function-log-row.js.map +1 -1
- package/dist/src/lib/function-run.d.ts +16 -21
- package/dist/src/lib/function-run.js +37 -30
- package/dist/src/lib/function-run.js.map +1 -1
- package/dist/src/lib/function-schema-codegen.d.ts +1 -1
- package/dist/src/lib/function-schema-codegen.js +5 -5
- package/dist/src/lib/function-schema-codegen.js.map +1 -1
- package/dist/src/lib/function-source-roots.d.ts +67 -0
- package/dist/src/lib/function-source-roots.js +148 -0
- package/dist/src/lib/function-source-roots.js.map +1 -0
- package/dist/src/lib/function-sync.d.ts +108 -22
- package/dist/src/lib/function-sync.js +127 -39
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/function-trigger-listing.d.ts +11 -6
- package/dist/src/lib/function-trigger-listing.js +32 -11
- package/dist/src/lib/function-trigger-listing.js.map +1 -1
- package/dist/src/lib/function-typecheck.d.ts +37 -2
- package/dist/src/lib/function-typecheck.js +210 -28
- package/dist/src/lib/function-typecheck.js.map +1 -1
- package/dist/src/lib/function-versions.d.ts +2 -0
- package/dist/src/lib/function-versions.js +1 -0
- package/dist/src/lib/function-versions.js.map +1 -1
- package/dist/src/lib/generated-allowlist.js +0 -20
- package/dist/src/lib/generated-allowlist.js.map +1 -1
- package/dist/src/lib/generated-config-surfaces.d.ts +703 -203
- package/dist/src/lib/generated-config-surfaces.js +2270 -2014
- package/dist/src/lib/generated-config-surfaces.js.map +1 -1
- package/dist/src/lib/generated-sdk-types.d.ts +1 -1
- package/dist/src/lib/generated-sdk-types.js +1 -1
- package/dist/src/lib/generated-sdk-types.js.map +1 -1
- package/dist/src/lib/init-adopt.js +12 -3
- package/dist/src/lib/init-adopt.js.map +1 -1
- package/dist/src/lib/init-login-note.d.ts +13 -0
- package/dist/src/lib/init-login-note.js +22 -0
- package/dist/src/lib/init-login-note.js.map +1 -0
- package/dist/src/lib/json-value.d.ts +6 -0
- package/dist/src/lib/json-value.js +13 -0
- package/dist/src/lib/json-value.js.map +1 -0
- package/dist/src/lib/load-routes.d.ts +33 -0
- package/dist/src/lib/load-routes.js +35 -0
- package/dist/src/lib/load-routes.js.map +1 -0
- package/dist/src/lib/local-state.d.ts +38 -7
- package/dist/src/lib/local-state.js +172 -49
- package/dist/src/lib/local-state.js.map +1 -1
- package/dist/src/lib/local-test-cases.d.ts +5 -2
- package/dist/src/lib/local-test-cases.js +7 -4
- package/dist/src/lib/local-test-cases.js.map +1 -1
- package/dist/src/lib/log-inspection.d.ts +42 -4
- package/dist/src/lib/log-inspection.js +37 -5
- package/dist/src/lib/log-inspection.js.map +1 -1
- package/dist/src/lib/login-exchange-check.d.ts +18 -0
- package/dist/src/lib/login-exchange-check.js +27 -0
- package/dist/src/lib/login-exchange-check.js.map +1 -0
- package/dist/src/lib/login-scope-lines.d.ts +25 -0
- package/dist/src/lib/login-scope-lines.js +45 -0
- package/dist/src/lib/login-scope-lines.js.map +1 -0
- package/dist/src/lib/logout-admin-session.d.ts +2 -1
- package/dist/src/lib/logout-admin-session.js +7 -1
- package/dist/src/lib/logout-admin-session.js.map +1 -1
- package/dist/src/lib/object-status-filter.d.ts +9 -1
- package/dist/src/lib/object-status-filter.js +9 -1
- package/dist/src/lib/object-status-filter.js.map +1 -1
- package/dist/src/lib/output.js +2 -0
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/paginate.d.ts +0 -5
- package/dist/src/lib/paginate.js +0 -5
- package/dist/src/lib/paginate.js.map +1 -1
- package/dist/src/lib/pin-refusal-hint.d.ts +12 -0
- package/dist/src/lib/pin-refusal-hint.js +35 -0
- package/dist/src/lib/pin-refusal-hint.js.map +1 -0
- package/dist/src/lib/primitive-env-plugin.d.ts +99 -0
- package/dist/src/lib/primitive-env-plugin.js +408 -0
- package/dist/src/lib/primitive-env-plugin.js.map +1 -0
- package/dist/src/lib/project-config.d.ts +7 -0
- package/dist/src/lib/project-config.js +22 -1
- package/dist/src/lib/project-config.js.map +1 -1
- package/dist/src/lib/project-login-apps.d.ts +8 -0
- package/dist/src/lib/project-login-apps.js +27 -0
- package/dist/src/lib/project-login-apps.js.map +1 -0
- package/dist/src/lib/prompt-schema-codegen.d.ts +10 -3
- package/dist/src/lib/prompt-schema-codegen.js +52 -11
- package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
- package/dist/src/lib/pull-write.d.ts +31 -0
- package/dist/src/lib/pull-write.js +49 -0
- package/dist/src/lib/pull-write.js.map +1 -0
- package/dist/src/lib/push-failure-report.d.ts +45 -0
- package/dist/src/lib/push-failure-report.js +57 -0
- package/dist/src/lib/push-failure-report.js.map +1 -0
- package/dist/src/lib/records-verbs.d.ts +69 -0
- package/dist/src/lib/records-verbs.js +40 -0
- package/dist/src/lib/records-verbs.js.map +1 -0
- package/dist/src/lib/refresh-admin-credentials.d.ts +7 -0
- package/dist/src/lib/refresh-admin-credentials.js +16 -4
- package/dist/src/lib/refresh-admin-credentials.js.map +1 -1
- package/dist/src/lib/root-import-decision.d.ts +65 -0
- package/dist/src/lib/root-import-decision.js +109 -0
- package/dist/src/lib/root-import-decision.js.map +1 -0
- package/dist/src/lib/run-status.d.ts +1 -1
- package/dist/src/lib/run-status.generated.d.ts +2 -2
- package/dist/src/lib/run-status.generated.js +3 -1
- package/dist/src/lib/run-status.generated.js.map +1 -1
- package/dist/src/lib/run-status.js +1 -1
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.d.ts +129 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +269 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -0
- package/dist/src/lib/schema-codegen/naming.d.ts +35 -0
- package/dist/src/lib/schema-codegen/naming.js +83 -0
- package/dist/src/lib/schema-codegen/naming.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaToTs.d.ts +82 -0
- package/dist/src/lib/schema-codegen/schemaToTs.js +305 -0
- package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -0
- package/dist/src/lib/scope-request.d.ts +84 -0
- package/dist/src/lib/scope-request.js +235 -0
- package/dist/src/lib/scope-request.js.map +1 -0
- package/dist/src/lib/session-id.d.ts +9 -0
- package/dist/src/lib/session-id.js +28 -0
- package/dist/src/lib/session-id.js.map +1 -0
- package/dist/src/lib/snapshot-build-rows.d.ts +21 -0
- package/dist/src/lib/snapshot-build-rows.js +22 -0
- package/dist/src/lib/snapshot-build-rows.js.map +1 -1
- package/dist/src/lib/snapshot-build.js +8 -3
- package/dist/src/lib/snapshot-build.js.map +1 -1
- package/dist/src/lib/snapshots.d.ts +17 -1
- package/dist/src/lib/snapshots.js +50 -2
- package/dist/src/lib/snapshots.js.map +1 -1
- package/dist/src/lib/swift-codegen/agentGenerator.d.ts +6 -2
- package/dist/src/lib/swift-codegen/agentGenerator.js +57 -5
- package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/banners.d.ts +34 -7
- package/dist/src/lib/swift-codegen/banners.js +37 -7
- package/dist/src/lib/swift-codegen/banners.js.map +1 -1
- package/dist/src/lib/swift-codegen/dbGenerator.d.ts +4 -3
- package/dist/src/lib/swift-codegen/dbGenerator.js +14 -117
- package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/functionGenerator.d.ts +3 -3
- package/dist/src/lib/swift-codegen/functionGenerator.js +23 -18
- package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/generator.d.ts +5 -5
- package/dist/src/lib/swift-codegen/generator.js +35 -40
- package/dist/src/lib/swift-codegen/generator.js.map +1 -1
- package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +3 -3
- package/dist/src/lib/swift-codegen/schemaToSwift.js +4 -4
- package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
- package/dist/src/lib/swift-codegen/swiftKeys.d.ts +19 -0
- package/dist/src/lib/swift-codegen/swiftKeys.js +31 -0
- package/dist/src/lib/swift-codegen/swiftKeys.js.map +1 -0
- package/dist/src/lib/sync-paths.d.ts +35 -0
- package/dist/src/lib/sync-paths.js +57 -5
- package/dist/src/lib/sync-paths.js.map +1 -1
- package/dist/src/lib/sync-resource-types.d.ts +26 -26
- package/dist/src/lib/sync-resource-types.js +61 -189
- package/dist/src/lib/sync-resource-types.js.map +1 -1
- package/dist/src/lib/sync-selectors.d.ts +5 -1
- package/dist/src/lib/sync-selectors.js +23 -13
- package/dist/src/lib/sync-selectors.js.map +1 -1
- package/dist/src/lib/test-case-file-names.d.ts +3 -5
- package/dist/src/lib/test-case-file-names.js +3 -5
- package/dist/src/lib/test-case-file-names.js.map +1 -1
- package/dist/src/lib/toml-database-config.d.ts +15 -75
- package/dist/src/lib/toml-database-config.js +17 -306
- package/dist/src/lib/toml-database-config.js.map +1 -1
- package/dist/src/lib/transient-retry.d.ts +43 -0
- package/dist/src/lib/transient-retry.js +94 -0
- package/dist/src/lib/transient-retry.js.map +1 -0
- package/dist/src/lib/vars-override.d.ts +105 -0
- package/dist/src/lib/vars-override.js +143 -0
- package/dist/src/lib/vars-override.js.map +1 -0
- package/dist/src/lib/webhook-capture.d.ts +43 -0
- package/dist/src/lib/webhook-capture.js +91 -0
- package/dist/src/lib/webhook-capture.js.map +1 -0
- package/dist/src/lib/webhook-deliver.d.ts +18 -20
- package/dist/src/lib/webhook-deliver.js +34 -89
- package/dist/src/lib/webhook-deliver.js.map +1 -1
- package/dist/src/lib/webhook-test-run.d.ts +32 -0
- package/dist/src/lib/webhook-test-run.js +108 -0
- package/dist/src/lib/webhook-test-run.js.map +1 -0
- package/dist/src/lib/workflow-codegen/generator.d.ts +7 -7
- package/dist/src/lib/workflow-codegen/generator.js +16 -23
- package/dist/src/lib/workflow-codegen/generator.js.map +1 -1
- package/dist/src/lib/workflow-codegen/invokerIR.d.ts +6 -12
- package/dist/src/lib/workflow-codegen/invokerIR.js +4 -5
- package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -1
- package/dist/src/lib/workflow-toml-validator.d.ts +2 -0
- package/dist/src/lib/workflow-toml-validator.js +28 -1
- package/dist/src/lib/workflow-toml-validator.js.map +1 -1
- package/dist/src/types/index.d.ts +30 -37
- package/dist/src/validators.d.ts +7 -55
- package/dist/src/validators.js +7 -53
- package/dist/src/validators.js.map +1 -1
- package/dist/src/vite.d.ts +17 -0
- package/dist/src/vite.js +18 -0
- package/dist/src/vite.js.map +1 -0
- package/package.json +20 -12
|
@@ -16,18 +16,21 @@
|
|
|
16
16
|
* (#2803's resurrection guard) — otherwise shipping a fix would silently put
|
|
17
17
|
* an endpoint an operator had taken down back in service.
|
|
18
18
|
*/
|
|
19
|
-
import { existsSync, readdirSync } from "fs";
|
|
19
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
20
20
|
import { join, relative as relativePath } from "path";
|
|
21
21
|
import { ApiClient } from "../lib/api-client.js";
|
|
22
22
|
import { resolveAppId } from "../lib/config.js";
|
|
23
23
|
import { resolveSyncDir } from "../lib/sync-paths.js";
|
|
24
|
+
import { requireCurrentEnvironment } from "../lib/env-resolver.js";
|
|
25
|
+
import { AUTH_CASE_FILE_SUFFIX, authFixturesPathFor, readAuthFixtures, } from "../lib/auth-fixtures.js";
|
|
26
|
+
import { caseFilesInTree, caseSummary, checkRequestBody, exitCodeForCheck, judgeCase, parseAuthorizeCaseFile, parseRuntimeFlag, parseTriggerFlag, renderCaseTable, renderCheckLine, resolveAliases, } from "../lib/function-authorize-check.js";
|
|
24
27
|
import { FunctionSchemaCodegenError, functionSchemaSources, } from "../lib/function-schema-codegen.js";
|
|
25
28
|
import { functionTypeWiringProblems, staleFunctionTypeArtifacts, writeFunctionTypeArtifacts, } from "../lib/function-db-types.js";
|
|
26
29
|
import { AGENT_CLIENT_FILE_SUFFIX, promptSchemaSources, treeDeclaresAgentPrompt, } from "../lib/prompt-schema-codegen.js";
|
|
27
30
|
import { generateFunctionSwiftTypes } from "../lib/swift-codegen/functionGenerator.js";
|
|
28
31
|
import { AGENT_SWIFT_FILE_SUFFIX } from "../lib/swift-codegen/agentGenerator.js";
|
|
29
32
|
import { SwiftCodegenError } from "../lib/swift-codegen/schemaToSwift.js";
|
|
30
|
-
import { success, error, info, warn, keyValue, result as printResult, formatTable, formatDate, formatStatus, json, jsonLine, divider, } from "../lib/output.js";
|
|
33
|
+
import { success, error, info, warn, keyValue, result as printResult, formatTable, formatDate, formatDuration, formatStatus, json, jsonLine, divider, flushOutput, } from "../lib/output.js";
|
|
31
34
|
import { confirmPrompt } from "../lib/confirm-prompt.js";
|
|
32
35
|
import { FUNCTION_LOG_COLUMNS, functionLogCells, functionLogLine, } from "../lib/function-log-row.js";
|
|
33
36
|
import { activatedLine, activationOutput, activationPrompt, activationRefusalLine, functionVersionRows, newerVersionLine, versionLine, } from "../lib/function-versions.js";
|
|
@@ -35,12 +38,14 @@ import { parseStatusFilter } from "../lib/object-status-filter.js";
|
|
|
35
38
|
import { renderStepRunTable } from "../lib/step-run-table.js";
|
|
36
39
|
import { triggerKindsCell, triggerTableRows, } from "../lib/function-trigger-listing.js";
|
|
37
40
|
import { renderRunLogs } from "../lib/function-log-lines.js";
|
|
38
|
-
import { buildWorkflowStepEnvelope } from "../lib/log-inspection.js";
|
|
41
|
+
import { buildIntegrationEnvelope, buildWorkflowStepEnvelope, formatIntegrationStepCell, } from "../lib/log-inspection.js";
|
|
39
42
|
import { followLoop } from "../lib/watch.js";
|
|
40
43
|
import { buildLogFollowSource } from "../lib/function-log-tail.js";
|
|
41
44
|
import { toFunctionLogInspectionRow } from "../lib/log-inspection.js";
|
|
42
|
-
import { decidePageContinuation, describeIdentity, exitCodeForInvokeStatus, exitCodeForRunStatus, invokeIdLines, logsFlagConflict, refusalLines, renderIdLines, resolveRunFlags, runRuntimeCell, runSliceCells,
|
|
45
|
+
import { decidePageContinuation, describeIdentity, exitCodeForInvokeStatus, exitCodeForRunStatus, invokeIdLines, logsFlagConflict, refusalLines, renderIdLines, resolveRunFlags, runRuntime, runRuntimeCell, runSliceCells, resumeCommand, startIdLines, userTokenName, waitDelayMs, withMintedToken, EXIT_INTERRUPTED, EXIT_TIMED_OUT, USER_TOKEN_TTL, WAIT_DEFAULT_TIMEOUT_SECONDS, } from "../lib/function-run.js";
|
|
43
46
|
import { wholeListEnvelope } from "../lib/paginate.js";
|
|
47
|
+
import { authorizeSection } from "../lib/function-authorize-view.js";
|
|
48
|
+
import { registerFunctionTriggersCommands } from "./function-trigger-commands.js";
|
|
44
49
|
/**
|
|
45
50
|
* How far back one `--follow` tick will page to meet its high-water mark.
|
|
46
51
|
*
|
|
@@ -126,10 +131,8 @@ Configuration lives in functions/<key>.toml, and the code beside it:
|
|
|
126
131
|
info("No functions found.");
|
|
127
132
|
return;
|
|
128
133
|
}
|
|
129
|
-
// #3690 — which functions a webhook or a schedule reaches, in one call
|
|
130
|
-
//
|
|
131
|
-
// rows a function owns (#3181), so without this the only way to find
|
|
132
|
-
// an app's triggers was `functions get`, one function at a time.
|
|
134
|
+
// #3690 — which functions a webhook or a schedule reaches, in one call,
|
|
135
|
+
// rather than `functions get` one function at a time.
|
|
133
136
|
console.log(formatTable(filtered.map((f) => ({
|
|
134
137
|
...f,
|
|
135
138
|
triggersCell: triggerKindsCell(f.triggers),
|
|
@@ -241,6 +244,14 @@ Configuration lives in functions/<key>.toml, and the code beside it:
|
|
|
241
244
|
printResult(" Config ID", active.configId);
|
|
242
245
|
printResult(" Entry", active.entry);
|
|
243
246
|
printResult(" Content Hash", active.contentHash || "-");
|
|
247
|
+
// #4717 — whether this version carries `authorize`, as the server's
|
|
248
|
+
// push probe recorded it. A legacy version runs the header's
|
|
249
|
+
// `access` rule above.
|
|
250
|
+
printResult(" Authorize", active.authorize === true ? "yes" : "no (legacy)");
|
|
251
|
+
// #4730 — what the push collected about it, from the manifest.
|
|
252
|
+
const section = authorizeSection(record.manifest && typeof record.manifest === "object" ? record.manifest : null, active.authorize === true);
|
|
253
|
+
for (const [label, value] of section ?? [])
|
|
254
|
+
printResult(` ${label}`, value);
|
|
244
255
|
// #3482 — no Mode line. The config says nothing about how a
|
|
245
256
|
// function runs: `invoke` runs it inside the request, `start` runs
|
|
246
257
|
// it as a task, and every function takes both.
|
|
@@ -276,22 +287,21 @@ Configuration lives in functions/<key>.toml, and the code beside it:
|
|
|
276
287
|
? documentSchemaModels.join(", ")
|
|
277
288
|
: "declares no models");
|
|
278
289
|
}
|
|
279
|
-
// #3181 —
|
|
280
|
-
//
|
|
281
|
-
// `webhooks list`, `cron-triggers list` and `config pull` by design, so
|
|
282
|
-
// without this an operator could not find the receiver URL a provider
|
|
283
|
-
// must be pointed at, or the schedule the platform actually holds.
|
|
290
|
+
// #3181 — where an operator finds the receiver URL a provider must be
|
|
291
|
+
// pointed at, and the schedule the platform actually holds.
|
|
284
292
|
divider();
|
|
285
293
|
info("Triggers:");
|
|
286
294
|
const triggers = record.triggers ?? { webhook: null, cron: [] };
|
|
287
295
|
const cronEntries = Array.isArray(triggers.cron)
|
|
288
296
|
? triggers.cron
|
|
289
297
|
: [];
|
|
298
|
+
// #4803 — the db3 types this function watches; absent when none.
|
|
299
|
+
const db3Entries = Array.isArray(triggers.db3) ? triggers.db3 : [];
|
|
290
300
|
// #3483 — an OLDER server still answers a `databases` key, and this
|
|
291
301
|
// command ignores it rather than branching on it: the trigger it
|
|
292
302
|
// described was removed, so a section about it would tell an operator
|
|
293
303
|
// that a write runs this function when nothing does.
|
|
294
|
-
if (!triggers.webhook && cronEntries.length === 0) {
|
|
304
|
+
if (!triggers.webhook && cronEntries.length === 0 && db3Entries.length === 0) {
|
|
295
305
|
printResult(" Triggers", "none — this function is invoked over HTTP only");
|
|
296
306
|
}
|
|
297
307
|
if (triggers.webhook) {
|
|
@@ -319,6 +329,21 @@ Configuration lives in functions/<key>.toml, and the code beside it:
|
|
|
319
329
|
{ header: "LAST RUN", key: "lastTriggeredRunId" },
|
|
320
330
|
]));
|
|
321
331
|
}
|
|
332
|
+
if (db3Entries.length > 0) {
|
|
333
|
+
info("DB3 TRIGGERS (one run per flush of a db3 of the type):");
|
|
334
|
+
console.log(formatTable(db3Entries, [
|
|
335
|
+
{ header: "TYPE", key: "type" },
|
|
336
|
+
{ header: "ID", key: "triggerId" },
|
|
337
|
+
{ header: "STATUS", key: "status", format: formatStatus },
|
|
338
|
+
{
|
|
339
|
+
header: "LAST FIRED",
|
|
340
|
+
key: "lastTriggeredAt",
|
|
341
|
+
format: (value) => (value ? formatDate(value) : "never"),
|
|
342
|
+
},
|
|
343
|
+
{ header: "LAST RUN", key: "lastTriggeredRunId" },
|
|
344
|
+
{ header: "LAST ERROR", key: "lastError" },
|
|
345
|
+
]));
|
|
346
|
+
}
|
|
322
347
|
// #3187 / #3279 — the ACTIVE version's manifest: what it registered
|
|
323
348
|
// and what it TOUCHES, from the push-time collection. Documentation,
|
|
324
349
|
// never authorization — function code acts as the system, and this
|
|
@@ -431,6 +456,9 @@ Configuration lives in functions/<key>.toml, and the code beside it:
|
|
|
431
456
|
{ header: "ENVELOPE", key: "envelope" },
|
|
432
457
|
{ header: "TRIGGERS", key: "triggers" },
|
|
433
458
|
{ header: "BY", key: "by" },
|
|
459
|
+
// #4717 — last, so every column a reader already parses keeps
|
|
460
|
+
// its place.
|
|
461
|
+
{ header: "AUTHORIZE", key: "authorize" },
|
|
434
462
|
]));
|
|
435
463
|
if (nextCursor) {
|
|
436
464
|
info(`More versions: --cursor ${nextCursor}`);
|
|
@@ -526,7 +554,7 @@ What activating a version does, and does not:
|
|
|
526
554
|
// empty string that sorts beside real ones.
|
|
527
555
|
const withRuntime = (items ?? []).map((run) => ({
|
|
528
556
|
...run,
|
|
529
|
-
runtime:
|
|
557
|
+
runtime: runRuntime(run),
|
|
530
558
|
}));
|
|
531
559
|
if (options.json) {
|
|
532
560
|
json({ items: withRuntime, nextCursor });
|
|
@@ -540,12 +568,13 @@ What activating a version does, and does not:
|
|
|
540
568
|
// #3381, #3566 — flatten the slice record's two counts onto the
|
|
541
569
|
// row for the REFRESHES and RESETS columns. One helper decides
|
|
542
570
|
// both, so a row with no record gets a blank cell in each and a
|
|
543
|
-
// record with no count gets `0`.
|
|
571
|
+
// record with no count gets `0`. #3766 — and the LAST PROGRESS
|
|
572
|
+
// cell, from the same helper.
|
|
544
573
|
items.map((run) => ({
|
|
545
574
|
...run,
|
|
546
575
|
// #3482 — which RUNTIME this run used, from the row's own
|
|
547
|
-
// `
|
|
548
|
-
//
|
|
576
|
+
// `runtime` (#3190). One reader, so the word an operator reads
|
|
577
|
+
// here is the word `ctx.runtime` gave the code.
|
|
549
578
|
runtime: runRuntimeCell(run),
|
|
550
579
|
...runSliceCells(run),
|
|
551
580
|
})), [
|
|
@@ -572,6 +601,11 @@ What activating a version does, and does not:
|
|
|
572
601
|
// step, so a run that reset and then COMPLETED carries no failure
|
|
573
602
|
// and no error code: this cell is the only place it shows.
|
|
574
603
|
{ header: "RESETS", key: "resets" },
|
|
604
|
+
// #3766 — when the platform last saw this run's slice do
|
|
605
|
+
// anything: its open, a refresh, a park or a step boundary. A
|
|
606
|
+
// `running` run whose last progress is long past is the stalled
|
|
607
|
+
// one. Blank with no slice record.
|
|
608
|
+
{ header: "LAST PROGRESS", key: "lastProgress" },
|
|
575
609
|
{ header: "STARTED", key: "startedAt", format: formatDate },
|
|
576
610
|
{ header: "ENDED", key: "endedAt", format: formatDate },
|
|
577
611
|
{ header: "CODE", key: "errorCode" },
|
|
@@ -634,6 +668,53 @@ What activating a version does, and does not:
|
|
|
634
668
|
process.exit(1);
|
|
635
669
|
}
|
|
636
670
|
});
|
|
671
|
+
// #3190 — the integration calls one run made. The run → integration-logs
|
|
672
|
+
// pivot was `workflows/runs/{runId}/integration-logs` on the admin API and
|
|
673
|
+
// had no CLI verb; a function run is addressed by the function that owns it,
|
|
674
|
+
// as `runs steps` is.
|
|
675
|
+
runs
|
|
676
|
+
.command("integration-logs")
|
|
677
|
+
.description("List the integration calls a function run made")
|
|
678
|
+
.argument("<function-id>", "Function ID")
|
|
679
|
+
.argument("<run-id>", "Run ID")
|
|
680
|
+
.option("--app <app-id>", "App ID (uses current app if not specified)")
|
|
681
|
+
.option("--limit <n>", "Number of calls to show (at most 200)", "100")
|
|
682
|
+
.option("--json", "Output as JSON")
|
|
683
|
+
.action(async (functionId, runId, _options, command) => {
|
|
684
|
+
// See `runs steps` above: `runs` parses its own `--app`/`--json` out of
|
|
685
|
+
// the argv before dispatching here, so the merged view is the real one.
|
|
686
|
+
const options = command.optsWithGlobals();
|
|
687
|
+
const resolvedAppId = resolveAppId(undefined, options);
|
|
688
|
+
const client = new ApiClient();
|
|
689
|
+
try {
|
|
690
|
+
const { items } = await client.listFunctionRunIntegrationLogs(resolvedAppId, functionId, runId, { limit: parseInt(options.limit, 10) });
|
|
691
|
+
if (options.json) {
|
|
692
|
+
json(buildIntegrationEnvelope(items));
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
if (!items || items.length === 0) {
|
|
696
|
+
info("No integration calls found for this run.");
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
const rows = items.map((log) => ({
|
|
700
|
+
...log,
|
|
701
|
+
stepCell: formatIntegrationStepCell(log),
|
|
702
|
+
}));
|
|
703
|
+
console.log(formatTable(rows, [
|
|
704
|
+
{ header: "TIME", key: "timestamp", format: formatDate },
|
|
705
|
+
{ header: "INTEGRATION", key: "integrationKey", format: (v) => v || "" },
|
|
706
|
+
{ header: "METHOD", key: "method" },
|
|
707
|
+
{ header: "PATH", key: "path" },
|
|
708
|
+
{ header: "STATUS", key: "status" },
|
|
709
|
+
{ header: "DURATION", key: "durationMs", format: formatDuration },
|
|
710
|
+
{ header: "STEP", key: "stepCell" },
|
|
711
|
+
]));
|
|
712
|
+
}
|
|
713
|
+
catch (err) {
|
|
714
|
+
error(err.message);
|
|
715
|
+
process.exit(1);
|
|
716
|
+
}
|
|
717
|
+
});
|
|
637
718
|
// #3348 — end a run that will not settle.
|
|
638
719
|
//
|
|
639
720
|
// `client.functions.terminate` has existed in the SDK since #3186 and nothing
|
|
@@ -901,8 +982,8 @@ What activating a version does, and does not:
|
|
|
901
982
|
// names the stale ones, but a diff exits 0 whatever it found, so a job that
|
|
902
983
|
// meant to fail on stale types passed and a declaration that disagreed with
|
|
903
984
|
// its schema reached the author as types that quietly lie (F3182-004). The
|
|
904
|
-
// verb and the flag are the
|
|
905
|
-
//
|
|
985
|
+
// verb and the flag are the ones `workflows codegen` already uses for
|
|
986
|
+
// exactly this.
|
|
906
987
|
functions
|
|
907
988
|
.command("codegen")
|
|
908
989
|
.allowExcessArguments(false)
|
|
@@ -1081,6 +1162,8 @@ What activating a version does, and does not:
|
|
|
1081
1162
|
warn(`functions/tsconfig.json: ${problem}`);
|
|
1082
1163
|
}
|
|
1083
1164
|
});
|
|
1165
|
+
// #3190 — the operational verbs of a function's webhook and cron triggers.
|
|
1166
|
+
registerFunctionTriggersCommands(functions);
|
|
1084
1167
|
// #2803 — the operational verb pair, and the only writers of `status` besides
|
|
1085
1168
|
// the delete flow. `config push` is deliberately not one: see the module note.
|
|
1086
1169
|
functions
|
|
@@ -1387,10 +1470,6 @@ Reclaiming the key means hard-deleting the row:
|
|
|
1387
1470
|
}
|
|
1388
1471
|
const body = {
|
|
1389
1472
|
rootInput: flags.input,
|
|
1390
|
-
// #3482 — `--as system` is the ONE door that is a single route for
|
|
1391
|
-
// both runtimes, so it keeps the deprecated body selector; every
|
|
1392
|
-
// other call says it with the route.
|
|
1393
|
-
...(identity.asSystem ? { mode: "task" } : {}),
|
|
1394
1473
|
...(contextDocId ? { contextDocId } : {}),
|
|
1395
1474
|
...(options.runKey ? { runKey: options.runKey } : {}),
|
|
1396
1475
|
};
|
|
@@ -1455,6 +1534,200 @@ Reclaiming the key means hard-deleting the row:
|
|
|
1455
1534
|
process.exit(1);
|
|
1456
1535
|
}
|
|
1457
1536
|
});
|
|
1537
|
+
// ── authorize (#4732) ───────────────────────────────────────────────
|
|
1538
|
+
//
|
|
1539
|
+
// Runs a function's `authorize` alone, through the admin endpoint, so a
|
|
1540
|
+
// gate can be checked without running the handler. The app, the fixture
|
|
1541
|
+
// map and the case files all come from the one environment `--env`
|
|
1542
|
+
// resolves, so the verb takes no `--app` (#3154's one-tree rule).
|
|
1543
|
+
functions
|
|
1544
|
+
.command("authorize")
|
|
1545
|
+
.allowExcessArguments(false)
|
|
1546
|
+
.description("Run only a function's authorize for a user, door, runtime and input, and print the decision; --cases runs its case file")
|
|
1547
|
+
.argument("[key]", "Function key (as written in functions/<key>.toml)")
|
|
1548
|
+
.option("--user <id>", "auth.user: an app user id or an @fixture alias (default: no user)")
|
|
1549
|
+
.option("--role <role>", "Replace auth.user's role for the check; memberships stay the user's")
|
|
1550
|
+
.option("--trigger <door>", "http (default), webhook, cron, manual, context, history, db3, function:<key>, tool[:<name>]")
|
|
1551
|
+
.option("--runtime <runtime>", "request or task (default: the door's own)")
|
|
1552
|
+
.option("--input <json>", "The input, as JSON; @fixture aliases resolve inside it (default {})")
|
|
1553
|
+
.option("--cases", "Run the function's case file, functions/<key>.auth.json")
|
|
1554
|
+
.option("--all", "With --cases, run every case file in the tree")
|
|
1555
|
+
.option("--json", "Output as JSON")
|
|
1556
|
+
.action(async (functionKey, options) => {
|
|
1557
|
+
const refuse = (message) => {
|
|
1558
|
+
error(message);
|
|
1559
|
+
process.exit(2);
|
|
1560
|
+
};
|
|
1561
|
+
const singleFlags = ["user", "role", "trigger", "runtime", "input"].filter((flag) => options[flag] !== undefined);
|
|
1562
|
+
if (options.all && !options.cases)
|
|
1563
|
+
refuse("--all runs every case file: use it with --cases");
|
|
1564
|
+
if (options.cases && singleFlags.length > 0) {
|
|
1565
|
+
refuse(`--cases runs each case as its file states it: drop ${singleFlags.map((f) => `--${f}`).join(", ")}`);
|
|
1566
|
+
}
|
|
1567
|
+
if (options.all && functionKey)
|
|
1568
|
+
refuse("--cases --all runs every case file: name no function with it");
|
|
1569
|
+
if (!functionKey && !options.all) {
|
|
1570
|
+
refuse(options.cases ? "Name the function whose case file to run, or use --all" : "Name the function to check");
|
|
1571
|
+
}
|
|
1572
|
+
let env;
|
|
1573
|
+
let configDir;
|
|
1574
|
+
try {
|
|
1575
|
+
env = requireCurrentEnvironment();
|
|
1576
|
+
configDir = resolveSyncDir();
|
|
1577
|
+
}
|
|
1578
|
+
catch (err) {
|
|
1579
|
+
return refuse(err.message);
|
|
1580
|
+
}
|
|
1581
|
+
const appId = env.config.appId;
|
|
1582
|
+
const fixturesPath = authFixturesPathFor(env);
|
|
1583
|
+
const fixturesLabel = relativePath(env.projectRoot, fixturesPath);
|
|
1584
|
+
const fixtures = readAuthFixtures(fixturesPath);
|
|
1585
|
+
if (fixtures.ok === false)
|
|
1586
|
+
return refuse(fixtures.error.replace(fixturesPath, fixturesLabel));
|
|
1587
|
+
/** A case's or the flags' user and input, with the aliases resolved. */
|
|
1588
|
+
const resolveSubject = (user, input) => {
|
|
1589
|
+
const resolvedUser = resolveAliases(user, fixtures.fixtures, fixturesLabel, "user");
|
|
1590
|
+
if (resolvedUser.ok === false)
|
|
1591
|
+
return resolvedUser;
|
|
1592
|
+
if (resolvedUser.value !== null && typeof resolvedUser.value !== "string") {
|
|
1593
|
+
return { ok: false, error: `user ${user} must resolve to a user id or null in ${fixturesLabel}` };
|
|
1594
|
+
}
|
|
1595
|
+
const resolvedInput = resolveAliases(input, fixtures.fixtures, fixturesLabel, "$");
|
|
1596
|
+
if (resolvedInput.ok === false)
|
|
1597
|
+
return resolvedInput;
|
|
1598
|
+
return { ok: true, user: resolvedUser.value, input: resolvedInput.value };
|
|
1599
|
+
};
|
|
1600
|
+
const client = new ApiClient();
|
|
1601
|
+
if (!options.cases) {
|
|
1602
|
+
const trigger = parseTriggerFlag(options.trigger ?? "http");
|
|
1603
|
+
if (trigger.ok === false)
|
|
1604
|
+
return refuse(trigger.error);
|
|
1605
|
+
let runtime = null;
|
|
1606
|
+
if (options.runtime !== undefined) {
|
|
1607
|
+
const parsed = parseRuntimeFlag(options.runtime);
|
|
1608
|
+
if (parsed.ok === false)
|
|
1609
|
+
return refuse(parsed.error);
|
|
1610
|
+
runtime = parsed.runtime;
|
|
1611
|
+
}
|
|
1612
|
+
let input = {};
|
|
1613
|
+
if (options.input !== undefined) {
|
|
1614
|
+
try {
|
|
1615
|
+
input = JSON.parse(options.input);
|
|
1616
|
+
}
|
|
1617
|
+
catch {
|
|
1618
|
+
return refuse(`--input is not valid JSON: ${options.input}`);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
const subject = resolveSubject(options.user ?? null, input);
|
|
1622
|
+
if (subject.ok === false)
|
|
1623
|
+
return refuse(subject.error);
|
|
1624
|
+
let outcome;
|
|
1625
|
+
try {
|
|
1626
|
+
const target = await resolveFunctionByKey(client, appId, functionKey);
|
|
1627
|
+
outcome = await client.authorizeFunction(appId, target.functionId, checkRequestBody({
|
|
1628
|
+
user: subject.user,
|
|
1629
|
+
role: options.role ?? null,
|
|
1630
|
+
trigger: trigger.trigger,
|
|
1631
|
+
runtime,
|
|
1632
|
+
input: subject.input,
|
|
1633
|
+
}));
|
|
1634
|
+
}
|
|
1635
|
+
catch (err) {
|
|
1636
|
+
return refuse(err.message);
|
|
1637
|
+
}
|
|
1638
|
+
const exitCode = exitCodeForCheck(outcome);
|
|
1639
|
+
if (options.json) {
|
|
1640
|
+
json({
|
|
1641
|
+
...(outcome.httpStatus >= 400 ? { httpStatus: outcome.httpStatus } : {}),
|
|
1642
|
+
...(outcome.body ?? {}),
|
|
1643
|
+
functionKey,
|
|
1644
|
+
exitCode,
|
|
1645
|
+
});
|
|
1646
|
+
await flushOutput();
|
|
1647
|
+
process.exit(exitCode);
|
|
1648
|
+
}
|
|
1649
|
+
if (outcome.httpStatus >= 400) {
|
|
1650
|
+
const body = outcome.body ?? {};
|
|
1651
|
+
error(`${body.error ?? "The check was refused"}` +
|
|
1652
|
+
`${body.code ? ` (${body.code}${body.reason ? `, ${body.reason}` : ""})` : ""}`);
|
|
1653
|
+
await flushOutput();
|
|
1654
|
+
process.exit(exitCode);
|
|
1655
|
+
}
|
|
1656
|
+
console.log(renderCheckLine(outcome.body));
|
|
1657
|
+
await flushOutput();
|
|
1658
|
+
process.exit(exitCode);
|
|
1659
|
+
}
|
|
1660
|
+
// ── cases ──
|
|
1661
|
+
const functionsDir = join(configDir, "functions");
|
|
1662
|
+
const keys = options.all ? caseFilesInTree(functionsDir) : [functionKey];
|
|
1663
|
+
if (keys.length === 0) {
|
|
1664
|
+
if (options.json)
|
|
1665
|
+
json({ items: [], passed: 0, failed: 0 });
|
|
1666
|
+
else
|
|
1667
|
+
console.log("No case files");
|
|
1668
|
+
await flushOutput();
|
|
1669
|
+
process.exit(0);
|
|
1670
|
+
}
|
|
1671
|
+
let listed;
|
|
1672
|
+
try {
|
|
1673
|
+
listed = (await client.listFunctions(appId)).items ?? [];
|
|
1674
|
+
}
|
|
1675
|
+
catch (err) {
|
|
1676
|
+
return refuse(err.message);
|
|
1677
|
+
}
|
|
1678
|
+
const rows = [];
|
|
1679
|
+
for (const key of keys) {
|
|
1680
|
+
const filePath = join(functionsDir, `${key}${AUTH_CASE_FILE_SUFFIX}`);
|
|
1681
|
+
const fileLabel = relativePath(env.projectRoot, filePath);
|
|
1682
|
+
if (!existsSync(filePath))
|
|
1683
|
+
refuse(`No case file ${fileLabel}`);
|
|
1684
|
+
const parsed = parseAuthorizeCaseFile(readFileSync(filePath, "utf-8"), fileLabel);
|
|
1685
|
+
if (parsed.ok === false) {
|
|
1686
|
+
if (!options.all)
|
|
1687
|
+
refuse(parsed.error);
|
|
1688
|
+
rows.push({ ...judgeCase(key, { name: "(case file)", expect: "-", code: null }, { error: parsed.error }) });
|
|
1689
|
+
continue;
|
|
1690
|
+
}
|
|
1691
|
+
const match = listed.find((item) => String(item.functionKey ?? "").toLowerCase() === key.toLowerCase());
|
|
1692
|
+
for (const testCase of parsed.cases) {
|
|
1693
|
+
if (!match) {
|
|
1694
|
+
rows.push(judgeCase(key, testCase, { error: `no function '${key}' in this app` }));
|
|
1695
|
+
continue;
|
|
1696
|
+
}
|
|
1697
|
+
const subject = resolveSubject(testCase.user, testCase.input);
|
|
1698
|
+
if (subject.ok === false) {
|
|
1699
|
+
rows.push(judgeCase(key, testCase, { error: `case "${testCase.name}": ${subject.error}` }));
|
|
1700
|
+
continue;
|
|
1701
|
+
}
|
|
1702
|
+
const trigger = parseTriggerFlag(testCase.trigger);
|
|
1703
|
+
let outcome;
|
|
1704
|
+
try {
|
|
1705
|
+
outcome = await client.authorizeFunction(appId, String(match.functionId), checkRequestBody({
|
|
1706
|
+
user: subject.user,
|
|
1707
|
+
role: testCase.role,
|
|
1708
|
+
trigger: trigger.ok ? trigger.trigger : { kind: "http" },
|
|
1709
|
+
runtime: testCase.runtime,
|
|
1710
|
+
input: subject.input,
|
|
1711
|
+
}));
|
|
1712
|
+
}
|
|
1713
|
+
catch (err) {
|
|
1714
|
+
outcome = { error: err.message };
|
|
1715
|
+
}
|
|
1716
|
+
rows.push(judgeCase(key, testCase, outcome));
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
const summary = caseSummary(rows);
|
|
1720
|
+
if (options.json) {
|
|
1721
|
+
json({ items: rows, passed: summary.passed, failed: summary.failed });
|
|
1722
|
+
}
|
|
1723
|
+
else {
|
|
1724
|
+
console.log(renderCaseTable(rows, { withFunction: !!options.all }));
|
|
1725
|
+
console.log(summary.line);
|
|
1726
|
+
}
|
|
1727
|
+
// A report past the pipe buffer is cut off by an exit that does not wait.
|
|
1728
|
+
await flushOutput();
|
|
1729
|
+
process.exit(summary.failed > 0 ? 1 : 0);
|
|
1730
|
+
});
|
|
1458
1731
|
runs
|
|
1459
1732
|
.command("wait")
|
|
1460
1733
|
.allowExcessArguments(false)
|