@rippling/rippling-sdk 0.2.0-alpha.85 → 0.2.0-alpha.87
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/client.d.mts +15 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +15 -0
- package/client.d.ts.map +1 -1
- package/client.js +15 -0
- package/client.js.map +1 -1
- package/client.mjs +15 -0
- package/client.mjs.map +1 -1
- package/core/platform/custom-objects/category.d.mts +125 -0
- package/core/platform/custom-objects/category.d.mts.map +1 -0
- package/core/platform/custom-objects/category.d.ts +125 -0
- package/core/platform/custom-objects/category.d.ts.map +1 -0
- package/core/platform/custom-objects/category.js +188 -0
- package/core/platform/custom-objects/category.js.map +1 -0
- package/core/platform/custom-objects/category.mjs +178 -0
- package/core/platform/custom-objects/category.mjs.map +1 -0
- package/core/platform/custom-objects/definition.d.mts +147 -0
- package/core/platform/custom-objects/definition.d.mts.map +1 -0
- package/core/platform/custom-objects/definition.d.ts +147 -0
- package/core/platform/custom-objects/definition.d.ts.map +1 -0
- package/core/platform/custom-objects/definition.js +200 -0
- package/core/platform/custom-objects/definition.js.map +1 -0
- package/core/platform/custom-objects/definition.mjs +190 -0
- package/core/platform/custom-objects/definition.mjs.map +1 -0
- package/core/platform/custom-objects/fields.d.mts +302 -0
- package/core/platform/custom-objects/fields.d.mts.map +1 -0
- package/core/platform/custom-objects/fields.d.ts +302 -0
- package/core/platform/custom-objects/fields.d.ts.map +1 -0
- package/core/platform/custom-objects/fields.js +369 -0
- package/core/platform/custom-objects/fields.js.map +1 -0
- package/core/platform/custom-objects/fields.mjs +347 -0
- package/core/platform/custom-objects/fields.mjs.map +1 -0
- package/core/platform/custom-objects/function-runtime.d.mts +42 -0
- package/core/platform/custom-objects/function-runtime.d.mts.map +1 -0
- package/core/platform/custom-objects/function-runtime.d.ts +42 -0
- package/core/platform/custom-objects/function-runtime.d.ts.map +1 -0
- package/core/platform/custom-objects/function-runtime.js +38 -0
- package/core/platform/custom-objects/function-runtime.js.map +1 -0
- package/core/platform/custom-objects/function-runtime.mjs +35 -0
- package/core/platform/custom-objects/function-runtime.mjs.map +1 -0
- package/core/platform/custom-objects/lifecycle.d.mts +83 -0
- package/core/platform/custom-objects/lifecycle.d.mts.map +1 -0
- package/core/platform/custom-objects/lifecycle.d.ts +83 -0
- package/core/platform/custom-objects/lifecycle.d.ts.map +1 -0
- package/core/platform/custom-objects/lifecycle.js +372 -0
- package/core/platform/custom-objects/lifecycle.js.map +1 -0
- package/core/platform/custom-objects/lifecycle.mjs +367 -0
- package/core/platform/custom-objects/lifecycle.mjs.map +1 -0
- package/core/platform/custom-objects/manager.d.mts +354 -0
- package/core/platform/custom-objects/manager.d.mts.map +1 -0
- package/core/platform/custom-objects/manager.d.ts +354 -0
- package/core/platform/custom-objects/manager.d.ts.map +1 -0
- package/core/platform/custom-objects/manager.js +646 -0
- package/core/platform/custom-objects/manager.js.map +1 -0
- package/core/platform/custom-objects/manager.mjs +637 -0
- package/core/platform/custom-objects/manager.mjs.map +1 -0
- package/core/platform/custom-objects/provisioning.d.mts +138 -0
- package/core/platform/custom-objects/provisioning.d.mts.map +1 -0
- package/core/platform/custom-objects/provisioning.d.ts +138 -0
- package/core/platform/custom-objects/provisioning.d.ts.map +1 -0
- package/core/platform/custom-objects/provisioning.js +455 -0
- package/core/platform/custom-objects/provisioning.js.map +1 -0
- package/core/platform/custom-objects/provisioning.mjs +447 -0
- package/core/platform/custom-objects/provisioning.mjs.map +1 -0
- package/core/platform/custom-objects/rql.d.mts +122 -0
- package/core/platform/custom-objects/rql.d.mts.map +1 -0
- package/core/platform/custom-objects/rql.d.ts +122 -0
- package/core/platform/custom-objects/rql.d.ts.map +1 -0
- package/core/platform/custom-objects/rql.js +225 -0
- package/core/platform/custom-objects/rql.js.map +1 -0
- package/core/platform/custom-objects/rql.mjs +222 -0
- package/core/platform/custom-objects/rql.mjs.map +1 -0
- package/core/platform/custom-objects/schema-manager.d.mts +203 -0
- package/core/platform/custom-objects/schema-manager.d.mts.map +1 -0
- package/core/platform/custom-objects/schema-manager.d.ts +203 -0
- package/core/platform/custom-objects/schema-manager.d.ts.map +1 -0
- package/core/platform/custom-objects/schema-manager.js +256 -0
- package/core/platform/custom-objects/schema-manager.js.map +1 -0
- package/core/platform/custom-objects/schema-manager.mjs +249 -0
- package/core/platform/custom-objects/schema-manager.mjs.map +1 -0
- package/core/platform/custom-objects/typed-rql.d.mts +157 -0
- package/core/platform/custom-objects/typed-rql.d.mts.map +1 -0
- package/core/platform/custom-objects/typed-rql.d.ts +157 -0
- package/core/platform/custom-objects/typed-rql.d.ts.map +1 -0
- package/core/platform/custom-objects/typed-rql.js +583 -0
- package/core/platform/custom-objects/typed-rql.js.map +1 -0
- package/core/platform/custom-objects/typed-rql.mjs +580 -0
- package/core/platform/custom-objects/typed-rql.mjs.map +1 -0
- package/core/platform/custom-objects/types.d.mts +549 -0
- package/core/platform/custom-objects/types.d.mts.map +1 -0
- package/core/platform/custom-objects/types.d.ts +549 -0
- package/core/platform/custom-objects/types.d.ts.map +1 -0
- package/core/platform/custom-objects/types.js +20 -0
- package/core/platform/custom-objects/types.js.map +1 -0
- package/core/platform/custom-objects/types.mjs +17 -0
- package/core/platform/custom-objects/types.mjs.map +1 -0
- package/core/platform/custom-objects/validation.d.mts +97 -0
- package/core/platform/custom-objects/validation.d.mts.map +1 -0
- package/core/platform/custom-objects/validation.d.ts +97 -0
- package/core/platform/custom-objects/validation.d.ts.map +1 -0
- package/core/platform/custom-objects/validation.js +477 -0
- package/core/platform/custom-objects/validation.js.map +1 -0
- package/core/platform/custom-objects/validation.mjs +465 -0
- package/core/platform/custom-objects/validation.mjs.map +1 -0
- package/core/platform/custom-objects.d.mts +67 -0
- package/core/platform/custom-objects.d.mts.map +1 -0
- package/core/platform/custom-objects.d.ts +67 -0
- package/core/platform/custom-objects.d.ts.map +1 -0
- package/core/platform/custom-objects.js +118 -0
- package/core/platform/custom-objects.js.map +1 -0
- package/core/platform/custom-objects.mjs +45 -0
- package/core/platform/custom-objects.mjs.map +1 -0
- package/lib/leave-programs/advanced.d.mts +5 -0
- package/lib/leave-programs/advanced.d.mts.map +1 -0
- package/lib/leave-programs/advanced.d.ts +5 -0
- package/lib/leave-programs/advanced.d.ts.map +1 -0
- package/lib/leave-programs/advanced.js +13 -0
- package/lib/leave-programs/advanced.js.map +1 -0
- package/lib/leave-programs/advanced.mjs +4 -0
- package/lib/leave-programs/advanced.mjs.map +1 -0
- package/lib/leave-programs/context.d.mts +3 -0
- package/lib/leave-programs/context.d.mts.map +1 -0
- package/lib/leave-programs/context.d.ts +3 -0
- package/lib/leave-programs/context.d.ts.map +1 -0
- package/lib/leave-programs/context.js +89 -0
- package/lib/leave-programs/context.js.map +1 -0
- package/lib/leave-programs/context.mjs +86 -0
- package/lib/leave-programs/context.mjs.map +1 -0
- package/lib/leave-programs/define-company-leave-program.d.mts +3 -0
- package/lib/leave-programs/define-company-leave-program.d.mts.map +1 -0
- package/lib/leave-programs/define-company-leave-program.d.ts +3 -0
- package/lib/leave-programs/define-company-leave-program.d.ts.map +1 -0
- package/lib/leave-programs/define-company-leave-program.js +47 -0
- package/lib/leave-programs/define-company-leave-program.js.map +1 -0
- package/lib/leave-programs/define-company-leave-program.mjs +44 -0
- package/lib/leave-programs/define-company-leave-program.mjs.map +1 -0
- package/lib/leave-programs/duration.d.mts +5 -0
- package/lib/leave-programs/duration.d.mts.map +1 -0
- package/lib/leave-programs/duration.d.ts +5 -0
- package/lib/leave-programs/duration.d.ts.map +1 -0
- package/lib/leave-programs/duration.js +21 -0
- package/lib/leave-programs/duration.js.map +1 -0
- package/lib/leave-programs/duration.mjs +16 -0
- package/lib/leave-programs/duration.mjs.map +1 -0
- package/lib/leave-programs/pay.d.mts +4 -0
- package/lib/leave-programs/pay.d.mts.map +1 -0
- package/lib/leave-programs/pay.d.ts +4 -0
- package/lib/leave-programs/pay.d.ts.map +1 -0
- package/lib/leave-programs/pay.js +20 -0
- package/lib/leave-programs/pay.js.map +1 -0
- package/lib/leave-programs/pay.mjs +16 -0
- package/lib/leave-programs/pay.mjs.map +1 -0
- package/lib/leave-programs/policy-builder.d.mts +20 -0
- package/lib/leave-programs/policy-builder.d.mts.map +1 -0
- package/lib/leave-programs/policy-builder.d.ts +20 -0
- package/lib/leave-programs/policy-builder.d.ts.map +1 -0
- package/lib/leave-programs/policy-builder.js +89 -0
- package/lib/leave-programs/policy-builder.js.map +1 -0
- package/lib/leave-programs/policy-builder.mjs +85 -0
- package/lib/leave-programs/policy-builder.mjs.map +1 -0
- package/lib/leave-programs/recipes/parental-top-up-policy.d.mts +25 -0
- package/lib/leave-programs/recipes/parental-top-up-policy.d.mts.map +1 -0
- package/lib/leave-programs/recipes/parental-top-up-policy.d.ts +25 -0
- package/lib/leave-programs/recipes/parental-top-up-policy.d.ts.map +1 -0
- package/lib/leave-programs/recipes/parental-top-up-policy.js +56 -0
- package/lib/leave-programs/recipes/parental-top-up-policy.js.map +1 -0
- package/lib/leave-programs/recipes/parental-top-up-policy.mjs +53 -0
- package/lib/leave-programs/recipes/parental-top-up-policy.mjs.map +1 -0
- package/lib/leave-programs/testing.d.mts +8 -0
- package/lib/leave-programs/testing.d.mts.map +1 -0
- package/lib/leave-programs/testing.d.ts +8 -0
- package/lib/leave-programs/testing.d.ts.map +1 -0
- package/lib/leave-programs/testing.js +11 -0
- package/lib/leave-programs/testing.js.map +1 -0
- package/lib/leave-programs/testing.mjs +7 -0
- package/lib/leave-programs/testing.mjs.map +1 -0
- package/lib/leave-programs/types.d.mts +223 -0
- package/lib/leave-programs/types.d.mts.map +1 -0
- package/lib/leave-programs/types.d.ts +223 -0
- package/lib/leave-programs/types.d.ts.map +1 -0
- package/lib/leave-programs/types.js +10 -0
- package/lib/leave-programs/types.js.map +1 -0
- package/lib/leave-programs/types.mjs +7 -0
- package/lib/leave-programs/types.mjs.map +1 -0
- package/lib/leave-programs.d.mts +7 -0
- package/lib/leave-programs.d.mts.map +1 -0
- package/lib/leave-programs.d.ts +7 -0
- package/lib/leave-programs.d.ts.map +1 -0
- package/lib/leave-programs.js +19 -0
- package/lib/leave-programs.js.map +1 -0
- package/lib/leave-programs.mjs +7 -0
- package/lib/leave-programs.mjs.map +1 -0
- package/package.json +1 -1
- package/resources/agents/agents.d.mts +208 -0
- package/resources/agents/agents.d.mts.map +1 -0
- package/resources/agents/agents.d.ts +208 -0
- package/resources/agents/agents.d.ts.map +1 -0
- package/resources/agents/agents.js +64 -0
- package/resources/agents/agents.js.map +1 -0
- package/resources/agents/agents.mjs +59 -0
- package/resources/agents/agents.mjs.map +1 -0
- package/resources/agents/deployments.d.mts +180 -0
- package/resources/agents/deployments.d.mts.map +1 -0
- package/resources/agents/deployments.d.ts +180 -0
- package/resources/agents/deployments.d.ts.map +1 -0
- package/resources/agents/deployments.js +32 -0
- package/resources/agents/deployments.js.map +1 -0
- package/resources/agents/deployments.mjs +28 -0
- package/resources/agents/deployments.mjs.map +1 -0
- package/resources/agents/index.d.mts +5 -0
- package/resources/agents/index.d.mts.map +1 -0
- package/resources/agents/index.d.ts +5 -0
- package/resources/agents/index.d.ts.map +1 -0
- package/resources/agents/index.js +13 -0
- package/resources/agents/index.js.map +1 -0
- package/resources/agents/index.mjs +6 -0
- package/resources/agents/index.mjs.map +1 -0
- package/resources/agents/sessions/events.d.mts +80 -0
- package/resources/agents/sessions/events.d.mts.map +1 -0
- package/resources/agents/sessions/events.d.ts +80 -0
- package/resources/agents/sessions/events.d.ts.map +1 -0
- package/resources/agents/sessions/events.js +19 -0
- package/resources/agents/sessions/events.js.map +1 -0
- package/resources/agents/sessions/events.mjs +15 -0
- package/resources/agents/sessions/events.mjs.map +1 -0
- package/resources/agents/sessions/index.d.mts +3 -0
- package/resources/agents/sessions/index.d.mts.map +1 -0
- package/resources/agents/sessions/index.d.ts +3 -0
- package/resources/agents/sessions/index.d.ts.map +1 -0
- package/resources/agents/sessions/index.js +9 -0
- package/resources/agents/sessions/index.js.map +1 -0
- package/resources/agents/sessions/index.mjs +4 -0
- package/resources/agents/sessions/index.mjs.map +1 -0
- package/resources/agents/sessions/sessions.d.mts +153 -0
- package/resources/agents/sessions/sessions.d.mts.map +1 -0
- package/resources/agents/sessions/sessions.d.ts +153 -0
- package/resources/agents/sessions/sessions.d.ts.map +1 -0
- package/resources/agents/sessions/sessions.js +44 -0
- package/resources/agents/sessions/sessions.js.map +1 -0
- package/resources/agents/sessions/sessions.mjs +39 -0
- package/resources/agents/sessions/sessions.mjs.map +1 -0
- package/resources/agents/sessions.d.mts +2 -0
- package/resources/agents/sessions.d.mts.map +1 -0
- package/resources/agents/sessions.d.ts +2 -0
- package/resources/agents/sessions.d.ts.map +1 -0
- package/resources/agents/sessions.js +6 -0
- package/resources/agents/sessions.js.map +1 -0
- package/resources/agents/sessions.mjs +3 -0
- package/resources/agents/sessions.mjs.map +1 -0
- package/resources/agents/source-revisions.d.mts +195 -0
- package/resources/agents/source-revisions.d.mts.map +1 -0
- package/resources/agents/source-revisions.d.ts +195 -0
- package/resources/agents/source-revisions.d.ts.map +1 -0
- package/resources/agents/source-revisions.js +32 -0
- package/resources/agents/source-revisions.js.map +1 -0
- package/resources/agents/source-revisions.mjs +28 -0
- package/resources/agents/source-revisions.mjs.map +1 -0
- package/resources/agents.d.mts +2 -0
- package/resources/agents.d.mts.map +1 -0
- package/resources/agents.d.ts +2 -0
- package/resources/agents.d.ts.map +1 -0
- package/resources/agents.js +6 -0
- package/resources/agents.js.map +1 -0
- package/resources/agents.mjs +3 -0
- package/resources/agents.mjs.map +1 -0
- package/resources/break-policies.d.mts +1 -1
- package/resources/break-policies.d.ts +1 -1
- package/resources/break-policies.js +1 -1
- package/resources/break-policies.mjs +1 -1
- package/resources/break-types.d.mts +1 -1
- package/resources/break-types.d.ts +1 -1
- package/resources/break-types.js +1 -1
- package/resources/break-types.mjs +1 -1
- package/resources/business-structure-paths.d.mts +1 -1
- package/resources/business-structure-paths.d.ts +1 -1
- package/resources/business-structure-paths.js +1 -1
- package/resources/business-structure-paths.mjs +1 -1
- package/resources/candidate-applications.d.mts +1 -1
- package/resources/candidate-applications.d.ts +1 -1
- package/resources/candidate-applications.js +1 -1
- package/resources/candidate-applications.mjs +1 -1
- package/resources/candidates.d.mts +1 -1
- package/resources/candidates.d.ts +1 -1
- package/resources/candidates.js +1 -1
- package/resources/candidates.mjs +1 -1
- package/resources/company-legal-entities.d.mts +1 -1
- package/resources/company-legal-entities.d.ts +1 -1
- package/resources/company-legal-entities.js +1 -1
- package/resources/company-legal-entities.mjs +1 -1
- package/resources/company-legal-entity-workers.d.mts +1 -1
- package/resources/company-legal-entity-workers.d.ts +1 -1
- package/resources/company-legal-entity-workers.js +1 -1
- package/resources/company-legal-entity-workers.mjs +1 -1
- package/resources/compensation-bands-details.d.mts +1 -1
- package/resources/compensation-bands-details.d.ts +1 -1
- package/resources/compensation-bands-details.js +1 -1
- package/resources/compensation-bands-details.mjs +1 -1
- package/resources/compensations.d.mts +1 -1
- package/resources/compensations.d.ts +1 -1
- package/resources/compensations.js +1 -1
- package/resources/compensations.mjs +1 -1
- package/resources/custom-objects/custom-objects.d.mts +7 -0
- package/resources/custom-objects/custom-objects.d.mts.map +1 -1
- package/resources/custom-objects/custom-objects.d.ts +7 -0
- package/resources/custom-objects/custom-objects.d.ts.map +1 -1
- package/resources/custom-objects/custom-objects.js.map +1 -1
- package/resources/custom-objects/custom-objects.mjs.map +1 -1
- package/resources/custom-objects/fields.d.mts +129 -54
- package/resources/custom-objects/fields.d.mts.map +1 -1
- package/resources/custom-objects/fields.d.ts +129 -54
- package/resources/custom-objects/fields.d.ts.map +1 -1
- package/resources/device-orders.d.mts +1 -1
- package/resources/device-orders.d.ts +1 -1
- package/resources/device-orders.js +1 -1
- package/resources/device-orders.mjs +1 -1
- package/resources/devices.d.mts +1 -1
- package/resources/devices.d.ts +1 -1
- package/resources/devices.js +1 -1
- package/resources/devices.mjs +1 -1
- package/resources/functions/deployments.d.mts +2 -2
- package/resources/functions/deployments.d.ts +2 -2
- package/resources/functions/deployments.js +2 -2
- package/resources/functions/deployments.mjs +2 -2
- package/resources/functions/executions.d.mts +2 -2
- package/resources/functions/executions.d.ts +2 -2
- package/resources/functions/executions.js +2 -2
- package/resources/functions/executions.mjs +2 -2
- package/resources/functions/functions.d.mts +1 -1
- package/resources/functions/functions.d.ts +1 -1
- package/resources/functions/functions.js +1 -1
- package/resources/functions/functions.mjs +1 -1
- package/resources/headcount-positions.d.mts +1 -1
- package/resources/headcount-positions.d.ts +1 -1
- package/resources/headcount-positions.js +1 -1
- package/resources/headcount-positions.mjs +1 -1
- package/resources/headcount-priorities.d.mts +1 -1
- package/resources/headcount-priorities.d.ts +1 -1
- package/resources/headcount-priorities.js +1 -1
- package/resources/headcount-priorities.mjs +1 -1
- package/resources/index.d.mts +3 -0
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +3 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +8 -2
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +3 -0
- package/resources/index.mjs.map +1 -1
- package/resources/job-assignments.d.mts +2 -2
- package/resources/job-assignments.d.ts +2 -2
- package/resources/job-assignments.js +2 -2
- package/resources/job-assignments.mjs +2 -2
- package/resources/job-codes.d.mts +2 -2
- package/resources/job-codes.d.ts +2 -2
- package/resources/job-codes.js +2 -2
- package/resources/job-codes.mjs +2 -2
- package/resources/job-dimensions.d.mts +1 -1
- package/resources/job-dimensions.d.ts +1 -1
- package/resources/job-dimensions.js +1 -1
- package/resources/job-dimensions.mjs +1 -1
- package/resources/job-pay-rate-exceptions.d.mts +2 -2
- package/resources/job-pay-rate-exceptions.d.ts +2 -2
- package/resources/job-pay-rate-exceptions.js +2 -2
- package/resources/job-pay-rate-exceptions.mjs +2 -2
- package/resources/job-requisitions.d.mts +1 -1
- package/resources/job-requisitions.d.ts +1 -1
- package/resources/job-requisitions.js +1 -1
- package/resources/job-requisitions.mjs +1 -1
- package/resources/kiosk-badges.d.mts +1 -1
- package/resources/kiosk-badges.d.ts +1 -1
- package/resources/kiosk-badges.js +1 -1
- package/resources/kiosk-badges.mjs +1 -1
- package/resources/leave-accruals.d.mts +1 -1
- package/resources/leave-accruals.d.ts +1 -1
- package/resources/leave-accruals.js +1 -1
- package/resources/leave-accruals.mjs +1 -1
- package/resources/leave-balances.d.mts +1 -1
- package/resources/leave-balances.d.ts +1 -1
- package/resources/leave-balances.js +1 -1
- package/resources/leave-balances.mjs +1 -1
- package/resources/leave-requests.d.mts +1 -1
- package/resources/leave-requests.d.ts +1 -1
- package/resources/leave-requests.js +1 -1
- package/resources/leave-requests.mjs +1 -1
- package/resources/leave-types.d.mts +1 -1
- package/resources/leave-types.d.ts +1 -1
- package/resources/leave-types.js +1 -1
- package/resources/leave-types.mjs +1 -1
- package/resources/legal-entities.d.mts +1 -1
- package/resources/legal-entities.d.ts +1 -1
- package/resources/legal-entities.js +1 -1
- package/resources/legal-entities.mjs +1 -1
- package/resources/levels.d.mts +26 -5
- package/resources/levels.d.mts.map +1 -1
- package/resources/levels.d.ts +26 -5
- package/resources/levels.d.ts.map +1 -1
- package/resources/levels.js +1 -1
- package/resources/levels.mjs +1 -1
- package/resources/location-factors.d.mts +1 -1
- package/resources/location-factors.d.ts +1 -1
- package/resources/location-factors.js +1 -1
- package/resources/location-factors.mjs +1 -1
- package/resources/packages/index.d.mts +3 -0
- package/resources/packages/index.d.mts.map +1 -0
- package/resources/packages/index.d.ts +3 -0
- package/resources/packages/index.d.ts.map +1 -0
- package/resources/packages/index.js +9 -0
- package/resources/packages/index.js.map +1 -0
- package/resources/packages/index.mjs +4 -0
- package/resources/packages/index.mjs.map +1 -0
- package/resources/packages/packages.d.mts +239 -0
- package/resources/packages/packages.d.mts.map +1 -0
- package/resources/packages/packages.d.ts +239 -0
- package/resources/packages/packages.d.ts.map +1 -0
- package/resources/packages/packages.js +60 -0
- package/resources/packages/packages.js.map +1 -0
- package/resources/packages/packages.mjs +55 -0
- package/resources/packages/packages.mjs.map +1 -0
- package/resources/packages/versions.d.mts +72 -0
- package/resources/packages/versions.d.mts.map +1 -0
- package/resources/packages/versions.d.ts +72 -0
- package/resources/packages/versions.d.ts.map +1 -0
- package/resources/packages/versions.js +19 -0
- package/resources/packages/versions.js.map +1 -0
- package/resources/packages/versions.mjs +15 -0
- package/resources/packages/versions.mjs.map +1 -0
- package/resources/packages.d.mts +2 -0
- package/resources/packages.d.mts.map +1 -0
- package/resources/packages.d.ts +2 -0
- package/resources/packages.d.ts.map +1 -0
- package/resources/packages.js +6 -0
- package/resources/packages.js.map +1 -0
- package/resources/packages.mjs +3 -0
- package/resources/packages.mjs.map +1 -0
- package/resources/scheduled-job-assignments.d.mts +1 -1
- package/resources/scheduled-job-assignments.d.ts +1 -1
- package/resources/scheduled-job-assignments.js +1 -1
- package/resources/scheduled-job-assignments.mjs +1 -1
- package/resources/schedules.d.mts +1 -1
- package/resources/schedules.d.ts +1 -1
- package/resources/schedules.js +1 -1
- package/resources/schedules.mjs +1 -1
- package/resources/shift-assignments.d.mts +1 -1
- package/resources/shift-assignments.d.ts +1 -1
- package/resources/shift-assignments.js +1 -1
- package/resources/shift-assignments.mjs +1 -1
- package/resources/shift-inputs.d.mts +1 -1
- package/resources/shift-inputs.d.ts +1 -1
- package/resources/shift-inputs.js +1 -1
- package/resources/shift-inputs.mjs +1 -1
- package/resources/shiftassignments.d.mts +1 -1
- package/resources/shiftassignments.d.ts +1 -1
- package/resources/shiftassignments.js +1 -1
- package/resources/shiftassignments.mjs +1 -1
- package/resources/sites.d.mts +572 -0
- package/resources/sites.d.mts.map +1 -0
- package/resources/sites.d.ts +572 -0
- package/resources/sites.d.ts.map +1 -0
- package/resources/sites.js +154 -0
- package/resources/sites.js.map +1 -0
- package/resources/sites.mjs +150 -0
- package/resources/sites.mjs.map +1 -0
- package/resources/software-deployments.d.mts +1 -1
- package/resources/software-deployments.d.ts +1 -1
- package/resources/software-deployments.js +1 -1
- package/resources/software-deployments.mjs +1 -1
- package/resources/time-cards.d.mts +1 -1
- package/resources/time-cards.d.ts +1 -1
- package/resources/time-cards.js +1 -1
- package/resources/time-cards.mjs +1 -1
- package/resources/time-entries.d.mts +1 -1
- package/resources/time-entries.d.ts +1 -1
- package/resources/time-entries.js +1 -1
- package/resources/time-entries.mjs +1 -1
- package/resources/tracks.d.mts +1 -1
- package/resources/tracks.d.ts +1 -1
- package/resources/tracks.js +1 -1
- package/resources/tracks.mjs +1 -1
- package/resources/unassigned-shifts.d.mts +2 -2
- package/resources/unassigned-shifts.d.ts +2 -2
- package/resources/unassigned-shifts.js +2 -2
- package/resources/unassigned-shifts.mjs +2 -2
- package/resources/unassignedshifts.d.mts +1 -1
- package/resources/unassignedshifts.d.ts +1 -1
- package/resources/unassignedshifts.js +1 -1
- package/resources/unassignedshifts.mjs +1 -1
- package/resources/worker-time-splits.d.mts +1 -1
- package/resources/worker-time-splits.d.ts +1 -1
- package/resources/worker-time-splits.js +1 -1
- package/resources/worker-time-splits.mjs +1 -1
- package/src/client.ts +91 -0
- package/src/core/platform/custom-objects/category.ts +294 -0
- package/src/core/platform/custom-objects/definition.ts +373 -0
- package/src/core/platform/custom-objects/fields.ts +653 -0
- package/src/core/platform/custom-objects/function-runtime.ts +76 -0
- package/src/core/platform/custom-objects/lifecycle.ts +557 -0
- package/src/core/platform/custom-objects/manager.ts +959 -0
- package/src/core/platform/custom-objects/provisioning.ts +672 -0
- package/src/core/platform/custom-objects/rql.ts +375 -0
- package/src/core/platform/custom-objects/schema-manager.ts +351 -0
- package/src/core/platform/custom-objects/typed-rql.ts +1273 -0
- package/src/core/platform/custom-objects/types.ts +753 -0
- package/src/core/platform/custom-objects/validation.ts +573 -0
- package/src/core/platform/custom-objects.ts +269 -0
- package/src/lib/leave-programs/README.md +160 -0
- package/src/lib/leave-programs/advanced.ts +11 -0
- package/src/lib/leave-programs/context.ts +101 -0
- package/src/lib/leave-programs/define-company-leave-program.ts +58 -0
- package/src/lib/leave-programs/duration.ts +20 -0
- package/src/lib/leave-programs/pay.ts +18 -0
- package/src/lib/leave-programs/policy-builder.ts +113 -0
- package/src/lib/leave-programs/recipes/parental-top-up-policy.ts +85 -0
- package/src/lib/leave-programs/testing.ts +16 -0
- package/src/lib/leave-programs/types.ts +274 -0
- package/src/lib/leave-programs.ts +35 -0
- package/src/resources/agents/agents.ts +340 -0
- package/src/resources/agents/deployments.ts +249 -0
- package/src/resources/agents/index.ts +40 -0
- package/src/resources/agents/sessions/events.ts +107 -0
- package/src/resources/agents/sessions/index.ts +12 -0
- package/src/resources/agents/sessions/sessions.ts +216 -0
- package/src/resources/agents/sessions.ts +3 -0
- package/src/resources/agents/source-revisions.ts +267 -0
- package/src/resources/agents.ts +3 -0
- package/src/resources/break-policies.ts +1 -1
- package/src/resources/break-types.ts +1 -1
- package/src/resources/business-structure-paths.ts +1 -1
- package/src/resources/candidate-applications.ts +1 -1
- package/src/resources/candidates.ts +1 -1
- package/src/resources/company-legal-entities.ts +1 -1
- package/src/resources/company-legal-entity-workers.ts +1 -1
- package/src/resources/compensation-bands-details.ts +1 -1
- package/src/resources/compensations.ts +1 -1
- package/src/resources/custom-objects/custom-objects.ts +8 -0
- package/src/resources/custom-objects/fields.ts +192 -59
- package/src/resources/device-orders.ts +1 -1
- package/src/resources/devices.ts +1 -1
- package/src/resources/functions/deployments.ts +2 -2
- package/src/resources/functions/executions.ts +2 -2
- package/src/resources/functions/functions.ts +1 -1
- package/src/resources/headcount-positions.ts +1 -1
- package/src/resources/headcount-priorities.ts +1 -1
- package/src/resources/index.ts +38 -0
- package/src/resources/job-assignments.ts +2 -2
- package/src/resources/job-codes.ts +2 -2
- package/src/resources/job-dimensions.ts +1 -1
- package/src/resources/job-pay-rate-exceptions.ts +2 -2
- package/src/resources/job-requisitions.ts +1 -1
- package/src/resources/kiosk-badges.ts +1 -1
- package/src/resources/leave-accruals.ts +1 -1
- package/src/resources/leave-balances.ts +1 -1
- package/src/resources/leave-requests.ts +1 -1
- package/src/resources/leave-types.ts +1 -1
- package/src/resources/legal-entities.ts +1 -1
- package/src/resources/levels.ts +29 -5
- package/src/resources/location-factors.ts +1 -1
- package/src/resources/packages/index.ts +14 -0
- package/src/resources/packages/packages.ts +329 -0
- package/src/resources/packages/versions.ts +98 -0
- package/src/resources/packages.ts +3 -0
- package/src/resources/scheduled-job-assignments.ts +1 -1
- package/src/resources/schedules.ts +1 -1
- package/src/resources/shift-assignments.ts +1 -1
- package/src/resources/shift-inputs.ts +1 -1
- package/src/resources/shiftassignments.ts +1 -1
- package/src/resources/sites.ts +736 -0
- package/src/resources/software-deployments.ts +1 -1
- package/src/resources/time-cards.ts +1 -1
- package/src/resources/time-entries.ts +1 -1
- package/src/resources/tracks.ts +1 -1
- package/src/resources/unassigned-shifts.ts +2 -2
- package/src/resources/unassignedshifts.ts +1 -1
- package/src/resources/worker-time-splits.ts +1 -1
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,959 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomObjectDataRow,
|
|
3
|
+
RecordBulkCreateResponse,
|
|
4
|
+
RecordBulkUpdateResponse,
|
|
5
|
+
RecordCreateResponse,
|
|
6
|
+
RecordQueryParams,
|
|
7
|
+
RecordQueryResponse,
|
|
8
|
+
RecordUpdateResponse,
|
|
9
|
+
} from '../../../resources/custom-objects/records';
|
|
10
|
+
import { validateCreateInput, validateUpdateInput, type ValidationIssue } from './validation';
|
|
11
|
+
import type {
|
|
12
|
+
AnyCustomObjectDefinition,
|
|
13
|
+
AnyFieldDefinition,
|
|
14
|
+
CreateInput,
|
|
15
|
+
LookupReference,
|
|
16
|
+
RecordShape,
|
|
17
|
+
UpdateInput,
|
|
18
|
+
} from './types';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Minimal records-resource surface consumed by {@link CustomObjectManager}.
|
|
22
|
+
*
|
|
23
|
+
* This is intentionally narrower than the full SDK client. Callers can pass the
|
|
24
|
+
* real `client.customObjects.records` resource or a lightweight test double
|
|
25
|
+
* exposing the same methods.
|
|
26
|
+
*/
|
|
27
|
+
export interface CustomObjectRecordsClient {
|
|
28
|
+
create(customObjectApiName: string, body: Record<string, unknown>): Promise<RecordCreateResponse>;
|
|
29
|
+
retrieve(customObjectApiName: string, recordId: string): Promise<CustomObjectDataRow>;
|
|
30
|
+
retrieveByExternalID(customObjectApiName: string, externalID: string): Promise<CustomObjectDataRow>;
|
|
31
|
+
update(
|
|
32
|
+
customObjectApiName: string,
|
|
33
|
+
recordId: string,
|
|
34
|
+
body: Record<string, unknown>,
|
|
35
|
+
): Promise<RecordUpdateResponse>;
|
|
36
|
+
delete(customObjectApiName: string, recordId: string): Promise<void>;
|
|
37
|
+
query(customObjectApiName: string, params: RecordQueryParams): Promise<RecordQueryResponse>;
|
|
38
|
+
bulkCreate(
|
|
39
|
+
customObjectApiName: string,
|
|
40
|
+
body: { all_or_nothing?: boolean; rows_to_write: Array<{ [key: string]: unknown }> },
|
|
41
|
+
): Promise<RecordBulkCreateResponse>;
|
|
42
|
+
bulkUpdate(
|
|
43
|
+
customObjectApiName: string,
|
|
44
|
+
body: { all_or_nothing?: boolean; rows_to_update: Array<{ [key: string]: unknown }> },
|
|
45
|
+
): Promise<RecordBulkUpdateResponse>;
|
|
46
|
+
bulkDelete(
|
|
47
|
+
customObjectApiName: string,
|
|
48
|
+
body: { all_or_nothing?: boolean; rows_to_delete: string[] },
|
|
49
|
+
): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Minimal SDK-shaped wrapper accepted by {@link CustomObjectManager.fromSDK}. */
|
|
53
|
+
interface CustomObjectManagerSDKLike {
|
|
54
|
+
readonly customObjects: {
|
|
55
|
+
readonly records: CustomObjectRecordsClient;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Response shape returned by low-level record queries. */
|
|
60
|
+
export interface CustomObjectRecordQueryResponse {
|
|
61
|
+
/** Opaque pagination cursor returned by the backend, if any. */
|
|
62
|
+
readonly cursor: string | null;
|
|
63
|
+
/** Raw backend rows returned for the query. */
|
|
64
|
+
readonly results: readonly CustomObjectDataRow[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Adapter request for batch creates. */
|
|
68
|
+
export interface CustomObjectRecordBulkCreateRequest {
|
|
69
|
+
/** Whether the backend should reject the entire batch if any row fails. */
|
|
70
|
+
readonly allOrNothing?: boolean;
|
|
71
|
+
/** Wire-level rows to create. */
|
|
72
|
+
readonly rowsToWrite: readonly Record<string, unknown>[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Adapter request for batch updates. */
|
|
76
|
+
export interface CustomObjectRecordBulkUpdateRequest {
|
|
77
|
+
/** Whether the backend should reject the entire batch if any row fails. */
|
|
78
|
+
readonly allOrNothing?: boolean;
|
|
79
|
+
/** Wire-level rows to update, including each record id. */
|
|
80
|
+
readonly rowsToUpdate: readonly Record<string, unknown>[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Adapter request for batch deletes. */
|
|
84
|
+
export interface CustomObjectRecordBulkDeleteRequest {
|
|
85
|
+
/** Whether the backend should reject the entire batch if any row fails. */
|
|
86
|
+
readonly allOrNothing?: boolean;
|
|
87
|
+
/** Record ids to delete. */
|
|
88
|
+
readonly rowsToDelete: readonly string[];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Small transport boundary used by the typed manager.
|
|
93
|
+
*
|
|
94
|
+
* Production code can use {@link createCustomObjectRecordAdapter}. Unit tests
|
|
95
|
+
* can provide an in-memory or hand-rolled adapter without depending on a real
|
|
96
|
+
* backend client.
|
|
97
|
+
*/
|
|
98
|
+
export interface CustomObjectRecordAdapter {
|
|
99
|
+
/** Creates one wire-level record. */
|
|
100
|
+
create(customObjectApiName: string, body: Record<string, unknown>): Promise<CustomObjectDataRow>;
|
|
101
|
+
/** Retrieves one wire-level record by id. */
|
|
102
|
+
retrieve(customObjectApiName: string, recordId: string): Promise<CustomObjectDataRow>;
|
|
103
|
+
/** Retrieves one wire-level record by external id. */
|
|
104
|
+
retrieveByExternalID(customObjectApiName: string, externalID: string): Promise<CustomObjectDataRow>;
|
|
105
|
+
/** Updates one wire-level record. */
|
|
106
|
+
update(
|
|
107
|
+
customObjectApiName: string,
|
|
108
|
+
recordId: string,
|
|
109
|
+
body: Record<string, unknown>,
|
|
110
|
+
): Promise<CustomObjectDataRow>;
|
|
111
|
+
/** Deletes one wire-level record. */
|
|
112
|
+
delete(customObjectApiName: string, recordId: string): Promise<void>;
|
|
113
|
+
/** Runs a backend query and returns raw rows. */
|
|
114
|
+
query(customObjectApiName: string, params: RecordQueryParams): Promise<CustomObjectRecordQueryResponse>;
|
|
115
|
+
/** Creates many wire-level rows. */
|
|
116
|
+
bulkCreate(
|
|
117
|
+
customObjectApiName: string,
|
|
118
|
+
request: CustomObjectRecordBulkCreateRequest,
|
|
119
|
+
): Promise<readonly CustomObjectDataRow[]>;
|
|
120
|
+
/** Updates many wire-level rows. */
|
|
121
|
+
bulkUpdate(
|
|
122
|
+
customObjectApiName: string,
|
|
123
|
+
request: CustomObjectRecordBulkUpdateRequest,
|
|
124
|
+
): Promise<readonly CustomObjectDataRow[]>;
|
|
125
|
+
/** Deletes many wire-level rows. */
|
|
126
|
+
bulkDelete(customObjectApiName: string, request: CustomObjectRecordBulkDeleteRequest): Promise<void>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Constructor options for {@link CustomObjectManager}. */
|
|
130
|
+
export interface CustomObjectManagerOptions {
|
|
131
|
+
/** Records resource to use for transport. */
|
|
132
|
+
readonly records?: CustomObjectRecordsClient;
|
|
133
|
+
/** Custom adapter implementation for tests or non-SDK backends. */
|
|
134
|
+
readonly adapter?: CustomObjectRecordAdapter;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Lightweight pagination options shared by list and query helpers. */
|
|
138
|
+
export interface TypedRecordPageOptions {
|
|
139
|
+
/** Opaque pagination cursor returned by a prior call. */
|
|
140
|
+
readonly cursor?: string;
|
|
141
|
+
/** Maximum number of records to return. */
|
|
142
|
+
readonly limit?: number;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Raw-query options for typed record queries. */
|
|
146
|
+
export interface TypedRecordQueryOptions extends TypedRecordPageOptions {
|
|
147
|
+
/** RQL string to execute against the underlying backend. */
|
|
148
|
+
readonly query?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Pagination result returned by typed list/query helpers. */
|
|
152
|
+
export interface TypedRecordPage<TDefinition extends AnyCustomObjectDefinition> {
|
|
153
|
+
/** Opaque backend cursor, if another page is available. */
|
|
154
|
+
readonly cursor: string | null;
|
|
155
|
+
/** Strongly typed logical-key records. */
|
|
156
|
+
readonly results: readonly RecordShape<TDefinition>[];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Batch-write flags shared by bulk create/update/delete helpers. */
|
|
160
|
+
export interface TypedBatchWriteOptions {
|
|
161
|
+
/** Whether the backend should reject the entire batch if any row fails. */
|
|
162
|
+
readonly allOrNothing?: boolean;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* One logical update item for {@link TypedCustomObjectRecordManager.updateMany}.
|
|
167
|
+
*
|
|
168
|
+
* @typeParam TDefinition - Object definition whose update payload should be enforced.
|
|
169
|
+
*/
|
|
170
|
+
export type TypedBulkUpdateInput<TDefinition extends AnyCustomObjectDefinition> = {
|
|
171
|
+
readonly id: string;
|
|
172
|
+
} & UpdateInput<TDefinition>;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Structured validation failure thrown by typed record managers.
|
|
176
|
+
*
|
|
177
|
+
* @typeParam TDefinition - Object definition whose payload validation failed.
|
|
178
|
+
*/
|
|
179
|
+
export class CustomObjectRecordValidationError<
|
|
180
|
+
TDefinition extends AnyCustomObjectDefinition = AnyCustomObjectDefinition,
|
|
181
|
+
> extends Error {
|
|
182
|
+
/** Definition whose payload validation failed. */
|
|
183
|
+
readonly definition: TDefinition;
|
|
184
|
+
/** Operation that was being attempted. */
|
|
185
|
+
readonly operation: 'create' | 'update' | 'bulk-create' | 'bulk-update';
|
|
186
|
+
/** Field-level validation issues returned by the schema validators. */
|
|
187
|
+
readonly issues: readonly ValidationIssue[];
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Builds a validation error for a typed record operation.
|
|
191
|
+
*
|
|
192
|
+
* @typeParam TDefinition - Object definition whose payload validation failed.
|
|
193
|
+
*/
|
|
194
|
+
constructor(
|
|
195
|
+
definition: TDefinition,
|
|
196
|
+
operation: 'create' | 'update' | 'bulk-create' | 'bulk-update',
|
|
197
|
+
issues: readonly ValidationIssue[],
|
|
198
|
+
) {
|
|
199
|
+
super(
|
|
200
|
+
`Invalid ${operation} payload for ${definition.apiName}: ${issues
|
|
201
|
+
.map((current) => `${current.path}: ${current.message}`)
|
|
202
|
+
.join('; ')}`,
|
|
203
|
+
);
|
|
204
|
+
this.name = 'CustomObjectRecordValidationError';
|
|
205
|
+
this.definition = definition;
|
|
206
|
+
this.operation = operation;
|
|
207
|
+
this.issues = issues;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Options for creating an in-memory adapter. */
|
|
212
|
+
export interface InMemoryCustomObjectRecordAdapterOptions {
|
|
213
|
+
/** Optional starting rows keyed by custom-object api name. */
|
|
214
|
+
readonly seedRowsByObjectApiName?: Readonly<Record<string, readonly CustomObjectDataRow[]>>;
|
|
215
|
+
/** Optional deterministic clock used for tests. */
|
|
216
|
+
readonly now?: () => string;
|
|
217
|
+
/** Optional deterministic id generator used for tests. */
|
|
218
|
+
readonly nextID?: (customObjectApiName: string) => string;
|
|
219
|
+
/**
|
|
220
|
+
* Optional raw-query evaluator.
|
|
221
|
+
*
|
|
222
|
+
* If omitted, the in-memory adapter supports pagination-only list/query calls
|
|
223
|
+
* and rejects query strings that would require actual RQL evaluation.
|
|
224
|
+
*/
|
|
225
|
+
readonly queryEvaluator?: (args: {
|
|
226
|
+
customObjectApiName: string;
|
|
227
|
+
query: string;
|
|
228
|
+
row: CustomObjectDataRow;
|
|
229
|
+
}) => boolean;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Returns whether one value is a plain object-like record.
|
|
234
|
+
*
|
|
235
|
+
* @param value - Candidate value to inspect.
|
|
236
|
+
* @returns Whether the value is a non-array object.
|
|
237
|
+
*/
|
|
238
|
+
function isObject(value: unknown): value is Record<string, unknown> {
|
|
239
|
+
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Requires a create/update response to contain the expected row payload.
|
|
244
|
+
*
|
|
245
|
+
* @param customObjectApiName - Custom-object API name involved in the operation.
|
|
246
|
+
* @param operation - Human-readable operation name for error messages.
|
|
247
|
+
* @param row - Optional row payload returned by the backend.
|
|
248
|
+
* @returns Required row payload.
|
|
249
|
+
* @throws Error when the backend response is missing the expected row payload.
|
|
250
|
+
*/
|
|
251
|
+
function requireSingleRow(
|
|
252
|
+
customObjectApiName: string,
|
|
253
|
+
operation: string,
|
|
254
|
+
row: CustomObjectDataRow | undefined,
|
|
255
|
+
): CustomObjectDataRow {
|
|
256
|
+
if (row != null) return row;
|
|
257
|
+
throw new Error(`Expected ${operation} on ${customObjectApiName} to return a record payload.`);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Normalizes a lookup-or-file value into the wire-level id string expected by the REST API.
|
|
262
|
+
*
|
|
263
|
+
* @param value - Logical lookup or file value to normalize.
|
|
264
|
+
* @returns Wire-level id string when possible, otherwise the original value.
|
|
265
|
+
*/
|
|
266
|
+
function toWireReference(value: unknown): unknown {
|
|
267
|
+
if (typeof value === 'string') return value;
|
|
268
|
+
if (isObject(value) && typeof value['id'] === 'string') return value['id'];
|
|
269
|
+
return value;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Serializes one logical field value into the backend wire shape.
|
|
274
|
+
*
|
|
275
|
+
* @param field - Typed field definition that owns the value.
|
|
276
|
+
* @param value - Logical field value to serialize.
|
|
277
|
+
* @returns Wire-level field value suitable for the records API.
|
|
278
|
+
*/
|
|
279
|
+
function serializeFieldValue(field: AnyFieldDefinition, value: unknown): unknown {
|
|
280
|
+
switch (field.kind) {
|
|
281
|
+
case 'lookup':
|
|
282
|
+
case 'parent-child':
|
|
283
|
+
case 'file':
|
|
284
|
+
return toWireReference(value);
|
|
285
|
+
default:
|
|
286
|
+
return value;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Serializes a logical create/update payload into wire-level API-name keys.
|
|
292
|
+
*
|
|
293
|
+
* @param definition - Typed object definition that owns the payload fields.
|
|
294
|
+
* @param input - Logical create/update payload to serialize.
|
|
295
|
+
* @returns Wire-level payload suitable for the records API.
|
|
296
|
+
* @typeParam TDefinition - Object definition being serialized.
|
|
297
|
+
*/
|
|
298
|
+
function serializeRecordInput<TDefinition extends AnyCustomObjectDefinition>(
|
|
299
|
+
definition: TDefinition,
|
|
300
|
+
input: Record<string, unknown>,
|
|
301
|
+
): Record<string, unknown> {
|
|
302
|
+
const wire: Record<string, unknown> = {};
|
|
303
|
+
|
|
304
|
+
if (Object.prototype.hasOwnProperty.call(input, 'name') && input['name'] !== undefined) {
|
|
305
|
+
wire['name'] = input['name'];
|
|
306
|
+
}
|
|
307
|
+
if (Object.prototype.hasOwnProperty.call(input, 'external_id') && input['external_id'] !== undefined) {
|
|
308
|
+
wire['external_id'] = input['external_id'];
|
|
309
|
+
}
|
|
310
|
+
if (Object.prototype.hasOwnProperty.call(input, 'owner_role') && input['owner_role'] !== undefined) {
|
|
311
|
+
wire['owner_role'] = toWireReference(input['owner_role']);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
for (const [logicalName, rawField] of Object.entries(definition.fields)) {
|
|
315
|
+
if (!Object.prototype.hasOwnProperty.call(input, logicalName)) continue;
|
|
316
|
+
const value = input[logicalName];
|
|
317
|
+
if (value === undefined) continue;
|
|
318
|
+
const field = rawField as AnyFieldDefinition & { apiName: string };
|
|
319
|
+
wire[field.apiName] = serializeFieldValue(field, value);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return wire;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Normalizes a backend lookup value into the logical record shape.
|
|
327
|
+
*
|
|
328
|
+
* @param targetApiName - Expected target API name when the backend omits it.
|
|
329
|
+
* @param value - Raw backend lookup value.
|
|
330
|
+
* @returns Logical lookup reference or `null` when the backend value cannot be interpreted.
|
|
331
|
+
* @typeParam TApiName - Lookup target API name.
|
|
332
|
+
*/
|
|
333
|
+
function deserializeLookupReference<TApiName extends string>(
|
|
334
|
+
targetApiName: TApiName,
|
|
335
|
+
value: unknown,
|
|
336
|
+
): LookupReference<TApiName> | null {
|
|
337
|
+
if (typeof value === 'string') {
|
|
338
|
+
return { id: value, apiName: targetApiName };
|
|
339
|
+
}
|
|
340
|
+
if (!isObject(value)) return null;
|
|
341
|
+
if (typeof value['id'] !== 'string') return null;
|
|
342
|
+
return {
|
|
343
|
+
id: value['id'],
|
|
344
|
+
...(typeof value['apiName'] === 'string' ?
|
|
345
|
+
{ apiName: value['apiName'] as TApiName }
|
|
346
|
+
: { apiName: targetApiName }),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Deserializes one backend field value into the logical typed shape.
|
|
352
|
+
*
|
|
353
|
+
* @param field - Typed field definition that owns the value.
|
|
354
|
+
* @param value - Raw backend field value.
|
|
355
|
+
* @returns Logical field value suitable for typed record helpers.
|
|
356
|
+
*/
|
|
357
|
+
function deserializeFieldValue(field: AnyFieldDefinition, value: unknown): unknown {
|
|
358
|
+
if (value == null) return null;
|
|
359
|
+
|
|
360
|
+
switch (field.kind) {
|
|
361
|
+
case 'lookup':
|
|
362
|
+
case 'parent-child':
|
|
363
|
+
return deserializeLookupReference(field.targetApiName ?? 'unknown', value);
|
|
364
|
+
case 'file':
|
|
365
|
+
return (
|
|
366
|
+
typeof value === 'string' ? value
|
|
367
|
+
: isObject(value) && typeof value['id'] === 'string' ? { id: value['id'] }
|
|
368
|
+
: null
|
|
369
|
+
);
|
|
370
|
+
default:
|
|
371
|
+
return value;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Converts one raw backend row into the logical typed record shape.
|
|
377
|
+
*
|
|
378
|
+
* @param definition - Typed object definition that owns the row shape.
|
|
379
|
+
* @param row - Raw backend row to deserialize.
|
|
380
|
+
* @returns Typed logical record.
|
|
381
|
+
* @typeParam TDefinition - Object definition being deserialized.
|
|
382
|
+
*/
|
|
383
|
+
function deserializeRecord<TDefinition extends AnyCustomObjectDefinition>(
|
|
384
|
+
definition: TDefinition,
|
|
385
|
+
row: CustomObjectDataRow,
|
|
386
|
+
): RecordShape<TDefinition> {
|
|
387
|
+
const typedRecord: Record<string, unknown> = {
|
|
388
|
+
id: row.id,
|
|
389
|
+
name: row.name,
|
|
390
|
+
created_at: typeof row.created_at === 'string' ? row.created_at : null,
|
|
391
|
+
updated_at: typeof row.updated_at === 'string' ? row.updated_at : null,
|
|
392
|
+
system_updated_at: typeof row.system_updated_at === 'string' ? row.system_updated_at : null,
|
|
393
|
+
external_id: typeof row.external_id === 'string' ? row.external_id : null,
|
|
394
|
+
owner_role: deserializeLookupReference('Employee', row.owner_role),
|
|
395
|
+
created_by: deserializeLookupReference('Employee', row.created_by),
|
|
396
|
+
last_modified_by: deserializeLookupReference('Employee', row.last_modified_by),
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
for (const [logicalName, rawField] of Object.entries(definition.fields)) {
|
|
400
|
+
const field = rawField as AnyFieldDefinition & { apiName: string };
|
|
401
|
+
typedRecord[logicalName] = deserializeFieldValue(field, row[field.apiName]);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return typedRecord as RecordShape<TDefinition>;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Prefixes validation issue paths for batch operations.
|
|
409
|
+
*
|
|
410
|
+
* @param prefix - Path prefix to prepend to each issue.
|
|
411
|
+
* @param issues - Validation issues to rewrite.
|
|
412
|
+
* @returns Rewritten validation issues with prefixed paths.
|
|
413
|
+
*/
|
|
414
|
+
function prefixIssues(prefix: string, issues: readonly ValidationIssue[]): ValidationIssue[] {
|
|
415
|
+
return issues.map((current) => ({ path: `${prefix}.${current.path}`, message: current.message }));
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Validates one create payload and throws a typed error when invalid.
|
|
420
|
+
*
|
|
421
|
+
* @param definition - Typed object definition whose create payload is being validated.
|
|
422
|
+
* @param input - Typed create payload to validate.
|
|
423
|
+
* @throws CustomObjectRecordValidationError when the payload is invalid.
|
|
424
|
+
* @typeParam TDefinition - Object definition being validated.
|
|
425
|
+
*/
|
|
426
|
+
function assertValidCreatePayload<TDefinition extends AnyCustomObjectDefinition>(
|
|
427
|
+
definition: TDefinition,
|
|
428
|
+
input: CreateInput<TDefinition>,
|
|
429
|
+
): void {
|
|
430
|
+
const result = validateCreateInput(definition, input as Record<string, unknown>);
|
|
431
|
+
if (!result.valid) throw new CustomObjectRecordValidationError(definition, 'create', result.issues);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Validates one update payload and throws a typed error when invalid.
|
|
436
|
+
*
|
|
437
|
+
* @param definition - Typed object definition whose update payload is being validated.
|
|
438
|
+
* @param input - Typed update payload to validate.
|
|
439
|
+
* @throws CustomObjectRecordValidationError when the payload is invalid.
|
|
440
|
+
* @typeParam TDefinition - Object definition being validated.
|
|
441
|
+
*/
|
|
442
|
+
function assertValidUpdatePayload<TDefinition extends AnyCustomObjectDefinition>(
|
|
443
|
+
definition: TDefinition,
|
|
444
|
+
input: UpdateInput<TDefinition>,
|
|
445
|
+
): void {
|
|
446
|
+
const result = validateUpdateInput(definition, input as Record<string, unknown>);
|
|
447
|
+
if (!result.valid) throw new CustomObjectRecordValidationError(definition, 'update', result.issues);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Validates a batch of create payloads and throws a typed error when any row is invalid.
|
|
452
|
+
*
|
|
453
|
+
* @param definition - Typed object definition whose payloads are being validated.
|
|
454
|
+
* @param rows - Typed create payloads to validate as a batch.
|
|
455
|
+
* @throws CustomObjectRecordValidationError when any row is invalid.
|
|
456
|
+
* @typeParam TDefinition - Object definition being validated.
|
|
457
|
+
*/
|
|
458
|
+
function assertValidCreateBatch<TDefinition extends AnyCustomObjectDefinition>(
|
|
459
|
+
definition: TDefinition,
|
|
460
|
+
rows: readonly CreateInput<TDefinition>[],
|
|
461
|
+
): void {
|
|
462
|
+
const issues = rows.flatMap((row, index) => {
|
|
463
|
+
const result = validateCreateInput(definition, row as Record<string, unknown>);
|
|
464
|
+
return result.valid ? [] : prefixIssues(`rows[${index}]`, result.issues);
|
|
465
|
+
});
|
|
466
|
+
if (issues.length > 0) throw new CustomObjectRecordValidationError(definition, 'bulk-create', issues);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Validates a batch of update payloads and throws a typed error when any row is invalid.
|
|
471
|
+
*
|
|
472
|
+
* @param definition - Typed object definition whose payloads are being validated.
|
|
473
|
+
* @param rows - Typed update payloads to validate as a batch.
|
|
474
|
+
* @throws CustomObjectRecordValidationError when any row is invalid.
|
|
475
|
+
* @typeParam TDefinition - Object definition being validated.
|
|
476
|
+
*/
|
|
477
|
+
function assertValidUpdateBatch<TDefinition extends AnyCustomObjectDefinition>(
|
|
478
|
+
definition: TDefinition,
|
|
479
|
+
rows: readonly TypedBulkUpdateInput<TDefinition>[],
|
|
480
|
+
): void {
|
|
481
|
+
const issues = rows.flatMap((row, index) => {
|
|
482
|
+
if (row.id.trim().length === 0) {
|
|
483
|
+
return [{ path: `rows[${index}].id`, message: 'Record id cannot be empty.' } satisfies ValidationIssue];
|
|
484
|
+
}
|
|
485
|
+
const { id: _id, ...patch } = row;
|
|
486
|
+
const result = validateUpdateInput(definition, patch as Record<string, unknown>);
|
|
487
|
+
return result.valid ? [] : prefixIssues(`rows[${index}]`, result.issues);
|
|
488
|
+
});
|
|
489
|
+
if (issues.length > 0) throw new CustomObjectRecordValidationError(definition, 'bulk-update', issues);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Records-resource adapter implementation for typed record managers.
|
|
494
|
+
*
|
|
495
|
+
* @param records - Low-level records resource to adapt into the manager-friendly transport boundary.
|
|
496
|
+
* @returns Adapter implementation backed by the supplied records resource.
|
|
497
|
+
*/
|
|
498
|
+
export function createCustomObjectRecordAdapter(
|
|
499
|
+
records: CustomObjectRecordsClient,
|
|
500
|
+
): CustomObjectRecordAdapter {
|
|
501
|
+
return {
|
|
502
|
+
async create(customObjectApiName, body) {
|
|
503
|
+
const response = await records.create(customObjectApiName, body);
|
|
504
|
+
return requireSingleRow(customObjectApiName, 'create', response.data);
|
|
505
|
+
},
|
|
506
|
+
retrieve(customObjectApiName, recordId) {
|
|
507
|
+
return records.retrieve(customObjectApiName, recordId);
|
|
508
|
+
},
|
|
509
|
+
retrieveByExternalID(customObjectApiName, externalID) {
|
|
510
|
+
return records.retrieveByExternalID(customObjectApiName, externalID);
|
|
511
|
+
},
|
|
512
|
+
async update(customObjectApiName, recordId, body) {
|
|
513
|
+
const response = await records.update(customObjectApiName, recordId, body);
|
|
514
|
+
return requireSingleRow(customObjectApiName, 'update', response.data);
|
|
515
|
+
},
|
|
516
|
+
delete(customObjectApiName, recordId) {
|
|
517
|
+
return records.delete(customObjectApiName, recordId);
|
|
518
|
+
},
|
|
519
|
+
async query(customObjectApiName, params) {
|
|
520
|
+
const response = await records.query(customObjectApiName, params);
|
|
521
|
+
return {
|
|
522
|
+
cursor: response.cursor ?? null,
|
|
523
|
+
results: response.results ?? [],
|
|
524
|
+
};
|
|
525
|
+
},
|
|
526
|
+
async bulkCreate(customObjectApiName, request) {
|
|
527
|
+
const response = await records.bulkCreate(customObjectApiName, {
|
|
528
|
+
...(request.allOrNothing != null ? { all_or_nothing: request.allOrNothing } : {}),
|
|
529
|
+
rows_to_write: [...request.rowsToWrite],
|
|
530
|
+
});
|
|
531
|
+
return response.data ?? [];
|
|
532
|
+
},
|
|
533
|
+
async bulkUpdate(customObjectApiName, request) {
|
|
534
|
+
const response = await records.bulkUpdate(customObjectApiName, {
|
|
535
|
+
...(request.allOrNothing != null ? { all_or_nothing: request.allOrNothing } : {}),
|
|
536
|
+
rows_to_update: [...request.rowsToUpdate],
|
|
537
|
+
});
|
|
538
|
+
return response.data ?? [];
|
|
539
|
+
},
|
|
540
|
+
bulkDelete(customObjectApiName, request) {
|
|
541
|
+
return records.bulkDelete(customObjectApiName, {
|
|
542
|
+
...(request.allOrNothing != null ? { all_or_nothing: request.allOrNothing } : {}),
|
|
543
|
+
rows_to_delete: [...request.rowsToDelete],
|
|
544
|
+
});
|
|
545
|
+
},
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* In-memory adapter useful for unit tests and local flows that should not depend
|
|
551
|
+
* on a real SDK transport.
|
|
552
|
+
*/
|
|
553
|
+
export class InMemoryCustomObjectRecordAdapter implements CustomObjectRecordAdapter {
|
|
554
|
+
private readonly rowsByObjectApiName: Map<string, Map<string, CustomObjectDataRow>>;
|
|
555
|
+
private readonly now: () => string;
|
|
556
|
+
private readonly nextID: (customObjectApiName: string) => string;
|
|
557
|
+
private readonly queryEvaluator?: InMemoryCustomObjectRecordAdapterOptions['queryEvaluator'];
|
|
558
|
+
private sequence = 0;
|
|
559
|
+
|
|
560
|
+
/** Builds a new in-memory adapter. */
|
|
561
|
+
constructor(options: InMemoryCustomObjectRecordAdapterOptions = {}) {
|
|
562
|
+
this.rowsByObjectApiName = new Map(
|
|
563
|
+
Object.entries(options.seedRowsByObjectApiName ?? {}).map(([customObjectApiName, rows]) => [
|
|
564
|
+
customObjectApiName,
|
|
565
|
+
new Map(rows.map((row) => [row.id, { ...row }])),
|
|
566
|
+
]),
|
|
567
|
+
);
|
|
568
|
+
this.now = options.now ?? (() => new Date().toISOString());
|
|
569
|
+
this.nextID =
|
|
570
|
+
options.nextID ??
|
|
571
|
+
((customObjectApiName) => {
|
|
572
|
+
this.sequence += 1;
|
|
573
|
+
return `${customObjectApiName.replace(/__c$/, '')}_row_${this.sequence}`;
|
|
574
|
+
});
|
|
575
|
+
this.queryEvaluator = options.queryEvaluator;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
private rowMap(customObjectApiName: string): Map<string, CustomObjectDataRow> {
|
|
579
|
+
const existing = this.rowsByObjectApiName.get(customObjectApiName);
|
|
580
|
+
if (existing != null) return existing;
|
|
581
|
+
const created = new Map<string, CustomObjectDataRow>();
|
|
582
|
+
this.rowsByObjectApiName.set(customObjectApiName, created);
|
|
583
|
+
return created;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
private requiredRow(customObjectApiName: string, recordId: string): CustomObjectDataRow {
|
|
587
|
+
const row = this.rowMap(customObjectApiName).get(recordId);
|
|
588
|
+
if (row != null) return row;
|
|
589
|
+
throw new Error(`Record ${recordId} was not found in ${customObjectApiName}.`);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
private paginate(
|
|
593
|
+
rows: readonly CustomObjectDataRow[],
|
|
594
|
+
params: TypedRecordPageOptions,
|
|
595
|
+
): CustomObjectRecordQueryResponse {
|
|
596
|
+
const startIndex = params.cursor == null ? 0 : Number(params.cursor);
|
|
597
|
+
const safeStartIndex = Number.isFinite(startIndex) && startIndex >= 0 ? startIndex : 0;
|
|
598
|
+
const endIndex = params.limit == null ? rows.length : safeStartIndex + params.limit;
|
|
599
|
+
const page = rows.slice(safeStartIndex, endIndex);
|
|
600
|
+
const cursor = endIndex < rows.length ? String(endIndex) : null;
|
|
601
|
+
return { cursor, results: page };
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
async create(customObjectApiName: string, body: Record<string, unknown>): Promise<CustomObjectDataRow> {
|
|
605
|
+
const id = this.nextID(customObjectApiName);
|
|
606
|
+
const timestamp = this.now();
|
|
607
|
+
const row: CustomObjectDataRow = {
|
|
608
|
+
id,
|
|
609
|
+
name: typeof body['name'] === 'string' ? body['name'] : id,
|
|
610
|
+
created_at: timestamp,
|
|
611
|
+
updated_at: timestamp,
|
|
612
|
+
...body,
|
|
613
|
+
};
|
|
614
|
+
this.rowMap(customObjectApiName).set(id, row);
|
|
615
|
+
return { ...row };
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
async retrieve(customObjectApiName: string, recordId: string): Promise<CustomObjectDataRow> {
|
|
619
|
+
return { ...this.requiredRow(customObjectApiName, recordId) };
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
async retrieveByExternalID(customObjectApiName: string, externalID: string): Promise<CustomObjectDataRow> {
|
|
623
|
+
const row = [...this.rowMap(customObjectApiName).values()].find(
|
|
624
|
+
(candidate) => candidate.external_id === externalID,
|
|
625
|
+
);
|
|
626
|
+
if (row != null) return { ...row };
|
|
627
|
+
throw new Error(`No record with external_id ${externalID} exists in ${customObjectApiName}.`);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
async update(
|
|
631
|
+
customObjectApiName: string,
|
|
632
|
+
recordId: string,
|
|
633
|
+
body: Record<string, unknown>,
|
|
634
|
+
): Promise<CustomObjectDataRow> {
|
|
635
|
+
const previous = this.requiredRow(customObjectApiName, recordId);
|
|
636
|
+
const next: CustomObjectDataRow = {
|
|
637
|
+
...previous,
|
|
638
|
+
...body,
|
|
639
|
+
updated_at: this.now(),
|
|
640
|
+
name: typeof body['name'] === 'string' ? body['name'] : previous.name,
|
|
641
|
+
};
|
|
642
|
+
this.rowMap(customObjectApiName).set(recordId, next);
|
|
643
|
+
return { ...next };
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
async delete(customObjectApiName: string, recordId: string): Promise<void> {
|
|
647
|
+
const deleted = this.rowMap(customObjectApiName).delete(recordId);
|
|
648
|
+
if (!deleted) throw new Error(`Record ${recordId} was not found in ${customObjectApiName}.`);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
async query(
|
|
652
|
+
customObjectApiName: string,
|
|
653
|
+
params: RecordQueryParams,
|
|
654
|
+
): Promise<CustomObjectRecordQueryResponse> {
|
|
655
|
+
const rows = [...this.rowMap(customObjectApiName).values()];
|
|
656
|
+
const filtered =
|
|
657
|
+
params.query == null || params.query.trim().length === 0 ? rows
|
|
658
|
+
: this.queryEvaluator == null ?
|
|
659
|
+
(() => {
|
|
660
|
+
throw new Error(
|
|
661
|
+
`In-memory adapter for ${customObjectApiName} does not support raw query strings without a queryEvaluator.`,
|
|
662
|
+
);
|
|
663
|
+
})()
|
|
664
|
+
: rows.filter((row) => this.queryEvaluator!({ customObjectApiName, query: params.query!, row }));
|
|
665
|
+
|
|
666
|
+
return this.paginate(filtered, params);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
async bulkCreate(
|
|
670
|
+
customObjectApiName: string,
|
|
671
|
+
request: CustomObjectRecordBulkCreateRequest,
|
|
672
|
+
): Promise<readonly CustomObjectDataRow[]> {
|
|
673
|
+
const created: CustomObjectDataRow[] = [];
|
|
674
|
+
for (const row of request.rowsToWrite) {
|
|
675
|
+
created.push(await this.create(customObjectApiName, { ...row }));
|
|
676
|
+
}
|
|
677
|
+
return created;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
async bulkUpdate(
|
|
681
|
+
customObjectApiName: string,
|
|
682
|
+
request: CustomObjectRecordBulkUpdateRequest,
|
|
683
|
+
): Promise<readonly CustomObjectDataRow[]> {
|
|
684
|
+
const updated: CustomObjectDataRow[] = [];
|
|
685
|
+
for (const row of request.rowsToUpdate) {
|
|
686
|
+
if (typeof row['id'] !== 'string') {
|
|
687
|
+
throw new Error(`Bulk update for ${customObjectApiName} requires each row to include an id.`);
|
|
688
|
+
}
|
|
689
|
+
const { id, ...patch } = row;
|
|
690
|
+
updated.push(await this.update(customObjectApiName, row['id'], patch));
|
|
691
|
+
void id;
|
|
692
|
+
}
|
|
693
|
+
return updated;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
async bulkDelete(customObjectApiName: string, request: CustomObjectRecordBulkDeleteRequest): Promise<void> {
|
|
697
|
+
for (const recordId of request.rowsToDelete) {
|
|
698
|
+
await this.delete(customObjectApiName, recordId);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Definition-bound CRUD manager returned by {@link CustomObjectManager.forObject}.
|
|
705
|
+
*
|
|
706
|
+
* @typeParam TDefinition - Object definition whose logical field names and value
|
|
707
|
+
* types should be enforced.
|
|
708
|
+
*/
|
|
709
|
+
export class TypedCustomObjectRecordManager<TDefinition extends AnyCustomObjectDefinition> {
|
|
710
|
+
private readonly definition: TDefinition;
|
|
711
|
+
private readonly adapter: CustomObjectRecordAdapter;
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Creates a bound typed manager for one object definition.
|
|
715
|
+
*
|
|
716
|
+
* @param definition - Typed object definition to bind to the manager.
|
|
717
|
+
* @param adapter - Transport adapter used for all record operations.
|
|
718
|
+
*/
|
|
719
|
+
constructor(definition: TDefinition, adapter: CustomObjectRecordAdapter) {
|
|
720
|
+
this.definition = definition;
|
|
721
|
+
this.adapter = adapter;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Creates one typed record after local schema validation.
|
|
726
|
+
*
|
|
727
|
+
* @param input - Typed logical create payload.
|
|
728
|
+
* @returns Created typed record.
|
|
729
|
+
*/
|
|
730
|
+
async create(input: CreateInput<TDefinition>): Promise<RecordShape<TDefinition>> {
|
|
731
|
+
assertValidCreatePayload(this.definition, input);
|
|
732
|
+
const row = await this.adapter.create(
|
|
733
|
+
this.definition.apiName,
|
|
734
|
+
serializeRecordInput(this.definition, input),
|
|
735
|
+
);
|
|
736
|
+
return deserializeRecord(this.definition, row);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Creates many typed records after validating the full batch locally.
|
|
741
|
+
*
|
|
742
|
+
* @param rows - Typed logical create payloads.
|
|
743
|
+
* @param options - Batch-write options forwarded to the adapter.
|
|
744
|
+
* @returns Created typed records in backend response order.
|
|
745
|
+
*/
|
|
746
|
+
async createMany(
|
|
747
|
+
rows: readonly CreateInput<TDefinition>[],
|
|
748
|
+
options: TypedBatchWriteOptions = {},
|
|
749
|
+
): Promise<readonly RecordShape<TDefinition>[]> {
|
|
750
|
+
assertValidCreateBatch(this.definition, rows);
|
|
751
|
+
const created = await this.adapter.bulkCreate(this.definition.apiName, {
|
|
752
|
+
...(options.allOrNothing != null ? { allOrNothing: options.allOrNothing } : {}),
|
|
753
|
+
rowsToWrite: rows.map((row) => serializeRecordInput(this.definition, row)),
|
|
754
|
+
});
|
|
755
|
+
return created.map((row) => deserializeRecord(this.definition, row));
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Retrieves one typed record by id.
|
|
760
|
+
*
|
|
761
|
+
* @param recordId - Backend record id to fetch.
|
|
762
|
+
* @returns Typed record for the requested id.
|
|
763
|
+
*/
|
|
764
|
+
async get(recordId: string): Promise<RecordShape<TDefinition>> {
|
|
765
|
+
const row = await this.adapter.retrieve(this.definition.apiName, recordId);
|
|
766
|
+
return deserializeRecord(this.definition, row);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Retrieves one typed record by external id.
|
|
771
|
+
*
|
|
772
|
+
* @param externalID - External id to look up.
|
|
773
|
+
* @returns Typed record for the requested external id.
|
|
774
|
+
*/
|
|
775
|
+
async getByExternalID(externalID: string): Promise<RecordShape<TDefinition>> {
|
|
776
|
+
const row = await this.adapter.retrieveByExternalID(this.definition.apiName, externalID);
|
|
777
|
+
return deserializeRecord(this.definition, row);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Updates one typed record after local schema validation.
|
|
782
|
+
*
|
|
783
|
+
* @param recordId - Backend record id to update.
|
|
784
|
+
* @param patch - Typed logical update payload.
|
|
785
|
+
* @returns Updated typed record.
|
|
786
|
+
*/
|
|
787
|
+
async update(recordId: string, patch: UpdateInput<TDefinition>): Promise<RecordShape<TDefinition>> {
|
|
788
|
+
assertValidUpdatePayload(this.definition, patch);
|
|
789
|
+
const row = await this.adapter.update(
|
|
790
|
+
this.definition.apiName,
|
|
791
|
+
recordId,
|
|
792
|
+
serializeRecordInput(this.definition, patch),
|
|
793
|
+
);
|
|
794
|
+
return deserializeRecord(this.definition, row);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Updates many typed records after validating the full batch locally.
|
|
799
|
+
*
|
|
800
|
+
* @param rows - Typed update payloads, each including a backend record id.
|
|
801
|
+
* @param options - Batch-write options forwarded to the adapter.
|
|
802
|
+
* @returns Updated typed records in backend response order.
|
|
803
|
+
*/
|
|
804
|
+
async updateMany(
|
|
805
|
+
rows: readonly TypedBulkUpdateInput<TDefinition>[],
|
|
806
|
+
options: TypedBatchWriteOptions = {},
|
|
807
|
+
): Promise<readonly RecordShape<TDefinition>[]> {
|
|
808
|
+
assertValidUpdateBatch(this.definition, rows);
|
|
809
|
+
const updated = await this.adapter.bulkUpdate(this.definition.apiName, {
|
|
810
|
+
...(options.allOrNothing != null ? { allOrNothing: options.allOrNothing } : {}),
|
|
811
|
+
rowsToUpdate: rows.map((row) => {
|
|
812
|
+
const { id, ...patch } = row;
|
|
813
|
+
return { id, ...serializeRecordInput(this.definition, patch) };
|
|
814
|
+
}),
|
|
815
|
+
});
|
|
816
|
+
return updated.map((row) => deserializeRecord(this.definition, row));
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Deletes one record by id.
|
|
821
|
+
*
|
|
822
|
+
* @param recordId - Backend record id to delete.
|
|
823
|
+
*/
|
|
824
|
+
delete(recordId: string): Promise<void> {
|
|
825
|
+
return this.adapter.delete(this.definition.apiName, recordId);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Deletes many records by id.
|
|
830
|
+
*
|
|
831
|
+
* @param recordIDs - Backend record ids to delete.
|
|
832
|
+
* @param options - Batch-write options forwarded to the adapter.
|
|
833
|
+
*/
|
|
834
|
+
deleteMany(recordIDs: readonly string[], options: TypedBatchWriteOptions = {}): Promise<void> {
|
|
835
|
+
return this.adapter.bulkDelete(this.definition.apiName, {
|
|
836
|
+
...(options.allOrNothing != null ? { allOrNothing: options.allOrNothing } : {}),
|
|
837
|
+
rowsToDelete: recordIDs,
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Lists records using backend pagination without applying any query filter.
|
|
843
|
+
*
|
|
844
|
+
* @param options - Pagination options for the backend list operation.
|
|
845
|
+
* @returns Typed record page.
|
|
846
|
+
*/
|
|
847
|
+
async list(options: TypedRecordPageOptions = {}): Promise<TypedRecordPage<TDefinition>> {
|
|
848
|
+
const page = await this.adapter.query(this.definition.apiName, options);
|
|
849
|
+
return {
|
|
850
|
+
cursor: page.cursor,
|
|
851
|
+
results: page.results.map((row) => deserializeRecord(this.definition, row)),
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Queries records with an optional raw RQL filter string.
|
|
857
|
+
*
|
|
858
|
+
* @param options - Query and pagination options for the backend query operation.
|
|
859
|
+
* @returns Typed record page.
|
|
860
|
+
*/
|
|
861
|
+
async query(options: TypedRecordQueryOptions = {}): Promise<TypedRecordPage<TDefinition>> {
|
|
862
|
+
const page = await this.adapter.query(this.definition.apiName, options);
|
|
863
|
+
return {
|
|
864
|
+
cursor: page.cursor,
|
|
865
|
+
results: page.results.map((row) => deserializeRecord(this.definition, row)),
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Root manager that binds typed custom-object definitions to a transport adapter.
|
|
872
|
+
*
|
|
873
|
+
* Callers can pass either a records resource or a test adapter. If neither is
|
|
874
|
+
* provided, the manager defaults to an in-memory adapter so unit tests can use
|
|
875
|
+
* the same high-level API without bootstrapping a backend client.
|
|
876
|
+
*/
|
|
877
|
+
export class CustomObjectManager {
|
|
878
|
+
private readonly adapter: CustomObjectRecordAdapter;
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* Creates a new custom-object manager.
|
|
882
|
+
*
|
|
883
|
+
* @param options - Optional records resource or adapter implementation.
|
|
884
|
+
*/
|
|
885
|
+
constructor(options: CustomObjectManagerOptions = {}) {
|
|
886
|
+
if (options.records != null && options.adapter != null) {
|
|
887
|
+
throw new Error('Pass either records or adapter to CustomObjectManager, not both.');
|
|
888
|
+
}
|
|
889
|
+
this.adapter =
|
|
890
|
+
options.adapter ??
|
|
891
|
+
(options.records != null ?
|
|
892
|
+
createCustomObjectRecordAdapter(options.records)
|
|
893
|
+
: new InMemoryCustomObjectRecordAdapter());
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Builds a manager from a records resource.
|
|
898
|
+
*
|
|
899
|
+
* @param records - Low-level records resource to wrap.
|
|
900
|
+
* @returns Custom-object manager backed by that records resource.
|
|
901
|
+
*/
|
|
902
|
+
static fromRecords(records: CustomObjectRecordsClient): CustomObjectManager {
|
|
903
|
+
return new CustomObjectManager({ records });
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Builds a manager from a real SDK client.
|
|
908
|
+
*
|
|
909
|
+
* @param sdk - SDK-shaped client exposing `customObjects.records`.
|
|
910
|
+
* @returns Custom-object manager backed by the SDK records resource.
|
|
911
|
+
*/
|
|
912
|
+
static fromSDK(sdk: CustomObjectManagerSDKLike): CustomObjectManager {
|
|
913
|
+
return new CustomObjectManager({ records: sdk.customObjects.records });
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Builds a manager backed by an in-memory adapter.
|
|
918
|
+
*
|
|
919
|
+
* @param options - In-memory adapter options for seed data and deterministic behavior.
|
|
920
|
+
* @returns Custom-object manager backed by an in-memory adapter.
|
|
921
|
+
*/
|
|
922
|
+
static inMemory(options: InMemoryCustomObjectRecordAdapterOptions = {}): CustomObjectManager {
|
|
923
|
+
return new CustomObjectManager({ adapter: new InMemoryCustomObjectRecordAdapter(options) });
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/** Returns the low-level adapter used by this manager. */
|
|
927
|
+
getAdapter(): CustomObjectRecordAdapter {
|
|
928
|
+
return this.adapter;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Returns a typed record manager bound to one object definition.
|
|
933
|
+
*
|
|
934
|
+
* @param definition - Typed object definition to bind.
|
|
935
|
+
* @returns Definition-bound typed record manager.
|
|
936
|
+
* @typeParam TDefinition - Object definition bound to the manager.
|
|
937
|
+
*/
|
|
938
|
+
forObject<TDefinition extends AnyCustomObjectDefinition>(
|
|
939
|
+
definition: TDefinition,
|
|
940
|
+
): TypedCustomObjectRecordManager<TDefinition> {
|
|
941
|
+
return new TypedCustomObjectRecordManager(definition, this.adapter);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Short ergonomic alias for {@link forObject}.
|
|
946
|
+
*
|
|
947
|
+
* @param definition - Typed object definition to bind.
|
|
948
|
+
* @returns Definition-bound typed record manager.
|
|
949
|
+
* @typeParam TDefinition - Object definition bound to the manager.
|
|
950
|
+
*/
|
|
951
|
+
for<TDefinition extends AnyCustomObjectDefinition>(
|
|
952
|
+
definition: TDefinition,
|
|
953
|
+
): TypedCustomObjectRecordManager<TDefinition> {
|
|
954
|
+
return this.forObject(definition);
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/** Short alias for teams that prefer concise manager names. */
|
|
959
|
+
export class COManager extends CustomObjectManager {}
|