@haustle/notion-orm 0.0.43 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +449 -109
- package/build/src/agents-sdk-resolver.d.ts +8 -0
- package/build/src/agents-sdk-resolver.d.ts.map +1 -0
- package/build/src/agents-sdk-resolver.js +23 -0
- package/build/src/agents-sdk-resolver.js.map +1 -0
- package/build/src/ast/agents/agent-file-writer.d.ts +21 -0
- package/build/src/ast/agents/agent-file-writer.d.ts.map +1 -0
- package/build/src/ast/agents/agent-file-writer.js +99 -0
- package/build/src/ast/agents/agent-file-writer.js.map +1 -0
- package/build/src/ast/agents/generate-agents-cli.d.ts +24 -0
- package/build/src/ast/agents/generate-agents-cli.d.ts.map +1 -0
- package/build/src/ast/agents/generate-agents-cli.js +193 -0
- package/build/src/ast/agents/generate-agents-cli.js.map +1 -0
- package/build/src/ast/database/database-file-writer.d.ts +37 -0
- package/build/src/ast/database/database-file-writer.d.ts.map +1 -0
- package/build/src/ast/database/database-file-writer.js +240 -0
- package/build/src/ast/database/database-file-writer.js.map +1 -0
- package/build/src/ast/database/generate-databases-cli.d.ts +27 -0
- package/build/src/ast/database/generate-databases-cli.d.ts.map +1 -0
- package/build/src/ast/database/generate-databases-cli.js +141 -0
- package/build/src/ast/database/generate-databases-cli.js.map +1 -0
- package/build/src/ast/database/notion-column-generators.d.ts +180 -0
- package/build/src/ast/database/notion-column-generators.d.ts.map +1 -0
- package/build/src/ast/database/notion-column-generators.js +269 -0
- package/build/src/ast/database/notion-column-generators.js.map +1 -0
- package/build/src/ast/database/zod-schema.d.ts +17 -0
- package/build/src/ast/database/zod-schema.d.ts.map +1 -0
- package/build/src/ast/database/zod-schema.js +5 -0
- package/build/src/ast/database/zod-schema.js.map +1 -0
- package/build/src/ast/demo/datasource-fixture-builder.d.ts +38 -0
- package/build/src/ast/demo/datasource-fixture-builder.d.ts.map +1 -0
- package/build/src/ast/demo/datasource-fixture-builder.js +274 -0
- package/build/src/ast/demo/datasource-fixture-builder.js.map +1 -0
- package/build/src/ast/demo/demo-entry-builders.d.ts +28 -0
- package/build/src/ast/demo/demo-entry-builders.d.ts.map +1 -0
- package/build/src/ast/demo/demo-entry-builders.js +133 -0
- package/build/src/ast/demo/demo-entry-builders.js.map +1 -0
- package/build/src/ast/demo/demo-playground-spec.d.ts +51 -0
- package/build/src/ast/demo/demo-playground-spec.d.ts.map +1 -0
- package/build/src/ast/demo/demo-playground-spec.js +91 -0
- package/build/src/ast/demo/demo-playground-spec.js.map +1 -0
- package/build/src/ast/demo/demo-workspace-builder.d.ts +24 -0
- package/build/src/ast/demo/demo-workspace-builder.d.ts.map +1 -0
- package/build/src/ast/demo/demo-workspace-builder.js +90 -0
- package/build/src/ast/demo/demo-workspace-builder.js.map +1 -0
- package/build/src/ast/shared/ast-builders.d.ts +112 -0
- package/build/src/ast/shared/ast-builders.d.ts.map +1 -0
- package/build/src/ast/shared/ast-builders.js +181 -0
- package/build/src/ast/shared/ast-builders.js.map +1 -0
- package/build/src/ast/shared/cached-metadata.d.ts +26 -0
- package/build/src/ast/shared/cached-metadata.d.ts.map +1 -0
- package/build/src/ast/shared/cached-metadata.js +76 -0
- package/build/src/ast/shared/cached-metadata.js.map +1 -0
- package/build/src/ast/shared/codegen-diagnostics.d.ts +23 -0
- package/build/src/ast/shared/codegen-diagnostics.d.ts.map +1 -0
- package/build/src/ast/shared/codegen-diagnostics.js +13 -0
- package/build/src/ast/shared/codegen-diagnostics.js.map +1 -0
- package/build/src/ast/shared/codegen-environment.d.ts +37 -0
- package/build/src/ast/shared/codegen-environment.d.ts.map +1 -0
- package/build/src/ast/shared/codegen-environment.js +53 -0
- package/build/src/ast/shared/codegen-environment.js.map +1 -0
- package/build/src/ast/shared/constants.d.ts +98 -0
- package/build/src/ast/shared/constants.d.ts.map +1 -0
- package/build/src/ast/shared/constants.js +145 -0
- package/build/src/ast/shared/constants.js.map +1 -0
- package/build/src/ast/shared/emit/config-emitter.d.ts +56 -0
- package/build/src/ast/shared/emit/config-emitter.d.ts.map +1 -0
- package/build/src/ast/shared/emit/config-emitter.js +454 -0
- package/build/src/ast/shared/emit/config-emitter.js.map +1 -0
- package/build/src/ast/shared/emit/emit-value-as-expression.d.ts +10 -0
- package/build/src/ast/shared/emit/emit-value-as-expression.d.ts.map +1 -0
- package/build/src/ast/shared/emit/emit-value-as-expression.js +37 -0
- package/build/src/ast/shared/emit/emit-value-as-expression.js.map +1 -0
- package/build/src/ast/shared/emit/orm-index-emitter.d.ts +61 -0
- package/build/src/ast/shared/emit/orm-index-emitter.d.ts.map +1 -0
- package/build/src/ast/shared/emit/orm-index-emitter.js +376 -0
- package/build/src/ast/shared/emit/orm-index-emitter.js.map +1 -0
- package/build/src/ast/shared/emit/registry-emitter.d.ts +35 -0
- package/build/src/ast/shared/emit/registry-emitter.d.ts.map +1 -0
- package/build/src/ast/shared/emit/registry-emitter.js +39 -0
- package/build/src/ast/shared/emit/registry-emitter.js.map +1 -0
- package/build/src/ast/shared/emit/ts-emit-core.d.ts +79 -0
- package/build/src/ast/shared/emit/ts-emit-core.d.ts.map +1 -0
- package/build/src/ast/shared/emit/ts-emit-core.js +135 -0
- package/build/src/ast/shared/emit/ts-emit-core.js.map +1 -0
- package/build/src/ast/shared/emit/ts-emit-options.d.ts +29 -0
- package/build/src/ast/shared/emit/ts-emit-options.d.ts.map +1 -0
- package/build/src/ast/shared/emit/ts-emit-options.js +29 -0
- package/build/src/ast/shared/emit/ts-emit-options.js.map +1 -0
- package/build/src/base.d.ts +21 -0
- package/build/src/base.d.ts.map +1 -0
- package/build/src/base.js +19 -0
- package/build/src/base.js.map +1 -0
- package/build/src/cli/agents-sdk-setup.d.ts +2 -0
- package/build/src/cli/agents-sdk-setup.d.ts.map +1 -0
- package/build/src/cli/agents-sdk-setup.js +107 -0
- package/build/src/cli/agents-sdk-setup.js.map +1 -0
- package/build/src/cli/helpers.d.ts +14 -0
- package/build/src/cli/helpers.d.ts.map +1 -0
- package/build/src/cli/helpers.js +125 -0
- package/build/src/cli/helpers.js.map +1 -0
- package/build/src/cli/index.d.ts +3 -0
- package/build/src/cli/index.d.ts.map +1 -0
- package/build/src/cli/index.js +244 -0
- package/build/src/cli/index.js.map +1 -0
- package/build/src/cli/sync-progress-renderer.d.ts +20 -0
- package/build/src/cli/sync-progress-renderer.d.ts.map +1 -0
- package/build/src/cli/sync-progress-renderer.js +79 -0
- package/build/src/cli/sync-progress-renderer.js.map +1 -0
- package/build/src/cli/sync-progress.d.ts +55 -0
- package/build/src/cli/sync-progress.d.ts.map +1 -0
- package/build/src/cli/sync-progress.js +120 -0
- package/build/src/cli/sync-progress.js.map +1 -0
- package/build/src/cli/sync-report.d.ts +17 -0
- package/build/src/cli/sync-report.d.ts.map +1 -0
- package/build/src/cli/sync-report.js +86 -0
- package/build/src/cli/sync-report.js.map +1 -0
- package/build/src/client/agent/AgentClient.d.ts +84 -0
- package/build/src/client/agent/AgentClient.d.ts.map +1 -0
- package/build/src/client/agent/AgentClient.js +118 -0
- package/build/src/client/agent/AgentClient.js.map +1 -0
- package/build/src/client/database/DatabaseClient.d.ts +37 -0
- package/build/src/client/database/DatabaseClient.d.ts.map +1 -0
- package/build/src/client/database/DatabaseClient.js +328 -0
- package/build/src/client/database/DatabaseClient.js.map +1 -0
- package/build/src/client/database/create/build-create-page-parameters.d.ts +9 -0
- package/build/src/client/database/create/build-create-page-parameters.d.ts.map +1 -0
- package/build/src/client/database/create/build-create-page-parameters.js +13 -0
- package/build/src/client/database/create/build-create-page-parameters.js.map +1 -0
- package/build/src/client/database/create/index.d.ts +4 -0
- package/build/src/client/database/create/index.d.ts.map +1 -0
- package/build/src/client/database/create/index.js +4 -0
- package/build/src/client/database/create/index.js.map +1 -0
- package/build/src/client/database/create/map-to-notion-properties.d.ts +14 -0
- package/build/src/client/database/create/map-to-notion-properties.d.ts.map +1 -0
- package/build/src/client/database/create/map-to-notion-properties.js +31 -0
- package/build/src/client/database/create/map-to-notion-properties.js.map +1 -0
- package/build/src/client/database/create/property-value.d.ts +16 -0
- package/build/src/client/database/create/property-value.d.ts.map +1 -0
- package/build/src/client/database/create/property-value.js +213 -0
- package/build/src/client/database/create/property-value.js.map +1 -0
- package/build/src/client/database/query/build-query-params.d.ts +11 -0
- package/build/src/client/database/query/build-query-params.d.ts.map +1 -0
- package/build/src/client/database/query/build-query-params.js +24 -0
- package/build/src/client/database/query/build-query-params.js.map +1 -0
- package/build/src/client/database/query/build-query-response.d.ts +23 -0
- package/build/src/client/database/query/build-query-response.d.ts.map +1 -0
- package/build/src/client/database/query/build-query-response.js +41 -0
- package/build/src/client/database/query/build-query-response.js.map +1 -0
- package/build/src/client/database/query/filter/builders.d.ts +4 -0
- package/build/src/client/database/query/filter/builders.d.ts.map +1 -0
- package/build/src/client/database/query/filter/builders.js +141 -0
- package/build/src/client/database/query/filter/builders.js.map +1 -0
- package/build/src/client/database/query/filter/compound.d.ts +3 -0
- package/build/src/client/database/query/filter/compound.d.ts.map +1 -0
- package/build/src/client/database/query/filter/compound.js +13 -0
- package/build/src/client/database/query/filter/compound.js.map +1 -0
- package/build/src/client/database/query/filter/index.d.ts +3 -0
- package/build/src/client/database/query/filter/index.d.ts.map +1 -0
- package/build/src/client/database/query/filter/index.js +89 -0
- package/build/src/client/database/query/filter/index.js.map +1 -0
- package/build/src/client/database/query/http-guards.d.ts +2 -0
- package/build/src/client/database/query/http-guards.d.ts.map +1 -0
- package/build/src/client/database/query/http-guards.js +10 -0
- package/build/src/client/database/query/http-guards.js.map +1 -0
- package/build/src/client/database/query/index.d.ts +5 -0
- package/build/src/client/database/query/index.d.ts.map +1 -0
- package/build/src/client/database/query/index.js +5 -0
- package/build/src/client/database/query/index.js.map +1 -0
- package/build/src/client/database/query/normalize-page-result.d.ts +15 -0
- package/build/src/client/database/query/normalize-page-result.d.ts.map +1 -0
- package/build/src/client/database/query/normalize-page-result.js +35 -0
- package/build/src/client/database/query/normalize-page-result.js.map +1 -0
- package/build/src/client/database/query/page-collection.d.ts +42 -0
- package/build/src/client/database/query/page-collection.d.ts.map +1 -0
- package/build/src/client/database/query/page-collection.js +71 -0
- package/build/src/client/database/query/page-collection.js.map +1 -0
- package/build/src/client/database/query/projection.d.ts +9 -0
- package/build/src/client/database/query/projection.d.ts.map +1 -0
- package/build/src/client/database/query/projection.js +43 -0
- package/build/src/client/database/query/projection.js.map +1 -0
- package/build/src/client/database/query/response/checkbox.d.ts +3 -0
- package/build/src/client/database/query/response/checkbox.d.ts.map +1 -0
- package/build/src/client/database/query/response/checkbox.js +7 -0
- package/build/src/client/database/query/response/checkbox.js.map +1 -0
- package/build/src/client/database/query/response/created_by.d.ts +3 -0
- package/build/src/client/database/query/response/created_by.d.ts.map +1 -0
- package/build/src/client/database/query/response/created_by.js +8 -0
- package/build/src/client/database/query/response/created_by.js.map +1 -0
- package/build/src/client/database/query/response/created_time.d.ts +3 -0
- package/build/src/client/database/query/response/created_time.d.ts.map +1 -0
- package/build/src/client/database/query/response/created_time.js +7 -0
- package/build/src/client/database/query/response/created_time.js.map +1 -0
- package/build/src/client/database/query/response/date.d.ts +6 -0
- package/build/src/client/database/query/response/date.d.ts.map +1 -0
- package/build/src/client/database/query/response/date.js +13 -0
- package/build/src/client/database/query/response/date.js.map +1 -0
- package/build/src/client/database/query/response/email.d.ts +3 -0
- package/build/src/client/database/query/response/email.d.ts.map +1 -0
- package/build/src/client/database/query/response/email.js +7 -0
- package/build/src/client/database/query/response/email.js.map +1 -0
- package/build/src/client/database/query/response/files.d.ts +6 -0
- package/build/src/client/database/query/response/files.d.ts.map +1 -0
- package/build/src/client/database/query/response/files.js +8 -0
- package/build/src/client/database/query/response/files.js.map +1 -0
- package/build/src/client/database/query/response/index.d.ts +53 -0
- package/build/src/client/database/query/response/index.d.ts.map +1 -0
- package/build/src/client/database/query/response/index.js +44 -0
- package/build/src/client/database/query/response/index.js.map +1 -0
- package/build/src/client/database/query/response/last_edited_by.d.ts +3 -0
- package/build/src/client/database/query/response/last_edited_by.d.ts.map +1 -0
- package/build/src/client/database/query/response/last_edited_by.js +8 -0
- package/build/src/client/database/query/response/last_edited_by.js.map +1 -0
- package/build/src/client/database/query/response/last_edited_time.d.ts +3 -0
- package/build/src/client/database/query/response/last_edited_time.d.ts.map +1 -0
- package/build/src/client/database/query/response/last_edited_time.js +7 -0
- package/build/src/client/database/query/response/last_edited_time.js.map +1 -0
- package/build/src/client/database/query/response/multi_select.d.ts +3 -0
- package/build/src/client/database/query/response/multi_select.d.ts.map +1 -0
- package/build/src/client/database/query/response/multi_select.js +10 -0
- package/build/src/client/database/query/response/multi_select.js.map +1 -0
- package/build/src/client/database/query/response/number.d.ts +3 -0
- package/build/src/client/database/query/response/number.d.ts.map +1 -0
- package/build/src/client/database/query/response/number.js +7 -0
- package/build/src/client/database/query/response/number.js.map +1 -0
- package/build/src/client/database/query/response/people.d.ts +3 -0
- package/build/src/client/database/query/response/people.d.ts.map +1 -0
- package/build/src/client/database/query/response/people.js +13 -0
- package/build/src/client/database/query/response/people.js.map +1 -0
- package/build/src/client/database/query/response/phone_number.d.ts +3 -0
- package/build/src/client/database/query/response/phone_number.d.ts.map +1 -0
- package/build/src/client/database/query/response/phone_number.js +7 -0
- package/build/src/client/database/query/response/phone_number.js.map +1 -0
- package/build/src/client/database/query/response/relation.d.ts +4 -0
- package/build/src/client/database/query/response/relation.d.ts.map +1 -0
- package/build/src/client/database/query/response/relation.js +14 -0
- package/build/src/client/database/query/response/relation.js.map +1 -0
- package/build/src/client/database/query/response/rich_text.d.ts +3 -0
- package/build/src/client/database/query/response/rich_text.d.ts.map +1 -0
- package/build/src/client/database/query/response/rich_text.js +12 -0
- package/build/src/client/database/query/response/rich_text.js.map +1 -0
- package/build/src/client/database/query/response/select.d.ts +3 -0
- package/build/src/client/database/query/response/select.d.ts.map +1 -0
- package/build/src/client/database/query/response/select.js +7 -0
- package/build/src/client/database/query/response/select.js.map +1 -0
- package/build/src/client/database/query/response/shared.d.ts +6 -0
- package/build/src/client/database/query/response/shared.d.ts.map +1 -0
- package/build/src/client/database/query/response/shared.js +41 -0
- package/build/src/client/database/query/response/shared.js.map +1 -0
- package/build/src/client/database/query/response/status.d.ts +3 -0
- package/build/src/client/database/query/response/status.d.ts.map +1 -0
- package/build/src/client/database/query/response/status.js +7 -0
- package/build/src/client/database/query/response/status.js.map +1 -0
- package/build/src/client/database/query/response/title.d.ts +3 -0
- package/build/src/client/database/query/response/title.d.ts.map +1 -0
- package/build/src/client/database/query/response/title.js +12 -0
- package/build/src/client/database/query/response/title.js.map +1 -0
- package/build/src/client/database/query/response/unique_id.d.ts +3 -0
- package/build/src/client/database/query/response/unique_id.d.ts.map +1 -0
- package/build/src/client/database/query/response/unique_id.js +14 -0
- package/build/src/client/database/query/response/unique_id.js.map +1 -0
- package/build/src/client/database/query/response/url.d.ts +3 -0
- package/build/src/client/database/query/response/url.d.ts.map +1 -0
- package/build/src/client/database/query/response/url.js +7 -0
- package/build/src/client/database/query/response/url.js.map +1 -0
- package/build/src/client/database/query/schema-drift-validation.d.ts +31 -0
- package/build/src/client/database/query/schema-drift-validation.d.ts.map +1 -0
- package/build/src/client/database/query/schema-drift-validation.js +68 -0
- package/build/src/client/database/query/schema-drift-validation.js.map +1 -0
- package/build/src/client/database/query/sort-transform.d.ts +6 -0
- package/build/src/client/database/query/sort-transform.d.ts.map +1 -0
- package/build/src/client/database/query/sort-transform.js +13 -0
- package/build/src/client/database/query/sort-transform.js.map +1 -0
- package/build/src/client/database/query/types.d.ts +42 -0
- package/build/src/client/database/query/types.d.ts.map +1 -0
- package/build/src/client/database/query/types.js +2 -0
- package/build/src/client/database/query/types.js.map +1 -0
- package/build/src/client/database/schema-builder.d.ts +8 -0
- package/build/src/client/database/schema-builder.d.ts.map +1 -0
- package/build/src/client/database/schema-builder.js +78 -0
- package/build/src/client/database/schema-builder.js.map +1 -0
- package/build/src/client/database/types/crud.d.ts +40 -0
- package/build/src/client/database/types/crud.d.ts.map +1 -0
- package/build/src/client/database/types/crud.js +5 -0
- package/build/src/client/database/types/crud.js.map +1 -0
- package/build/src/client/database/types/filter-capability.d.ts +30 -0
- package/build/src/client/database/types/filter-capability.d.ts.map +1 -0
- package/build/src/client/database/types/filter-capability.js +28 -0
- package/build/src/client/database/types/filter-capability.js.map +1 -0
- package/build/src/client/database/types/index.d.ts +16 -0
- package/build/src/client/database/types/index.d.ts.map +1 -0
- package/build/src/client/database/types/index.js +16 -0
- package/build/src/client/database/types/index.js.map +1 -0
- package/build/src/client/database/types/notion-database-id.d.ts +14 -0
- package/build/src/client/database/types/notion-database-id.d.ts.map +1 -0
- package/build/src/client/database/types/notion-database-id.js +9 -0
- package/build/src/client/database/types/notion-database-id.js.map +1 -0
- package/build/src/client/database/types/notion-filter-model.d.ts +98 -0
- package/build/src/client/database/types/notion-filter-model.d.ts.map +1 -0
- package/build/src/client/database/types/notion-filter-model.js +5 -0
- package/build/src/client/database/types/notion-filter-model.js.map +1 -0
- package/build/src/client/database/types/notion-id-brand.d.ts +27 -0
- package/build/src/client/database/types/notion-id-brand.d.ts.map +1 -0
- package/build/src/client/database/types/notion-id-brand.js +8 -0
- package/build/src/client/database/types/notion-id-brand.js.map +1 -0
- package/build/src/client/database/types/notion-page-id.d.ts +10 -0
- package/build/src/client/database/types/notion-page-id.d.ts.map +1 -0
- package/build/src/client/database/types/notion-page-id.js +6 -0
- package/build/src/client/database/types/notion-page-id.js.map +1 -0
- package/build/src/client/database/types/notion-user-id.d.ts +10 -0
- package/build/src/client/database/types/notion-user-id.d.ts.map +1 -0
- package/build/src/client/database/types/notion-user-id.js +6 -0
- package/build/src/client/database/types/notion-user-id.js.map +1 -0
- package/build/src/client/database/types/projection.d.ts +78 -0
- package/build/src/client/database/types/projection.d.ts.map +1 -0
- package/build/src/client/database/types/projection.js +6 -0
- package/build/src/client/database/types/projection.js.map +1 -0
- package/build/src/client/database/types/query-filter.d.ts +19 -0
- package/build/src/client/database/types/query-filter.d.ts.map +1 -0
- package/build/src/client/database/types/query-filter.js +5 -0
- package/build/src/client/database/types/query-filter.js.map +1 -0
- package/build/src/client/database/types/query-object.d.ts +42 -0
- package/build/src/client/database/types/query-object.d.ts.map +1 -0
- package/build/src/client/database/types/query-object.js +5 -0
- package/build/src/client/database/types/query-object.js.map +1 -0
- package/build/src/client/database/types/schema.d.ts +190 -0
- package/build/src/client/database/types/schema.d.ts.map +1 -0
- package/build/src/client/database/types/schema.js +41 -0
- package/build/src/client/database/types/schema.js.map +1 -0
- package/build/src/client/database/types/sort.d.ts +22 -0
- package/build/src/client/database/types/sort.d.ts.map +1 -0
- package/build/src/client/database/types/sort.js +5 -0
- package/build/src/client/database/types/sort.js.map +1 -0
- package/build/src/config/findConfigFile.d.ts +8 -0
- package/build/src/config/findConfigFile.d.ts.map +1 -0
- package/build/src/config/findConfigFile.js +18 -0
- package/build/src/config/findConfigFile.js.map +1 -0
- package/build/src/config/helpers.d.ts +7 -0
- package/build/src/config/helpers.d.ts.map +1 -0
- package/build/src/config/helpers.js +57 -0
- package/build/src/config/helpers.js.map +1 -0
- package/build/src/config/init.d.ts +7 -0
- package/build/src/config/init.d.ts.map +1 -0
- package/build/src/config/init.js +28 -0
- package/build/src/config/init.js.map +1 -0
- package/build/src/config/loadConfig.d.ts +11 -0
- package/build/src/config/loadConfig.d.ts.map +1 -0
- package/build/src/config/loadConfig.js +91 -0
- package/build/src/config/loadConfig.js.map +1 -0
- package/build/src/config/loadDotEnvFromCwd.d.ts +12 -0
- package/build/src/config/loadDotEnvFromCwd.d.ts.map +1 -0
- package/build/src/config/loadDotEnvFromCwd.js +47 -0
- package/build/src/config/loadDotEnvFromCwd.js.map +1 -0
- package/build/src/config/notion-config-filenames.d.ts +20 -0
- package/build/src/config/notion-config-filenames.d.ts.map +1 -0
- package/build/src/config/notion-config-filenames.js +24 -0
- package/build/src/config/notion-config-filenames.js.map +1 -0
- package/build/src/config/resolveNotionAuth.d.ts +18 -0
- package/build/src/config/resolveNotionAuth.d.ts.map +1 -0
- package/build/src/config/resolveNotionAuth.js +24 -0
- package/build/src/config/resolveNotionAuth.js.map +1 -0
- package/build/src/config/types.d.ts +16 -0
- package/build/src/config/types.d.ts.map +1 -0
- package/build/src/config/types.js +7 -0
- package/build/src/config/types.js.map +1 -0
- package/build/src/helpers.d.ts +22 -0
- package/build/src/helpers.d.ts.map +1 -0
- package/build/src/helpers.js +67 -0
- package/build/src/helpers.js.map +1 -0
- package/build/src/index.d.ts +15 -11
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +11 -116
- package/build/src/index.js.map +1 -1
- package/build/src/notion-id-patterns.d.ts +9 -0
- package/build/src/notion-id-patterns.d.ts.map +1 -0
- package/build/src/notion-id-patterns.js +9 -0
- package/build/src/notion-id-patterns.js.map +1 -0
- package/build/src/runtime-constants.d.ts +13 -0
- package/build/src/runtime-constants.d.ts.map +1 -0
- package/build/src/runtime-constants.js +13 -0
- package/build/src/runtime-constants.js.map +1 -0
- package/build/src/typeUtils.d.ts +77 -0
- package/build/src/typeUtils.d.ts.map +1 -0
- package/build/src/typeUtils.js +52 -0
- package/build/src/typeUtils.js.map +1 -0
- package/package.json +85 -30
- package/build/src/BuildCall.d.ts +0 -45
- package/build/src/BuildCall.d.ts.map +0 -1
- package/build/src/BuildCall.js +0 -114
- package/build/src/BuildCall.js.map +0 -1
- package/build/src/DatabaseActions.d.ts +0 -19
- package/build/src/DatabaseActions.d.ts.map +0 -1
- package/build/src/DatabaseActions.js +0 -158
- package/build/src/DatabaseActions.js.map +0 -1
- package/build/src/GenerateTypes.d.ts +0 -8
- package/build/src/GenerateTypes.d.ts.map +0 -1
- package/build/src/GenerateTypes.js +0 -257
- package/build/src/GenerateTypes.js.map +0 -1
- package/build/src/cli.d.ts +0 -3
- package/build/src/cli.d.ts.map +0 -1
- package/build/src/cli.js +0 -48
- package/build/src/cli.js.map +0 -1
- package/build/src/queryTypes.d.ts +0 -117
- package/build/src/queryTypes.d.ts.map +0 -1
- package/build/src/queryTypes.js +0 -7
- package/build/src/queryTypes.js.map +0 -1
- package/src/BuildCall.ts +0 -118
- package/src/DatabaseActions.ts +0 -227
- package/src/GenerateTypes.ts +0 -448
- package/src/cli.ts +0 -40
- package/src/index.ts +0 -136
- package/src/queryTypes.ts +0 -177
package/README.md
CHANGED
|
@@ -1,132 +1,472 @@
|
|
|
1
1
|
# Notion ORM
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
👉 This package is currently still in development.
|
|
3
|
+
A lightweight TypeScript [Notion API](https://developers.notion.com/) wrapper that aims to improve interactions with databases and custom agents, by leveraging static schema types
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
## Key Features
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
- Type inference when interacting with databases (e.g, `add` and `query`)
|
|
8
|
+
- Sync remote schema changes in single command
|
|
9
|
+
- Quickly start/resume chat streams with your agents
|
|
10
|
+
- Access exported property values, schemas, and types
|
|
11
|
+
- Logs console warnings when local vs remote schema drift is detected
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
## Installation
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
15
|
+
```bash
|
|
16
|
+
npm install @haustle/notion-orm
|
|
17
|
+
# or: pnpm add / yarn add / bun add @haustle/notion-orm
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The CLI is installed as the `**notion**` binary and runs on **Node.js 18+** (the published shebang is `node`). After upgrading the package, run `**npx notion sync`** (or `**pnpm exec notion sync**`, `**yarn notion sync**`, `**bunx notion sync**`) so generated files under `**notion/**` stay in sync with the version you installed (stale codegen can break at runtime when imports from the ORM package change). In app code, prefer `**import { NotionORM } from "./notion/"**` — the directory import resolves to `index.ts`, so you do not need to spell `**index**`.
|
|
21
|
+
|
|
22
|
+
**Config file:** use `**notion.config.js`** or `**notion.config.mjs**` if you run the CLI with plain Node. `**notion.config.ts**` is supported when your runtime can load TypeScript (for example Bun or a project using a TS loader); otherwise compile the config or use JavaScript.
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
- Multiselect
|
|
19
|
-
- Select
|
|
20
|
-
- Status
|
|
21
|
-
- Date
|
|
22
|
-
- Text
|
|
23
|
-
- Url
|
|
24
|
-
- Checkbox
|
|
25
|
-
- Email
|
|
26
|
-
- Phone Number
|
|
24
|
+
Generated database and agent modules live in your app's local `**./notion/**` folder after `notion sync`; import those relative files directly if you need a generated factory outside the `NotionORM` wrapper.
|
|
27
25
|
|
|
28
|
-
#
|
|
26
|
+
# Quick start
|
|
27
|
+
|
|
28
|
+
Initialize config from your project root (recommended):
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
|
|
31
|
+
npx notion init
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Generated config shape:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// notion.config.ts
|
|
38
|
+
|
|
39
|
+
// If you don't have an API key, sign up for free
|
|
40
|
+
// [here](https://developers.notion.com)
|
|
41
|
+
|
|
42
|
+
const auth = process.env.NOTION_KEY || "your-notion-api-key-here";
|
|
43
|
+
const NotionConfig = {
|
|
44
|
+
auth,
|
|
45
|
+
databases: [
|
|
46
|
+
// Use: notion add <database-id>
|
|
47
|
+
],
|
|
48
|
+
agents: [
|
|
49
|
+
// Auto-populated by: notion sync
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default NotionConfig;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Adding databases
|
|
57
|
+
|
|
58
|
+
Add new database to track and generate static types (ex. how to find ID [here](https://developers.notion.com/guides/data-apis/working-with-databases#adding-pages-to-a-database) )
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx notion add <database-id>
|
|
32
62
|
```
|
|
33
63
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
### Nested Filters
|
|
101
|
-
|
|
102
|
-
```tsx
|
|
103
|
-
await notion.books.query({
|
|
104
|
-
filter: {
|
|
64
|
+
### Adding agents (paid feature)
|
|
65
|
+
|
|
66
|
+
Agent support requires the [Notion Agents SDK](https://github.com/makenotion/notion-agents-sdk-js), which is **currently in alpha** and not published to npm. Because of this, a one-command setup handles the entire download-and-install flow for you:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx notion setup-agents-sdk
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**What this does:**
|
|
73
|
+
|
|
74
|
+
1. Clones the SDK repository into a local cache (`node_modules/.cache/.notion-agents-sdk`)
|
|
75
|
+
2. Installs the SDK's dependencies and builds it
|
|
76
|
+
3. Adds the built `@notionhq/agents-client` package to your project
|
|
77
|
+
|
|
78
|
+
After setup, run `notion sync` to generate agent types. Agents linked to your integration are automatically discovered.
|
|
79
|
+
|
|
80
|
+
**Updating:** When the upstream SDK receives changes, rerun the same command. It pulls the latest from the cached clone, rebuilds, and reinstalls:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npx notion setup-agents-sdk
|
|
84
|
+
npx notion sync
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
If you have not run the setup command, `notion sync` will skip agent generation and only produce database types. Once the SDK is published to npm, this step will no longer be necessary.
|
|
88
|
+
|
|
89
|
+
Learn more about [Custom Agents](https://www.notion.com/help/custom-agents) in the Notion documentation.
|
|
90
|
+
|
|
91
|
+
### Full sync command (`notion sync`)
|
|
92
|
+
|
|
93
|
+
Fetch/refresh database schemas. If the agents SDK is installed, also syncs custom agents.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx notion sync
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Basic examples
|
|
100
|
+
|
|
101
|
+
### Create page in a database
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
await notion.databases.books.create({
|
|
105
|
+
icon: {
|
|
106
|
+
type: "emoji",
|
|
107
|
+
emoji: "📕",
|
|
108
|
+
},
|
|
109
|
+
// Expected <key,value> is constrained to `books` database schema
|
|
110
|
+
properties: {
|
|
111
|
+
bookName: "Creativity, Inc.",
|
|
112
|
+
genre: ["Non-fiction"],
|
|
113
|
+
publishDate: {
|
|
114
|
+
start: "2026-03-01",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Query/filter database
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
const books = await notion.databases.books.findMany({
|
|
125
|
+
where: {
|
|
126
|
+
and: [
|
|
127
|
+
{ genre: { contains: "Non-fiction" } },
|
|
128
|
+
{ publishDate: { on_or_after: "2026-01-01" } },
|
|
129
|
+
{
|
|
105
130
|
or: [
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
contains: "Sci-Fi",
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
genre: {
|
|
113
|
-
contains: "Biography",
|
|
114
|
-
},
|
|
115
|
-
},
|
|
131
|
+
{ bookName: { contains: "Creativity" } },
|
|
132
|
+
{ bookName: { contains: "Innovation" } },
|
|
116
133
|
],
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
sortBy: [{ property: "bookName", direction: "ascending" }],
|
|
138
|
+
select: ["bookName", "genre"],
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Chat with agent
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
const chat = await notion.agents.helpBot.chat({message: "Is the company closed today"})
|
|
147
|
+
await notion.agents.helpBot.pollThread(chat.threadId)
|
|
148
|
+
const messages = await notion.agents.helpBot.getMessages(chat.threadId, {
|
|
149
|
+
role: "agent",
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Chat with agent (stream)
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
const thread = await notion.agents.helpBot.chatStream({
|
|
157
|
+
message: "How can I update my shipping address?",
|
|
158
|
+
onMessage: ({content, role}) => (msg.content),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
# Implementation
|
|
164
|
+
|
|
165
|
+
### Client setup
|
|
166
|
+
|
|
167
|
+
Create a single ORM instance with your Notion integration key. Import from the generated `**notion/**` folder (directory specifier → `index`):
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
import { NotionORM } from "./notion/";
|
|
171
|
+
|
|
172
|
+
const notion = new NotionORM({
|
|
173
|
+
auth: process.env.NOTION_KEY!,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const db = notion.databases.yourDatabaseName; // DatabaseClient
|
|
177
|
+
const agent = notion.agents.yourAgentName; // AgentClient
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Generated database and agent names are camelCased and exposed on an instance of `NotionORM`.
|
|
181
|
+
|
|
182
|
+
- Use `notion.databases.<camelCaseDatabaseName>` for typed CRUD + query operations (`findMany`, `findFirst`, `findUnique`, `create`, `update`, `delete`, and more).
|
|
183
|
+
- Use `notion.agents.<camelCaseAgentName>` for `chat()`, `chatStream()`, thread helpers, and history APIs.
|
|
184
|
+
- For full method signatures and response shapes, see [API Reference](#api-reference).
|
|
185
|
+
|
|
186
|
+
# Available database operations
|
|
187
|
+
|
|
188
|
+
## Adding
|
|
189
|
+
|
|
190
|
+
Only title is required by Notion for a minimal page.
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
await notion.databases.books.create({
|
|
194
|
+
properties: {
|
|
195
|
+
bookName: "Raphael, Painter in Rome: a Novel", // title
|
|
196
|
+
author: "Stephanie Storey", // rich_text
|
|
197
|
+
status: "In progress", // status
|
|
198
|
+
numberOfPages: 307, // number
|
|
199
|
+
genre: ["Historical Fiction"], // multi_select
|
|
200
|
+
startDate: {
|
|
201
|
+
start: "2023-01-01",
|
|
202
|
+
}, // date
|
|
203
|
+
phone: "0000000000", // phone_number
|
|
204
|
+
email: "tyrus@haustle.studio", // email
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Adding page content with markdown
|
|
210
|
+
|
|
211
|
+
Pass a `markdown` string alongside `properties` to create a page with body content in a single call. This uses Notion's [enhanced markdown format](https://developers.notion.com/guides/data-apis/working-with-markdown-content#block-type-support), which supports headings, lists, code blocks, quotes, checklists, and more.
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
await notion.databases.books.create({
|
|
215
|
+
properties: {
|
|
216
|
+
bookName: "Hello World",
|
|
217
|
+
},
|
|
218
|
+
markdown: "# Hello World\n\nThis is a page created with **markdown**.",
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
`markdown` is mutually exclusive with `children` / `content` — use one or the other. When `properties.title` is provided, the `# h1` heading is treated as body content; when omitted, Notion extracts it as the page title.
|
|
223
|
+
|
|
224
|
+
## Querying
|
|
225
|
+
|
|
226
|
+
Query filters are typed by your generated schema, including nested compound filters. Find Notion filter operators [here](https://developers.notion.com/reference/post-database-query-filter).
|
|
227
|
+
|
|
228
|
+
Example single filter:
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
await notion.databases.books.findMany({
|
|
232
|
+
where: {
|
|
233
|
+
genre: {
|
|
234
|
+
contains: "Sci-Fi",
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
sortBy: [
|
|
238
|
+
{
|
|
239
|
+
property: "bookName",
|
|
240
|
+
direction: "ascending",
|
|
117
241
|
},
|
|
242
|
+
],
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Example compound filters:
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
await notion.databases.books.findMany({
|
|
250
|
+
where: {
|
|
251
|
+
and: [
|
|
252
|
+
{
|
|
253
|
+
or: [
|
|
254
|
+
{ genre: { contains: "Sci-Fi" } },
|
|
255
|
+
{ genre: { contains: "Biography" } },
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
{ numberOfPages: { greater_than: 250 } },
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Projection is available via `select` and `omit` string arrays:
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
const response = await notion.databases.books.findMany({
|
|
268
|
+
where: {
|
|
269
|
+
genre: { contains: "Sci-Fi" },
|
|
270
|
+
},
|
|
271
|
+
select: ["bookName", "genre"],
|
|
118
272
|
});
|
|
119
273
|
```
|
|
120
274
|
|
|
121
|
-
|
|
275
|
+
Successful response shape:
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
[
|
|
279
|
+
{
|
|
280
|
+
bookName: "The Dream Machine",
|
|
281
|
+
genre: ["Non-fiction"],
|
|
282
|
+
},
|
|
283
|
+
]
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Agents
|
|
122
287
|
|
|
123
|
-
|
|
124
|
-
>
|
|
288
|
+
Agents are generated from those shared with your integration and exposed at `notion.agents.*`.
|
|
125
289
|
|
|
126
|
-
|
|
290
|
+
#### Basic chat (non-streaming)
|
|
127
291
|
|
|
128
|
-
|
|
292
|
+
- Useful when you want a straightforward request/response flow.
|
|
293
|
+
- Helpful when you plan to fetch message history after completion.
|
|
129
294
|
|
|
130
|
-
|
|
295
|
+
```ts
|
|
296
|
+
const chat = await notion.agents.yourAgentName.chat({
|
|
297
|
+
message: "Give me a summary of this month",
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
await notion.agents.yourAgentName.pollThread(chat.threadId);
|
|
301
|
+
|
|
302
|
+
const messages = await notion.agents.yourAgentName.getMessages(chat.threadId, {
|
|
303
|
+
role: "agent",
|
|
304
|
+
});
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
#### Continue an existing thread
|
|
308
|
+
|
|
309
|
+
- Useful when you want to preserve context across follow-up prompts.
|
|
310
|
+
- Helpful for chat UIs where users continue the same conversation.
|
|
311
|
+
|
|
312
|
+
```ts
|
|
313
|
+
const nextTurn = await notion.agents.yourAgentName.chat({
|
|
314
|
+
threadId: chat.threadId,
|
|
315
|
+
message: "Now turn that into a grocery list.",
|
|
316
|
+
});
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
#### Streaming patterns
|
|
320
|
+
|
|
321
|
+
How to start a new chat stream (pass `threadId` to resume):
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
import { AgentClient } from "@haustle/notion-orm";
|
|
325
|
+
|
|
326
|
+
const thread = await notion.agents.yourAgentName.chatStream({
|
|
327
|
+
message: "Generate a prep list for that plan.",
|
|
328
|
+
|
|
329
|
+
onMessage: (msg) => {
|
|
330
|
+
if (msg.role === "agent") process.stdout.write(msg.content);
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
const finalResponse = AgentClient.getAgentResponse(thread);
|
|
336
|
+
console.log("Thread ID:", thread.threadId);
|
|
337
|
+
console.log("Final:", finalResponse);
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
See [API Reference](#api-reference) for full method signatures, `ThreadInfo` shape, and message schemas.
|
|
341
|
+
|
|
342
|
+
# API Reference
|
|
343
|
+
|
|
344
|
+
## Runtime access (detailed)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
| runtime property | type | description | go deeper |
|
|
348
|
+
| ------------------ | -------------------------------- | -------------------------------------------------------------- | -------------------------------------------------- |
|
|
349
|
+
| `notion.databases` | `Record<string, DatabaseClient>` | Generated database client map keyed by camelCase database name | [Adding](#adding), [Querying](#querying) |
|
|
350
|
+
| `notion.agents` | `Record<string, AgentClient>` | Generated agent client map keyed by camelCase agent name | [Agents](#agents), [Agent methods](#agent-methods) |
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
## Database client methods
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
| member | kind | description | go deeper |
|
|
357
|
+
| ----------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
358
|
+
| `id` | property | Notion data source ID used by this client instance | - |
|
|
359
|
+
| `name` | property | Human-readable database name captured during generation | - |
|
|
360
|
+
| `findMany({ where?, sortBy?, size?, select?, omit?, stream?, after? })` | method | Queries database pages with typed filters, projection, pagination, or streaming | [Querying](#querying), [Supported database properties](#supported-database-properties) |
|
|
361
|
+
| `findFirst({ where?, sortBy?, select?, omit? })` | method | Returns the first matching row or `null` | [Querying](#querying) |
|
|
362
|
+
| `findUnique({ where: { id }, select?, omit? })` | method | Fetches a row by page ID with optional projection | [Querying](#querying) |
|
|
363
|
+
| `create({ properties, icon?, cover?, markdown? })` | method | Creates a page with optional [markdown body content](https://developers.notion.com/guides/data-apis/working-with-markdown-content#block-type-support) | [Adding](#adding), [Markdown](#adding-page-content-with-markdown) |
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
## Agent methods
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
| member | kind | description | go deeper |
|
|
370
|
+
| ------------------------------------------------ | -------- | --------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
371
|
+
| `id` | property | Notion agent ID used by this client instance | - |
|
|
372
|
+
| `name` | property | Human-readable agent name | - |
|
|
373
|
+
| `icon` | property | Normalized agent icon metadata (or `null`) | - |
|
|
374
|
+
| `listThreads()` | method | Lists recent threads with `id`, `title`, and `status` | [Thread response shapes](#thread-response-shapes) |
|
|
375
|
+
| `getThreadInfo(threadId)` | method | Fetches a single thread record | [Thread response shapes](#thread-response-shapes) |
|
|
376
|
+
| `getThreadTitle(threadId)` | method | Convenience helper to fetch just the thread title | [Thread response shapes](#thread-response-shapes) |
|
|
377
|
+
| `chat({ message, threadId? })` | method | Sends a message and creates/resumes a thread | [Agents](#agents), [Thread response shapes](#thread-response-shapes) |
|
|
378
|
+
| `chatStream({ message, threadId?, onMessage? })` | method | Streams messages and returns final `ThreadInfo` | [Agents](#agents), [Thread response shapes](#thread-response-shapes) |
|
|
379
|
+
| `getMessages(threadId, { role? })` | method | Gets full (or role-filtered) message history | [Thread response shapes](#thread-response-shapes) |
|
|
380
|
+
| `pollThread(threadId, options?)` | method | Polls until thread processing completes | [Thread response shapes](#thread-response-shapes) |
|
|
381
|
+
| `AgentClient.getAgentResponse(threadInfo)` | method | Extract combined plain-text agent output from a streamed thread | [Thread response shapes](#thread-response-shapes) |
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
## Generated exports
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
| import path | what you get | when to use |
|
|
388
|
+
| -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
|
|
389
|
+
| `./notion/` (relative) | `NotionORM` class (generated entry; same as `./notion/index` but shorter) | Typical app code after `**notion sync**` |
|
|
390
|
+
| `./notion/databases/<DatabaseName>.js` | `<DatabaseName>(auth)` factory, `PageSchema`, `CreateSchema`, `QuerySchema`, generated Zod schema, generated option tuples (for select/status/multi-select), schema/type aliases | Script-level direct DB usage without the `NotionORM` wrapper |
|
|
391
|
+
| `./notion/agents/<AgentName>.js` | `<AgentName>(auth)` factory that returns an `AgentClient` (PascalCase export; registry keys on `notion.agents` stay camelCase) | Script-level direct agent usage |
|
|
392
|
+
| `./notion/databases/index.js` | `databases` barrel object (all database factories) | Dynamic database selection or custom registry wiring |
|
|
393
|
+
| `./notion/agents/index.js` | `agents` barrel object (all agent factories) | Dynamic agent selection or custom registry wiring |
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
## Thread response shapes
|
|
397
|
+
|
|
398
|
+
`chatStream(...)` returns `ThreadInfo` with the following properties:
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
| ThreadInfo property | type | description | example |
|
|
402
|
+
| ------------------- | --------------------- | -------------------------------------------------------- | ------------------------------------------------------ |
|
|
403
|
+
| `threadId` | `string` | Stable thread identifier used to continue a conversation | `"1f4e6f4a-5b58-4d91-a7fc-2f5f2a0f6bb1"` |
|
|
404
|
+
| `agentId` | `string` | Agent identifier that produced the response | `"2c3c495da03c8078b95500927f02d213"` |
|
|
405
|
+
| `messages` | `Array<{ role: "user" | "agent"; content: string }>` | Full message history currently available in the thread |
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
`messages` item shape:
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
| message property | type | description |
|
|
412
|
+
| ---------------- | -------- | -------------------------- |
|
|
413
|
+
| `role` | `user` | `agent` (`string`) |
|
|
414
|
+
| `content` | `string` | Plain text message content |
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
## Supported database properties
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
| property_type | expected returned shape | example value |
|
|
421
|
+
| ------------------ | -------------------------------------- | --------------------------------------------- |
|
|
422
|
+
| `title` | `string` | `"The Dream Machine"` |
|
|
423
|
+
| `rich_text` | `string` | `"Long-form notes from the page"` |
|
|
424
|
+
| `number` | `number` | `460` |
|
|
425
|
+
| `date` | `{ start: string; end: string }` | `{ start: "2026-03-01", end: "2026-03-02" }` |
|
|
426
|
+
| `status` | `string` | `"In progress"` |
|
|
427
|
+
| `select` | `string` | `"Non-fiction"` |
|
|
428
|
+
| `multi_select` | `string[]` | `["Sci-Fi", "Biography"]` |
|
|
429
|
+
| `checkbox` | `boolean` | `true` |
|
|
430
|
+
| `email` | `string` | `"tyrus@haustle.studio"` |
|
|
431
|
+
| `phone_number` | `string` | `"0000000000"` |
|
|
432
|
+
| `url` | `string` | `"https://developers.notion.com/"` |
|
|
433
|
+
| `files` | `Array<{ name: string; url: string }>` | `[{ name: "brief.pdf", url: "https://..." }]` |
|
|
434
|
+
| `people` | `string[]` | `["1f4e6f4a-5b58-4d91-a7fc-2f5f2a0f6bb1"]` |
|
|
435
|
+
| `relation` | `string[]` | `["6f7f9cbf-8d45-48f8-a194-661e73f7f5d9"]` |
|
|
436
|
+
| `created_by` | `string` | `"Ada Lovelace"` |
|
|
437
|
+
| `last_edited_by` | `string` | `"user_123"` |
|
|
438
|
+
| `created_time` | `string` | `"2026-03-01T10:30:00.000Z"` |
|
|
439
|
+
| `last_edited_time` | `string` | `"2026-03-01T13:15:00.000Z"` |
|
|
440
|
+
| `unique_id` | `string` | `"TASK-42"` |
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
## Unsupported properties
|
|
444
|
+
|
|
445
|
+
`rollup` and `formula` are intentionally unsupported.
|
|
446
|
+
|
|
447
|
+
- `formula`: Notion computes formula values at read time, and the actual output shape depends on the formula expression and its current result type. That makes it a poor fit for the generated static schema this client exposes. Because we cannot provide a stable contract for reads, writes, or filters, formula properties are skipped entirely during code generation.
|
|
448
|
+
- `rollup`: Rollup values are polymorphic and still need additional normalization before we can expose them as a predictable typed contract.
|
|
449
|
+
|
|
450
|
+
All supported properties can be used in typed filters. Formula properties are not surfaced in the generated client at all, so they are unavailable for selection, filtering, and normalized query results.
|
|
451
|
+
|
|
452
|
+
## Project Structure
|
|
453
|
+
|
|
454
|
+
```txt
|
|
455
|
+
.
|
|
456
|
+
├── src
|
|
457
|
+
│ ├── cli # notion init / add / sync / setup-agents-sdk
|
|
458
|
+
│ ├── config # config discovery, loading, and validation
|
|
459
|
+
│ ├── client # runtime DatabaseClient + AgentClient
|
|
460
|
+
│ │ └── query # typed filters + response simplification
|
|
461
|
+
│ ├── ast # code generation internals
|
|
462
|
+
│ │ ├── database
|
|
463
|
+
│ │ ├── agents
|
|
464
|
+
│ │ └── shared
|
|
465
|
+
│ └── types # local type bridges
|
|
466
|
+
├── plugins # lint/tooling helpers
|
|
467
|
+
└── notion # generated output (after notion sync)
|
|
468
|
+
├── index.* # import as ./notion/
|
|
469
|
+
├── databases
|
|
470
|
+
└── agents
|
|
471
|
+
```
|
|
131
472
|
|
|
132
|
-
This project was started as a way to strengthen my TypeScript knowledge. I’ve succeeded in some regard, but there are still a few `@ts-ignore` in the project.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const AGENTS_SDK_SETUP_COMMAND = "notion setup-agents-sdk";
|
|
2
|
+
export declare const AGENTS_SDK_REPO_URL = "https://github.com/makenotion/notion-agents-sdk-js.git";
|
|
3
|
+
/** Filesystem probe instead of `createRequire` so resolution works the same in Node and other runtimes. */
|
|
4
|
+
export declare function isAgentsSdkAvailable(): boolean;
|
|
5
|
+
export declare function loadAgentsSdk(): Promise<typeof import("@notionhq/agents-client")>;
|
|
6
|
+
/** Inlined so `AgentClient.getAgentResponse` works without eagerly importing the SDK. */
|
|
7
|
+
export declare function stripLangTags(text: string): string;
|
|
8
|
+
//# sourceMappingURL=agents-sdk-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-sdk-resolver.d.ts","sourceRoot":"","sources":["../../src/agents-sdk-resolver.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,wBAAwB,4BAA4B,CAAC;AAElE,eAAO,MAAM,mBAAmB,2DACyB,CAAC;AAM1D,2GAA2G;AAC3G,wBAAgB,oBAAoB,IAAI,OAAO,CAQ9C;AAED,wBAAsB,aAAa,IAAI,OAAO,CAC7C,cAAc,yBAAyB,CAAC,CACxC,CAKA;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
const AGENTS_SDK_PACKAGE = "@notionhq/agents-client";
|
|
4
|
+
export const AGENTS_SDK_SETUP_COMMAND = "notion setup-agents-sdk";
|
|
5
|
+
export const AGENTS_SDK_REPO_URL = "https://github.com/makenotion/notion-agents-sdk-js.git";
|
|
6
|
+
const AGENTS_SDK_MISSING_MESSAGE = `Agent support requires the Notion Agents SDK (paid feature).\n` +
|
|
7
|
+
`Run \`${AGENTS_SDK_SETUP_COMMAND}\` to install it, then run \`notion sync\`.`;
|
|
8
|
+
/** Filesystem probe instead of `createRequire` so resolution works the same in Node and other runtimes. */
|
|
9
|
+
export function isAgentsSdkAvailable() {
|
|
10
|
+
const sdkPackageJson = path.join(process.cwd(), "node_modules", ...AGENTS_SDK_PACKAGE.split("/"), "package.json");
|
|
11
|
+
return fs.existsSync(sdkPackageJson);
|
|
12
|
+
}
|
|
13
|
+
export async function loadAgentsSdk() {
|
|
14
|
+
if (!isAgentsSdkAvailable()) {
|
|
15
|
+
throw new Error(AGENTS_SDK_MISSING_MESSAGE);
|
|
16
|
+
}
|
|
17
|
+
return import(AGENTS_SDK_PACKAGE);
|
|
18
|
+
}
|
|
19
|
+
/** Inlined so `AgentClient.getAgentResponse` works without eagerly importing the SDK. */
|
|
20
|
+
export function stripLangTags(text) {
|
|
21
|
+
return text.replace(/<\/?lang[^>]*>/g, "");
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=agents-sdk-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-sdk-resolver.js","sourceRoot":"","sources":["../../src/agents-sdk-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,kBAAkB,GAAG,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAElE,MAAM,CAAC,MAAM,mBAAmB,GAC/B,wDAAwD,CAAC;AAE1D,MAAM,0BAA0B,GAC/B,gEAAgE;IAChE,SAAS,wBAAwB,6CAA6C,CAAC;AAEhF,2GAA2G;AAC3G,MAAM,UAAU,oBAAoB;IACnC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAC/B,OAAO,CAAC,GAAG,EAAE,EACb,cAAc,EACd,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,EAChC,cAAc,CACd,CAAC;IACF,OAAO,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa;IAGlC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,MAAM,CAAC,kBAAkB,CAAC,CAAC;AACnC,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,aAAa,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AgentIcon } from "../../client/agent/AgentClient";
|
|
2
|
+
import { type CodegenEnvironment } from "../shared/codegen-environment";
|
|
3
|
+
export declare function renderAgentModule(args: {
|
|
4
|
+
agentId: string;
|
|
5
|
+
agentName: string;
|
|
6
|
+
agentIcon: AgentIcon;
|
|
7
|
+
agentModuleName?: string;
|
|
8
|
+
}): {
|
|
9
|
+
tsCode: string;
|
|
10
|
+
agentId: string;
|
|
11
|
+
agentName: string;
|
|
12
|
+
agentModuleName: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function createTypescriptFileForAgent(args: {
|
|
15
|
+
agentId: string;
|
|
16
|
+
agentName: string;
|
|
17
|
+
agentModuleName: string;
|
|
18
|
+
agentIcon: AgentIcon;
|
|
19
|
+
environment: CodegenEnvironment;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=agent-file-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-file-writer.d.ts","sourceRoot":"","sources":["../../../../src/ast/agents/agent-file-writer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAIhE,OAAO,EACN,KAAK,kBAAkB,EAEvB,MAAM,+BAA+B,CAAC;AAwLvC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACxB,CAQA;AAED,wBAAsB,4BAA4B,CAAC,IAAI,EAAE;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,kBAAkB,CAAC;CAChC,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBhB"}
|