Open-Cap-Table-Coalition / Open-Cap-Format-OCF

Open Cap Format (OCF) - The Open Source Company Capitalization Data Standard. OCF can be used to structure and track the complex data structures necessary to build and maintain accurate capitalization (cap) tables.

Home Page:https://opencaptablecoalition.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: validate-example-ocf-files crashes on releases

pjohnmeyer opened this issue · comments

Current Behavior:

The validator fails when run against a release (expand for full log):
--- Validate OCF Files ---------------
1)	Analyze File: /Users/pj/code/Open-Cap-Format-OCF/samples/Manifest.ocf.json
	OCF File Type: OCF_MANIFEST_FILE
	File Type URI: https://schema.opencaptablecoalition.com/v/1.1.0/files/OCFManifestFile.schema.json
::error::		OCF Validation failed due to error: validator is not a function
pj@LTSE-Q293FVD2T0 Open-Cap-Format-OCF % npm run validate-example-ocf-files 

> validate-example-ocf-files
> node --loader ts-node/esm --no-warnings --experimental-json-modules ./utils/validate.mjs validate-ocf-directory -v -p ./samples -t


-->	Load Schema Files...

•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/AccrualPeriodType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/AddressType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/AllocationType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/CompensationType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/CompoundingType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/ConversionMechanismType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/ConversionRightType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/ConversionTimingType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/ConversionTriggerType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/ConvertibleType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/DayCountType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/EmailType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/FileType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/InterestPayoutType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/ObjectType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/OptionType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/ParentSecurityType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/PeriodType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/PhoneType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/RoundingType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/StakeholderRelationshipType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/StakeholderType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/StockClassType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/StockIssuanceType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/StockPlanCancellationBehaviorType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/TerminationWindowType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/ValuationType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/VestingDayOfMonth.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/enums/VestingTriggerType.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/files/OCFManifestFile.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/files/StakeholdersFile.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/files/StockClassesFile.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/files/StockLegendTemplatesFile.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/files/StockPlansFile.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/files/TransactionsFile.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/files/ValuationsFile.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/files/VestingTermsFile.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/Issuer.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/Stakeholder.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/StockClass.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/StockLegendTemplate.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/StockPlan.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/Valuation.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/VestingTerms.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/acceptance/ConvertibleAcceptance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/acceptance/EquityCompensationAcceptance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/acceptance/PlanSecurityAcceptance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/acceptance/StockAcceptance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/acceptance/WarrantAcceptance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/adjustment/StockClassAuthorizedSharesAdjustment.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/adjustment/StockClassConversionRatioAdjustment.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/adjustment/StockPlanPoolAdjustment.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/cancellation/ConvertibleCancellation.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/cancellation/EquityCompensationCancellation.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/cancellation/PlanSecurityCancellation.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/cancellation/StockCancellation.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/cancellation/WarrantCancellation.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/conversion/ConvertibleConversion.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/conversion/StockConversion.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/exercise/EquityCompensationExercise.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/exercise/PlanSecurityExercise.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/exercise/WarrantExercise.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/issuance/ConvertibleIssuance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/issuance/EquityCompensationIssuance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/issuance/PlanSecurityIssuance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/issuance/StockIssuance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/issuance/WarrantIssuance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/reissuance/StockReissuance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/release/EquityCompensationRelease.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/release/PlanSecurityRelease.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/repurchase/StockRepurchase.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/retraction/ConvertibleRetraction.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/retraction/EquityCompensationRetraction.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/retraction/PlanSecurityRetraction.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/retraction/StockRetraction.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/retraction/WarrantRetraction.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/return_to_pool/StockPlanReturnToPool.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/split/StockClassSplit.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/transfer/ConvertibleTransfer.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/transfer/EquityCompensationTransfer.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/transfer/PlanSecurityTransfer.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/transfer/StockTransfer.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/transfer/WarrantTransfer.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/vesting/VestingAcceleration.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/vesting/VestingEvent.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/objects/transactions/vesting/VestingStart.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/files/File.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/Object.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/SecurityTransaction.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/StockClassTransaction.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/StockPlanTransaction.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/Transaction.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/acceptance/Acceptance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/cancellation/Cancellation.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/conversion/Conversion.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/exercise/Exercise.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/issuance/Issuance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/reissuance/Reissuance.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/release/Release.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/repurchase/Repurchase.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/retraction/Retraction.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/return_to_pool/ReturnToPool.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/objects/transactions/transfer/Transfer.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/types/conversion_mechanisms/ConversionMechanism.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/types/conversion_rights/ConversionRight.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/types/conversion_triggers/ConversionTrigger.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/types/vesting/VestingConditionTrigger.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/primitives/types/vesting/VestingPeriod.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/Address.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/CapitalizationDefinition.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/CapitalizationDefinitionRules.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/ContactInfo.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/ContactInfoWithoutName.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/CountryCode.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/CountrySubdivisionCode.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/CurrencyCode.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/Date.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/Email.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/File.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/InterestRate.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/Md5.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/Monetary.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/Name.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/Numeric.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/Percentage.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/Phone.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/Ratio.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/SecurityExemption.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/ShareNumberRange.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/StockParent.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/TaxID.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/TerminationWindow.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_mechanisms/CustomConversionMechanism.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_mechanisms/FixedAmountConversionMechanism.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_mechanisms/NoteConversionMechanism.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_mechanisms/PercentCapitalizationConversionMechanism.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_mechanisms/RatioConversionMechanism.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_mechanisms/SAFEConversionMechanism.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_rights/ConvertibleConversionRight.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_rights/StockClassConversionRight.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_rights/WarrantConversionRight.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_triggers/AutomaticConversionOnConditionTrigger.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_triggers/AutomaticConversionOnDateTrigger.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_triggers/ElectiveConversionAtWillTrigger.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_triggers/ElectiveConversionInDateRangeTrigger.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_triggers/ElectiveConversionOnConditionTrigger.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/conversion_triggers/UnspecifiedConversionTrigger.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/vesting/VestingCondition.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/vesting/VestingConditionPortion.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/vesting/VestingEventTrigger.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/vesting/VestingPeriodInDays.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/vesting/VestingPeriodInMonths.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/vesting/VestingScheduleAbsoluteTrigger.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/vesting/VestingScheduleRelativeTrigger.schema.json
•	/Users/pj/code/Open-Cap-Format-OCF/schema/types/vesting/VestingStartTrigger.schema.json

-->	Parse Schema Objs...

-->	Parsing Schema JSONs

-->	Create AJV Validator

-->	Validator Ready

-->	getOcfFilesFromDir from root directory:	./samples
	•	/Users/pj/code/Open-Cap-Format-OCF/samples/Manifest.ocf.json
	•	/Users/pj/code/Open-Cap-Format-OCF/samples/Stakeholders.ocf.json
	•	/Users/pj/code/Open-Cap-Format-OCF/samples/StockClasses.ocf.json
	•	/Users/pj/code/Open-Cap-Format-OCF/samples/StockLegends.ocf.json
	•	/Users/pj/code/Open-Cap-Format-OCF/samples/StockPlans.ocf.json
	•	/Users/pj/code/Open-Cap-Format-OCF/samples/Transactions.ocf.json
	•	/Users/pj/code/Open-Cap-Format-OCF/samples/Valuations.ocf.json
	•	/Users/pj/code/Open-Cap-Format-OCF/samples/VestingTerms.example1.ocf.json
	•	/Users/pj/code/Open-Cap-Format-OCF/samples/VestingTerms.example2.ocf.json
	•	/Users/pj/code/Open-Cap-Format-OCF/samples/VestingTerms.ocf.json
	•	/Users/pj/code/Open-Cap-Format-OCF/samples/VestingTransactions.examples.ocf.json
-->	DONE!

--- Loading URI Lookup for file types ---------------

--- Loading OCF File Buffers... ---------------

--- Validate OCF Files ---------------

1)	Analyze File: /Users/pj/code/Open-Cap-Format-OCF/samples/Manifest.ocf.json
	OCF File Type: OCF_MANIFEST_FILE
	File Type URI: https://schema.opencaptablecoalition.com/v/1.1.0/files/OCFManifestFile.schema.json
::error::		OCF Validation failed due to error: validator is not a function

Expected Behavior:

It should pass or fail validation appropriately.

Steps to Reproduce:

git fetch && git checkout v1.1.0
nvm use && npm install
npm run validate-ocf-file-schemas && echo 'ok' || echo 'FAILED' # should be ok
npm run validate-example-ocf-files && echo 'ok' || echo 'FAILED' # should be ok but is FAILED

Environment:

MacOS 12.16, Node 16.16, npm 9.6.4

Anything else we need to know?

Found as part of #422

@JSv4 unassigning myself for now. I may return to this but I don't want it waiting on me.

The AJV validator takes in schemas when it's created. It doesn't look them up via URI.
To fix this issue we just need to update the file schema URIs in the top of validate.mjs

e.g.

export const OCF_MANIFEST_FILE_SCHEMA_URI =
  "https://schema.opencaptablecoalition.com/v/1.1.0/files/OCFManifestFile.schema.json";

export const OCF_TRANSACTIONS_FILE_SCHEMA_URI =
  "https://schema.opencaptablecoalition.com/v/1.1.0/files/TransactionsFile.schema.json";

export const OCF_STAKEHOLDERS_FILE_SCHEMA_URI =
  "https://schema.opencaptablecoalition.com/v/1.1.0/files/StakeholdersFile.schema.json";

export const OCF_STOCK_PLANS_FILE_SCHEMA_URI =
  "https://schema.opencaptablecoalition.com/v/1.1.0/files/StockPlansFile.schema.json";

export const OCF_VALUATIONS_FILE_SCHEMA_URI =
  "https://schema.opencaptablecoalition.com/v/1.1.0/files/ValuationsFile.schema.json";

export const OCF_VESTING_TERMS_FILE_SCHEMA_URI =
  "https://schema.opencaptablecoalition.com/v/1.1.0/files/VestingTermsFile.schema.json";

export const OCF_STOCK_CLASSES_FILE_SCHEMA_URI =
  "https://schema.opencaptablecoalition.com/v/1.1.0/files/StockClassesFile.schema.json";

export const OCF_STOCK_LEGEND_TEMPLATES_FILE_SCHEMA_URI =
  "https://schema.opencaptablecoalition.com/v/1.1.0/files/StockLegendTemplatesFile.schema.json";

We'll just need to include the above lines in /utils/validate.mjs in our release process -- changing them to match the $id values for the release when we are preparing to tag.
Closing this issue now

Re-opening this as I discovered duplication related to the constants I pasted above.

i.e. We have file utils/schema-utils/UriLookupForFileType.json and these paths were properly updated in the v1.1.0 tag. The lines in utils/validate.mjs seemed to be leftover by accident when the above was introduced. I'll put up a PR to remove the duplication.