@unbrained/pm-cli 2026.11.13 → 2026.11.15
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/.claude-plugin/marketplace.json +1 -1
- package/README.md +1 -1
- package/dist/cli/extension-command-help.js +2 -2
- package/dist/cli/register-mutation.js +2 -2
- package/dist/cli/register-operations.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-6UTBX62V.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-GWVP23RZ.js → chunk-7AODVNHX.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-ASGAELBQ.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-PUU5DXSV.js → chunk-DBUBX4DL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5LG5YZYF.js → chunk-E4B2HWH7.js} +13 -13
- package/dist/cli-bundle/chunks/chunk-E74OMFBZ.js +6 -0
- package/dist/cli-bundle/chunks/chunk-FSE624WQ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-FYOIH56R.js +20 -0
- package/dist/cli-bundle/chunks/chunk-GAFALSR2.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-LKVFPQNY.js → chunk-GCSKHCYK.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-HMVZSXB4.js +8 -0
- package/dist/cli-bundle/chunks/chunk-IXV5UM4U.js +31 -0
- package/dist/cli-bundle/chunks/chunk-J6L3Q5J4.js +3 -0
- package/dist/cli-bundle/chunks/chunk-KLWGIEDC.js +114 -0
- package/dist/cli-bundle/chunks/chunk-KSLPRST2.js +10 -0
- package/dist/cli-bundle/chunks/chunk-LC6DL446.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-UFZQPKQS.js → chunk-NAX554KY.js} +35 -35
- package/dist/cli-bundle/chunks/chunk-PMIGRSNZ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-Q6GBRK27.js +3 -0
- package/dist/cli-bundle/chunks/chunk-QZNDEZYI.js +2 -0
- package/dist/cli-bundle/chunks/chunk-S5UXBECQ.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-UJMQP2HP.js → chunk-TESRFVGF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GXGMMIZN.js → chunk-VWKLTHYQ.js} +80 -70
- package/dist/cli-bundle/chunks/chunk-YJNY5MKP.js +2 -0
- package/dist/cli-bundle/chunks/chunk-YLPZE2TK.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-RSAN2YUU.js → chunk-ZVDXGAYV.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-ZWUS65LN.js +2 -0
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-I6RQGD6Y.js → indexed-receipt-blobs-42Y2CSEQ.js} +2 -2
- package/dist/cli-bundle/chunks/item-revision-JCEDTAVX.js +2 -0
- package/dist/cli-bundle/chunks/item-transaction-BSMGKZ4S.js +2 -0
- package/dist/cli-bundle/chunks/mutation-actor-IQHBRFAJ.js +2 -0
- package/dist/cli-bundle/chunks/mutation-admission-DF6BFGG6.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-JNJY2D3N.js → register-list-query-DNKPQB76.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-WVTDFLEF.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-NR5MTT5T.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-2RTG3LII.js +2 -0
- package/dist/cli-bundle/chunks/{settlement-hook-JHXLUBEN.js → settlement-hook-W5ULPKIE.js} +2 -2
- package/dist/cli-bundle/chunks/stage-YFNK7U26.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-Q3OA5OAK.js → chunk-2UQFFVQK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-52H6AELE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-J3LQQP3N.js → chunk-63FM3TIG.js} +7 -7
- package/dist/cli-bundle/focused-chunks/{chunk-VGFKTSGY.js → chunk-7GCAZJT4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-BSY6FZ3Y.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-CZZKAGHE.js +91 -0
- package/dist/cli-bundle/focused-chunks/chunk-DRBXOAGY.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-DXMQ32EH.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-EALGFJRP.js +78 -0
- package/dist/cli-bundle/focused-chunks/chunk-FK2X6MJY.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IDAYTYNN.js → chunk-JE3MFEQZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-JR75B6HU.js → chunk-JRRHN2PZ.js} +12 -12
- package/dist/cli-bundle/focused-chunks/chunk-JXA77YIV.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-LQZ5F6LE.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-LSWUTTE6.js +6 -0
- package/dist/cli-bundle/focused-chunks/chunk-QXOFSZR6.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-RMCODWHZ.js +65 -0
- package/dist/cli-bundle/focused-chunks/chunk-S6GTALM4.js +24 -0
- package/dist/cli-bundle/focused-chunks/chunk-UPUIDGNJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-TVJ2PHAK.js → chunk-W2KIQ7RF.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-WGYR3X6O.js +26 -0
- package/dist/cli-bundle/focused-chunks/chunk-WVYXR3YX.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-ZJF6ZA7B.js → chunk-XQZKGTZV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-4LFE3FQL.js → chunk-YTNUUEY6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-YZUBG4W2.js +6 -0
- package/dist/cli-bundle/focused-chunks/chunk-Z6HCQYSW.js +8 -0
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-7XGVHYAO.js → indexed-receipt-blobs-LSBWMXKS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-YO7YGQYE.js +2 -0
- package/dist/cli-bundle/focused-chunks/item-transaction-7A3Q4CAJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-actor-UQHBNHOF.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-admission-G565NLPE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{settlement-hook-H56537UV.js → settlement-hook-UXN76GMA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/stage-F3YJGNRK.js +2 -0
- package/dist/cli-bundle/main.js +7 -7
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +3 -3
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +57 -57
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +11 -11
- package/dist/core/extensions/extension-hook-runtime.js +1 -1
- package/dist/core/extensions/extension-types.d.ts +30 -0
- package/dist/core/extensions/extension-types.js +1 -1
- package/dist/core/extensions/index.d.ts +21 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/mutation-actor-snapshot.js +2 -0
- package/dist/core/extensions/mutation-actor.js +2 -0
- package/dist/core/item/deferred-fields.js +2 -0
- package/dist/core/item/item-format-version.d.ts +8 -6
- package/dist/core/item/item-format-version.js +1 -1
- package/dist/core/item/item-format.js +2 -2
- package/dist/core/lock/lock.js +3 -3
- package/dist/core/output/linked-test-projection.js +6 -0
- package/dist/core/output/output.d.ts +7 -0
- package/dist/core/output/output.js +9 -7
- package/dist/core/schema/runtime-field-values.d.ts +4 -0
- package/dist/core/schema/runtime-field-values.js +1 -1
- package/dist/core/session/session-state.js +1 -1
- package/dist/core/shared/item-metadata-contract.js +1 -1
- package/dist/core/shared/text-normalization.d.ts +24 -0
- package/dist/core/shared/text-normalization.js +1 -1
- package/dist/core/shared/url-credentials.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/core/test/run-selectors.d.ts +3 -1
- package/dist/core/test/run-selectors.js +1 -1
- package/dist/sdk/agent/closed-domain-contracts.js +1 -1
- package/dist/sdk/annotations.js +1 -1
- package/dist/sdk/authoring.d.ts +1 -1
- package/dist/sdk/authoring.js +1 -1
- package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
- package/dist/sdk/cli-contracts/completeness.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/registration-helpers.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/completion/bash.js +1 -1
- package/dist/sdk/completion/fish.js +6 -1
- package/dist/sdk/completion/zsh.js +6 -1
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/dist/sdk/docs.d.ts +3 -1
- package/dist/sdk/docs.js +1 -1
- package/dist/sdk/environment/project-runtime-compatibility.d.ts +8 -1
- package/dist/sdk/environment/project-runtime-compatibility.js +2 -2
- package/dist/sdk/extension/command-options.d.ts +23 -4
- package/dist/sdk/extension/command-options.js +1 -1
- package/dist/sdk/extension/native-command-options.js +2 -0
- package/dist/sdk/files.d.ts +3 -1
- package/dist/sdk/files.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/health.js +1 -1
- package/dist/sdk/governance/lifecycle-dependency-cycles.d.ts +12 -0
- package/dist/sdk/governance/lifecycle-dependency-cycles.js +2 -0
- package/dist/sdk/governance/validate-deferred-fields.js +2 -0
- package/dist/sdk/governance/validate.d.ts +2 -2
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/guide-topics.js +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/item-transaction.d.ts +2 -2
- package/dist/sdk/item-transaction.js +1 -1
- package/dist/sdk/lifecycle/claim.d.ts +5 -1
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/close.js +1 -1
- package/dist/sdk/lifecycle/copy.js +1 -1
- package/dist/sdk/lifecycle/create-deferrals.js +2 -0
- package/dist/sdk/lifecycle/create.d.ts +6 -2
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/mutation-facet-contracts.js +1 -1
- package/dist/sdk/lifecycle/plan.js +1 -1
- package/dist/sdk/lifecycle/restore.js +1 -1
- package/dist/sdk/lifecycle/shared-unset-fields.d.ts +7 -1
- package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
- package/dist/sdk/linked-artifacts.d.ts +45 -3
- package/dist/sdk/linked-artifacts.js +2 -2
- package/dist/sdk/merge/three-way.d.ts +1 -1
- package/dist/sdk/merge/three-way.js +2 -2
- package/dist/sdk/output/table-rows.d.ts +28 -4
- package/dist/sdk/output/table-rows.js +1 -1
- package/dist/sdk/output.d.ts +1 -1
- package/dist/sdk/output.js +1 -1
- package/dist/sdk/package-import-adapters.d.ts +9 -1
- package/dist/sdk/package-import-adapters.js +1 -1
- package/dist/sdk/pagination.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/complete-list.d.ts +14 -5
- package/dist/sdk/query/complete-list.js +1 -1
- package/dist/sdk/query/list.js +1 -1
- package/dist/sdk/query/projection-contracts.d.ts +6 -0
- package/dist/sdk/query/projection-contracts.js +1 -1
- package/dist/sdk/read-output/continuation.js +1 -1
- package/dist/sdk/read-output/extension.js +1 -1
- package/dist/sdk/read-output-budget.js +1 -1
- package/dist/sdk/runtime-input.d.ts +6 -2
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime.d.ts +2 -2
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/structured-mutations.js +1 -1
- package/dist/sdk/test/batch.d.ts +5 -2
- package/dist/sdk/test/batch.js +2 -2
- package/dist/sdk/test/command-args.js +1 -1
- package/dist/sdk/test/entry.js +2 -2
- package/dist/sdk/test/execution.d.ts +10 -7
- package/dist/sdk/test/execution.js +2 -2
- package/dist/sdk/test/parsers.js +1 -1
- package/dist/sdk/test/prerequisites.d.ts +1 -1
- package/dist/sdk/test/prerequisites.js +1 -1
- package/dist/sdk/test/run-phases.d.ts +44 -0
- package/dist/sdk/test/run-phases.js +2 -0
- package/dist/sdk/testing.d.ts +15 -2
- package/dist/sdk/testing.js +1 -1
- package/dist/types.d.ts +11 -1
- package/dist/types.js +1 -1
- package/docs/AGENT_OUTPUT_ENCODINGS.md +16 -4
- package/docs/COMMANDS.md +31 -4
- package/docs/EXTENSIONS.md +1 -1
- package/docs/LINKED_TEST_EDITS.md +2 -1
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +6 -3
- package/docs/README.md +2 -2
- package/docs/READ_OUTPUT_CONTRACTS.md +23 -2
- package/docs/SDK.md +129 -6
- package/docs/TESTING.md +64 -1
- package/docs/WORKSPACE_CONCURRENCY.md +5 -1
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +9 -9
- package/marketplace.json +1 -1
- package/package.json +6 -4
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/extensions/calendar/command-definitions.ts +2 -0
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/extensions/todos/runtime.ts +3 -0
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/CHANGELOG.md +0 -4793
- package/dist/cli-bundle/chunks/chunk-36E4L2R4.js +0 -2
- package/dist/cli-bundle/chunks/chunk-4WD4CHVH.js +0 -8
- package/dist/cli-bundle/chunks/chunk-6UXBWMEM.js +0 -2
- package/dist/cli-bundle/chunks/chunk-CO7RWLCM.js +0 -2
- package/dist/cli-bundle/chunks/chunk-COTC2QOR.js +0 -6
- package/dist/cli-bundle/chunks/chunk-FAYX6C7H.js +0 -2
- package/dist/cli-bundle/chunks/chunk-GIAJX2QJ.js +0 -9
- package/dist/cli-bundle/chunks/chunk-HQINCDF6.js +0 -116
- package/dist/cli-bundle/chunks/chunk-IYDIPXBO.js +0 -2
- package/dist/cli-bundle/chunks/chunk-L4F4ZHGR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-O4ZLEN4T.js +0 -3
- package/dist/cli-bundle/chunks/chunk-O6PBQMD7.js +0 -2
- package/dist/cli-bundle/chunks/chunk-O6T24Z3M.js +0 -2
- package/dist/cli-bundle/chunks/chunk-OQCVU2SG.js +0 -8
- package/dist/cli-bundle/chunks/chunk-QSSENTXG.js +0 -20
- package/dist/cli-bundle/chunks/chunk-TCYIGAQG.js +0 -31
- package/dist/cli-bundle/chunks/chunk-URWNUZQZ.js +0 -3
- package/dist/cli-bundle/chunks/chunk-UYARS5XF.js +0 -3
- package/dist/cli-bundle/chunks/item-revision-G5OVYGZ5.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-I2X2P4TW.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-SET4KY73.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-WTHZHPOP.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-EZP3EG6A.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-THFZP23A.js +0 -2
- package/dist/cli-bundle/chunks/stage-JXJILTYE.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2ZPGEGTB.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3MB47JLT.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-5KTOMFLR.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-5NTLNE54.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-ADBFVDTG.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-CSKDIMQP.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-FNIX62V6.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-G6ERMFJ5.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-IYV3IPRF.js +0 -65
- package/dist/cli-bundle/focused-chunks/chunk-QGQJBQCH.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-RIMNSVFA.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-VGJDKDKA.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-VGUQ4V47.js +0 -82
- package/dist/cli-bundle/focused-chunks/chunk-VTOTZ5UC.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-WFVZ7GGR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZOGEQFGH.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-revision-IF7E7BVY.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-5TFWIOXI.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-KELM46JF.js +0 -2
- package/dist/cli-bundle/focused-chunks/stage-UAKMQTCI.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0f06f072-47a7-560e-9291-72e47225a73c")}catch{}})();import{appendHistoryEntry,createHistoryEntry}from"../core/history/history.js";import{acquireLock}from"../core/lock/lock.js";import{enforceWorkflowMutation}from"../core/policy/workflow-policy-store.js";import{parseTags}from"../core/item/parse.js";import{normalizeStatusInput}from"../core/item/status.js";import{serializeItemDocument}from"../core/item/item-format.js";import{getHistoryPath}from"../core/store/paths.js";import{removeFileIfExists,writeFileAtomic}from"../core/fs/fs-utils.js";import{runActiveOnWriteHooks}from"../core/extensions/index.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{resolveAuthor}from"../core/shared/author.js";import{nowIso}from"../core/shared/time.js";import{assertInitializedTracker}from"./environment/tracker-preflight.js";function toNonEmptyImportString(value){if(typeof value!="string")return;const trimmed=value.trim();return trimmed.length>0?trimmed:void 0}function toEstimatedMinutesValue(value){if(typeof value=="number"&&Number.isFinite(value)&&value>=0)return value;if(typeof value=="string"&&value.trim().length>0){const parsed=Number(value);if(Number.isFinite(parsed)&&parsed>=0)return parsed}}function toImportPriority(value){if(typeof value=="number"&&Number.isInteger(value)&&value>=0&&value<=4)return value;if(typeof value=="string"&&value.trim().length>0){const parsed=Number(value);if(Number.isInteger(parsed)&&parsed>=0&&parsed<=4)return parsed}return 2}function toImportTags(value){if(Array.isArray(value)){const tags=value.filter(entry=>typeof entry=="string").map(entry=>entry.trim().toLowerCase()).filter(entry=>entry.length>0);return Array.from(new Set(tags)).sort((left,right)=>left.localeCompare(right))}return typeof value=="string"?parseTags(value):[]}function toImportStatus(value){const normalized=toNonEmptyImportString(value);if(normalized){const canonical=normalizeStatusInput(normalized);if(canonical)return canonical}return"open"}function toImportInteger(value){if(typeof value=="number"&&Number.isInteger(value))return value;if(typeof value!="string"||value.trim().length===0)return;const parsed=Number(value);return Number.isInteger(parsed)?parsed:void 0}function toImportBoolean(value){if(typeof value=="boolean")return value;if(typeof value=="number")return value===1?!0:value===0?!1:void 0;if(typeof value!="string")return;const normalized=value.trim().toLowerCase();return normalized==="true"||normalized==="1"?!0:normalized==="false"||normalized==="0"?!1:void 0}function toImportStringList(value){if(!Array.isArray(value))return;const entries=value.map(entry=>toNonEmptyImportString(entry)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportStringMap(value){return toImportValueMap(value,toNonEmptyImportString)}function toImportNumberMap(value){return toImportValueMap(value,toImportFiniteNumber)}function toImportConfidence(value,allowedTextValues){if(typeof value=="number"&&Number.isInteger(value)&&value>=0&&value<=100)return value;const normalized=toNonEmptyImportString(value)?.toLowerCase();if(!normalized)return;const candidate=normalized==="med"?"medium":normalized;if(allowedTextValues.some(entry=>entry===candidate))return candidate;const parsed=Number(candidate);return Number.isInteger(parsed)&&parsed>=0&&parsed<=100?parsed:void 0}function toImportNormalizedEnum(value,allowed){const normalized=toNonEmptyImportString(value)?.toLowerCase();if(!normalized)return;const candidate=normalized==="med"?"medium":normalized;return allowed.includes(candidate)?candidate:void 0}function toImportLinkScope(value){return toNonEmptyImportString(value)?.toLowerCase()==="global"?"global":"project"}function toImportLogEntries(value,options){const values=normalizeImportCollection(value,options.allowScalar===!0);if(!values)return;const entries=values.map(entry=>toImportLogEntry(entry,options)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportLinkedFiles(value,options={}){return toImportLinkedArtifacts(value,options,(pathValue,record)=>({path:pathValue,scope:toImportLinkScope(record?.scope),note:toNonEmptyImportString(record?.note)}))}function toImportLinkedDocs(value,options={}){return toImportLinkedArtifacts(value,options,(pathValue,record)=>({path:pathValue,scope:toImportLinkScope(record?.scope),note:toNonEmptyImportString(record?.note)}))}function toImportLinkedTests(value,options={}){const values=normalizeImportCollection(value,options.allowScalar===!0);if(!values)return;const entries=values.map(entry=>toImportLinkedTest(entry,options)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function selectImportAuthor(explicitAuthor,settingsAuthor){return resolveAuthor(explicitAuthor,settingsAuthor)}function isImportRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function normalizeImportCollection(value,allowScalar){return Array.isArray(value)?value:allowScalar?[value]:void 0}function firstNonEmptyImportString(record,keys){for(const key of keys){const value=toNonEmptyImportString(record[key]);if(value)return value}}function toImportValueMap(value,coerce){if(!isImportRecord(value))return;const entries=Object.entries(value).map(([key,entryValue])=>[key.trim(),coerce(entryValue)]).filter(entry=>entry[0].length>0&&entry[1]!==void 0);return entries.length>0?Object.fromEntries(entries):void 0}function toImportLogEntry(entry,options){if(typeof entry=="string")return toImportLogEntryFromText(entry,options);if(!isImportRecord(entry))return;const text=firstNonEmptyImportString(entry,options.textKeys??["text"]);if(!text)return;const createdAtKey=options.createdAtKey??"created_at",authorKey=options.authorKey??"author";return{created_at:(options.toIsoString?options.toIsoString(entry[createdAtKey]):toNonEmptyImportString(entry[createdAtKey]))??options.fallbackCreatedAt,author:toNonEmptyImportString(entry[authorKey])??options.fallbackAuthor,text}}function toImportLogEntryFromText(entry,options){const text=toNonEmptyImportString(entry);return text?{created_at:options.fallbackCreatedAt,author:options.fallbackAuthor,text}:void 0}function toImportLinkedArtifacts(value,options,build){const values=normalizeImportCollection(value,options.allowScalar===!0);if(!values)return;const pathKeys=options.pathKeys??["path"],entries=values.map(entry=>toImportLinkedArtifact(entry,pathKeys,build)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportLinkedArtifact(entry,pathKeys,build){if(typeof entry=="string"){const pathValue2=toNonEmptyImportString(entry);return pathValue2?build(pathValue2):void 0}if(!isImportRecord(entry))return;const pathValue=firstNonEmptyImportString(entry,pathKeys);return pathValue?build(pathValue,entry):void 0}function toImportLinkedTest(entry,options){if(typeof entry=="string"){const command2=toNonEmptyImportString(entry);return command2?{command:command2,scope:"project"}:void 0}if(!isImportRecord(entry))return;const command=firstNonEmptyImportString(entry,options.commandKeys??["command"]),testPath=firstNonEmptyImportString(entry,options.pathKeys??["path"]);if(!(!command&&(options.requireCommand===!0||!testPath)))return{...command?{command}:{},...testPath?{path:testPath}:{},scope:toImportLinkScope(entry.scope),timeout_seconds:toImportLinkedTestTimeout(entry.timeout_seconds,options),note:toNonEmptyImportString(entry.note),...options.includeExtendedAssertions===!0?toImportLinkedTestAssertions(entry):{}}}function toImportLinkedTestTimeout(value,options){const parsed=options.integerTimeout===!0?toImportInteger(value):toImportFiniteNumber(value);if(parsed===void 0)return;const minimum=options.timeoutMinimum??0;return options.timeoutExclusiveMinimum===!0?parsed>minimum?parsed:void 0:parsed>=minimum?parsed:void 0}function toImportFiniteNumber(value){if(typeof value=="number"&&Number.isFinite(value))return value;if(typeof value!="string"||value.trim().length===0)return;const parsed=Number(value);return Number.isFinite(parsed)?parsed:void 0}function toImportLinkedTestAssertions(entry){return{pm_context_mode:toImportNormalizedEnum(entry.pm_context_mode,["schema","tracker","auto"]),env_set:toImportStringMap(entry.env_set),env_clear:toImportStringList(entry.env_clear),shared_host_safe:toImportBoolean(entry.shared_host_safe),assert_stdout_contains:toImportStringList(entry.assert_stdout_contains),assert_stdout_regex:toImportStringList(entry.assert_stdout_regex),assert_stderr_contains:toImportStringList(entry.assert_stderr_contains),assert_stderr_regex:toImportStringList(entry.assert_stderr_regex),assert_stdout_min_lines:toImportInteger(entry.assert_stdout_min_lines),assert_json_field_equals:toImportStringMap(entry.assert_json_field_equals),assert_json_field_gte:toImportNumberMap(entry.assert_json_field_gte)}}async function ensureTrackerInitialized(pmRoot){await assertInitializedTracker(pmRoot)}function emptyImportedDocument(){return{metadata:{},body:""}}async function commitImportedItem(params){const{pmRoot,id,itemPath,document,author,message,settings,conflictWarningPrefix}=params,historyPath=getHistoryPath(pmRoot,id),beforeDocument=emptyImportedDocument();try{const releaseLock=await acquireLock(pmRoot,id,settings.locks.ttl_seconds,author,!1,settings.governance.force_required_for_stale_lock,settings.locks.wait_ms);try{const workflowPolicy=await enforceWorkflowMutation({pmRoot,settings,operation:"import",author,before:null,after:document});await writeFileAtomic(itemPath,serializeItemDocument(document,{format:"toon"}));try{const entry=createHistoryEntry({nowIso:nowIso(),author,op:"import",before:beforeDocument,after:document,message,context:workflowPolicy.decisions.length===0?void 0:{workflow_policies:workflowPolicy.decisions}});return await appendHistoryEntry(historyPath,entry),{committed:!0,writeWarnings:[...workflowPolicy.warnings,...await runActiveOnWriteHooks({path:itemPath,scope:"project",op:"import",item_id:document.metadata.id,item_type:document.metadata.type,before:beforeDocument,after:document,changed_fields:["imported"]}),...await runActiveOnWriteHooks({path:historyPath,scope:"project",op:"import:history",item_id:document.metadata.id,item_type:document.metadata.type,before:beforeDocument,after:document,changed_fields:["imported"]})]}}catch(error){throw await removeFileIfExists(itemPath),error}}finally{await releaseLock()}}catch(error){if(error instanceof PmCliError&&error.exitCode===EXIT_CODE.CONFLICT&&!error.code?.startsWith("workflow_policy_"))return{committed:!1,conflictWarning:`${conflictWarningPrefix}:${id}`};throw error}}export{commitImportedItem,emptyImportedDocument,ensureTrackerInitialized,selectImportAuthor,toEstimatedMinutesValue,toImportBoolean,toImportConfidence,toImportInteger,toImportLinkScope,toImportLinkedDocs,toImportLinkedFiles,toImportLinkedTests,toImportLogEntries,toImportNormalizedEnum,toImportNumberMap,toImportPriority,toImportStatus,toImportStringList,toImportStringMap,toImportTags,toNonEmptyImportString};
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="67429334-089f-5cc0-9d73-533fed16b53a")}catch{}})();import{appendHistoryEntry,createHistoryEntry}from"../core/history/history.js";import{acquireLock}from"../core/lock/lock.js";import{enforceWorkflowMutation}from"../core/policy/workflow-policy-store.js";import{parseTags}from"../core/item/parse.js";import{normalizeStatusInput}from"../core/item/status.js";import{canonicalDocument,serializeItemDocument}from"../core/item/item-format.js";import{deferrableItemFieldByKey,normalizeDeferredFields,pruneResolvedDeferredFields}from"../core/item/deferred-fields.js";import{getHistoryPath}from"../core/store/paths.js";import{removeFileIfExists,writeFileAtomic}from"../core/fs/fs-utils.js";import{getActiveExtensionRegistrations,runActiveBeforeMutationHooks,runActiveOnWriteHooks}from"../core/extensions/index.js";import{createMutationGuardSdk}from"../core/store/item-store.js";import{resolveItemTypeRegistry}from"../core/item/type-registry.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{resolveAuthor}from"../core/shared/author.js";import{nowIso}from"../core/shared/time.js";import{assertInitializedTracker}from"./environment/tracker-preflight.js";import{stampRequiredItemFormat}from"./environment/project-runtime-compatibility.js";function toNonEmptyImportString(value){if(typeof value!="string")return;const trimmed=value.trim();return trimmed.length>0?trimmed:void 0}function toEstimatedMinutesValue(value){if(typeof value=="number"&&Number.isFinite(value)&&value>=0)return value;if(typeof value=="string"&&value.trim().length>0){const parsed=Number(value);if(Number.isFinite(parsed)&&parsed>=0)return parsed}}function toImportPriority(value){if(typeof value=="number"&&Number.isInteger(value)&&value>=0&&value<=4)return value;if(typeof value=="string"&&value.trim().length>0){const parsed=Number(value);if(Number.isInteger(parsed)&&parsed>=0&&parsed<=4)return parsed}return 2}function toImportTags(value){if(Array.isArray(value)){const tags=value.filter(entry=>typeof entry=="string").map(entry=>entry.trim().toLowerCase()).filter(entry=>entry.length>0);return Array.from(new Set(tags)).sort((left,right)=>left.localeCompare(right))}return typeof value=="string"?parseTags(value):[]}function toImportStatus(value){const normalized=toNonEmptyImportString(value);if(normalized){const canonical=normalizeStatusInput(normalized);if(canonical)return canonical}return"open"}function toImportInteger(value){if(typeof value=="number"&&Number.isInteger(value))return value;if(typeof value!="string"||value.trim().length===0)return;const parsed=Number(value);return Number.isInteger(parsed)?parsed:void 0}function toImportBoolean(value){if(typeof value=="boolean")return value;if(typeof value=="number")return value===1?!0:value===0?!1:void 0;if(typeof value!="string")return;const normalized=value.trim().toLowerCase();return normalized==="true"||normalized==="1"?!0:normalized==="false"||normalized==="0"?!1:void 0}function toImportStringList(value){if(!Array.isArray(value))return;const entries=value.map(entry=>toNonEmptyImportString(entry)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportStringMap(value){return toImportValueMap(value,toNonEmptyImportString)}function toImportNumberMap(value){return toImportValueMap(value,toImportFiniteNumber)}function toImportConfidence(value,allowedTextValues){if(typeof value=="number"&&Number.isInteger(value)&&value>=0&&value<=100)return value;const normalized=toNonEmptyImportString(value)?.toLowerCase();if(!normalized)return;const candidate=normalized==="med"?"medium":normalized;if(allowedTextValues.some(entry=>entry===candidate))return candidate;const parsed=Number(candidate);return Number.isInteger(parsed)&&parsed>=0&&parsed<=100?parsed:void 0}function toImportNormalizedEnum(value,allowed){const normalized=toNonEmptyImportString(value)?.toLowerCase();if(!normalized)return;const candidate=normalized==="med"?"medium":normalized;return allowed.includes(candidate)?candidate:void 0}function toImportLinkScope(value){return toNonEmptyImportString(value)?.toLowerCase()==="global"?"global":"project"}function toImportLogEntries(value,options){const values=normalizeImportCollection(value,options.allowScalar===!0);if(!values)return;const entries=values.map(entry=>toImportLogEntry(entry,options)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportLinkedFiles(value,options={}){return toImportLinkedArtifacts(value,options,(pathValue,record)=>({path:pathValue,scope:toImportLinkScope(record?.scope),note:toNonEmptyImportString(record?.note)}))}function toImportLinkedDocs(value,options={}){return toImportLinkedArtifacts(value,options,(pathValue,record)=>({path:pathValue,scope:toImportLinkScope(record?.scope),note:toNonEmptyImportString(record?.note)}))}function toImportDeferredFields(value){const entries=(Array.isArray(value)?value:[]).filter(entry=>typeof entry=="object"&&entry!==null&&!Array.isArray(entry)&&typeof entry.field=="string"&&deferrableItemFieldByKey(entry.field)!==void 0&&typeof entry.reason=="string"&&entry.reason.trim().length>0),byField=new Map(entries.map(entry=>[entry.field,{field:entry.field,reason:entry.reason}]));return normalizeDeferredFields([...byField.values()])}function toImportLinkedTests(value,options={}){const values=normalizeImportCollection(value,options.allowScalar===!0);if(!values)return;const entries=values.map(entry=>toImportLinkedTest(entry,options)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function selectImportAuthor(explicitAuthor,settingsAuthor){return resolveAuthor(explicitAuthor,settingsAuthor)}function isImportRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function normalizeImportCollection(value,allowScalar){return Array.isArray(value)?value:allowScalar?[value]:void 0}function firstNonEmptyImportString(record,keys){for(const key of keys){const value=toNonEmptyImportString(record[key]);if(value)return value}}function toImportValueMap(value,coerce){if(!isImportRecord(value))return;const entries=Object.entries(value).map(([key,entryValue])=>[key.trim(),coerce(entryValue)]).filter(entry=>entry[0].length>0&&entry[1]!==void 0);return entries.length>0?Object.fromEntries(entries):void 0}function toImportLogEntry(entry,options){if(typeof entry=="string")return toImportLogEntryFromText(entry,options);if(!isImportRecord(entry))return;const text=firstNonEmptyImportString(entry,options.textKeys??["text"]);if(!text)return;const createdAtKey=options.createdAtKey??"created_at",authorKey=options.authorKey??"author";return{created_at:(options.toIsoString?options.toIsoString(entry[createdAtKey]):toNonEmptyImportString(entry[createdAtKey]))??options.fallbackCreatedAt,author:toNonEmptyImportString(entry[authorKey])??options.fallbackAuthor,text}}function toImportLogEntryFromText(entry,options){const text=toNonEmptyImportString(entry);return text?{created_at:options.fallbackCreatedAt,author:options.fallbackAuthor,text}:void 0}function toImportLinkedArtifacts(value,options,build){const values=normalizeImportCollection(value,options.allowScalar===!0);if(!values)return;const pathKeys=options.pathKeys??["path"],entries=values.map(entry=>toImportLinkedArtifact(entry,pathKeys,build)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportLinkedArtifact(entry,pathKeys,build){if(typeof entry=="string"){const pathValue2=toNonEmptyImportString(entry);return pathValue2?build(pathValue2):void 0}if(!isImportRecord(entry))return;const pathValue=firstNonEmptyImportString(entry,pathKeys);return pathValue?build(pathValue,entry):void 0}function toImportLinkedTest(entry,options){if(typeof entry=="string"){const command2=toNonEmptyImportString(entry);return command2?{command:command2,scope:"project"}:void 0}if(!isImportRecord(entry))return;const command=firstNonEmptyImportString(entry,options.commandKeys??["command"]),testPath=firstNonEmptyImportString(entry,options.pathKeys??["path"]);if(!(!command&&(options.requireCommand===!0||!testPath)))return{...command?{command}:{},...testPath?{path:testPath}:{},scope:toImportLinkScope(entry.scope),timeout_seconds:toImportLinkedTestTimeout(entry.timeout_seconds,options),note:toNonEmptyImportString(entry.note),...typeof entry.phase=="string"&&entry.phase.trim().toLowerCase()==="setup"?{phase:"setup"}:{},...options.includeExtendedAssertions===!0?toImportLinkedTestAssertions(entry):{}}}function toImportLinkedTestTimeout(value,options){const parsed=options.integerTimeout===!0?toImportInteger(value):toImportFiniteNumber(value);if(parsed===void 0)return;const minimum=options.timeoutMinimum??0;return options.timeoutExclusiveMinimum===!0?parsed>minimum?parsed:void 0:parsed>=minimum?parsed:void 0}function toImportFiniteNumber(value){if(typeof value=="number"&&Number.isFinite(value))return value;if(typeof value!="string"||value.trim().length===0)return;const parsed=Number(value);return Number.isFinite(parsed)?parsed:void 0}function toImportLinkedTestAssertions(entry){return{pm_context_mode:toImportNormalizedEnum(entry.pm_context_mode,["schema","tracker","auto"]),env_set:toImportStringMap(entry.env_set),env_clear:toImportStringList(entry.env_clear),shared_host_safe:toImportBoolean(entry.shared_host_safe),assert_stdout_contains:toImportStringList(entry.assert_stdout_contains),assert_stdout_regex:toImportStringList(entry.assert_stdout_regex),assert_stderr_contains:toImportStringList(entry.assert_stderr_contains),assert_stderr_regex:toImportStringList(entry.assert_stderr_regex),assert_stdout_min_lines:toImportInteger(entry.assert_stdout_min_lines),assert_json_field_equals:toImportStringMap(entry.assert_json_field_equals),assert_json_field_gte:toImportNumberMap(entry.assert_json_field_gte)}}async function ensureTrackerInitialized(pmRoot){await assertInitializedTracker(pmRoot)}function emptyImportedDocument(){return{metadata:{},body:""}}function importedChangedFields(document){return[...Object.entries(document.metadata).filter(([,value])=>value!==void 0).map(([key])=>key),...document.body.length>0?["body"]:[]].sort()}async function commitImportedItem(params){const{pmRoot,id,itemPath,author,message,settings,conflictWarningPrefix}=params,stamped={...params.document,metadata:{...params.document.metadata}};pruneResolvedDeferredFields(stamped.metadata),stampRequiredItemFormat(stamped.metadata,pmRoot);const document=canonicalDocument(stamped),historyPath=getHistoryPath(pmRoot,id),beforeDocument=emptyImportedDocument();let releaseLock;try{releaseLock=await acquireLock(pmRoot,id,settings.locks.ttl_seconds,author,!1,settings.governance.force_required_for_stale_lock,settings.locks.wait_ms)}catch(error){if(error instanceof PmCliError&&error.exitCode===EXIT_CODE.CONFLICT)return{committed:!1,conflictWarning:`${conflictWarningPrefix}:${id}`};throw error}try{const workflowPolicy=await enforceWorkflowMutation({pmRoot,settings,operation:"import",author,before:null,after:document});await runActiveBeforeMutationHooks({pm_root:pmRoot,operation:"import",before:null,after:document,changed_fields:importedChangedFields(document),author,sdk:createMutationGuardSdk({pmRoot,settings,typeToFolder:resolveItemTypeRegistry(settings,getActiveExtensionRegistrations()).type_to_folder})}),await writeFileAtomic(itemPath,serializeItemDocument(document,{format:"toon"}));try{const entry=createHistoryEntry({nowIso:nowIso(),author,op:"import",before:beforeDocument,after:document,message,context:workflowPolicy.decisions.length===0?void 0:{workflow_policies:workflowPolicy.decisions}});return await appendHistoryEntry(historyPath,entry),{committed:!0,writeWarnings:[...workflowPolicy.warnings,...await runActiveOnWriteHooks({path:itemPath,scope:"project",op:"import",item_id:document.metadata.id,item_type:document.metadata.type,before:beforeDocument,after:document,changed_fields:["imported"]}),...await runActiveOnWriteHooks({path:historyPath,scope:"project",op:"import:history",item_id:document.metadata.id,item_type:document.metadata.type,before:beforeDocument,after:document,changed_fields:["imported"]})]}}catch(error){throw await removeFileIfExists(itemPath),error}}finally{await releaseLock()}}export{commitImportedItem,emptyImportedDocument,ensureTrackerInitialized,selectImportAuthor,toEstimatedMinutesValue,toImportBoolean,toImportConfidence,toImportDeferredFields,toImportInteger,toImportLinkScope,toImportLinkedDocs,toImportLinkedFiles,toImportLinkedTests,toImportLogEntries,toImportNormalizedEnum,toImportNumberMap,toImportPriority,toImportStatus,toImportStringList,toImportStringMap,toImportTags,toNonEmptyImportString};
|
|
2
2
|
//# sourceMappingURL=package-import-adapters.js.map
|
package/dist/sdk/pagination.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9c5d8732-3e10-5224-a558-e870397090f2")}catch{}})();import{READ_OUTPUT_DIMENSION_FLAGS,READ_OUTPUT_COMPOSITION_FLAGS}from"./read-output/options.js";import{createHash}from"node:crypto";import{PmCliError}from"../core/shared/errors.js";import{EXIT_CODE}from"../core/shared/constants.js";import{stableStringify}from"../core/shared/serialization.js";import{isCompactedCursorArgument}from"../core/shared/text-normalization.js";import{decodeReadOutputContinuationCursor}from"./read-output/continuation.js";const QUERY_CURSOR_VERSION=1,MAX_CURSOR_LENGTH=4096,BASE64URL_PATTERN=/^[A-Za-z0-9_-]+$/;function optionKeyForFlag(flag){return flag.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(_,character)=>character.toUpperCase())}function selectCursorSemanticOptions(options,contracts){const universalFlags=[...Object.values(READ_OUTPUT_DIMENSION_FLAGS),...READ_OUTPUT_COMPOSITION_FLAGS],presentationKeys=new Set(universalFlags.flatMap(flag=>[optionKeyForFlag(flag),flag.slice(2).replaceAll("-","_")]));for(const contract of contracts)if(contract.cursor_semantics==="presentation"){presentationKeys.add(optionKeyForFlag(contract.flag));for(const alias of contract.aliases??[])presentationKeys.add(optionKeyForFlag(alias))}return Object.fromEntries(Object.entries(options).filter(([key])=>!presentationKeys.has(key)))}function createQueryFingerprint(command,contract){return createHash("sha256").update(command).update("\0").update(stableStringify(contract)).digest("hex").slice(0,24)}function encodeQueryCursor(fingerprint,afterId,afterIndex,snapshot){return Buffer.from(JSON.stringify({version:QUERY_CURSOR_VERSION,fingerprint,after_id:afterId,...afterIndex===void 0?{}:{after_index:afterIndex},...snapshot===void 0?{}:{snapshot}})).toString("base64url")}function invalidCursor(message,cursorFlag){return new PmCliError(message,EXIT_CODE.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${cursorFlag} to obtain a fresh cursor.`]})}function compactedCursor(cursorFlag){return new PmCliError("Query cursor was shortened by output compaction: it contains an ellipsis, which no cursor encoder emits.",EXIT_CODE.USAGE,{code:"invalid_query_cursor",reason:"cursor_compacted",required:"Pass the whole cursor the previous page emitted; a shortened cursor cannot resume the query.",nextSteps:[`Re-read the previous page with a larger --output-budget (or --output-budget unbounded) and pass its whole next_cursor to ${cursorFlag}.`,`Or repeat the original query without ${cursorFlag} to obtain a fresh cursor.`]})}function isQueryCursorEnvelope(value){if(typeof value!="object"||value===null||Array.isArray(value))return!1;const envelope=value;return envelope.version===QUERY_CURSOR_VERSION&&typeof envelope.fingerprint=="string"&&typeof envelope.after_id=="string"&&envelope.after_id.length>0&&(envelope.after_index===void 0||Number.isSafeInteger(envelope.after_index)&&envelope.after_index>=0)&&(envelope.snapshot===void 0||typeof envelope.snapshot=="string"&&envelope.snapshot.length>0)}function decodeQueryCursorEnvelope(cursor,cursorFlag="--after"){if(typeof cursor!="string")throw invalidCursor("Query cursor is malformed.",cursorFlag);const normalized=cursor.trim();if(isCompactedCursorArgument(normalized))throw compactedCursor(cursorFlag);if(normalized.length===0||normalized.length>MAX_CURSOR_LENGTH||!BASE64URL_PATTERN.test(normalized))throw invalidCursor("Query cursor is malformed.",cursorFlag);let parsed;try{parsed=JSON.parse(Buffer.from(normalized,"base64url").toString("utf8"))}catch{throw invalidCursor("Query cursor is malformed.",cursorFlag)}if(!isQueryCursorEnvelope(parsed)){let outputCursor=!1;try{decodeReadOutputContinuationCursor(normalized),outputCursor=!0}catch{}throw outputCursor?new PmCliError(`An output cursor must be continued with --output-cursor, not ${cursorFlag}.`,EXIT_CODE.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${cursorFlag} with --output-cursor ${normalized}; retain any producer ${cursorFlag} cursor from the original page.`]}):invalidCursor("Query cursor version or payload is unsupported.",cursorFlag)}return parsed}function decodeQueryCursorState(cursor,expectedFingerprint,cursorFlag="--after"){const envelope=decodeQueryCursorEnvelope(cursor,cursorFlag);if(envelope.fingerprint!==expectedFingerprint)throw invalidCursor(`Query cursor does not match the current filters, sort, or query (${envelope.fingerprint} != ${expectedFingerprint}).`,cursorFlag);return{after_id:envelope.after_id,...envelope.after_index===void 0?{}:{after_index:envelope.after_index},...envelope.snapshot===void 0?{}:{snapshot:envelope.snapshot}}}function decodeQueryCursor(cursor,expectedFingerprint){return decodeQueryCursorState(cursor,expectedFingerprint).after_id}function resolveQueryCursorStart(rows,cursor,fingerprint,readId,cursorFlag="--after"){if(cursor===void 0)return 0;const state=decodeQueryCursorState(cursor,fingerprint,cursorFlag),index=rows.findIndex(row=>readId(row)===state.after_id);if(index<0){if(state.after_index!==void 0)return Math.min(state.after_index,rows.length);throw invalidCursor(`Query cursor item ${state.after_id} is no longer present in this result set.`,cursorFlag)}return index+1}function paginateQueryRows(rows,options){if(options.cursor!==void 0&&decodeQueryCursorState(options.cursor,options.fingerprint).snapshot!==options.snapshot)throw invalidCursor("Query cursor does not match the requested snapshot.","--after");const pageStart=resolveQueryCursorStart(rows,options.cursor,options.fingerprint,options.readId),pageRows=rows.slice(pageStart,pageStart+options.limit),hasMore=pageRows.length>0&&pageStart+pageRows.length<rows.length,lastRow=pageRows.at(-1);return{rows:pageRows,has_more:hasMore,...hasMore&&lastRow!==void 0?{next_cursor:encodeQueryCursor(options.fingerprint,options.readId(lastRow),pageStart+pageRows.length-1,options.snapshot)}:{}}}const QUERY_CURSOR_CONTRACT=Object.freeze({version:QUERY_CURSOR_VERSION,max_length:MAX_CURSOR_LENGTH});export{QUERY_CURSOR_CONTRACT,createQueryFingerprint,decodeQueryCursor,decodeQueryCursorEnvelope,decodeQueryCursorState,encodeQueryCursor,paginateQueryRows,resolveQueryCursorStart,selectCursorSemanticOptions};
|
|
2
2
|
//# sourceMappingURL=pagination.js.map
|