@elumixor/notion-orm 2.1.1 → 2.1.3
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 +0 -3
- package/dist/cli.js +3 -3
- package/dist/db-client/add.d.ts +4 -0
- package/dist/index.js +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,9 +44,6 @@ Generates `generated/notion-orm/` with a typed client per database and an `index
|
|
|
44
44
|
import { NotionORM } from "../generated/notion-orm";
|
|
45
45
|
|
|
46
46
|
const notion = new NotionORM(process.env.NOTION_API_KEY);
|
|
47
|
-
|
|
48
|
-
// or with a config object
|
|
49
|
-
const notion = new NotionORM({ auth: process.env.NOTION_API_KEY });
|
|
50
47
|
```
|
|
51
48
|
|
|
52
49
|
## API
|
package/dist/cli.js
CHANGED
|
@@ -174122,7 +174122,7 @@ function writeNotionORMFile(databasesDirPath, databasesMetadata) {
|
|
|
174122
174122
|
fs3.mkdirSync(databasesDirPath, { recursive: true });
|
|
174123
174123
|
if (databasesMetadata.length === 0) {
|
|
174124
174124
|
writeWithJs(notionORMFile, `export class NotionORM {
|
|
174125
|
-
constructor(_auth: string
|
|
174125
|
+
constructor(_auth: string) {}
|
|
174126
174126
|
}
|
|
174127
174127
|
`);
|
|
174128
174128
|
return;
|
|
@@ -174131,14 +174131,14 @@ function writeNotionORMFile(databasesDirPath, databasesMetadata) {
|
|
|
174131
174131
|
`);
|
|
174132
174132
|
const properties = databasesMetadata.map(({ camelCaseName }) => ` public ${camelCaseName}: ReturnType<typeof ${camelCaseName}>;`).join(`
|
|
174133
174133
|
`);
|
|
174134
|
-
const assignments = databasesMetadata.map(({ camelCaseName }) => ` this.${camelCaseName} = ${camelCaseName}(
|
|
174134
|
+
const assignments = databasesMetadata.map(({ camelCaseName }) => ` this.${camelCaseName} = ${camelCaseName}(auth);`).join(`
|
|
174135
174135
|
`);
|
|
174136
174136
|
const tsCode = `${imports}
|
|
174137
174137
|
|
|
174138
174138
|
export class NotionORM {
|
|
174139
174139
|
${properties}
|
|
174140
174140
|
|
|
174141
|
-
constructor(auth: string
|
|
174141
|
+
constructor(auth: string) {
|
|
174142
174142
|
${assignments}
|
|
174143
174143
|
}
|
|
174144
174144
|
}
|
package/dist/db-client/add.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1388,6 +1388,8 @@ function buildPropertyValueForAddPage(args) {
|
|
|
1388
1388
|
return phoneNumberCall({ value });
|
|
1389
1389
|
} else if (type === "url" && typeof value === "string") {
|
|
1390
1390
|
return urlCall({ url: value });
|
|
1391
|
+
} else if (type === "relation" && Array.isArray(value)) {
|
|
1392
|
+
return relationCall({ ids: value });
|
|
1391
1393
|
} else if (type === "checkbox" && typeof value === "boolean") {
|
|
1392
1394
|
return checkboxCall({ checked: value });
|
|
1393
1395
|
} else if (type === "title" && typeof value === "string") {
|
|
@@ -1463,6 +1465,9 @@ var emailCall = (args) => {
|
|
|
1463
1465
|
const { value } = args;
|
|
1464
1466
|
return { email: value };
|
|
1465
1467
|
};
|
|
1468
|
+
var relationCall = (args) => {
|
|
1469
|
+
return { relation: args.ids.map((id) => ({ id })) };
|
|
1470
|
+
};
|
|
1466
1471
|
|
|
1467
1472
|
// src/db-client/query.ts
|
|
1468
1473
|
function buildQueryResponse(res, camelPropertyNameToNameAndTypeMap, validateSchema, meta) {
|