figma-inspect-cli 0.1.0
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 +156 -0
- package/dist/bin/figma-inspect.d.ts +3 -0
- package/dist/bin/figma-inspect.d.ts.map +1 -0
- package/dist/bin/figma-inspect.js +19 -0
- package/dist/bin/figma-inspect.js.map +1 -0
- package/dist/cli/errors.d.ts +3 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/errors.js +3 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/export-component-set.d.ts +21 -0
- package/dist/cli/export-component-set.d.ts.map +1 -0
- package/dist/cli/export-component-set.js +173 -0
- package/dist/cli/export-component-set.js.map +1 -0
- package/dist/cli/export-contract.d.ts +20 -0
- package/dist/cli/export-contract.d.ts.map +1 -0
- package/dist/cli/export-contract.js +48 -0
- package/dist/cli/export-contract.js.map +1 -0
- package/dist/cli/export-node-contract.d.ts +17 -0
- package/dist/cli/export-node-contract.d.ts.map +1 -0
- package/dist/cli/export-node-contract.js +93 -0
- package/dist/cli/export-node-contract.js.map +1 -0
- package/dist/cli/export-result.d.ts +17 -0
- package/dist/cli/export-result.d.ts.map +1 -0
- package/dist/cli/export-result.js +22 -0
- package/dist/cli/export-result.js.map +1 -0
- package/dist/cli/export-team-index.d.ts +18 -0
- package/dist/cli/export-team-index.d.ts.map +1 -0
- package/dist/cli/export-team-index.js +121 -0
- package/dist/cli/export-team-index.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/output.d.ts +13 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +26 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/parse-args.d.ts +3 -0
- package/dist/cli/parse-args.d.ts.map +1 -0
- package/dist/cli/parse-args.js +790 -0
- package/dist/cli/parse-args.js.map +1 -0
- package/dist/cli/run-cli.d.ts +3 -0
- package/dist/cli/run-cli.d.ts.map +1 -0
- package/dist/cli/run-cli.js +416 -0
- package/dist/cli/run-cli.js.map +1 -0
- package/dist/cli/types.d.ts +114 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/usage.d.ts +2 -0
- package/dist/cli/usage.d.ts.map +1 -0
- package/dist/cli/usage.js +75 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/figma-api/cache/cached-request.d.ts +8 -0
- package/dist/figma-api/cache/cached-request.d.ts.map +1 -0
- package/dist/figma-api/cache/cached-request.js +100 -0
- package/dist/figma-api/cache/cached-request.js.map +1 -0
- package/dist/figma-api/cache/constants.d.ts +5 -0
- package/dist/figma-api/cache/constants.d.ts.map +1 -0
- package/dist/figma-api/cache/constants.js +5 -0
- package/dist/figma-api/cache/constants.js.map +1 -0
- package/dist/figma-api/cache/extract-metadata.d.ts +3 -0
- package/dist/figma-api/cache/extract-metadata.d.ts.map +1 -0
- package/dist/figma-api/cache/extract-metadata.js +13 -0
- package/dist/figma-api/cache/extract-metadata.js.map +1 -0
- package/dist/figma-api/cache/index.d.ts +3 -0
- package/dist/figma-api/cache/index.d.ts.map +1 -0
- package/dist/figma-api/cache/index.js +3 -0
- package/dist/figma-api/cache/index.js.map +1 -0
- package/dist/figma-api/cache/store.d.ts +10 -0
- package/dist/figma-api/cache/store.d.ts.map +1 -0
- package/dist/figma-api/cache/store.js +53 -0
- package/dist/figma-api/cache/store.js.map +1 -0
- package/dist/figma-api/cache/types.d.ts +20 -0
- package/dist/figma-api/cache/types.d.ts.map +1 -0
- package/dist/figma-api/cache/types.js +2 -0
- package/dist/figma-api/cache/types.js.map +1 -0
- package/dist/figma-api/cache/url.d.ts +5 -0
- package/dist/figma-api/cache/url.d.ts.map +1 -0
- package/dist/figma-api/cache/url.js +20 -0
- package/dist/figma-api/cache/url.js.map +1 -0
- package/dist/figma-api/constants.d.ts +2 -0
- package/dist/figma-api/constants.d.ts.map +1 -0
- package/dist/figma-api/constants.js +2 -0
- package/dist/figma-api/constants.js.map +1 -0
- package/dist/figma-api/fetch-with-retry.d.ts +2 -0
- package/dist/figma-api/fetch-with-retry.d.ts.map +1 -0
- package/dist/figma-api/fetch-with-retry.js +48 -0
- package/dist/figma-api/fetch-with-retry.js.map +1 -0
- package/dist/figma-api/figma-api-error.d.ts +4 -0
- package/dist/figma-api/figma-api-error.d.ts.map +1 -0
- package/dist/figma-api/figma-api-error.js +7 -0
- package/dist/figma-api/figma-api-error.js.map +1 -0
- package/dist/figma-api/figma-request.d.ts +2 -0
- package/dist/figma-api/figma-request.d.ts.map +1 -0
- package/dist/figma-api/figma-request.js +21 -0
- package/dist/figma-api/figma-request.js.map +1 -0
- package/dist/figma-api/format-figma-error.d.ts +2 -0
- package/dist/figma-api/format-figma-error.d.ts.map +1 -0
- package/dist/figma-api/format-figma-error.js +24 -0
- package/dist/figma-api/format-figma-error.js.map +1 -0
- package/dist/figma-api/get-component-set.d.ts +4 -0
- package/dist/figma-api/get-component-set.d.ts.map +1 -0
- package/dist/figma-api/get-component-set.js +8 -0
- package/dist/figma-api/get-component-set.js.map +1 -0
- package/dist/figma-api/get-file-images.d.ts +4 -0
- package/dist/figma-api/get-file-images.d.ts.map +1 -0
- package/dist/figma-api/get-file-images.js +45 -0
- package/dist/figma-api/get-file-images.js.map +1 -0
- package/dist/figma-api/get-file-node.d.ts +3 -0
- package/dist/figma-api/get-file-node.d.ts.map +1 -0
- package/dist/figma-api/get-file-node.js +8 -0
- package/dist/figma-api/get-file-node.js.map +1 -0
- package/dist/figma-api/get-file.d.ts +3 -0
- package/dist/figma-api/get-file.d.ts.map +1 -0
- package/dist/figma-api/get-file.js +6 -0
- package/dist/figma-api/get-file.js.map +1 -0
- package/dist/figma-api/index.d.ts +11 -0
- package/dist/figma-api/index.d.ts.map +1 -0
- package/dist/figma-api/index.js +11 -0
- package/dist/figma-api/index.js.map +1 -0
- package/dist/figma-api/list-file-component-sets.d.ts +4 -0
- package/dist/figma-api/list-file-component-sets.d.ts.map +1 -0
- package/dist/figma-api/list-file-component-sets.js +8 -0
- package/dist/figma-api/list-file-component-sets.js.map +1 -0
- package/dist/figma-api/list-file-components.d.ts +5 -0
- package/dist/figma-api/list-file-components.d.ts.map +1 -0
- package/dist/figma-api/list-file-components.js +13 -0
- package/dist/figma-api/list-file-components.js.map +1 -0
- package/dist/figma-api/list-file-pages.d.ts +4 -0
- package/dist/figma-api/list-file-pages.d.ts.map +1 -0
- package/dist/figma-api/list-file-pages.js +10 -0
- package/dist/figma-api/list-file-pages.js.map +1 -0
- package/dist/figma-api/list-project-files.d.ts +4 -0
- package/dist/figma-api/list-project-files.d.ts.map +1 -0
- package/dist/figma-api/list-project-files.js +8 -0
- package/dist/figma-api/list-project-files.js.map +1 -0
- package/dist/figma-api/list-team-component-sets.d.ts +4 -0
- package/dist/figma-api/list-team-component-sets.d.ts.map +1 -0
- package/dist/figma-api/list-team-component-sets.js +19 -0
- package/dist/figma-api/list-team-component-sets.js.map +1 -0
- package/dist/figma-api/list-team-project-files.d.ts +4 -0
- package/dist/figma-api/list-team-project-files.d.ts.map +1 -0
- package/dist/figma-api/list-team-project-files.js +19 -0
- package/dist/figma-api/list-team-project-files.js.map +1 -0
- package/dist/figma-api/list-team-projects.d.ts +4 -0
- package/dist/figma-api/list-team-projects.d.ts.map +1 -0
- package/dist/figma-api/list-team-projects.js +8 -0
- package/dist/figma-api/list-team-projects.js.map +1 -0
- package/dist/figma-api/schemas.d.ts +95 -0
- package/dist/figma-api/schemas.d.ts.map +1 -0
- package/dist/figma-api/schemas.js +154 -0
- package/dist/figma-api/schemas.js.map +1 -0
- package/dist/figma-api/types.d.ts +60 -0
- package/dist/figma-api/types.d.ts.map +1 -0
- package/dist/figma-api/types.js +2 -0
- package/dist/figma-api/types.js.map +1 -0
- package/dist/inspect/component-set-context.d.ts +11 -0
- package/dist/inspect/component-set-context.d.ts.map +1 -0
- package/dist/inspect/component-set-context.js +71 -0
- package/dist/inspect/component-set-context.js.map +1 -0
- package/dist/inspect/component-set-lookup.d.ts +6 -0
- package/dist/inspect/component-set-lookup.d.ts.map +1 -0
- package/dist/inspect/component-set-lookup.js +40 -0
- package/dist/inspect/component-set-lookup.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/asset-backed-contract.d.ts +3 -0
- package/dist/inspect/component-set-pseudocode/asset-backed-contract.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/asset-backed-contract.js +34 -0
- package/dist/inspect/component-set-pseudocode/asset-backed-contract.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/assets-contract.d.ts +9 -0
- package/dist/inspect/component-set-pseudocode/assets-contract.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/assets-contract.js +4 -0
- package/dist/inspect/component-set-pseudocode/assets-contract.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/baseline-contract.d.ts +17 -0
- package/dist/inspect/component-set-pseudocode/baseline-contract.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/baseline-contract.js +67 -0
- package/dist/inspect/component-set-pseudocode/baseline-contract.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/build-pseudocode.d.ts +24 -0
- package/dist/inspect/component-set-pseudocode/build-pseudocode.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/build-pseudocode.js +83 -0
- package/dist/inspect/component-set-pseudocode/build-pseudocode.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/index.d.ts +2 -0
- package/dist/inspect/component-set-pseudocode/index.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/index.js +2 -0
- package/dist/inspect/component-set-pseudocode/index.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/infer.d.ts +4 -0
- package/dist/inspect/component-set-pseudocode/infer.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/infer.js +426 -0
- package/dist/inspect/component-set-pseudocode/infer.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/meta-contract.d.ts +27 -0
- package/dist/inspect/component-set-pseudocode/meta-contract.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/meta-contract.js +136 -0
- package/dist/inspect/component-set-pseudocode/meta-contract.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/slim-node-guards.d.ts +14 -0
- package/dist/inspect/component-set-pseudocode/slim-node-guards.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/slim-node-guards.js +28 -0
- package/dist/inspect/component-set-pseudocode/slim-node-guards.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/structure-contract.d.ts +71 -0
- package/dist/inspect/component-set-pseudocode/structure-contract.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/structure-contract.js +281 -0
- package/dist/inspect/component-set-pseudocode/structure-contract.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/structure-dsl.d.ts +3 -0
- package/dist/inspect/component-set-pseudocode/structure-dsl.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/structure-dsl.js +170 -0
- package/dist/inspect/component-set-pseudocode/structure-dsl.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/types.d.ts +44 -0
- package/dist/inspect/component-set-pseudocode/types.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/types.js +2 -0
- package/dist/inspect/component-set-pseudocode/types.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/universal.d.ts +14 -0
- package/dist/inspect/component-set-pseudocode/universal.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/universal.js +393 -0
- package/dist/inspect/component-set-pseudocode/universal.js.map +1 -0
- package/dist/inspect/component-set-spec/bound-variables.d.ts +14 -0
- package/dist/inspect/component-set-spec/bound-variables.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/bound-variables.js +53 -0
- package/dist/inspect/component-set-spec/bound-variables.js.map +1 -0
- package/dist/inspect/component-set-spec/build-spec.d.ts +9 -0
- package/dist/inspect/component-set-spec/build-spec.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/build-spec.js +102 -0
- package/dist/inspect/component-set-spec/build-spec.js.map +1 -0
- package/dist/inspect/component-set-spec/compact-spec.d.ts +3 -0
- package/dist/inspect/component-set-spec/compact-spec.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/compact-spec.js +357 -0
- package/dist/inspect/component-set-spec/compact-spec.js.map +1 -0
- package/dist/inspect/component-set-spec/extract-slots.d.ts +5 -0
- package/dist/inspect/component-set-spec/extract-slots.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/extract-slots.js +57 -0
- package/dist/inspect/component-set-spec/extract-slots.js.map +1 -0
- package/dist/inspect/component-set-spec/figma-node.d.ts +9 -0
- package/dist/inspect/component-set-spec/figma-node.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/figma-node.js +31 -0
- package/dist/inspect/component-set-spec/figma-node.js.map +1 -0
- package/dist/inspect/component-set-spec/index.d.ts +2 -0
- package/dist/inspect/component-set-spec/index.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/index.js +2 -0
- package/dist/inspect/component-set-spec/index.js.map +1 -0
- package/dist/inspect/component-set-spec/parse-props.d.ts +9 -0
- package/dist/inspect/component-set-spec/parse-props.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/parse-props.js +96 -0
- package/dist/inspect/component-set-spec/parse-props.js.map +1 -0
- package/dist/inspect/component-set-spec/prop-name.d.ts +5 -0
- package/dist/inspect/component-set-spec/prop-name.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/prop-name.js +26 -0
- package/dist/inspect/component-set-spec/prop-name.js.map +1 -0
- package/dist/inspect/component-set-spec/resolve-tokens.d.ts +4 -0
- package/dist/inspect/component-set-spec/resolve-tokens.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/resolve-tokens.js +42 -0
- package/dist/inspect/component-set-spec/resolve-tokens.js.map +1 -0
- package/dist/inspect/component-set-spec/slim-context.d.ts +6 -0
- package/dist/inspect/component-set-spec/slim-context.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/slim-context.js +2 -0
- package/dist/inspect/component-set-spec/slim-context.js.map +1 -0
- package/dist/inspect/component-set-spec/slim-node.d.ts +5 -0
- package/dist/inspect/component-set-spec/slim-node.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/slim-node.js +393 -0
- package/dist/inspect/component-set-spec/slim-node.js.map +1 -0
- package/dist/inspect/component-set-spec/slim-text-export.d.ts +8 -0
- package/dist/inspect/component-set-spec/slim-text-export.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/slim-text-export.js +74 -0
- package/dist/inspect/component-set-spec/slim-text-export.js.map +1 -0
- package/dist/inspect/component-set-spec/team-component-registry.d.ts +19 -0
- package/dist/inspect/component-set-spec/team-component-registry.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/team-component-registry.js +96 -0
- package/dist/inspect/component-set-spec/team-component-registry.js.map +1 -0
- package/dist/inspect/component-set-spec/types.d.ts +127 -0
- package/dist/inspect/component-set-spec/types.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/types.js +2 -0
- package/dist/inspect/component-set-spec/types.js.map +1 -0
- package/dist/inspect/component-set-spec/variable-registry.d.ts +8 -0
- package/dist/inspect/component-set-spec/variable-registry.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/variable-registry.js +74 -0
- package/dist/inspect/component-set-spec/variable-registry.js.map +1 -0
- package/dist/inspect/component-set-spec/variant-axes.d.ts +2 -0
- package/dist/inspect/component-set-spec/variant-axes.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/variant-axes.js +14 -0
- package/dist/inspect/component-set-spec/variant-axes.js.map +1 -0
- package/dist/inspect/contract/contract-format.d.ts +5 -0
- package/dist/inspect/contract/contract-format.d.ts.map +1 -0
- package/dist/inspect/contract/contract-format.js +26 -0
- package/dist/inspect/contract/contract-format.js.map +1 -0
- package/dist/inspect/contract/contract-lock.d.ts +75 -0
- package/dist/inspect/contract/contract-lock.d.ts.map +1 -0
- package/dist/inspect/contract/contract-lock.js +326 -0
- package/dist/inspect/contract/contract-lock.js.map +1 -0
- package/dist/inspect/contract/contract-schema.d.ts +51 -0
- package/dist/inspect/contract/contract-schema.d.ts.map +1 -0
- package/dist/inspect/contract/contract-schema.js +130 -0
- package/dist/inspect/contract/contract-schema.js.map +1 -0
- package/dist/inspect/contract/fingerprint.d.ts +9 -0
- package/dist/inspect/contract/fingerprint.d.ts.map +1 -0
- package/dist/inspect/contract/fingerprint.js +301 -0
- package/dist/inspect/contract/fingerprint.js.map +1 -0
- package/dist/inspect/contract/lock-metadata.d.ts +30 -0
- package/dist/inspect/contract/lock-metadata.d.ts.map +1 -0
- package/dist/inspect/contract/lock-metadata.js +101 -0
- package/dist/inspect/contract/lock-metadata.js.map +1 -0
- package/dist/inspect/contract/stable-stringify.d.ts +2 -0
- package/dist/inspect/contract/stable-stringify.d.ts.map +1 -0
- package/dist/inspect/contract/stable-stringify.js +14 -0
- package/dist/inspect/contract/stable-stringify.js.map +1 -0
- package/dist/inspect/contract/verify-component-contract.d.ts +19 -0
- package/dist/inspect/contract/verify-component-contract.d.ts.map +1 -0
- package/dist/inspect/contract/verify-component-contract.js +126 -0
- package/dist/inspect/contract/verify-component-contract.js.map +1 -0
- package/dist/inspect/errors.d.ts +4 -0
- package/dist/inspect/errors.d.ts.map +1 -0
- package/dist/inspect/errors.js +7 -0
- package/dist/inspect/errors.js.map +1 -0
- package/dist/inspect/export/assert-asset-exportable.d.ts +3 -0
- package/dist/inspect/export/assert-asset-exportable.d.ts.map +1 -0
- package/dist/inspect/export/assert-asset-exportable.js +45 -0
- package/dist/inspect/export/assert-asset-exportable.js.map +1 -0
- package/dist/inspect/export/export-nested-assets.d.ts +94 -0
- package/dist/inspect/export/export-nested-assets.d.ts.map +1 -0
- package/dist/inspect/export/export-nested-assets.js +333 -0
- package/dist/inspect/export/export-nested-assets.js.map +1 -0
- package/dist/inspect/export/export-node-preview.d.ts +24 -0
- package/dist/inspect/export/export-node-preview.d.ts.map +1 -0
- package/dist/inspect/export/export-node-preview.js +34 -0
- package/dist/inspect/export/export-node-preview.js.map +1 -0
- package/dist/inspect/export/export-variant-assets.d.ts +18 -0
- package/dist/inspect/export/export-variant-assets.d.ts.map +1 -0
- package/dist/inspect/export/export-variant-assets.js +127 -0
- package/dist/inspect/export/export-variant-assets.js.map +1 -0
- package/dist/inspect/export/normalize-exported-svg.d.ts +2 -0
- package/dist/inspect/export/normalize-exported-svg.d.ts.map +1 -0
- package/dist/inspect/export/normalize-exported-svg.js +15 -0
- package/dist/inspect/export/normalize-exported-svg.js.map +1 -0
- package/dist/inspect/export/rendered-image-bytes.d.ts +4 -0
- package/dist/inspect/export/rendered-image-bytes.d.ts.map +1 -0
- package/dist/inspect/export/rendered-image-bytes.js +24 -0
- package/dist/inspect/export/rendered-image-bytes.js.map +1 -0
- package/dist/inspect/export-contract-target.d.ts +7 -0
- package/dist/inspect/export-contract-target.d.ts.map +1 -0
- package/dist/inspect/export-contract-target.js +33 -0
- package/dist/inspect/export-contract-target.js.map +1 -0
- package/dist/inspect/fetch-file-entry.d.ts +4 -0
- package/dist/inspect/fetch-file-entry.d.ts.map +1 -0
- package/dist/inspect/fetch-file-entry.js +7 -0
- package/dist/inspect/fetch-file-entry.js.map +1 -0
- package/dist/inspect/fetch-file-node-entry.d.ts +4 -0
- package/dist/inspect/fetch-file-node-entry.d.ts.map +1 -0
- package/dist/inspect/fetch-file-node-entry.js +7 -0
- package/dist/inspect/fetch-file-node-entry.js.map +1 -0
- package/dist/inspect/figma-node-url.d.ts +3 -0
- package/dist/inspect/figma-node-url.d.ts.map +1 -0
- package/dist/inspect/figma-node-url.js +30 -0
- package/dist/inspect/figma-node-url.js.map +1 -0
- package/dist/inspect/get-node-component-set.d.ts +5 -0
- package/dist/inspect/get-node-component-set.d.ts.map +1 -0
- package/dist/inspect/get-node-component-set.js +10 -0
- package/dist/inspect/get-node-component-set.js.map +1 -0
- package/dist/inspect/index.d.ts +17 -0
- package/dist/inspect/index.d.ts.map +1 -0
- package/dist/inspect/index.js +17 -0
- package/dist/inspect/index.js.map +1 -0
- package/dist/inspect/list-all-component-sets.d.ts +3 -0
- package/dist/inspect/list-all-component-sets.d.ts.map +1 -0
- package/dist/inspect/list-all-component-sets.js +27 -0
- package/dist/inspect/list-all-component-sets.js.map +1 -0
- package/dist/inspect/list-component-set-properties.d.ts +4 -0
- package/dist/inspect/list-component-set-properties.d.ts.map +1 -0
- package/dist/inspect/list-component-set-properties.js +73 -0
- package/dist/inspect/list-component-set-properties.js.map +1 -0
- package/dist/inspect/node-contract/build-node-contract.d.ts +12 -0
- package/dist/inspect/node-contract/build-node-contract.d.ts.map +1 -0
- package/dist/inspect/node-contract/build-node-contract.js +212 -0
- package/dist/inspect/node-contract/build-node-contract.js.map +1 -0
- package/dist/inspect/node-contract/dependencies.d.ts +5 -0
- package/dist/inspect/node-contract/dependencies.d.ts.map +1 -0
- package/dist/inspect/node-contract/dependencies.js +84 -0
- package/dist/inspect/node-contract/dependencies.js.map +1 -0
- package/dist/inspect/node-contract/index.d.ts +6 -0
- package/dist/inspect/node-contract/index.d.ts.map +1 -0
- package/dist/inspect/node-contract/index.js +6 -0
- package/dist/inspect/node-contract/index.js.map +1 -0
- package/dist/inspect/node-contract/node-kind.d.ts +9 -0
- package/dist/inspect/node-contract/node-kind.d.ts.map +1 -0
- package/dist/inspect/node-contract/node-kind.js +31 -0
- package/dist/inspect/node-contract/node-kind.js.map +1 -0
- package/dist/inspect/node-contract/node-lock.d.ts +6 -0
- package/dist/inspect/node-contract/node-lock.d.ts.map +1 -0
- package/dist/inspect/node-contract/node-lock.js +181 -0
- package/dist/inspect/node-contract/node-lock.js.map +1 -0
- package/dist/inspect/node-contract/node-schema.d.ts +14 -0
- package/dist/inspect/node-contract/node-schema.d.ts.map +1 -0
- package/dist/inspect/node-contract/node-schema.js +137 -0
- package/dist/inspect/node-contract/node-schema.js.map +1 -0
- package/dist/inspect/node-contract/paths.d.ts +10 -0
- package/dist/inspect/node-contract/paths.d.ts.map +1 -0
- package/dist/inspect/node-contract/paths.js +29 -0
- package/dist/inspect/node-contract/paths.js.map +1 -0
- package/dist/inspect/node-contract/tokens.d.ts +4 -0
- package/dist/inspect/node-contract/tokens.d.ts.map +1 -0
- package/dist/inspect/node-contract/tokens.js +30 -0
- package/dist/inspect/node-contract/tokens.js.map +1 -0
- package/dist/inspect/node-contract/types.d.ts +84 -0
- package/dist/inspect/node-contract/types.d.ts.map +1 -0
- package/dist/inspect/node-contract/types.js +2 -0
- package/dist/inspect/node-contract/types.js.map +1 -0
- package/dist/inspect/node-contract/verify-node-contract.d.ts +20 -0
- package/dist/inspect/node-contract/verify-node-contract.d.ts.map +1 -0
- package/dist/inspect/node-contract/verify-node-contract.js +131 -0
- package/dist/inspect/node-contract/verify-node-contract.js.map +1 -0
- package/dist/inspect/resolve-team-component-set.d.ts +14 -0
- package/dist/inspect/resolve-team-component-set.d.ts.map +1 -0
- package/dist/inspect/resolve-team-component-set.js +77 -0
- package/dist/inspect/resolve-team-component-set.js.map +1 -0
- package/dist/inspect/schemas.d.ts +37 -0
- package/dist/inspect/schemas.d.ts.map +1 -0
- package/dist/inspect/schemas.js +79 -0
- package/dist/inspect/schemas.js.map +1 -0
- package/dist/inspect/team-index.d.ts +76 -0
- package/dist/inspect/team-index.d.ts.map +1 -0
- package/dist/inspect/team-index.js +361 -0
- package/dist/inspect/team-index.js.map +1 -0
- package/dist/inspect/types.d.ts +46 -0
- package/dist/inspect/types.d.ts.map +1 -0
- package/dist/inspect/types.js +2 -0
- package/dist/inspect/types.js.map +1 -0
- package/dist/test/fixtures.d.ts +3 -0
- package/dist/test/fixtures.d.ts.map +1 -0
- package/dist/test/fixtures.js +6 -0
- package/dist/test/fixtures.js.map +1 -0
- package/dist/zod/parse-valid-entries.d.ts +4 -0
- package/dist/zod/parse-valid-entries.d.ts.map +1 -0
- package/dist/zod/parse-valid-entries.js +20 -0
- package/dist/zod/parse-valid-entries.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { access, readFile } from "node:fs/promises";
|
|
2
|
+
import { parse } from "yaml";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { FigmaInspectError } from "../errors.js";
|
|
5
|
+
import { nodeContractArtifactFileName, resolveNodeGeometryContractPath, resolveNodeMetaContractPath, resolveNodeStructureDslPath, resolveNodeVisualsContractPath, } from "./paths.js";
|
|
6
|
+
const dependencySchema = z.object({
|
|
7
|
+
nodeId: z.string().min(1),
|
|
8
|
+
name: z.string().min(1).optional(),
|
|
9
|
+
key: z.string().min(1).optional(),
|
|
10
|
+
fileKey: z.string().min(1).optional(),
|
|
11
|
+
componentSetId: z.string().min(1).optional(),
|
|
12
|
+
componentSetName: z.string().min(1).optional(),
|
|
13
|
+
componentSetKey: z.string().min(1).optional(),
|
|
14
|
+
});
|
|
15
|
+
const metaContractSchema = z.object({
|
|
16
|
+
version: z.literal(1),
|
|
17
|
+
kind: z.enum(["component", "frame"]),
|
|
18
|
+
node: z.object({
|
|
19
|
+
id: z.string().min(1),
|
|
20
|
+
name: z.string().min(1),
|
|
21
|
+
type: z.enum(["COMPONENT", "FRAME"]),
|
|
22
|
+
}),
|
|
23
|
+
componentProperties: z
|
|
24
|
+
.record(z.string(), z.object({
|
|
25
|
+
type: z.string().min(1).optional(),
|
|
26
|
+
default: z.union([z.boolean(), z.string()]).optional(),
|
|
27
|
+
options: z.array(z.string()).optional(),
|
|
28
|
+
}))
|
|
29
|
+
.optional(),
|
|
30
|
+
dependencies: z.object({
|
|
31
|
+
componentSets: z.array(dependencySchema),
|
|
32
|
+
components: z.array(dependencySchema),
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
const contractTreeSchema = z.lazy(() => z.record(z.string(), z.union([
|
|
36
|
+
z.string(),
|
|
37
|
+
z.number(),
|
|
38
|
+
z.boolean(),
|
|
39
|
+
z.array(z.unknown()),
|
|
40
|
+
contractTreeSchema,
|
|
41
|
+
])));
|
|
42
|
+
function formatSchemaIssues(error) {
|
|
43
|
+
return error.issues.map((issue) => {
|
|
44
|
+
const pathLabel = issue.path.length > 0 ? issue.path.join(".") : "(root)";
|
|
45
|
+
return `${pathLabel}: ${issue.message}`;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function parseRecord(raw, label, format) {
|
|
49
|
+
if (format === "json") {
|
|
50
|
+
let parsed;
|
|
51
|
+
try {
|
|
52
|
+
parsed = JSON.parse(raw);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
throw new FigmaInspectError(`Invalid JSON in ${label}.`);
|
|
56
|
+
}
|
|
57
|
+
if (typeof parsed !== "object" ||
|
|
58
|
+
parsed === null ||
|
|
59
|
+
Array.isArray(parsed)) {
|
|
60
|
+
throw new FigmaInspectError(`${label} must be a JSON object.`);
|
|
61
|
+
}
|
|
62
|
+
return parsed;
|
|
63
|
+
}
|
|
64
|
+
const parsed = parse(raw);
|
|
65
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
66
|
+
throw new FigmaInspectError(`${label} must be a YAML mapping.`);
|
|
67
|
+
}
|
|
68
|
+
return parsed;
|
|
69
|
+
}
|
|
70
|
+
function validateRecord(schema, value, label) {
|
|
71
|
+
const result = schema.safeParse(value);
|
|
72
|
+
if (!result.success) {
|
|
73
|
+
throw new FigmaInspectError(`Invalid ${label}:\n${formatSchemaIssues(result.error).join("\n")}`);
|
|
74
|
+
}
|
|
75
|
+
return result.data;
|
|
76
|
+
}
|
|
77
|
+
function validateStructureDsl(options) {
|
|
78
|
+
const header = options.structureDsl.split("\n")[0]?.trim();
|
|
79
|
+
const expectedHeader = `node ${options.kind} ${JSON.stringify(options.nodeName)}`;
|
|
80
|
+
if (header !== expectedHeader) {
|
|
81
|
+
throw new FigmaInspectError(`Invalid node structure DSL: expected first line ${JSON.stringify(expectedHeader)}.`);
|
|
82
|
+
}
|
|
83
|
+
const requiredSnippets = [
|
|
84
|
+
"contracts {",
|
|
85
|
+
nodeContractArtifactFileName(options.nodeName, options.kind, "visuals", options.format),
|
|
86
|
+
nodeContractArtifactFileName(options.nodeName, options.kind, "geometry", options.format),
|
|
87
|
+
nodeContractArtifactFileName(options.nodeName, options.kind, "meta", options.format),
|
|
88
|
+
"resolve {",
|
|
89
|
+
"tree {",
|
|
90
|
+
];
|
|
91
|
+
for (const snippet of requiredSnippets) {
|
|
92
|
+
if (!options.structureDsl.includes(snippet)) {
|
|
93
|
+
throw new FigmaInspectError(`Invalid node structure DSL: missing ${JSON.stringify(snippet)}.`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export async function detectNodeContractFormat(contractDir, nodeName, kind) {
|
|
98
|
+
try {
|
|
99
|
+
await access(resolveNodeMetaContractPath(contractDir, nodeName, kind, "json"));
|
|
100
|
+
return "json";
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return "yaml";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export async function readNodeContractArtifacts(contractDir, nodeName, kind, format = "yaml") {
|
|
107
|
+
const [metaRaw, geometryRaw, visualsRaw, structureDsl] = await Promise.all([
|
|
108
|
+
readFile(resolveNodeMetaContractPath(contractDir, nodeName, kind, format), "utf8"),
|
|
109
|
+
readFile(resolveNodeGeometryContractPath(contractDir, nodeName, kind, format), "utf8"),
|
|
110
|
+
readFile(resolveNodeVisualsContractPath(contractDir, nodeName, kind, format), "utf8"),
|
|
111
|
+
readFile(resolveNodeStructureDslPath(contractDir, nodeName, kind), "utf8"),
|
|
112
|
+
]);
|
|
113
|
+
const meta = validateRecord(metaContractSchema, parseRecord(metaRaw, "node meta contract", format), "node meta contract");
|
|
114
|
+
const geometry = validateRecord(contractTreeSchema, parseRecord(geometryRaw, "node geometry contract", format), "node geometry contract");
|
|
115
|
+
const visuals = validateRecord(contractTreeSchema, parseRecord(visualsRaw, "node visuals contract", format), "node visuals contract");
|
|
116
|
+
validateStructureDsl({ structureDsl, nodeName, kind, format });
|
|
117
|
+
return {
|
|
118
|
+
nodeName,
|
|
119
|
+
kind,
|
|
120
|
+
meta,
|
|
121
|
+
geometry,
|
|
122
|
+
visuals,
|
|
123
|
+
structureDsl,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export function validateNodeContractArtifacts(artifacts, format = "yaml") {
|
|
127
|
+
validateRecord(metaContractSchema, artifacts.meta, "node meta contract");
|
|
128
|
+
validateRecord(contractTreeSchema, artifacts.geometry, "node geometry contract");
|
|
129
|
+
validateRecord(contractTreeSchema, artifacts.visuals, "node visuals contract");
|
|
130
|
+
validateStructureDsl({
|
|
131
|
+
structureDsl: artifacts.structureDsl,
|
|
132
|
+
nodeName: artifacts.nodeName,
|
|
133
|
+
kind: artifacts.kind,
|
|
134
|
+
format,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=node-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-schema.js","sourceRoot":"","sources":["../../../src/inspect/node-contract/node-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,EAC/B,2BAA2B,EAC3B,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AAGpB,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAClC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,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AAO,EACjB,uBAAuB,CACxB,CAAC;IACF,oBAAoB,CAAC;QACnB,YAAY,EAAE,SAAS,CAAC,YAAY;QACpC,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContractFormat } from "../contract/contract-format.js";
|
|
2
|
+
import type { NodeContractKind } from "./types.js";
|
|
3
|
+
export type NodeContractArtifact = "geometry" | "meta" | "visuals";
|
|
4
|
+
export declare function nodeContractArtifactFileName(nodeName: string, kind: NodeContractKind, artifact: NodeContractArtifact, format?: ContractFormat): string;
|
|
5
|
+
export declare function resolveNodeMetaContractPath(directory: string, nodeName: string, kind: NodeContractKind, format?: ContractFormat): string;
|
|
6
|
+
export declare function resolveNodeGeometryContractPath(directory: string, nodeName: string, kind: NodeContractKind, format?: ContractFormat): string;
|
|
7
|
+
export declare function resolveNodeVisualsContractPath(directory: string, nodeName: string, kind: NodeContractKind, format?: ContractFormat): string;
|
|
8
|
+
export declare function resolveNodeStructureDslPath(directory: string, nodeName: string, kind: NodeContractKind): string;
|
|
9
|
+
export declare function resolveNodeContractLockPath(directory: string, nodeName: string, kind: NodeContractKind): string;
|
|
10
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/inspect/node-contract/paths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAMnE,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,gBAAgB,EACtB,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,GAAE,cAAuB,GAC9B,MAAM,CAER;AAgBD,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,gBAAgB,EACtB,MAAM,GAAE,cAAuB,GAC9B,MAAM,CAKR;AAED,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,gBAAgB,EACtB,MAAM,GAAE,cAAuB,GAC9B,MAAM,CAKR;AAED,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,gBAAgB,EACtB,MAAM,GAAE,cAAuB,GAC9B,MAAM,CAKR;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,gBAAgB,GACrB,MAAM,CAER;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,gBAAgB,GACrB,MAAM,CAER"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
function dataFileExtension(format) {
|
|
3
|
+
return format === "yaml" ? ".yaml" : ".json";
|
|
4
|
+
}
|
|
5
|
+
export function nodeContractArtifactFileName(nodeName, kind, artifact, format = "yaml") {
|
|
6
|
+
return `${nodeName}.${kind}.${artifact}${dataFileExtension(format)}`;
|
|
7
|
+
}
|
|
8
|
+
function nodeContractStructureFileName(nodeName, kind) {
|
|
9
|
+
return `${nodeName}.${kind}.structure.dsl`;
|
|
10
|
+
}
|
|
11
|
+
function nodeContractLockFileName(nodeName, kind) {
|
|
12
|
+
return `${nodeName}.${kind}.lock.yaml`;
|
|
13
|
+
}
|
|
14
|
+
export function resolveNodeMetaContractPath(directory, nodeName, kind, format = "yaml") {
|
|
15
|
+
return path.join(directory, nodeContractArtifactFileName(nodeName, kind, "meta", format));
|
|
16
|
+
}
|
|
17
|
+
export function resolveNodeGeometryContractPath(directory, nodeName, kind, format = "yaml") {
|
|
18
|
+
return path.join(directory, nodeContractArtifactFileName(nodeName, kind, "geometry", format));
|
|
19
|
+
}
|
|
20
|
+
export function resolveNodeVisualsContractPath(directory, nodeName, kind, format = "yaml") {
|
|
21
|
+
return path.join(directory, nodeContractArtifactFileName(nodeName, kind, "visuals", format));
|
|
22
|
+
}
|
|
23
|
+
export function resolveNodeStructureDslPath(directory, nodeName, kind) {
|
|
24
|
+
return path.join(directory, nodeContractStructureFileName(nodeName, kind));
|
|
25
|
+
}
|
|
26
|
+
export function resolveNodeContractLockPath(directory, nodeName, kind) {
|
|
27
|
+
return path.join(directory, nodeContractLockFileName(nodeName, kind));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/inspect/node-contract/paths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAM7B,SAAS,iBAAiB,CAAC,MAAsB;IAC/C,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,QAAgB,EAChB,IAAsB,EACtB,QAA8B,EAC9B,SAAyB,MAAM;IAE/B,OAAO,GAAG,QAAQ,IAAI,IAAI,IAAI,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;AACvE,CAAC;AAED,SAAS,6BAA6B,CACpC,QAAgB,EAChB,IAAsB;IAEtB,OAAO,GAAG,QAAQ,IAAI,IAAI,gBAAgB,CAAC;AAC7C,CAAC;AAED,SAAS,wBAAwB,CAC/B,QAAgB,EAChB,IAAsB;IAEtB,OAAO,GAAG,QAAQ,IAAI,IAAI,YAAY,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,SAAiB,EACjB,QAAgB,EAChB,IAAsB,EACtB,SAAyB,MAAM;IAE/B,OAAO,IAAI,CAAC,IAAI,CACd,SAAS,EACT,4BAA4B,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAC7D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,SAAiB,EACjB,QAAgB,EAChB,IAAsB,EACtB,SAAyB,MAAM;IAE/B,OAAO,IAAI,CAAC,IAAI,CACd,SAAS,EACT,4BAA4B,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,CACjE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC5C,SAAiB,EACjB,QAAgB,EAChB,IAAsB,EACtB,SAAyB,MAAM;IAE/B,OAAO,IAAI,CAAC,IAAI,CACd,SAAS,EACT,4BAA4B,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,CAChE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,SAAiB,EACjB,QAAgB,EAChB,IAAsB;IAEtB,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,6BAA6B,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,SAAiB,EACjB,QAAgB,EAChB,IAAsB;IAEtB,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,wBAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SlimNode } from "../component-set-spec/types.js";
|
|
2
|
+
import type { VariableRegistry } from "../component-set-spec/variable-registry.js";
|
|
3
|
+
export declare function resolveSlimNodeTokens(node: SlimNode, registry: VariableRegistry): SlimNode;
|
|
4
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/inspect/node-contract/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAyCnF,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,gBAAgB,GACzB,QAAQ,CAEV"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function resolveVariableField(value, registry) {
|
|
2
|
+
const variable = value.variable;
|
|
3
|
+
if (typeof variable !== "string") {
|
|
4
|
+
return value;
|
|
5
|
+
}
|
|
6
|
+
const token = registry.resolve(variable);
|
|
7
|
+
if (!token) {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
const { variable: _removed, ...rest } = value;
|
|
11
|
+
return { ...rest, token };
|
|
12
|
+
}
|
|
13
|
+
function resolveValue(value, registry) {
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
return value.map((entry) => resolveValue(entry, registry));
|
|
16
|
+
}
|
|
17
|
+
if (typeof value !== "object" || value === null) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
const resolved = resolveVariableField(value, registry);
|
|
21
|
+
const output = {};
|
|
22
|
+
for (const [key, entry] of Object.entries(resolved)) {
|
|
23
|
+
output[key] = resolveValue(entry, registry);
|
|
24
|
+
}
|
|
25
|
+
return output;
|
|
26
|
+
}
|
|
27
|
+
export function resolveSlimNodeTokens(node, registry) {
|
|
28
|
+
return resolveValue(node, registry);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/inspect/node-contract/tokens.ts"],"names":[],"mappings":"AAGA,SAAS,oBA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,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ContractFormat } from "../contract/contract-format.js";
|
|
2
|
+
import type { LockApproval, LockDrift, LockFingerprintsV1, LockFingerprintsV2 } from "../contract/lock-metadata.js";
|
|
3
|
+
import type { DocumentNode } from "../schemas.js";
|
|
4
|
+
export type NodeContractKind = "component" | "frame";
|
|
5
|
+
export type NodeContractFigmaType = "COMPONENT" | "FRAME";
|
|
6
|
+
export interface NodeContractSource {
|
|
7
|
+
fileKey: string;
|
|
8
|
+
nodeId: string;
|
|
9
|
+
nodeType: NodeContractFigmaType;
|
|
10
|
+
name: string;
|
|
11
|
+
sourceUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface NodeContractDependency {
|
|
14
|
+
nodeId: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
key?: string;
|
|
17
|
+
fileKey?: string;
|
|
18
|
+
componentSetId?: string;
|
|
19
|
+
componentSetName?: string;
|
|
20
|
+
componentSetKey?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface NodeContractDependencies {
|
|
23
|
+
componentSets: NodeContractDependency[];
|
|
24
|
+
components: NodeContractDependency[];
|
|
25
|
+
}
|
|
26
|
+
export interface NodeContractMeta {
|
|
27
|
+
version: 1;
|
|
28
|
+
kind: NodeContractKind;
|
|
29
|
+
node: {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
type: NodeContractFigmaType;
|
|
33
|
+
};
|
|
34
|
+
componentProperties?: Record<string, {
|
|
35
|
+
type?: string;
|
|
36
|
+
default?: boolean | string;
|
|
37
|
+
options?: string[];
|
|
38
|
+
}>;
|
|
39
|
+
dependencies: NodeContractDependencies;
|
|
40
|
+
}
|
|
41
|
+
export interface NodeContractResult {
|
|
42
|
+
nodeName: string;
|
|
43
|
+
kind: NodeContractKind;
|
|
44
|
+
source: NodeContractSource;
|
|
45
|
+
rawNode: DocumentNode;
|
|
46
|
+
visuals: Record<string, unknown>;
|
|
47
|
+
geometry: Record<string, unknown>;
|
|
48
|
+
meta: NodeContractMeta;
|
|
49
|
+
structureDsl: string;
|
|
50
|
+
lock: NodeContractLock;
|
|
51
|
+
}
|
|
52
|
+
interface NodeContractLockBase {
|
|
53
|
+
kind: NodeContractKind;
|
|
54
|
+
source: NodeContractSource;
|
|
55
|
+
dependencies: NodeContractDependencies;
|
|
56
|
+
approval: LockApproval;
|
|
57
|
+
drift: LockDrift;
|
|
58
|
+
}
|
|
59
|
+
interface NodeContractLockV1 extends NodeContractLockBase {
|
|
60
|
+
version: 1;
|
|
61
|
+
fingerprints: LockFingerprintsV1;
|
|
62
|
+
}
|
|
63
|
+
interface NodeContractLockV2 extends NodeContractLockBase {
|
|
64
|
+
version: 2;
|
|
65
|
+
fingerprints: LockFingerprintsV2;
|
|
66
|
+
}
|
|
67
|
+
export type NodeContractLock = NodeContractLockV1 | NodeContractLockV2;
|
|
68
|
+
export interface NodeContractLockDiff {
|
|
69
|
+
source: boolean;
|
|
70
|
+
tree: boolean;
|
|
71
|
+
contractSurface: boolean;
|
|
72
|
+
kind: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface BuildNodeContractOptions {
|
|
75
|
+
token: string;
|
|
76
|
+
fileKey: string;
|
|
77
|
+
nodeId: string;
|
|
78
|
+
sourceUrl?: string;
|
|
79
|
+
variablesPath: string;
|
|
80
|
+
format?: ContractFormat;
|
|
81
|
+
fetchImpl?: typeof fetch;
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/inspect/node-contract/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,K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types.js","sourceRoot":"","sources":["../../../src/inspect/node-contract/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ContractFormat } from "../contract/contract-format.js";
|
|
2
|
+
import type { NodeContractKind, NodeContractLockDiff } from "./types.js";
|
|
3
|
+
type NodeContractVerifyStatus = "changed" | "error" | "ok";
|
|
4
|
+
export interface NodeContractVerifyResult {
|
|
5
|
+
nodeName: string;
|
|
6
|
+
kind: NodeContractKind;
|
|
7
|
+
status: NodeContractVerifyStatus;
|
|
8
|
+
errors: string[];
|
|
9
|
+
changed: NodeContractLockDiff;
|
|
10
|
+
}
|
|
11
|
+
export interface VerifyNodeContractsOptions {
|
|
12
|
+
token: string;
|
|
13
|
+
contractDir: string;
|
|
14
|
+
nodeName?: string;
|
|
15
|
+
contractFormat?: ContractFormat;
|
|
16
|
+
fetchImpl?: typeof fetch;
|
|
17
|
+
}
|
|
18
|
+
export declare function verifyNodeContracts(options: VerifyNodeContractsOptions): Promise<NodeContractVerifyResult[]>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=verify-node-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-node-contract.d.ts","sourceRoot":"","sources":["../../../src/inspect/node-contract/verify-node-contract.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAmBrE,OAAO,KAAK,EACV,gBAAgB,EAEhB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,KAAK,wBAAwB,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI,CAAC;AAE3D,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAmJD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAmBrC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fingerprintContractSurface, fingerprintTree, } from "../contract/fingerprint.js";
|
|
4
|
+
import { FigmaInspectError } from "../errors.js";
|
|
5
|
+
import { fetchFileNodeEntry } from "../fetch-file-node-entry.js";
|
|
6
|
+
import { collectNodeContractDependencies } from "./dependencies.js";
|
|
7
|
+
import { assertNodeContractRoot } from "./node-kind.js";
|
|
8
|
+
import { diffNodeContractLock, isNodeContractLockDiffEmpty, readNodeContractLock, } from "./node-lock.js";
|
|
9
|
+
import { detectNodeContractFormat, readNodeContractArtifacts, validateNodeContractArtifacts, } from "./node-schema.js";
|
|
10
|
+
function emptyDiff() {
|
|
11
|
+
return {
|
|
12
|
+
source: false,
|
|
13
|
+
tree: false,
|
|
14
|
+
contractSurface: false,
|
|
15
|
+
kind: false,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function lockFileNamePattern() {
|
|
19
|
+
return /^(.+)\.(frame|component)\.lock\.yaml$/;
|
|
20
|
+
}
|
|
21
|
+
async function discoverNodeLocks(contractDir, nodeName) {
|
|
22
|
+
const entries = await readdir(contractDir, { withFileTypes: true });
|
|
23
|
+
const locks = [];
|
|
24
|
+
for (const entry of entries) {
|
|
25
|
+
if (!entry.isFile()) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const match = entry.name.match(lockFileNamePattern());
|
|
29
|
+
const matchedNodeName = match?.[1];
|
|
30
|
+
const matchedKind = match?.[2];
|
|
31
|
+
if (!matchedNodeName || !matchedKind) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (nodeName && matchedNodeName !== nodeName) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
locks.push({
|
|
38
|
+
nodeName: matchedNodeName,
|
|
39
|
+
kind: matchedKind,
|
|
40
|
+
lockPath: path.join(contractDir, entry.name),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return locks.sort((left, right) => {
|
|
44
|
+
const byName = left.nodeName.localeCompare(right.nodeName);
|
|
45
|
+
return byName === 0 ? left.kind.localeCompare(right.kind) : byName;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async function verifySingleNodeContract(options, discovered) {
|
|
49
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
50
|
+
try {
|
|
51
|
+
const lock = await readNodeContractLock(discovered.lockPath);
|
|
52
|
+
if (!lock) {
|
|
53
|
+
return {
|
|
54
|
+
nodeName: discovered.nodeName,
|
|
55
|
+
kind: discovered.kind,
|
|
56
|
+
status: "error",
|
|
57
|
+
errors: [`Missing lock file: ${discovered.lockPath}`],
|
|
58
|
+
changed: emptyDiff(),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const contractFormat = options.contractFormat ??
|
|
62
|
+
(await detectNodeContractFormat(options.contractDir, discovered.nodeName, discovered.kind));
|
|
63
|
+
const artifacts = await readNodeContractArtifacts(options.contractDir, discovered.nodeName, discovered.kind, contractFormat);
|
|
64
|
+
validateNodeContractArtifacts(artifacts, contractFormat);
|
|
65
|
+
const entry = await fetchFileNodeEntry({
|
|
66
|
+
token: options.token,
|
|
67
|
+
fileKey: lock.source.fileKey,
|
|
68
|
+
nodeId: lock.source.nodeId,
|
|
69
|
+
fetchImpl,
|
|
70
|
+
});
|
|
71
|
+
const { node, kind } = assertNodeContractRoot(entry, lock.source.nodeId);
|
|
72
|
+
const live = {
|
|
73
|
+
version: 2,
|
|
74
|
+
kind,
|
|
75
|
+
source: {
|
|
76
|
+
fileKey: lock.source.fileKey,
|
|
77
|
+
nodeId: node.id ?? lock.source.nodeId,
|
|
78
|
+
nodeType: node.type,
|
|
79
|
+
name: typeof node.name === "string" && node.name.length > 0
|
|
80
|
+
? node.name
|
|
81
|
+
: lock.source.nodeId,
|
|
82
|
+
...(lock.source.sourceUrl ? { sourceUrl: lock.source.sourceUrl } : {}),
|
|
83
|
+
},
|
|
84
|
+
fingerprints: {
|
|
85
|
+
tree: fingerprintTree(node),
|
|
86
|
+
contractSurface: fingerprintContractSurface(node),
|
|
87
|
+
contracts: lock.fingerprints.contracts,
|
|
88
|
+
},
|
|
89
|
+
dependencies: collectNodeContractDependencies(entry, node, lock.source.fileKey),
|
|
90
|
+
approval: lock.approval,
|
|
91
|
+
drift: lock.drift,
|
|
92
|
+
};
|
|
93
|
+
const changed = diffNodeContractLock(lock, live);
|
|
94
|
+
const status = isNodeContractLockDiffEmpty(changed) ? "ok" : "changed";
|
|
95
|
+
return {
|
|
96
|
+
nodeName: discovered.nodeName,
|
|
97
|
+
kind: discovered.kind,
|
|
98
|
+
status,
|
|
99
|
+
errors: [],
|
|
100
|
+
changed,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
const message = error instanceof FigmaInspectError
|
|
105
|
+
? error.message
|
|
106
|
+
: error instanceof Error
|
|
107
|
+
? error.message
|
|
108
|
+
: String(error);
|
|
109
|
+
return {
|
|
110
|
+
nodeName: discovered.nodeName,
|
|
111
|
+
kind: discovered.kind,
|
|
112
|
+
status: "error",
|
|
113
|
+
errors: [message],
|
|
114
|
+
changed: emptyDiff(),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export async function verifyNodeContracts(options) {
|
|
119
|
+
const discoveredLocks = await discoverNodeLocks(options.contractDir, options.nodeName);
|
|
120
|
+
if (discoveredLocks.length === 0) {
|
|
121
|
+
throw new FigmaInspectError(options.nodeName
|
|
122
|
+
? `No node lock files found for ${options.nodeName} in ${options.contractDir}.`
|
|
123
|
+
: `No *.frame.lock.yaml or *.component.lock.yaml files found in ${options.contractDir}.`);
|
|
124
|
+
}
|
|
125
|
+
const results = [];
|
|
126
|
+
for (const lock of discoveredLocks) {
|
|
127
|
+
results.push(await verifySingleNodeContract(options, lock));
|
|
128
|
+
}
|
|
129
|
+
return results;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=verify-node-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-node-contract.js","sourceRoot":"","sources":["../../../src/inspect/node-contract/verify-node-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,0BAA0B,EAC1B,eAAe,GAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,kBAAkB,CAAC;AA+B1B,SAAS,SAAS;IAChB,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,KAAK;QACX,eAAe,EAAE,KAAK;QACtB,IAAI,EAAE,KAAK;KACZ,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO,uCAAuC,CAAC;AACjD,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC9B,WAAmB,EACnB,QAAiB;IA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B,CAAC,CAAC,KAAK,CAAC,OAAO;gBACf,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtB,OAAO;YACL,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,MAAM,EAAE,OAAO;YACf,MAAM,EAAE,CAAC,OAAO,CAAC;YACjB,OAAO,EAAE,SAAS,EAAE;SACrB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAAmC;IAEnC,MAAM,eAAe,GAAG,MAAM,iBAAiB,CAC7C,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,QAAQ,CACjB,CAAC;IACF,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,iBAAiB,CACzB,OAAO,CAAC,QAAQ;YACd,CAAC,CAAC,gCAAgC,OAAO,CAAC,QAAQ,OAAO,OAAO,CAAC,WAAW,GAAG;YAC/E,CAAC,CAAC,gEAAgE,OAAO,CAAC,WAAW,GAAG,CAC3F,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAA+B,EAAE,CAAC;IAC/C,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,MAAM,wBAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TeamComponentRegistry } from "./component-set-spec/team-component-registry.js";
|
|
2
|
+
import type { ComponentSetScopeOptions, ComponentSetTarget, FigmaTeamComponentSet } from "./types.js";
|
|
3
|
+
export interface ResolveTeamComponentSetScopeResult extends Pick<ComponentSetScopeOptions, "fileKey" | "nodeId" | "componentSet"> {
|
|
4
|
+
publishedSet: FigmaTeamComponentSet;
|
|
5
|
+
teamComponents: TeamComponentRegistry;
|
|
6
|
+
}
|
|
7
|
+
export interface ResolveTeamComponentSetOptions {
|
|
8
|
+
token: string;
|
|
9
|
+
teamId: string;
|
|
10
|
+
componentSet: ComponentSetTarget;
|
|
11
|
+
fetchImpl?: typeof fetch;
|
|
12
|
+
}
|
|
13
|
+
export declare function resolveTeamComponentSetScope({ token, teamId, componentSet, fetchImpl, }: ResolveTeamComponentSetOptions): Promise<ResolveTeamComponentSetScopeResult>;
|
|
14
|
+
//# sourceMappingURL=resolve-team-component-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-team-component-set.d.ts","sourceRoot":"","sources":["../../src/inspect/resolve-team-component-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AAIxF,OAAO,KAAK,EAEV,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,kCACf,SAAQ,IAAI,CACV,wBAAwB,EACxB,SAAS,GAAG,QAAQ,GAAG,cAAc,CACtC;IACD,YAAY,EAAE,qBAAqB,CAAC;IACpC,cAAc,EAAE,qBAAqB,CAAC;CACvC;AAgBD,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,kBAAkB,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAqED,wBAAsB,4BAA4B,CAAC,EACjD,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,GACV,EAAE,8BAA8B,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAkC9E"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { TeamComponentRegistry } from "./component-set-spec/team-component-registry.js";
|
|
2
|
+
import { FigmaInspectError } from "./errors.js";
|
|
3
|
+
import { fetchFileNodeEntry } from "./fetch-file-node-entry.js";
|
|
4
|
+
import { listAllComponentSets } from "./list-all-component-sets.js";
|
|
5
|
+
function teamComponentRegistryFromPublishedSets(publishedSets) {
|
|
6
|
+
return TeamComponentRegistry.fromEntries(publishedSets.map((set) => ({
|
|
7
|
+
id: set.id,
|
|
8
|
+
key: set.key,
|
|
9
|
+
name: set.name,
|
|
10
|
+
fileKey: set.fileKey,
|
|
11
|
+
projectId: set.projectId,
|
|
12
|
+
})));
|
|
13
|
+
}
|
|
14
|
+
function matchesLookup(componentSet, lookup) {
|
|
15
|
+
return lookup.kind === "name"
|
|
16
|
+
? componentSet.name === lookup.value
|
|
17
|
+
: componentSet.key === lookup.value;
|
|
18
|
+
}
|
|
19
|
+
function formatTeamComponentSetLocation(componentSet) {
|
|
20
|
+
return `${componentSet.name} (${componentSet.fileName}, ${componentSet.projectName})`;
|
|
21
|
+
}
|
|
22
|
+
async function assertComponentSetNodeTarget({ token, componentSet, fetchImpl, }) {
|
|
23
|
+
if (componentSet.kind !== "node") {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const nodeEntry = await fetchFileNodeEntry({
|
|
27
|
+
token,
|
|
28
|
+
fileKey: componentSet.fileKey,
|
|
29
|
+
nodeId: componentSet.nodeId,
|
|
30
|
+
fetchImpl,
|
|
31
|
+
});
|
|
32
|
+
if (nodeEntry.document?.type !== "COMPONENT_SET") {
|
|
33
|
+
const type = nodeEntry.document?.type ?? "UNKNOWN";
|
|
34
|
+
throw new FigmaInspectError(`Figma node ${componentSet.nodeId} is ${type}; expected COMPONENT_SET.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function matchesTarget(componentSet, target) {
|
|
38
|
+
if (target.kind === "node") {
|
|
39
|
+
return (componentSet.fileKey === target.fileKey &&
|
|
40
|
+
componentSet.id === target.nodeId);
|
|
41
|
+
}
|
|
42
|
+
return matchesLookup(componentSet, target);
|
|
43
|
+
}
|
|
44
|
+
function targetLabel(componentSet) {
|
|
45
|
+
if (componentSet.kind === "name") {
|
|
46
|
+
return `name "${componentSet.value}"`;
|
|
47
|
+
}
|
|
48
|
+
if (componentSet.kind === "key") {
|
|
49
|
+
return `key ${componentSet.value}`;
|
|
50
|
+
}
|
|
51
|
+
return `node ${componentSet.nodeId} in file ${componentSet.fileKey}`;
|
|
52
|
+
}
|
|
53
|
+
export async function resolveTeamComponentSetScope({ token, teamId, componentSet, fetchImpl, }) {
|
|
54
|
+
await assertComponentSetNodeTarget({ token, componentSet, fetchImpl });
|
|
55
|
+
const publishedSets = await listAllComponentSets({
|
|
56
|
+
token,
|
|
57
|
+
teamId,
|
|
58
|
+
fetchImpl,
|
|
59
|
+
});
|
|
60
|
+
const matches = publishedSets.filter((entry) => matchesTarget(entry, componentSet));
|
|
61
|
+
if (matches.length === 0) {
|
|
62
|
+
throw new FigmaInspectError(`No published component set with ${targetLabel(componentSet)} found in team.`);
|
|
63
|
+
}
|
|
64
|
+
if (matches.length > 1) {
|
|
65
|
+
const locations = matches.map(formatTeamComponentSetLocation).join("; ");
|
|
66
|
+
throw new FigmaInspectError(`Multiple published component sets match: ${locations}. Use --inspect-component-set with --file-key and --node-id.`);
|
|
67
|
+
}
|
|
68
|
+
const match = matches[0];
|
|
69
|
+
return {
|
|
70
|
+
fileKey: match.fileKey,
|
|
71
|
+
nodeId: match.id,
|
|
72
|
+
componentSet: { kind: "key", value: match.key },
|
|
73
|
+
publishedSet: match,
|
|
74
|
+
teamComponents: teamComponentRegistryFromPublishedSets(publishedSets),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=resolve-team-component-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-team-component-set.js","sourceRoot":"","sources":["../../src/inspect/resolve-team-component-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;A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