Interfaces not mapping for ontology as code

I am attempting to execute the following ontology as code:

import { defineSharedPropertyType, defineInterface, defineObject, defineLink, defineCreateObjectAction, defineModifyObjectAction, defineDeleteObjectAction } from "@osdk/maker";
// Shared Property Types (deduped across interface-attached tables)
const hashIdProperty = defineSharedPropertyType({
    apiName: "hash_id",
    displayName: "Hash Id",
    type: "string",
});
const startDateProperty = defineSharedPropertyType({
    apiName: "start_date",
    displayName: "Start Date",
    type: "date",
});
const endDateProperty = defineSharedPropertyType({
    apiName: "end_date",
    displayName: "End Date",
    type: "date",
});
const descriptionProperty = defineSharedPropertyType({
    apiName: "description",
    displayName: "Description",
    type: {
        type: "string",
        isLongText: true,
        supportsEfficientLeadingWildcard: true,
        supportsExactMatching: false,
    },
});
const amountProperty = defineSharedPropertyType({
    apiName: "amount",
    displayName: "Amount",
    type: "integer",
});
const rawRowProperty = defineSharedPropertyType({
    apiName: "raw_row",
    displayName: "Raw Row",
    type: {
        type: "string",
        isLongText: true,
        supportsEfficientLeadingWildcard: true,
        supportsExactMatching: false,
    },
});
const workpaperHashProperty = defineSharedPropertyType({
    apiName: "workpaper_hash",
    displayName: "Workpaper Hash",
    type: "string",
});
const fileIdProperty = defineSharedPropertyType({
    apiName: "file_id",
    displayName: "File Id",
    type: "string",
});
const customerIdProperty = defineSharedPropertyType({
    apiName: "customer_id",
    displayName: "Customer Id",
    type: "string",
});
const systemOfRecordIdProperty = defineSharedPropertyType({
    apiName: "system_of_record_id",
    displayName: "System Of Record Id",
    type: "string",
});
const batchIdProperty = defineSharedPropertyType({
    apiName: "batch_id",
    displayName: "Batch Id",
    type: "string",
});
const ingestedDateProperty = defineSharedPropertyType({
    apiName: "ingested_date",
    displayName: "Ingested Date",
    type: "date",
});
const idProperty = defineSharedPropertyType({
    apiName: "id",
    displayName: "Id",
    type: "string",
});
const fsliIdProperty = defineSharedPropertyType({
    apiName: "fsli_id",
    displayName: "Fsli Id",
    type: "string",
});
const mainAccountIdProperty = defineSharedPropertyType({
    apiName: "main_account_id",
    displayName: "Main Account Id",
    type: "string",
});
const subAccountIdProperty = defineSharedPropertyType({
    apiName: "sub_account_id",
    displayName: "Sub Account Id",
    type: "string",
});
const fsliNameProperty = defineSharedPropertyType({
    apiName: "fsli_name",
    displayName: "Fsli Name",
    type: "string",
});
const mainAccountNameProperty = defineSharedPropertyType({
    apiName: "main_account_name",
    displayName: "Main Account Name",
    type: "string",
});
const subAccountNameProperty = defineSharedPropertyType({
    apiName: "sub_account_name",
    displayName: "Sub Account Name",
    type: "string",
});
const typeProperty = defineSharedPropertyType({
    apiName: "type",
    displayName: "Type",
    type: "string",
});
const chartOfAccountIdProperty = defineSharedPropertyType({
    apiName: "chart_of_account_id",
    displayName: "Chart Of Account Id",
    type: "string",
});

const iWorkpaperInterface = defineInterface({
    apiName: "IWorkpaper",
    displayName: "Workpaper",
    properties: {
        "hash_id": hashIdProperty,
        "start_date": startDateProperty,
        "end_date": endDateProperty,
        "description": descriptionProperty,
        "amount": amountProperty,
        "raw_row": rawRowProperty,
        "workpaper_hash": workpaperHashProperty,
        "file_id": fileIdProperty,
        "customer_id": customerIdProperty,
        "system_of_record_id": systemOfRecordIdProperty,
        "batch_id": batchIdProperty,
        "ingested_date": ingestedDateProperty,
    },
});

const workpapersExtractedObject = defineObject({
    apiName: "workpapers-extracted",
    displayName: "Workpapers Extracted",
    pluralDisplayName: "Workpapers Extracteds",
    titlePropertyApiName: "hash_id",
    primaryKeyPropertyApiName: "hash_id",
    properties: {
        "hash_id": { displayName: "Hash Id", type: "string" },
        "start_date": { displayName: "Start Date", type: "date" },
        "end_date": { displayName: "End Date", type: "date" },
        "description": { displayName: "Description", type: { type: "string", isLongText: true, supportsEfficientLeadingWildcard: true, supportsExactMatching: false } },
        "amount": { displayName: "Amount", type: "integer" },
        "raw_row": { displayName: "Raw Row", type: { type: "string", isLongText: true, supportsEfficientLeadingWildcard: true, supportsExactMatching: false } },
        "workpaper_hash": { displayName: "Workpaper Hash", type: "string" },
        "file_id": { displayName: "File Id", type: "string" },
        "customer_id": { displayName: "Customer Id", type: "string" },
        "system_of_record_id": { displayName: "System Of Record Id", type: "string" },
        "batch_id": { displayName: "Batch Id", type: "string" },
        "ingested_date": { displayName: "Ingested Date", type: "date" },
    },
    implementsInterfaces: [{
        implements: iWorkpaperInterface, propertyMapping: [
            { interfaceProperty: "hash_id", mapsTo: "hash_id" },
            { interfaceProperty: "start_date", mapsTo: "start_date" },
            { interfaceProperty: "end_date", mapsTo: "end_date" },
            { interfaceProperty: "description", mapsTo: "description" },
            { interfaceProperty: "amount", mapsTo: "amount" },
            { interfaceProperty: "raw_row", mapsTo: "raw_row" },
            { interfaceProperty: "workpaper_hash", mapsTo: "workpaper_hash" },
            { interfaceProperty: "file_id", mapsTo: "file_id" },
            { interfaceProperty: "customer_id", mapsTo: "customer_id" },
            { interfaceProperty: "system_of_record_id", mapsTo: "system_of_record_id" },
            { interfaceProperty: "batch_id", mapsTo: "batch_id" },
            { interfaceProperty: "ingested_date", mapsTo: "ingested_date" },
        ]
    }],
});

But I keep getting errors this this related to the interface properties not being implemented by workpapers-extracted (it does this for all proprs, I just limited it to one):

Error: Invariant failed: 
Ontology Definition Error: Interface spt com.palantirfoundry.<STACK>.<MAVEN_ID>.ontology-as-code-test-store.ontology-as-code-test.hash_id not implemented by workpapers-extracted object definition

What am I doing wring here?

Also the docs here need updating. As is they will generate this error due to the apiName of name and the key of firstName not matching.

Error: Invariant failed: property key and it's apiName must be identical. {"key":"firstName","apiName":"com.palantirfoundry.usw-3.codestrap.default-maven-id.ontology-as-code-test-store.ontology-as-code-test.name"}
    at invariant (file:///app/ri.jemma.main.job.00000005-95dd-ed79-acbc-d878fa079196-592521f5-ecdc-40e0-8fac-5422ebe69b0a/repo/node_modules/tiny-invariant/dist/esm/tiny-invariant.js:12:11)
    at verifyBasePropertyDefinition (file:///app/ri.jemma.main.job.00000005-95dd-ed79-acbc-d878fa079196-592521f5-ecdc-40e0-8fac-5422ebe69b0a/repo/node_modules/@osdk/maker/build/esm/api/defineInterface.js:91:124)
    at file:///app/ri.jemma.main.job.00000005-95dd-ed79-acbc-d878fa079196-592521f5-ecdc-40e0-8fac-5422ebe69b0a/repo/node_modules/@osdk/maker/build/esm/api/defineInterface.js:42:27
    at Array.map (<anonymous>)
    at defineInterface (file:///app/ri.jemma.main.job.00000005-95dd-ed79-acbc-d878fa079196-592521f5-ecdc-40e0-8fac-5422ebe69b0a/repo/node_modules/@osdk/maker/build/esm/api/defineInterface.js:38:64)
    at file:///app/ri.jemma.main.job.00000005-95dd-ed79-acbc-d878fa079196-592521f5-ecdc-40e0-8fac-5422ebe69b0a/repo/dist/index.mjs:10:27
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

OK, after fixing the sample provided from the OSDK documentation I get the exact same error. I am 99% confident this is an issue with your checks. The type definitions day my definitions are valid here:

Updated code:

import {
  defineSharedPropertyType,
  defineInterface,
  defineObject,
  defineLink,
  defineCreateObjectAction,
  defineModifyObjectAction,
  defineDeleteObjectAction,
} from "@osdk/maker";
// Define a simple string SPT
const nameProperty = defineSharedPropertyType({
  apiName: "firstName",
  type: "string",
  displayName: "Name",
  description: "The name of an entity",
});
const lastNameProperty = defineSharedPropertyType({
  apiName: "lastName",
  type: "string",
  displayName: "Name",
  description: "The name of an entity",
});
// Define an interface with existing property types
const employeeInterface = defineInterface({
  apiName: "Employee",
  displayName: "Employee",
  description: "Represents an employee",
  properties: {
    firstName: nameProperty, // Using previously defined SPT
    lastName: lastNameProperty, // Using previously defined SPT
    employeeId: { type: "string" },
    department: { type: "string" },
    hireDate: { type: "date" },
    isActive: { type: "boolean" },
  },
});

// Define an object that implements an interface
const employeeObject = defineObject({
  apiName: "employee",
  displayName: "Employee",
  pluralDisplayName: "Employees",
  titlePropertyApiName: "firstName",
  primaryKeyPropertyApiName: "id",
  properties: {
    id: { type: "string", displayName: "ID" },
    firstName: { type: "string" },
    lastName: { type: "string" },
    email: { type: "string" },
    department: { type: "string" },
    hireDate: { type: "date", displayName: "Hire Date" },
    isActive: { type: "boolean" },
  },
  implementsInterfaces: [
    {
      implements: employeeInterface,
      propertyMapping: [
        { interfaceProperty: "firstName", mapsTo: "firstName" },
        { interfaceProperty: "lastName", mapsTo: "lastName" },
        { interfaceProperty: "employeeId", mapsTo: "id" },
        { interfaceProperty: "department", mapsTo: "department" },
        { interfaceProperty: "hireDate", mapsTo: "hireDate" },
        { interfaceProperty: "isActive", mapsTo: "isActive" },
      ],
    },
  ],
});

Unexpected error while processing the body of the ontology Error: Invariant failed: 
Ontology Definition Error: Interface spt com.palantirfoundry.usw-3.codestrap.default-maven-id.ontology-as-code-test-store.ontology-as-code-test.firstName not implemented by employee object definition

Ontology Definition Error: Interface spt com.palantirfoundry.usw-3.codestrap.default-maven-id.ontology-as-code-test-store.ontology-as-code-test.lastName not implemented by employee object definition

    at invariant (file:///app/ri.jemma.main.job.00000005-95e0-1a51-a21b-e3b051e05f82-9b1a6608-8015-46ff-8d81-d0dde8b1c420/repo/node_modules/tiny-invariant/dist/esm/tiny-invariant.js:12:11)
    at file:///app/ri.jemma.main.job.00000005-95e0-1a51-a21b-e3b051e05f82-9b1a6608-8015-46ff-8d81-d0dde8b1c420/repo/node_modules/@osdk/maker/build/esm/api/defineObject.js:89:84
    at Array.forEach (<anonymous>)
    at defineObject (file:///app/ri.jemma.main.job.00000005-95e0-1a51-a21b-e3b051e05f82-9b1a6608-8015-46ff-8d81-d0dde8b1c420/repo/node_modules/@osdk/maker/build/esm/api/defineObject.js:70:35)
    at file:///app/ri.jemma.main.job.00000005-95e0-1a51-a21b-e3b051e05f82-9b1a6608-8015-46ff-8d81-d0dde8b1c420/repo/dist/index.mjs:30:24
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);

I also tried with the SptWithOptional and I get the same result:

properties: {
    firstName: {
      required: true,
      sharedPropertyType: nameProperty,
    }, // Using previously defined SPT
    lastName: {
      required: true,
      sharedPropertyType: lastNameProperty,
    }, 

After removing the use of shared properties in my interface definitions it works

import {
  defineSharedPropertyType,
  defineInterface,
  defineObject,
  defineLink,
  defineCreateObjectAction,
  defineModifyObjectAction,
  defineDeleteObjectAction,
} from "@osdk/maker";
// Define a simple string SPT
const nameProperty = defineSharedPropertyType({
  apiName: "firstName",
  type: "string",
  displayName: "Name",
  description: "The name of an entity",
});
const lastNameProperty = defineSharedPropertyType({
  apiName: "lastName",
  type: "string",
  displayName: "Name",
  description: "The name of an entity",
});
// Define an interface with existing property types
const employeeInterface = defineInterface({
  apiName: "Employee",
  displayName: "Employee",
  description: "Represents an employee",
  properties: {
    firstName: { type: "string" }, // Using previously defined SPT
    lastName: { type: "string" }, // Using previously defined SPT
    employeeId: { type: "string" },
    department: { type: "string" },
    hireDate: { type: "date" },
    isActive: { type: "boolean" },
  },
});

// Define an object that implements an interface
const employeeObject = defineObject({
  apiName: "employee",
  displayName: "Employee",
  pluralDisplayName: "Employees",
  titlePropertyApiName: "firstName",
  primaryKeyPropertyApiName: "id",
  properties: {
    id: { type: "string", displayName: "ID" },
    firstName: { type: "string" },
    lastName: { type: "string" },
    email: { type: "string" },
    department: { type: "string" },
    hireDate: { type: "date", displayName: "Hire Date" },
    isActive: { type: "boolean" },
  },
  implementsInterfaces: [
    {
      implements: employeeInterface,
      propertyMapping: [
        { interfaceProperty: "firstName", mapsTo: "firstName" },
        { interfaceProperty: "lastName", mapsTo: "lastName" },
        { interfaceProperty: "employeeId", mapsTo: "id" },
        { interfaceProperty: "department", mapsTo: "department" },
        { interfaceProperty: "hireDate", mapsTo: "hireDate" },
        { interfaceProperty: "isActive", mapsTo: "isActive" },
      ],
    },
  ],
});

const a = { type: "string" };
const b = { type: "string" };

console.log(a === b); // current implementation logic 
const a = { type: "string" };
const b = a;

console.log(a === b); // true

I think the issue is on the remapping it’s creating a new inline instance.

Is the below an appropriate solution?

properties: {
  hash_id: hashIdProperty,
  start_date: startDateProperty,
  end_date: endDateProperty,
  description: descriptionProperty,
  amount: amountProperty,
  raw_row: rawRowProperty,
  workpaper_hash: workpaperHashProperty,
  file_id: fileIdProperty,
  customer_id: customerIdProperty,
  system_of_record_id: systemOfRecordIdProperty,
  batch_id: batchIdProperty,
  ingested_date: ingestedDateProperty,
},

no, that is what I tried originally then switched to inline property definitions so I could at least get checks to pass.