Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export all models as a top-level export #534

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

### Unreleased
* Models can now directly be imported from the top-level `nylas` package

### 7.0.0 / 2024-02-05
* **BREAKING CHANGE**: Node SDK v7 supports the Nylas API v3 exclusively, dropping support for any endpoints that are not available in v3.
* **BREAKING CHANGE**: Convert `Nylas` class from a static to a non-static class
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"lint:prettier:check": "prettier --check '**/*.{ts,js}'",
"export-version": "node scripts/exportVersion.js",
"generate-lib-package-json": "node scripts/generateLibPackageJson.js",
"prebuild": "npm run export-version",
"generate-model-index": "node scripts/generateModelIndex.js",
"prebuild": "npm run export-version && npm run generate-model-index",
"build": "rm -rf lib && npm run build-esm && npm run build-cjs && npm run generate-lib-package-json",
"build-esm": "tsc -p tsconfig.esm.json",
"build-cjs": "tsc -p tsconfig.cjs.json",
Expand Down
15 changes: 15 additions & 0 deletions scripts/generateModelIndex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fs = require('fs');
const path = require('path');

const comment = '// This file is generated by scripts/generateModelIndex.js\n';
const modelsDir = path.join(__dirname, '..', 'src', 'models');
let indexContent = '';

fs.readdirSync(modelsDir).forEach(file => {
if (file.endsWith('.ts') && file !== 'index.ts') {
const modelName = file.replace('.ts', '.js');
indexContent += `export * from './${modelName}';\n`;
}
});

fs.writeFileSync(path.join(modelsDir, 'index.ts'), comment + indexContent);
22 changes: 22 additions & 0 deletions src/models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This file is generated by scripts/generateModelIndex.js
export * from './applicationDetails.js';
export * from './attachments.js';
export * from './auth.js';
export * from './availability.js';
export * from './calendars.js';
export * from './connectors.js';
export * from './contacts.js';
export * from './credentials.js';
export * from './drafts.js';
export * from './error.js';
export * from './events.js';
export * from './folders.js';
export * from './freeBusy.js';
export * from './grants.js';
export * from './listQueryParams.js';
export * from './messages.js';
export * from './redirectUri.js';
export * from './response.js';
export * from './smartCompose.js';
export * from './threads.js';
export * from './webhooks.js';
2 changes: 2 additions & 0 deletions src/nylas.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './models/index.js';

import APIClient from './apiClient.js';
import { NylasConfig, DEFAULT_SERVER_URL } from './config.js';
import { Calendars } from './resources/calendars.js';
Expand Down
Loading